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 /** \returns true if the babel package is used (interogates
79 * the BufferParams and a LyXRC variable).
80 * This returned value can then be passed to the insets...
82 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
85 void useClassDefaults();
88 bool hasClassDefaults() const;
91 VSpace const & getDefSkip() const;
94 void setDefSkip(VSpace const & vs);
96 /** Whether paragraphs are separated by using a indent like in
97 * articles or by using a little skip like in letters.
99 PARSEP paragraph_separation;
101 InsetQuotes::quote_language quotes_language;
103 InsetQuotes::quote_times quotes_times;
105 std::string fontsize;
106 ///Get the LyX TextClass (that is, the layout file) this document is using.
107 textclass_type getBaseClass() const;
108 ///Set the LyX TextClass (that is, the layout file) this document is using.
109 ///NOTE This also calls makeTextClass(), to update the local
111 bool setBaseClass(textclass_type);
112 ///Returns the TextClass currently in use: the BaseClass as modified
114 TextClass const & getTextClass() const;
115 ///Returns a pointer to the TextClass currently in use: the BaseClass
116 ///as modified by modules. (See \file TextClassPtr.h for the typedef.)
117 TextClassPtr getTextClassPtr() const;
118 ///Set the LyX TextClass---layout file---this document is using.
119 ///This does NOT call makeTextClass() and so should be used with
120 ///care. This is most likely not what you want if you are operating on
121 ///BufferParams that are actually associatd with a Buffer. If, on the
122 ///other hand, you are using a temporary set of BufferParams---say, in
123 ///a controller, it may well be, since in that case the local TextClass
124 ///has nothing to do.
125 void setJustBaseClass(textclass_type);
126 /// This bypasses the baseClass and sets the textClass directly.
127 /// Should be called with care and would be better not being here,
128 /// but it seems to be needed by CutAndPaste::putClipboard().
129 void setTextClass(TextClassPtr);
130 /// List of modules in use
131 std::vector<std::string> const & getModules() const;
132 /// Add a module to the list of modules in use.
133 /// Returns true if module was successfully added.
134 bool addLayoutModule(std::string modName, bool makeClass = true);
135 /// Add a list of modules.
136 /// Returns true if all modules were successfully added.
137 bool addLayoutModules(std::vector<std::string>modNames);
139 void clearLayoutModules();
141 /// returns the main font for the buffer (document)
142 Font const getFont() const;
144 /* this are for the PaperLayout */
146 PAPER_SIZE papersize;
148 PAPER_ORIENTATION orientation;
149 /// use custom margins
152 std::string paperwidth;
154 std::string paperheight;
156 std::string leftmargin;
158 std::string topmargin;
160 std::string rightmargin;
162 std::string bottommargin;
164 std::string headheight;
168 std::string footskip;
170 /* some LaTeX options */
171 /// The graphics driver
172 std::string graphicsDriver;
174 std::string fontsRoman;
176 std::string fontsSans;
178 std::string fontsTypewriter;
179 /// the default family (rm, sf, tt)
180 std::string fontsDefaultFamily;
181 /// use expert Small Caps
183 /// use Old Style Figures
185 /// the scale factor of the sf font
187 /// the scale factor of the tt font
188 int fontsTypewriterScale;
191 Spacing const & spacing() const;
197 Language const * language;
199 BranchList & branchlist();
200 BranchList const & branchlist() const;
202 * The input encoding for LaTeX. This can be one of
203 * - \c auto: find out the input encoding from the used languages
204 * - \c default: ditto
205 * - any encoding supported by the inputenc package
206 * The encoding of the LyX file is always utf8 and has nothing to
207 * do with this setting.
208 * The difference between \c auto and \c default is that \c auto also
209 * causes loading of the inputenc package, while \c default does not.
210 * \c default will not work unless the user takes additional measures
211 * (such as using special environments like the CJK environment from
213 * \c default can be seen as an unspecified 8bit encoding, since LyX
214 * does not interpret it in any way apart from display on screen.
216 std::string inputenc;
217 /// The main encoding used by this buffer for LaTeX output.
218 /// Individual pieces of text can use different encodings.
219 Encoding const & encoding() const;
221 std::string preamble;
225 std::string float_placement;
227 unsigned int columns;
228 /// parameters for the listings package
229 std::string listings_params;
233 std::string pagestyle;
234 /// \param index should lie in the range 0 <= \c index <= 3.
235 Bullet & temp_bullet(size_type index);
236 Bullet const & temp_bullet(size_type index) const;
237 /// \param index should lie in the range 0 <= \c index <= 3.
238 Bullet & user_defined_bullet(size_type index);
239 Bullet const & user_defined_bullet(size_type index) const;
241 /// Whether to load a package such as amsmath or esint.
242 /// The enum values must not be changed (file format!)
244 /// Don't load the package. For experts only.
246 /// Load the package if needed (recommended)
248 /// Always load the package (e.g. if the document contains
249 /// some ERT that needs the package)
252 /// Whether and how to load amsmath
254 /// Whether and how to load esint
258 /// revision tracking for this buffer ?
260 /** This param decides whether change tracking marks should be used
261 * in output (irrespective of how these marks are actually defined;
262 * for instance, they may differ for DVI and PDF generation)
270 /// the author list for the document
271 AuthorList & authors();
272 AuthorList const & authors() const;
274 /// map of the file's author IDs to buffer author IDs
275 std::vector<unsigned int> author_map;
277 std::string const dvips_options() const;
279 std::string const paperSizeName() const;
280 /// set up if and how babel is called
281 std::string const babelCall(std::string const & lang_opts) const;
282 /// handle inputenc etc.
283 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
284 TexRow & texrow) const;
285 /// set up the document fonts
286 std::string const loadFonts(std::string const & rm,
287 std::string const & sf, std::string const & tt,
288 bool const & sc, bool const & osf,
289 int const & sfscale, int const & ttscale) const;
291 /// get the appropriate cite engine (natbib handling)
292 biblio::CiteEngine getEngine() const;
295 void setCiteEngine(biblio::CiteEngine const);
297 /// options for pdf output
298 PDFOptions & pdfoptions();
299 PDFOptions const & pdfoptions() const;
303 void readPreamble(Lexer &);
305 void readLanguage(Lexer &);
307 void readGraphicsDriver(Lexer &);
309 void readBullets(Lexer &);
311 void readBulletsLaTeX(Lexer &);
313 void readModules(Lexer &);
314 /// Adds the module information to the baseClass information to
315 /// create our local TextClass.
316 void makeTextClass();
319 /// for use with natbib
320 biblio::CiteEngine cite_engine_;
321 /// the base TextClass associated with the document
322 textclass_type baseClass_;
323 /// the possibly modular TextClass actually in use
324 TextClassPtr textClass_;
326 typedef std::vector<std::string> LayoutModuleList;
328 LayoutModuleList layoutModules_;
330 /** Use the Pimpl idiom to hide those member variables that would otherwise
331 * drag in other header files.
336 static Impl * clone(Impl const *);
337 static void destroy(Impl *);
339 support::copied_ptr<Impl, MemoryTraits> pimpl_;