]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
Fix text direction issue for InsetInfo in RTL context
[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         ///
167         bool isFreeSpacing() const { return freespacing_; }
168         ///
169         bool isKeepEmpty() const { return keepempty_; }
170         ///
171         bool forceLTR() const { return forceltr_; }
172         ///
173         bool forceOwnlines() const { return forceownlines_; }
174         ///
175         bool isInToc() const { return intoc_; }
176         ///
177         bool spellcheck() const { return spellcheck_; }
178         ///
179         bool resetsFont() const { return resetsfont_; }
180         ///
181         bool isDisplay() const { return display_; }
182         ///
183         bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
184         ///
185         docstring const & obsoleted_by() const { return obsoleted_by_; }
186         ///
187         bool addToToc() const { return add_to_toc_; }
188         ///
189         std::string tocType() const { return toc_type_; }
190         ///
191         bool isTocCaption() const { return is_toc_caption_; }
192 private:
193         ///
194         void makeDefaultCSS() const;
195         ///
196         std::string defaultCSSClass() const;
197         ///
198         void readArgument(Lexer &);
199         ///
200         docstring name_;
201         /**
202                 * This is only used (at present) to decide where to put them on the menus.
203                 * Values are 'charstyle', 'custom' (things that by default look like a
204                 * footnote), 'element' (docbook), 'standard'.
205                 */
206         InsetLyXType lyxtype_;
207         ///
208         docstring labelstring_;
209         ///
210         bool contentaslabel_;
211         ///
212         InsetDecoration decoration_;
213         ///
214         InsetLaTeXType latextype_;
215         ///
216         std::string latexname_;
217         ///
218         std::string latexparam_;
219         ///
220         docstring leftdelim_;
221         ///
222         docstring rightdelim_;
223         ///
224         FontInfo font_;
225         ///
226         FontInfo labelfont_;
227         ///
228         ColorCode bgcolor_;
229         ///
230         docstring counter_;
231         ///
232         docstring preamble_;
233         /// Language dependent macro definitions needed for this inset
234         docstring langpreamble_;
235         /// Language and babel dependent macro definitions needed for this inset
236         docstring babelpreamble_;
237         ///
238         bool fixedwidthpreambleencoding_;
239         ///
240         docstring refprefix_;
241         ///
242         mutable std::string htmltag_;
243         ///
244         mutable std::string htmlattr_;
245         ///
246         std::string htmlinnertag_;
247         ///
248         mutable std::string htmlinnerattr_;
249         ///
250         std::string htmllabel_;
251         ///
252         docstring htmlstyle_;
253         /// Cache for default CSS info for this inset.
254         mutable docstring htmldefaultstyle_;
255         /// Cache for default CSS class.
256         mutable std::string defaultcssclass_;
257         /// Whether to force generation of default CSS even if some is given.
258         /// False by default.
259         bool htmlforcecss_;
260         ///
261         docstring htmlpreamble_;
262         ///
263         bool htmlisblock_;
264         ///
265         std::set<std::string> requires_;
266         ///
267         bool multipar_;
268         ///
269         bool custompars_;
270         ///
271         bool forceplain_;
272         ///
273         bool passthru_;
274         ///
275         docstring passthru_chars_;
276         ///
277         bool parbreakisnewline_;
278         ///
279         bool freespacing_;
280         ///
281         bool keepempty_;
282         ///
283         bool forceltr_;
284         ///
285         bool forceownlines_;
286         ///
287         bool needprotect_;
288         ///
289         bool needcprotect_;
290         /// should the contents be written to TOC strings?
291         bool intoc_;
292         /// check spelling of this inset?
293         bool spellcheck_;
294         ///
295         bool resetsfont_;
296         ///
297         bool display_;
298         ///
299         bool forcelocalfontswitch_;
300         /** Name of an insetlayout that has replaced this insetlayout.
301             This is used to rename an insetlayout, while keeping backward
302             compatibility
303         */
304         docstring obsoleted_by_;
305         ///
306         Layout::LaTeXArgMap latexargs_;
307         ///
308         Layout::LaTeXArgMap postcommandargs_;
309         ///
310         bool add_to_toc_;
311         ///
312         std::string toc_type_;
313         ///
314         bool is_toc_caption_;
315 };
316
317 ///
318 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
319 InsetLayout::InsetDecoration translateDecoration(std::string const & str);
320
321 } // namespace lyx
322
323 #endif