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; }
41 /// The document language
42 std::string docLanguage() const { return h_language; }
43 /// The language of text which is not explicitly marked
44 std::string defaultLanguage() const { return default_language; }
46 std::string use_indices() const { return h_use_indices; }
48 std::string polyglossia2lyx(std::string const & language);
50 bool indentParagraphs() const;
52 bool isPackageUsed(std::string const & package) const;
54 std::vector<std::string>
55 getPackageOptions(std::string const & package) const;
56 /// Tell that \p package will be loaded automatically by LyX.
57 /// This has only an effect if \p package is prepared for
58 /// autoloading in parse().
59 void registerAutomaticallyLoadedPackage(std::string const & package);
61 void addModule(std::string const & module);
63 void suppressDate(bool suppress);
65 bool titleLayoutFound() const { return title_layout_found; }
67 void titleLayoutFound(bool found) { title_layout_found = found; }
68 /// Register an author named \p name in the author list
69 void registerAuthor(std::string const & name);
70 /// Get author named \p name (must be registered first)
71 Author const & getAuthor(std::string const & name) const;
73 /// Parses the LaTeX preamble into internal data
74 void parse(Parser & p, std::string const & forceclass,
75 TeX2LyXDocClass & tc);
76 /// Writes the LyX file header from internal data
77 bool writeLyXHeader(std::ostream & os, bool subdoc);
79 /// known polyglossia language names (including variants)
80 static const char * const polyglossia_languages[];
81 /// the same as polyglossia_languages with .lyx names
82 static const char * const coded_polyglossia_languages[];
86 std::map<std::string, std::vector<std::string> > used_packages;
87 /// Packages that will be loaded automatically by LyX
88 std::set<std::string> auto_packages;
90 std::vector<std::string> used_modules;
92 /// needed to handle encodings with babel
94 /// the main non-CJK language
95 std::string default_language;
97 /// was at least one title layout found?
98 bool title_layout_found;
100 std::ostringstream h_preamble;
101 std::string h_backgroundcolor;
102 std::string h_biblio_style;
103 std::string h_bibtex_command;
104 std::string h_boxbgcolor;
105 std::string h_cite_engine;
106 std::string h_cite_engine_type;
108 std::string h_defskip;
109 std::string h_float_placement;
110 std::string h_fontcolor;
111 std::string h_fontencoding;
112 std::string h_font_math;
113 std::string h_font_roman;
114 std::string h_font_sans;
115 std::string h_font_typewriter;
116 std::string h_font_default_family;
117 std::string h_use_non_tex_fonts;
118 std::string h_font_sc;
119 std::string h_font_osf;
120 std::string h_font_sf_scale;
121 std::string h_font_tt_scale;
122 std::string h_graphics;
123 std::string h_default_output_format;
124 std::string h_html_be_strict;
125 std::string h_html_css_as_file;
126 std::string h_html_math_output;
128 std::string h_index_command;
129 std::string h_inputencoding;
130 std::string h_justification;
131 std::string h_language;
132 std::string h_language_package;
133 std::string h_listings_params;
134 std::string h_maintain_unincluded_children;
135 std::string h_margins;
136 std::string h_notefontcolor;
137 std::string h_options;
138 std::string h_output_changes;
139 std::string h_output_sync;
140 std::string h_output_sync_macro;
141 std::string h_papercolumns;
142 std::string h_paperfontsize;
143 std::string h_paperorientation;
144 std::string h_paperpagestyle;
145 std::string h_papersides;
146 std::string h_papersize;
147 std::string h_paragraph_indentation;
148 /// necessary to set the separation when \setlength is parsed
149 std::string h_paragraph_separation;
150 std::string h_pdf_title;
151 std::string h_pdf_author;
152 std::string h_pdf_subject;
153 std::string h_pdf_keywords;
154 std::string h_pdf_bookmarks;
155 std::string h_pdf_bookmarksnumbered;
156 std::string h_pdf_bookmarksopen;
157 std::string h_pdf_bookmarksopenlevel;
158 std::string h_pdf_breaklinks;
159 std::string h_pdf_pdfborder;
160 std::string h_pdf_colorlinks;
161 std::string h_pdf_backref;
162 std::string h_pdf_pdfusetitle;
163 std::string h_pdf_pagemode;
164 std::string h_pdf_quoted_options;
165 std::string h_quotes_language;
166 std::string h_secnumdepth;
167 std::string h_shortcut;
168 std::string h_spacing;
169 std::string h_suppress_date;
170 std::string h_textclass;
171 std::string h_tocdepth;
172 std::string h_tracking_changes;
173 std::string h_use_bibtopic;
174 std::string h_use_indices;
175 std::string h_use_geometry;
176 std::map<std::string, std::string> h_use_packages;
177 std::string h_use_default_options;
178 std::string h_use_hyperref;
179 std::string h_use_refstyle;
182 * Add package \p name with options \p options to used_packages.
183 * Remove options from \p options that we don't want to output.
185 void add_package(std::string const & name,
186 std::vector<std::string> & options);
188 void handle_hyperref(std::vector<std::string> & options);
190 void handle_geometry(std::vector<std::string> & options);
192 void handle_package(Parser &p, std::string const & name,
193 std::string const & opts, bool in_lyx_preamble);
195 void handle_if(Parser & p, bool in_lyx_preamble);
201 extern Preamble preamble;