]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/Preamble.h
tex2lyx: support for btUnit (multibib)
[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         std::vector<std::string>
71         getPackageOptions(std::string const & package) const;
72         /// Tell that \p package will be loaded automatically by LyX.
73         /// This has only an effect if \p package is prepared for
74         /// autoloading in parse().
75         void registerAutomaticallyLoadedPackage(std::string const & package);
76         ///
77         void addModule(std::string const & module);
78         ///
79         void suppressDate(bool suppress);
80         ///
81         std::string citeEngine() const { return h_cite_engine; }
82         ///
83         void citeEngine(std::string const & e) { h_cite_engine = e; }
84         ///
85         void multibib(std::string const & s) { h_multibib = s; }
86         ///
87         bool titleLayoutFound() const { return title_layout_found; }
88         ///
89         void titleLayoutFound(bool found) { title_layout_found = found; }
90         /// Register an author named \p name in the author list
91         void registerAuthor(std::string const & name);
92         /// Get author named \p name (must be registered first)
93         Author const & getAuthor(std::string const & name) const;
94         /// Get number of arguments of special table column type \c or -1
95         /// if no column type \p c exists
96         int getSpecialTableColumnArguments(char c) const;
97
98         /// Parses the LaTeX preamble into internal data
99         void parse(Parser & p, std::string const & forceclass,
100                    TeX2LyXDocClass & tc);
101         /// Parse the encoding from a preamble. *this is unusable afterwards.
102         std::string parseEncoding(Parser & p, std::string const & forceclass);
103         /// Writes the LyX file header from internal data
104         bool writeLyXHeader(std::ostream & os, bool subdoc,
105                             std::string const & outfiledir);
106
107         /// known polyglossia language names (including variants)
108         static const char * const polyglossia_languages[];
109         /// the same as polyglossia_languages with .lyx names
110         static const char * const coded_polyglossia_languages[];
111         ///
112         std::vector<std::string> biblatex_bibliographies;
113         ///
114         std::string bibencoding;
115         ///
116         std::string docencoding;
117
118 private:
119         ///
120         void parse(Parser & p, std::string const & forceclass,
121                    bool detectEncoding, TeX2LyXDocClass & tc);
122         ///
123         std::map<std::string, std::vector<std::string> > used_packages;
124         /// Packages that will be loaded automatically by LyX
125         std::set<std::string> auto_packages;
126         ///
127         std::vector<std::string> used_modules;
128
129         /// needed to handle encodings with babel
130         bool one_language;
131         /// the main non-CJK language
132         std::string default_language;
133         /// Was babel called explicitly?
134         bool explicit_babel;
135
136         /// was at least one title layout found?
137         bool title_layout_found;
138
139         /// used for the handling of \newindex
140         int index_number;
141
142         std::ostringstream h_preamble;
143         std::string h_backgroundcolor;
144         std::string h_multibib;
145         std::string h_biblio_style;
146         std::string h_biblio_options;
147         std::string h_biblatex_bibstyle;
148         std::string h_biblatex_citestyle;
149         std::string h_bibtex_command;
150         std::string h_boxbgcolor;
151         std::string h_cite_engine;
152         std::string h_cite_engine_type;
153         std::string h_color;
154         std::string h_defskip;
155         bool h_dynamic_quotes;
156         std::string h_float_placement;
157         std::string h_fontcolor;
158         std::string h_fontencoding;
159         std::string h_font_math[2];
160         std::string h_font_roman[2];
161         std::string h_font_sans[2];
162         std::string h_font_typewriter[2];
163         std::string h_font_default_family;
164         bool h_use_non_tex_fonts;
165         std::string h_font_sc;
166         std::string h_font_osf;
167         std::string h_font_sf_scale[2];
168         std::string h_font_tt_scale[2];
169         bool h_font_cjk_set;
170         std::string h_font_cjk;
171         std::string h_use_microtype;
172         std::string h_is_mathindent;
173         std::string h_math_numbering_side;
174         std::string h_mathindentation;
175         std::string h_graphics;
176         std::string h_default_output_format;
177         std::string h_html_be_strict;
178         std::string h_html_css_as_file;
179         std::string h_html_math_output;
180         std::string h_index[99];
181         std::string h_index_command;
182         std::string h_inputencoding;
183         std::string h_justification;
184         std::string h_language;
185         std::string h_language_package;
186         std::string h_listings_params;
187         std::string h_maintain_unincluded_children;
188         std::string h_margins;
189         std::string h_notefontcolor;
190         std::string h_options;
191         std::string h_output_changes;
192         std::string h_output_sync;
193         std::string h_output_sync_macro;
194         std::string h_papercolumns;
195         std::string h_paperfontsize;
196         std::string h_paperorientation;
197         std::string h_paperpagestyle;
198         std::string h_papersides;
199         std::string h_papersize;
200         std::string h_paragraph_indentation;
201         /// necessary to set the separation when \setlength is parsed
202         std::string h_paragraph_separation;
203         std::string h_pdf_title;
204         std::string h_pdf_author;
205         std::string h_pdf_subject;
206         std::string h_pdf_keywords;
207         std::string h_pdf_bookmarks;
208         std::string h_pdf_bookmarksnumbered;
209         std::string h_pdf_bookmarksopen;
210         std::string h_pdf_bookmarksopenlevel;
211         std::string h_pdf_breaklinks;
212         std::string h_pdf_pdfborder;
213         std::string h_pdf_colorlinks;
214         std::string h_pdf_backref;
215         std::string h_pdf_pdfusetitle;
216         std::string h_pdf_pagemode;
217         std::string h_pdf_quoted_options;
218         std::string h_quotes_style;
219         std::string h_secnumdepth;
220         std::string h_shortcut[99];
221         std::string h_spacing;
222         std::string h_suppress_date;
223         std::string h_save_transient_properties;
224         std::string h_textclass;
225         std::string h_tocdepth;
226         std::string h_tracking_changes;
227         std::string h_use_bibtopic;
228         std::string h_use_dash_ligatures;
229         std::string h_use_indices;
230         std::string h_use_geometry;
231         std::map<std::string, std::string> h_use_packages;
232         std::string h_use_default_options;
233         std::string h_use_hyperref;
234         std::vector<std::string> h_includeonlys;
235         bool h_use_refstyle;
236         bool h_use_minted;
237
238         /*!
239          * Add package \p name with options \p options to used_packages.
240          * Remove options from \p options that we don't want to output.
241          */
242         void add_package(std::string const & name,
243                          std::vector<std::string> & options);
244         ///
245         void handle_hyperref(std::vector<std::string> & options);
246         ///
247         void handle_geometry(std::vector<std::string> & options);
248         ///
249         void handle_package(Parser &p, std::string const & name,
250                             std::string const & opts, bool in_lyx_preamble,
251                             bool detectEncoding);
252         ///
253         void handle_if(Parser & p, bool in_lyx_preamble);
254
255         ///
256         AuthorList authors_;
257         /// special table column types
258         std::map<char, int> special_columns_;
259         ///
260         std::map<std::string, std::string> extra_package_options_;
261 };
262
263
264 extern Preamble preamble;
265
266 // }])
267
268
269 } // namespace lyx
270
271 #endif