+enum CharStyleTags {
+ CS_FONT = 1,
+ CS_LABELFONT,
+ CS_LATEXTYPE,
+ CS_LATEXNAME,
+ CS_LATEXPARAM,
+ CS_PREAMBLE,
+ CS_END
+};
+
+
+void LyXTextClass::readCharStyle(LyXLex & 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;
+ LyXFont font(LyXFont::ALL_INHERIT);
+ LyXFont labelfont(LyXFont::ALL_INHERIT);
+ string preamble;
+
+ bool getout = false;
+ while (!getout && lexrc.isOK()) {
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::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 = preamble;
+ charstyles().push_back(cs);
+ }
+
+ lexrc.popTable();
+}
+
+
+enum FloatTags {
+ FT_TYPE = 1,
+ FT_NAME,
+ FT_PLACEMENT,
+ FT_EXT,
+ FT_WITHIN,
+ FT_STYLE,
+ FT_LISTNAME,
+ FT_BUILTIN,
+ FT_END
+};
+
+
+void LyXTextClass::readFloat(LyXLex & lexrc)
+{
+ keyword_item floatTags[] = {
+ { "end", FT_END },
+ { "extension", FT_EXT },
+ { "guiname", FT_NAME },
+ { "latexbuiltin", FT_BUILTIN },
+ { "listname", FT_LISTNAME },
+ { "numberwithin", FT_WITHIN },
+ { "placement", FT_PLACEMENT },
+ { "style", FT_STYLE },
+ { "type", FT_TYPE }
+ };
+
+ lexrc.pushTable(floatTags, FT_END);
+
+ string type;
+ string placement;
+ string ext;
+ string within;
+ string style;
+ string name;
+ string listname;
+ bool builtin = false;
+
+ bool getout = false;
+ while (!getout && lexrc.isOK()) {
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown ClassOption tag `$$Token'");
+ continue;
+ default: break;
+ }
+ switch (static_cast<FloatTags>(le)) {
+ case FT_TYPE:
+ lexrc.next();
+ type = lexrc.getString();
+ // Here we could check if this type is already defined
+ // and modify it with the rest of the vars instead.
+ break;
+ case FT_NAME:
+ lexrc.next();
+ name = lexrc.getString();
+ break;
+ case FT_PLACEMENT:
+ lexrc.next();
+ placement = lexrc.getString();
+ break;
+ case FT_EXT:
+ lexrc.next();
+ ext = lexrc.getString();
+ break;
+ case FT_WITHIN:
+ lexrc.next();
+ within = lexrc.getString();
+ if (within == "none")
+ within.erase();
+ break;
+ case FT_STYLE:
+ lexrc.next();
+ style = lexrc.getString();
+ break;
+ case FT_LISTNAME:
+ lexrc.next();
+ listname = lexrc.getString();
+ break;
+ case FT_BUILTIN:
+ lexrc.next();
+ builtin = lexrc.getBool();
+ break;
+ case FT_END:
+ getout = true;
+ break;
+ }
+ }
+
+ // Here if have a full float if getout == true
+ if (getout) {
+ Floating newfloat(type, placement, ext, within,
+ style, name, listname, builtin);
+ floatlist_->newFloat(newfloat);
+ }
+
+ lexrc.popTable();
+}
+
+
+enum CounterTags {
+ CT_NAME = 1,
+ CT_WITHIN,
+ CT_END
+};
+
+void LyXTextClass::readCounter(LyXLex & lexrc)
+{
+ keyword_item counterTags[] = {
+ { "end", CT_END },
+ { "name", CT_NAME },
+ { "within", CT_WITHIN }
+ };
+
+ lexrc.pushTable(counterTags, CT_END);
+
+ string name;
+ string within;
+
+ bool getout = false;
+ while (!getout && lexrc.isOK()) {
+ int le = lexrc.lex();
+ switch (le) {
+ case LyXLex::LEX_UNDEF:
+ lexrc.printError("Unknown ClassOption tag `$$Token'");
+ continue;
+ default: break;
+ }
+ switch (static_cast<CounterTags>(le)) {
+ case CT_NAME:
+ lexrc.next();
+ name = lexrc.getString();
+ break;
+ case CT_WITHIN:
+ lexrc.next();
+ within = lexrc.getString();
+ if (within == "none")
+ within.erase();
+ break;
+ case CT_END:
+ getout = true;
+ break;
+ }
+ }
+
+ // Here if have a full counter if getout == true
+ if (getout) {
+ if (within.empty()) {
+ ctrs_->newCounter(name);
+ } else {
+ ctrs_->newCounter(name, within);
+ }
+ }
+
+ lexrc.popTable();
+}
+