]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/Preamble.h
Remove 3rdparty/boost/Makefile.am
[lyx.git] / src / tex2lyx / Preamble.h
1 /**
2  * \file Preamble.h
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  * \author Uwe Stöhr
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 // {[(
13
14 #ifndef LYX_PREAMBLE_H
15 #define LYX_PREAMBLE_H
16
17 #include "Author.h"
18
19 #include <iosfwd>
20 #include <sstream>
21 #include <string>
22 #include <vector>
23 #include <map>
24 #include <set>
25
26
27 namespace lyx {
28
29 class Parser;
30 class TeX2LyXDocClass;
31
32 class Preamble
33 {
34 public:
35         Preamble();
36
37         ///
38         std::string inputencoding() const { return h_inputencoding; }
39         ///
40         void setInputencoding(std::string const & e) { h_inputencoding = e; }
41         ///
42         std::string notefontcolor() const { return h_notefontcolor; }
43         ///
44         bool refstyle() const { return h_use_refstyle; }
45         ///
46         bool fontCJKSet() const { return h_font_cjk_set; }
47         ///
48         std::string fontCJK() const { return h_font_cjk; }
49         ///
50         void fontCJK(std::string const & f) { h_font_cjk_set = true; h_font_cjk = f; }
51         ///
52         bool minted() const { return h_use_minted; }
53         /// The document language
54         std::string docLanguage() const { return h_language; }
55         /// The language of text which is not explicitly marked
56         std::string defaultLanguage() const  { return default_language; }
57         /// The quotation marks style
58         std::string quotesStyle() const { return h_quotes_style; }
59         ///
60         bool usePolyglossia() const;
61         ///
62         std::string use_indices() const { return h_use_indices; }
63         ///
64         std::string polyglossia2lyx(std::string const & language);
65         ///
66         bool indentParagraphs() const;
67         ///
68         bool isPackageUsed(std::string const & package) const;
69         ///
70         bool isPackageAutoLoaded(std::string const & package) const;
71         ///
72         std::vector<std::string>
73         getPackageOptions(std::string const & package) const;
74         /// Tell that \p package will be loaded automatically by LyX.
75         /// This has only an effect if \p package is prepared for
76         /// autoloading in parse().
77         void registerAutomaticallyLoadedPackage(std::string const & package);
78         ///
79         void addModule(std::string const & module);
80         ///
81         void suppressDate(bool suppress);
82         ///
83         std::string citeEngine() const { return h_cite_engine; }
84         ///
85         void citeEngine(std::string const & e) { h_cite_engine = e; }
86         ///
87         std::string multibib() const { return h_multibib; }
88         ///
89         void multibib(std::string const & s) { h_multibib = s; }
90         ///
91         bool titleLayoutFound() const { return title_layout_found; }
92         ///
93         void titleLayoutFound(bool found) { title_layout_found = found; }
94         /// Register an author named \p name in the author list
95         void registerAuthor(std::string const & name, std::string const & initials);
96         /// Get author named \p name (must be registered first)
97         Author const & getAuthor(std::string const & name) const;
98         /// Set text class
99         void setTextClass(std::string const & tclass, TeX2LyXDocClass & tc);
100         /// Get number of arguments of special table column type \c or -1
101         /// if no column type \p c exists
102         int getSpecialTableColumnArguments(char c) const;
103
104         /// Parses the LaTeX preamble into internal data
105         void parse(Parser & p, std::string const & forceclass,
106                    TeX2LyXDocClass & tc);
107         /// Parse the encoding from a preamble. *this is unusable afterwards.
108         std::string parseEncoding(Parser & p, std::string const & forceclass);
109         /// Writes the LyX file header from internal data
110         bool writeLyXHeader(std::ostream & os, bool subdoc,
111                             std::string const & outfiledir);
112
113         /// known polyglossia language names (including variants)
114         static const char * const polyglossia_languages[];
115         /// the same as polyglossia_languages with .lyx names
116         static const char * const coded_polyglossia_languages[];
117         ///
118         std::vector<std::string> biblatex_bibliographies;
119         ///
120         std::vector<std::string> biblatex_encodings;
121         ///
122         std::string bibencoding;
123         ///
124         std::string docencoding;
125
126 private:
127         ///
128         void parse(Parser & p, std::string const & forceclass,
129                    bool detectEncoding, TeX2LyXDocClass & tc);
130         ///
131         std::map<std::string, std::vector<std::string> > used_packages;
132         /// Packages that will be loaded automatically by LyX
133         std::set<std::string> auto_packages;
134         ///
135         std::vector<std::string> used_modules;
136
137         /// needed to handle encodings with babel
138         bool one_language;
139         /// the main non-CJK language
140         std::string default_language;
141         /// Was babel called explicitly?
142         bool explicit_babel;
143
144         /// was at least one title layout found?
145         bool title_layout_found;
146
147         /// used for the handling of \newindex
148         int index_number;
149
150         std::ostringstream h_preamble;
151         std::string h_backgroundcolor;
152         std::string h_multibib;
153         std::string h_biblio_style;
154         std::string h_biblio_options;
155         std::string h_biblatex_bibstyle;
156         std::string h_biblatex_citestyle;
157         std::string h_bibtex_command;
158         std::string h_boxbgcolor;
159         std::string h_cite_engine;
160         std::string h_cite_engine_type;
161         std::string h_color;
162         std::string h_defskip;
163         bool h_dynamic_quotes;
164         std::string h_float_placement;
165         std::string h_fontcolor;
166         std::string h_fontencoding;
167         std::string h_font_math[2];
168         std::string h_font_roman[2];
169         std::string h_font_sans[2];
170         std::string h_font_typewriter[2];
171         std::string h_font_roman_opts;
172         std::string h_font_sans_opts;
173         std::string h_font_typewriter_opts;
174         std::string h_font_default_family;
175         bool h_use_non_tex_fonts;
176         std::string h_font_sc;
177         std::string h_font_roman_osf;
178         std::string h_font_sans_osf;
179         std::string h_font_typewriter_osf;
180         std::string h_font_sf_scale[2];
181         std::string h_font_tt_scale[2];
182         bool h_font_cjk_set;
183         std::string h_font_cjk;
184         std::string h_use_microtype;
185         std::string h_use_lineno;
186         std::string h_lineno_options;
187         std::string h_is_mathindent;
188         std::string h_math_numbering_side;
189         std::string h_mathindentation;
190         std::string h_graphics;
191         std::string h_default_output_format;
192         std::string h_html_be_strict;
193         std::string h_html_css_as_file;
194         std::string h_html_math_output;
195         std::string h_docbook_table_output;
196         std::string h_index[99];
197         std::string h_index_command;
198         std::string h_inputencoding;
199         std::string h_justification;
200         std::string h_language;
201         std::string h_language_package;
202         std::string h_listings_params;
203         std::string h_maintain_unincluded_children;
204         std::string h_margins;
205         std::string h_notefontcolor;
206         std::string h_options;
207         std::string h_output_changes;
208         std::string h_change_bars;
209         std::string h_output_sync;
210         std::string h_output_sync_macro;
211         std::string h_papercolumns;
212         std::string h_paperfontsize;
213         std::string h_paperorientation;
214         std::string h_paperpagestyle;
215         std::string h_papersides;
216         std::string h_papersize;
217         std::string h_paragraph_indentation;
218         /// necessary to set the separation when \setlength is parsed
219         std::string h_paragraph_separation;
220         std::string h_pdf_title;
221         std::string h_pdf_author;
222         std::string h_pdf_subject;
223         std::string h_pdf_keywords;
224         std::string h_pdf_bookmarks;
225         std::string h_pdf_bookmarksnumbered;
226         std::string h_pdf_bookmarksopen;
227         std::string h_pdf_bookmarksopenlevel;
228         std::string h_pdf_breaklinks;
229         std::string h_pdf_pdfborder;
230         std::string h_pdf_colorlinks;
231         std::string h_pdf_backref;
232         std::string h_pdf_pdfusetitle;
233         std::string h_pdf_pagemode;
234         std::string h_pdf_quoted_options;
235         std::string h_quotes_style;
236         std::string h_secnumdepth;
237         std::string h_shortcut[99];
238         std::string h_spacing;
239         std::string h_suppress_date;
240         std::string h_save_transient_properties;
241         std::string h_textclass;
242         std::string h_tocdepth;
243         std::string h_tracking_changes;
244         std::string h_use_bibtopic;
245         std::string h_use_dash_ligatures;
246         std::string h_use_indices;
247         std::string h_use_geometry;
248         std::map<std::string, std::string> h_use_packages;
249         std::string h_use_default_options;
250         std::string h_use_hyperref;
251         std::vector<std::string> h_includeonlys;
252         bool h_use_refstyle;
253         bool h_use_minted;
254
255         /*!
256          * Add package \p name with options \p options to used_packages.
257          * Remove options from \p options that we don't want to output.
258          */
259         void add_package(std::string const & name,
260                          std::vector<std::string> & options);
261         ///
262         void handle_hyperref(std::vector<std::string> & options);
263         ///
264         void handle_geometry(std::vector<std::string> & options);
265         ///
266         void handle_package(Parser &p, std::string const & name,
267                             std::string const & opts, bool in_lyx_preamble,
268                             bool detectEncoding);
269         ///
270         void handle_if(Parser & p, bool in_lyx_preamble);
271
272         ///
273         AuthorList authors_;
274         /// special table column types
275         std::map<char, int> special_columns_;
276         ///
277         std::map<std::string, std::string> extra_package_options_;
278 };
279
280
281 extern Preamble preamble;
282
283 // }])
284
285
286 } // namespace lyx
287
288 #endif