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
10 * \author André Pönitz
12 * Full author contact details are available in file CREDITS.
15 #ifndef BUFFERPARAMS_H
16 #define BUFFERPARAMS_H
20 #include "LayoutModuleList.h"
23 #include "insets/InsetQuotes.h"
25 #include "support/copied_ptr.h"
26 #include "support/FileName.h"
34 namespace support { class FileName; }
46 class LayoutFileIndex;
53 /** Buffer parameters.
54 * This class contains all the parameters for this buffer's use. Some
55 * work needs to be done on this class to make it nice. Now everything
61 enum ParagraphSeparation {
63 ParagraphIndentSeparation,
65 ParagraphSkipSeparation
70 /// get l10n translated to the buffers language
71 docstring B_(std::string const & l10n) const;
73 /// read a header token, if unrecognised, return it or an unknown class name
74 std::string readToken(Lexer & lex,
75 std::string const & token, ///< token to read.
76 support::FileName const & filepath);
79 void writeFile(std::ostream &) const;
81 /// check what features are implied by the buffer parameters.
82 void validate(LaTeXFeatures &) const;
84 /** \returns true if the babel package is used (interogates
85 * the BufferParams and a LyXRC variable).
86 * This returned value can then be passed to the insets...
88 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &,
89 support::FileName const &) const;
92 void useClassDefaults();
94 bool hasClassDefaults() const;
97 HSpace const & getIndentation() const;
99 void setIndentation(HSpace const & indent);
101 VSpace const & getDefSkip() const;
103 void setDefSkip(VSpace const & vs);
105 /** Whether paragraphs are separated by using a indent like in
106 * articles or by using a little skip like in letters.
108 ParagraphSeparation paragraph_separation;
110 InsetQuotes::QuoteLanguage quotes_language;
112 InsetQuotes::QuoteTimes quotes_times;
114 std::string fontsize;
115 ///Get the LayoutFile this document is using.
116 LayoutFile const * baseClass() const;
118 LayoutFileIndex const & baseClassID() const;
119 /// Set the LyX layout file this document is using.
120 /// NOTE: This does not call makeDocumentClass() to update the local
121 /// DocumentClass. That needs to be done manually.
122 /// \param filename the name of the layout file
123 bool setBaseClass(std::string const & classname);
124 /// Adds the module information to the baseClass information to
125 /// create our local DocumentClass.
126 void makeDocumentClass();
127 /// Returns the DocumentClass currently in use: the BaseClass as modified
129 DocumentClass const & documentClass() const;
130 /// \return A pointer to the DocumentClass currently in use: the BaseClass
131 /// as modified by modules.
132 DocumentClass const * documentClassPtr() const;
133 /// This bypasses the baseClass and sets the textClass directly.
134 /// Should be called with care and would be better not being here,
135 /// but it seems to be needed by CutAndPaste::putClipboard().
136 void setDocumentClass(DocumentClass const * const);
137 /// List of modules in use
138 LayoutModuleList const & getModules() const { return layoutModules_; }
139 /// List of default modules the user has removed
140 std::list<std::string> const & getRemovedModules() const
141 { return removedModules_; }
143 /// Add a module to the list of modules in use. This checks only that the
144 /// module is not already in the list, so use moduleIsCompatible first if
145 /// you want to check for compatibility.
146 /// \return true if module was successfully added.
147 bool addLayoutModule(std::string const & modName);
148 /// checks to make sure module's requriements are satisfied, that it does
149 /// not conflict with already-present modules, isn't already loaded, etc.
150 bool moduleCanBeAdded(std::string const & modName) const;
152 void addRemovedModule(std::string const & modName)
153 { removedModules_.push_back(modName); }
155 void clearLayoutModules() { layoutModules_.clear(); }
156 /// Clear the removed module list
157 void clearRemovedModules() { removedModules_.clear(); }
159 /// List of included children (for includeonly)
160 std::list<std::string> const & getIncludedChildren() const
161 { return includedChildren_; }
163 void addIncludedChildren(std::string const & child)
164 { includedChildren_.push_back(child); }
165 /// Clear the list of included children
166 void clearIncludedChildren() { includedChildren_.clear(); }
168 /// returns the main font for the buffer (document)
169 Font const getFont() const;
171 /* these are for the PaperLayout */
173 PAPER_SIZE papersize;
175 PAPER_ORIENTATION orientation;
176 /// use custom margins
179 std::string paperwidth;
181 std::string paperheight;
183 std::string leftmargin;
185 std::string topmargin;
187 std::string rightmargin;
189 std::string bottommargin;
191 std::string headheight;
195 std::string footskip;
197 std::string columnsep;
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;
211 std::string fontsRoman;
213 std::string fontsSans;
215 std::string fontsTypewriter;
216 /// the default family (rm, sf, tt)
217 std::string fontsDefaultFamily;
218 /// use the XeTeX processor
220 /// use expert Small Caps
222 /// use Old Style Figures
224 /// the scale factor of the sf font
226 /// the scale factor of the tt font
227 int fontsTypewriterScale;
228 /// the font used by the CJK command
229 std::string fontsCJK;
232 Spacing const & spacing() const;
238 Language const * language;
240 BranchList & branchlist();
241 BranchList const & branchlist() const;
243 IndicesList & indiceslist();
244 IndicesList const & indiceslist() const;
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
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.
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;
265 std::string preamble;
267 std::string local_layout;
270 /// use the class options defined in the layout?
271 bool use_default_options;
277 std::string float_placement;
279 unsigned int columns;
280 /// parameters for the listings package
281 std::string listings_params;
285 std::string pagestyle;
287 RGBColor backgroundcolor;
288 /// \param index should lie in the range 0 <= \c index <= 3.
289 Bullet & temp_bullet(size_type index);
290 Bullet const & temp_bullet(size_type index) const;
291 /// \param index should lie in the range 0 <= \c index <= 3.
292 Bullet & user_defined_bullet(size_type index);
293 Bullet const & user_defined_bullet(size_type index) const;
295 /// Whether to load a package such as amsmath or esint.
296 /// The enum values must not be changed (file format!)
298 /// Don't load the package. For experts only.
300 /// Load the package if needed (recommended)
302 /// Always load the package (e.g. if the document contains
303 /// some ERT that needs the package)
306 /// Whether and how to load amsmath
308 /// Whether and how to load esint
310 /// Whether and how to load mhchem
312 /// Split bibliography?
316 /// revision tracking for this buffer ?
318 /** This param decides whether change tracking marks should be used
319 * in output (irrespective of how these marks are actually defined;
320 * for instance, they may differ for DVI and PDF generation)
326 /// the author list for the document
327 AuthorList & authors();
328 AuthorList const & authors() const;
330 /// map of the file's author IDs to AuthorList indexes
331 std::map<unsigned int, int> author_map;
332 /// the buffer's font encoding
333 std::string const font_encoding() const;
335 std::string const dvips_options() const;
336 /** The return value of paperSizeName() depends on the
337 * purpose for which the paper size is needed, since they
338 * support different subsets of paper sizes.
340 enum PapersizePurpose {
349 std::string paperSizeName(PapersizePurpose purpose) const;
350 /// set up if and how babel is called
351 std::string babelCall(std::string const & lang_opts) const;
352 /// return supported drivers for specific packages
353 docstring getGraphicsDriver(std::string const & package) const;
354 /// handle inputenc etc.
355 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
356 TexRow & texrow) const;
358 std::string const parseFontName(std::string const & name) const;
359 /// set up the document fonts
360 std::string const loadFonts(std::string const & rm,
361 std::string const & sf, std::string const & tt,
362 bool const & sc, bool const & osf,
363 int const & sfscale, int const & ttscale,
364 bool const & xetex) const;
366 /// get the appropriate cite engine (natbib handling)
367 CiteEngine citeEngine() const;
369 void setCiteEngine(CiteEngine const);
371 /// options for pdf output
372 PDFOptions & pdfoptions();
373 PDFOptions const & pdfoptions() const;
375 /// whether to use MathML for math output, or instead images
376 bool html_use_mathml;
377 /// whether to attempt to be XHTML 1.1 compliant or instead be
378 /// a little more mellow
383 void readPreamble(Lexer &);
385 void readLocalLayout(Lexer &);
387 void readLanguage(Lexer &);
389 void readGraphicsDriver(Lexer &);
391 void readBullets(Lexer &);
393 void readBulletsLaTeX(Lexer &);
395 void readModules(Lexer &);
397 void readRemovedModules(Lexer &);
399 void readIncludeonly(Lexer &);
400 /// for use with natbib
401 CiteEngine cite_engine_;
403 DocumentClass * doc_class_;
405 LayoutModuleList layoutModules_;
406 /// this is for modules that are required by the document class but that
407 /// the user has chosen not to use
408 std::list<std::string> removedModules_;
410 /// the list of included children (for includeonly)
411 std::list<std::string> includedChildren_;
413 /** Use the Pimpl idiom to hide those member variables that would otherwise
414 * drag in other header files.
419 static Impl * clone(Impl const *);
420 static void destroy(Impl *);
422 support::copied_ptr<Impl, MemoryTraits> pimpl_;