]> git.lyx.org Git - lyx.git/blob - src/OutputParams.h
Update Russian localization
[lyx.git] / src / OutputParams.h
1 // -*- C++ -*-
2 /**
3  * \file OutputParams.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  *  \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef OUTPUTPARAMS_H
13 #define OUTPUTPARAMS_H
14
15
16 #include "Changes.h"
17
18 #include <memory>
19 #include <set>
20
21
22 namespace lyx {
23
24
25 class Encoding;
26 class ExportData;
27 class Font;
28 class Language;
29
30 class OutputParams {
31 public:
32         enum FLAVOR {
33                 DVILUATEX,
34                 LATEX,
35                 LUATEX,
36                 PDFLATEX,
37                 XETEX,
38                 DOCBOOK5,
39                 HTML,
40                 TEXT,
41                 LYX
42         };
43
44         enum MathFlavor {
45                 NotApplicable,
46                 MathAsMathML,
47                 MathAsHTML,
48                 MathAsImages,
49                 MathAsLaTeX
50         };
51
52         enum TableCell {
53                 NO,
54                 PLAIN,
55                 ALIGNED
56         };
57
58         enum Float {
59                 NONFLOAT,
60                 MAINFLOAT,
61                 SUBFLOAT
62         };
63
64         enum CtObject {
65                 CT_NORMAL,
66                 CT_OBJECT,
67                 CT_DISPLAYOBJECT,
68                 CT_UDISPLAYOBJECT,
69                 CT_OMITOBJECT
70         };
71
72         OutputParams(Encoding const *);
73         ~OutputParams();
74
75         /** The file that we export depends occasionally on what is to
76             compile the file.
77         */
78         FLAVOR flavor = LATEX;
79         /// is it some flavor of LaTeX?
80         bool isLaTeX() const;
81         /// does this flavour support full unicode?
82         bool isFullUnicode() const;
83         /// Do we use the bidi package (which does some reordering and stuff)?
84         bool useBidiPackage() const;
85
86         /// Same, but for math output, which only matter is XHTML output.
87         MathFlavor math_flavor = NotApplicable;
88
89         /** Are we to write a 'nice' LaTeX file or not.
90             This essentially seems to mean whether InsetInclude, InsetGraphics
91             and InsetExternal should add the absolute path to any external
92             files or not.
93             Non-nice LaTeX also includes additional safe line breaks in order to
94             increase the precision of forward/reverse search and error reporting.
95         */
96         bool nice = false;
97
98         /** Is this a real child (i.e., compiled as a child)?
99             This depends on wherefrom we export the buffer. Even children
100             that have a master can be compiled standalone.
101         */
102         mutable bool is_child = false;
103
104         /** moving_arg == true means that the environment in which the inset
105             is typeset is a moving argument. The inset should take care about
106             fragile commands by preceding the latex with \\protect.
107         */
108         bool moving_arg = false;
109
110         /** intitle == true means that the environment in which the
111             inset is typeset is part of a title (before a \\maketitle).
112             Footnotes in such environments have moving arguments.
113         */
114         bool intitle = false;
115
116         /** need_maketitle == true means that the last layout was a title layout
117          * this is to track when \maketitle needs to be output.
118         */
119         mutable bool need_maketitle = false;
120
121         /** have_maketitle == true means that \maketitle already hase been output.
122         */
123         mutable bool have_maketitle = false;
124
125         /** inbranch == true means that the environment being typeset
126             is inside an active branch inset.
127         */
128         bool inbranch = false;
129
130         /** inulemcmd > 0 means that the environment in which the
131             inset is typeset is part of a ulem or soul command (e.g., \uline,
132             \uuline, \uwave, \sout or \xout). Insets that output latex commands
133             relying on local assignments (such as \cite) should enclose such
134             commands in \mbox{} in order to avoid breakage.
135         */
136         mutable int inulemcmd = 0;
137
138         /** the font at the point where the inset is
139          */
140         Font const * local_font = nullptr;
141
142         /** Document language lyx name
143          */
144         std::string document_language;
145
146         /// main font encoding of the document
147         std::string main_fontenc;
148
149         /** The master language. Non-null only for child documents.
150             Note that this is not the language of the top level master, but
151             of the direct parent for nested includes.
152          */
153         mutable Language const * master_language = nullptr;
154
155         /// Active characters
156         std::string active_chars;
157
158         /** Current stream encoding. Only used for LaTeX.
159             This must be set to the document encoding (via the constructor)
160             before output starts. Afterwards it must be kept up to date for
161             each single character (\sa Paragraph::latex).
162             This does also mean that you need to set it back if you use a
163             copy (e.g. in insets): \code
164             int InsetFoo::latex(..., OutputParams const & runparams_in) const
165             {
166                 OutputParams runparams(runparams_in);
167                 runparams.inComment = true;
168                 ...
169                 InsetBla::latex(..., runparams);
170                 ...
171                 runparams_in.encoding = runparams.encoding;
172             }
173             \endcode
174          */
175         mutable Encoding const * encoding;
176
177         /** free_spacing == true means that the inset is in a free-spacing
178             paragraph.
179         */
180         bool free_spacing = false;
181
182         /** This var is set by the return value from BufferParams::writeLaTeX
183         */
184         bool use_babel = false;
185
186         /** Do we use polyglossia (instead of babel)?
187         */
188         bool use_polyglossia = false;
189
190         /** Do we use hyperref?
191         */
192         bool use_hyperref = false;
193
194         /// Do we use the CJK package?
195         bool use_CJK = false;
196
197         /** Are we generating multiple indices?
198         */
199         bool use_indices = false;
200
201         /** Are we using japanese (pLaTeX)?
202         */
203         bool use_japanese = false;
204
205         /** Customized bibtex_command
206         */
207         std::string bibtex_command;
208
209         /** Customized index_command
210         */
211         std::string index_command;
212
213         /** Hyperref driver
214         */
215         std::string hyperref_driver;
216
217         /** Line length to use with plaintext or LaTeX export.
218         */
219         size_type linelen = 0;
220
221         /** The depth of the current paragraph, set for plaintext
222          *  export and used by InsetTabular
223          */
224         int depth = 0;
225
226         /** Export data filled in by the latex(), docbook(), etc. methods.
227             This is a hack: Make it possible to add stuff to constant
228             OutputParams instances.
229         */
230         std::shared_ptr<ExportData> exportdata;
231
232         /** Store labels, index entries, etc. (in \ref post_macro)
233          *  and output them later. This is used in particular to get
234          *  labels and index entries (and potentially other fragile commands)
235          *  outside of moving arguments (bug 2154)
236          */
237         bool postpone_fragile_stuff = false;
238
239         /** Stuff to be postponed and output after the current macro
240          *  (if \ref postpone_fragile_stuff is true). Used for labels and index
241          *  entries in commands with moving arguments (\\section, \\caption etc.)
242          */
243         mutable docstring post_macro;
244
245         /** Whether we are entering a display math inset.
246          *  Needed to correctly strike out deleted math in change tracking.
247          */
248         mutable bool inDisplayMath = false;
249
250         /** Whether we are leaving a display math inset.
251          *  Needed to correctly track nested ulem commands in change tracking.
252          */
253         mutable bool wasDisplayMath = false;
254
255         /** Whether we are inside a comment inset. Insets that are including
256          *  external files like InsetGraphics, InsetInclude and InsetExternal
257          *  may only write the usual output and must not attempt to do
258          *  something with the included files (e.g. copying, converting)
259          *  if this flag is true, since they may not exist.
260          */
261         bool inComment = false;
262
263         /** Whether we are inside an include inset. 
264          */
265         bool inInclude = false;
266
267         /** Whether a btUnit (for multiple biblographies) is open.
268          */
269         mutable bool openbtUnit = false;
270
271         /** Process only the children's aux files with BibTeX.
272          *  This is necessary with chapterbib.
273          */
274         bool only_childbibs = false;
275
276         /** Whether we are in a table cell.
277          *  For newline, it matters whether its content is aligned or not.
278          */
279         TableCell inTableCell = NO;
280
281         /** Whether we are inside a float or subfloat.
282          *  Needed for subfloat detection on the command line.
283          */
284         Float inFloat = NONFLOAT;
285
286         /** Whether we are inside an index inset.
287          *  ERT needs to know this, due to the active chars.
288          */
289         bool inIndexEntry = false;
290
291         /** Whether we are inside an IPA inset.
292          *  Needed for proper IPA output.
293          */
294         bool inIPA = false;
295
296         /** Whether we are inside an inset that is logically deleted.
297          *  A value > 0 indicates a deleted inset.
298         */
299         int inDeletedInset = 0;
300
301         /** The change information of the outermost logically deleted inset.
302          *  changeOfDeletedInset shall only be evaluated if inDeletedInset > 0.
303         */
304         Change changeOfDeletedInset {Change::UNCHANGED};
305
306         /** What kind of change tracking object is this?
307          * Relevant for strikeout method in output
308          */
309         mutable CtObject ctObject = CT_NORMAL;
310
311         /** allow output of only part of the top-level paragraphs
312          *  par_begin: beginning paragraph
313          */
314         mutable pit_type par_begin = 0;
315
316         /** allow output of only part of the top-level paragraphs
317          *  par_end: par_end-1 is the ending paragraph
318          *  if par_begin=par_end, output all paragraphs
319          */
320         mutable pit_type par_end = 0;
321
322         /// Id of the last paragraph before an inset
323         mutable int lastid = -1;
324
325         /// Last position in the last paragraph before an inset
326         mutable pos_type lastpos = 0;
327
328         /// is this the last paragraph in the current buffer/inset?
329         bool isLastPar = false;
330
331
332         /** whether or not to do actual file copying and image conversion
333          *  This mode will be used to preview the source code
334          */
335         bool dryrun = false;
336
337         /// whether to display output errors or not
338         bool silent = false;
339
340         /// Should we output verbatim or escape LaTeX's special chars?
341         bool pass_thru = false;
342
343         /// Should we output verbatim specific chars?
344         docstring pass_thru_chars;
345
346         /// A specific newline macro
347         std::string newlinecmd;
348
349         /// Should we output captions?
350         bool html_disable_captions = false;
351
352         /// Are we already in a paragraph?
353         bool html_in_par = false;
354
355         /// Does the present context even permit paragraphs?
356         bool html_make_pars = true;
357
358         /// Are we already in a paragraph?
359         bool docbook_in_par = false;
360
361         /// Does the present context even permit paragraphs?
362         bool docbook_make_pars = true;
363
364         /// Are paragraphs mandatory in this context?
365         bool docbook_force_pars = false;
366
367         /// Anchors that should not be output (LyX-side identifier, not DocBook-side).
368         std::set<docstring> docbook_anchors_to_ignore;
369
370         /// Is the current context a float (such as a table or a figure)?
371         bool docbook_in_float = false;
372
373         /// Is the current context a listing?
374         bool docbook_in_listing = false;
375
376         /// Is the current context a table?
377         bool docbook_in_table = false;
378
379         /// Are we generating this material for inclusion in a TOC-like entity?
380         bool for_toc = false;
381
382         /// Are we generating this material for inclusion in a tooltip?
383         bool for_tooltip = false;
384
385         /// Are we generating this material for use by advanced search?
386         bool for_search = false;
387
388         /// Are we generating this material for instant preview?
389         bool for_preview = false;
390
391         /// Include all children notwithstanding the use of \includeonly
392         bool includeall = false;
393
394         /// Explicit output folder, if any is desired
395         std::string export_folder;
396 };
397
398
399 } // namespace lyx
400
401 #endif // NOT OUTPUTPARAMS_H