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
18 #include "BiblioInfo.h"
19 #include "TextClass.h"
20 #include "TextClass_ptr.h"
23 #include "insets/InsetQuotes.h"
25 #include "support/copied_ptr.h"
26 #include "support/FileName.h"
27 #include "support/types.h"
29 #include "frontends/controllers/frontend_helpers.h"
46 /** Buffer parameters.
47 * This class contains all the parameters for this buffer's use. Some
48 * work needs to be done on this class to make it nice. Now everything
64 /// get l10n translated to the buffers language
65 docstring const B_(std::string const & l10n) const;
67 /// read a header token, if unrecognised, return it or an unknown class name
68 std::string const readToken(Lexer & lex, std::string const & token);
71 void writeFile(std::ostream &) const;
73 /** \returns true if the babel package is used (interogates
74 * the BufferParams and a LyXRC variable).
75 * This returned value can then be passed to the insets...
77 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
80 void useClassDefaults();
83 bool hasClassDefaults() const;
86 VSpace const & getDefSkip() const;
89 void setDefSkip(VSpace const & vs);
91 /** Whether paragraphs are separated by using a indent like in
92 * articles or by using a little skip like in letters.
94 PARSEP paragraph_separation;
96 InsetQuotes::quote_language quotes_language;
98 InsetQuotes::quote_times quotes_times;
100 std::string fontsize;
101 ///Get the LyX TextClass (that is, the layout file) this document is using.
102 textclass_type getBaseClass() const;
103 ///Set the LyX TextClass (that is, the layout file) this document is using.
104 ///NOTE This also calls makeTextClass(), to update the local
106 void setBaseClass(textclass_type);
107 ///Returns the TextClass currently in use: the BaseClass as modified
109 TextClass const & getTextClass() const;
110 ///Returns a pointer to the TextClass currently in use: the BaseClass
111 ///as modified by modules. (See \file TextClass_ptr.h for the typedef.)
112 TextClass_ptr getTextClass_ptr() const;
113 ///Set the LyX TextClass---layout file---this document is using.
114 ///This does NOT call makeTextClass() and so should be used with
115 ///care. This is most likely not what you want if you are operating on
116 ///BufferParams that are actually associatd with a Buffer. If, on the
117 ///other hand, you are using a temporary set of BufferParams---say, in
118 ///a controller, it may well be, since in that case the local TextClass
119 ///has nothing to do.
120 void setJustBaseClass(textclass_type);
121 /// This bypasses the baseClass and sets the textClass directly.
122 /// Should be called with care and would be better not being here,
123 /// but it seems to be needed by CutAndPaste::putClipboard().
124 void setTextClass(TextClass_ptr);
126 /// returns the main font for the buffer (document)
127 Font const getFont() const;
129 /* this are for the PaperLayout */
131 PAPER_SIZE papersize;
133 PAPER_ORIENTATION orientation;
134 /// use custom margins
137 std::string paperwidth;
139 std::string paperheight;
141 std::string leftmargin;
143 std::string topmargin;
145 std::string rightmargin;
147 std::string bottommargin;
149 std::string headheight;
153 std::string footskip;
155 /* some LaTeX options */
156 /// The graphics driver
157 std::string graphicsDriver;
159 std::string fontsRoman;
161 std::string fontsSans;
163 std::string fontsTypewriter;
164 /// the default family (rm, sf, tt)
165 std::string fontsDefaultFamily;
166 /// use expert Small Caps
168 /// use Old Style Figures
170 /// the scale factor of the sf font
172 /// the scale factor of the tt font
173 int fontsTypewriterScale;
176 Spacing const & spacing() const;
182 Language const * language;
184 BranchList & branchlist();
185 BranchList const & branchlist() const;
187 * The input encoding for LaTeX. This can be one of
188 * - \c auto: find out the input encoding from the used languages
189 * - \c default: ditto
190 * - any encoding supported by the inputenc package
191 * The encoding of the LyX file is always utf8 and has nothing to
192 * do with this setting.
193 * The difference between \c auto and \c default is that \c auto also
194 * causes loading of the inputenc package, while \c default does not.
195 * \c default will not work unless the user takes additional measures
196 * (such as using special environments like the CJK environment from
198 * \c default can be seen as an unspecified 8bit encoding, since LyX
199 * does not interpret it in any way apart from display on screen.
201 std::string inputenc;
202 /// The main encoding used by this buffer for LaTeX output.
203 /// Individual pieces of text can use different encodings.
204 Encoding const & encoding() const;
206 std::string preamble;
210 std::string float_placement;
212 unsigned int columns;
213 /// parameters for the listings package
214 std::string listings_params;
216 TextClass::PageSides sides;
218 std::string pagestyle;
219 /// \param index should lie in the range 0 <= \c index <= 3.
220 Bullet & temp_bullet(size_type index);
221 Bullet const & temp_bullet(size_type index) const;
222 /// \param index should lie in the range 0 <= \c index <= 3.
223 Bullet & user_defined_bullet(size_type index);
224 Bullet const & user_defined_bullet(size_type index) const;
226 /// Whether to load a package such as amsmath or esint.
227 /// The enum values must not be changed (file format!)
229 /// Don't load the package. For experts only.
231 /// Load the package if needed (recommended)
233 /// Always load the package (e.g. if the document contains
234 /// some ERT that needs the package)
237 /// Whether and how to load amsmath
239 /// Whether and how to load esint
243 /// revision tracking for this buffer ?
245 /** This param decides whether change tracking marks should be used
246 * in output (irrespective of how these marks are actually defined;
247 * for instance, they may differ for DVI and PDF generation)
250 /// Time ago we agreed that this was a buffer property [ale990407]
251 std::string parentname;
255 /// the author list for the document
256 AuthorList & authors();
257 AuthorList const & authors() const;
259 /// map of the file's author IDs to buffer author IDs
260 std::vector<unsigned int> author_map;
262 std::string const dvips_options() const;
264 std::string const paperSizeName() const;
265 /// set up if and how babel is called
266 std::string const babelCall(std::string const & lang_opts) const;
267 /// handle inputenc etc.
268 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
269 TexRow & texrow) const;
270 /// set up the document fonts
271 std::string const loadFonts(std::string const & rm,
272 std::string const & sf, std::string const & tt,
273 bool const & sc, bool const & osf,
274 int const & sfscale, int const & ttscale) const;
275 /// path of the current buffer
276 std::string filepath;
277 /// get the appropriate cite engine (natbib handling)
278 biblio::CiteEngine getEngine() const;
281 void setCiteEngine(biblio::CiteEngine const);
285 void readPreamble(Lexer &);
287 void readLanguage(Lexer &);
289 void readGraphicsDriver(Lexer &);
291 void readBullets(Lexer &);
293 void readBulletsLaTeX(Lexer &);
294 /// create our local TextClass.
295 void makeTextClass();
298 /// for use with natbib
299 biblio::CiteEngine cite_engine_;
300 /// the base TextClass associated with the document
301 textclass_type baseClass_;
302 /// the possibly modular TextClass actually in use
303 TextClass_ptr textClass_;
305 /** Use the Pimpl idiom to hide those member variables that would otherwise
306 * drag in other header files.
311 static Impl * clone(Impl const *);
312 static void destroy(Impl *);
314 support::copied_ptr<Impl, MemoryTraits> pimpl_;