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"
32 namespace support { class FileName; }
44 class LayoutFileIndex;
51 /** Buffer parameters.
52 * This class contains all the parameters for this buffer's use. Some
53 * work needs to be done on this class to make it nice. Now everything
59 enum ParagraphSeparation {
61 ParagraphIndentSeparation,
63 ParagraphSkipSeparation
68 /// get l10n translated to the buffers language
69 docstring B_(std::string const & l10n) const;
71 /// read a header token, if unrecognised, return it or an unknown class name
72 std::string readToken(Lexer & lex,
73 std::string const & token, ///< token to read.
74 support::FileName const & filepath);
77 void writeFile(std::ostream &) const;
79 /// check what features are implied by the buffer parameters.
80 void validate(LaTeXFeatures &) const;
82 /** \returns true if the babel package is used (interogates
83 * the BufferParams and a LyXRC variable).
84 * This returned value can then be passed to the insets...
86 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) 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 /// returns the main font for the buffer (document)
157 Font const getFont() const;
159 /* this are for the PaperLayout */
161 PAPER_SIZE papersize;
163 PAPER_ORIENTATION orientation;
164 /// use custom margins
167 std::string paperwidth;
169 std::string paperheight;
171 std::string leftmargin;
173 std::string topmargin;
175 std::string rightmargin;
177 std::string bottommargin;
179 std::string headheight;
183 std::string footskip;
185 std::string columnsep;
187 /* some LaTeX options */
188 /// The graphics driver
189 std::string graphicsDriver;
190 /// The default output format
191 std::string defaultOutputFormat;
192 /// customized bibliography processor
193 std::string bibtex_command;
194 /// customized index processor
195 std::string index_command;
197 std::string fontsRoman;
199 std::string fontsSans;
201 std::string fontsTypewriter;
202 /// the default family (rm, sf, tt)
203 std::string fontsDefaultFamily;
204 /// use the XeTeX processor
206 /// use expert Small Caps
208 /// use Old Style Figures
210 /// the scale factor of the sf font
212 /// the scale factor of the tt font
213 int fontsTypewriterScale;
214 /// the font used by the CJK command
215 std::string fontsCJK;
218 Spacing const & spacing() const;
224 Language const * language;
226 BranchList & branchlist();
227 BranchList const & branchlist() const;
229 IndicesList & indiceslist();
230 IndicesList const & indiceslist() const;
232 * The input encoding for LaTeX. This can be one of
233 * - \c auto: find out the input encoding from the used languages
234 * - \c default: ditto
235 * - any encoding supported by the inputenc package
236 * The encoding of the LyX file is always utf8 and has nothing to
237 * do with this setting.
238 * The difference between \c auto and \c default is that \c auto also
239 * causes loading of the inputenc package, while \c default does not.
240 * \c default will not work unless the user takes additional measures
241 * (such as using special environments like the CJK environment from
243 * \c default can be seen as an unspecified 8bit encoding, since LyX
244 * does not interpret it in any way apart from display on screen.
246 std::string inputenc;
247 /// The main encoding used by this buffer for LaTeX output.
248 /// Individual pieces of text can use different encodings.
249 Encoding const & encoding() const;
251 std::string preamble;
253 std::string local_layout;
256 /// use the class options defined in the layout?
257 bool use_default_options;
261 std::string float_placement;
263 unsigned int columns;
264 /// parameters for the listings package
265 std::string listings_params;
269 std::string pagestyle;
271 RGBColor backgroundcolor;
272 /// \param index should lie in the range 0 <= \c index <= 3.
273 Bullet & temp_bullet(size_type index);
274 Bullet const & temp_bullet(size_type index) const;
275 /// \param index should lie in the range 0 <= \c index <= 3.
276 Bullet & user_defined_bullet(size_type index);
277 Bullet const & user_defined_bullet(size_type index) const;
279 /// Whether to load a package such as amsmath or esint.
280 /// The enum values must not be changed (file format!)
282 /// Don't load the package. For experts only.
284 /// Load the package if needed (recommended)
286 /// Always load the package (e.g. if the document contains
287 /// some ERT that needs the package)
290 /// Whether and how to load amsmath
292 /// Whether and how to load esint
294 /// Split bibliography?
298 /// revision tracking for this buffer ?
300 /** This param decides whether change tracking marks should be used
301 * in output (irrespective of how these marks are actually defined;
302 * for instance, they may differ for DVI and PDF generation)
308 /// the author list for the document
309 AuthorList & authors();
310 AuthorList const & authors() const;
312 /// map of the file's author IDs to buffer author IDs
313 std::vector<unsigned int> author_map;
315 std::string const dvips_options() const;
316 /** The return value of paperSizeName() depends on the
317 * purpose for which the paper size is needed, since they
318 * support different subsets of paper sizes.
320 enum PapersizePurpose {
329 std::string paperSizeName(PapersizePurpose purpose) const;
330 /// set up if and how babel is called
331 std::string babelCall(std::string const & lang_opts) const;
332 /// return supported drivers for specific packages
333 docstring getGraphicsDriver(std::string const & package) const;
334 /// handle inputenc etc.
335 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
336 TexRow & texrow) const;
338 std::string const parseFontName(std::string const & name) const;
339 /// set up the document fonts
340 std::string const loadFonts(std::string const & rm,
341 std::string const & sf, std::string const & tt,
342 bool const & sc, bool const & osf,
343 int const & sfscale, int const & ttscale,
344 bool const & xetex) const;
346 /// get the appropriate cite engine (natbib handling)
347 CiteEngine citeEngine() const;
349 void setCiteEngine(CiteEngine const);
351 /// options for pdf output
352 PDFOptions & pdfoptions();
353 PDFOptions const & pdfoptions() const;
357 void readPreamble(Lexer &);
359 void readLocalLayout(Lexer &);
361 void readLanguage(Lexer &);
363 void readGraphicsDriver(Lexer &);
365 void readBullets(Lexer &);
367 void readBulletsLaTeX(Lexer &);
369 void readModules(Lexer &);
371 void readRemovedModules(Lexer &);
372 /// for use with natbib
373 CiteEngine cite_engine_;
375 DocumentClass * doc_class_;
377 LayoutModuleList layoutModules_;
378 /// this is for modules that are required by the document class but that
379 /// the user has chosen not to use
380 std::list<std::string> removedModules_;
382 /** Use the Pimpl idiom to hide those member variables that would otherwise
383 * drag in other header files.
388 static Impl * clone(Impl const *);
389 static void destroy(Impl *);
391 support::copied_ptr<Impl, MemoryTraits> pimpl_;