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_insetlabel); }
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 { return htmlattr_; }
126 std::string const & htmlclass() const;
128 std::string const & htmlGetAttrString() const;
129 /// Tag for individual paragraphs in the inset. Default is none.
130 std::string const & htmlinnertag() const { return htmlinnertag_; }
131 /// Attributes for that tag. Default (if a tag is provided) is:
132 /// class="name_inner".
133 std::string const & htmlinnerattr() const;
134 /// A label for this environment, possibly including a reference
135 /// to a counter. E.g., for footnote, it might be:
136 /// \arabic{footnote}
138 /// FIXME Could we get this from the layout?
139 std::string const & htmllabel() const { return htmllabel_; }
141 inline std::string htmllabeltag() const { return "span"; }
143 std::string htmllabelattr() const
144 { return "class=\"" + defaultCSSClass() + "_label\""; }
145 /// CSS associated with this inset.
146 docstring htmlstyle() const;
147 /// Additional material for the header.
148 docstring htmlpreamble() const { return htmlpreamble_; }
149 /// Whether this inset represents a "block" of material, i.e., a set
150 /// of paragraphs of its own (true), or should be run into the previous
151 /// paragraph (false). Examples:
152 /// For branches, this is false.
153 /// For footnotes, this is true.
154 /// Defaults to true.
155 bool htmlisblock() const { return htmlisblock_; }
157 std::string docbooktag() const { return docbooktag_; }
159 std::string docbooktagtype() const;
161 std::string docbookattr() const { return docbookattr_; }
163 std::string docbookinnertag() const { return docbookinnertag_; }
165 std::string docbookinnertagtype() const;
167 std::string docbookinnerattr() const { return docbookinnerattr_; }
169 std::string const & docbookininfo() const;
171 bool docbooksection() const { return docbooksection_; }
173 bool docbooknotinpara() const { return docbooknotinpara_; }
175 bool docbookargumentbeforemaintag() const { return docbookargumentbeforemaintag_; }
177 bool docbookargumentaftermaintag() const { return docbookargumentaftermaintag_; }
179 std::string docbookwrappertag() const { return docbookwrappertag_; }
181 std::string docbookwrappertagtype() const;
183 std::string docbookwrapperattr() const { return docbookwrapperattr_; }
185 std::string docbookitemwrappertag() const { return docbookitemwrappertag_; }
187 std::string docbookitemwrappertagtype() const;
189 std::string docbookitemwrapperattr() const { return docbookitemwrapperattr_; }
191 std::string docbookitemtag() const { return docbookitemtag_; }
193 std::string docbookitemtagtype() const;
195 std::string docbookitemattr() const { return docbookitemattr_; }
197 bool docbooknofontinside() const { return docbooknofontinside_; }
199 bool docbookrenderasimage() const { return docbookrenderasimage_; }
201 std::set<std::string> required() const { return required_; }
203 bool isMultiPar() const { return multipar_; }
205 bool forcePlainLayout() const { return forceplain_; }
207 bool allowParagraphCustomization() const { return custompars_; }
209 bool isPassThru() const { return passthru_; }
211 docstring passThruChars() const { return passthru_chars_; }
213 std::string newlineCmd() const { return newline_cmd_; }
215 bool parbreakIsNewline() const { return parbreakisnewline_; }
217 bool parbreakIgnored() const { return parbreakignored_; }
219 bool isNeedProtect() const { return needprotect_; }
221 bool needsCProtect() const { return needcprotect_; }
222 /// Protection of some elements such as \ref and \cite
223 /// in \mbox (needed by commands building on soul or ulem)
224 bool isNeedMBoxProtect() const { return needmboxprotect_; }
226 bool isFreeSpacing() const { return freespacing_; }
228 bool isKeepEmpty() const { return keepempty_; }
230 bool forceLTR() const { return forceltr_; }
232 bool forceOwnlines() const { return forceownlines_; }
234 bool isInToc() const { return intoc_; }
236 bool spellcheck() const { return spellcheck_; }
238 bool resetsFont() const { return resetsfont_; }
240 bool isDisplay() const { return display_; }
242 bool forceLocalFontSwitch() const { return forcelocalfontswitch_; }
244 docstring const & obsoleted_by() const { return obsoleted_by_; }
246 bool addToToc() const { return add_to_toc_; }
248 std::string tocType() const { return toc_type_; }
250 bool isTocCaption() const { return is_toc_caption_; }
252 bool editExternally () const { return edit_external_; }
255 void makeDefaultCSS() const;
257 std::string defaultCSSClass() const;
259 void readArgument(Lexer &);
261 docstring name_ = from_ascii("undefined");
263 * This is only used (at present) to decide where to put them on the menus.
264 * Values are 'charstyle', 'custom' (things that by default look like a
265 * footnote), 'standard'.
267 InsetLyXType lyxtype_ = InsetLyXType::STANDARD;
269 docstring labelstring_ = from_ascii("UNDEFINED");
271 docstring menustring_;
273 bool contentaslabel_ = false;
275 InsetDecoration decoration_ = InsetDecoration::DEFAULT;
277 InsetLaTeXType latextype_ = InsetLaTeXType::NOLATEXTYPE;
279 std::string latexname_;
281 std::string latexparam_;
283 docstring leftdelim_;
285 docstring rightdelim_;
287 FontInfo font_ = inherit_font;
289 FontInfo labelfont_ = sane_font;
291 ColorCode bgcolor_ = Color_error;
296 /// Language dependent macro definitions needed for this inset
297 docstring langpreamble_;
298 /// Language and babel dependent macro definitions needed for this inset
299 docstring babelpreamble_;
301 bool fixedwidthpreambleencoding_ = false;
303 docstring refprefix_;
305 mutable std::string htmltag_;
307 mutable std::string htmlattr_;
309 mutable std::string htmlclass_;
311 mutable std::string htmlfullattrs_;
313 std::string htmlinnertag_;
315 mutable std::string htmlinnerattr_;
317 std::string htmllabel_;
319 docstring htmlstyle_;
320 /// Cache for default CSS info for this inset.
321 mutable docstring htmldefaultstyle_;
322 /// Cache for default CSS class.
323 mutable std::string defaultcssclass_;
324 /// Whether to force generation of default CSS even if some is given.
325 /// False by default.
326 bool htmlforcecss_ = false;
328 docstring htmlpreamble_;
330 bool htmlisblock_ = true;
332 std::string docbooktag_;
334 mutable std::string docbooktagtype_;
336 std::string docbookattr_;
338 std::string docbookinnertag_;
340 mutable std::string docbookinnertagtype_;
342 std::string docbookinnerattr_;
344 mutable std::string docbookininfo_;
346 bool docbooknotinpara_ = false;
348 bool docbookargumentbeforemaintag_ = false;
350 bool docbookargumentaftermaintag_ = false;
352 bool docbooksection_ = false;
354 std::string docbookwrappertag_;
356 mutable std::string docbookwrappertagtype_;
358 std::string docbookwrapperattr_;
360 std::string docbookitemtag_;
362 mutable std::string docbookitemtagtype_;
364 std::string docbookitemattr_;
366 std::string docbookitemwrappertag_;
368 mutable std::string docbookitemwrappertagtype_;
370 std::string docbookitemwrapperattr_;
372 bool docbooknofontinside_ = false;
374 bool docbookrenderasimage_ = false;
376 std::set<std::string> required_;
378 bool multipar_ = true;
380 bool custompars_ = true;
382 bool forceplain_ = false;
384 bool passthru_ = false;
386 docstring passthru_chars_;
388 std::string newline_cmd_;
390 bool parbreakisnewline_ = false;
392 bool parbreakignored_ = false;
394 bool freespacing_ = false;
396 bool keepempty_ = false;
398 bool forceltr_ = false;
400 bool forceownlines_ = false;
402 bool needprotect_ = false;
404 bool needcprotect_ = false;
406 bool needmboxprotect_ = false;
407 /// should the contents be written to TOC strings?
409 /// check spelling of this inset?
410 bool spellcheck_ = true;
412 bool resetsfont_ = false;
414 bool display_ = true;
416 bool forcelocalfontswitch_ = false;
417 /** Name of an insetlayout that has replaced this insetlayout.
418 This is used to rename an insetlayout, while keeping backward
421 docstring obsoleted_by_;
423 Layout::LaTeXArgMap latexargs_;
425 Layout::LaTeXArgMap postcommandargs_;
427 bool add_to_toc_ = false;
429 std::string toc_type_;
431 bool is_toc_caption_ = false;
433 bool edit_external_ = false;
437 InsetLyXType translateLyXType(std::string const & str);
438 InsetDecoration translateDecoration(std::string const & str);