4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
12 #ifndef OUTPUTPARAMS_H
13 #define OUTPUTPARAMS_H
32 enum class Flavor : int {
44 enum class CtObject : int {
75 OutputParams(Encoding const *);
78 /** The file that we export depends occasionally on what is to
81 Flavor flavor = Flavor::LaTeX;
82 /// is it some flavor of LaTeX?
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;
89 /// Same, but for math output, which only matter is XHTML output.
90 MathFlavor math_flavor = NotApplicable;
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
96 Non-nice LaTeX also includes additional safe line breaks in order to
97 increase the precision of forward/reverse search and error reporting.
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.
105 mutable bool is_child = false;
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.
111 bool moving_arg = false;
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.
117 bool intitle = false;
119 /** need_maketitle == true means that the last layout was a title layout
120 * this is to track when \maketitle needs to be output.
122 mutable bool need_maketitle = false;
124 /** have_maketitle == true means that \maketitle already has been output.
126 mutable bool have_maketitle = false;
128 /** inbranch == true means that the environment being typeset
129 is inside an active branch inset.
131 bool inbranch = false;
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.
139 mutable int inulemcmd = 0;
141 /** the font at the point where the inset is
143 * Note from lasgouttes: I have doubts on the semantics of this
144 * variable. Until this is sorted out, here are some notes on the
145 * history of local_font.
147 * A research that excludes test and assignment [*] shows that
148 * this is only used to remember language, which is a different
149 * story (and not changed by this patch). The only exception being
150 * in InsetMathHull::getCtObject and InsetMathNest::latex to
151 * support change tracking in insets, but I am not 100% sure that
152 * this is required. And historically [**] local_font used to be
153 * local_lang; it may be good to return to this simpler variable
156 * [*] git grep local_font src|grep -v 'local_font [!=]*='
158 * [**] before afed118a, which improved support for InsetLine;
159 * however, since 0e7ab29f, InsetLine does not depend on the
160 * current font anymore.
162 Font const * local_font = nullptr;
164 /** Document language lyx name
166 std::string document_language;
168 /// main font encoding of the document
169 std::string main_fontenc;
171 /** The master language. Non-null only for child documents.
172 Note that this is not the language of the top level master, but
173 of the direct parent for nested includes.
175 mutable Language const * master_language = nullptr;
177 /// Active characters
178 std::string active_chars;
180 /** Current stream encoding. Only used for LaTeX.
181 This must be set to the document encoding (via the constructor)
182 before output starts. Afterwards it must be kept up to date for
183 each single character (\sa Paragraph::latex).
184 This does also mean that you need to set it back if you use a
185 copy (e.g. in insets): \code
186 int InsetFoo::latex(..., OutputParams const & runparams_in) const
188 OutputParams runparams(runparams_in);
189 runparams.inComment = true;
191 InsetBla::latex(..., runparams);
193 runparams_in.encoding = runparams.encoding;
197 mutable Encoding const * encoding;
199 /** free_spacing == true means that the inset is in a free-spacing
202 bool free_spacing = false;
204 /** This var is set by the return value from BufferParams::writeLaTeX
206 bool use_babel = false;
208 /** Do we use polyglossia (instead of babel)?
210 bool use_polyglossia = false;
212 /** Do we use hyperref?
214 bool use_hyperref = false;
216 /// Do we use the CJK package?
217 bool use_CJK = false;
219 /** Are we generating multiple indices?
221 bool use_indices = false;
223 /** Are we using japanese (pLaTeX)?
225 bool use_japanese = false;
227 /** Customized bibtex_command
229 std::string bibtex_command;
231 /** Customized index_command
233 std::string index_command;
237 std::string hyperref_driver;
239 /** Line length to use with plaintext or LaTeX export.
241 size_type linelen = 0;
243 /** The depth of the current paragraph, set for plaintext
244 * export and used by InsetTabular
248 /** Export data filled in by the latex(), docbook(), etc. methods.
249 This is a hack: Make it possible to add stuff to constant
250 OutputParams instances.
252 std::shared_ptr<ExportData> exportdata;
254 /** Store labels, index entries, etc. (in \ref post_macro)
255 * and output them later. This is used in particular to get
256 * labels and index entries (and potentially other fragile commands)
257 * outside of moving arguments (bug 2154)
259 bool postpone_fragile_stuff = false;
261 /** Stuff to be postponed and output after the current macro
262 * (if \ref postpone_fragile_stuff is true). Used for labels and index
263 * entries in commands with moving arguments (\\section, \\caption etc.)
265 mutable docstring post_macro;
267 /** Whether we in a command that is not \\long (i.e. cannot have multiple
270 mutable bool isNonLong = false;
272 /** Whether we are entering a display math inset.
273 * Needed to correctly strike out deleted math in change tracking.
275 mutable bool inDisplayMath = false;
277 /** Whether we are leaving a display math inset.
278 * Needed to correctly track nested ulem commands in change tracking.
280 mutable bool wasDisplayMath = false;
282 /** Whether we are inside a comment inset. Insets that are including
283 * external files like InsetGraphics, InsetInclude and InsetExternal
284 * may only write the usual output and must not attempt to do
285 * something with the included files (e.g. copying, converting)
286 * if this flag is true, since they may not exist.
288 bool inComment = false;
290 /** Whether we are inside an include inset.
292 bool inInclude = false;
294 /** Whether a btUnit (for multiple biblographies) is open.
296 mutable bool openbtUnit = false;
298 /** Process only the children's aux files with BibTeX.
299 * This is necessary with chapterbib.
301 bool only_childbibs = false;
303 /** Whether we are in a table cell.
304 * For newline, it matters whether its content is aligned or not.
306 TableCell inTableCell = NO;
308 /** Whether we are inside a float or subfloat.
309 * Needed for subfloat detection on the command line.
311 Float inFloat = NONFLOAT;
313 /** Whether we are inside an index inset.
314 * ERT needs to know this, due to the active chars.
316 bool inIndexEntry = false;
318 /** Whether we are inside an IPA inset.
319 * Needed for proper IPA output.
323 /** Whether we are inside an inset that is logically deleted.
324 * A value > 0 indicates a deleted inset.
326 int inDeletedInset = 0;
328 /** The change information of the outermost logically deleted inset.
329 * changeOfDeletedInset shall only be evaluated if inDeletedInset > 0.
331 Change changeOfDeletedInset {Change::UNCHANGED};
333 /** What kind of change tracking object is this?
334 * Relevant for strikeout method in output
336 mutable CtObject ctObject = CtObject::Normal;
338 /** allow output of only part of the top-level paragraphs
339 * par_begin: beginning paragraph
341 mutable pit_type par_begin = 0;
343 /** allow output of only part of the top-level paragraphs
344 * par_end: par_end-1 is the ending paragraph
345 * if par_begin=par_end, output all paragraphs
347 mutable pit_type par_end = 0;
349 /// Id of the last paragraph before an inset
350 mutable int lastid = -1;
352 /// Last position in the last paragraph before an inset
353 mutable pos_type lastpos = 0;
355 /// is this the last paragraph in the current buffer/inset?
356 bool isLastPar = false;
359 /** whether or not to do actual file copying and image conversion
360 * This mode will be used to preview the source code
364 /// whether to display output errors or not
367 /// Should we output verbatim or escape LaTeX's special chars?
368 bool pass_thru = false;
370 /// Should we output verbatim specific chars?
371 docstring pass_thru_chars;
373 /// A specific newline macro
374 std::string newlinecmd;
376 /// Should we output captions?
377 bool html_disable_captions = false;
379 /// Are we already in a paragraph?
380 bool html_in_par = false;
382 /// Does the present context even permit paragraphs?
383 bool html_make_pars = true;
385 /// Are we already in a paragraph?
386 bool docbook_in_par = false;
388 /// Is this element's allowMultiPar useable or not?
389 bool docbook_consider_allow_multi_par = true;
391 /// Does the present context even permit paragraphs?
392 bool docbook_make_pars = true;
394 /// Are paragraphs mandatory in this context?
395 bool docbook_force_pars = false;
397 /// Anchors that should not be output (LyX-side identifier, not DocBook-side).
398 std::set<docstring> docbook_anchors_to_ignore;
400 /// Is the current context a float (such as a table or a figure)?
401 bool docbook_in_float = false;
403 /// Is the current context a listing?
404 bool docbook_in_listing = false;
406 /// Is the current context a table?
407 bool docbook_in_table = false;
409 /// Should the layouts that should/must go into <info> be generated?
410 bool docbook_generate_info = true;
412 /// Should wrappers be ignored? Mostly useful to avoid generation of <abstract>.
413 bool docbook_ignore_wrapper = false;
415 /// Some parameters are output before the rest of the paragraph, they should not be generated a second time.
416 std::set<InsetArgument const *> docbook_prepended_arguments = {};
418 /// Some parameters are output after the rest of the paragraph, they should not be generated a second time.
419 std::set<InsetArgument const *> docbook_appended_arguments = {};
421 /// Are we generating this material for inclusion in a TOC-like entity?
422 bool for_toc = false;
424 /// Are we generating this material for inclusion in a tooltip?
425 bool for_tooltip = false;
427 /// Are we generating this material for use by advanced search?
430 SearchWithDeleted = 1,
431 SearchWithoutDeleted = 2,
436 inline bool find_effective(void) const { return (for_search != OutputParams::NoSearch); }
437 inline bool find_with_non_output() const { return ((for_search & OutputParams::SearchNonOutput) != 0); }
438 inline bool find_with_deleted() const { return ((for_search & OutputParams::SearchWithDeleted) != 0); }
439 inline void find_set_feature(enum Search set_) { for_search = set_; }
440 inline void find_add_feature(enum Search add_) { for_search |= add_; }
441 inline void find_clean_features(void) { for_search = OutputParams::NoSearch; }
443 /// Are we generating this material for instant preview?
444 bool for_preview = false;
446 /// Include all children notwithstanding the use of \includeonly
447 bool includeall = false;
449 /// Explicit output folder, if any is desired
450 std::string export_folder;
452 /// A postponed \\noindent (after VSpace)
453 mutable bool need_noindent = false;
455 int for_search = NoSearch;
461 #endif // NOT OUTPUTPARAMS_H