]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetLayout.cpp
Stupid bug fix.
[lyx.git] / src / insets / InsetLayout.cpp
index 900881764999652e943c0921b78d7da58145bfc8..8e117224ae1ab0771e5a905450499a7733ebe661 100644 (file)
@@ -17,6 +17,7 @@
 #include "Color.h"
 #include "Font.h"
 #include "Lexer.h"
+
 #include "support/lstrings.h"
 
 #include <vector>
@@ -38,47 +39,49 @@ InsetLayout::InsetLayout() :
 }
 
 
-enum InsetLayoutTags {
-       IL_FONT = 1,
-       IL_BGCOLOR,
-       IL_DECORATION,
-       IL_FREESPACING,
-       IL_FORCELTR,
-       IL_LABELFONT,
-       IL_LABELSTRING,
-       IL_LATEXNAME,
-       IL_LATEXPARAM,
-       IL_LATEXTYPE,
-       IL_LYXTYPE,
-       IL_KEEPEMPTY,
-       IL_MULTIPAR,
-       IL_NEEDPROTECT,
-       IL_PASSTHRU,
-       IL_PREAMBLE,
-       IL_REQUIRES,
-       IL_END
-};
+namespace {
 
+InsetLayout::InsetDecoration translateDecoration(std::string const & str) 
+{
+       if (str == "classic")
+               return InsetLayout::Classic;
+       if (str == "minimalistic")
+               return InsetLayout::Minimalistic;
+       if (str == "conglomerate")
+               return InsetLayout::Conglomerate;
+       return InsetLayout::Default;
+}
 
-namespace {
-       InsetLayout::InsetDecoration translateDecoration(std::string const & str) 
-       {
-               if (str == "classic")
-                       return InsetLayout::Classic;
-               if (str == "minimalistic")
-                       return InsetLayout::Minimalistic;
-               if (str == "conglomerate")
-                       return InsetLayout::Conglomerate;
-               return InsetLayout::Default;
-       }
 }
 
 
-bool InsetLayout::read(Lexer & lexrc)
+bool InsetLayout::read(Lexer & lex)
 {
-       name_ = support::subst(lexrc.getDocString(), '_', ' ');
+       name_ = support::subst(lex.getDocString(), '_', ' ');
+
+       enum {
+               IL_FONT,
+               IL_BGCOLOR,
+               IL_DECORATION,
+               IL_FREESPACING,
+               IL_FORCELTR,
+               IL_LABELFONT,
+               IL_LABELSTRING,
+               IL_LATEXNAME,
+               IL_LATEXPARAM,
+               IL_LATEXTYPE,
+               IL_LYXTYPE,
+               IL_KEEPEMPTY,
+               IL_MULTIPAR,
+               IL_NEEDPROTECT,
+               IL_PASSTHRU,
+               IL_PREAMBLE,
+               IL_REQUIRES,
+               IL_END
+       };
 
-       keyword_item elementTags[] = {
+
+       LexerKeyword elementTags[] = {
                { "bgcolor", IL_BGCOLOR },
                { "decoration", IL_DECORATION },
                { "end", IL_END },
@@ -99,93 +102,83 @@ bool InsetLayout::read(Lexer & lexrc)
                { "requires", IL_REQUIRES }
        };
 
-       lexrc.pushTable(elementTags, IL_END);
+       lex.pushTable(elementTags);
 
        FontInfo font = inherit_font;
        labelfont_ = inherit_font;
        bgcolor_ = Color_background;
        bool getout = false;
-       
-       while (!getout && lexrc.isOK()) {
-               int le = lexrc.lex();
+
+       string tmp;     
+       while (!getout && lex.isOK()) {
+               int le = lex.lex();
                switch (le) {
                case Lexer::LEX_UNDEF:
-                       lexrc.printError("Unknown InsetLayout tag `$$Token'");
+                       lex.printError("Unknown InsetLayout tag");
                        continue;
-               default: break;
+               default:
+                       break;
                }
-               switch (static_cast<InsetLayoutTags>(le)) {
+               switch (le) {
                case IL_LYXTYPE:
-                       lexrc.next();
-                       lyxtype_ = lexrc.getString();
+                       lex >> lyxtype_;
                        break;
                case IL_LATEXTYPE:
-                       lexrc.next();
-                       latextype_ = lexrc.getString();
+                       lex >> latextype_;
                        break;
                case IL_LABELSTRING:
-                       lexrc.next();
-                       labelstring_ = lexrc.getDocString();
+                       lex >> labelstring_;
                        break;
                case IL_DECORATION:
-                       lexrc.next();
-                       decoration_ = translateDecoration(lexrc.getString());
+                       lex >> tmp;
+                       decoration_ = translateDecoration(tmp);
                        break;
                case IL_LATEXNAME:
-                       lexrc.next();
-                       latexname_ = lexrc.getString();
+                       lex >> latexname_;
                        break;
                case IL_LATEXPARAM:
-                       lexrc.next();
-                       latexparam_ = support::subst(lexrc.getString(), "&quot;", "\"");
+                       lex >> tmp;
+                       latexparam_ = support::subst(tmp, "&quot;", "\"");
                        break;
                case IL_LABELFONT:
-                       labelfont_ = lyxRead(lexrc, inherit_font);
+                       labelfont_ = lyxRead(lex, inherit_font);
                        break;
                case IL_FORCELTR:
-                       lexrc.next();
-                       forceltr_ = lexrc.getBool();
+                       lex >> forceltr_;
                        break;
                case IL_MULTIPAR:
-                       lexrc.next();
-                       multipar_ = lexrc.getBool();
+                       lex >> multipar_;
                        break;
                case IL_PASSTHRU:
-                       lexrc.next();
-                       passthru_ = lexrc.getBool();
+                       lex >> passthru_;
                        break;
                case IL_KEEPEMPTY:
-                       lexrc.next();
-                       keepempty_ = lexrc.getBool();
+                       lex >> keepempty_;
                        break;
                case IL_FREESPACING:
-                       lexrc.next();
-                       freespacing_ = lexrc.getBool();
+                       lex >> freespacing_;
                        break;
                case IL_NEEDPROTECT:
-                       lexrc.next();
-                       needprotect_ = lexrc.getBool();
+                       lex >> needprotect_;
                        break;
                case IL_FONT: {
-                       font_ = lyxRead(lexrc, inherit_font);
+                       font_ = lyxRead(lex, inherit_font);
                        // If you want to define labelfont, you need to do so after
                        // font is defined.
                        labelfont_ = font_;
                        break;
                }
-               case IL_BGCOLOR: {
-                       lexrc.next();
-                       string const token = lexrc.getString();
-                       bgcolor_ = lcolor.getFromLyXName(token);
+               case IL_BGCOLOR:
+                       lex >> tmp;
+                       bgcolor_ = lcolor.getFromLyXName(tmp);
                        break;
-               }
                case IL_PREAMBLE:
-                       preamble_ = lexrc.getLongString("EndPreamble");
+                       preamble_ = lex.getLongString("EndPreamble");
                        break;
                case IL_REQUIRES: {
-                       lexrc.eatLine();
+                       lex.eatLine();
                        vector<string> const req 
-                               = support::getVectorFromString(lexrc.getString());
+                               = support::getVectorFromString(lex.getString());
                        requires_.insert(req.begin(), req.end());
                        break;
                }
@@ -203,7 +196,7 @@ bool InsetLayout::read(Lexer & lexrc)
        // any realization against a given context.
        labelfont_.realize(sane_font);
 
-       lexrc.popTable();
+       lex.popTable();
        return true;
 }