]> git.lyx.org Git - lyx.git/blob - src/tex2lyx/Preamble.h
14a759796536970a54dd6d28aba8d821332be0bd
[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_defskip;
87         std::string h_float_placement;
88         std::string h_fontcolor;
89         std::string h_fontencoding;
90         std::string h_font_roman;
91         std::string h_font_sans;
92         std::string h_font_typewriter;
93         std::string h_font_default_family;
94         std::string h_font_sc;
95         std::string h_font_osf;
96         std::string h_font_sf_scale;
97         std::string h_font_tt_scale;
98         std::string h_graphics;
99         std::string h_html_be_strict;
100         std::string h_html_css_as_file;
101         std::string h_html_math_output;
102         std::string h_inputencoding;
103         std::string h_justification;
104         std::string h_language;
105         std::string h_language_package;
106         std::string h_listings_params;
107         std::string h_margins;
108         std::string h_notefontcolor;
109         std::string h_options;
110         std::string h_output_changes;
111         std::string h_papercolumns;
112         std::string h_paperfontsize;
113         std::string h_paperorientation;
114         std::string h_paperpagestyle;
115         std::string h_papersides;
116         std::string h_papersize;
117         std::string h_paragraph_indentation;
118         /// necessary to set the separation when \setlength is parsed
119         std::string h_paragraph_separation;
120         std::string h_pdf_title;
121         std::string h_pdf_author;
122         std::string h_pdf_subject;
123         std::string h_pdf_keywords;
124         std::string h_pdf_bookmarks;
125         std::string h_pdf_bookmarksnumbered;
126         std::string h_pdf_bookmarksopen;
127         std::string h_pdf_bookmarksopenlevel;
128         std::string h_pdf_breaklinks;
129         std::string h_pdf_pdfborder;
130         std::string h_pdf_colorlinks;
131         std::string h_pdf_backref;
132         std::string h_pdf_pdfusetitle;
133         std::string h_pdf_pagemode;
134         std::string h_pdf_quoted_options;
135         std::string h_quotes_language;
136         std::string h_secnumdepth;
137         std::string h_spacing;
138         std::string h_suppress_date;
139         std::string h_textclass;
140         std::string h_tocdepth;
141         std::string h_tracking_changes;
142         std::string h_use_bibtopic;
143         std::string h_use_indices;
144         std::string h_use_geometry;
145         std::string h_use_amsmath;
146         std::string h_use_default_options;
147         std::string h_use_esint;
148         std::string h_use_hyperref;
149         std::string h_use_mhchem;
150         std::string h_use_mathdots;
151         std::string h_use_refstyle;
152         std::string h_use_undertilde;
153
154         /*!
155          * Add package \p name with options \p options to used_packages.
156          * Remove options from \p options that we don't want to output.
157          */
158         void add_package(std::string const & name,
159                          std::vector<std::string> & options);
160         ///
161         void handle_hyperref(std::vector<std::string> & options);
162         ///
163         void handle_geometry(std::vector<std::string> & options);
164         ///
165         void handle_package(Parser &p, std::string const & name,
166                             std::string const & opts, bool in_lyx_preamble);
167         ///
168         void handle_if(Parser & p, bool in_lyx_preamble);
169
170         AuthorList authors_;
171 };
172
173
174 extern Preamble preamble;
175
176 // }])
177
178
179 } // namespace lyx
180
181 #endif