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