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