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