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