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 "DocumentClassPtr.h"
21 #include "LayoutModuleList.h"
22 #include "OutputParams.h"
25 #include "insets/InsetQuotes.h"
27 #include "support/copied_ptr.h"
34 namespace support { class FileName; }
47 class LayoutFileIndex;
54 /** Buffer parameters.
55 * This class contains all the parameters for this buffer's use. Some
56 * work needs to be done on this class to make it nice. Now everything
62 enum ParagraphSeparation {
64 ParagraphIndentSeparation,
66 ParagraphSkipSeparation
71 /// get l10n translated to the buffers language
72 docstring B_(std::string const & l10n) const;
74 /// read a header token, if unrecognised, return it or an unknown class name
75 std::string readToken(Lexer & lex,
76 std::string const & token, ///< token to read.
77 support::FileName const & filepath);
80 void writeFile(std::ostream &) const;
82 /// check what features are implied by the buffer parameters.
83 void validate(LaTeXFeatures &) const;
85 /** \returns true if the babel package is used (interogates
86 * the BufferParams, a LyXRC variable, and the document class).
87 * This returned value can then be passed to the insets...
89 bool writeLaTeX(otexstream &, LaTeXFeatures &,
90 support::FileName const &) const;
93 void useClassDefaults();
95 bool hasClassDefaults() const;
98 HSpace const & getIndentation() const;
100 void setIndentation(HSpace const & indent);
102 VSpace const & getDefSkip() const;
104 void setDefSkip(VSpace const & vs);
106 /** Whether paragraphs are separated by using a indent like in
107 * articles or by using a little skip like in letters.
109 ParagraphSeparation paragraph_separation;
111 InsetQuotes::QuoteLanguage quotes_language;
113 InsetQuotes::QuoteTimes quotes_times;
115 std::string fontsize;
116 /// Get the LayoutFile this document is using.
117 LayoutFile const * baseClass() const;
119 LayoutFileIndex const & baseClassID() const;
120 /// Set the LyX layout file this document is using.
121 /// NOTE: This does not call makeDocumentClass() to update the local
122 /// DocumentClass. That needs to be done manually.
123 /// \param filename the name of the layout file
124 bool setBaseClass(std::string const & classname);
125 /// Adds the module information to the baseClass information to
126 /// create our local DocumentClass.
127 void makeDocumentClass();
128 /// Returns the DocumentClass currently in use: the BaseClass as modified
130 DocumentClass const & documentClass() const;
131 /// \return A pointer to the DocumentClass currently in use: the BaseClass
132 /// as modified by modules.
133 DocumentClassConstPtr documentClassPtr() const;
134 /// This bypasses the baseClass and sets the textClass directly.
135 /// Should be called with care and would be better not being here,
136 /// but it seems to be needed by CutAndPaste::putClipboard().
137 void setDocumentClass(DocumentClassConstPtr);
138 /// List of modules in use
139 LayoutModuleList const & getModules() const { return layout_modules_; }
140 /// List of default modules the user has removed
141 std::list<std::string> const & getRemovedModules() const
142 { return removed_modules_; }
144 /// Add a module to the list of modules in use. This checks only that the
145 /// module is not already in the list, so use moduleIsCompatible first if
146 /// you want to check for compatibility.
147 /// \return true if module was successfully added.
148 bool addLayoutModule(std::string const & modName);
149 /// checks to make sure module's requriements are satisfied, that it does
150 /// not conflict with already-present modules, isn't already loaded, etc.
151 bool moduleCanBeAdded(std::string const & modName) const;
153 void addRemovedModule(std::string const & modName)
154 { removed_modules_.push_back(modName); }
156 void clearLayoutModules() { layout_modules_.clear(); }
157 /// Clear the removed module list
158 void clearRemovedModules() { removed_modules_.clear(); }
160 /// returns \c true if the buffer contains a LaTeX document
161 bool isLatex() const;
162 /// returns \c true if the buffer contains a DocBook document
163 bool isDocBook() const;
164 /// returns \c true if the buffer contains a Wed document
165 bool isLiterate() const;
167 /// return the format of the buffer on a string
168 std::string bufferFormat() const;
169 /// return the default output format of the current backend
170 std::string getDefaultOutputFormat() const;
171 /// return the output flavor of \p format or the default
172 OutputParams::FLAVOR getOutputFlavor(
173 std::string const format = std::string()) const;
175 bool isExportable(std::string const & format) const;
177 std::vector<Format const *> exportableFormats(bool only_viewable) const;
179 bool isExportableFormat(std::string const & format) const;
180 /// the backends appropriate for use with this document.
181 /// so, e.g., latex is excluded , if we're using non-TeX fonts
182 std::vector<std::string> backends() const;
184 /// List of included children (for includeonly)
185 std::list<std::string> const & getIncludedChildren() const
186 { return included_children_; }
188 void addIncludedChildren(std::string const & child)
189 { included_children_.push_back(child); }
190 /// Clear the list of included children
191 void clearIncludedChildren() { included_children_.clear(); }
193 /// update aux files of unincluded children (with \includeonly)
194 bool maintain_unincluded_children;
196 /// returns the main font for the buffer (document)
197 Font const getFont() const;
199 /* these are for the PaperLayout */
201 PAPER_SIZE papersize;
203 PAPER_ORIENTATION orientation;
204 /// use custom margins
207 std::string paperwidth;
209 std::string paperheight;
211 std::string leftmargin;
213 std::string topmargin;
215 std::string rightmargin;
217 std::string bottommargin;
219 std::string headheight;
223 std::string footskip;
225 std::string columnsep;
227 /* some LaTeX options */
228 /// The graphics driver
229 std::string graphics_driver;
230 /// The default output format
231 std::string default_output_format;
232 /// customized bibliography processor
233 std::string bibtex_command;
234 /// customized index processor
235 std::string index_command;
239 std::string fonts_roman;
241 std::string fonts_sans;
243 std::string fonts_typewriter;
244 /// the default family (rm, sf, tt)
245 std::string fonts_default_family;
246 /// use the fonts of the OS (OpenType, True Type) directly
248 /// use expert Small Caps
249 bool fonts_expert_sc;
250 /// use Old Style Figures
251 bool fonts_old_figures;
252 /// the scale factor of the sf font
253 int fonts_sans_scale;
254 /// the scale factor of the tt font
255 int fonts_typewriter_scale;
256 /// the font used by the CJK command
257 std::string fonts_cjk;
260 Spacing const & spacing() const;
266 Language const * language;
268 std::string lang_package;
270 BranchList & branchlist();
271 BranchList const & branchlist() const;
273 IndicesList & indiceslist();
274 IndicesList const & indiceslist() const;
276 * The input encoding for LaTeX. This can be one of
277 * - \c auto: find out the input encoding from the used languages
278 * - \c default: ditto
279 * - any encoding supported by the inputenc package
280 * The encoding of the LyX file is always utf8 and has nothing to
281 * do with this setting.
282 * The difference between \c auto and \c default is that \c auto also
283 * causes loading of the inputenc package, while \c default does not.
284 * \c default will not work unless the user takes additional measures
285 * (such as using special environments like the CJK environment from
287 * \c default can be seen as an unspecified 8bit encoding, since LyX
288 * does not interpret it in any way apart from display on screen.
290 std::string inputenc;
291 /// The main encoding used by this buffer for LaTeX output.
292 /// Individual pieces of text can use different encodings.
293 Encoding const & encoding() const;
295 std::string preamble;
297 std::string local_layout;
300 /// use the class options defined in the layout?
301 bool use_default_options;
307 std::string float_placement;
309 unsigned int columns;
312 /// parameters for the listings package
313 std::string listings_params;
317 std::string pagestyle;
319 RGBColor backgroundcolor;
321 bool isbackgroundcolor;
327 RGBColor notefontcolor;
330 /// \param index should lie in the range 0 <= \c index <= 3.
331 Bullet & temp_bullet(size_type index);
332 Bullet const & temp_bullet(size_type index) const;
333 /// \param index should lie in the range 0 <= \c index <= 3.
334 Bullet & user_defined_bullet(size_type index);
335 Bullet const & user_defined_bullet(size_type index) const;
337 /// Whether to load a package such as amsmath or esint.
338 /// The enum values must not be changed (file format!)
340 /// Don't load the package. For experts only.
342 /// Load the package if needed (recommended)
344 /// Always load the package (e.g. if the document contains
345 /// some ERT that needs the package)
348 /// Whether to load a package such as amsmath or esint.
349 Package use_package(std::string const & p) const;
350 /// Set whether to load a package such as amsmath or esint.
351 void use_package(std::string const & p, Package u);
352 /// All packages that can be switched on or off
353 static std::vector<std::string> const & auto_packages();
354 /// Split bibliography?
358 /// revision tracking for this buffer ?
360 /** This param decides whether change tracking marks should be used
361 * in output (irrespective of how these marks are actually defined;
362 * for instance, they may differ for DVI and PDF generation)
368 /// the author list for the document
369 AuthorList & authors();
370 AuthorList const & authors() const;
372 /// map of the file's author IDs to AuthorList indexes
373 typedef std::map<int, int> AuthorMap;
374 AuthorMap author_map;
375 /// the buffer's font encoding
376 std::string const font_encoding() const;
378 std::string const dvips_options() const;
379 /** The return value of paperSizeName() depends on the
380 * purpose for which the paper size is needed, since they
381 * support different subsets of paper sizes.
383 enum PapersizePurpose {
392 std::string paperSizeName(PapersizePurpose purpose) const;
393 /// set up if and how babel is called
394 std::string babelCall(std::string const & lang_opts, bool const langoptions) const;
395 /// return supported drivers for specific packages
396 docstring getGraphicsDriver(std::string const & package) const;
397 /// handle inputenc etc.
398 void writeEncodingPreamble(otexstream & os, LaTeXFeatures & features) const;
400 std::string const parseFontName(std::string const & name) const;
401 /// set up the document fonts
402 std::string const loadFonts(std::string const & rm,
403 std::string const & sf, std::string const & tt,
404 bool const & sc, bool const & osf,
405 int const & sfscale, int const & ttscale,
406 bool const & use_nonlatexfonts,
407 LaTeXFeatures & features) const;
409 /// the cite engine modules
410 LayoutModuleList const & citeEngine() const
411 { return cite_engine_; }
412 /// the type of cite engine (authoryear or numerical)
413 CiteEngineType const & citeEngineType() const
414 { return cite_engine_type_; }
415 /// add the module to the cite engine modules
416 bool addCiteEngine(std::string const &);
417 /// add the modules to the cite engine modules
418 bool addCiteEngine(std::vector<std::string> const &);
419 /// clear the list of cite engine modules
420 void clearCiteEngine() { cite_engine_.clear(); }
421 /// set the cite engine module
422 void setCiteEngine(std::string const &);
423 /// set the cite engine modules
424 void setCiteEngine(std::vector<std::string> const &);
425 /// set the cite engine type
426 void setCiteEngineType(CiteEngineType const & engine_type)
427 { cite_engine_type_ = engine_type; }
429 /// the available citation commands
430 std::vector<std::string> citeCommands() const;
431 /// the available citation styles
432 std::vector<CitationStyle> citeStyles() const;
434 /// the default BibTeX style file for the document
435 std::string biblio_style;
436 /// the default BibTeX style file from the TextClass
437 std::string const & defaultBiblioStyle() const;
438 /// whether the BibTeX style supports full author lists
439 bool const & fullAuthorList() const;
441 /// options for pdf output
442 PDFOptions & pdfoptions();
443 PDFOptions const & pdfoptions() const;
445 // do not change these values. we rely upon them.
452 /// what to use for math output. present choices are above
453 MathOutput html_math_output;
454 /// whether to attempt to be XHTML 1.1 compliant or instead be
455 /// a little more mellow
458 double html_math_img_scale;
460 std::string html_latex_start;
462 std::string html_latex_end;
464 bool html_css_as_file;
465 /// generate output usable for reverse/forward search
467 /// custom LaTeX macro from user instead our own
468 std::string output_sync_macro;
469 /// use refstyle? or prettyref?
472 /// Return true if language could be set to lang,
473 /// otherwise return false and do not change language
474 bool setLanguage(std::string const & lang);
478 void readPreamble(Lexer &);
480 void readLocalLayout(Lexer &);
482 void readLanguage(Lexer &);
484 void readGraphicsDriver(Lexer &);
486 void readBullets(Lexer &);
488 void readBulletsLaTeX(Lexer &);
490 void readModules(Lexer &);
492 void readRemovedModules(Lexer &);
494 void readIncludeonly(Lexer &);
495 /// A cache for the default flavors
496 typedef std::map<std::string, OutputParams::FLAVOR> DefaultFlavorCache;
498 mutable DefaultFlavorCache default_flavors_;
499 /// the cite engine modules
500 LayoutModuleList cite_engine_;
501 /// the type of cite engine (authoryear or numerical)
502 CiteEngineType cite_engine_type_;
504 DocumentClassPtr doc_class_;
506 LayoutModuleList layout_modules_;
507 /// this is for modules that are required by the document class but that
508 /// the user has chosen not to use
509 std::list<std::string> removed_modules_;
511 /// the list of included children (for includeonly)
512 std::list<std::string> included_children_;
514 typedef std::map<std::string, Package> PackageMap;
515 /** Whether and how to load packages like amsmath, esint, mhchem,
516 * mathdots and undertilde.
518 PackageMap use_packages;
520 /** Use the Pimpl idiom to hide those member variables that would otherwise
521 * drag in other header files.
526 static Impl * clone(Impl const *);
527 static void destroy(Impl *);
529 support::copied_ptr<Impl, MemoryTraits> pimpl_;