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 font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error),
33 multipar_(false), passthru_(false), needprotect_(false),
34 freespacing_(false), keepempty_(false), forceltr_(false)
36 labelfont_.setColor(Color_error);
40 enum InsetLayoutTags {
63 InsetLayout::InsetDecoration translateDecoration(std::string const & str)
66 return InsetLayout::Classic;
67 if (str == "minimalistic")
68 return InsetLayout::Minimalistic;
69 if (str == "conglomerate")
70 return InsetLayout::Conglomerate;
71 return InsetLayout::Default;
76 bool InsetLayout::read(Lexer & lexrc)
78 name_ = support::subst(lexrc.getDocString(), '_', ' ');
80 keyword_item elementTags[] = {
81 { "bgcolor", IL_BGCOLOR },
82 { "decoration", IL_DECORATION },
85 { "forceltr", IL_FORCELTR },
86 { "freespacing", IL_FREESPACING },
87 { "keepempty", IL_KEEPEMPTY },
88 { "labelfont", IL_LABELFONT },
89 { "labelstring", IL_LABELSTRING },
90 { "latexname", IL_LATEXNAME },
91 { "latexparam", IL_LATEXPARAM },
92 { "latextype", IL_LATEXTYPE },
93 { "lyxtype", IL_LYXTYPE },
94 { "multipar", IL_MULTIPAR },
95 { "needprotect", IL_NEEDPROTECT },
96 { "passthru", IL_PASSTHRU },
97 { "preamble", IL_PREAMBLE },
98 { "requires", IL_REQUIRES }
101 lexrc.pushTable(elementTags, IL_END);
103 FontInfo font = inherit_font;
104 labelfont_ = inherit_font;
105 bgcolor_ = Color_background;
108 while (!getout && lexrc.isOK()) {
109 int le = lexrc.lex();
111 case Lexer::LEX_UNDEF:
112 lexrc.printError("Unknown InsetLayout tag `$$Token'");
116 switch (static_cast<InsetLayoutTags>(le)) {
119 lyxtype_ = lexrc.getString();
123 latextype_ = lexrc.getString();
127 labelstring_ = lexrc.getDocString();
131 decoration_ = translateDecoration(lexrc.getString());
135 latexname_ = lexrc.getString();
139 latexparam_ = support::subst(lexrc.getString(), """, "\"");
142 labelfont_ = lyxRead(lexrc, inherit_font);
146 forceltr_ = lexrc.getBool();
150 multipar_ = lexrc.getBool();
154 passthru_ = lexrc.getBool();
158 keepempty_ = lexrc.getBool();
162 freespacing_ = lexrc.getBool();
166 needprotect_ = lexrc.getBool();
169 font = lyxRead(lexrc, inherit_font);
170 // So: define font before labelfont
176 string const token = lexrc.getString();
177 bgcolor_ = lcolor.getFromLyXName(token);
181 preamble_ = lexrc.getLongString("EndPreamble");
185 vector<string> const req
186 = support::getVectorFromString(lexrc.getString());
187 requires_.insert(req.begin(), req.end());
196 // Here add element to list if getout == true
200 // The label font is generally used as-is without
201 // any realization against a given context.
202 labelfont_.realize(sane_font);