4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Martin Vermeer
8 * \author Richard Kimberly Heck
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"
31 enum class InsetDecoration : int {
38 enum class InsetLyXType : int {
46 enum class InsetLaTeXType : int {
58 InsetLayout() { labelfont_.setColor(Color_error); }
60 bool read(Lexer & lexrc, TextClass const & tclass,
61 bool validating = false);
63 docstring name() const { return name_; }
65 void setName(docstring const & n) { name_ = n; }
67 InsetLyXType lyxtype() const { return lyxtype_; }
69 docstring labelstring() const { return labelstring_; }
71 docstring menustring() const { return menustring_; }
73 bool contentaslabel() const { return contentaslabel_; }
75 InsetDecoration decoration() const { return decoration_; }
77 InsetLaTeXType latextype() const { return latextype_; }
79 std::string latexname() const { return latexname_; }
81 std::string latexparam() const { return latexparam_; }
83 docstring leftdelim() const { return leftdelim_; }
85 docstring rightdelim() const { return rightdelim_; }
87 FontInfo font() const { return font_; }
89 FontInfo labelfont() const { return labelfont_; }
91 ColorCode bgcolor() const { return bgcolor_; }
93 Layout::LaTeXArgMap const & latexargs() const { return latexargs_; }
95 Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
96 /// Returns latexargs() + postcommandargs().
97 /// But note that it returns a *copy*, not a reference, so do not do
99 /// Layout::LaTeXArgMap::iterator it = args().begin();
100 /// Layout::LaTeXArgMap::iterator en = args().end();
101 /// Those are iterators for different containers.
102 Layout::LaTeXArgMap args() const;
106 int requiredArgs() const;
108 docstring preamble() const { return preamble_; }
109 /// Get language dependent macro definitions needed for this inset
110 docstring const langpreamble() const { return langpreamble_; }
111 /// Get language and babel dependent macro definitions needed for
113 docstring const babelpreamble() const { return babelpreamble_; }
115 bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
117 docstring counter() const { return counter_; }
119 docstring refprefix() const { return refprefix_; }
120 /// The tag enclosing all the material in this inset. Default is "span".
121 std::string const & htmltag() const;
122 /// Additional attributes for inclusion with the start tag. Default (if
123 /// a tag is provided) is: class="name".
124 std::string const & htmlattr() const;
125 /// Tag for individual paragraphs in the inset. Default is none.
126 std::string const & htmlinnertag() const { return htmlinnertag_; }
127 /// Attributes for that tag. Default (if a tag is provided) is:
128 /// class="name_inner".
129 std::string const & htmlinnerattr() const;
130 /// A label for this environment, possibly including a reference
131 /// to a counter. E.g., for footnote, it might be:
132 /// \arabic{footnote}
134 /// FIXME Could we get this from the layout?
135 std::string const & htmllabel() const { return htmllabel_; }
137 inline std::string htmllabeltag() const { return "span"; }
139 std::string htmllabelattr() const
140 { return "class=\"" + defaultCSSClass() + "_label\""; }
141 /// CSS associated with this inset.
142 docstring htmlstyle() const;
143 /// Additional material for the header.
144 docstring htmlpreamble() const { return htmlpreamble_; }
145 /// Whether this inset represents a "block" of material, i.e., a set
146 /// of paragraphs of its own (true), or should be run into the previous
147 /// paragraph (false). Examples:
148 /// For branches, this is false.
149 /// For footnotes, this is true.
150 /// Defaults to true.
151 bool htmlisblock() const { return htmlisblock_; }
153 std::string docbooktag() const { return docbooktag_; }
155 std::string docbooktagtype() const;
157 std::string docbookattr() const { return docbookattr_; }
159 std::string const & docbookininfo() const;
161 bool docbooksection() const { return docbooksection_; }
163 bool docbooknotinpara() const { return docbooknotinpara_; }
165 bool docbookargumentbeforemaintag() const { return docbookargumentbeforemaintag_; }
167 std::string docbookwrappertag() const { return docbookwrappertag_; }
169 std::string docbookwrappertagtype() const;
171 std::string docbookwrapperattr() const { return docbookwrapperattr_; }
173 std::string docbookitemwrappertag() const { return docbookitemwrappertag_; }
175 std::string docbookitemwrappertagtype() const;
177 std::string docbookitemwrapperattr() const { return docbookitemwrapperattr_; }
179 std::string docbookitemtag() const { return docbookitemtag_; }
181 std::string docbookitemtagtype() const;
183 std::string docbookitemattr() const { return docbookitemattr_; }
185 std::set<std::string> required() const { return required_; }
187 bool isMultiPar() const { return multipar_; }
189 bool forcePlainLayout() const { return forceplain_; }
191 bool allowParagraphCustomization() const { return custompars_; }
193 bool isPassThru() const { return passthru_; }
195 docstring passThruChars() const { return passthru_chars_; }
197 std::string newlineCmd() const { return newline_cmd_; }
199 bool parbreakIsNewline() const { return parbreakisnewline_; }
201 bool parbreakIgnored() const { return parbreakignored_; }
203 bool isNeedProtect() const { return needprotect_; }
205 bool needsCProtect() const { return needcprotect_; }
206 /// Protection of some elements such as \ref and \cite
207 /// in \mbox (needed by commands building on soul or ulem)
208 bool isNeedMBoxProtect() const { return needmboxprotect_; }
210 bool isFreeSpacing() const { return freespacing_; }
212 bool isKeepEmpty() const { return keepempty_; }
214 bool forceLTR() const { return forceltr_; }
216 bool forceOwnlines() const { return forceownlines_; }
218 bool isInToc() const { return intoc_; }
220 bool spellcheck() const { return spellcheck_; }
222 bool resetsFont() const { return resetsfont_; }
224 bool isDisplay() const { return display_; }
226 bool forceLocalFontSwitch() const { return forcelocalfontswitch_; }
228 docstring const & obsoleted_by() const { return obsoleted_by_; }
230 bool addToToc() const { return add_to_toc_; }
232 std::string tocType() const { return toc_type_; }
234 bool isTocCaption() const { return is_toc_caption_; }
236 bool editExternally () const { return edit_external_; }
239 void makeDefaultCSS() const;
241 std::string defaultCSSClass() const;
243 void readArgument(Lexer &);
245 docstring name_ = from_ascii("undefined");
247 * This is only used (at present) to decide where to put them on the menus.
248 * Values are 'charstyle', 'custom' (things that by default look like a
249 * footnote), 'standard'.
251 InsetLyXType lyxtype_ = InsetLyXType::STANDARD;
253 docstring labelstring_ = from_ascii("UNDEFINED");
255 docstring menustring_;
257 bool contentaslabel_ = false;
259 InsetDecoration decoration_ = InsetDecoration::DEFAULT;
261 InsetLaTeXType latextype_ = InsetLaTeXType::NOLATEXTYPE;
263 std::string latexname_;
265 std::string latexparam_;
267 docstring leftdelim_;
269 docstring rightdelim_;
271 FontInfo font_ = inherit_font;
273 FontInfo labelfont_ = sane_font;
275 ColorCode bgcolor_ = Color_error;
280 /// Language dependent macro definitions needed for this inset
281 docstring langpreamble_;
282 /// Language and babel dependent macro definitions needed for this inset
283 docstring babelpreamble_;
285 bool fixedwidthpreambleencoding_ = false;
287 docstring refprefix_;
289 mutable std::string htmltag_;
291 mutable std::string htmlattr_;
293 std::string htmlinnertag_;
295 mutable std::string htmlinnerattr_;
297 std::string htmllabel_;
299 docstring htmlstyle_;
300 /// Cache for default CSS info for this inset.
301 mutable docstring htmldefaultstyle_;
302 /// Cache for default CSS class.
303 mutable std::string defaultcssclass_;
304 /// Whether to force generation of default CSS even if some is given.
305 /// False by default.
306 bool htmlforcecss_ = false;
308 docstring htmlpreamble_;
310 bool htmlisblock_ = true;
312 std::string docbooktag_;
314 mutable std::string docbooktagtype_;
316 std::string docbookattr_;
318 mutable std::string docbookininfo_;
320 bool docbooknotinpara_ = false;
322 bool docbookargumentbeforemaintag_ = false;
324 bool docbooksection_ = false;
326 std::string docbookwrappertag_;
328 mutable std::string docbookwrappertagtype_;
330 std::string docbookwrapperattr_;
332 std::string docbookitemtag_;
334 mutable std::string docbookitemtagtype_;
336 std::string docbookitemattr_;
338 std::string docbookitemwrappertag_;
340 mutable std::string docbookitemwrappertagtype_;
342 std::string docbookitemwrapperattr_;
344 std::set<std::string> required_;
346 bool multipar_ = true;
348 bool custompars_ = true;
350 bool forceplain_ = false;
352 bool passthru_ = false;
354 docstring passthru_chars_;
356 std::string newline_cmd_;
358 bool parbreakisnewline_ = false;
360 bool parbreakignored_ = false;
362 bool freespacing_ = false;
364 bool keepempty_ = false;
366 bool forceltr_ = false;
368 bool forceownlines_ = false;
370 bool needprotect_ = false;
372 bool needcprotect_ = false;
374 bool needmboxprotect_ = false;
375 /// should the contents be written to TOC strings?
377 /// check spelling of this inset?
378 bool spellcheck_ = true;
380 bool resetsfont_ = false;
382 bool display_ = true;
384 bool forcelocalfontswitch_ = false;
385 /** Name of an insetlayout that has replaced this insetlayout.
386 This is used to rename an insetlayout, while keeping backward
389 docstring obsoleted_by_;
391 Layout::LaTeXArgMap latexargs_;
393 Layout::LaTeXArgMap postcommandargs_;
395 bool add_to_toc_ = false;
397 std::string toc_type_;
399 bool is_toc_caption_ = false;
401 bool edit_external_ = false;
405 InsetLyXType translateLyXType(std::string const & str);
406 InsetDecoration translateDecoration(std::string const & str);