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 {
62 bool InsetLayout::read(Lexer & lexrc)
64 name_ = support::subst(lexrc.getDocString(), '_', ' ');
66 keyword_item elementTags[] = {
67 { "bgcolor", IL_BGCOLOR },
68 { "decoration", IL_DECORATION },
71 { "forceltr", IL_FORCELTR },
72 { "freespacing", IL_FREESPACING },
73 { "keepempty", IL_KEEPEMPTY },
74 { "labelfont", IL_LABELFONT },
75 { "labelstring", IL_LABELSTRING },
76 { "latexname", IL_LATEXNAME },
77 { "latexparam", IL_LATEXPARAM },
78 { "latextype", IL_LATEXTYPE },
79 { "lyxtype", IL_LYXTYPE },
80 { "multipar", IL_MULTIPAR },
81 { "needprotect", IL_NEEDPROTECT },
82 { "passthru", IL_PASSTHRU },
83 { "preamble", IL_PREAMBLE },
84 { "requires", IL_REQUIRES }
87 lexrc.pushTable(elementTags, IL_END);
89 FontInfo font = inherit_font;
90 labelfont_ = inherit_font;
91 bgcolor_ = Color_background;
94 while (!getout && lexrc.isOK()) {
97 case Lexer::LEX_UNDEF:
98 lexrc.printError("Unknown InsetLayout tag `$$Token'");
102 switch (static_cast<InsetLayoutTags>(le)) {
105 lyxtype_ = lexrc.getString();
109 latextype_ = lexrc.getString();
113 labelstring_ = lexrc.getDocString();
117 decoration_ = lexrc.getString();
121 latexname_ = lexrc.getString();
125 latexparam_ = support::subst(lexrc.getString(), """, "\"");
128 labelfont_ = lyxRead(lexrc, inherit_font);
132 forceltr_ = lexrc.getBool();
136 multipar_ = lexrc.getBool();
140 passthru_ = lexrc.getBool();
144 keepempty_ = lexrc.getBool();
148 freespacing_ = lexrc.getBool();
152 needprotect_ = lexrc.getBool();
155 font = lyxRead(lexrc, inherit_font);
156 // So: define font before labelfont
162 string const token = lexrc.getString();
163 bgcolor_ = lcolor.getFromLyXName(token);
167 preamble_ = lexrc.getLongString("EndPreamble");
171 vector<string> const req
172 = support::getVectorFromString(lexrc.getString());
173 requires_.insert(req.begin(), req.end());
182 // Here add element to list if getout == true
186 // The label font is generally used as-is without
187 // any realization against a given context.
188 labelfont_.realize(sane_font);