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