4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Martin Vermeer
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSET_LAYOUT_H
14 #define INSET_LAYOUT_H
16 #include "ColorCode.h"
20 #include "support/docstring.h"
36 enum InsetDecoration {
59 bool read(Lexer & lexrc, TextClass const & tclass,
60 bool validating = false);
62 docstring name() const { return name_; }
64 void setName(docstring const & n) { name_ = n; }
66 InsetLyXType lyxtype() const { return lyxtype_; }
68 docstring labelstring() const { return labelstring_; }
70 docstring menustring() const { return menustring_; }
72 bool contentaslabel() const { return contentaslabel_; }
74 InsetDecoration decoration() const { return decoration_; }
76 InsetLaTeXType latextype() const { return latextype_; }
78 std::string latexname() const { return latexname_; }
80 std::string latexparam() const { return latexparam_; }
82 docstring leftdelim() const { return leftdelim_; }
84 docstring rightdelim() const { return rightdelim_; }
86 FontInfo font() const { return font_; }
88 FontInfo labelfont() const { return labelfont_; }
90 ColorCode bgcolor() const { return bgcolor_; }
92 Layout::LaTeXArgMap const & latexargs() const { return latexargs_; }
94 Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
95 /// Returns latexargs() + postcommandargs().
96 /// But note that it returns a *copy*, not a reference, so do not do
98 /// Layout::LaTeXArgMap::iterator it = args().begin();
99 /// Layout::LaTeXArgMap::iterator en = args().end();
100 /// Those are iterators for different containers.
101 Layout::LaTeXArgMap args() const;
103 unsigned int optArgs() const;
105 unsigned int requiredArgs() const;
107 docstring preamble() const { return preamble_; }
108 /// Get language dependent macro definitions needed for this inset
109 docstring const langpreamble() const { return langpreamble_; }
110 /// Get language and babel dependent macro definitions needed for
112 docstring const babelpreamble() const { return babelpreamble_; }
114 bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
116 docstring counter() const { return counter_; }
118 docstring refprefix() const { return refprefix_; }
119 /// The tag enclosing all the material in this inset. Default is "span".
120 std::string const & htmltag() const;
121 /// Additional attributes for inclusion with the start tag. Default (if
122 /// a tag is provided) is: class="name".
123 std::string const & htmlattr() const;
124 /// Tag for individual paragraphs in the inset. Default is none.
125 std::string const & htmlinnertag() const { return htmlinnertag_; }
126 /// Attributes for that tag. Default (if a tag is provided) is:
127 /// class="name_inner".
128 std::string const & htmlinnerattr() const;
129 /// A label for this environment, possibly including a reference
130 /// to a counter. E.g., for footnote, it might be:
131 /// \arabic{footnote}
133 /// FIXME Could we get this from the layout?
134 std::string const & htmllabel() const { return htmllabel_; }
136 inline std::string htmllabeltag() const { return "span"; }
138 std::string htmllabelattr() const
139 { return "class=\"" + defaultCSSClass() + "_label\""; }
140 /// CSS associated with this inset.
141 docstring htmlstyle() const;
142 /// Additional material for the header.
143 docstring htmlpreamble() const { return htmlpreamble_; }
144 /// Whether this inset represents a "block" of material, i.e., a set
145 /// of paragraphs of its own (true), or should be run into the previous
146 /// paragraph (false). Examples:
147 /// For branches, this is false.
148 /// For footnotes, this is true.
149 /// Defaults to true.
150 bool htmlisblock() const { return htmlisblock_; }
152 std::set<std::string> required() const { return required_; }
154 bool isMultiPar() const { return multipar_; }
156 bool forcePlainLayout() const { return forceplain_; }
158 bool allowParagraphCustomization() const { return custompars_; }
160 bool isPassThru() const { return passthru_; }
162 docstring passThruChars() const { return passthru_chars_; }
164 std::string newlineCmd() const { return newline_cmd_; }
166 bool parbreakIsNewline() const { return parbreakisnewline_; }
168 bool parbreakIgnored() const { return parbreakignored_; }
170 bool isNeedProtect() const { return needprotect_; }
172 bool needsCProtect() const { return needcprotect_; }
173 /// Protection of some elements such as \ref and \cite
174 /// in \mbox (needed by commands building on soul or ulem)
175 bool isNeedMBoxProtect() const { return needmboxprotect_; }
177 bool isFreeSpacing() const { return freespacing_; }
179 bool isKeepEmpty() const { return keepempty_; }
181 bool forceLTR() const { return forceltr_; }
183 bool forceOwnlines() const { return forceownlines_; }
185 bool isInToc() const { return intoc_; }
187 bool spellcheck() const { return spellcheck_; }
189 bool resetsFont() const { return resetsfont_; }
191 bool isDisplay() const { return display_; }
193 bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
195 docstring const & obsoleted_by() const { return obsoleted_by_; }
197 bool addToToc() const { return add_to_toc_; }
199 std::string tocType() const { return toc_type_; }
201 bool isTocCaption() const { return is_toc_caption_; }
203 bool editExternally () const { return edit_external_; }
206 void makeDefaultCSS() const;
208 std::string defaultCSSClass() const;
210 void readArgument(Lexer &);
214 * This is only used (at present) to decide where to put them on the menus.
215 * Values are 'charstyle', 'custom' (things that by default look like a
216 * footnote), 'element' (docbook), 'standard'.
218 InsetLyXType lyxtype_;
220 docstring labelstring_;
222 docstring menustring_;
224 bool contentaslabel_;
226 InsetDecoration decoration_;
228 InsetLaTeXType latextype_;
230 std::string latexname_;
232 std::string latexparam_;
234 docstring leftdelim_;
236 docstring rightdelim_;
247 /// Language dependent macro definitions needed for this inset
248 docstring langpreamble_;
249 /// Language and babel dependent macro definitions needed for this inset
250 docstring babelpreamble_;
252 bool fixedwidthpreambleencoding_;
254 docstring refprefix_;
256 mutable std::string htmltag_;
258 mutable std::string htmlattr_;
260 std::string htmlinnertag_;
262 mutable std::string htmlinnerattr_;
264 std::string htmllabel_;
266 docstring htmlstyle_;
267 /// Cache for default CSS info for this inset.
268 mutable docstring htmldefaultstyle_;
269 /// Cache for default CSS class.
270 mutable std::string defaultcssclass_;
271 /// Whether to force generation of default CSS even if some is given.
272 /// False by default.
275 docstring htmlpreamble_;
279 std::set<std::string> required_;
289 docstring passthru_chars_;
291 std::string newline_cmd_;
293 bool parbreakisnewline_;
295 bool parbreakignored_;
309 bool needmboxprotect_;
310 /// should the contents be written to TOC strings?
312 /// check spelling of this inset?
319 bool forcelocalfontswitch_;
320 /** Name of an insetlayout that has replaced this insetlayout.
321 This is used to rename an insetlayout, while keeping backward
324 docstring obsoleted_by_;
326 Layout::LaTeXArgMap latexargs_;
328 Layout::LaTeXArgMap postcommandargs_;
332 std::string toc_type_;
334 bool is_toc_caption_;
340 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
341 InsetLayout::InsetDecoration translateDecoration(std::string const & str);