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
19 #include "LayoutModuleList.h"
22 #include "insets/InsetQuotes.h"
24 #include "support/copied_ptr.h"
30 namespace support { class FileName; }
43 class LayoutFileIndex;
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
58 enum ParagraphSeparation {
60 ParagraphIndentSeparation,
62 ParagraphSkipSeparation
67 /// get l10n translated to the buffers language
68 docstring B_(std::string const & l10n) const;
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);
76 void writeFile(std::ostream &) const;
78 /// check what features are implied by the buffer parameters.
79 void validate(LaTeXFeatures &) const;
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...
85 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &,
86 support::FileName const &) const;
89 void useClassDefaults();
91 bool hasClassDefaults() const;
94 HSpace const & getIndentation() const;
96 void setIndentation(HSpace const & indent);
98 VSpace const & getDefSkip() const;
100 void setDefSkip(VSpace const & vs);
102 /** Whether paragraphs are separated by using a indent like in
103 * articles or by using a little skip like in letters.
105 ParagraphSeparation paragraph_separation;
107 InsetQuotes::QuoteLanguage quotes_language;
109 InsetQuotes::QuoteTimes quotes_times;
111 std::string fontsize;
112 ///Get the LayoutFile this document is using.
113 LayoutFile const * baseClass() const;
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
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_; }
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;
149 void addRemovedModule(std::string const & modName)
150 { removedModules_.push_back(modName); }
152 void clearLayoutModules() { layoutModules_.clear(); }
153 /// Clear the removed module list
154 void clearRemovedModules() { removedModules_.clear(); }
156 /// List of included children (for includeonly)
157 std::list<std::string> const & getIncludedChildren() const
158 { return includedChildren_; }
160 void addIncludedChildren(std::string const & child)
161 { includedChildren_.push_back(child); }
162 /// Clear the list of included children
163 void clearIncludedChildren() { includedChildren_.clear(); }
165 /// update aux files of unincluded children (with \includeonly)
166 bool maintain_unincluded_children;
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;
289 bool isbackgroundcolor;
295 RGBColor notefontcolor;
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;
305 /// Whether to load a package such as amsmath or esint.
306 /// The enum values must not be changed (file format!)
308 /// Don't load the package. For experts only.
310 /// Load the package if needed (recommended)
312 /// Always load the package (e.g. if the document contains
313 /// some ERT that needs the package)
316 /// Whether and how to load amsmath
318 /// Whether and how to load esint
320 /// Whether and how to load mhchem
322 /// Split bibliography?
326 /// revision tracking for this buffer ?
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)
336 /// the author list for the document
337 AuthorList & authors();
338 AuthorList const & authors() const;
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;
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.
350 enum PapersizePurpose {
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;
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;
376 /// get the appropriate cite engine (natbib handling)
377 CiteEngine citeEngine() const;
379 void setCiteEngine(CiteEngine const);
381 /// options for pdf output
382 PDFOptions & pdfoptions();
383 PDFOptions const & pdfoptions() const;
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
397 double html_math_img_scale;
399 std::string html_latex_start;
401 std::string html_latex_end;
402 /// generate output usable for reverse/forward search
404 /// custom LaTeX macro from user instead our own
405 std::string output_sync_macro;
409 void readPreamble(Lexer &);
411 void readLocalLayout(Lexer &);
413 void readLanguage(Lexer &);
415 void readGraphicsDriver(Lexer &);
417 void readBullets(Lexer &);
419 void readBulletsLaTeX(Lexer &);
421 void readModules(Lexer &);
423 void readRemovedModules(Lexer &);
425 void readIncludeonly(Lexer &);
426 /// for use with natbib
427 CiteEngine cite_engine_;
429 DocumentClass * doc_class_;
431 LayoutModuleList layoutModules_;
432 /// this is for modules that are required by the document class but that
433 /// the user has chosen not to use
434 std::list<std::string> removedModules_;
436 /// the list of included children (for includeonly)
437 std::list<std::string> includedChildren_;
439 /** Use the Pimpl idiom to hide those member variables that would otherwise
440 * drag in other header files.
445 static Impl * clone(Impl const *);
446 static void destroy(Impl *);
448 support::copied_ptr<Impl, MemoryTraits> pimpl_;