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"
22 #include "insets/InsetQuotes.h"
24 #include "support/copied_ptr.h"
25 #include "support/FileName.h"
26 #include "support/types.h"
44 /** Buffer parameters.
45 * This class contains all the parameters for this buffer's use. Some
46 * work needs to be done on this class to make it nice. Now everything
62 /// get l10n translated to the buffers language
63 docstring const B_(std::string const & l10n) const;
65 /// read a header token, if unrecognised, return it or an unknown class name
66 std::string const readToken(Lexer & lex, std::string const & token);
69 void writeFile(std::ostream &) const;
71 /** \returns true if the babel package is used (interogates
72 * the BufferParams and a LyXRC variable).
73 * This returned value can then be passed to the insets...
75 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
78 void useClassDefaults();
81 bool hasClassDefaults() const;
84 VSpace const & getDefSkip() const;
87 void setDefSkip(VSpace const & vs);
89 /** Whether paragraphs are separated by using a indent like in
90 * articles or by using a little skip like in letters.
92 PARSEP paragraph_separation;
94 InsetQuotes::quote_language quotes_language;
96 InsetQuotes::quote_times quotes_times;
99 ///Get the LyX TextClass (that is, the layout file) this document is using.
100 textclass_type getBaseClass() const;
101 ///Set the LyX TextClass (that is, the layout file) this document is using.
102 ///NOTE This also calls makeTextClass(), to update the local
104 bool setBaseClass(textclass_type);
105 ///Returns the TextClass currently in use: the BaseClass as modified
107 TextClass const & getTextClass() const;
108 ///Returns a pointer to the TextClass currently in use: the BaseClass
109 ///as modified by modules. (See \file TextClass.h for the typedef.)
110 TextClassPtr getTextClassPtr() const;
111 ///Set the LyX TextClass---layout file---this document is using.
112 ///This does NOT call makeTextClass() and so should be used with
113 ///care. This is most likely not what you want if you are operating on
114 ///BufferParams that are actually associatd with a Buffer. If, on the
115 ///other hand, you are using a temporary set of BufferParams---say, in
116 ///a controller, it may well be, since in that case the local TextClass
117 ///has nothing to do.
118 void setJustBaseClass(textclass_type);
119 /// This bypasses the baseClass and sets the textClass directly.
120 /// Should be called with care and would be better not being here,
121 /// but it seems to be needed by CutAndPaste::putClipboard().
122 void setTextClass(TextClassPtr);
123 /// List of modules in use
124 std::vector<std::string> const & getModules() const;
125 /// Add a module to the list of modules in use.
126 /// Returns true if module was successfully added.
127 bool addLayoutModule(std::string modName, bool makeClass = true);
128 /// Add a list of modules.
129 /// Returns true if all modules were successfully added.
130 bool addLayoutModules(std::vector<std::string>modNames);
132 void clearLayoutModules();
134 /// returns the main font for the buffer (document)
135 Font const getFont() const;
137 /* this are for the PaperLayout */
139 PAPER_SIZE papersize;
141 PAPER_ORIENTATION orientation;
142 /// use custom margins
145 std::string paperwidth;
147 std::string paperheight;
149 std::string leftmargin;
151 std::string topmargin;
153 std::string rightmargin;
155 std::string bottommargin;
157 std::string headheight;
161 std::string footskip;
163 /* some LaTeX options */
164 /// The graphics driver
165 std::string graphicsDriver;
167 std::string fontsRoman;
169 std::string fontsSans;
171 std::string fontsTypewriter;
172 /// the default family (rm, sf, tt)
173 std::string fontsDefaultFamily;
174 /// use expert Small Caps
176 /// use Old Style Figures
178 /// the scale factor of the sf font
180 /// the scale factor of the tt font
181 int fontsTypewriterScale;
184 Spacing const & spacing() const;
190 Language const * language;
192 BranchList & branchlist();
193 BranchList const & branchlist() const;
195 * The input encoding for LaTeX. This can be one of
196 * - \c auto: find out the input encoding from the used languages
197 * - \c default: ditto
198 * - any encoding supported by the inputenc package
199 * The encoding of the LyX file is always utf8 and has nothing to
200 * do with this setting.
201 * The difference between \c auto and \c default is that \c auto also
202 * causes loading of the inputenc package, while \c default does not.
203 * \c default will not work unless the user takes additional measures
204 * (such as using special environments like the CJK environment from
206 * \c default can be seen as an unspecified 8bit encoding, since LyX
207 * does not interpret it in any way apart from display on screen.
209 std::string inputenc;
210 /// The main encoding used by this buffer for LaTeX output.
211 /// Individual pieces of text can use different encodings.
212 Encoding const & encoding() const;
214 std::string preamble;
218 std::string float_placement;
220 unsigned int columns;
221 /// parameters for the listings package
222 std::string listings_params;
224 TextClass::PageSides sides;
226 std::string pagestyle;
227 /// \param index should lie in the range 0 <= \c index <= 3.
228 Bullet & temp_bullet(size_type index);
229 Bullet const & temp_bullet(size_type index) const;
230 /// \param index should lie in the range 0 <= \c index <= 3.
231 Bullet & user_defined_bullet(size_type index);
232 Bullet const & user_defined_bullet(size_type index) const;
234 /// Whether to load a package such as amsmath or esint.
235 /// The enum values must not be changed (file format!)
237 /// Don't load the package. For experts only.
239 /// Load the package if needed (recommended)
241 /// Always load the package (e.g. if the document contains
242 /// some ERT that needs the package)
245 /// Whether and how to load amsmath
247 /// Whether and how to load esint
251 /// revision tracking for this buffer ?
253 /** This param decides whether change tracking marks should be used
254 * in output (irrespective of how these marks are actually defined;
255 * for instance, they may differ for DVI and PDF generation)
258 /// Time ago we agreed that this was a buffer property [ale990407]
259 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);
293 /// options for pdf output
294 PDFOptions & pdfoptions();
295 PDFOptions const & pdfoptions() const;
299 void readPreamble(Lexer &);
301 void readLanguage(Lexer &);
303 void readGraphicsDriver(Lexer &);
305 void readBullets(Lexer &);
307 void readBulletsLaTeX(Lexer &);
309 void readModules(Lexer &);
310 /// Adds the module information to the baseClass information to
311 /// create our local TextClass.
312 void makeTextClass();
315 /// for use with natbib
316 biblio::CiteEngine cite_engine_;
317 /// the base TextClass associated with the document
318 textclass_type baseClass_;
319 /// the possibly modular TextClass actually in use
320 TextClassPtr textClass_;
322 typedef std::vector<std::string> LayoutModuleList;
324 LayoutModuleList layoutModules_;
326 /** Use the Pimpl idiom to hide those member variables that would otherwise
327 * drag in other header files.
332 static Impl * clone(Impl const *);
333 static void destroy(Impl *);
335 support::copied_ptr<Impl, MemoryTraits> pimpl_;