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"
21 #include "support/lstrings.h"
31 InsetLayout::InsetLayout() :
32 name_(from_ascii("undefined")), labelstring_(from_ascii("UNDEFINED")),
33 decoration_(InsetLayout::Default),
34 font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error),
35 multipar_(false), passthru_(false), needprotect_(false),
36 freespacing_(false), keepempty_(false), forceltr_(false)
38 labelfont_.setColor(Color_error);
44 InsetLayout::InsetDecoration translateDecoration(std::string const & str)
47 return InsetLayout::Classic;
48 if (str == "minimalistic")
49 return InsetLayout::Minimalistic;
50 if (str == "conglomerate")
51 return InsetLayout::Conglomerate;
52 return InsetLayout::Default;
58 bool InsetLayout::read(Lexer & lex)
60 name_ = support::subst(lex.getDocString(), '_', ' ');
84 LexerKeyword elementTags[] = {
85 { "bgcolor", IL_BGCOLOR },
86 { "decoration", IL_DECORATION },
89 { "forceltr", IL_FORCELTR },
90 { "freespacing", IL_FREESPACING },
91 { "keepempty", IL_KEEPEMPTY },
92 { "labelfont", IL_LABELFONT },
93 { "labelstring", IL_LABELSTRING },
94 { "latexname", IL_LATEXNAME },
95 { "latexparam", IL_LATEXPARAM },
96 { "latextype", IL_LATEXTYPE },
97 { "lyxtype", IL_LYXTYPE },
98 { "multipar", IL_MULTIPAR },
99 { "needprotect", IL_NEEDPROTECT },
100 { "passthru", IL_PASSTHRU },
101 { "preamble", IL_PREAMBLE },
102 { "requires", IL_REQUIRES }
105 lex.pushTable(elementTags);
107 FontInfo font = inherit_font;
108 labelfont_ = inherit_font;
109 bgcolor_ = Color_background;
113 while (!getout && lex.isOK()) {
116 case Lexer::LEX_UNDEF:
117 lex.printError("Unknown InsetLayout tag");
134 decoration_ = translateDecoration(tmp);
141 latexparam_ = support::subst(tmp, """, "\"");
144 labelfont_ = lyxRead(lex, inherit_font);
165 font_ = lyxRead(lex, inherit_font);
166 // If you want to define labelfont, you need to do so after
173 bgcolor_ = lcolor.getFromLyXName(tmp);
176 preamble_ = lex.getLongString("EndPreamble");
180 vector<string> const req
181 = support::getVectorFromString(lex.getString());
182 requires_.insert(req.begin(), req.end());
191 // Here add element to list if getout == true
195 // The label font is generally used as-is without
196 // any realization against a given context.
197 labelfont_.realize(sane_font);