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