]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
de.po
[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();
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         bool contentaslabel() const { return contentaslabel_; }
70         ///
71         InsetDecoration decoration() const { return decoration_; }
72         ///
73         InsetLaTeXType latextype() const { return latextype_; }
74         ///
75         std::string latexname() const { return latexname_; }
76         ///
77         std::string latexparam() const { return latexparam_; }
78         ///
79         docstring leftdelim() const { return leftdelim_; }
80         ///
81         docstring rightdelim() const { return rightdelim_; }
82         ///
83         FontInfo font() const { return font_; }
84         ///
85         FontInfo labelfont() const { return labelfont_; }
86         ///
87         ColorCode bgcolor() const { return bgcolor_; }
88         ///
89         Layout::LaTeXArgMap const & latexargs() const { return latexargs_; }
90         ///
91         Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
92         /// Returns latexargs() + postcommandargs().
93         /// But note that it returns a *copy*, not a reference, so do not do
94         /// anything like:
95         ///   Layout::LaTeXArgMap::iterator it = args().begin();
96         ///   Layout::LaTeXArgMap::iterator en = args().end();
97         /// Those are iterators for different containers.
98         Layout::LaTeXArgMap args() const;
99         ///
100         unsigned int optArgs() const;
101         ///
102         unsigned int requiredArgs() const;
103         ///
104         docstring preamble() const { return preamble_; }
105         /// Get language dependent macro definitions needed for this inset
106         docstring const langpreamble() const { return langpreamble_; }
107         /// Get language and babel dependent macro definitions needed for
108         /// this inset
109         docstring const babelpreamble() const { return babelpreamble_; }
110         ///
111         bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
112         ///
113         docstring counter() const { return counter_; }
114         ///
115         docstring refprefix() const { return refprefix_; }
116         /// The tag enclosing all the material in this inset. Default is "span".
117         std::string const & htmltag() const;
118         /// Additional attributes for inclusion with the start tag. Default (if
119         /// a tag is provided) is: class="name".
120         std::string const & htmlattr() const;
121         /// Tag for individual paragraphs in the inset. Default is none.
122         std::string const & htmlinnertag() const { return htmlinnertag_; }
123         /// Attributes for that tag. Default (if a tag is provided) is:
124         /// class="name_inner".
125         std::string const & htmlinnerattr() const;
126         /// A label for this environment, possibly including a reference
127         /// to a counter. E.g., for footnote, it might be:
128         ///    \arabic{footnote}
129         /// No default.
130         /// FIXME Could we get this from the layout?
131         std::string const & htmllabel() const { return htmllabel_; }
132         ///
133         inline std::string htmllabeltag() const { return "span"; }
134         ///
135         std::string htmllabelattr() const
136                 { return "class=\"" + defaultCSSClass() + "_label\""; }
137         /// CSS associated with this inset.
138         docstring htmlstyle() const;
139         /// Additional material for the header.
140         docstring htmlpreamble() const { return htmlpreamble_; }
141         /// Whether this inset represents a "block" of material, i.e., a set
142         /// of paragraphs of its own (true), or should be run into the previous
143         /// paragraph (false). Examples:
144         ///   For branches, this is false.
145         ///   For footnotes, this is true.
146         /// Defaults to true.
147         bool htmlisblock() const { return htmlisblock_; }
148         ///
149         std::set<std::string> requires() const { return requires_; }
150         ///
151         bool isMultiPar() const { return multipar_; }
152         ///
153         bool forcePlainLayout() const { return forceplain_; }
154         ///
155         bool allowParagraphCustomization() const { return custompars_; }
156         ///
157         bool isPassThru() const { return passthru_; }
158         ///
159         docstring passThruChars() const { return passthru_chars_; }
160         ///
161         bool parbreakIsNewline() const { return parbreakisnewline_; }
162         ///
163         bool isNeedProtect() const { return needprotect_; }
164         ///
165         bool needsCProtect() const { return needcprotect_; }
166         /// Protection of some elements such as \ref and \cite
167         /// in \mbox (needed by commands building on soul or ulem)
168         bool isNeedMBoxProtect() const { return needmboxprotect_; }
169         ///
170         bool isFreeSpacing() const { return freespacing_; }
171         ///
172         bool isKeepEmpty() const { return keepempty_; }
173         ///
174         bool forceLTR() const { return forceltr_; }
175         ///
176         bool forceOwnlines() const { return forceownlines_; }
177         ///
178         bool isInToc() const { return intoc_; }
179         ///
180         bool spellcheck() const { return spellcheck_; }
181         ///
182         bool resetsFont() const { return resetsfont_; }
183         ///
184         bool isDisplay() const { return display_; }
185         ///
186         bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
187         ///
188         docstring const & obsoleted_by() const { return obsoleted_by_; }
189         ///
190         bool addToToc() const { return add_to_toc_; }
191         ///
192         std::string tocType() const { return toc_type_; }
193         ///
194         bool isTocCaption() const { return is_toc_caption_; }
195         ///
196         bool editExternally () const { return edit_external_; }
197 private:
198         ///
199         void makeDefaultCSS() const;
200         ///
201         std::string defaultCSSClass() const;
202         ///
203         void readArgument(Lexer &);
204         ///
205         docstring name_;
206         /**
207                 * This is only used (at present) to decide where to put them on the menus.
208                 * Values are 'charstyle', 'custom' (things that by default look like a
209                 * footnote), 'element' (docbook), 'standard'.
210                 */
211         InsetLyXType lyxtype_;
212         ///
213         docstring labelstring_;
214         ///
215         bool contentaslabel_;
216         ///
217         InsetDecoration decoration_;
218         ///
219         InsetLaTeXType latextype_;
220         ///
221         std::string latexname_;
222         ///
223         std::string latexparam_;
224         ///
225         docstring leftdelim_;
226         ///
227         docstring rightdelim_;
228         ///
229         FontInfo font_;
230         ///
231         FontInfo labelfont_;
232         ///
233         ColorCode bgcolor_;
234         ///
235         docstring counter_;
236         ///
237         docstring preamble_;
238         /// Language dependent macro definitions needed for this inset
239         docstring langpreamble_;
240         /// Language and babel dependent macro definitions needed for this inset
241         docstring babelpreamble_;
242         ///
243         bool fixedwidthpreambleencoding_;
244         ///
245         docstring refprefix_;
246         ///
247         mutable std::string htmltag_;
248         ///
249         mutable std::string htmlattr_;
250         ///
251         std::string htmlinnertag_;
252         ///
253         mutable std::string htmlinnerattr_;
254         ///
255         std::string htmllabel_;
256         ///
257         docstring htmlstyle_;
258         /// Cache for default CSS info for this inset.
259         mutable docstring htmldefaultstyle_;
260         /// Cache for default CSS class.
261         mutable std::string defaultcssclass_;
262         /// Whether to force generation of default CSS even if some is given.
263         /// False by default.
264         bool htmlforcecss_;
265         ///
266         docstring htmlpreamble_;
267         ///
268         bool htmlisblock_;
269         ///
270         std::set<std::string> requires_;
271         ///
272         bool multipar_;
273         ///
274         bool custompars_;
275         ///
276         bool forceplain_;
277         ///
278         bool passthru_;
279         ///
280         docstring passthru_chars_;
281         ///
282         bool parbreakisnewline_;
283         ///
284         bool freespacing_;
285         ///
286         bool keepempty_;
287         ///
288         bool forceltr_;
289         ///
290         bool forceownlines_;
291         ///
292         bool needprotect_;
293         ///
294         bool needcprotect_;
295         ///
296         bool needmboxprotect_;
297         /// should the contents be written to TOC strings?
298         bool intoc_;
299         /// check spelling of this inset?
300         bool spellcheck_;
301         ///
302         bool resetsfont_;
303         ///
304         bool display_;
305         ///
306         bool forcelocalfontswitch_;
307         /** Name of an insetlayout that has replaced this insetlayout.
308             This is used to rename an insetlayout, while keeping backward
309             compatibility
310         */
311         docstring obsoleted_by_;
312         ///
313         Layout::LaTeXArgMap latexargs_;
314         ///
315         Layout::LaTeXArgMap postcommandargs_;
316         ///
317         bool add_to_toc_;
318         ///
319         std::string toc_type_;
320         ///
321         bool is_toc_caption_;
322         ///
323         bool edit_external_;
324 };
325
326 ///
327 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
328 InsetLayout::InsetDecoration translateDecoration(std::string const & str);
329
330 } // namespace lyx
331
332 #endif