3 * \file InsetLayout.cpp
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.
15 #include "InsetLayout.h"
20 #include "support/lstrings.h"
30 InsetLayout::InsetLayout() :
31 name_(from_ascii("undefined")), labelstring_(from_ascii("UNDEFINED")),
32 decoration_(InsetLayout::Default),
33 font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error),
34 multipar_(false), passthru_(false), needprotect_(false),
35 freespacing_(false), keepempty_(false), forceltr_(false)
37 labelfont_.setColor(Color_error);
43 InsetLayout::InsetDecoration translateDecoration(std::string const & str)
46 return InsetLayout::Classic;
47 if (str == "minimalistic")
48 return InsetLayout::Minimalistic;
49 if (str == "conglomerate")
50 return InsetLayout::Conglomerate;
51 return InsetLayout::Default;
57 bool InsetLayout::read(Lexer & lex)
59 name_ = support::subst(lex.getDocString(), '_', ' ');
83 LexerKeyword elementTags[] = {
84 { "bgcolor", IL_BGCOLOR },
85 { "decoration", IL_DECORATION },
88 { "forceltr", IL_FORCELTR },
89 { "freespacing", IL_FREESPACING },
90 { "keepempty", IL_KEEPEMPTY },
91 { "labelfont", IL_LABELFONT },
92 { "labelstring", IL_LABELSTRING },
93 { "latexname", IL_LATEXNAME },
94 { "latexparam", IL_LATEXPARAM },
95 { "latextype", IL_LATEXTYPE },
96 { "lyxtype", IL_LYXTYPE },
97 { "multipar", IL_MULTIPAR },
98 { "needprotect", IL_NEEDPROTECT },
99 { "passthru", IL_PASSTHRU },
100 { "preamble", IL_PREAMBLE },
101 { "requires", IL_REQUIRES }
104 lex.pushTable(elementTags);
106 FontInfo font = inherit_font;
107 labelfont_ = inherit_font;
108 bgcolor_ = Color_background;
112 while (!getout && lex.isOK()) {
115 case Lexer::LEX_UNDEF:
116 lex.printError("Unknown InsetLayout tag");
133 decoration_ = translateDecoration(tmp);
140 latexparam_ = support::subst(tmp, """, "\"");
143 labelfont_ = lyxRead(lex, inherit_font);
164 font_ = lyxRead(lex, inherit_font);
165 // If you want to define labelfont, you need to do so after
172 bgcolor_ = lcolor.getFromLyXName(tmp);
175 preamble_ = lex.getLongString("EndPreamble");
179 vector<string> const req
180 = support::getVectorFromString(lex.getString());
181 requires_.insert(req.begin(), req.end());
190 // Here add element to list if getout == true
194 // The label font is generally used as-is without
195 // any realization against a given context.
196 labelfont_.realize(sane_font);