]> git.lyx.org Git - lyx.git/blob - src/BufferParams.h
6872c9b9db078f15320c359ac8fbb56426f000f6
[lyx.git] / src / BufferParams.h
1 // -*- C++ -*-
2 /**
3  * \file BufferParams.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author John Levon
10  * \author André Pönitz
11  *
12  * Full author contact details are available in file CREDITS.
13  */
14
15 #ifndef BUFFERPARAMS_H
16 #define BUFFERPARAMS_H
17
18 #include "TextClass.h"
19 #include "paper.h"
20
21 #include "insets/InsetQuotes.h"
22
23 #include "support/copied_ptr.h"
24 #include "support/types.h"
25
26 #include "frontends/controllers/frontend_helpers.h"
27
28 #include <vector>
29
30
31 namespace lyx {
32
33 class AuthorList;
34 class BranchList;
35 class Bullet;
36 class Encoding;
37 class Lexer;
38 class LatexFeatures;
39 class Spacing;
40 class TexRow;
41 class VSpace;
42 class Language;
43
44
45 /** Buffer parameters.
46  *  This class contains all the parameters for this a buffer uses. Some
47  *  work needs to be done on this class to make it nice. Now everything
48  *  is in public.
49  */
50 class BufferParams {
51 public:
52         ///
53         enum PARSEP {
54                 ///
55                 PARSEP_INDENT,
56                 ///
57                 PARSEP_SKIP
58         };
59         ///
60         BufferParams();
61         ~BufferParams();
62
63         /// get l10n translated to the buffers language
64         docstring const B_(std::string const & l10n) const;
65
66         /// read a header token, if unrecognised, return it or an unknown class name
67         std::string const readToken(Lexer & lex, std::string const & token);
68
69         ///
70         void writeFile(std::ostream &) const;
71
72         /** \returns true if the babel package is used (interogates
73          *  the BufferParams and a LyXRC variable).
74          *  This returned value can then be passed to the insets...
75          */
76         bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
77
78         ///
79         void useClassDefaults();
80
81         ///
82         bool hasClassDefaults() const;
83
84         ///
85         VSpace const & getDefSkip() const;
86
87         ///
88         void setDefSkip(VSpace const & vs);
89
90         /** Wether paragraphs are separated by using a indent like in
91          *  articles or by using a little skip like in letters.
92          */
93         PARSEP paragraph_separation;
94         ///
95         InsetQuotes::quote_language quotes_language;
96         ///
97         InsetQuotes::quote_times quotes_times;
98         ///
99         std::string fontsize;
100         ///
101         textclass_type textclass;
102         ///
103         TextClass const & getTextClass() const;
104
105         /// returns the main font for the buffer (document)
106         Font const getFont() const;
107
108         /* this are for the PaperLayout */
109         /// the papersize
110         PAPER_SIZE papersize;
111         ///
112         PAPER_ORIENTATION orientation;
113         /// use custom margins
114         bool use_geometry;
115         ///
116         std::string paperwidth;
117         ///
118         std::string paperheight;
119         ///
120         std::string leftmargin;
121         ///
122         std::string topmargin;
123         ///
124         std::string rightmargin;
125         ///
126         std::string bottommargin;
127         ///
128         std::string headheight;
129         ///
130         std::string headsep;
131         ///
132         std::string footskip;
133
134         /* some LaTeX options */
135         /// The graphics driver
136         std::string graphicsDriver;
137         /// the rm font
138         std::string fontsRoman;
139         /// the sf font
140         std::string fontsSans;
141         /// the tt font
142         std::string fontsTypewriter;
143         /// the default family (rm, sf, tt)
144         std::string fontsDefaultFamily;
145         /// use expert Small Caps
146         bool fontsSC;
147         /// use Old Style Figures
148         bool fontsOSF;
149         /// the scale factor of the sf font
150         int fontsSansScale;
151         /// the scale factor of the tt font
152         int fontsTypewriterScale;
153         ///
154         Spacing & spacing();
155         Spacing const & spacing() const;
156         ///
157         int secnumdepth;
158         ///
159         int tocdepth;
160         ///
161         Language const * language;
162         /// BranchList:
163         BranchList & branchlist();
164         BranchList const & branchlist() const;
165         /**
166          * The input encoding for LaTeX. This can be one of
167          * - \c auto: find out the input encoding from the used languages
168          * - \c default: ditto
169          * - any encoding supported by the inputenc package
170          * The encoding of the LyX file is always utf8 and has nothing to
171          * do with this setting.
172          * The difference between \c auto and \c default is that \c auto also
173          * causes loading of the inputenc package, while \c default does not.
174          * \c default will not work unless the user takes additional measures
175          * (such as using special environments like the CJK environment from
176          * CJK.sty).
177          * \c default can be seen as an unspecified 8bit encoding, since LyX
178          * does not interpret it in any way apart from display on screen.
179          */
180         std::string inputenc;
181         /// The main encoding used by this buffer for LaTeX output.
182         /// Individual pieces of text can use different encodings.
183         Encoding const & encoding() const;
184         ///
185         std::string preamble;
186         ///
187         std::string options;
188         ///
189         std::string float_placement;
190         ///
191         unsigned int columns;
192         ///
193         TextClass::PageSides sides;
194         ///
195         std::string pagestyle;
196         /// \param index should lie in the range 0 <= \c index <= 3.
197         Bullet & temp_bullet(size_type index);
198         Bullet const & temp_bullet(size_type index) const;
199         /// \param index should lie in the range 0 <= \c index <= 3.
200         Bullet & user_defined_bullet(size_type index);
201         Bullet const & user_defined_bullet(size_type index) const;
202         ///
203         void readPreamble(Lexer &);
204         ///
205         void readLanguage(Lexer &);
206         ///
207         void readGraphicsDriver(Lexer &);
208         ///
209         void readBullets(Lexer &);
210         ///
211         void readBulletsLaTeX(Lexer &);
212
213         /// Whether to load a package such as amsmath or esint.
214         /// The enum values must not be changed (file format!)
215         enum Package {
216                 /// Don't load the package. For experts only.
217                 package_off = 0,
218                 /// Load the package if needed (recommended)
219                 package_auto = 1,
220                 /// Always load the package (e.g. if the document contains
221                 /// some ERT that needs the package)
222                 package_on = 2
223         };
224         /// Whether and how to load amsmath
225         Package use_amsmath;
226         /// Whether and how to load esint
227         Package use_esint;
228         ///
229         bool use_bibtopic;
230         /// revision tracking for this buffer ?
231         bool trackChanges;
232         /** This param decides whether change tracking marks should be output
233          *  (using the dvipost package) or if the current "state" of the
234          *  document should be output instead. Since dvipost needs dvi
235          *  specials, it only works with dvi/ps output (the param will be
236          *  ignored with other output flavors and disabled when dvipost is
237          *  not installed).
238          */
239         bool outputChanges;
240         /// Time ago we agreed that this was a buffer property [ale990407]
241         std::string parentname;
242         ///
243         bool compressed;
244
245         /// the author list for the document
246         AuthorList & authors();
247         AuthorList const & authors() const;
248
249         /// map of the file's author IDs to buffer author IDs
250         std::vector<unsigned int> author_map;
251         ///
252         std::string const dvips_options() const;
253         ///
254         std::string const paperSizeName() const;
255         /// set up if and how babel is called
256         std::string const babelCall(std::string const & lang_opts) const;
257         /// set up the document fonts
258         std::string const loadFonts(std::string const & rm,
259                                      std::string const & sf, std::string const & tt,
260                                      bool const & sc, bool const & osf,
261                                      int const & sfscale, int const & ttscale) const;
262         /// path of the current buffer
263         std::string filepath;
264         /// get the appropriate cite engine (natbib handling)
265         biblio::CiteEngine getEngine() const;
266
267         ///
268         void setCiteEngine(biblio::CiteEngine const);
269
270 private:
271         /** Use the Pimpl idiom to hide those member variables that would otherwise
272          *  drag in other header files.
273          */
274         class Impl;
275         class MemoryTraits {
276         public:
277                 static Impl * clone(Impl const *);
278                 static void destroy(Impl *);
279         };
280         support::copied_ptr<Impl, MemoryTraits> pimpl_;
281
282         ///
283         biblio::CiteEngine cite_engine_;
284 };
285
286 } // namespace lyx
287
288 #endif