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 /// update aux files of unincluded children (with \includeonly)
169 bool maintain_unincluded_children;
171 /// returns the main font for the buffer (document)
172 Font const getFont() const;
174 /* these are for the PaperLayout */
176 PAPER_SIZE papersize;
178 PAPER_ORIENTATION orientation;
179 /// use custom margins
182 std::string paperwidth;
184 std::string paperheight;
186 std::string leftmargin;
188 std::string topmargin;
190 std::string rightmargin;
192 std::string bottommargin;
194 std::string headheight;
198 std::string footskip;
200 std::string columnsep;
202 /* some LaTeX options */
203 /// The graphics driver
204 std::string graphicsDriver;
205 /// The default output format
206 std::string defaultOutputFormat;
207 /// customized bibliography processor
208 std::string bibtex_command;
209 /// customized index processor
210 std::string index_command;
214 std::string fontsRoman;
216 std::string fontsSans;
218 std::string fontsTypewriter;
219 /// the default family (rm, sf, tt)
220 std::string fontsDefaultFamily;
221 /// use the XeTeX processor
223 /// use expert Small Caps
225 /// use Old Style Figures
227 /// the scale factor of the sf font
229 /// the scale factor of the tt font
230 int fontsTypewriterScale;
231 /// the font used by the CJK command
232 std::string fontsCJK;
235 Spacing const & spacing() const;
241 Language const * language;
243 BranchList & branchlist();
244 BranchList const & branchlist() const;
246 IndicesList & indiceslist();
247 IndicesList const & indiceslist() const;
249 * The input encoding for LaTeX. This can be one of
250 * - \c auto: find out the input encoding from the used languages
251 * - \c default: ditto
252 * - any encoding supported by the inputenc package
253 * The encoding of the LyX file is always utf8 and has nothing to
254 * do with this setting.
255 * The difference between \c auto and \c default is that \c auto also
256 * causes loading of the inputenc package, while \c default does not.
257 * \c default will not work unless the user takes additional measures
258 * (such as using special environments like the CJK environment from
260 * \c default can be seen as an unspecified 8bit encoding, since LyX
261 * does not interpret it in any way apart from display on screen.
263 std::string inputenc;
264 /// The main encoding used by this buffer for LaTeX output.
265 /// Individual pieces of text can use different encodings.
266 Encoding const & encoding() const;
268 std::string preamble;
270 std::string local_layout;
273 /// use the class options defined in the layout?
274 bool use_default_options;
280 std::string float_placement;
282 unsigned int columns;
283 /// parameters for the listings package
284 std::string listings_params;
288 std::string pagestyle;
290 RGBColor backgroundcolor;
291 /// \param index should lie in the range 0 <= \c index <= 3.
292 Bullet & temp_bullet(size_type index);
293 Bullet const & temp_bullet(size_type index) const;
294 /// \param index should lie in the range 0 <= \c index <= 3.
295 Bullet & user_defined_bullet(size_type index);
296 Bullet const & user_defined_bullet(size_type index) const;
298 /// Whether to load a package such as amsmath or esint.
299 /// The enum values must not be changed (file format!)
301 /// Don't load the package. For experts only.
303 /// Load the package if needed (recommended)
305 /// Always load the package (e.g. if the document contains
306 /// some ERT that needs the package)
309 /// Whether and how to load amsmath
311 /// Whether and how to load esint
313 /// Whether and how to load mhchem
315 /// Split bibliography?
319 /// revision tracking for this buffer ?
321 /** This param decides whether change tracking marks should be used
322 * in output (irrespective of how these marks are actually defined;
323 * for instance, they may differ for DVI and PDF generation)
329 /// the author list for the document
330 AuthorList & authors();
331 AuthorList const & authors() const;
333 /// map of the file's author IDs to AuthorList indexes
334 std::map<unsigned int, int> author_map;
335 /// the buffer's font encoding
336 std::string const font_encoding() const;
338 std::string const dvips_options() const;
339 /** The return value of paperSizeName() depends on the
340 * purpose for which the paper size is needed, since they
341 * support different subsets of paper sizes.
343 enum PapersizePurpose {
352 std::string paperSizeName(PapersizePurpose purpose) const;
353 /// set up if and how babel is called
354 std::string babelCall(std::string const & lang_opts) const;
355 /// return supported drivers for specific packages
356 docstring getGraphicsDriver(std::string const & package) const;
357 /// handle inputenc etc.
358 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
359 TexRow & texrow) const;
361 std::string const parseFontName(std::string const & name) const;
362 /// set up the document fonts
363 std::string const loadFonts(std::string const & rm,
364 std::string const & sf, std::string const & tt,
365 bool const & sc, bool const & osf,
366 int const & sfscale, int const & ttscale,
367 bool const & xetex) const;
369 /// get the appropriate cite engine (natbib handling)
370 CiteEngine citeEngine() const;
372 void setCiteEngine(CiteEngine const);
374 /// options for pdf output
375 PDFOptions & pdfoptions();
376 PDFOptions const & pdfoptions() const;
384 /// what to use for math output. present choices are above
385 MathOutput html_math_output;
386 /// whether to attempt to be XHTML 1.1 compliant or instead be
387 /// a little more mellow
392 void readPreamble(Lexer &);
394 void readLocalLayout(Lexer &);
396 void readLanguage(Lexer &);
398 void readGraphicsDriver(Lexer &);
400 void readBullets(Lexer &);
402 void readBulletsLaTeX(Lexer &);
404 void readModules(Lexer &);
406 void readRemovedModules(Lexer &);
408 void readIncludeonly(Lexer &);
409 /// for use with natbib
410 CiteEngine cite_engine_;
412 DocumentClass * doc_class_;
414 LayoutModuleList layoutModules_;
415 /// this is for modules that are required by the document class but that
416 /// the user has chosen not to use
417 std::list<std::string> removedModules_;
419 /// the list of included children (for includeonly)
420 std::list<std::string> includedChildren_;
422 /** Use the Pimpl idiom to hide those member variables that would otherwise
423 * drag in other header files.
428 static Impl * clone(Impl const *);
429 static void destroy(Impl *);
431 support::copied_ptr<Impl, MemoryTraits> pimpl_;