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