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