-enum CharStyleTags {
- CS_FONT = 1,
- CS_LABELFONT,
- CS_LATEXTYPE,
- CS_LATEXNAME,
- CS_LATEXPARAM,
- CS_PREAMBLE,
- CS_END
-};
-
-
-enum InsetLayoutTags {
- IL_FONT = 1,
- IL_LABELFONT,
- IL_LABELSTRING,
- IL_LATEXTYPE,
- IL_LATEXNAME,
- IL_LATEXPARAM,
- IL_PREAMBLE,
- IL_END
-};
-
-
-
-void TextClass::readCharStyle(Lexer & lexrc, string const & name)
-{
- keyword_item elementTags[] = {
- { "end", CS_END },
- { "font", CS_FONT },
- { "labelfont", CS_LABELFONT },
- { "latexname", CS_LATEXNAME },
- { "latexparam", CS_LATEXPARAM },
- { "latextype", CS_LATEXTYPE },
- { "preamble", CS_PREAMBLE}
- };
-
- lexrc.pushTable(elementTags, CS_END);
-
- string latextype;
- string latexname;
- string latexparam;
- Font font(Font::ALL_INHERIT);
- Font labelfont(Font::ALL_INHERIT);
- string preamble;
-
- bool getout = false;
- while (!getout && lexrc.isOK()) {
- int le = lexrc.lex();
- switch (le) {
- case Lexer::LEX_UNDEF:
- lexrc.printError("Unknown ClassOption tag `$$Token'");
- continue;
- default: break;
- }
- switch (static_cast<CharStyleTags>(le)) {
- case CS_LATEXTYPE:
- lexrc.next();
- latextype = lexrc.getString();
- break;
- case CS_LATEXNAME:
- lexrc.next();
- latexname = lexrc.getString();
- break;
- case CS_LATEXPARAM:
- lexrc.next();
- latexparam = subst(lexrc.getString(), """, "\"");
- break;
- case CS_LABELFONT:
- labelfont.lyxRead(lexrc);
- break;
- case CS_FONT:
- font.lyxRead(lexrc);
- labelfont = font;
- break;
- case CS_PREAMBLE:
- preamble = lexrc.getLongString("EndPreamble");
- break;
- case CS_END:
- getout = true;
- break;
- }
- }
-
- //
- // Here add element to list if getout == true
- if (getout) {
- CharStyle cs;
- cs.name = name;
- cs.latextype = latextype;
- cs.latexname = latexname;
- cs.latexparam = latexparam;
- cs.font = font;
- cs.labelfont = labelfont;
- cs.preamble = from_utf8(preamble);
- charstyles().push_back(cs);
- }
-
- lexrc.popTable();
-}
-
-
-void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
-{
- keyword_item elementTags[] = {
- { "end", IL_END },
- { "font", IL_FONT },
- { "labelfont", IL_LABELFONT },
- { "labelstring", IL_LABELSTRING },
- { "latexname", IL_LATEXNAME },
- { "latexparam", IL_LATEXPARAM },
- { "latextype", IL_LATEXTYPE },
- { "preamble", IL_PREAMBLE}
- };
-
- lexrc.pushTable(elementTags, IL_END);
-
- docstring labelstring;
- string latextype;
- string latexname;
- string latexparam;
- Font font(Font::ALL_INHERIT);
- Font labelfont(Font::ALL_INHERIT);
- string preamble;
-
- bool getout = false;
- while (!getout && lexrc.isOK()) {
- int le = lexrc.lex();
- switch (le) {
- case Lexer::LEX_UNDEF:
- lexrc.printError("Unknown ClassOption tag `$$Token'");
- continue;
- default: break;
- }
- switch (static_cast<InsetLayoutTags>(le)) {
- case IL_LATEXTYPE:
- lexrc.next();
- latextype = lexrc.getString();
- break;
- case IL_LABELSTRING:
- lexrc.next();
- labelstring = lexrc.getDocString();
- break;
- case IL_LATEXNAME:
- lexrc.next();
- latexname = lexrc.getString();
- break;
- case IL_LATEXPARAM:
- lexrc.next();
- latexparam = subst(lexrc.getString(), """, "\"");
- break;
- case IL_LABELFONT:
- labelfont.lyxRead(lexrc);
- labelfont.realize(defaultfont());
- break;
- case IL_FONT:
- font.lyxRead(lexrc);
- font.realize(defaultfont());
- labelfont = font;
- break;
- case IL_PREAMBLE:
- preamble = lexrc.getLongString("EndPreamble");
- break;
- case IL_END:
- getout = true;
- break;
- }
- }
-
- //
- // Here add element to list if getout == true
- if (getout) {
- InsetLayout il;
- il.labelstring = labelstring;
- il.latextype = latextype;
- il.latexname = latexname;
- il.latexparam = latexparam;
- il.font = font;
- il.labelfont = labelfont;
- il.preamble = from_utf8(preamble);
- insetlayoutlist_[name] = il;
- }
-
- lexrc.popTable();
-}
-
-