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"
42 class LayoutFileIndex;
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,
74 support::FileName const & temppath); ///< where to look for local layout file.
77 void writeFile(std::ostream &) const;
79 /// check what features are implied by the buffer parameters.
80 void validate(LaTeXFeatures &) const;
82 /** \returns true if the babel package is used (interogates
83 * the BufferParams and a LyXRC variable).
84 * This returned value can then be passed to the insets...
86 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
89 void useClassDefaults();
92 bool hasClassDefaults() const;
95 VSpace const & getDefSkip() const;
98 void setDefSkip(VSpace const & vs);
100 /** Whether paragraphs are separated by using a indent like in
101 * articles or by using a little skip like in letters.
103 PARSEP paragraph_separation;
105 InsetQuotes::quote_language quotes_language;
107 InsetQuotes::quote_times quotes_times;
109 std::string fontsize;
110 ///Get the LayoutFile this document is using.
111 LayoutFile const * baseClass() const;
113 LayoutFileIndex const & baseClassID() const;
114 /// Set the LyX layout file this document is using.
115 /// NOTE: This does not call makeDocumentClass() to update the local
116 /// DocumentClass. That needs to be done manually.
117 /// \param filename the name of the layout file
118 bool setBaseClass(std::string const & classname);
119 /// Adds the module information to the baseClass information to
120 /// create our local DocumentClass.
121 void makeDocumentClass();
122 /// Returns the DocumentClass currently in use: the BaseClass as modified
124 DocumentClass const & documentClass() const;
125 /// \return A pointer to the DocumentClass currently in use: the BaseClass
126 /// as modified by modules.
127 DocumentClass * documentClassPtr() const;
128 /// This bypasses the baseClass and sets the textClass directly.
129 /// Should be called with care and would be better not being here,
130 /// but it seems to be needed by CutAndPaste::putClipboard().
131 void setDocumentClass(DocumentClass const * const);
132 /// List of modules in use
133 std::vector<std::string> const & getModules() const;
134 /// Add a module to the list of modules in use.
135 /// Returns true if module was successfully added.
136 /// The makeClass variable signals whether to call makeDocumentClass. This
137 /// need not be done if we know this isn't the final time through, or if
138 /// the BufferParams do not represent the parameters for an actual buffer
139 /// (as in GuiDocument).
140 bool addLayoutModule(std::string const & modName);
142 void clearLayoutModules();
144 /// returns the main font for the buffer (document)
145 Font const getFont() const;
147 /* this are for the PaperLayout */
149 PAPER_SIZE papersize;
151 PAPER_ORIENTATION orientation;
152 /// use custom margins
155 std::string paperwidth;
157 std::string paperheight;
159 std::string leftmargin;
161 std::string topmargin;
163 std::string rightmargin;
165 std::string bottommargin;
167 std::string headheight;
171 std::string footskip;
173 std::string columnsep;
175 /* some LaTeX options */
176 /// The graphics driver
177 std::string graphicsDriver;
179 std::string fontsRoman;
181 std::string fontsSans;
183 std::string fontsTypewriter;
184 /// the default family (rm, sf, tt)
185 std::string fontsDefaultFamily;
186 /// use expert Small Caps
188 /// use Old Style Figures
190 /// the scale factor of the sf font
192 /// the scale factor of the tt font
193 int fontsTypewriterScale;
196 Spacing const & spacing() const;
202 Language const * language;
204 BranchList & branchlist();
205 BranchList const & branchlist() const;
207 * The input encoding for LaTeX. This can be one of
208 * - \c auto: find out the input encoding from the used languages
209 * - \c default: ditto
210 * - any encoding supported by the inputenc package
211 * The encoding of the LyX file is always utf8 and has nothing to
212 * do with this setting.
213 * The difference between \c auto and \c default is that \c auto also
214 * causes loading of the inputenc package, while \c default does not.
215 * \c default will not work unless the user takes additional measures
216 * (such as using special environments like the CJK environment from
218 * \c default can be seen as an unspecified 8bit encoding, since LyX
219 * does not interpret it in any way apart from display on screen.
221 std::string inputenc;
222 /// The main encoding used by this buffer for LaTeX output.
223 /// Individual pieces of text can use different encodings.
224 Encoding const & encoding() const;
226 std::string preamble;
230 std::string float_placement;
232 unsigned int columns;
233 /// parameters for the listings package
234 std::string listings_params;
238 std::string pagestyle;
239 /// \param index should lie in the range 0 <= \c index <= 3.
240 Bullet & temp_bullet(size_type index);
241 Bullet const & temp_bullet(size_type index) const;
242 /// \param index should lie in the range 0 <= \c index <= 3.
243 Bullet & user_defined_bullet(size_type index);
244 Bullet const & user_defined_bullet(size_type index) const;
246 /// Whether to load a package such as amsmath or esint.
247 /// The enum values must not be changed (file format!)
249 /// Don't load the package. For experts only.
251 /// Load the package if needed (recommended)
253 /// Always load the package (e.g. if the document contains
254 /// some ERT that needs the package)
257 /// Whether and how to load amsmath
259 /// Whether and how to load esint
263 /// revision tracking for this buffer ?
265 /** This param decides whether change tracking marks should be used
266 * in output (irrespective of how these marks are actually defined;
267 * for instance, they may differ for DVI and PDF generation)
275 std::vector<std::string> & extraEmbeddedFiles();
276 std::vector<std::string> const & extraEmbeddedFiles() const;
278 /// the author list for the document
279 AuthorList & authors();
280 AuthorList const & authors() const;
282 /// map of the file's author IDs to buffer author IDs
283 std::vector<unsigned int> author_map;
285 std::string const dvips_options() const;
286 /** The return value of paperSizeName() depends on the
287 * purpose for which the paper size is needed, since they
288 * support different subsets of paper sizes.
290 enum Papersize_Purpose {
299 std::string const paperSizeName(Papersize_Purpose const & purpose) const;
300 /// set up if and how babel is called
301 std::string const babelCall(std::string const & lang_opts) const;
302 /// handle inputenc etc.
303 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
304 TexRow & texrow) const;
305 /// set up the document fonts
306 std::string const loadFonts(std::string const & rm,
307 std::string const & sf, std::string const & tt,
308 bool const & sc, bool const & osf,
309 int const & sfscale, int const & ttscale) const;
311 /// get the appropriate cite engine (natbib handling)
312 biblio::CiteEngine getEngine() const;
315 void setCiteEngine(biblio::CiteEngine const);
317 /// options for pdf output
318 PDFOptions & pdfoptions();
319 PDFOptions const & pdfoptions() const;
323 void readPreamble(Lexer &);
325 void readLanguage(Lexer &);
327 void readGraphicsDriver(Lexer &);
329 void readBullets(Lexer &);
331 void readBulletsLaTeX(Lexer &);
333 void readModules(Lexer &);
335 /// for use with natbib
336 biblio::CiteEngine cite_engine_;
338 DocumentClass * doc_class_;
340 typedef std::vector<std::string> LayoutModuleList;
342 LayoutModuleList layoutModules_;
344 /** Use the Pimpl idiom to hide those member variables that would otherwise
345 * drag in other header files.
350 static Impl * clone(Impl const *);
351 static void destroy(Impl *);
353 support::copied_ptr<Impl, MemoryTraits> pimpl_;