tufte layout files:
[lyx.git] / src / BufferParams.h
blobfefa91b90f4ff3e0da390feb6b12fe8be9e43e50
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.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
9 * \author John Levon
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
15 #ifndef BUFFERPARAMS_H
16 #define BUFFERPARAMS_H
18 #include "Citation.h"
19 #include "Font.h"
20 #include "LayoutModuleList.h"
21 #include "paper.h"
23 #include "insets/InsetQuotes.h"
25 #include "support/copied_ptr.h"
27 #include <list>
28 #include <map>
29 #include <vector>
31 namespace lyx {
33 namespace support { class FileName; }
35 class AuthorList;
36 class BranchList;
37 class Bullet;
38 class DocumentClass;
39 class Encoding;
40 class HSpace;
41 class IndicesList;
42 class Language;
43 class LatexFeatures;
44 class LayoutFile;
45 class LayoutFileIndex;
46 class Lexer;
47 class PDFOptions;
48 class Spacing;
49 class TexRow;
50 class VSpace;
52 /** Buffer parameters.
53 * This class contains all the parameters for this buffer's use. Some
54 * work needs to be done on this class to make it nice. Now everything
55 * is in public.
57 class BufferParams {
58 public:
59 ///
60 enum ParagraphSeparation {
61 ///
62 ParagraphIndentSeparation,
63 ///
64 ParagraphSkipSeparation
66 ///
67 BufferParams();
69 /// get l10n translated to the buffers language
70 docstring B_(std::string const & l10n) const;
72 /// read a header token, if unrecognised, return it or an unknown class name
73 std::string readToken(Lexer & lex,
74 std::string const & token, ///< token to read.
75 support::FileName const & filepath);
77 ///
78 void writeFile(std::ostream &) const;
80 /// check what features are implied by the buffer parameters.
81 void validate(LaTeXFeatures &) const;
83 /** \returns true if the babel package is used (interogates
84 * the BufferParams and a LyXRC variable).
85 * This returned value can then be passed to the insets...
87 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
89 ///
90 void useClassDefaults();
91 ///
92 bool hasClassDefaults() const;
94 ///
95 HSpace const & getIndentation() const;
96 ///
97 void setIndentation(HSpace const & indent);
98 ///
99 VSpace const & getDefSkip() const;
101 void setDefSkip(VSpace const & vs);
103 /** Whether paragraphs are separated by using a indent like in
104 * articles or by using a little skip like in letters.
106 ParagraphSeparation paragraph_separation;
108 InsetQuotes::QuoteLanguage quotes_language;
110 InsetQuotes::QuoteTimes quotes_times;
112 std::string fontsize;
113 ///Get the LayoutFile this document is using.
114 LayoutFile const * baseClass() const;
116 LayoutFileIndex const & baseClassID() const;
117 /// Set the LyX layout file this document is using.
118 /// NOTE: This does not call makeDocumentClass() to update the local
119 /// DocumentClass. That needs to be done manually.
120 /// \param filename the name of the layout file
121 bool setBaseClass(std::string const & classname);
122 /// Adds the module information to the baseClass information to
123 /// create our local DocumentClass.
124 void makeDocumentClass();
125 /// Returns the DocumentClass currently in use: the BaseClass as modified
126 /// by modules.
127 DocumentClass const & documentClass() const;
128 /// \return A pointer to the DocumentClass currently in use: the BaseClass
129 /// as modified by modules.
130 DocumentClass const * documentClassPtr() const;
131 /// This bypasses the baseClass and sets the textClass directly.
132 /// Should be called with care and would be better not being here,
133 /// but it seems to be needed by CutAndPaste::putClipboard().
134 void setDocumentClass(DocumentClass const * const);
135 /// List of modules in use
136 LayoutModuleList const & getModules() const { return layoutModules_; }
137 /// List of default modules the user has removed
138 std::list<std::string> const & getRemovedModules() const
139 { return removedModules_; }
141 /// Add a module to the list of modules in use. This checks only that the
142 /// module is not already in the list, so use moduleIsCompatible first if
143 /// you want to check for compatibility.
144 /// \return true if module was successfully added.
145 bool addLayoutModule(std::string const & modName);
146 /// checks to make sure module's requriements are satisfied, that it does
147 /// not conflict with already-present modules, isn't already loaded, etc.
148 bool moduleCanBeAdded(std::string const & modName) const;
150 void addRemovedModule(std::string const & modName)
151 { removedModules_.push_back(modName); }
152 /// Clear the list
153 void clearLayoutModules() { layoutModules_.clear(); }
154 /// Clear the removed module list
155 void clearRemovedModules() { removedModules_.clear(); }
157 /// returns the main font for the buffer (document)
158 Font const getFont() const;
160 /* this are for the PaperLayout */
161 /// the papersize
162 PAPER_SIZE papersize;
164 PAPER_ORIENTATION orientation;
165 /// use custom margins
166 bool use_geometry;
168 std::string paperwidth;
170 std::string paperheight;
172 std::string leftmargin;
174 std::string topmargin;
176 std::string rightmargin;
178 std::string bottommargin;
180 std::string headheight;
182 std::string headsep;
184 std::string footskip;
186 std::string columnsep;
188 /* some LaTeX options */
189 /// The graphics driver
190 std::string graphicsDriver;
191 /// The default output format
192 std::string defaultOutputFormat;
193 /// customized bibliography processor
194 std::string bibtex_command;
195 /// customized index processor
196 std::string index_command;
197 /// the rm font
198 std::string fontsRoman;
199 /// the sf font
200 std::string fontsSans;
201 /// the tt font
202 std::string fontsTypewriter;
203 /// the default family (rm, sf, tt)
204 std::string fontsDefaultFamily;
205 /// use the XeTeX processor
206 bool useXetex;
207 /// use expert Small Caps
208 bool fontsSC;
209 /// use Old Style Figures
210 bool fontsOSF;
211 /// the scale factor of the sf font
212 int fontsSansScale;
213 /// the scale factor of the tt font
214 int fontsTypewriterScale;
215 /// the font used by the CJK command
216 std::string fontsCJK;
218 Spacing & spacing();
219 Spacing const & spacing() const;
221 int secnumdepth;
223 int tocdepth;
225 Language const * language;
226 /// BranchList:
227 BranchList & branchlist();
228 BranchList const & branchlist() const;
229 /// IndicesList:
230 IndicesList & indiceslist();
231 IndicesList const & indiceslist() const;
233 * The input encoding for LaTeX. This can be one of
234 * - \c auto: find out the input encoding from the used languages
235 * - \c default: ditto
236 * - any encoding supported by the inputenc package
237 * The encoding of the LyX file is always utf8 and has nothing to
238 * do with this setting.
239 * The difference between \c auto and \c default is that \c auto also
240 * causes loading of the inputenc package, while \c default does not.
241 * \c default will not work unless the user takes additional measures
242 * (such as using special environments like the CJK environment from
243 * CJK.sty).
244 * \c default can be seen as an unspecified 8bit encoding, since LyX
245 * does not interpret it in any way apart from display on screen.
247 std::string inputenc;
248 /// The main encoding used by this buffer for LaTeX output.
249 /// Individual pieces of text can use different encodings.
250 Encoding const & encoding() const;
252 std::string preamble;
254 std::string local_layout;
256 std::string options;
257 /// use the class options defined in the layout?
258 bool use_default_options;
260 std::string master;
262 bool suppress_date;
264 std::string float_placement;
266 unsigned int columns;
267 /// parameters for the listings package
268 std::string listings_params;
270 PageSides sides;
272 std::string pagestyle;
274 RGBColor backgroundcolor;
275 /// \param index should lie in the range 0 <= \c index <= 3.
276 Bullet & temp_bullet(size_type index);
277 Bullet const & temp_bullet(size_type index) const;
278 /// \param index should lie in the range 0 <= \c index <= 3.
279 Bullet & user_defined_bullet(size_type index);
280 Bullet const & user_defined_bullet(size_type index) const;
282 /// Whether to load a package such as amsmath or esint.
283 /// The enum values must not be changed (file format!)
284 enum Package {
285 /// Don't load the package. For experts only.
286 package_off = 0,
287 /// Load the package if needed (recommended)
288 package_auto = 1,
289 /// Always load the package (e.g. if the document contains
290 /// some ERT that needs the package)
291 package_on = 2
293 /// Whether and how to load amsmath
294 Package use_amsmath;
295 /// Whether and how to load esint
296 Package use_esint;
297 /// Whether and how to load mhchem
298 Package use_mhchem;
299 /// Split bibliography?
300 bool use_bibtopic;
301 /// Split the index?
302 bool use_indices;
303 /// revision tracking for this buffer ?
304 bool trackChanges;
305 /** This param decides whether change tracking marks should be used
306 * in output (irrespective of how these marks are actually defined;
307 * for instance, they may differ for DVI and PDF generation)
309 bool outputChanges;
311 bool compressed;
313 /// the author list for the document
314 AuthorList & authors();
315 AuthorList const & authors() const;
317 /// map of the file's author IDs to AuthorList indexes
318 std::map<unsigned int, int> author_map;
320 std::string const dvips_options() const;
321 /** The return value of paperSizeName() depends on the
322 * purpose for which the paper size is needed, since they
323 * support different subsets of paper sizes.
325 enum PapersizePurpose {
327 DVIPS,
329 DVIPDFM,
331 XDVI
334 std::string paperSizeName(PapersizePurpose purpose) const;
335 /// set up if and how babel is called
336 std::string babelCall(std::string const & lang_opts) const;
337 /// return supported drivers for specific packages
338 docstring getGraphicsDriver(std::string const & package) const;
339 /// handle inputenc etc.
340 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
341 TexRow & texrow) const;
343 std::string const parseFontName(std::string const & name) const;
344 /// set up the document fonts
345 std::string const loadFonts(std::string const & rm,
346 std::string const & sf, std::string const & tt,
347 bool const & sc, bool const & osf,
348 int const & sfscale, int const & ttscale,
349 bool const & xetex) const;
351 /// get the appropriate cite engine (natbib handling)
352 CiteEngine citeEngine() const;
354 void setCiteEngine(CiteEngine const);
356 /// options for pdf output
357 PDFOptions & pdfoptions();
358 PDFOptions const & pdfoptions() const;
360 private:
362 void readPreamble(Lexer &);
364 void readLocalLayout(Lexer &);
366 void readLanguage(Lexer &);
368 void readGraphicsDriver(Lexer &);
370 void readBullets(Lexer &);
372 void readBulletsLaTeX(Lexer &);
374 void readModules(Lexer &);
376 void readRemovedModules(Lexer &);
377 /// for use with natbib
378 CiteEngine cite_engine_;
380 DocumentClass * doc_class_;
381 ///
382 LayoutModuleList layoutModules_;
383 /// this is for modules that are required by the document class but that
384 /// the user has chosen not to use
385 std::list<std::string> removedModules_;
387 /** Use the Pimpl idiom to hide those member variables that would otherwise
388 * drag in other header files.
390 class Impl;
391 class MemoryTraits {
392 public:
393 static Impl * clone(Impl const *);
394 static void destroy(Impl *);
396 support::copied_ptr<Impl, MemoryTraits> pimpl_;
400 } // namespace lyx
402 #endif