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