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 docbookinnertag() const { return docbookinnertag_; }
161 std::string docbookinnertagtype() const;
163 std::string docbookinnerattr() const { return docbookinnerattr_; }
165 std::string const & docbookininfo() const;
167 bool docbooksection() const { return docbooksection_; }
169 bool docbooknotinpara() const { return docbooknotinpara_; }
171 bool docbookargumentbeforemaintag() const { return docbookargumentbeforemaintag_; }
173 bool docbookargumentaftermaintag() const { return docbookargumentaftermaintag_; }
175 std::string docbookwrappertag() const { return docbookwrappertag_; }
177 std::string docbookwrappertagtype() const;
179 std::string docbookwrapperattr() const { return docbookwrapperattr_; }
181 std::string docbookitemwrappertag() const { return docbookitemwrappertag_; }
183 std::string docbookitemwrappertagtype() const;
185 std::string docbookitemwrapperattr() const { return docbookitemwrapperattr_; }
187 std::string docbookitemtag() const { return docbookitemtag_; }
189 std::string docbookitemtagtype() const;
191 std::string docbookitemattr() const { return docbookitemattr_; }
193 bool docbooknofontinside() const { return docbooknofontinside_; }
195 bool docbookrenderasimage() const { return docbookrenderasimage_; }
197 std::set<std::string> required() const { return required_; }
199 bool isMultiPar() const { return multipar_; }
201 bool forcePlainLayout() const { return forceplain_; }
203 bool allowParagraphCustomization() const { return custompars_; }
205 bool isPassThru() const { return passthru_; }
207 docstring passThruChars() const { return passthru_chars_; }
209 std::string newlineCmd() const { return newline_cmd_; }
211 bool parbreakIsNewline() const { return parbreakisnewline_; }
213 bool parbreakIgnored() const { return parbreakignored_; }
215 bool isNeedProtect() const { return needprotect_; }
217 bool needsCProtect() const { return needcprotect_; }
218 /// Protection of some elements such as \ref and \cite
219 /// in \mbox (needed by commands building on soul or ulem)
220 bool isNeedMBoxProtect() const { return needmboxprotect_; }
222 bool isFreeSpacing() const { return freespacing_; }
224 bool isKeepEmpty() const { return keepempty_; }
226 bool forceLTR() const { return forceltr_; }
228 bool forceOwnlines() const { return forceownlines_; }
230 bool isInToc() const { return intoc_; }
232 bool spellcheck() const { return spellcheck_; }
234 bool resetsFont() const { return resetsfont_; }
236 bool isDisplay() const { return display_; }
238 bool forceLocalFontSwitch() const { return forcelocalfontswitch_; }
240 docstring const & obsoleted_by() const { return obsoleted_by_; }
242 bool addToToc() const { return add_to_toc_; }
244 std::string tocType() const { return toc_type_; }
246 bool isTocCaption() const { return is_toc_caption_; }
248 bool editExternally () const { return edit_external_; }
251 void makeDefaultCSS() const;
253 std::string defaultCSSClass() const;
255 void readArgument(Lexer &);
257 docstring name_ = from_ascii("undefined");
259 * This is only used (at present) to decide where to put them on the menus.
260 * Values are 'charstyle', 'custom' (things that by default look like a
261 * footnote), 'standard'.
263 InsetLyXType lyxtype_ = InsetLyXType::STANDARD;
265 docstring labelstring_ = from_ascii("UNDEFINED");
267 docstring menustring_;
269 bool contentaslabel_ = false;
271 InsetDecoration decoration_ = InsetDecoration::DEFAULT;
273 InsetLaTeXType latextype_ = InsetLaTeXType::NOLATEXTYPE;
275 std::string latexname_;
277 std::string latexparam_;
279 docstring leftdelim_;
281 docstring rightdelim_;
283 FontInfo font_ = inherit_font;
285 FontInfo labelfont_ = sane_font;
287 ColorCode bgcolor_ = Color_error;
292 /// Language dependent macro definitions needed for this inset
293 docstring langpreamble_;
294 /// Language and babel dependent macro definitions needed for this inset
295 docstring babelpreamble_;
297 bool fixedwidthpreambleencoding_ = false;
299 docstring refprefix_;
301 mutable std::string htmltag_;
303 mutable std::string htmlattr_;
305 std::string htmlinnertag_;
307 mutable std::string htmlinnerattr_;
309 std::string htmllabel_;
311 docstring htmlstyle_;
312 /// Cache for default CSS info for this inset.
313 mutable docstring htmldefaultstyle_;
314 /// Cache for default CSS class.
315 mutable std::string defaultcssclass_;
316 /// Whether to force generation of default CSS even if some is given.
317 /// False by default.
318 bool htmlforcecss_ = false;
320 docstring htmlpreamble_;
322 bool htmlisblock_ = true;
324 std::string docbooktag_;
326 mutable std::string docbooktagtype_;
328 std::string docbookattr_;
330 std::string docbookinnertag_;
332 mutable std::string docbookinnertagtype_;
334 std::string docbookinnerattr_;
336 mutable std::string docbookininfo_;
338 bool docbooknotinpara_ = false;
340 bool docbookargumentbeforemaintag_ = false;
342 bool docbookargumentaftermaintag_ = false;
344 bool docbooksection_ = false;
346 std::string docbookwrappertag_;
348 mutable std::string docbookwrappertagtype_;
350 std::string docbookwrapperattr_;
352 std::string docbookitemtag_;
354 mutable std::string docbookitemtagtype_;
356 std::string docbookitemattr_;
358 std::string docbookitemwrappertag_;
360 mutable std::string docbookitemwrappertagtype_;
362 std::string docbookitemwrapperattr_;
364 bool docbooknofontinside_ = false;
366 bool docbookrenderasimage_ = false;
368 std::set<std::string> required_;
370 bool multipar_ = true;
372 bool custompars_ = true;
374 bool forceplain_ = false;
376 bool passthru_ = false;
378 docstring passthru_chars_;
380 std::string newline_cmd_;
382 bool parbreakisnewline_ = false;
384 bool parbreakignored_ = false;
386 bool freespacing_ = false;
388 bool keepempty_ = false;
390 bool forceltr_ = false;
392 bool forceownlines_ = false;
394 bool needprotect_ = false;
396 bool needcprotect_ = false;
398 bool needmboxprotect_ = false;
399 /// should the contents be written to TOC strings?
401 /// check spelling of this inset?
402 bool spellcheck_ = true;
404 bool resetsfont_ = false;
406 bool display_ = true;
408 bool forcelocalfontswitch_ = false;
409 /** Name of an insetlayout that has replaced this insetlayout.
410 This is used to rename an insetlayout, while keeping backward
413 docstring obsoleted_by_;
415 Layout::LaTeXArgMap latexargs_;
417 Layout::LaTeXArgMap postcommandargs_;
419 bool add_to_toc_ = false;
421 std::string toc_type_;
423 bool is_toc_caption_ = false;
425 bool edit_external_ = false;
429 InsetLyXType translateLyXType(std::string const & str);
430 InsetDecoration translateDecoration(std::string const & str);