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