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
22 #include "insets/InsetQuotes.h"
24 #include "support/copied_ptr.h"
30 namespace support { class FileName; }
40 class LayoutFileIndex;
47 /** Buffer parameters.
48 * This class contains all the parameters for this buffer's use. Some
49 * work needs to be done on this class to make it nice. Now everything
55 enum ParagraphSeparation {
57 ParagraphIndentSeparation,
59 ParagraphSkipSeparation
64 /// get l10n translated to the buffers language
65 docstring B_(std::string const & l10n) const;
67 /// read a header token, if unrecognised, return it or an unknown class name
68 std::string readToken(Lexer & lex,
69 std::string const & token, ///< token to read.
70 support::FileName const & filepath);
73 void writeFile(std::ostream &) const;
75 /// check what features are implied by the buffer parameters.
76 void validate(LaTeXFeatures &) 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();
87 bool hasClassDefaults() const;
90 VSpace const & getDefSkip() const;
92 void setDefSkip(VSpace const & vs);
94 /** Whether paragraphs are separated by using a indent like in
95 * articles or by using a little skip like in letters.
97 ParagraphSeparation paragraph_separation;
99 InsetQuotes::QuoteLanguage quotes_language;
101 InsetQuotes::QuoteTimes quotes_times;
103 std::string fontsize;
104 ///Get the LayoutFile this document is using.
105 LayoutFile const * baseClass() const;
107 LayoutFileIndex const & baseClassID() const;
108 /// Set the LyX layout file this document is using.
109 /// NOTE: This does not call makeDocumentClass() to update the local
110 /// DocumentClass. That needs to be done manually.
111 /// \param filename the name of the layout file
112 bool setBaseClass(std::string const & classname);
113 /// Adds the module information to the baseClass information to
114 /// create our local DocumentClass.
115 void makeDocumentClass();
116 /// Returns the DocumentClass currently in use: the BaseClass as modified
118 DocumentClass const & documentClass() const;
119 /// \return A pointer to the DocumentClass currently in use: the BaseClass
120 /// as modified by modules.
121 DocumentClass const * documentClassPtr() const;
122 /// This bypasses the baseClass and sets the textClass directly.
123 /// Should be called with care and would be better not being here,
124 /// but it seems to be needed by CutAndPaste::putClipboard().
125 void setDocumentClass(DocumentClass const * const);
126 /// List of modules in use
127 std::vector<std::string> const & getModules() const;
128 /// Add a module to the list of modules in use.
129 /// Returns true if module was successfully added.
130 /// The makeClass variable signals whether to call makeDocumentClass. This
131 /// need not be done if we know this isn't the final time through, or if
132 /// the BufferParams do not represent the parameters for an actual buffer
133 /// (as in GuiDocument).
134 bool addLayoutModule(std::string const & modName);
136 void clearLayoutModules();
138 /// returns the main font for the buffer (document)
139 Font const getFont() const;
141 /* this are for the PaperLayout */
143 PAPER_SIZE papersize;
145 PAPER_ORIENTATION orientation;
146 /// use custom margins
149 std::string paperwidth;
151 std::string paperheight;
153 std::string leftmargin;
155 std::string topmargin;
157 std::string rightmargin;
159 std::string bottommargin;
161 std::string headheight;
165 std::string footskip;
167 std::string columnsep;
169 /* some LaTeX options */
170 /// The graphics driver
171 std::string graphicsDriver;
173 std::string fontsRoman;
175 std::string fontsSans;
177 std::string fontsTypewriter;
178 /// the default family (rm, sf, tt)
179 std::string fontsDefaultFamily;
180 /// use expert Small Caps
182 /// use Old Style Figures
184 /// the scale factor of the sf font
186 /// the scale factor of the tt font
187 int fontsTypewriterScale;
190 Spacing const & spacing() const;
196 Language const * language;
198 BranchList & branchlist();
199 BranchList const & branchlist() const;
201 * The input encoding for LaTeX. This can be one of
202 * - \c auto: find out the input encoding from the used languages
203 * - \c default: ditto
204 * - any encoding supported by the inputenc package
205 * The encoding of the LyX file is always utf8 and has nothing to
206 * do with this setting.
207 * The difference between \c auto and \c default is that \c auto also
208 * causes loading of the inputenc package, while \c default does not.
209 * \c default will not work unless the user takes additional measures
210 * (such as using special environments like the CJK environment from
212 * \c default can be seen as an unspecified 8bit encoding, since LyX
213 * does not interpret it in any way apart from display on screen.
215 std::string inputenc;
216 /// The main encoding used by this buffer for LaTeX output.
217 /// Individual pieces of text can use different encodings.
218 Encoding const & encoding() const;
220 std::string preamble;
222 std::string local_layout;
228 std::string float_placement;
230 unsigned int columns;
231 /// parameters for the listings package
232 std::string listings_params;
236 std::string pagestyle;
237 /// \param index should lie in the range 0 <= \c index <= 3.
238 Bullet & temp_bullet(size_type index);
239 Bullet const & temp_bullet(size_type index) const;
240 /// \param index should lie in the range 0 <= \c index <= 3.
241 Bullet & user_defined_bullet(size_type index);
242 Bullet const & user_defined_bullet(size_type index) const;
244 /// Whether to load a package such as amsmath or esint.
245 /// The enum values must not be changed (file format!)
247 /// Don't load the package. For experts only.
249 /// Load the package if needed (recommended)
251 /// Always load the package (e.g. if the document contains
252 /// some ERT that needs the package)
255 /// Whether and how to load amsmath
257 /// Whether and how to load esint
261 /// revision tracking for this buffer ?
263 /** This param decides whether change tracking marks should be used
264 * in output (irrespective of how these marks are actually defined;
265 * for instance, they may differ for DVI and PDF generation)
271 /// the author list for the document
272 AuthorList & authors();
273 AuthorList const & authors() const;
275 /// map of the file's author IDs to buffer author IDs
276 std::vector<unsigned int> author_map;
278 std::string const dvips_options() const;
279 /** The return value of paperSizeName() depends on the
280 * purpose for which the paper size is needed, since they
281 * support different subsets of paper sizes.
283 enum PapersizePurpose {
292 std::string paperSizeName(PapersizePurpose purpose) const;
293 /// set up if and how babel is called
294 std::string babelCall(std::string const & lang_opts) const;
295 /// handle inputenc etc.
296 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
297 TexRow & texrow) const;
298 /// set up the document fonts
299 std::string const loadFonts(std::string const & rm,
300 std::string const & sf, std::string const & tt,
301 bool const & sc, bool const & osf,
302 int const & sfscale, int const & ttscale) const;
304 /// get the appropriate cite engine (natbib handling)
305 CiteEngine citeEngine() const;
307 void setCiteEngine(CiteEngine const);
309 /// options for pdf output
310 PDFOptions & pdfoptions();
311 PDFOptions const & pdfoptions() const;
315 void readPreamble(Lexer &);
317 void readLocalLayout(Lexer &);
319 void readLanguage(Lexer &);
321 void readGraphicsDriver(Lexer &);
323 void readBullets(Lexer &);
325 void readBulletsLaTeX(Lexer &);
327 void readModules(Lexer &);
329 /// for use with natbib
330 CiteEngine cite_engine_;
332 DocumentClass * doc_class_;
334 typedef std::vector<std::string> LayoutModuleList;
336 LayoutModuleList layoutModules_;
338 /** Use the Pimpl idiom to hide those member variables that would otherwise
339 * drag in other header files.
344 static Impl * clone(Impl const *);
345 static void destroy(Impl *);
347 support::copied_ptr<Impl, MemoryTraits> pimpl_;