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);
125 /// List of modules in use
126 std::vector<std::string> const & getModules() const;
127 /// Add a module to the list of modules in use.
128 /// Returns true if module was successfully added.
129 bool addLayoutModule(std::string modName, bool makeClass = true);
130 /// Add a list of modules.
131 /// Returns true if all modules were successfully added.
132 bool addLayoutModules(std::vector<std::string>modNames);
134 void clearLayoutModules();
136 /// returns the main font for the buffer (document)
137 Font const getFont() const;
139 /* this are for the PaperLayout */
141 PAPER_SIZE papersize;
143 PAPER_ORIENTATION orientation;
144 /// use custom margins
147 std::string paperwidth;
149 std::string paperheight;
151 std::string leftmargin;
153 std::string topmargin;
155 std::string rightmargin;
157 std::string bottommargin;
159 std::string headheight;
163 std::string footskip;
165 /* some LaTeX options */
166 /// The graphics driver
167 std::string graphicsDriver;
169 std::string fontsRoman;
171 std::string fontsSans;
173 std::string fontsTypewriter;
174 /// the default family (rm, sf, tt)
175 std::string fontsDefaultFamily;
176 /// use expert Small Caps
178 /// use Old Style Figures
180 /// the scale factor of the sf font
182 /// the scale factor of the tt font
183 int fontsTypewriterScale;
186 Spacing const & spacing() const;
192 Language const * language;
194 BranchList & branchlist();
195 BranchList const & branchlist() const;
197 * The input encoding for LaTeX. This can be one of
198 * - \c auto: find out the input encoding from the used languages
199 * - \c default: ditto
200 * - any encoding supported by the inputenc package
201 * The encoding of the LyX file is always utf8 and has nothing to
202 * do with this setting.
203 * The difference between \c auto and \c default is that \c auto also
204 * causes loading of the inputenc package, while \c default does not.
205 * \c default will not work unless the user takes additional measures
206 * (such as using special environments like the CJK environment from
208 * \c default can be seen as an unspecified 8bit encoding, since LyX
209 * does not interpret it in any way apart from display on screen.
211 std::string inputenc;
212 /// The main encoding used by this buffer for LaTeX output.
213 /// Individual pieces of text can use different encodings.
214 Encoding const & encoding() const;
216 std::string preamble;
220 std::string float_placement;
222 unsigned int columns;
223 /// parameters for the listings package
224 std::string listings_params;
226 TextClass::PageSides sides;
228 std::string pagestyle;
229 /// \param index should lie in the range 0 <= \c index <= 3.
230 Bullet & temp_bullet(size_type index);
231 Bullet const & temp_bullet(size_type index) const;
232 /// \param index should lie in the range 0 <= \c index <= 3.
233 Bullet & user_defined_bullet(size_type index);
234 Bullet const & user_defined_bullet(size_type index) const;
236 /// Whether to load a package such as amsmath or esint.
237 /// The enum values must not be changed (file format!)
239 /// Don't load the package. For experts only.
241 /// Load the package if needed (recommended)
243 /// Always load the package (e.g. if the document contains
244 /// some ERT that needs the package)
247 /// Whether and how to load amsmath
249 /// Whether and how to load esint
253 /// revision tracking for this buffer ?
255 /** This param decides whether change tracking marks should be used
256 * in output (irrespective of how these marks are actually defined;
257 * for instance, they may differ for DVI and PDF generation)
260 /// Time ago we agreed that this was a buffer property [ale990407]
261 std::string parentname;
265 /// the author list for the document
266 AuthorList & authors();
267 AuthorList const & authors() const;
269 /// map of the file's author IDs to buffer author IDs
270 std::vector<unsigned int> author_map;
272 std::string const dvips_options() const;
274 std::string const paperSizeName() const;
275 /// set up if and how babel is called
276 std::string const babelCall(std::string const & lang_opts) const;
277 /// handle inputenc etc.
278 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
279 TexRow & texrow) const;
280 /// set up the document fonts
281 std::string const loadFonts(std::string const & rm,
282 std::string const & sf, std::string const & tt,
283 bool const & sc, bool const & osf,
284 int const & sfscale, int const & ttscale) const;
285 /// path of the current buffer
286 std::string filepath;
287 /// get the appropriate cite engine (natbib handling)
288 biblio::CiteEngine getEngine() const;
291 void setCiteEngine(biblio::CiteEngine const);
295 void readPreamble(Lexer &);
297 void readLanguage(Lexer &);
299 void readGraphicsDriver(Lexer &);
301 void readBullets(Lexer &);
303 void readBulletsLaTeX(Lexer &);
305 void readModules(Lexer &);
306 /// Adds the module information to the baseClass information to
307 /// create our local TextClass.
308 void makeTextClass();
311 /// for use with natbib
312 biblio::CiteEngine cite_engine_;
313 /// the base TextClass associated with the document
314 textclass_type baseClass_;
315 /// the possibly modular TextClass actually in use
316 TextClass_ptr textClass_;
318 typedef std::vector<std::string> LayoutModuleList;
320 LayoutModuleList layoutModules_;
322 /** Use the Pimpl idiom to hide those member variables that would otherwise
323 * drag in other header files.
328 static Impl * clone(Impl const *);
329 static void destroy(Impl *);
331 support::copied_ptr<Impl, MemoryTraits> pimpl_;