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);
41 enum InsetLayoutTags {
64 InsetLayout::InsetDecoration translateDecoration(std::string const & str)
67 return InsetLayout::Classic;
68 if (str == "minimalistic")
69 return InsetLayout::Minimalistic;
70 if (str == "conglomerate")
71 return InsetLayout::Conglomerate;
72 return InsetLayout::Default;
77 bool InsetLayout::read(Lexer & lexrc)
79 name_ = support::subst(lexrc.getDocString(), '_', ' ');
81 keyword_item elementTags[] = {
82 { "bgcolor", IL_BGCOLOR },
83 { "decoration", IL_DECORATION },
86 { "forceltr", IL_FORCELTR },
87 { "freespacing", IL_FREESPACING },
88 { "keepempty", IL_KEEPEMPTY },
89 { "labelfont", IL_LABELFONT },
90 { "labelstring", IL_LABELSTRING },
91 { "latexname", IL_LATEXNAME },
92 { "latexparam", IL_LATEXPARAM },
93 { "latextype", IL_LATEXTYPE },
94 { "lyxtype", IL_LYXTYPE },
95 { "multipar", IL_MULTIPAR },
96 { "needprotect", IL_NEEDPROTECT },
97 { "passthru", IL_PASSTHRU },
98 { "preamble", IL_PREAMBLE },
99 { "requires", IL_REQUIRES }
102 lexrc.pushTable(elementTags, IL_END);
104 FontInfo font = inherit_font;
105 labelfont_ = inherit_font;
106 bgcolor_ = Color_background;
109 while (!getout && lexrc.isOK()) {
110 int le = lexrc.lex();
112 case Lexer::LEX_UNDEF:
113 lexrc.printError("Unknown InsetLayout tag `$$Token'");
117 switch (static_cast<InsetLayoutTags>(le)) {
120 lyxtype_ = lexrc.getString();
124 latextype_ = lexrc.getString();
128 labelstring_ = lexrc.getDocString();
132 decoration_ = translateDecoration(lexrc.getString());
136 latexname_ = lexrc.getString();
140 latexparam_ = support::subst(lexrc.getString(), """, "\"");
143 labelfont_ = lyxRead(lexrc, inherit_font);
147 forceltr_ = lexrc.getBool();
151 multipar_ = lexrc.getBool();
155 passthru_ = lexrc.getBool();
159 keepempty_ = lexrc.getBool();
163 freespacing_ = lexrc.getBool();
167 needprotect_ = lexrc.getBool();
170 font_ = lyxRead(lexrc, inherit_font);
171 // If you want to define labelfont, you need to do so after
178 string const token = lexrc.getString();
179 bgcolor_ = lcolor.getFromLyXName(token);
183 preamble_ = lexrc.getLongString("EndPreamble");
187 vector<string> const req
188 = support::getVectorFromString(lexrc.getString());
189 requires_.insert(req.begin(), req.end());
198 // Here add element to list if getout == true
202 // The label font is generally used as-is without
203 // any realization against a given context.
204 labelfont_.realize(sane_font);