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