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