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