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