3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
14 #ifndef LYX_PREAMBLE_H
15 #define LYX_PREAMBLE_H
30 class TeX2LyXDocClass;
38 std::string inputencoding() const { return h_inputencoding; }
40 std::string notefontcolor() const { return h_notefontcolor; }
42 std::string refstyle() const { return h_use_refstyle; }
44 bool fontCJKSet() const { return h_font_cjk_set; }
46 std::string fontCJK() const { return h_font_cjk; }
48 void fontCJK(std::string const & f) { h_font_cjk_set = true; h_font_cjk = f; }
49 /// The document language
50 std::string docLanguage() const { return h_language; }
51 /// The language of text which is not explicitly marked
52 std::string defaultLanguage() const { return default_language; }
54 std::string use_indices() const { return h_use_indices; }
56 std::string polyglossia2lyx(std::string const & language);
58 bool indentParagraphs() const;
60 bool isPackageUsed(std::string const & package) const;
62 std::vector<std::string>
63 getPackageOptions(std::string const & package) const;
64 /// Tell that \p package will be loaded automatically by LyX.
65 /// This has only an effect if \p package is prepared for
66 /// autoloading in parse().
67 void registerAutomaticallyLoadedPackage(std::string const & package);
69 void addModule(std::string const & module);
71 void suppressDate(bool suppress);
73 std::string citeEngine() const { return h_cite_engine; }
75 void citeEngine(std::string const & e) { h_cite_engine = e; }
77 bool titleLayoutFound() const { return title_layout_found; }
79 void titleLayoutFound(bool found) { title_layout_found = found; }
80 /// Register an author named \p name in the author list
81 void registerAuthor(std::string const & name);
82 /// Get author named \p name (must be registered first)
83 Author const & getAuthor(std::string const & name) const;
85 /// Parses the LaTeX preamble into internal data
86 void parse(Parser & p, std::string const & forceclass,
87 TeX2LyXDocClass & tc);
88 /// Writes the LyX file header from internal data
89 bool writeLyXHeader(std::ostream & os, bool subdoc);
91 /// known polyglossia language names (including variants)
92 static const char * const polyglossia_languages[];
93 /// the same as polyglossia_languages with .lyx names
94 static const char * const coded_polyglossia_languages[];
98 std::map<std::string, std::vector<std::string> > used_packages;
99 /// Packages that will be loaded automatically by LyX
100 std::set<std::string> auto_packages;
102 std::vector<std::string> used_modules;
104 /// needed to handle encodings with babel
106 /// the main non-CJK language
107 std::string default_language;
109 /// was at least one title layout found?
110 bool title_layout_found;
112 std::ostringstream h_preamble;
113 std::string h_backgroundcolor;
114 std::string h_biblio_style;
115 std::string h_bibtex_command;
116 std::string h_boxbgcolor;
117 std::string h_cite_engine;
118 std::string h_cite_engine_type;
120 std::string h_defskip;
121 std::string h_float_placement;
122 std::string h_fontcolor;
123 std::string h_fontencoding;
124 std::string h_font_math;
125 std::string h_font_roman;
126 std::string h_font_sans;
127 std::string h_font_typewriter;
128 std::string h_font_default_family;
129 std::string h_use_non_tex_fonts;
130 std::string h_font_sc;
131 std::string h_font_osf;
132 std::string h_font_sf_scale;
133 std::string h_font_tt_scale;
135 std::string h_font_cjk;
136 std::string h_graphics;
137 std::string h_default_output_format;
138 std::string h_html_be_strict;
139 std::string h_html_css_as_file;
140 std::string h_html_math_output;
142 std::string h_index_command;
143 std::string h_inputencoding;
144 std::string h_justification;
145 std::string h_language;
146 std::string h_language_package;
147 std::string h_listings_params;
148 std::string h_maintain_unincluded_children;
149 std::string h_margins;
150 std::string h_notefontcolor;
151 std::string h_options;
152 std::string h_output_changes;
153 std::string h_output_sync;
154 std::string h_output_sync_macro;
155 std::string h_papercolumns;
156 std::string h_paperfontsize;
157 std::string h_paperorientation;
158 std::string h_paperpagestyle;
159 std::string h_papersides;
160 std::string h_papersize;
161 std::string h_paragraph_indentation;
162 /// necessary to set the separation when \setlength is parsed
163 std::string h_paragraph_separation;
164 std::string h_pdf_title;
165 std::string h_pdf_author;
166 std::string h_pdf_subject;
167 std::string h_pdf_keywords;
168 std::string h_pdf_bookmarks;
169 std::string h_pdf_bookmarksnumbered;
170 std::string h_pdf_bookmarksopen;
171 std::string h_pdf_bookmarksopenlevel;
172 std::string h_pdf_breaklinks;
173 std::string h_pdf_pdfborder;
174 std::string h_pdf_colorlinks;
175 std::string h_pdf_backref;
176 std::string h_pdf_pdfusetitle;
177 std::string h_pdf_pagemode;
178 std::string h_pdf_quoted_options;
179 std::string h_quotes_language;
180 std::string h_secnumdepth;
181 std::string h_shortcut;
182 std::string h_spacing;
183 std::string h_suppress_date;
184 std::string h_textclass;
185 std::string h_tocdepth;
186 std::string h_tracking_changes;
187 std::string h_use_bibtopic;
188 std::string h_use_indices;
189 std::string h_use_geometry;
190 std::map<std::string, std::string> h_use_packages;
191 std::string h_use_default_options;
192 std::string h_use_hyperref;
193 std::string h_use_refstyle;
196 * Add package \p name with options \p options to used_packages.
197 * Remove options from \p options that we don't want to output.
199 void add_package(std::string const & name,
200 std::vector<std::string> & options);
202 void handle_hyperref(std::vector<std::string> & options);
204 void handle_geometry(std::vector<std::string> & options);
206 void handle_package(Parser &p, std::string const & name,
207 std::string const & opts, bool in_lyx_preamble);
209 void handle_if(Parser & p, bool in_lyx_preamble);
215 extern Preamble preamble;