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