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