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