]> git.lyx.org Git - features.git/blob - src/insets/InsetLayout.h
Add NewlineCmd InsetLayout and Argument option
[features.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();
35         ///
36         enum InsetDecoration {
37                 CLASSIC,
38                 MINIMALISTIC,
39                 CONGLOMERATE,
40                 DEFAULT
41         };
42         ///
43         enum InsetLyXType {
44                 NOLYXTYPE,
45                 CHARSTYLE,
46                 CUSTOM,
47                 ELEMENT,
48                 END,
49                 STANDARD
50         };
51         ///
52         enum InsetLaTeXType {
53                 NOLATEXTYPE,
54                 COMMAND,
55                 ENVIRONMENT,
56                 ILT_ERROR
57         };
58         ///
59         bool read(Lexer & lexrc, TextClass const & tclass);
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         unsigned int optArgs() const;
103         ///
104         unsigned 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::set<std::string> requires() const { return requires_; }
152         ///
153         bool isMultiPar() const { return multipar_; }
154         ///
155         bool forcePlainLayout() const { return forceplain_; }
156         ///
157         bool allowParagraphCustomization() const { return custompars_; }
158         ///
159         bool isPassThru() const { return passthru_; }
160         ///
161         docstring passThruChars() const { return passthru_chars_; }
162         ///
163         std::string newlineCmd() const { return newline_cmd_; }
164         ///
165         bool parbreakIsNewline() const { return parbreakisnewline_; }
166         ///
167         bool isNeedProtect() const { return needprotect_; }
168         ///
169         bool needsCProtect() const { return needcprotect_; }
170         /// Protection of some elements such as \ref and \cite
171         /// in \mbox (needed by commands building on soul or ulem)
172         bool isNeedMBoxProtect() const { return needmboxprotect_; }
173         ///
174         bool isFreeSpacing() const { return freespacing_; }
175         ///
176         bool isKeepEmpty() const { return keepempty_; }
177         ///
178         bool forceLTR() const { return forceltr_; }
179         ///
180         bool forceOwnlines() const { return forceownlines_; }
181         ///
182         bool isInToc() const { return intoc_; }
183         ///
184         bool spellcheck() const { return spellcheck_; }
185         ///
186         bool resetsFont() const { return resetsfont_; }
187         ///
188         bool isDisplay() const { return display_; }
189         ///
190         bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
191         ///
192         docstring const & obsoleted_by() const { return obsoleted_by_; }
193         ///
194         bool addToToc() const { return add_to_toc_; }
195         ///
196         std::string tocType() const { return toc_type_; }
197         ///
198         bool isTocCaption() const { return is_toc_caption_; }
199         ///
200         bool editExternally () const { return edit_external_; }
201 private:
202         ///
203         void makeDefaultCSS() const;
204         ///
205         std::string defaultCSSClass() const;
206         ///
207         void readArgument(Lexer &);
208         ///
209         docstring name_;
210         /**
211                 * This is only used (at present) to decide where to put them on the menus.
212                 * Values are 'charstyle', 'custom' (things that by default look like a
213                 * footnote), 'element' (docbook), 'standard'.
214                 */
215         InsetLyXType lyxtype_;
216         ///
217         docstring labelstring_;
218         ///
219         docstring menustring_;
220         ///
221         bool contentaslabel_;
222         ///
223         InsetDecoration decoration_;
224         ///
225         InsetLaTeXType latextype_;
226         ///
227         std::string latexname_;
228         ///
229         std::string latexparam_;
230         ///
231         docstring leftdelim_;
232         ///
233         docstring rightdelim_;
234         ///
235         FontInfo font_;
236         ///
237         FontInfo labelfont_;
238         ///
239         ColorCode bgcolor_;
240         ///
241         docstring counter_;
242         ///
243         docstring preamble_;
244         /// Language dependent macro definitions needed for this inset
245         docstring langpreamble_;
246         /// Language and babel dependent macro definitions needed for this inset
247         docstring babelpreamble_;
248         ///
249         bool fixedwidthpreambleencoding_;
250         ///
251         docstring refprefix_;
252         ///
253         mutable std::string htmltag_;
254         ///
255         mutable std::string htmlattr_;
256         ///
257         std::string htmlinnertag_;
258         ///
259         mutable std::string htmlinnerattr_;
260         ///
261         std::string htmllabel_;
262         ///
263         docstring htmlstyle_;
264         /// Cache for default CSS info for this inset.
265         mutable docstring htmldefaultstyle_;
266         /// Cache for default CSS class.
267         mutable std::string defaultcssclass_;
268         /// Whether to force generation of default CSS even if some is given.
269         /// False by default.
270         bool htmlforcecss_;
271         ///
272         docstring htmlpreamble_;
273         ///
274         bool htmlisblock_;
275         ///
276         std::set<std::string> requires_;
277         ///
278         bool multipar_;
279         ///
280         bool custompars_;
281         ///
282         bool forceplain_;
283         ///
284         bool passthru_;
285         ///
286         docstring passthru_chars_;
287         ///
288         std::string newline_cmd_;
289         ///
290         bool parbreakisnewline_;
291         ///
292         bool freespacing_;
293         ///
294         bool keepempty_;
295         ///
296         bool forceltr_;
297         ///
298         bool forceownlines_;
299         ///
300         bool needprotect_;
301         ///
302         bool needcprotect_;
303         ///
304         bool needmboxprotect_;
305         /// should the contents be written to TOC strings?
306         bool intoc_;
307         /// check spelling of this inset?
308         bool spellcheck_;
309         ///
310         bool resetsfont_;
311         ///
312         bool display_;
313         ///
314         bool forcelocalfontswitch_;
315         /** Name of an insetlayout that has replaced this insetlayout.
316             This is used to rename an insetlayout, while keeping backward
317             compatibility
318         */
319         docstring obsoleted_by_;
320         ///
321         Layout::LaTeXArgMap latexargs_;
322         ///
323         Layout::LaTeXArgMap postcommandargs_;
324         ///
325         bool add_to_toc_;
326         ///
327         std::string toc_type_;
328         ///
329         bool is_toc_caption_;
330         ///
331         bool edit_external_;
332 };
333
334 ///
335 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
336 InsetLayout::InsetDecoration translateDecoration(std::string const & str);
337
338 } // namespace lyx
339
340 #endif