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