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