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"
21 #include "OutputParams.h"
24 #include "insets/InsetQuotes.h"
26 #include "support/copied_ptr.h"
33 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, a LyXRC variable, and the document class).
86 * This returned value can then be passed to the insets...
88 bool writeLaTeX(otexstream &, LaTeXFeatures &,
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 layout_modules_; }
139 /// List of default modules the user has removed
140 std::list<std::string> const & getRemovedModules() const
141 { return removed_modules_; }
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 { removed_modules_.push_back(modName); }
155 void clearLayoutModules() { layout_modules_.clear(); }
156 /// Clear the removed module list
157 void clearRemovedModules() { removed_modules_.clear(); }
159 /// returns \c true if the buffer contains a LaTeX document
160 bool isLatex() const;
161 /// returns \c true if the buffer contains a DocBook document
162 bool isDocBook() const;
163 /// returns \c true if the buffer contains a Wed document
164 bool isLiterate() const;
166 /// return the format of the buffer on a string
167 std::string bufferFormat() const;
168 /// return the default output format of the current backend
169 std::string getDefaultOutputFormat() const;
170 /// return the output flavor of \p format or the default
171 OutputParams::FLAVOR getOutputFlavor(
172 std::string const format = std::string()) const;
174 bool isExportable(std::string const & format) const;
176 std::vector<Format const *> exportableFormats(bool only_viewable) const;
178 bool isExportableFormat(std::string const & format) const;
180 std::vector<std::string> backends() const;
182 /// List of included children (for includeonly)
183 std::list<std::string> const & getIncludedChildren() const
184 { return included_children_; }
186 void addIncludedChildren(std::string const & child)
187 { included_children_.push_back(child); }
188 /// Clear the list of included children
189 void clearIncludedChildren() { included_children_.clear(); }
191 /// update aux files of unincluded children (with \includeonly)
192 bool maintain_unincluded_children;
194 /// returns the main font for the buffer (document)
195 Font const getFont() const;
197 /* these are for the PaperLayout */
199 PAPER_SIZE papersize;
201 PAPER_ORIENTATION orientation;
202 /// use custom margins
205 std::string paperwidth;
207 std::string paperheight;
209 std::string leftmargin;
211 std::string topmargin;
213 std::string rightmargin;
215 std::string bottommargin;
217 std::string headheight;
221 std::string footskip;
223 std::string columnsep;
225 /* some LaTeX options */
226 /// The graphics driver
227 std::string graphics_driver;
228 /// The default output format
229 std::string default_output_format;
230 /// customized bibliography processor
231 std::string bibtex_command;
232 /// customized index processor
233 std::string index_command;
237 std::string fonts_roman;
239 std::string fonts_sans;
241 std::string fonts_typewriter;
242 /// the default family (rm, sf, tt)
243 std::string fonts_default_family;
244 /// use the fonts of the OS (OpenType, True Type) directly
246 /// use expert Small Caps
247 bool fonts_expert_sc;
248 /// use Old Style Figures
249 bool fonts_old_figures;
250 /// the scale factor of the sf font
251 int fonts_sans_scale;
252 /// the scale factor of the tt font
253 int fonts_typewriter_scale;
254 /// the font used by the CJK command
255 std::string fonts_cjk;
258 Spacing const & spacing() const;
264 Language const * language;
266 std::string lang_package;
268 BranchList & branchlist();
269 BranchList const & branchlist() const;
271 IndicesList & indiceslist();
272 IndicesList const & indiceslist() const;
274 * The input encoding for LaTeX. This can be one of
275 * - \c auto: find out the input encoding from the used languages
276 * - \c default: ditto
277 * - any encoding supported by the inputenc package
278 * The encoding of the LyX file is always utf8 and has nothing to
279 * do with this setting.
280 * The difference between \c auto and \c default is that \c auto also
281 * causes loading of the inputenc package, while \c default does not.
282 * \c default will not work unless the user takes additional measures
283 * (such as using special environments like the CJK environment from
285 * \c default can be seen as an unspecified 8bit encoding, since LyX
286 * does not interpret it in any way apart from display on screen.
288 std::string inputenc;
289 /// The main encoding used by this buffer for LaTeX output.
290 /// Individual pieces of text can use different encodings.
291 Encoding const & encoding() const;
293 std::string preamble;
295 std::string local_layout;
298 /// use the class options defined in the layout?
299 bool use_default_options;
305 std::string float_placement;
307 unsigned int columns;
310 /// parameters for the listings package
311 std::string listings_params;
315 std::string pagestyle;
317 RGBColor backgroundcolor;
319 bool isbackgroundcolor;
325 RGBColor notefontcolor;
328 /// \param index should lie in the range 0 <= \c index <= 3.
329 Bullet & temp_bullet(size_type index);
330 Bullet const & temp_bullet(size_type index) const;
331 /// \param index should lie in the range 0 <= \c index <= 3.
332 Bullet & user_defined_bullet(size_type index);
333 Bullet const & user_defined_bullet(size_type index) const;
335 /// Whether to load a package such as amsmath or esint.
336 /// The enum values must not be changed (file format!)
338 /// Don't load the package. For experts only.
340 /// Load the package if needed (recommended)
342 /// Always load the package (e.g. if the document contains
343 /// some ERT that needs the package)
346 /// Whether and how to load amsmath
348 /// Whether and how to load esint
350 /// Whether and how to load mhchem
352 /// Whether and how to load mathdots
353 Package use_mathdots;
354 /// Whether and how to load undertilde
355 Package use_undertilde;
356 /// Split bibliography?
360 /// revision tracking for this buffer ?
362 /** This param decides whether change tracking marks should be used
363 * in output (irrespective of how these marks are actually defined;
364 * for instance, they may differ for DVI and PDF generation)
370 /// the author list for the document
371 AuthorList & authors();
372 AuthorList const & authors() const;
374 /// map of the file's author IDs to AuthorList indexes
375 typedef std::map<int, int> AuthorMap;
376 AuthorMap author_map;
377 /// the buffer's font encoding
378 std::string const font_encoding() const;
380 std::string const dvips_options() const;
381 /** The return value of paperSizeName() depends on the
382 * purpose for which the paper size is needed, since they
383 * support different subsets of paper sizes.
385 enum PapersizePurpose {
394 std::string paperSizeName(PapersizePurpose purpose) const;
395 /// set up if and how babel is called
396 std::string babelCall(std::string const & lang_opts, bool const langoptions) const;
397 /// return supported drivers for specific packages
398 docstring getGraphicsDriver(std::string const & package) const;
399 /// handle inputenc etc.
400 void writeEncodingPreamble(otexstream & os, LaTeXFeatures & features) const;
402 std::string const parseFontName(std::string const & name) const;
403 /// set up the document fonts
404 std::string const loadFonts(std::string const & rm,
405 std::string const & sf, std::string const & tt,
406 bool const & sc, bool const & osf,
407 int const & sfscale, int const & ttscale,
408 bool const & use_nonlatexfonts,
409 LaTeXFeatures & features) const;
411 /// get the appropriate cite engine (natbib handling)
412 CiteEngine citeEngine() const;
414 void setCiteEngine(CiteEngine const);
416 /// options for pdf output
417 PDFOptions & pdfoptions();
418 PDFOptions const & pdfoptions() const;
420 // do not change these values. we rely upon them.
427 /// what to use for math output. present choices are above
428 MathOutput html_math_output;
429 /// whether to attempt to be XHTML 1.1 compliant or instead be
430 /// a little more mellow
433 double html_math_img_scale;
435 std::string html_latex_start;
437 std::string html_latex_end;
439 bool html_css_as_file;
440 /// generate output usable for reverse/forward search
442 /// custom LaTeX macro from user instead our own
443 std::string output_sync_macro;
444 /// use refstyle? or prettyref?
447 /// Return true if language could be set to lang,
448 /// otherwise return false and do not change language
449 bool setLanguage(std::string const & lang);
453 void readPreamble(Lexer &);
455 void readLocalLayout(Lexer &);
457 void readLanguage(Lexer &);
459 void readGraphicsDriver(Lexer &);
461 void readBullets(Lexer &);
463 void readBulletsLaTeX(Lexer &);
465 void readModules(Lexer &);
467 void readRemovedModules(Lexer &);
469 void readIncludeonly(Lexer &);
470 /// A cache for the default flavors
471 typedef std::map<std::string, OutputParams::FLAVOR> DefaultFlavorCache;
473 mutable DefaultFlavorCache default_flavors_;
474 /// for use with natbib
475 CiteEngine cite_engine_;
477 DocumentClass * doc_class_;
479 LayoutModuleList layout_modules_;
480 /// this is for modules that are required by the document class but that
481 /// the user has chosen not to use
482 std::list<std::string> removed_modules_;
484 /// the list of included children (for includeonly)
485 std::list<std::string> included_children_;
487 /** Use the Pimpl idiom to hide those member variables that would otherwise
488 * drag in other header files.
493 static Impl * clone(Impl const *);
494 static void destroy(Impl *);
496 support::copied_ptr<Impl, MemoryTraits> pimpl_;