]> git.lyx.org Git - lyx.git/blob - src/BufferParams.h
Clean-up in CharStyles, externalize detection of undefined styles to
[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 "TextClass_ptr.h"
21 #include "paper.h"
22
23 #include "insets/InsetQuotes.h"
24
25 #include "support/copied_ptr.h"
26 #include "support/FileName.h"
27 #include "support/types.h"
28
29 #include "frontends/controllers/frontend_helpers.h"
30
31 #include <vector>
32
33 namespace lyx {
34
35 class AuthorList;
36 class BranchList;
37 class Bullet;
38 class Encoding;
39 class Lexer;
40 class LatexFeatures;
41 class Spacing;
42 class TexRow;
43 class VSpace;
44 class Language;
45
46 /** Buffer parameters.
47  *  This class contains all the parameters for this buffer's use. 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         /** Whether 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         ///Get the LyX TextClass (that is, the layout file) this document is using.
102         textclass_type getBaseClass() const;
103         ///Set the LyX TextClass (that is, the layout file) this document is using.
104         ///NOTE This also calls makeTextClass(), to update the local
105         ///TextClass.
106         void setBaseClass(textclass_type);
107         ///Returns the TextClass currently in use: the BaseClass as modified
108         ///by modules.
109         TextClass const & getTextClass() const;
110         ///Returns a pointer to the TextClass currently in use: the BaseClass 
111         ///as modified by modules. (See \file TextClass_ptr.h for the typedef.)
112         TextClass_ptr getTextClass_ptr() const;
113         ///Set the LyX TextClass---layout file---this document is using.
114         ///This does NOT call makeTextClass() and so should be used with
115         ///care. This is most likely not what you want if you are operating on 
116         ///BufferParams that are actually associatd with a Buffer. If, on the
117         ///other hand, you are using a temporary set of BufferParams---say, in
118         ///a controller, it may well be, since in that case the local TextClass
119         ///has nothing to do.
120         void setJustBaseClass(textclass_type);
121         /// This bypasses the baseClass and sets the textClass directly.
122         /// Should be called with care and would be better not being here,
123         /// but it seems to be needed by CutAndPaste::putClipboard().
124         void setTextClass(TextClass_ptr);
125
126         /// returns the main font for the buffer (document)
127         Font const getFont() const;
128
129         /* this are for the PaperLayout */
130         /// the papersize
131         PAPER_SIZE papersize;
132         ///
133         PAPER_ORIENTATION orientation;
134         /// use custom margins
135         bool use_geometry;
136         ///
137         std::string paperwidth;
138         ///
139         std::string paperheight;
140         ///
141         std::string leftmargin;
142         ///
143         std::string topmargin;
144         ///
145         std::string rightmargin;
146         ///
147         std::string bottommargin;
148         ///
149         std::string headheight;
150         ///
151         std::string headsep;
152         ///
153         std::string footskip;
154
155         /* some LaTeX options */
156         /// The graphics driver
157         std::string graphicsDriver;
158         /// the rm font
159         std::string fontsRoman;
160         /// the sf font
161         std::string fontsSans;
162         /// the tt font
163         std::string fontsTypewriter;
164         /// the default family (rm, sf, tt)
165         std::string fontsDefaultFamily;
166         /// use expert Small Caps
167         bool fontsSC;
168         /// use Old Style Figures
169         bool fontsOSF;
170         /// the scale factor of the sf font
171         int fontsSansScale;
172         /// the scale factor of the tt font
173         int fontsTypewriterScale;
174         ///
175         Spacing & spacing();
176         Spacing const & spacing() const;
177         ///
178         int secnumdepth;
179         ///
180         int tocdepth;
181         ///
182         Language const * language;
183         /// BranchList:
184         BranchList & branchlist();
185         BranchList const & branchlist() const;
186         /**
187          * The input encoding for LaTeX. This can be one of
188          * - \c auto: find out the input encoding from the used languages
189          * - \c default: ditto
190          * - any encoding supported by the inputenc package
191          * The encoding of the LyX file is always utf8 and has nothing to
192          * do with this setting.
193          * The difference between \c auto and \c default is that \c auto also
194          * causes loading of the inputenc package, while \c default does not.
195          * \c default will not work unless the user takes additional measures
196          * (such as using special environments like the CJK environment from
197          * CJK.sty).
198          * \c default can be seen as an unspecified 8bit encoding, since LyX
199          * does not interpret it in any way apart from display on screen.
200          */
201         std::string inputenc;
202         /// The main encoding used by this buffer for LaTeX output.
203         /// Individual pieces of text can use different encodings.
204         Encoding const & encoding() const;
205         ///
206         std::string preamble;
207         ///
208         std::string options;
209         ///
210         std::string float_placement;
211         ///
212         unsigned int columns;
213         /// parameters for the listings package
214         std::string listings_params;
215         ///
216         TextClass::PageSides sides;
217         ///
218         std::string pagestyle;
219         /// \param index should lie in the range 0 <= \c index <= 3.
220         Bullet & temp_bullet(size_type index);
221         Bullet const & temp_bullet(size_type index) const;
222         /// \param index should lie in the range 0 <= \c index <= 3.
223         Bullet & user_defined_bullet(size_type index);
224         Bullet const & user_defined_bullet(size_type index) const;
225
226         /// Whether to load a package such as amsmath or esint.
227         /// The enum values must not be changed (file format!)
228         enum Package {
229                 /// Don't load the package. For experts only.
230                 package_off = 0,
231                 /// Load the package if needed (recommended)
232                 package_auto = 1,
233                 /// Always load the package (e.g. if the document contains
234                 /// some ERT that needs the package)
235                 package_on = 2
236         };
237         /// Whether and how to load amsmath
238         Package use_amsmath;
239         /// Whether and how to load esint
240         Package use_esint;
241         ///
242         bool use_bibtopic;
243         /// revision tracking for this buffer ?
244         bool trackChanges;
245         /** This param decides whether change tracking marks should be used
246          *  in output (irrespective of how these marks are actually defined;
247          *  for instance, they may differ for DVI and PDF generation)
248          */
249         bool outputChanges;
250         /// Time ago we agreed that this was a buffer property [ale990407]
251         std::string parentname;
252         ///
253         bool compressed;
254
255         /// the author list for the document
256         AuthorList & authors();
257         AuthorList const & authors() const;
258
259         /// map of the file's author IDs to buffer author IDs
260         std::vector<unsigned int> author_map;
261         ///
262         std::string const dvips_options() const;
263         ///
264         std::string const paperSizeName() const;
265         /// set up if and how babel is called
266         std::string const babelCall(std::string const & lang_opts) const;
267         /// handle inputenc etc.
268         void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
269                                               TexRow & texrow) const;
270         /// set up the document fonts
271         std::string const loadFonts(std::string const & rm,
272                                      std::string const & sf, std::string const & tt,
273                                      bool const & sc, bool const & osf,
274                                      int const & sfscale, int const & ttscale) const;
275         /// path of the current buffer
276         std::string filepath;
277         /// get the appropriate cite engine (natbib handling)
278         biblio::CiteEngine getEngine() const;
279
280         ///
281         void setCiteEngine(biblio::CiteEngine const);
282
283 private:
284         ///
285         void readPreamble(Lexer &);
286         ///
287         void readLanguage(Lexer &);
288         ///
289         void readGraphicsDriver(Lexer &);
290         ///
291         void readBullets(Lexer &);
292         ///
293         void readBulletsLaTeX(Lexer &);
294         /// create our local TextClass.
295         void makeTextClass();
296
297         
298         /// for use with natbib
299         biblio::CiteEngine cite_engine_;
300         /// the base TextClass associated with the document
301         textclass_type baseClass_;
302         /// the possibly modular TextClass actually in use
303         TextClass_ptr textClass_;
304
305         /** Use the Pimpl idiom to hide those member variables that would otherwise
306          *  drag in other header files.
307          */
308         class Impl;
309         class MemoryTraits {
310         public:
311                 static Impl * clone(Impl const *);
312                 static void destroy(Impl *);
313         };
314         support::copied_ptr<Impl, MemoryTraits> pimpl_;
315
316 };
317
318 } // namespace lyx
319
320 #endif