]> git.lyx.org Git - lyx.git/blob - src/BufferParams.h
Fixed some lines that were too long. It compiled afterwards.
[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         /// parameters for the listings package
193         std::string listings_params;
194         ///
195         TextClass::PageSides sides;
196         ///
197         std::string pagestyle;
198         /// \param index should lie in the range 0 <= \c index <= 3.
199         Bullet & temp_bullet(size_type index);
200         Bullet const & temp_bullet(size_type index) const;
201         /// \param index should lie in the range 0 <= \c index <= 3.
202         Bullet & user_defined_bullet(size_type index);
203         Bullet const & user_defined_bullet(size_type index) const;
204         ///
205         void readPreamble(Lexer &);
206         ///
207         void readLanguage(Lexer &);
208         ///
209         void readGraphicsDriver(Lexer &);
210         ///
211         void readBullets(Lexer &);
212         ///
213         void readBulletsLaTeX(Lexer &);
214
215         /// Whether to load a package such as amsmath or esint.
216         /// The enum values must not be changed (file format!)
217         enum Package {
218                 /// Don't load the package. For experts only.
219                 package_off = 0,
220                 /// Load the package if needed (recommended)
221                 package_auto = 1,
222                 /// Always load the package (e.g. if the document contains
223                 /// some ERT that needs the package)
224                 package_on = 2
225         };
226         /// Whether and how to load amsmath
227         Package use_amsmath;
228         /// Whether and how to load esint
229         Package use_esint;
230         ///
231         bool use_bibtopic;
232         /// revision tracking for this buffer ?
233         bool trackChanges;
234         /** This param decides whether change tracking marks should be used
235          *  in output (irrespective of how these marks are actually defined;
236          *  for instance, they may differ for DVI and PDF generation)
237          */
238         bool outputChanges;
239         /// Time ago we agreed that this was a buffer property [ale990407]
240         std::string parentname;
241         ///
242         bool compressed;
243
244         /// the author list for the document
245         AuthorList & authors();
246         AuthorList const & authors() const;
247
248         /// map of the file's author IDs to buffer author IDs
249         std::vector<unsigned int> author_map;
250         ///
251         std::string const dvips_options() const;
252         ///
253         std::string const paperSizeName() const;
254         /// set up if and how babel is called
255         std::string const babelCall(std::string const & lang_opts) const;
256         /// handle inputenc etc.
257         void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
258                                               TexRow & texrow) const;
259         /// set up the document fonts
260         std::string const loadFonts(std::string const & rm,
261                                      std::string const & sf, std::string const & tt,
262                                      bool const & sc, bool const & osf,
263                                      int const & sfscale, int const & ttscale) const;
264         /// path of the current buffer
265         std::string filepath;
266         /// get the appropriate cite engine (natbib handling)
267         biblio::CiteEngine getEngine() const;
268
269         ///
270         void setCiteEngine(biblio::CiteEngine const);
271
272 private:
273         /** Use the Pimpl idiom to hide those member variables that would otherwise
274          *  drag in other header files.
275          */
276         class Impl;
277         class MemoryTraits {
278         public:
279                 static Impl * clone(Impl const *);
280                 static void destroy(Impl *);
281         };
282         support::copied_ptr<Impl, MemoryTraits> pimpl_;
283
284         ///
285         biblio::CiteEngine cite_engine_;
286 };
287
288 } // namespace lyx
289
290 #endif