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, a LyXRC variable, and the document class).
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 layout_modules_; }
136 /// List of default modules the user has removed
137 std::list<std::string> const & getRemovedModules() const
138 { return removed_modules_; }
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 { removed_modules_.push_back(modName); }
152 void clearLayoutModules() { layout_modules_.clear(); }
153 /// Clear the removed module list
154 void clearRemovedModules() { removed_modules_.clear(); }
156 /// List of included children (for includeonly)
157 std::list<std::string> const & getIncludedChildren() const
158 { return included_children_; }
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(); }
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 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;
211 std::string fonts_roman;
213 std::string fonts_sans;
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
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;
232 Spacing const & spacing() const;
238 Language const * language;
240 std::string lang_package;
242 BranchList & branchlist();
243 BranchList const & branchlist() const;
245 IndicesList & indiceslist();
246 IndicesList const & indiceslist() const;
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
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.
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;
267 std::string preamble;
269 std::string local_layout;
272 /// use the class options defined in the layout?
273 bool use_default_options;
279 std::string float_placement;
281 unsigned int columns;
282 /// parameters for the listings package
283 std::string listings_params;
287 std::string pagestyle;
289 RGBColor backgroundcolor;
291 bool isbackgroundcolor;
297 RGBColor notefontcolor;
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;
307 /// Whether to load a package such as amsmath or esint.
308 /// The enum values must not be changed (file format!)
310 /// Don't load the package. For experts only.
312 /// Load the package if needed (recommended)
314 /// Always load the package (e.g. if the document contains
315 /// some ERT that needs the package)
318 /// Whether and how to load amsmath
320 /// Whether and how to load esint
322 /// Whether and how to load mhchem
324 /// Whether and how to load mathdots
325 Package use_mathdots;
326 /// Split bibliography?
330 /// revision tracking for this buffer ?
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)
340 /// the author list for the document
341 AuthorList & authors();
342 AuthorList const & authors() const;
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;
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.
355 enum PapersizePurpose {
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(odocstream & os, LaTeXFeatures & features,
371 TexRow & texrow) const;
373 std::string const parseFontName(std::string const & name) const;
374 /// set up the document fonts
375 std::string const loadFonts(std::string const & rm,
376 std::string const & sf, std::string const & tt,
377 bool const & sc, bool const & osf,
378 int const & sfscale, int const & ttscale,
379 bool const & use_nonlatexfonts,
380 LaTeXFeatures & features) const;
382 /// get the appropriate cite engine (natbib handling)
383 CiteEngine citeEngine() const;
385 void setCiteEngine(CiteEngine const);
387 /// options for pdf output
388 PDFOptions & pdfoptions();
389 PDFOptions const & pdfoptions() const;
391 // do not change these values. we rely upon them.
398 /// what to use for math output. present choices are above
399 MathOutput html_math_output;
400 /// whether to attempt to be XHTML 1.1 compliant or instead be
401 /// a little more mellow
404 double html_math_img_scale;
406 std::string html_latex_start;
408 std::string html_latex_end;
409 /// generate output usable for reverse/forward search
411 /// custom LaTeX macro from user instead our own
412 std::string output_sync_macro;
413 /// use refstyle? or prettyref?
418 void readPreamble(Lexer &);
420 void readLocalLayout(Lexer &);
422 void readLanguage(Lexer &);
424 void readGraphicsDriver(Lexer &);
426 void readBullets(Lexer &);
428 void readBulletsLaTeX(Lexer &);
430 void readModules(Lexer &);
432 void readRemovedModules(Lexer &);
434 void readIncludeonly(Lexer &);
435 /// for use with natbib
436 CiteEngine cite_engine_;
438 DocumentClass * doc_class_;
440 LayoutModuleList layout_modules_;
441 /// this is for modules that are required by the document class but that
442 /// the user has chosen not to use
443 std::list<std::string> removed_modules_;
445 /// the list of included children (for includeonly)
446 std::list<std::string> included_children_;
448 /** Use the Pimpl idiom to hide those member variables that would otherwise
449 * drag in other header files.
454 static Impl * clone(Impl const *);
455 static void destroy(Impl *);
457 support::copied_ptr<Impl, MemoryTraits> pimpl_;