]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
Fix functions that used functions but did not defined it
[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 TextClass;
28
29 namespace support { class Lexer; }
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_insetlabel); }
59         ///
60         bool read(support::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         bool inheritFont() const { return inheritfont_; }
88         ///
89         FontInfo font() const { return font_; }
90         ///
91         FontInfo labelfont() const { return labelfont_; }
92         ///
93         ColorCode bgcolor() const { return bgcolor_; }
94         ///
95         Layout::LaTeXArgMap const & latexargs() const { return latexargs_; }
96         ///
97         Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
98         /// Returns latexargs() + postcommandargs().
99         /// But note that it returns a *copy*, not a reference, so do not do
100         /// anything like:
101         ///   Layout::LaTeXArgMap::iterator it = args().begin();
102         ///   Layout::LaTeXArgMap::iterator en = args().end();
103         /// Those are iterators for different containers.
104         Layout::LaTeXArgMap args() const;
105         ///
106         int optArgs() const;
107         ///
108         int requiredArgs() const;
109         ///
110         docstring preamble() const { return preamble_; }
111         /// Get language dependent macro definitions needed for this inset
112         docstring const langpreamble() const { return langpreamble_; }
113         /// Get language and babel dependent macro definitions needed for
114         /// this inset
115         docstring const babelpreamble() const { return babelpreamble_; }
116         ///
117         bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
118         ///
119         docstring counter() const { return counter_; }
120         ///
121         docstring refprefix() const { return refprefix_; }
122         /// The tag enclosing all the material in this inset. Default is "span".
123         std::string const & htmltag() const;
124         /// Additional attributes for inclusion with the start tag. Default (if
125         /// a tag is provided) is: class="name".
126         std::string const & htmlattr() const { return htmlattr_; }
127         ///
128         std::string const & htmlclass() const;
129         ///
130         std::string const & htmlGetAttrString() const;
131         /// Tag for individual paragraphs in the inset. Default is none.
132         std::string const & htmlinnertag() const { return htmlinnertag_; }
133         /// Attributes for that tag. Default (if a tag is provided) is:
134         /// class="name_inner".
135         std::string const & htmlinnerattr() const;
136         /// A label for this environment, possibly including a reference
137         /// to a counter. E.g., for footnote, it might be:
138         ///    \arabic{footnote}
139         /// No default.
140         /// FIXME Could we get this from the layout?
141         std::string const & htmllabel() const { return htmllabel_; }
142         ///
143         inline std::string htmllabeltag() const { return "span"; }
144         ///
145         std::string htmllabelattr() const
146                 { return "class=\"" + defaultCSSClass() + "_label\""; }
147         /// CSS associated with this inset.
148         docstring htmlstyle() const;
149         /// Additional material for the header.
150         docstring htmlpreamble() const { return htmlpreamble_; }
151         /// Whether this inset represents a "block" of material, i.e., a set
152         /// of paragraphs of its own (true), or should be run into the previous
153         /// paragraph (false). Examples:
154         ///   For branches, this is false.
155         ///   For footnotes, this is true.
156         /// Defaults to true.
157         bool htmlisblock() const { return htmlisblock_; }
158         ///
159         std::string docbooktag() const { return docbooktag_; }
160         ///
161         std::string docbooktagtype() const;
162         ///
163         std::string docbookattr() const { return docbookattr_; }
164         ///
165         std::string docbookinnertag() const { return docbookinnertag_; }
166         ///
167         std::string docbookinnertagtype() const;
168         ///
169         std::string docbookinnerattr() const { return docbookinnerattr_; }
170         ///
171         std::string const & docbookininfo() const;
172         ///
173         bool docbooksection() const { return docbooksection_; }
174         ///
175         bool docbooknotinpara() const { return docbooknotinpara_; }
176         ///
177         bool docbookargumentbeforemaintag() const { return docbookargumentbeforemaintag_; }
178         ///
179         bool docbookargumentaftermaintag() const { return docbookargumentaftermaintag_; }
180         ///
181         std::string docbookwrappertag() const { return docbookwrappertag_; }
182         ///
183         std::string docbookwrappertagtype() const;
184         ///
185         std::string docbookwrapperattr() const { return docbookwrapperattr_; }
186         ///
187         std::string docbookitemwrappertag() const { return docbookitemwrappertag_; }
188         ///
189         std::string docbookitemwrappertagtype() const;
190         ///
191         std::string docbookitemwrapperattr() const { return docbookitemwrapperattr_; }
192         ///
193         std::string docbookitemtag() const { return docbookitemtag_; }
194         ///
195         std::string docbookitemtagtype() const;
196         ///
197         std::string docbookitemattr() const { return docbookitemattr_; }
198         ///
199         bool docbooknofontinside() const { return docbooknofontinside_; }
200         ///
201         bool docbookrenderasimage() const { return docbookrenderasimage_; }
202         ///
203         std::set<std::string> const & required() const { return required_; }
204         ///
205         bool requiresFeature(std::string const f) const;
206         ///
207         bool isMultiPar() const { return multipar_; }
208         ///
209         bool forcePlainLayout() const { return forceplain_; }
210         ///
211         bool allowParagraphCustomization() const { return custompars_; }
212         ///
213         bool isPassThru() const { return passthru_; }
214         ///
215         docstring passThruChars() const { return passthru_chars_; }
216         ///
217         docstring noPassThruChars() const { return no_passthru_chars_; }
218         ///
219         std::string newlineCmd() const { return newline_cmd_; }
220         ///
221         bool parbreakIsNewline() const { return parbreakisnewline_; }
222         ///
223         bool parbreakIgnored() const { return parbreakignored_; }
224         ///
225         bool isNeedProtect() const { return needprotect_; }
226         ///
227         bool needsCProtect() const { return needcprotect_; }
228         ///
229         bool noCProtect() const { return nocprotect_; }
230         /// Protection of some elements such as \ref and \cite
231         /// in \mbox (needed by commands building on soul or ulem)
232         bool isNeedMBoxProtect() const { return needmboxprotect_; }
233         ///
234         bool isFreeSpacing() const { return freespacing_; }
235         ///
236         bool isKeepEmpty() const { return keepempty_; }
237         ///
238         bool forceLTR() const { return forceltr_; }
239         ///
240         bool forceOwnlines() const { return forceownlines_; }
241         ///
242         bool isInToc() const { return intoc_; }
243         ///
244         bool spellcheck() const { return spellcheck_; }
245         ///
246         bool resetsFont() const { return resetsfont_; }
247         ///
248         bool isDisplay() const { return display_; }
249         ///
250         bool forceLocalFontSwitch() const { return forcelocalfontswitch_; }
251         ///
252         docstring const & obsoleted_by() const { return obsoleted_by_; }
253         ///
254         bool addToToc() const { return add_to_toc_; }
255         ///
256         std::string tocType() const { return toc_type_; }
257         ///
258         bool isTocCaption() const { return is_toc_caption_; }
259         ///
260         bool editExternally () const { return edit_external_; }
261         ///
262         std::set<docstring> const & allowedInInsets() const { return allowed_in_insets_; }
263         ///
264         std::set<docstring> const & allowedInLayouts() const { return allowed_in_layouts_; }
265         ///
266         int allowedOccurrences() const { return allowed_occurrences_; }
267         ///
268         bool allowedOccurrencesPerItem() const { return allowed_occurrences_per_item_; }
269 private:
270         ///
271         void makeDefaultCSS() const;
272         ///
273         std::string defaultCSSClass() const;
274         ///
275         void readArgument(support::Lexer &);
276         ///
277         docstring name_ = from_ascii("undefined");
278         /**
279                 * This is only used (at present) to decide where to put them on the menus.
280                 * Values are 'charstyle', 'custom' (things that by default look like a
281                 * footnote), 'standard'.
282                 */
283         InsetLyXType lyxtype_ = InsetLyXType::STANDARD;
284         ///
285         docstring labelstring_ = from_ascii("UNDEFINED");
286         ///
287         docstring menustring_;
288         ///
289         bool contentaslabel_ = false;
290         ///
291         InsetDecoration decoration_ = InsetDecoration::DEFAULT;
292         ///
293         InsetLaTeXType latextype_ = InsetLaTeXType::NOLATEXTYPE;
294         ///
295         std::string latexname_;
296         ///
297         std::string latexparam_;
298         ///
299         docstring leftdelim_;
300         ///
301         docstring rightdelim_;
302         ///
303         FontInfo font_ = inherit_font;
304         ///
305         FontInfo labelfont_ = sane_font;
306         ///
307         bool inheritfont_ = true;
308         ///
309         ColorCode bgcolor_ = Color_error;
310         ///
311         docstring counter_;
312         ///
313         docstring preamble_;
314         /// Language dependent macro definitions needed for this inset
315         docstring langpreamble_;
316         /// Language and babel dependent macro definitions needed for this inset
317         docstring babelpreamble_;
318         ///
319         bool fixedwidthpreambleencoding_ = false;
320         ///
321         docstring refprefix_;
322         ///
323         mutable std::string htmltag_;
324         ///
325         mutable std::string htmlattr_;
326         ///
327         mutable std::string htmlclass_;
328         /// cache
329         mutable std::string htmlfullattrs_;
330         ///
331         std::string htmlinnertag_;
332         ///
333         mutable std::string htmlinnerattr_;
334         ///
335         std::string htmllabel_;
336         ///
337         docstring htmlstyle_;
338         /// Cache for default CSS info for this inset.
339         mutable docstring htmldefaultstyle_;
340         /// Cache for default CSS class.
341         mutable std::string defaultcssclass_;
342         /// Whether to force generation of default CSS even if some is given.
343         /// False by default.
344         bool htmlforcecss_ = false;
345         ///
346         docstring htmlpreamble_;
347         ///
348         bool htmlisblock_ = true;
349         ///
350         std::string docbooktag_;
351         ///
352         mutable std::string docbooktagtype_;
353         ///
354         std::string docbookattr_;
355         ///
356         std::string docbookinnertag_;
357         ///
358         mutable std::string docbookinnertagtype_;
359         ///
360         std::string docbookinnerattr_;
361         ///
362         mutable std::string docbookininfo_;
363         ///
364         bool docbooknotinpara_ = false;
365         ///
366         bool docbookargumentbeforemaintag_ = false;
367         ///
368         bool docbookargumentaftermaintag_ = false;
369         ///
370         bool docbooksection_ = false;
371         ///
372         std::string docbookwrappertag_;
373         ///
374         mutable std::string docbookwrappertagtype_;
375         ///
376         std::string docbookwrapperattr_;
377         ///
378         std::string docbookitemtag_;
379         ///
380         mutable std::string docbookitemtagtype_;
381         ///
382         std::string docbookitemattr_;
383         ///
384         std::string docbookitemwrappertag_;
385         ///
386         mutable std::string docbookitemwrappertagtype_;
387         ///
388         std::string docbookitemwrapperattr_;
389         ///
390         bool docbooknofontinside_ = false;
391         ///
392         bool docbookrenderasimage_ = false;
393         ///
394         std::set<std::string> required_;
395         ///
396         bool multipar_ = true;
397         ///
398         bool custompars_ = true;
399         ///
400         bool forceplain_ = false;
401         ///
402         bool passthru_ = false;
403         ///
404         docstring passthru_chars_;
405         ///
406         docstring no_passthru_chars_;
407         ///
408         std::string newline_cmd_;
409         ///
410         bool parbreakisnewline_ = false;
411         ///
412         bool parbreakignored_ = false;
413         ///
414         bool freespacing_ = false;
415         ///
416         bool keepempty_ = false;
417         ///
418         bool forceltr_ = false;
419         ///
420         bool forceownlines_ = false;
421         ///
422         bool needprotect_ = false;
423         ///
424         bool needcprotect_ = false;
425         ///
426         bool nocprotect_ = false;
427         ///
428         bool needmboxprotect_ = false;
429         /// should the contents be written to TOC strings?
430         bool intoc_ = false;
431         /// check spelling of this inset?
432         bool spellcheck_ = true;
433         ///
434         bool resetsfont_ = false;
435         ///
436         bool display_ = true;
437         ///
438         bool forcelocalfontswitch_ = false;
439         /** Name of an insetlayout that has replaced this insetlayout.
440             This is used to rename an insetlayout, while keeping backward
441             compatibility
442         */
443         docstring obsoleted_by_;
444         ///
445         Layout::LaTeXArgMap latexargs_;
446         ///
447         Layout::LaTeXArgMap postcommandargs_;
448         ///
449         bool add_to_toc_ = false;
450         ///
451         std::string toc_type_;
452         ///
453         bool is_toc_caption_ = false;
454         ///
455         bool edit_external_ = false;
456         /// Insets that can hold insets with this InsetLayout
457         std::set<docstring> allowed_in_insets_;
458         /// Layouts that can hold insets with this InsetLayout
459         std::set<docstring> allowed_in_layouts_;
460         ///
461         int allowed_occurrences_ = -1;
462         ///
463         bool allowed_occurrences_per_item_ = false;
464 };
465
466 ///
467 InsetLyXType translateLyXType(std::string const & str);
468 InsetDecoration translateDecoration(std::string const & str);
469
470 } // namespace lyx
471
472 #endif