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