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