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"
43 /** Buffer parameters.
44 * This class contains all the parameters for this buffer's use. Some
45 * work needs to be done on this class to make it nice. Now everything
61 /// get l10n translated to the buffers language
62 docstring const B_(std::string const & l10n) const;
64 /// read a header token, if unrecognised, return it or an unknown class name
65 std::string const readToken(Lexer & lex, std::string const & token);
68 void writeFile(std::ostream &) const;
70 /** \returns true if the babel package is used (interogates
71 * the BufferParams and a LyXRC variable).
72 * This returned value can then be passed to the insets...
74 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
77 void useClassDefaults();
80 bool hasClassDefaults() const;
83 VSpace const & getDefSkip() const;
86 void setDefSkip(VSpace const & vs);
88 /** Whether paragraphs are separated by using a indent like in
89 * articles or by using a little skip like in letters.
91 PARSEP paragraph_separation;
93 InsetQuotes::quote_language quotes_language;
95 InsetQuotes::quote_times quotes_times;
98 ///Get the LyX TextClass (that is, the layout file) this document is using.
99 textclass_type getBaseClass() const;
100 ///Set the LyX TextClass (that is, the layout file) this document is using.
101 ///NOTE This also calls makeTextClass(), to update the local
103 bool setBaseClass(textclass_type);
104 ///Returns the TextClass currently in use: the BaseClass as modified
106 TextClass const & getTextClass() const;
107 ///Returns a pointer to the TextClass currently in use: the BaseClass
108 ///as modified by modules. (See \file TextClass.h for the typedef.)
109 TextClassPtr getTextClassPtr() const;
110 ///Set the LyX TextClass---layout file---this document is using.
111 ///This does NOT call makeTextClass() and so should be used with
112 ///care. This is most likely not what you want if you are operating on
113 ///BufferParams that are actually associatd with a Buffer. If, on the
114 ///other hand, you are using a temporary set of BufferParams---say, in
115 ///a controller, it may well be, since in that case the local TextClass
116 ///has nothing to do.
117 void setJustBaseClass(textclass_type);
118 /// This bypasses the baseClass and sets the textClass directly.
119 /// Should be called with care and would be better not being here,
120 /// but it seems to be needed by CutAndPaste::putClipboard().
121 void setTextClass(TextClassPtr);
122 /// List of modules in use
123 std::vector<std::string> const & getModules() const;
124 /// Add a module to the list of modules in use.
125 /// Returns true if module was successfully added.
126 bool addLayoutModule(std::string modName, bool makeClass = true);
127 /// Add a list of modules.
128 /// Returns true if all modules were successfully added.
129 bool addLayoutModules(std::vector<std::string>modNames);
131 void clearLayoutModules();
133 /// returns the main font for the buffer (document)
134 Font const getFont() const;
136 /* this are for the PaperLayout */
138 PAPER_SIZE papersize;
140 PAPER_ORIENTATION orientation;
141 /// use custom margins
144 std::string paperwidth;
146 std::string paperheight;
148 std::string leftmargin;
150 std::string topmargin;
152 std::string rightmargin;
154 std::string bottommargin;
156 std::string headheight;
160 std::string footskip;
162 /* some LaTeX options */
163 /// The graphics driver
164 std::string graphicsDriver;
166 std::string fontsRoman;
168 std::string fontsSans;
170 std::string fontsTypewriter;
171 /// the default family (rm, sf, tt)
172 std::string fontsDefaultFamily;
173 /// use expert Small Caps
175 /// use Old Style Figures
177 /// the scale factor of the sf font
179 /// the scale factor of the tt font
180 int fontsTypewriterScale;
183 Spacing const & spacing() const;
189 Language const * language;
191 BranchList & branchlist();
192 BranchList const & branchlist() const;
194 * The input encoding for LaTeX. This can be one of
195 * - \c auto: find out the input encoding from the used languages
196 * - \c default: ditto
197 * - any encoding supported by the inputenc package
198 * The encoding of the LyX file is always utf8 and has nothing to
199 * do with this setting.
200 * The difference between \c auto and \c default is that \c auto also
201 * causes loading of the inputenc package, while \c default does not.
202 * \c default will not work unless the user takes additional measures
203 * (such as using special environments like the CJK environment from
205 * \c default can be seen as an unspecified 8bit encoding, since LyX
206 * does not interpret it in any way apart from display on screen.
208 std::string inputenc;
209 /// The main encoding used by this buffer for LaTeX output.
210 /// Individual pieces of text can use different encodings.
211 Encoding const & encoding() const;
213 std::string preamble;
217 std::string float_placement;
219 unsigned int columns;
220 /// parameters for the listings package
221 std::string listings_params;
223 TextClass::PageSides sides;
225 std::string pagestyle;
226 /// \param index should lie in the range 0 <= \c index <= 3.
227 Bullet & temp_bullet(size_type index);
228 Bullet const & temp_bullet(size_type index) const;
229 /// \param index should lie in the range 0 <= \c index <= 3.
230 Bullet & user_defined_bullet(size_type index);
231 Bullet const & user_defined_bullet(size_type index) const;
233 /// Whether to load a package such as amsmath or esint.
234 /// The enum values must not be changed (file format!)
236 /// Don't load the package. For experts only.
238 /// Load the package if needed (recommended)
240 /// Always load the package (e.g. if the document contains
241 /// some ERT that needs the package)
244 /// Whether and how to load amsmath
246 /// Whether and how to load esint
250 /// revision tracking for this buffer ?
252 /** This param decides whether change tracking marks should be used
253 * in output (irrespective of how these marks are actually defined;
254 * for instance, they may differ for DVI and PDF generation)
257 /// Time ago we agreed that this was a buffer property [ale990407]
258 std::string parentname;
264 /// the author list for the document
265 AuthorList & authors();
266 AuthorList const & authors() const;
268 /// map of the file's author IDs to buffer author IDs
269 std::vector<unsigned int> author_map;
271 std::string const dvips_options() const;
273 std::string const paperSizeName() const;
274 /// set up if and how babel is called
275 std::string const babelCall(std::string const & lang_opts) const;
276 /// handle inputenc etc.
277 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
278 TexRow & texrow) const;
279 /// set up the document fonts
280 std::string const loadFonts(std::string const & rm,
281 std::string const & sf, std::string const & tt,
282 bool const & sc, bool const & osf,
283 int const & sfscale, int const & ttscale) const;
284 /// path of the current buffer
285 std::string filepath;
286 /// get the appropriate cite engine (natbib handling)
287 biblio::CiteEngine getEngine() const;
290 void setCiteEngine(biblio::CiteEngine const);
294 void readPreamble(Lexer &);
296 void readLanguage(Lexer &);
298 void readGraphicsDriver(Lexer &);
300 void readBullets(Lexer &);
302 void readBulletsLaTeX(Lexer &);
304 void readModules(Lexer &);
305 /// Adds the module information to the baseClass information to
306 /// create our local TextClass.
307 void makeTextClass();
310 /// for use with natbib
311 biblio::CiteEngine cite_engine_;
312 /// the base TextClass associated with the document
313 textclass_type baseClass_;
314 /// the possibly modular TextClass actually in use
315 TextClassPtr textClass_;
317 typedef std::vector<std::string> LayoutModuleList;
319 LayoutModuleList layoutModules_;
321 /** Use the Pimpl idiom to hide those member variables that would otherwise
322 * drag in other header files.
327 static Impl * clone(Impl const *);
328 static void destroy(Impl *);
330 support::copied_ptr<Impl, MemoryTraits> pimpl_;