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"
22 #include "insets/InsetQuotes.h"
24 #include "support/copied_ptr.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 /// check what features are implied by the buffer parameters.
79 void validate(LaTeXFeatures &) const;
81 /** \returns true if the babel package is used (interogates
82 * the BufferParams and a LyXRC variable).
83 * This returned value can then be passed to the insets...
85 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
88 void useClassDefaults();
91 bool hasClassDefaults() const;
94 VSpace const & getDefSkip() const;
97 void setDefSkip(VSpace const & vs);
99 /** Whether paragraphs are separated by using a indent like in
100 * articles or by using a little skip like in letters.
102 PARSEP paragraph_separation;
104 InsetQuotes::quote_language quotes_language;
106 InsetQuotes::quote_times quotes_times;
108 std::string fontsize;
109 ///Get the LyX TextClass (that is, the layout file) this document is using.
110 TextClass const * baseClass() const;
112 BaseClassIndex const & baseClassID() const;
113 /// Set the LyX TextClass (that is, the layout file) this document is using.
114 /// NOTE: This does not call makeDocumentClass() to update the local
115 /// DocumentClass. That needs to be done manually.
116 /// \param filename the name of the layout file
117 bool setBaseClass(std::string const & classname);
118 /// Adds the module information to the baseClass information to
119 /// create our local DocumentClass.
120 void makeDocumentClass();
121 /// Returns the DocumentClass currently in use: the BaseClass as modified
123 DocumentClass const & documentClass() const;
124 /// \return A pointer to the DocumentClass currently in use: the BaseClass
125 /// as modified by modules.
126 DocumentClass * documentClassPtr() const;
127 /// This bypasses the baseClass and sets the textClass directly.
128 /// Should be called with care and would be better not being here,
129 /// but it seems to be needed by CutAndPaste::putClipboard().
130 void setDocumentClass(DocumentClass const * const);
131 /// List of modules in use
132 std::vector<std::string> const & getModules() const;
133 /// Add a module to the list of modules in use.
134 /// Returns true if module was successfully added.
135 /// The makeClass variable signals whether to call makeDocumentClass. This
136 /// need not be done if we know this isn't the final time through, or if
137 /// the BufferParams do not represent the parameters for an actual buffer
138 /// (as in GuiDocument).
139 bool addLayoutModule(std::string const & modName);
141 void clearLayoutModules();
143 /// returns the main font for the buffer (document)
144 Font const getFont() const;
146 /* this are for the PaperLayout */
148 PAPER_SIZE papersize;
150 PAPER_ORIENTATION orientation;
151 /// use custom margins
154 std::string paperwidth;
156 std::string paperheight;
158 std::string leftmargin;
160 std::string topmargin;
162 std::string rightmargin;
164 std::string bottommargin;
166 std::string headheight;
170 std::string footskip;
172 std::string columnsep;
174 /* some LaTeX options */
175 /// The graphics driver
176 std::string graphicsDriver;
178 std::string fontsRoman;
180 std::string fontsSans;
182 std::string fontsTypewriter;
183 /// the default family (rm, sf, tt)
184 std::string fontsDefaultFamily;
185 /// use expert Small Caps
187 /// use Old Style Figures
189 /// the scale factor of the sf font
191 /// the scale factor of the tt font
192 int fontsTypewriterScale;
195 Spacing const & spacing() const;
201 Language const * language;
203 BranchList & branchlist();
204 BranchList const & branchlist() const;
206 * The input encoding for LaTeX. This can be one of
207 * - \c auto: find out the input encoding from the used languages
208 * - \c default: ditto
209 * - any encoding supported by the inputenc package
210 * The encoding of the LyX file is always utf8 and has nothing to
211 * do with this setting.
212 * The difference between \c auto and \c default is that \c auto also
213 * causes loading of the inputenc package, while \c default does not.
214 * \c default will not work unless the user takes additional measures
215 * (such as using special environments like the CJK environment from
217 * \c default can be seen as an unspecified 8bit encoding, since LyX
218 * does not interpret it in any way apart from display on screen.
220 std::string inputenc;
221 /// The main encoding used by this buffer for LaTeX output.
222 /// Individual pieces of text can use different encodings.
223 Encoding const & encoding() const;
225 std::string preamble;
229 std::string float_placement;
231 unsigned int columns;
232 /// parameters for the listings package
233 std::string listings_params;
237 std::string pagestyle;
238 /// \param index should lie in the range 0 <= \c index <= 3.
239 Bullet & temp_bullet(size_type index);
240 Bullet const & temp_bullet(size_type index) const;
241 /// \param index should lie in the range 0 <= \c index <= 3.
242 Bullet & user_defined_bullet(size_type index);
243 Bullet const & user_defined_bullet(size_type index) const;
245 /// Whether to load a package such as amsmath or esint.
246 /// The enum values must not be changed (file format!)
248 /// Don't load the package. For experts only.
250 /// Load the package if needed (recommended)
252 /// Always load the package (e.g. if the document contains
253 /// some ERT that needs the package)
256 /// Whether and how to load amsmath
258 /// Whether and how to load esint
262 /// revision tracking for this buffer ?
264 /** This param decides whether change tracking marks should be used
265 * in output (irrespective of how these marks are actually defined;
266 * for instance, they may differ for DVI and PDF generation)
274 /// the author list for the document
275 AuthorList & authors();
276 AuthorList const & authors() const;
278 /// map of the file's author IDs to buffer author IDs
279 std::vector<unsigned int> author_map;
281 std::string const dvips_options() const;
282 /** The return value of paperSizeName() depends on the
283 * purpose for which the paper size is needed, since they
284 * support different subsets of paper sizes.
286 enum Papersize_Purpose {
295 std::string const paperSizeName(Papersize_Purpose const & purpose) const;
296 /// set up if and how babel is called
297 std::string const babelCall(std::string const & lang_opts) const;
298 /// handle inputenc etc.
299 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
300 TexRow & texrow) const;
301 /// set up the document fonts
302 std::string const loadFonts(std::string const & rm,
303 std::string const & sf, std::string const & tt,
304 bool const & sc, bool const & osf,
305 int const & sfscale, int const & ttscale) const;
307 /// get the appropriate cite engine (natbib handling)
308 biblio::CiteEngine getEngine() const;
311 void setCiteEngine(biblio::CiteEngine const);
313 /// options for pdf output
314 PDFOptions & pdfoptions();
315 PDFOptions const & pdfoptions() const;
319 void readPreamble(Lexer &);
321 void readLanguage(Lexer &);
323 void readGraphicsDriver(Lexer &);
325 void readBullets(Lexer &);
327 void readBulletsLaTeX(Lexer &);
329 void readModules(Lexer &);
331 /// for use with natbib
332 biblio::CiteEngine cite_engine_;
334 DocumentClass * doc_class_;
336 typedef std::vector<std::string> LayoutModuleList;
338 LayoutModuleList layoutModules_;
340 /** Use the Pimpl idiom to hide those member variables that would otherwise
341 * drag in other header files.
346 static Impl * clone(Impl const *);
347 static void destroy(Impl *);
349 support::copied_ptr<Impl, MemoryTraits> pimpl_;