]> git.lyx.org Git - lyx.git/blob - src/BufferParams.h
New XHTML math options. Format change.
[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 "Citation.h"
19 #include "LayoutModuleList.h"
20 #include "paper.h"
21
22 #include "insets/InsetQuotes.h"
23
24 #include "support/copied_ptr.h"
25
26 #include <map>
27
28 namespace lyx {
29
30 namespace support { class FileName; }
31
32 class AuthorList;
33 class BranchList;
34 class Bullet;
35 class DocumentClass;
36 class Encoding;
37 class Font;
38 class HSpace;
39 class IndicesList;
40 class Language;
41 class LatexFeatures;
42 class LayoutFile;
43 class LayoutFileIndex;
44 class Lexer;
45 class PDFOptions;
46 class Spacing;
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 ParagraphSeparation {
59                 ///
60                 ParagraphIndentSeparation,
61                 ///
62                 ParagraphSkipSeparation
63         };
64         ///
65         BufferParams();
66
67         /// get l10n translated to the buffers language
68         docstring B_(std::string const & l10n) const;
69
70         /// read a header token, if unrecognised, return it or an unknown class name
71         std::string readToken(Lexer & lex,
72                 std::string const & token, ///< token to read.
73                 support::FileName const & filepath);
74
75         ///
76         void writeFile(std::ostream &) const;
77
78         /// check what features are implied by the buffer parameters.
79         void validate(LaTeXFeatures &) const;
80
81         /** \returns true if the babel package is used (interogates
82          *  the BufferParams and a LyXRC variable).
83          *  This returned value can then be passed to the insets...
84          */
85         bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &,
86                         support::FileName const &) const;
87
88         ///
89         void useClassDefaults();
90         ///
91         bool hasClassDefaults() const;
92
93         ///
94         HSpace const & getIndentation() const;
95         ///
96         void setIndentation(HSpace const & indent);
97         ///
98         VSpace const & getDefSkip() const;
99         ///
100         void setDefSkip(VSpace const & vs);
101
102         /** Whether paragraphs are separated by using a indent like in
103          *  articles or by using a little skip like in letters.
104          */
105         ParagraphSeparation paragraph_separation;
106         ///
107         InsetQuotes::QuoteLanguage quotes_language;
108         ///
109         InsetQuotes::QuoteTimes quotes_times;
110         ///
111         std::string fontsize;
112         ///Get the LayoutFile this document is using.
113         LayoutFile const * baseClass() const;
114         ///
115         LayoutFileIndex const & baseClassID() const;
116         /// Set the LyX layout file this document is using.
117         /// NOTE: This does not call makeDocumentClass() to update the local 
118         /// DocumentClass. That needs to be done manually.
119         /// \param filename the name of the layout file
120         bool setBaseClass(std::string const & classname);
121         /// Adds the module information to the baseClass information to
122         /// create our local DocumentClass.
123         void makeDocumentClass();
124         /// Returns the DocumentClass currently in use: the BaseClass as modified
125         /// by modules.
126         DocumentClass const & documentClass() const;
127         /// \return A pointer to the DocumentClass currently in use: the BaseClass 
128         /// as modified by modules. 
129         DocumentClass const * documentClassPtr() const;
130         /// This bypasses the baseClass and sets the textClass directly.
131         /// Should be called with care and would be better not being here,
132         /// but it seems to be needed by CutAndPaste::putClipboard().
133         void setDocumentClass(DocumentClass const * const);
134         /// List of modules in use
135         LayoutModuleList const & getModules() const { return layoutModules_; }
136         /// List of default modules the user has removed
137         std::list<std::string> const & getRemovedModules() const 
138                         { return removedModules_; }
139         ///
140         /// Add a module to the list of modules in use. This checks only that the
141         /// module is not already in the list, so use moduleIsCompatible first if
142         /// you want to check for compatibility.
143         /// \return true if module was successfully added.
144         bool addLayoutModule(std::string const & modName);
145         /// checks to make sure module's requriements are satisfied, that it does
146         /// not conflict with already-present modules, isn't already loaded, etc.
147         bool moduleCanBeAdded(std::string const & modName) const;
148         ///
149         void addRemovedModule(std::string const & modName) 
150                         { removedModules_.push_back(modName); }
151         /// Clear the list
152         void clearLayoutModules() { layoutModules_.clear(); }
153         /// Clear the removed module list
154         void clearRemovedModules() { removedModules_.clear(); }
155
156         /// List of included children (for includeonly)
157         std::list<std::string> const & getIncludedChildren() const 
158                         { return includedChildren_; }
159         ///
160         void addIncludedChildren(std::string const & child) 
161                         { includedChildren_.push_back(child); }
162         /// Clear the list of included children
163         void clearIncludedChildren() { includedChildren_.clear(); }
164
165         /// update aux files of unincluded children (with \includeonly)
166         bool maintain_unincluded_children;
167
168         /// returns the main font for the buffer (document)
169         Font const getFont() const;
170
171         /* these are for the PaperLayout */
172         /// the papersize
173         PAPER_SIZE papersize;
174         ///
175         PAPER_ORIENTATION orientation;
176         /// use custom margins
177         bool use_geometry;
178         ///
179         std::string paperwidth;
180         ///
181         std::string paperheight;
182         ///
183         std::string leftmargin;
184         ///
185         std::string topmargin;
186         ///
187         std::string rightmargin;
188         ///
189         std::string bottommargin;
190         ///
191         std::string headheight;
192         ///
193         std::string headsep;
194         ///
195         std::string footskip;
196         ///
197         std::string columnsep;
198
199         /* some LaTeX options */
200         /// The graphics driver
201         std::string graphicsDriver;
202         /// The default output format
203         std::string defaultOutputFormat;
204         /// customized bibliography processor
205         std::string bibtex_command;
206         /// customized index processor
207         std::string index_command;
208         /// font encoding
209         std::string fontenc;
210         /// the rm font
211         std::string fontsRoman;
212         /// the sf font
213         std::string fontsSans;
214         /// the tt font
215         std::string fontsTypewriter;
216         /// the default family (rm, sf, tt)
217         std::string fontsDefaultFamily;
218         /// use the XeTeX processor
219         bool useXetex;
220         /// use expert Small Caps
221         bool fontsSC;
222         /// use Old Style Figures
223         bool fontsOSF;
224         /// the scale factor of the sf font
225         int fontsSansScale;
226         /// the scale factor of the tt font
227         int fontsTypewriterScale;
228         /// the font used by the CJK command
229         std::string fontsCJK;
230         ///
231         Spacing & spacing();
232         Spacing const & spacing() const;
233         ///
234         int secnumdepth;
235         ///
236         int tocdepth;
237         ///
238         Language const * language;
239         /// BranchList:
240         BranchList & branchlist();
241         BranchList const & branchlist() const;
242         /// IndicesList:
243         IndicesList & indiceslist();
244         IndicesList const & indiceslist() const;
245         /**
246          * The input encoding for LaTeX. This can be one of
247          * - \c auto: find out the input encoding from the used languages
248          * - \c default: ditto
249          * - any encoding supported by the inputenc package
250          * The encoding of the LyX file is always utf8 and has nothing to
251          * do with this setting.
252          * The difference between \c auto and \c default is that \c auto also
253          * causes loading of the inputenc package, while \c default does not.
254          * \c default will not work unless the user takes additional measures
255          * (such as using special environments like the CJK environment from
256          * CJK.sty).
257          * \c default can be seen as an unspecified 8bit encoding, since LyX
258          * does not interpret it in any way apart from display on screen.
259          */
260         std::string inputenc;
261         /// The main encoding used by this buffer for LaTeX output.
262         /// Individual pieces of text can use different encodings.
263         Encoding const & encoding() const;
264         ///
265         std::string preamble;
266         ///
267         std::string local_layout;
268         ///
269         std::string options;
270         /// use the class options defined in the layout?
271         bool use_default_options;
272         ///
273         std::string master;
274         ///
275         bool suppress_date;
276         ///
277         std::string float_placement;
278         ///
279         unsigned int columns;
280         /// parameters for the listings package
281         std::string listings_params;
282         ///
283         PageSides sides;
284         ///
285         std::string pagestyle;
286         ///
287         RGBColor backgroundcolor;
288         ///
289         bool isbackgroundcolor;
290         ///
291         RGBColor fontcolor;
292         ///
293         bool isfontcolor;
294         ///
295         RGBColor notefontcolor;
296         ///
297         RGBColor boxbgcolor;
298         /// \param index should lie in the range 0 <= \c index <= 3.
299         Bullet & temp_bullet(size_type index);
300         Bullet const & temp_bullet(size_type index) const;
301         /// \param index should lie in the range 0 <= \c index <= 3.
302         Bullet & user_defined_bullet(size_type index);
303         Bullet const & user_defined_bullet(size_type index) const;
304
305         /// Whether to load a package such as amsmath or esint.
306         /// The enum values must not be changed (file format!)
307         enum Package {
308                 /// Don't load the package. For experts only.
309                 package_off = 0,
310                 /// Load the package if needed (recommended)
311                 package_auto = 1,
312                 /// Always load the package (e.g. if the document contains
313                 /// some ERT that needs the package)
314                 package_on = 2
315         };
316         /// Whether and how to load amsmath
317         Package use_amsmath;
318         /// Whether and how to load esint
319         Package use_esint;
320         /// Whether and how to load mhchem
321         Package use_mhchem;
322         /// Split bibliography?
323         bool use_bibtopic;
324         /// Split the index?
325         bool use_indices;
326         /// revision tracking for this buffer ?
327         bool trackChanges;
328         /** This param decides whether change tracking marks should be used
329          *  in output (irrespective of how these marks are actually defined;
330          *  for instance, they may differ for DVI and PDF generation)
331          */
332         bool outputChanges;
333         ///
334         bool compressed;
335
336         /// the author list for the document
337         AuthorList & authors();
338         AuthorList const & authors() const;
339
340         /// map of the file's author IDs to AuthorList indexes
341         std::map<unsigned int, int> author_map;
342         /// the buffer's font encoding
343         std::string const font_encoding() const;
344         ///
345         std::string const dvips_options() const;
346         /** The return value of paperSizeName() depends on the
347          *  purpose for which the paper size is needed, since they
348          *  support different subsets of paper sizes.
349         */
350         enum PapersizePurpose {
351                 ///
352                 DVIPS,
353                 ///
354                 DVIPDFM,
355                 ///
356                 XDVI
357         };
358         ///
359         std::string paperSizeName(PapersizePurpose purpose) const;
360         /// set up if and how babel is called
361         std::string babelCall(std::string const & lang_opts) const;
362         /// return supported drivers for specific packages
363         docstring getGraphicsDriver(std::string const & package) const;
364         /// handle inputenc etc.
365         void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
366                                               TexRow & texrow) const;
367         ///
368         std::string const parseFontName(std::string const & name) const;
369         /// set up the document fonts
370         std::string const loadFonts(std::string const & rm,
371                                      std::string const & sf, std::string const & tt,
372                                      bool const & sc, bool const & osf,
373                                      int const & sfscale, int const & ttscale,
374                                      bool const & xetex) const;
375
376         /// get the appropriate cite engine (natbib handling)
377         CiteEngine citeEngine() const;
378         ///
379         void setCiteEngine(CiteEngine const);
380
381         /// options for pdf output
382         PDFOptions & pdfoptions();
383         PDFOptions const & pdfoptions() const;
384
385         enum MathOutput {
386                 MathML,
387                 HTML,
388                 Images,
389                 LaTeX
390         };
391         /// what to use for math output. present choices are above
392         MathOutput html_math_output;
393         /// whether to attempt to be XHTML 1.1 compliant or instead be
394         /// a little more mellow
395         bool html_be_strict;
396         ///
397         double html_math_img_scale;
398         ///
399         std::string html_latex_start;
400         ///
401         std::string html_latex_end;
402
403 private:
404         ///
405         void readPreamble(Lexer &);
406         ///
407         void readLocalLayout(Lexer &);
408         ///
409         void readLanguage(Lexer &);
410         ///
411         void readGraphicsDriver(Lexer &);
412         ///
413         void readBullets(Lexer &);
414         ///
415         void readBulletsLaTeX(Lexer &);
416         ///
417         void readModules(Lexer &);
418         ///
419         void readRemovedModules(Lexer &);
420         ///
421         void readIncludeonly(Lexer &);
422         /// for use with natbib
423         CiteEngine cite_engine_;
424         ///
425         DocumentClass * doc_class_;
426         /// 
427         LayoutModuleList layoutModules_;
428         /// this is for modules that are required by the document class but that
429         /// the user has chosen not to use
430         std::list<std::string> removedModules_;
431
432         /// the list of included children (for includeonly)
433         std::list<std::string> includedChildren_;
434
435         /** Use the Pimpl idiom to hide those member variables that would otherwise
436          *  drag in other header files.
437          */
438         class Impl;
439         class MemoryTraits {
440         public:
441                 static Impl * clone(Impl const *);
442                 static void destroy(Impl *);
443         };
444         support::copied_ptr<Impl, MemoryTraits> pimpl_;
445
446 };
447
448 } // namespace lyx
449
450 #endif