]> git.lyx.org Git - lyx.git/blob - src/BufferParams.h
some de-boostification
[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 "Font.h"
19 #include "BiblioInfo.h"
20 #include "paper.h"
21 #include "TextClassPtr.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 <vector>
30
31 namespace lyx {
32
33 namespace support {
34 class FileName;
35 }
36
37 class AuthorList;
38 class BranchList;
39 class Bullet;
40 class Encoding;
41 class Language;
42 class Lexer;
43 class LatexFeatures;
44 class PDFOptions;
45 class Spacing;
46 class TextClass;
47 class TexRow;
48 class VSpace;
49
50 /** Buffer parameters.
51  *  This class contains all the parameters for this buffer's use. Some
52  *  work needs to be done on this class to make it nice. Now everything
53  *  is in public.
54  */
55 class BufferParams {
56 public:
57         ///
58         enum PARSEP {
59                 ///
60                 PARSEP_INDENT,
61                 ///
62                 PARSEP_SKIP
63         };
64         ///
65         BufferParams();
66         ~BufferParams();
67
68         /// get l10n translated to the buffers language
69         docstring const B_(std::string const & l10n) const;
70
71         /// read a header token, if unrecognised, return it or an unknown class name
72         std::string const readToken(Lexer & lex,
73                 std::string const & token, ///< token to read.
74                 support::FileName const & filepath); ///< where to look for local layout file.
75
76         ///
77         void writeFile(std::ostream &) const;
78
79         /** \returns true if the babel package is used (interogates
80          *  the BufferParams and a LyXRC variable).
81          *  This returned value can then be passed to the insets...
82          */
83         bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
84
85         ///
86         void useClassDefaults();
87
88         ///
89         bool hasClassDefaults() const;
90
91         ///
92         VSpace const & getDefSkip() const;
93
94         ///
95         void setDefSkip(VSpace const & vs);
96
97         /** Whether paragraphs are separated by using a indent like in
98          *  articles or by using a little skip like in letters.
99          */
100         PARSEP paragraph_separation;
101         ///
102         InsetQuotes::quote_language quotes_language;
103         ///
104         InsetQuotes::quote_times quotes_times;
105         ///
106         std::string fontsize;
107         ///Get the LyX TextClass (that is, the layout file) this document is using.
108         textclass_type getBaseClass() const;
109         ///Set the LyX TextClass (that is, the layout file) this document is using.
110         ///NOTE This also calls makeTextClass(), to update the local
111         ///TextClass.
112         bool setBaseClass(textclass_type);
113         ///Returns the TextClass currently in use: the BaseClass as modified
114         ///by modules.
115         TextClass const & getTextClass() const;
116         ///Returns a pointer to the TextClass currently in use: the BaseClass 
117         ///as modified by modules. (See \file TextClassPtr.h for the typedef.)
118         TextClassPtr getTextClassPtr() const;
119         ///Set the LyX TextClass---layout file---this document is using.
120         ///This does NOT call makeTextClass() and so should be used with
121         ///care. This is most likely not what you want if you are operating on 
122         ///BufferParams that are actually associatd with a Buffer. If, on the
123         ///other hand, you are using a temporary set of BufferParams---say, in
124         ///a controller, it may well be, since in that case the local TextClass
125         ///has nothing to do.
126         void setJustBaseClass(textclass_type);
127         /// This bypasses the baseClass and sets the textClass directly.
128         /// Should be called with care and would be better not being here,
129         /// but it seems to be needed by CutAndPaste::putClipboard().
130         void setTextClass(TextClassPtr);
131         /// List of modules in use
132         std::vector<std::string> const & getModules() const;
133         /// Add a module to the list of modules in use.
134         /// Returns true if module was successfully added.
135         bool addLayoutModule(std::string modName, bool makeClass = true);
136         /// Add a list of modules.
137         /// Returns true if all modules were successfully added.
138         bool addLayoutModules(std::vector<std::string>modNames);
139         /// Clear the list
140         void clearLayoutModules();
141
142         /// returns the main font for the buffer (document)
143         Font const getFont() const;
144
145         /* this are for the PaperLayout */
146         /// the papersize
147         PAPER_SIZE papersize;
148         ///
149         PAPER_ORIENTATION orientation;
150         /// use custom margins
151         bool use_geometry;
152         ///
153         std::string paperwidth;
154         ///
155         std::string paperheight;
156         ///
157         std::string leftmargin;
158         ///
159         std::string topmargin;
160         ///
161         std::string rightmargin;
162         ///
163         std::string bottommargin;
164         ///
165         std::string headheight;
166         ///
167         std::string headsep;
168         ///
169         std::string footskip;
170
171         /* some LaTeX options */
172         /// The graphics driver
173         std::string graphicsDriver;
174         /// the rm font
175         std::string fontsRoman;
176         /// the sf font
177         std::string fontsSans;
178         /// the tt font
179         std::string fontsTypewriter;
180         /// the default family (rm, sf, tt)
181         std::string fontsDefaultFamily;
182         /// use expert Small Caps
183         bool fontsSC;
184         /// use Old Style Figures
185         bool fontsOSF;
186         /// the scale factor of the sf font
187         int fontsSansScale;
188         /// the scale factor of the tt font
189         int fontsTypewriterScale;
190         ///
191         Spacing & spacing();
192         Spacing const & spacing() const;
193         ///
194         int secnumdepth;
195         ///
196         int tocdepth;
197         ///
198         Language const * language;
199         /// BranchList:
200         BranchList & branchlist();
201         BranchList const & branchlist() const;
202         /**
203          * The input encoding for LaTeX. This can be one of
204          * - \c auto: find out the input encoding from the used languages
205          * - \c default: ditto
206          * - any encoding supported by the inputenc package
207          * The encoding of the LyX file is always utf8 and has nothing to
208          * do with this setting.
209          * The difference between \c auto and \c default is that \c auto also
210          * causes loading of the inputenc package, while \c default does not.
211          * \c default will not work unless the user takes additional measures
212          * (such as using special environments like the CJK environment from
213          * CJK.sty).
214          * \c default can be seen as an unspecified 8bit encoding, since LyX
215          * does not interpret it in any way apart from display on screen.
216          */
217         std::string inputenc;
218         /// The main encoding used by this buffer for LaTeX output.
219         /// Individual pieces of text can use different encodings.
220         Encoding const & encoding() const;
221         ///
222         std::string preamble;
223         ///
224         std::string options;
225         ///
226         std::string float_placement;
227         ///
228         unsigned int columns;
229         /// parameters for the listings package
230         std::string listings_params;
231         ///
232         PageSides sides;
233         ///
234         std::string pagestyle;
235         /// \param index should lie in the range 0 <= \c index <= 3.
236         Bullet & temp_bullet(size_type index);
237         Bullet const & temp_bullet(size_type index) const;
238         /// \param index should lie in the range 0 <= \c index <= 3.
239         Bullet & user_defined_bullet(size_type index);
240         Bullet const & user_defined_bullet(size_type index) const;
241
242         /// Whether to load a package such as amsmath or esint.
243         /// The enum values must not be changed (file format!)
244         enum Package {
245                 /// Don't load the package. For experts only.
246                 package_off = 0,
247                 /// Load the package if needed (recommended)
248                 package_auto = 1,
249                 /// Always load the package (e.g. if the document contains
250                 /// some ERT that needs the package)
251                 package_on = 2
252         };
253         /// Whether and how to load amsmath
254         Package use_amsmath;
255         /// Whether and how to load esint
256         Package use_esint;
257         ///
258         bool use_bibtopic;
259         /// revision tracking for this buffer ?
260         bool trackChanges;
261         /** This param decides whether change tracking marks should be used
262          *  in output (irrespective of how these marks are actually defined;
263          *  for instance, they may differ for DVI and PDF generation)
264          */
265         bool outputChanges;
266         /// Time ago we agreed that this was a buffer property [ale990407]
267         std::string parentname;
268         ///
269         bool compressed;
270         ///
271         bool embedded;
272
273         /// the author list for the document
274         AuthorList & authors();
275         AuthorList const & authors() const;
276
277         /// map of the file's author IDs to buffer author IDs
278         std::vector<unsigned int> author_map;
279         ///
280         std::string const dvips_options() const;
281         ///
282         std::string const paperSizeName() const;
283         /// set up if and how babel is called
284         std::string const babelCall(std::string const & lang_opts) const;
285         /// handle inputenc etc.
286         void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
287                                               TexRow & texrow) const;
288         /// set up the document fonts
289         std::string const loadFonts(std::string const & rm,
290                                      std::string const & sf, std::string const & tt,
291                                      bool const & sc, bool const & osf,
292                                      int const & sfscale, int const & ttscale) const;
293
294         /// get the appropriate cite engine (natbib handling)
295         biblio::CiteEngine getEngine() const;
296
297         ///
298         void setCiteEngine(biblio::CiteEngine const);
299
300         /// options for pdf output
301         PDFOptions & pdfoptions();
302         PDFOptions const & pdfoptions() const;
303
304 private:
305         ///
306         void readPreamble(Lexer &);
307         ///
308         void readLanguage(Lexer &);
309         ///
310         void readGraphicsDriver(Lexer &);
311         ///
312         void readBullets(Lexer &);
313         ///
314         void readBulletsLaTeX(Lexer &);
315         ///
316         void readModules(Lexer &);
317         /// Adds the module information to the baseClass information to
318         /// create our local TextClass.
319         void makeTextClass();
320
321         
322         /// for use with natbib
323         biblio::CiteEngine cite_engine_;
324         /// the base TextClass associated with the document
325         textclass_type baseClass_;
326         /// the possibly modular TextClass actually in use
327         TextClassPtr textClass_;
328         ///
329         typedef std::vector<std::string> LayoutModuleList;
330         /// 
331         LayoutModuleList layoutModules_;
332
333         /** Use the Pimpl idiom to hide those member variables that would otherwise
334          *  drag in other header files.
335          */
336         class Impl;
337         class MemoryTraits {
338         public:
339                 static Impl * clone(Impl const *);
340                 static void destroy(Impl *);
341         };
342         support::copied_ptr<Impl, MemoryTraits> pimpl_;
343
344 };
345
346 } // namespace lyx
347
348 #endif