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 "BiblioInfo.h"
21 #include "TextClassPtr.h"
23 #include "insets/InsetQuotes.h"
25 #include "support/copied_ptr.h"
26 #include "support/types.h"
49 /** Buffer parameters.
50 * This class contains all the parameters for this buffer's use. Some
51 * work needs to be done on this class to make it nice. Now everything
67 /// get l10n translated to the buffers language
68 docstring const B_(std::string const & l10n) const;
70 /// read a header token, if unrecognised, return it or an unknown class name
71 std::string const readToken(Lexer & lex,
72 std::string const & token, ///< token to read.
73 support::FileName const & filepath); ///< where to look for local layout file.
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 &) const;
88 void useClassDefaults();
91 bool hasClassDefaults() const;
94 VSpace const & getDefSkip() const;
97 void setDefSkip(VSpace const & vs);
99 /** Whether paragraphs are separated by using a indent like in
100 * articles or by using a little skip like in letters.
102 PARSEP paragraph_separation;
104 InsetQuotes::quote_language quotes_language;
106 InsetQuotes::quote_times quotes_times;
108 std::string fontsize;
109 ///Get the LyX TextClass (that is, the layout file) this document is using.
110 textclass_type baseClass() const;
111 /// Set the LyX TextClass (that is, the layout file) this document is using.
112 /// NOTE: This does not call makeTextClass() to update the local TextClass.
113 /// That needs to be done manually.
114 bool setBaseClass(textclass_type);
115 /// Adds the module information to the baseClass information to
116 /// create our local TextClass.
117 void makeTextClass();
118 /// Returns the TextClass currently in use: the BaseClass as modified
120 TextClass const & textClass() const;
121 /// Returns a pointer to the TextClass currently in use: the BaseClass
122 /// as modified by modules. (See \file TextClassPtr.h for the typedef.)
123 TextClassPtr textClassPtr() const;
124 /// This bypasses the baseClass and sets the textClass directly.
125 /// Should be called with care and would be better not being here,
126 /// but it seems to be needed by CutAndPaste::putClipboard().
127 void setTextClass(TextClassPtr);
128 /// List of modules in use
129 std::vector<std::string> const & getModules() const;
130 /// Add a module to the list of modules in use.
131 /// Returns true if module was successfully added.
132 /// The makeClass variable signals whether to call makeTextClass. This
133 /// need not be done if we know this isn't the final time through, or if
134 /// the BufferParams do not represent the parameters for an actual buffer
135 /// (as in GuiDocument).
136 bool addLayoutModule(std::string const & modName);
138 void clearLayoutModules();
140 /// returns the main font for the buffer (document)
141 Font const getFont() const;
143 /* this are for the PaperLayout */
145 PAPER_SIZE papersize;
147 PAPER_ORIENTATION orientation;
148 /// use custom margins
151 std::string paperwidth;
153 std::string paperheight;
155 std::string leftmargin;
157 std::string topmargin;
159 std::string rightmargin;
161 std::string bottommargin;
163 std::string headheight;
167 std::string footskip;
169 std::string columnsep;
171 /* some LaTeX options */
172 /// The graphics driver
173 std::string graphicsDriver;
175 std::string fontsRoman;
177 std::string fontsSans;
179 std::string fontsTypewriter;
180 /// the default family (rm, sf, tt)
181 std::string fontsDefaultFamily;
182 /// use expert Small Caps
184 /// use Old Style Figures
186 /// the scale factor of the sf font
188 /// the scale factor of the tt font
189 int fontsTypewriterScale;
192 Spacing const & spacing() const;
198 Language const * language;
200 BranchList & branchlist();
201 BranchList const & branchlist() const;
203 * The input encoding for LaTeX. This can be one of
204 * - \c auto: find out the input encoding from the used languages
205 * - \c default: ditto
206 * - any encoding supported by the inputenc package
207 * The encoding of the LyX file is always utf8 and has nothing to
208 * do with this setting.
209 * The difference between \c auto and \c default is that \c auto also
210 * causes loading of the inputenc package, while \c default does not.
211 * \c default will not work unless the user takes additional measures
212 * (such as using special environments like the CJK environment from
214 * \c default can be seen as an unspecified 8bit encoding, since LyX
215 * does not interpret it in any way apart from display on screen.
217 std::string inputenc;
218 /// The main encoding used by this buffer for LaTeX output.
219 /// Individual pieces of text can use different encodings.
220 Encoding const & encoding() const;
222 std::string preamble;
226 std::string float_placement;
228 unsigned int columns;
229 /// parameters for the listings package
230 std::string listings_params;
234 std::string pagestyle;
235 /// \param index should lie in the range 0 <= \c index <= 3.
236 Bullet & temp_bullet(size_type index);
237 Bullet const & temp_bullet(size_type index) const;
238 /// \param index should lie in the range 0 <= \c index <= 3.
239 Bullet & user_defined_bullet(size_type index);
240 Bullet const & user_defined_bullet(size_type index) const;
242 /// Whether to load a package such as amsmath or esint.
243 /// The enum values must not be changed (file format!)
245 /// Don't load the package. For experts only.
247 /// Load the package if needed (recommended)
249 /// Always load the package (e.g. if the document contains
250 /// some ERT that needs the package)
253 /// Whether and how to load amsmath
255 /// Whether and how to load esint
259 /// revision tracking for this buffer ?
261 /** This param decides whether change tracking marks should be used
262 * in output (irrespective of how these marks are actually defined;
263 * for instance, they may differ for DVI and PDF generation)
271 /// the author list for the document
272 AuthorList & authors();
273 AuthorList const & authors() const;
275 /// map of the file's author IDs to buffer author IDs
276 std::vector<unsigned int> author_map;
278 std::string const dvips_options() const;
279 /** The return value of paperSizeName() depends on the
280 * purpose for which the paper size is needed, since they
281 * support different subsets of paper sizes.
283 enum Papersize_Purpose {
292 std::string const paperSizeName(Papersize_Purpose const & purpose) const;
293 /// set up if and how babel is called
294 std::string const babelCall(std::string const & lang_opts) const;
295 /// handle inputenc etc.
296 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
297 TexRow & texrow) const;
298 /// set up the document fonts
299 std::string const loadFonts(std::string const & rm,
300 std::string const & sf, std::string const & tt,
301 bool const & sc, bool const & osf,
302 int const & sfscale, int const & ttscale) const;
304 /// get the appropriate cite engine (natbib handling)
305 biblio::CiteEngine getEngine() const;
308 void setCiteEngine(biblio::CiteEngine const);
310 /// options for pdf output
311 PDFOptions & pdfoptions();
312 PDFOptions const & pdfoptions() const;
316 void readPreamble(Lexer &);
318 void readLanguage(Lexer &);
320 void readGraphicsDriver(Lexer &);
322 void readBullets(Lexer &);
324 void readBulletsLaTeX(Lexer &);
326 void readModules(Lexer &);
328 /// for use with natbib
329 biblio::CiteEngine cite_engine_;
330 /// the base TextClass associated with the document
331 textclass_type baseClass_;
332 /// the possibly modular TextClass actually in use
333 TextClassPtr textClass_;
335 typedef std::vector<std::string> LayoutModuleList;
337 LayoutModuleList layoutModules_;
339 /** Use the Pimpl idiom to hide those member variables that would otherwise
340 * drag in other header files.
345 static Impl * clone(Impl const *);
346 static void destroy(Impl *);
348 support::copied_ptr<Impl, MemoryTraits> pimpl_;