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