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"
33 namespace support { class FileName; }
43 class LayoutFileIndex;
50 /** Buffer parameters.
51 * This class contains all the parameters for this buffer's use. Some
52 * work needs to be done on this class to make it nice. Now everything
58 enum ParagraphSeparation {
60 ParagraphIndentSeparation,
62 ParagraphSkipSeparation
67 /// get l10n translated to the buffers language
68 docstring B_(std::string const & l10n) const;
70 /// read a header token, if unrecognised, return it or an unknown class name
71 std::string readToken(Lexer & lex,
72 std::string const & token, ///< token to read.
73 support::FileName const & filepath);
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();
90 bool hasClassDefaults() const;
93 VSpace const & getDefSkip() const;
95 void setDefSkip(VSpace const & vs);
97 /** Whether paragraphs are separated by using a indent like in
98 * articles or by using a little skip like in letters.
100 ParagraphSeparation paragraph_separation;
102 InsetQuotes::QuoteLanguage quotes_language;
104 InsetQuotes::QuoteTimes quotes_times;
106 std::string fontsize;
107 ///Get the LayoutFile this document is using.
108 LayoutFile const * baseClass() const;
110 LayoutFileIndex const & baseClassID() const;
111 /// Set the LyX layout file this document is using.
112 /// NOTE: This does not call makeDocumentClass() to update the local
113 /// DocumentClass. That needs to be done manually.
114 /// \param filename the name of the layout file
115 bool setBaseClass(std::string const & classname);
116 /// Adds the module information to the baseClass information to
117 /// create our local DocumentClass.
118 void makeDocumentClass();
119 /// Returns the DocumentClass currently in use: the BaseClass as modified
121 DocumentClass const & documentClass() const;
122 /// \return A pointer to the DocumentClass currently in use: the BaseClass
123 /// as modified by modules.
124 DocumentClass const * documentClassPtr() const;
125 /// This bypasses the baseClass and sets the textClass directly.
126 /// Should be called with care and would be better not being here,
127 /// but it seems to be needed by CutAndPaste::putClipboard().
128 void setDocumentClass(DocumentClass const * const);
129 /// List of modules in use
130 LayoutModuleList const & getModules() const { return layoutModules_; }
131 /// List of default modules the user has removed
132 std::set<std::string> const & getRemovedModules() const
133 { return removedModules_; }
135 /// Add a module to the list of modules in use. This checks only that the
136 /// module is not already in the list, so use moduleIsCompatible first if
137 /// you want to check for compatibility.
138 /// \return true if module was successfully added.
139 bool addLayoutModule(std::string const & modName);
140 /// checks to make sure module's requriements are satisfied, that it does
141 /// not conflict with already-present modules, isn't already loaded, etc.
142 bool moduleCanBeAdded(std::string const & modName) const;
144 void addRemovedModule(std::string const & modName)
145 { removedModules_.insert(modName); }
147 void clearLayoutModules() { layoutModules_.clear(); }
148 /// Clear the removed module list
149 void clearRemovedModules() { removedModules_.clear(); }
151 /// returns the main font for the buffer (document)
152 Font const getFont() const;
154 /* this are for the PaperLayout */
156 PAPER_SIZE papersize;
158 PAPER_ORIENTATION orientation;
159 /// use custom margins
162 std::string paperwidth;
164 std::string paperheight;
166 std::string leftmargin;
168 std::string topmargin;
170 std::string rightmargin;
172 std::string bottommargin;
174 std::string headheight;
178 std::string footskip;
180 std::string columnsep;
182 /* some LaTeX options */
183 /// The graphics driver
184 std::string graphicsDriver;
186 std::string fontsRoman;
188 std::string fontsSans;
190 std::string fontsTypewriter;
191 /// the default family (rm, sf, tt)
192 std::string fontsDefaultFamily;
193 /// use expert Small Caps
195 /// use Old Style Figures
197 /// the scale factor of the sf font
199 /// the scale factor of the tt font
200 int fontsTypewriterScale;
201 /// the font used by the CJK command
202 std::string fontsCJK;
205 Spacing const & spacing() const;
211 Language const * language;
213 BranchList & branchlist();
214 BranchList const & branchlist() const;
216 * The input encoding for LaTeX. This can be one of
217 * - \c auto: find out the input encoding from the used languages
218 * - \c default: ditto
219 * - any encoding supported by the inputenc package
220 * The encoding of the LyX file is always utf8 and has nothing to
221 * do with this setting.
222 * The difference between \c auto and \c default is that \c auto also
223 * causes loading of the inputenc package, while \c default does not.
224 * \c default will not work unless the user takes additional measures
225 * (such as using special environments like the CJK environment from
227 * \c default can be seen as an unspecified 8bit encoding, since LyX
228 * does not interpret it in any way apart from display on screen.
230 std::string inputenc;
231 /// The main encoding used by this buffer for LaTeX output.
232 /// Individual pieces of text can use different encodings.
233 Encoding const & encoding() const;
235 std::string preamble;
237 std::string local_layout;
240 /// use the class options defined in the layout?
241 bool use_default_options;
245 std::string float_placement;
247 unsigned int columns;
248 /// parameters for the listings package
249 std::string listings_params;
253 std::string pagestyle;
254 /// \param index should lie in the range 0 <= \c index <= 3.
255 Bullet & temp_bullet(size_type index);
256 Bullet const & temp_bullet(size_type index) const;
257 /// \param index should lie in the range 0 <= \c index <= 3.
258 Bullet & user_defined_bullet(size_type index);
259 Bullet const & user_defined_bullet(size_type index) const;
261 /// Whether to load a package such as amsmath or esint.
262 /// The enum values must not be changed (file format!)
264 /// Don't load the package. For experts only.
266 /// Load the package if needed (recommended)
268 /// Always load the package (e.g. if the document contains
269 /// some ERT that needs the package)
272 /// Whether and how to load amsmath
274 /// Whether and how to load esint
278 /// revision tracking for this buffer ?
280 /** This param decides whether change tracking marks should be used
281 * in output (irrespective of how these marks are actually defined;
282 * for instance, they may differ for DVI and PDF generation)
288 /// the author list for the document
289 AuthorList & authors();
290 AuthorList const & authors() const;
292 /// map of the file's author IDs to buffer author IDs
293 std::vector<unsigned int> author_map;
295 std::string const dvips_options() const;
296 /** The return value of paperSizeName() depends on the
297 * purpose for which the paper size is needed, since they
298 * support different subsets of paper sizes.
300 enum PapersizePurpose {
309 std::string paperSizeName(PapersizePurpose purpose) const;
310 /// set up if and how babel is called
311 std::string babelCall(std::string const & lang_opts) const;
312 /// return supported drivers for specific packages
313 docstring getGraphicsDriver(std::string const & package) const;
314 /// handle inputenc etc.
315 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
316 TexRow & texrow) const;
317 /// set up the document fonts
318 std::string const loadFonts(std::string const & rm,
319 std::string const & sf, std::string const & tt,
320 bool const & sc, bool const & osf,
321 int const & sfscale, int const & ttscale) const;
323 /// get the appropriate cite engine (natbib handling)
324 CiteEngine citeEngine() const;
326 void setCiteEngine(CiteEngine const);
328 /// options for pdf output
329 PDFOptions & pdfoptions();
330 PDFOptions const & pdfoptions() const;
334 void readPreamble(Lexer &);
336 void readLocalLayout(Lexer &);
338 void readLanguage(Lexer &);
340 void readGraphicsDriver(Lexer &);
342 void readBullets(Lexer &);
344 void readBulletsLaTeX(Lexer &);
346 void readModules(Lexer &);
348 void readRemovedModules(Lexer &);
349 /// Called when the document class changes. Removes modules
350 /// excluded by, provided by, etc, the document class.
351 /// \return true if modules were consistent, false if changes had
353 bool removeBadModules();
354 /// Adds default modules, if they're addable.
355 void addDefaultModules();
356 /// checks for consistency among modules: makes sure requirements
357 /// are met, no modules exclude one another, etc, and resolves any
358 /// such conflicts, leaving us with a consistent collection.
359 /// \return true if modules were consistent, false if changes had
361 bool checkModuleConsistency();
363 /// for use with natbib
364 CiteEngine cite_engine_;
366 DocumentClass * doc_class_;
368 LayoutModuleList layoutModules_;
369 /// this is for modules that are required by the document class but that
370 /// the user has chosen not to use
371 std::set<std::string> removedModules_;
373 /** Use the Pimpl idiom to hide those member variables that would otherwise
374 * drag in other header files.
379 static Impl * clone(Impl const *);
380 static void destroy(Impl *);
382 support::copied_ptr<Impl, MemoryTraits> pimpl_;