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"
19 #include "support/lstrings.h"
29 InsetLayout::InsetLayout() :
30 name_(from_ascii("undefined")), labelstring_(from_ascii("UNDEFINED")),
31 font_(sane_font), labelfont_(sane_font), bgcolor_(Color_error),
32 multipar_(false), passthru_(false), needprotect_(false),
33 freespacing_(false), keepempty_(false), forceltr_(false)
35 labelfont_.setColor(Color_error);
39 enum InsetLayoutTags {
61 bool InsetLayout::read(Lexer & lexrc)
63 name_ = support::subst(lexrc.getDocString(), '_', ' ');
65 keyword_item elementTags[] = {
66 { "bgcolor", IL_BGCOLOR },
67 { "decoration", IL_DECORATION },
70 { "forceltr", IL_FORCELTR },
71 { "freespacing", IL_FREESPACING },
72 { "keepempty", IL_KEEPEMPTY },
73 { "labelfont", IL_LABELFONT },
74 { "labelstring", IL_LABELSTRING },
75 { "latexname", IL_LATEXNAME },
76 { "latexparam", IL_LATEXPARAM },
77 { "latextype", IL_LATEXTYPE },
78 { "lyxtype", IL_LYXTYPE },
79 { "multipar", IL_MULTIPAR },
80 { "needprotect", IL_NEEDPROTECT },
81 { "passthru", IL_PASSTHRU },
82 { "preamble", IL_PREAMBLE },
83 { "requires", IL_REQUIRES }
86 lexrc.pushTable(elementTags, IL_END);
88 FontInfo font = inherit_font;
89 labelfont_ = inherit_font;
90 bgcolor_ = Color_background;
93 while (!getout && lexrc.isOK()) {
96 case Lexer::LEX_UNDEF:
97 lexrc.printError("Unknown InsetLayout tag `$$Token'");
101 switch (static_cast<InsetLayoutTags>(le)) {
104 lyxtype_ = lexrc.getString();
108 latextype_ = lexrc.getString();
112 labelstring_ = lexrc.getDocString();
116 decoration_ = lexrc.getString();
120 latexname_ = lexrc.getString();
124 latexparam_ = support::subst(lexrc.getString(), """, "\"");
127 labelfont_ = lyxRead(lexrc, inherit_font);
131 forceltr_ = lexrc.getBool();
135 multipar_ = lexrc.getBool();
139 passthru_ = lexrc.getBool();
143 keepempty_ = lexrc.getBool();
147 freespacing_ = lexrc.getBool();
151 needprotect_ = lexrc.getBool();
154 font = lyxRead(lexrc, inherit_font);
155 // So: define font before labelfont
161 string const token = lexrc.getString();
162 bgcolor_ = lcolor.getFromLyXName(token);
166 preamble_ = lexrc.getLongString("EndPreamble");
170 vector<string> const req
171 = support::getVectorFromString(lexrc.getString());
172 requires_.insert(req.begin(), req.end());
181 // Here add element to list if getout == true
185 // The label font is generally used as-is without
186 // any realization against a given context.
187 labelfont_.realize(sane_font);