]> git.lyx.org Git - lyx.git/blob - src/BufferParams.h
* de/UserGuide: some translation work.
[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, a LyXRC variable, and the document class).
83          *  This returned value can then be passed to the insets...
84          */
85         bool writeLaTeX(otexstream &, LaTeXFeatures &,
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 layout_modules_; }
136         /// List of default modules the user has removed
137         std::list<std::string> const & getRemovedModules() const 
138                         { return removed_modules_; }
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                         { removed_modules_.push_back(modName); }
151         /// Clear the list
152         void clearLayoutModules() { layout_modules_.clear(); }
153         /// Clear the removed module list
154         void clearRemovedModules() { removed_modules_.clear(); }
155
156         /// List of included children (for includeonly)
157         std::list<std::string> const & getIncludedChildren() const 
158                         { return included_children_; }
159         ///
160         void addIncludedChildren(std::string const & child) 
161                         { included_children_.push_back(child); }
162         /// Clear the list of included children
163         void clearIncludedChildren() { included_children_.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 graphics_driver;
202         /// The default output format
203         std::string default_output_format;
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 fonts_roman;
212         /// the sf font
213         std::string fonts_sans;
214         /// the tt font
215         std::string fonts_typewriter;
216         /// the default family (rm, sf, tt)
217         std::string fonts_default_family;
218         /// use the fonts of the OS (OpenType, True Type) directly
219         bool useNonTeXFonts;
220         /// use expert Small Caps
221         bool fonts_expert_sc;
222         /// use Old Style Figures
223         bool fonts_old_figures;
224         /// the scale factor of the sf font
225         int fonts_sans_scale;
226         /// the scale factor of the tt font
227         int fonts_typewriter_scale;
228         /// the font used by the CJK command
229         std::string fonts_cjk;
230         ///
231         Spacing & spacing();
232         Spacing const & spacing() const;
233         ///
234         int secnumdepth;
235         ///
236         int tocdepth;
237         ///
238         Language const * language;
239         /// language package
240         std::string lang_package;
241         /// BranchList:
242         BranchList & branchlist();
243         BranchList const & branchlist() const;
244         /// IndicesList:
245         IndicesList & indiceslist();
246         IndicesList const & indiceslist() const;
247         /**
248          * The input encoding for LaTeX. This can be one of
249          * - \c auto: find out the input encoding from the used languages
250          * - \c default: ditto
251          * - any encoding supported by the inputenc package
252          * The encoding of the LyX file is always utf8 and has nothing to
253          * do with this setting.
254          * The difference between \c auto and \c default is that \c auto also
255          * causes loading of the inputenc package, while \c default does not.
256          * \c default will not work unless the user takes additional measures
257          * (such as using special environments like the CJK environment from
258          * CJK.sty).
259          * \c default can be seen as an unspecified 8bit encoding, since LyX
260          * does not interpret it in any way apart from display on screen.
261          */
262         std::string inputenc;
263         /// The main encoding used by this buffer for LaTeX output.
264         /// Individual pieces of text can use different encodings.
265         Encoding const & encoding() const;
266         ///
267         std::string preamble;
268         ///
269         std::string local_layout;
270         ///
271         std::string options;
272         /// use the class options defined in the layout?
273         bool use_default_options;
274         ///
275         std::string master;
276         ///
277         bool suppress_date;
278         ///
279         std::string float_placement;
280         ///
281         unsigned int columns;
282         /// parameters for the listings package
283         std::string listings_params;
284         ///
285         PageSides sides;
286         ///
287         std::string pagestyle;
288         ///
289         RGBColor backgroundcolor;
290         ///
291         bool isbackgroundcolor;
292         ///
293         RGBColor fontcolor;
294         ///
295         bool isfontcolor;
296         ///
297         RGBColor notefontcolor;
298         ///
299         RGBColor boxbgcolor;
300         /// \param index should lie in the range 0 <= \c index <= 3.
301         Bullet & temp_bullet(size_type index);
302         Bullet const & temp_bullet(size_type index) const;
303         /// \param index should lie in the range 0 <= \c index <= 3.
304         Bullet & user_defined_bullet(size_type index);
305         Bullet const & user_defined_bullet(size_type index) const;
306
307         /// Whether to load a package such as amsmath or esint.
308         /// The enum values must not be changed (file format!)
309         enum Package {
310                 /// Don't load the package. For experts only.
311                 package_off = 0,
312                 /// Load the package if needed (recommended)
313                 package_auto = 1,
314                 /// Always load the package (e.g. if the document contains
315                 /// some ERT that needs the package)
316                 package_on = 2
317         };
318         /// Whether and how to load amsmath
319         Package use_amsmath;
320         /// Whether and how to load esint
321         Package use_esint;
322         /// Whether and how to load mhchem
323         Package use_mhchem;
324         /// Whether and how to load mathdots
325         Package use_mathdots;
326         /// Split bibliography?
327         bool use_bibtopic;
328         /// Split the index?
329         bool use_indices;
330         /// revision tracking for this buffer ?
331         bool trackChanges;
332         /** This param decides whether change tracking marks should be used
333          *  in output (irrespective of how these marks are actually defined;
334          *  for instance, they may differ for DVI and PDF generation)
335          */
336         bool outputChanges;
337         ///
338         bool compressed;
339
340         /// the author list for the document
341         AuthorList & authors();
342         AuthorList const & authors() const;
343
344         /// map of the file's author IDs to AuthorList indexes
345         typedef std::map<int, int> AuthorMap;
346         AuthorMap author_map;
347         /// the buffer's font encoding
348         std::string const font_encoding() const;
349         ///
350         std::string const dvips_options() const;
351         /** The return value of paperSizeName() depends on the
352          *  purpose for which the paper size is needed, since they
353          *  support different subsets of paper sizes.
354         */
355         enum PapersizePurpose {
356                 ///
357                 DVIPS,
358                 ///
359                 DVIPDFM,
360                 ///
361                 XDVI
362         };
363         ///
364         std::string paperSizeName(PapersizePurpose purpose) const;
365         /// set up if and how babel is called
366         std::string babelCall(std::string const & lang_opts, bool const langoptions) const;
367         /// return supported drivers for specific packages
368         docstring getGraphicsDriver(std::string const & package) const;
369         /// handle inputenc etc.
370         void writeEncodingPreamble(otexstream & os, LaTeXFeatures & features) const;
371         ///
372         std::string const parseFontName(std::string const & name) const;
373         /// set up the document fonts
374         std::string const loadFonts(std::string const & rm,
375                                      std::string const & sf, std::string const & tt,
376                                      bool const & sc, bool const & osf,
377                                      int const & sfscale, int const & ttscale,
378                                      bool const & use_nonlatexfonts,
379                                      LaTeXFeatures & features) const;
380
381         /// get the appropriate cite engine (natbib handling)
382         CiteEngine citeEngine() const;
383         ///
384         void setCiteEngine(CiteEngine const);
385
386         /// options for pdf output
387         PDFOptions & pdfoptions();
388         PDFOptions const & pdfoptions() const;
389
390         // do not change these values. we rely upon them.
391         enum MathOutput {
392                 MathML = 0,
393                 HTML = 1,
394                 Images = 2,
395                 LaTeX = 3
396         };
397         /// what to use for math output. present choices are above
398         MathOutput html_math_output;
399         /// whether to attempt to be XHTML 1.1 compliant or instead be
400         /// a little more mellow
401         bool html_be_strict;
402         ///
403         double html_math_img_scale;
404         ///
405         std::string html_latex_start;
406         ///
407         std::string html_latex_end;
408         ///
409         bool html_css_as_file;
410         /// generate output usable for reverse/forward search
411         bool output_sync;
412         /// custom LaTeX macro from user instead our own
413         std::string output_sync_macro;
414         /// use refstyle? or prettyref?
415         bool use_refstyle;
416
417 private:
418         ///
419         void readPreamble(Lexer &);
420         ///
421         void readLocalLayout(Lexer &);
422         ///
423         void readLanguage(Lexer &);
424         ///
425         void readGraphicsDriver(Lexer &);
426         ///
427         void readBullets(Lexer &);
428         ///
429         void readBulletsLaTeX(Lexer &);
430         ///
431         void readModules(Lexer &);
432         ///
433         void readRemovedModules(Lexer &);
434         ///
435         void readIncludeonly(Lexer &);
436         /// for use with natbib
437         CiteEngine cite_engine_;
438         ///
439         DocumentClass * doc_class_;
440         /// 
441         LayoutModuleList layout_modules_;
442         /// this is for modules that are required by the document class but that
443         /// the user has chosen not to use
444         std::list<std::string> removed_modules_;
445
446         /// the list of included children (for includeonly)
447         std::list<std::string> included_children_;
448
449         /** Use the Pimpl idiom to hide those member variables that would otherwise
450          *  drag in other header files.
451          */
452         class Impl;
453         class MemoryTraits {
454         public:
455                 static Impl * clone(Impl const *);
456                 static void destroy(Impl *);
457         };
458         support::copied_ptr<Impl, MemoryTraits> pimpl_;
459
460 };
461
462 } // namespace lyx
463
464 #endif