]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
Rename LATEX debug level to OUTFILE and use it for DocBook, HTML, and XML messages.
[lyx.git] / src / insets / InsetLayout.h
1 // -*- C++ -*-
2 /**
3  * \file InsetLayout.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Martin Vermeer
8  * \author Richard Kimberly Heck
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_LAYOUT_H
14 #define INSET_LAYOUT_H
15
16 #include "ColorCode.h"
17 #include "FontInfo.h"
18 #include "Layout.h"
19
20 #include "support/docstring.h"
21
22 #include <set>
23 #include <string>
24
25 namespace lyx {
26
27 class Lexer;
28 class TextClass;
29
30
31 enum class InsetDecoration : int {
32         CLASSIC,
33         MINIMALISTIC,
34         CONGLOMERATE,
35         DEFAULT
36 };
37
38 enum class InsetLyXType : int {
39         NOLYXTYPE,
40         CHARSTYLE,
41         CUSTOM,
42         END,
43         STANDARD
44 };
45
46 enum class InsetLaTeXType : int {
47         NOLATEXTYPE,
48         COMMAND,
49         ENVIRONMENT,
50         ILT_ERROR
51 };
52
53
54 ///
55 class InsetLayout {
56 public:
57         ///
58         InsetLayout() { labelfont_.setColor(Color_error); }
59         ///
60         bool read(Lexer & lexrc, TextClass const & tclass,
61                         bool validating = false);
62         ///
63         docstring name() const { return name_; }
64         ///
65         void setName(docstring const & n) { name_ = n; }
66         ///
67         InsetLyXType lyxtype() const { return lyxtype_; }
68         ///
69         docstring labelstring() const { return labelstring_; }
70         ///
71         docstring menustring() const { return menustring_; }
72         ///
73         bool contentaslabel() const { return contentaslabel_; }
74         ///
75         InsetDecoration decoration() const { return decoration_; }
76         ///
77         InsetLaTeXType latextype() const { return latextype_; }
78         ///
79         std::string latexname() const { return latexname_; }
80         ///
81         std::string latexparam() const { return latexparam_; }
82         ///
83         docstring leftdelim() const { return leftdelim_; }
84         ///
85         docstring rightdelim() const { return rightdelim_; }
86         ///
87         FontInfo font() const { return font_; }
88         ///
89         FontInfo labelfont() const { return labelfont_; }
90         ///
91         ColorCode bgcolor() const { return bgcolor_; }
92         ///
93         Layout::LaTeXArgMap const & latexargs() const { return latexargs_; }
94         ///
95         Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
96         /// Returns latexargs() + postcommandargs().
97         /// But note that it returns a *copy*, not a reference, so do not do
98         /// anything like:
99         ///   Layout::LaTeXArgMap::iterator it = args().begin();
100         ///   Layout::LaTeXArgMap::iterator en = args().end();
101         /// Those are iterators for different containers.
102         Layout::LaTeXArgMap args() const;
103         ///
104         int optArgs() const;
105         ///
106         int requiredArgs() const;
107         ///
108         docstring preamble() const { return preamble_; }
109         /// Get language dependent macro definitions needed for this inset
110         docstring const langpreamble() const { return langpreamble_; }
111         /// Get language and babel dependent macro definitions needed for
112         /// this inset
113         docstring const babelpreamble() const { return babelpreamble_; }
114         ///
115         bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
116         ///
117         docstring counter() const { return counter_; }
118         ///
119         docstring refprefix() const { return refprefix_; }
120         /// The tag enclosing all the material in this inset. Default is "span".
121         std::string const & htmltag() const;
122         /// Additional attributes for inclusion with the start tag. Default (if
123         /// a tag is provided) is: class="name".
124         std::string const & htmlattr() const;
125         /// Tag for individual paragraphs in the inset. Default is none.
126         std::string const & htmlinnertag() const { return htmlinnertag_; }
127         /// Attributes for that tag. Default (if a tag is provided) is:
128         /// class="name_inner".
129         std::string const & htmlinnerattr() const;
130         /// A label for this environment, possibly including a reference
131         /// to a counter. E.g., for footnote, it might be:
132         ///    \arabic{footnote}
133         /// No default.
134         /// FIXME Could we get this from the layout?
135         std::string const & htmllabel() const { return htmllabel_; }
136         ///
137         inline std::string htmllabeltag() const { return "span"; }
138         ///
139         std::string htmllabelattr() const
140                 { return "class=\"" + defaultCSSClass() + "_label\""; }
141         /// CSS associated with this inset.
142         docstring htmlstyle() const;
143         /// Additional material for the header.
144         docstring htmlpreamble() const { return htmlpreamble_; }
145         /// Whether this inset represents a "block" of material, i.e., a set
146         /// of paragraphs of its own (true), or should be run into the previous
147         /// paragraph (false). Examples:
148         ///   For branches, this is false.
149         ///   For footnotes, this is true.
150         /// Defaults to true.
151         bool htmlisblock() const { return htmlisblock_; }
152         ///
153         std::string docbooktag() const { return docbooktag_; }
154         ///
155         std::string docbooktagtype() const;
156         ///
157         std::string docbookattr() const { return docbookattr_; }
158         ///
159         std::string docbookinnertag() const { return docbookinnertag_; }
160         ///
161         std::string docbookinnertagtype() const;
162         ///
163         std::string docbookinnerattr() const { return docbookinnerattr_; }
164         ///
165         std::string const & docbookininfo() const;
166         ///
167         bool docbooksection() const { return docbooksection_; }
168         ///
169         bool docbooknotinpara() const { return docbooknotinpara_; }
170         ///
171         bool docbookargumentbeforemaintag() const { return docbookargumentbeforemaintag_; }
172         ///
173         bool docbookargumentaftermaintag() const { return docbookargumentaftermaintag_; }
174         ///
175         std::string docbookwrappertag() const { return docbookwrappertag_; }
176         ///
177         std::string docbookwrappertagtype() const;
178         ///
179         std::string docbookwrapperattr() const { return docbookwrapperattr_; }
180         ///
181         std::string docbookitemwrappertag() const { return docbookitemwrappertag_; }
182         ///
183         std::string docbookitemwrappertagtype() const;
184         ///
185         std::string docbookitemwrapperattr() const { return docbookitemwrapperattr_; }
186         ///
187         std::string docbookitemtag() const { return docbookitemtag_; }
188         ///
189         std::string docbookitemtagtype() const;
190         ///
191         std::string docbookitemattr() const { return docbookitemattr_; }
192         ///
193         bool docbooknofontinside() const { return docbooknofontinside_; }
194         ///
195         bool docbookrenderasimage() const { return docbookrenderasimage_; }
196         ///
197         std::set<std::string> required() const { return required_; }
198         ///
199         bool isMultiPar() const { return multipar_; }
200         ///
201         bool forcePlainLayout() const { return forceplain_; }
202         ///
203         bool allowParagraphCustomization() const { return custompars_; }
204         ///
205         bool isPassThru() const { return passthru_; }
206         ///
207         docstring passThruChars() const { return passthru_chars_; }
208         ///
209         std::string newlineCmd() const { return newline_cmd_; }
210         ///
211         bool parbreakIsNewline() const { return parbreakisnewline_; }
212         ///
213         bool parbreakIgnored() const { return parbreakignored_; }
214         ///
215         bool isNeedProtect() const { return needprotect_; }
216         ///
217         bool needsCProtect() const { return needcprotect_; }
218         /// Protection of some elements such as \ref and \cite
219         /// in \mbox (needed by commands building on soul or ulem)
220         bool isNeedMBoxProtect() const { return needmboxprotect_; }
221         ///
222         bool isFreeSpacing() const { return freespacing_; }
223         ///
224         bool isKeepEmpty() const { return keepempty_; }
225         ///
226         bool forceLTR() const { return forceltr_; }
227         ///
228         bool forceOwnlines() const { return forceownlines_; }
229         ///
230         bool isInToc() const { return intoc_; }
231         ///
232         bool spellcheck() const { return spellcheck_; }
233         ///
234         bool resetsFont() const { return resetsfont_; }
235         ///
236         bool isDisplay() const { return display_; }
237         ///
238         bool forceLocalFontSwitch() const { return forcelocalfontswitch_; }
239         ///
240         docstring const & obsoleted_by() const { return obsoleted_by_; }
241         ///
242         bool addToToc() const { return add_to_toc_; }
243         ///
244         std::string tocType() const { return toc_type_; }
245         ///
246         bool isTocCaption() const { return is_toc_caption_; }
247         ///
248         bool editExternally () const { return edit_external_; }
249 private:
250         ///
251         void makeDefaultCSS() const;
252         ///
253         std::string defaultCSSClass() const;
254         ///
255         void readArgument(Lexer &);
256         ///
257         docstring name_ = from_ascii("undefined");
258         /**
259                 * This is only used (at present) to decide where to put them on the menus.
260                 * Values are 'charstyle', 'custom' (things that by default look like a
261                 * footnote), 'standard'.
262                 */
263         InsetLyXType lyxtype_ = InsetLyXType::STANDARD;
264         ///
265         docstring labelstring_ = from_ascii("UNDEFINED");
266         ///
267         docstring menustring_;
268         ///
269         bool contentaslabel_ = false;
270         ///
271         InsetDecoration decoration_ = InsetDecoration::DEFAULT;
272         ///
273         InsetLaTeXType latextype_ = InsetLaTeXType::NOLATEXTYPE;
274         ///
275         std::string latexname_;
276         ///
277         std::string latexparam_;
278         ///
279         docstring leftdelim_;
280         ///
281         docstring rightdelim_;
282         ///
283         FontInfo font_ = inherit_font;
284         ///
285         FontInfo labelfont_ = sane_font;
286         ///
287         ColorCode bgcolor_ = Color_error;
288         ///
289         docstring counter_;
290         ///
291         docstring preamble_;
292         /// Language dependent macro definitions needed for this inset
293         docstring langpreamble_;
294         /// Language and babel dependent macro definitions needed for this inset
295         docstring babelpreamble_;
296         ///
297         bool fixedwidthpreambleencoding_ = false;
298         ///
299         docstring refprefix_;
300         ///
301         mutable std::string htmltag_;
302         ///
303         mutable std::string htmlattr_;
304         ///
305         std::string htmlinnertag_;
306         ///
307         mutable std::string htmlinnerattr_;
308         ///
309         std::string htmllabel_;
310         ///
311         docstring htmlstyle_;
312         /// Cache for default CSS info for this inset.
313         mutable docstring htmldefaultstyle_;
314         /// Cache for default CSS class.
315         mutable std::string defaultcssclass_;
316         /// Whether to force generation of default CSS even if some is given.
317         /// False by default.
318         bool htmlforcecss_ = false;
319         ///
320         docstring htmlpreamble_;
321         ///
322         bool htmlisblock_ = true;
323         ///
324         std::string docbooktag_;
325         ///
326         mutable std::string docbooktagtype_;
327         ///
328         std::string docbookattr_;
329         ///
330         std::string docbookinnertag_;
331         ///
332         mutable std::string docbookinnertagtype_;
333         ///
334         std::string docbookinnerattr_;
335         ///
336         mutable std::string docbookininfo_;
337         ///
338         bool docbooknotinpara_ = false;
339         ///
340         bool docbookargumentbeforemaintag_ = false;
341     ///
342     bool docbookargumentaftermaintag_ = false;
343         ///
344         bool docbooksection_ = false;
345         ///
346         std::string docbookwrappertag_;
347         ///
348         mutable std::string docbookwrappertagtype_;
349         ///
350         std::string docbookwrapperattr_;
351         ///
352         std::string docbookitemtag_;
353         ///
354         mutable std::string docbookitemtagtype_;
355         ///
356         std::string docbookitemattr_;
357         ///
358         std::string docbookitemwrappertag_;
359         ///
360         mutable std::string docbookitemwrappertagtype_;
361         ///
362         std::string docbookitemwrapperattr_;
363         ///
364         bool docbooknofontinside_ = false;
365         ///
366         bool docbookrenderasimage_ = false;
367         ///
368         std::set<std::string> required_;
369         ///
370         bool multipar_ = true;
371         ///
372         bool custompars_ = true;
373         ///
374         bool forceplain_ = false;
375         ///
376         bool passthru_ = false;
377         ///
378         docstring passthru_chars_;
379         ///
380         std::string newline_cmd_;
381         ///
382         bool parbreakisnewline_ = false;
383         ///
384         bool parbreakignored_ = false;
385         ///
386         bool freespacing_ = false;
387         ///
388         bool keepempty_ = false;
389         ///
390         bool forceltr_ = false;
391         ///
392         bool forceownlines_ = false;
393         ///
394         bool needprotect_ = false;
395         ///
396         bool needcprotect_ = false;
397         ///
398         bool needmboxprotect_ = false;
399         /// should the contents be written to TOC strings?
400         bool intoc_ = false;
401         /// check spelling of this inset?
402         bool spellcheck_ = true;
403         ///
404         bool resetsfont_ = false;
405         ///
406         bool display_ = true;
407         ///
408         bool forcelocalfontswitch_ = false;
409         /** Name of an insetlayout that has replaced this insetlayout.
410             This is used to rename an insetlayout, while keeping backward
411             compatibility
412         */
413         docstring obsoleted_by_;
414         ///
415         Layout::LaTeXArgMap latexargs_;
416         ///
417         Layout::LaTeXArgMap postcommandargs_;
418         ///
419         bool add_to_toc_ = false;
420         ///
421         std::string toc_type_;
422         ///
423         bool is_toc_caption_ = false;
424         ///
425         bool edit_external_ = false;
426 };
427
428 ///
429 InsetLyXType translateLyXType(std::string const & str);
430 InsetDecoration translateDecoration(std::string const & str);
431
432 } // namespace lyx
433
434 #endif