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
20 #include "LayoutModuleList.h"
23 #include "insets/InsetQuotes.h"
25 #include "support/copied_ptr.h"
32 namespace support { class FileName; }
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
57 enum ParagraphSeparation {
59 ParagraphIndentSeparation,
61 ParagraphSkipSeparation
66 /// get l10n translated to the buffers language
67 docstring B_(std::string const & l10n) const;
69 /// read a header token, if unrecognised, return it or an unknown class name
70 std::string readToken(Lexer & lex,
71 std::string const & token, ///< token to read.
72 support::FileName const & filepath);
75 void writeFile(std::ostream &) const;
77 /// check what features are implied by the buffer parameters.
78 void validate(LaTeXFeatures &) const;
80 /** \returns true if the babel package is used (interogates
81 * the BufferParams and a LyXRC variable).
82 * This returned value can then be passed to the insets...
84 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
87 void useClassDefaults();
89 bool hasClassDefaults() const;
92 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 ParagraphSeparation paragraph_separation;
101 InsetQuotes::QuoteLanguage quotes_language;
103 InsetQuotes::QuoteTimes quotes_times;
105 std::string fontsize;
106 ///Get the LayoutFile this document is using.
107 LayoutFile const * baseClass() const;
109 LayoutFileIndex const & baseClassID() const;
110 /// Set the LyX layout file this document is using.
111 /// NOTE: This does not call makeDocumentClass() to update the local
112 /// DocumentClass. That needs to be done manually.
113 /// \param filename the name of the layout file
114 bool setBaseClass(std::string const & classname);
115 /// Adds the module information to the baseClass information to
116 /// create our local DocumentClass.
117 void makeDocumentClass();
118 /// Returns the DocumentClass currently in use: the BaseClass as modified
120 DocumentClass const & documentClass() const;
121 /// \return A pointer to the DocumentClass currently in use: the BaseClass
122 /// as modified by modules.
123 DocumentClass const * documentClassPtr() const;
124 /// This bypasses the baseClass and sets the textClass directly.
125 /// Should be called with care and would be better not being here,
126 /// but it seems to be needed by CutAndPaste::putClipboard().
127 void setDocumentClass(DocumentClass const * const);
128 /// List of modules in use
129 LayoutModuleList const & getModules() const { return layoutModules_; }
130 /// List of default modules the user has removed
131 std::list<std::string> const & getRemovedModules() const
132 { return removedModules_; }
134 /// Add a module to the list of modules in use. This checks only that the
135 /// module is not already in the list, so use moduleIsCompatible first if
136 /// you want to check for compatibility.
137 /// \return true if module was successfully added.
138 bool addLayoutModule(std::string const & modName);
139 /// checks to make sure module's requriements are satisfied, that it does
140 /// not conflict with already-present modules, isn't already loaded, etc.
141 bool moduleCanBeAdded(std::string const & modName) const;
143 void addRemovedModule(std::string const & modName)
144 { removedModules_.push_back(modName); }
146 void clearLayoutModules() { layoutModules_.clear(); }
147 /// Clear the removed module list
148 void clearRemovedModules() { removedModules_.clear(); }
150 /// returns the main font for the buffer (document)
151 Font const getFont() const;
153 /* this are for the PaperLayout */
155 PAPER_SIZE papersize;
157 PAPER_ORIENTATION orientation;
158 /// use custom margins
161 std::string paperwidth;
163 std::string paperheight;
165 std::string leftmargin;
167 std::string topmargin;
169 std::string rightmargin;
171 std::string bottommargin;
173 std::string headheight;
177 std::string footskip;
179 std::string columnsep;
181 /* some LaTeX options */
182 /// The graphics driver
183 std::string graphicsDriver;
184 /// The default output format
185 std::string defaultOutputFormat;
187 std::string fontsRoman;
189 std::string fontsSans;
191 std::string fontsTypewriter;
192 /// the default family (rm, sf, tt)
193 std::string fontsDefaultFamily;
194 /// use the XeTeX processor
196 /// use expert Small Caps
198 /// use Old Style Figures
200 /// the scale factor of the sf font
202 /// the scale factor of the tt font
203 int fontsTypewriterScale;
204 /// the font used by the CJK command
205 std::string fontsCJK;
208 Spacing const & spacing() const;
214 Language const * language;
216 BranchList & branchlist();
217 BranchList const & branchlist() const;
219 * The input encoding for LaTeX. This can be one of
220 * - \c auto: find out the input encoding from the used languages
221 * - \c default: ditto
222 * - any encoding supported by the inputenc package
223 * The encoding of the LyX file is always utf8 and has nothing to
224 * do with this setting.
225 * The difference between \c auto and \c default is that \c auto also
226 * causes loading of the inputenc package, while \c default does not.
227 * \c default will not work unless the user takes additional measures
228 * (such as using special environments like the CJK environment from
230 * \c default can be seen as an unspecified 8bit encoding, since LyX
231 * does not interpret it in any way apart from display on screen.
233 std::string inputenc;
234 /// The main encoding used by this buffer for LaTeX output.
235 /// Individual pieces of text can use different encodings.
236 Encoding const & encoding() const;
238 std::string preamble;
240 std::string local_layout;
243 /// use the class options defined in the layout?
244 bool use_default_options;
248 std::string float_placement;
250 unsigned int columns;
251 /// parameters for the listings package
252 std::string listings_params;
256 std::string pagestyle;
258 RGBColor backgroundcolor;
259 /// \param index should lie in the range 0 <= \c index <= 3.
260 Bullet & temp_bullet(size_type index);
261 Bullet const & temp_bullet(size_type index) const;
262 /// \param index should lie in the range 0 <= \c index <= 3.
263 Bullet & user_defined_bullet(size_type index);
264 Bullet const & user_defined_bullet(size_type index) const;
266 /// Whether to load a package such as amsmath or esint.
267 /// The enum values must not be changed (file format!)
269 /// Don't load the package. For experts only.
271 /// Load the package if needed (recommended)
273 /// Always load the package (e.g. if the document contains
274 /// some ERT that needs the package)
277 /// Whether and how to load amsmath
279 /// Whether and how to load esint
283 /// revision tracking for this buffer ?
285 /** This param decides whether change tracking marks should be used
286 * in output (irrespective of how these marks are actually defined;
287 * for instance, they may differ for DVI and PDF generation)
293 /// the author list for the document
294 AuthorList & authors();
295 AuthorList const & authors() const;
297 /// map of the file's author IDs to buffer author IDs
298 std::vector<unsigned int> author_map;
300 std::string const dvips_options() const;
301 /** The return value of paperSizeName() depends on the
302 * purpose for which the paper size is needed, since they
303 * support different subsets of paper sizes.
305 enum PapersizePurpose {
314 std::string paperSizeName(PapersizePurpose purpose) const;
315 /// set up if and how babel is called
316 std::string babelCall(std::string const & lang_opts) const;
317 /// return supported drivers for specific packages
318 docstring getGraphicsDriver(std::string const & package) const;
319 /// handle inputenc etc.
320 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
321 TexRow & texrow) const;
323 std::string const parseFontName(std::string const & name) const;
324 /// set up the document fonts
325 std::string const loadFonts(std::string const & rm,
326 std::string const & sf, std::string const & tt,
327 bool const & sc, bool const & osf,
328 int const & sfscale, int const & ttscale,
329 bool const & xetex) const;
331 /// get the appropriate cite engine (natbib handling)
332 CiteEngine citeEngine() const;
334 void setCiteEngine(CiteEngine const);
336 /// options for pdf output
337 PDFOptions & pdfoptions();
338 PDFOptions const & pdfoptions() const;
342 void readPreamble(Lexer &);
344 void readLocalLayout(Lexer &);
346 void readLanguage(Lexer &);
348 void readGraphicsDriver(Lexer &);
350 void readBullets(Lexer &);
352 void readBulletsLaTeX(Lexer &);
354 void readModules(Lexer &);
356 void readRemovedModules(Lexer &);
357 /// for use with natbib
358 CiteEngine cite_engine_;
360 DocumentClass * doc_class_;
362 LayoutModuleList layoutModules_;
363 /// this is for modules that are required by the document class but that
364 /// the user has chosen not to use
365 std::list<std::string> removedModules_;
367 /** Use the Pimpl idiom to hide those member variables that would otherwise
368 * drag in other header files.
373 static Impl * clone(Impl const *);
374 static void destroy(Impl *);
376 support::copied_ptr<Impl, MemoryTraits> pimpl_;