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