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"
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,
71 support::FileName const & temppath); ///< where to look for local layout file.
74 void writeFile(std::ostream &) const;
76 /// check what features are implied by the buffer parameters.
77 void validate(LaTeXFeatures &) const;
79 /** \returns true if the babel package is used (interogates
80 * the BufferParams and a LyXRC variable).
81 * This returned value can then be passed to the insets...
83 bool writeLaTeX(odocstream &, LaTeXFeatures &, TexRow &) const;
86 void useClassDefaults();
88 bool hasClassDefaults() const;
91 VSpace const & getDefSkip() const;
93 void setDefSkip(VSpace const & vs);
95 /** Whether paragraphs are separated by using a indent like in
96 * articles or by using a little skip like in letters.
98 ParagraphSeparation paragraph_separation;
100 InsetQuotes::QuoteLanguage quotes_language;
102 InsetQuotes::QuoteTimes quotes_times;
104 std::string fontsize;
105 ///Get the LayoutFile this document is using.
106 LayoutFile const * baseClass() const;
108 LayoutFileIndex const & baseClassID() const;
109 /// Set the LyX layout file this document is using.
110 /// NOTE: This does not call makeDocumentClass() to update the local
111 /// DocumentClass. That needs to be done manually.
112 /// \param filename the name of the layout file
113 bool setBaseClass(std::string const & classname);
114 /// Adds the module information to the baseClass information to
115 /// create our local DocumentClass.
116 void makeDocumentClass();
117 /// Returns the DocumentClass currently in use: the BaseClass as modified
119 DocumentClass const & documentClass() const;
120 /// \return A pointer to the DocumentClass currently in use: the BaseClass
121 /// as modified by modules.
122 DocumentClass * documentClassPtr() const;
123 /// This bypasses the baseClass and sets the textClass directly.
124 /// Should be called with care and would be better not being here,
125 /// but it seems to be needed by CutAndPaste::putClipboard().
126 void setDocumentClass(DocumentClass const * const);
127 /// List of modules in use
128 std::vector<std::string> const & getModules() const;
129 /// Add a module to the list of modules in use.
130 /// Returns true if module was successfully added.
131 /// The makeClass variable signals whether to call makeDocumentClass. This
132 /// need not be done if we know this isn't the final time through, or if
133 /// the BufferParams do not represent the parameters for an actual buffer
134 /// (as in GuiDocument).
135 bool addLayoutModule(std::string const & modName);
137 void clearLayoutModules();
139 /// returns the main font for the buffer (document)
140 Font const getFont() const;
142 /* this are for the PaperLayout */
144 PAPER_SIZE papersize;
146 PAPER_ORIENTATION orientation;
147 /// use custom margins
150 std::string paperwidth;
152 std::string paperheight;
154 std::string leftmargin;
156 std::string topmargin;
158 std::string rightmargin;
160 std::string bottommargin;
162 std::string headheight;
166 std::string footskip;
168 std::string columnsep;
170 /* some LaTeX options */
171 /// The graphics driver
172 std::string graphicsDriver;
174 std::string fontsRoman;
176 std::string fontsSans;
178 std::string fontsTypewriter;
179 /// the default family (rm, sf, tt)
180 std::string fontsDefaultFamily;
181 /// use expert Small Caps
183 /// use Old Style Figures
185 /// the scale factor of the sf font
187 /// the scale factor of the tt font
188 int fontsTypewriterScale;
191 Spacing const & spacing() const;
197 Language const * language;
199 BranchList & branchlist();
200 BranchList const & branchlist() const;
202 * The input encoding for LaTeX. This can be one of
203 * - \c auto: find out the input encoding from the used languages
204 * - \c default: ditto
205 * - any encoding supported by the inputenc package
206 * The encoding of the LyX file is always utf8 and has nothing to
207 * do with this setting.
208 * The difference between \c auto and \c default is that \c auto also
209 * causes loading of the inputenc package, while \c default does not.
210 * \c default will not work unless the user takes additional measures
211 * (such as using special environments like the CJK environment from
213 * \c default can be seen as an unspecified 8bit encoding, since LyX
214 * does not interpret it in any way apart from display on screen.
216 std::string inputenc;
217 /// The main encoding used by this buffer for LaTeX output.
218 /// Individual pieces of text can use different encodings.
219 Encoding const & encoding() const;
221 std::string preamble;
223 std::string local_layout;
227 std::string float_placement;
229 unsigned int columns;
230 /// parameters for the listings package
231 std::string listings_params;
235 std::string pagestyle;
236 /// \param index should lie in the range 0 <= \c index <= 3.
237 Bullet & temp_bullet(size_type index);
238 Bullet const & temp_bullet(size_type index) const;
239 /// \param index should lie in the range 0 <= \c index <= 3.
240 Bullet & user_defined_bullet(size_type index);
241 Bullet const & user_defined_bullet(size_type index) const;
243 /// Whether to load a package such as amsmath or esint.
244 /// The enum values must not be changed (file format!)
246 /// Don't load the package. For experts only.
248 /// Load the package if needed (recommended)
250 /// Always load the package (e.g. if the document contains
251 /// some ERT that needs the package)
254 /// Whether and how to load amsmath
256 /// Whether and how to load esint
260 /// revision tracking for this buffer ?
262 /** This param decides whether change tracking marks should be used
263 * in output (irrespective of how these marks are actually defined;
264 * for instance, they may differ for DVI and PDF generation)
272 std::vector<std::string> & extraEmbeddedFiles();
273 std::vector<std::string> const & extraEmbeddedFiles() const;
275 /// the author list for the document
276 AuthorList & authors();
277 AuthorList const & authors() const;
279 /// map of the file's author IDs to buffer author IDs
280 std::vector<unsigned int> author_map;
282 std::string const dvips_options() const;
283 /** The return value of paperSizeName() depends on the
284 * purpose for which the paper size is needed, since they
285 * support different subsets of paper sizes.
287 enum PapersizePurpose {
296 std::string paperSizeName(PapersizePurpose purpose) const;
297 /// set up if and how babel is called
298 std::string babelCall(std::string const & lang_opts) const;
299 /// handle inputenc etc.
300 void writeEncodingPreamble(odocstream & os, LaTeXFeatures & features,
301 TexRow & texrow) const;
302 /// set up the document fonts
303 std::string const loadFonts(std::string const & rm,
304 std::string const & sf, std::string const & tt,
305 bool const & sc, bool const & osf,
306 int const & sfscale, int const & ttscale) const;
308 /// get the appropriate cite engine (natbib handling)
309 biblio::CiteEngine citeEngine() 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 readLocalLayout(Lexer &);
323 void readLanguage(Lexer &);
325 void readGraphicsDriver(Lexer &);
327 void readBullets(Lexer &);
329 void readBulletsLaTeX(Lexer &);
331 void readModules(Lexer &);
333 /// for use with natbib
334 biblio::CiteEngine cite_engine_;
336 DocumentClass * doc_class_;
338 typedef std::vector<std::string> LayoutModuleList;
340 LayoutModuleList layoutModules_;
342 /** Use the Pimpl idiom to hide those member variables that would otherwise
343 * drag in other header files.
348 static Impl * clone(Impl const *);
349 static void destroy(Impl *);
351 support::copied_ptr<Impl, MemoryTraits> pimpl_;