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
; }
45 class LayoutFileIndex
;
52 /** Buffer parameters.
53 * This class contains all the parameters for this buffer's use. Some
54 * work needs to be done on this class to make it nice. Now everything
60 enum ParagraphSeparation
{
62 ParagraphIndentSeparation
,
64 ParagraphSkipSeparation
69 /// get l10n translated to the buffers language
70 docstring
B_(std::string
const & l10n
) const;
72 /// read a header token, if unrecognised, return it or an unknown class name
73 std::string
readToken(Lexer
& lex
,
74 std::string
const & token
, ///< token to read.
75 support::FileName
const & filepath
);
78 void writeFile(std::ostream
&) const;
80 /// check what features are implied by the buffer parameters.
81 void validate(LaTeXFeatures
&) const;
83 /** \returns true if the babel package is used (interogates
84 * the BufferParams and a LyXRC variable).
85 * This returned value can then be passed to the insets...
87 bool writeLaTeX(odocstream
&, LaTeXFeatures
&, TexRow
&) const;
90 void useClassDefaults();
92 bool hasClassDefaults() const;
95 HSpace
const & getIndentation() const;
97 void setIndentation(HSpace
const & indent
);
99 VSpace
const & getDefSkip() const;
101 void setDefSkip(VSpace
const & vs
);
103 /** Whether paragraphs are separated by using a indent like in
104 * articles or by using a little skip like in letters.
106 ParagraphSeparation paragraph_separation
;
108 InsetQuotes::QuoteLanguage quotes_language
;
110 InsetQuotes::QuoteTimes quotes_times
;
112 std::string fontsize
;
113 ///Get the LayoutFile this document is using.
114 LayoutFile
const * baseClass() const;
116 LayoutFileIndex
const & baseClassID() const;
117 /// Set the LyX layout file this document is using.
118 /// NOTE: This does not call makeDocumentClass() to update the local
119 /// DocumentClass. That needs to be done manually.
120 /// \param filename the name of the layout file
121 bool setBaseClass(std::string
const & classname
);
122 /// Adds the module information to the baseClass information to
123 /// create our local DocumentClass.
124 void makeDocumentClass();
125 /// Returns the DocumentClass currently in use: the BaseClass as modified
127 DocumentClass
const & documentClass() const;
128 /// \return A pointer to the DocumentClass currently in use: the BaseClass
129 /// as modified by modules.
130 DocumentClass
const * documentClassPtr() const;
131 /// This bypasses the baseClass and sets the textClass directly.
132 /// Should be called with care and would be better not being here,
133 /// but it seems to be needed by CutAndPaste::putClipboard().
134 void setDocumentClass(DocumentClass
const * const);
135 /// List of modules in use
136 LayoutModuleList
const & getModules() const { return layoutModules_
; }
137 /// List of default modules the user has removed
138 std::list
<std::string
> const & getRemovedModules() const
139 { return removedModules_
; }
141 /// Add a module to the list of modules in use. This checks only that the
142 /// module is not already in the list, so use moduleIsCompatible first if
143 /// you want to check for compatibility.
144 /// \return true if module was successfully added.
145 bool addLayoutModule(std::string
const & modName
);
146 /// checks to make sure module's requriements are satisfied, that it does
147 /// not conflict with already-present modules, isn't already loaded, etc.
148 bool moduleCanBeAdded(std::string
const & modName
) const;
150 void addRemovedModule(std::string
const & modName
)
151 { removedModules_
.push_back(modName
); }
153 void clearLayoutModules() { layoutModules_
.clear(); }
154 /// Clear the removed module list
155 void clearRemovedModules() { removedModules_
.clear(); }
157 /// returns the main font for the buffer (document)
158 Font
const getFont() const;
160 /* this are for the PaperLayout */
162 PAPER_SIZE papersize
;
164 PAPER_ORIENTATION orientation
;
165 /// use custom margins
168 std::string paperwidth
;
170 std::string paperheight
;
172 std::string leftmargin
;
174 std::string topmargin
;
176 std::string rightmargin
;
178 std::string bottommargin
;
180 std::string headheight
;
184 std::string footskip
;
186 std::string columnsep
;
188 /* some LaTeX options */
189 /// The graphics driver
190 std::string graphicsDriver
;
191 /// The default output format
192 std::string defaultOutputFormat
;
193 /// customized bibliography processor
194 std::string bibtex_command
;
195 /// customized index processor
196 std::string index_command
;
198 std::string fontsRoman
;
200 std::string fontsSans
;
202 std::string fontsTypewriter
;
203 /// the default family (rm, sf, tt)
204 std::string fontsDefaultFamily
;
205 /// use the XeTeX processor
207 /// use expert Small Caps
209 /// use Old Style Figures
211 /// the scale factor of the sf font
213 /// the scale factor of the tt font
214 int fontsTypewriterScale
;
215 /// the font used by the CJK command
216 std::string fontsCJK
;
219 Spacing
const & spacing() const;
225 Language
const * language
;
227 BranchList
& branchlist();
228 BranchList
const & branchlist() const;
230 IndicesList
& indiceslist();
231 IndicesList
const & indiceslist() const;
233 * The input encoding for LaTeX. This can be one of
234 * - \c auto: find out the input encoding from the used languages
235 * - \c default: ditto
236 * - any encoding supported by the inputenc package
237 * The encoding of the LyX file is always utf8 and has nothing to
238 * do with this setting.
239 * The difference between \c auto and \c default is that \c auto also
240 * causes loading of the inputenc package, while \c default does not.
241 * \c default will not work unless the user takes additional measures
242 * (such as using special environments like the CJK environment from
244 * \c default can be seen as an unspecified 8bit encoding, since LyX
245 * does not interpret it in any way apart from display on screen.
247 std::string inputenc
;
248 /// The main encoding used by this buffer for LaTeX output.
249 /// Individual pieces of text can use different encodings.
250 Encoding
const & encoding() const;
252 std::string preamble
;
254 std::string local_layout
;
257 /// use the class options defined in the layout?
258 bool use_default_options
;
264 std::string float_placement
;
266 unsigned int columns
;
267 /// parameters for the listings package
268 std::string listings_params
;
272 std::string pagestyle
;
274 RGBColor backgroundcolor
;
275 /// \param index should lie in the range 0 <= \c index <= 3.
276 Bullet
& temp_bullet(size_type index
);
277 Bullet
const & temp_bullet(size_type index
) const;
278 /// \param index should lie in the range 0 <= \c index <= 3.
279 Bullet
& user_defined_bullet(size_type index
);
280 Bullet
const & user_defined_bullet(size_type index
) const;
282 /// Whether to load a package such as amsmath or esint.
283 /// The enum values must not be changed (file format!)
285 /// Don't load the package. For experts only.
287 /// Load the package if needed (recommended)
289 /// Always load the package (e.g. if the document contains
290 /// some ERT that needs the package)
293 /// Whether and how to load amsmath
295 /// Whether and how to load esint
297 /// Split bibliography?
301 /// revision tracking for this buffer ?
303 /** This param decides whether change tracking marks should be used
304 * in output (irrespective of how these marks are actually defined;
305 * for instance, they may differ for DVI and PDF generation)
311 /// the author list for the document
312 AuthorList
& authors();
313 AuthorList
const & authors() const;
315 /// map of the file's author IDs to AuthorList indexes
316 std::map
<unsigned int, int> author_map
;
318 std::string
const dvips_options() const;
319 /** The return value of paperSizeName() depends on the
320 * purpose for which the paper size is needed, since they
321 * support different subsets of paper sizes.
323 enum PapersizePurpose
{
332 std::string
paperSizeName(PapersizePurpose purpose
) const;
333 /// set up if and how babel is called
334 std::string
babelCall(std::string
const & lang_opts
) const;
335 /// return supported drivers for specific packages
336 docstring
getGraphicsDriver(std::string
const & package
) const;
337 /// handle inputenc etc.
338 void writeEncodingPreamble(odocstream
& os
, LaTeXFeatures
& features
,
339 TexRow
& texrow
) const;
341 std::string
const parseFontName(std::string
const & name
) const;
342 /// set up the document fonts
343 std::string
const loadFonts(std::string
const & rm
,
344 std::string
const & sf
, std::string
const & tt
,
345 bool const & sc
, bool const & osf
,
346 int const & sfscale
, int const & ttscale
,
347 bool const & xetex
) const;
349 /// get the appropriate cite engine (natbib handling)
350 CiteEngine
citeEngine() const;
352 void setCiteEngine(CiteEngine
const);
354 /// options for pdf output
355 PDFOptions
& pdfoptions();
356 PDFOptions
const & pdfoptions() const;
360 void readPreamble(Lexer
&);
362 void readLocalLayout(Lexer
&);
364 void readLanguage(Lexer
&);
366 void readGraphicsDriver(Lexer
&);
368 void readBullets(Lexer
&);
370 void readBulletsLaTeX(Lexer
&);
372 void readModules(Lexer
&);
374 void readRemovedModules(Lexer
&);
375 /// for use with natbib
376 CiteEngine cite_engine_
;
378 DocumentClass
* doc_class_
;
380 LayoutModuleList layoutModules_
;
381 /// this is for modules that are required by the document class but that
382 /// the user has chosen not to use
383 std::list
<std::string
> removedModules_
;
385 /** Use the Pimpl idiom to hide those member variables that would otherwise
386 * drag in other header files.
391 static Impl
* clone(Impl
const *);
392 static void destroy(Impl
*);
394 support::copied_ptr
<Impl
, MemoryTraits
> pimpl_
;