]> git.lyx.org Git - lyx.git/blobdiff - src/layout.C
Fix working of the spellchecker dialog with ispell when there are no
[lyx.git] / src / layout.C
index 853114a7c2ac0d0166d3f1ca55a11c4224dbd658..b4fb05f7337277dbb499475ae90c16d2ad285fa4 100644 (file)
@@ -4,9 +4,10 @@
  *           LyX, The Document Processor
  *      
  *          Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2000 The LyX Team.
+ *          Copyright 1995-2001 The LyX Team.
  *
- * ====================================================== */
+ * ======================================================
+ */
 
 #include <config.h>
 
 #include "debug.h"
 #include "gettext.h"
 #include "support/LAssert.h"
+#include "support/lyxfunctional.h"
+#include "support/lstrings.h"
 
 using std::pair;
 using std::make_pair;
 using std::sort;
 using std::endl;
+using std::find_if;
+using std::remove_if;
 
 // Global variable: textclass table.
 LyXTextClassList textclasslist;
@@ -66,6 +71,7 @@ enum LayoutTags {
        //LT_FIRST_COUNTER,
        LT_FONT, 
        LT_FREE_SPACING, 
+       LT_PASS_THRU,
        //LT_HEADINGS,
        LT_ITEMSEP, 
        LT_KEEPEMPTY, 
@@ -77,6 +83,7 @@ enum LayoutTags {
        LT_LABELSTRING, 
        LT_LABELSTRING_APPENDIX, 
        LT_LABELTYPE,
+       LT_ENDLABELSTRING,
        LT_ENDLABELTYPE,
        LT_LATEXNAME, 
        LT_LATEXPARAM, 
@@ -128,6 +135,7 @@ LyXLayout::LyXLayout ()
        fill_bottom = false;
        newline_allowed = true;
        free_spacing = false;
+       pass_thru = false;
 }
 
 
@@ -141,6 +149,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                { "bottomsep",                  LT_BOTTOMSEP },
                { "copystyle",                  LT_COPYSTYLE },
                { "end",                        LT_END },
+               { "endlabelstring",             LT_ENDLABELSTRING },
                { "endlabeltype",               LT_ENDLABELTYPE },
                { "fill_bottom",                LT_FILL_BOTTOM },
                { "fill_top",                   LT_FILL_TOP },
@@ -168,6 +177,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                { "parindent",                  LT_PARINDENT },
                { "parsep",                     LT_PARSEP },
                { "parskip",                    LT_PARSKIP },
+               { "passthru",                   LT_PASS_THRU },
                { "preamble",                   LT_PREAMBLE },
                { "rightmargin",                LT_RIGHTMARGIN },
                { "spacing",                    LT_SPACING },
@@ -179,10 +189,10 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
        bool finished = false;
        lexrc.pushTable(layoutTags, LT_INTITLE);
        // parse style section
-       while (!finished && lexrc.IsOK() && !error) {
+       while (!finished && lexrc.isOK() && !error) {
                int le = lexrc.lex();
                // See comment in lyxrc.C.
-               switch(le) {
+               switch (le) {
                case LyXLex::LEX_FEOF:
                        continue; 
 
@@ -192,16 +202,16 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                        continue; 
                default: break;
                }
-               switch(static_cast<LayoutTags>(le)) {
+               switch (static_cast<LayoutTags>(le)) {
                case LT_END:            // end of structure
                        finished = true;
                        break;
 
                case LT_COPYSTYLE:     // initialize with a known style
                        if (lexrc.next()) {
-                               if (tclass.hasLayout(lexrc.GetString())) {
-                                       string tmpname = name_;
-                                       this->operator= (tclass.GetLayout(lexrc.GetString()));
+                               if (tclass.hasLayout(lexrc.getString())) {
+                                       string const tmpname = name_;
+                                       this->operator= (tclass.GetLayout(lexrc.getString()));
                                        name_ = tmpname;
                                } else {
                                        lexrc.printError("Cannot copy known "
@@ -212,12 +222,12 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 
                case LT_OBSOLETEDBY:     // replace with a known style
                        if (lexrc.next()) {
-                               if (tclass.hasLayout(lexrc.GetString())) {
-                                       string tmpname = name_;
-                                       this->operator= (tclass.GetLayout(lexrc.GetString()));
+                               if (tclass.hasLayout(lexrc.getString())) {
+                                       string const tmpname = name_;
+                                       this->operator= (tclass.GetLayout(lexrc.getString()));
                                        name_ = tmpname;
                                        if (obsoleted_by().empty())
-                                         obsoleted_by_ = lexrc.GetString();
+                                               obsoleted_by_ = lexrc.getString();
                                } else {
                                        lexrc.printError("Cannot replace with" 
                                                         " unknown style "
@@ -235,15 +245,15 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                        break;
 
                case LT_INTITLE:
-                       intitle = lexrc.next() && lexrc.GetInteger();
+                       intitle = lexrc.next() && lexrc.getInteger();
                        break;
                        
                case LT_NEED_PROTECT:
-                       needprotect = lexrc.next() && lexrc.GetInteger();
+                       needprotect = lexrc.next() && lexrc.getInteger();
                        break;
                        
                case LT_KEEPEMPTY:
-                       keepempty = lexrc.next() && lexrc.GetInteger();
+                       keepempty = lexrc.next() && lexrc.getInteger();
                        break;
 
                case LT_FONT:
@@ -260,7 +270,7 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                        break;
 
                case LT_NEXTNOINDENT:   // Indent next paragraph?
-                       if (lexrc.next() && lexrc.GetInteger())
+                       if (lexrc.next() && lexrc.getInteger())
                                nextnoindent = true;
                        else
                                nextnoindent = false;
@@ -268,12 +278,12 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 
                case LT_LATEXNAME:
                        if (lexrc.next())
-                               latexname_ = lexrc.GetString();
+                               latexname_ = lexrc.getString();
                        break;
                         
                case LT_LATEXPARAM:
                        if (lexrc.next())
-                               latexparam_ = lexrc.GetString();
+                               latexparam_ = lexrc.getString();
                        break;
 
                case LT_PREAMBLE:
@@ -290,73 +300,73 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
                        
                case LT_LEFTMARGIN:     // left margin type
                        if (lexrc.next())
-                               leftmargin = lexrc.GetString();
+                               leftmargin = lexrc.getString();
                        break;                  
 
                case LT_RIGHTMARGIN:    // right margin type
                        if (lexrc.next())
-                               rightmargin = lexrc.GetString();
+                               rightmargin = lexrc.getString();
                        break;
 
                case LT_LABELINDENT:    // label indenting flag
                        if (lexrc.next())
-                               labelindent = lexrc.GetString();
+                               labelindent = lexrc.getString();
                        break;
 
                case LT_PARINDENT:      // paragraph indent. flag
                        if (lexrc.next())
-                               parindent = lexrc.GetString();
+                               parindent = lexrc.getString();
                        break;
 
                case LT_PARSKIP:        // paragraph skip size
                        if (lexrc.next())
-                               parskip = lexrc.GetFloat();
+                               parskip = lexrc.getFloat();
                        break;
 
                case LT_ITEMSEP:        // item separation size
                        if (lexrc.next())
-                               itemsep = lexrc.GetFloat();
+                               itemsep = lexrc.getFloat();
                        break;
 
                case LT_TOPSEP:         // top separation size
                        if (lexrc.next())
-                               topsep = lexrc.GetFloat();
+                               topsep = lexrc.getFloat();
                        break;
 
                case LT_BOTTOMSEP:      // bottom separation size
                        if (lexrc.next())
-                               bottomsep = lexrc.GetFloat();
+                               bottomsep = lexrc.getFloat();
                        break;
 
                case LT_LABEL_BOTTOMSEP: // label bottom separation size
                        if (lexrc.next())
-                               labelbottomsep = lexrc.GetFloat();
+                               labelbottomsep = lexrc.getFloat();
                        break;
 
                case LT_LABELSEP:       // label separator
                        if (lexrc.next()) {
-                               labelsep = subst(lexrc.GetString(), 'x', ' ');
+                               labelsep = subst(lexrc.getString(), 'x', ' ');
                        }
                        break;
 
                case LT_PARSEP:         // par. separation size
                        if (lexrc.next())
-                               parsep = lexrc.GetFloat();
+                               parsep = lexrc.getFloat();
                        break;
 
                case LT_FILL_TOP:       // fill top flag
                        if (lexrc.next())
-                               fill_top = lexrc.GetInteger();
+                               fill_top = lexrc.getInteger();
                        break;
 
                case LT_FILL_BOTTOM:    // fill bottom flag
                        if (lexrc.next())
-                               fill_bottom = lexrc.GetInteger();
+                               fill_bottom = lexrc.getInteger();
                        break;
 
                case LT_NEWLINE:        // newlines allowed?
                        if (lexrc.next())
-                               newline_allowed = lexrc.GetInteger();
+                               newline_allowed = lexrc.getInteger();
                        break;
 
                case LT_ALIGN:          // paragraph align
@@ -368,17 +378,27 @@ bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass)
 
                case LT_LABELSTRING:    // label string definition
                        if (lexrc.next())
-                               labelstring_ = lexrc.GetString();
+                               labelstring_ = lexrc.getString();
+                       break;
+
+               case LT_ENDLABELSTRING: // endlabel string definition
+                       if (lexrc.next())
+                               endlabelstring_ = lexrc.getString();
                        break;
 
                case LT_LABELSTRING_APPENDIX: // label string appendix definition
                        if (lexrc.next())
-                               labelstring_appendix_ = lexrc.GetString();
+                               labelstring_appendix_ = lexrc.getString();
                        break;
 
                case LT_FREE_SPACING:   // Allow for free spacing.
                        if (lexrc.next())
-                               free_spacing = lexrc.GetInteger();
+                               free_spacing = lexrc.getInteger();
+                       break;
+
+               case LT_PASS_THRU:      // Allow for pass thru.
+                       if (lexrc.next())
+                               pass_thru = lexrc.getInteger();
                        break;
 
                case LT_SPACING: // setspace.sty
@@ -418,7 +438,7 @@ void LyXLayout::readAlign(LyXLex & lexrc)
                return; 
        default: break;
        };
-       switch(static_cast<AlignTags>(le)) {
+       switch (static_cast<AlignTags>(le)) {
        case AT_BLOCK:
                align = LYX_ALIGN_BLOCK;
                break;
@@ -450,7 +470,7 @@ void LyXLayout::readAlignPossible(LyXLex & lexrc)
 
        lexrc.pushTable(alignTags, AT_LAYOUT);
        alignpossible = LYX_ALIGN_NONE;
-       int lineno = lexrc.GetLineNo();
+       int lineno = lexrc.getLineNo();
        do {
                int le = lexrc.lex();
                switch (le) {
@@ -476,7 +496,7 @@ void LyXLayout::readAlignPossible(LyXLex & lexrc)
                        alignpossible |= LYX_ALIGN_LAYOUT;
                        break;
                }
-       } while (lineno == lexrc.GetLineNo());
+       } while (lineno == lexrc.getLineNo());
        lexrc.popTable();
 }
 
@@ -502,29 +522,6 @@ enum LabelTypeTags {
 };
 
 
-#if 0
-static keyword_item labelTypeTags[] = {
-       { "bibliography",             LA_BIBLIO },
-       { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT },
-       { "counter_chapter",          LA_COUNTER_CHAPTER },
-       { "counter_enumi",            LA_COUNTER_ENUMI },
-       { "counter_enumii",           LA_COUNTER_ENUMII },
-       { "counter_enumiii",          LA_COUNTER_ENUMIII },
-       { "counter_enumiv",           LA_COUNTER_ENUMIV },
-       { "counter_paragraph",        LA_COUNTER_PARAGRAPH },
-       { "counter_section",          LA_COUNTER_SECTION },
-       { "counter_subparagraph",     LA_COUNTER_SUBPARAGRAPH },
-       { "counter_subsection",       LA_COUNTER_SUBSECTION },
-       { "counter_subsubsection",    LA_COUNTER_SUBSUBSECTION },
-       { "manual",                   LA_MANUAL },
-       { "no_label",                 LA_NO_LABEL },
-       { "sensitive",                LA_SENSITIVE },
-       { "static",                   LA_STATIC },
-       { "top_environment",          LA_TOP_ENVIRONMENT }
-};
-#endif
-
-
 void LyXLayout::readLabelType(LyXLex & lexrc)
 {
        keyword_item labelTypeTags[] = {
@@ -610,21 +607,29 @@ void LyXLayout::readLabelType(LyXLex & lexrc)
        }
 }
 
-static keyword_item endlabelTypeTags[] = {
+
+namespace {
+
+keyword_item endlabelTypeTags[] = {
        { "box",        END_LABEL_BOX },
        { "filled_box", END_LABEL_FILLED_BOX },
-       { "no_label",   END_LABEL_NO_LABEL }
+       { "no_label",   END_LABEL_NO_LABEL },
+       { "static",     END_LABEL_STATIC }
 };
 
+} // namespace anon
+
+
 void LyXLayout::readEndLabelType(LyXLex & lexrc)
 {
        pushpophelper pph(lexrc, endlabelTypeTags,
                          END_LABEL_ENUM_LAST-END_LABEL_ENUM_FIRST+1);
        int le = lexrc.lex();
-       switch(le) {
+       switch (le) {
        case LyXLex::LEX_UNDEF:
                lexrc.printError("Unknown labeltype tag `$$Token'");
                break;
+       case END_LABEL_STATIC:
        case END_LABEL_BOX:
        case END_LABEL_FILLED_BOX:
        case END_LABEL_NO_LABEL:
@@ -637,15 +642,6 @@ void LyXLayout::readEndLabelType(LyXLex & lexrc)
        }
 }
 
-#if 0
-static keyword_item marginTags[] = {
-       { "dynamic",           MARGIN_DYNAMIC },
-       { "first_dynamic",     MARGIN_FIRST_DYNAMIC },
-       { "manual",            MARGIN_MANUAL },
-       { "right_address_box", MARGIN_RIGHT_ADDRESS_BOX },
-       { "static",            MARGIN_STATIC }
-};
-#endif
 
 void LyXLayout::readMargin(LyXLex & lexrc)
 {
@@ -660,7 +656,7 @@ void LyXLayout::readMargin(LyXLex & lexrc)
        pushpophelper pph(lexrc, marginTags, MARGIN_RIGHT_ADDRESS_BOX);
 
        int le = lexrc.lex();
-       switch(le) {
+       switch (le) {
        case LyXLex::LEX_UNDEF:
                lexrc.printError("Unknown margin type tag `$$Token'");
                return;
@@ -679,17 +675,6 @@ void LyXLayout::readMargin(LyXLex & lexrc)
 }
 
 
-#if 0
-static keyword_item latexTypeTags[] = {
-       { "command",          LATEX_COMMAND },
-       { "environment",      LATEX_ENVIRONMENT },
-       { "item_environment", LATEX_ITEM_ENVIRONMENT },
-       { "list_environment", LATEX_LIST_ENVIRONMENT },
-       { "paragraph",        LATEX_PARAGRAPH }
-};
-#endif
-
-
 void LyXLayout::readLatexType(LyXLex & lexrc)
 {
        keyword_item latexTypeTags[] = {
@@ -729,16 +714,6 @@ enum SpacingTags {
 };
 
 
-#if 0
-static keyword_item spacingTags[] = {
-       {"double",  ST_SPACING_DOUBLE },
-       {"onehalf", ST_SPACING_ONEHALF },
-       {"other",   ST_OTHER },
-       {"single",  ST_SPACING_SINGLE }
-};
-#endif
-
-
 void LyXLayout::readSpacing(LyXLex & lexrc)
 {
        keyword_item spacingTags[] = {
@@ -750,13 +725,13 @@ void LyXLayout::readSpacing(LyXLex & lexrc)
 
        pushpophelper pph(lexrc, spacingTags, ST_OTHER);
        int le = lexrc.lex();
-       switch(le) {
+       switch (le) {
        case LyXLex::LEX_UNDEF:
                lexrc.printError("Unknown spacing token `$$Token'");
                return;
        default: break;
        }
-       switch(static_cast<SpacingTags>(le)) {
+       switch (static_cast<SpacingTags>(le)) {
        case ST_SPACING_SINGLE:
                spacing.set(Spacing::Single);
                break;
@@ -768,7 +743,7 @@ void LyXLayout::readSpacing(LyXLex & lexrc)
                break;
        case ST_OTHER:
                lexrc.next();
-               spacing.set(Spacing::Other, lexrc.GetFloat());
+               spacing.set(Spacing::Other, lexrc.getFloat());
                break;
        }
 }
@@ -801,9 +776,15 @@ bool LyXTextClass::do_readStyle(LyXLex & lexrc, LyXLayout & lay)
        if (!lay.Read(lexrc, *this)) {
                // Reslove fonts
                lay.resfont = lay.font;
+#ifndef INHERIT_LANGUAGE
                lay.resfont.realize(defaultfont());
                lay.reslabelfont = lay.labelfont;
                lay.reslabelfont.realize(defaultfont());
+#else
+               lay.resfont.realize(defaultfont(), default_language);
+               lay.reslabelfont = lay.labelfont;
+               lay.reslabelfont.realize(defaultfont(), default_language);
+#endif
                return false; // no errors
        } 
        lyxerr << "Error parsing style `" << lay.name() << "'" << endl;
@@ -833,30 +814,6 @@ enum TextClassTags {
 };
 
 
-#if 0
-static keyword_item textClassTags[] = {
-       { "classoptions",    TC_CLASSOPTIONS },
-       { "columns",         TC_COLUMNS },
-       { "defaultfont",     TC_DEFAULTFONT },
-       { "input",           TC_INPUT },
-       { "leftmargin",      TC_LEFTMARGIN },
-       { "maxcounter",      TC_MAXCOUNTER },
-       { "nostyle",         TC_NOSTYLE },
-       { "outputtype",      TC_OUTPUTTYPE },
-       { "pagestyle",       TC_PAGESTYLE },
-       { "preamble",        TC_PREAMBLE },
-       { "providesamsmath", TC_PROVIDESAMSMATH },
-       { "providesmakeidx", TC_PROVIDESMAKEIDX },
-       { "providesurl",     TC_PROVIDESURL },
-       { "rightmargin",     TC_RIGHTMARGIN },
-       { "secnumdepth",     TC_SECNUMDEPTH },
-       { "sides",           TC_SIDES },
-       { "style",           TC_STYLE },
-       { "tocdepth",        TC_TOCDEPTH }
-};
-#endif
-
-
 // Reads a textclass structure from file.
 bool LyXTextClass::Read(string const & filename, bool merge)
 {
@@ -894,12 +851,12 @@ bool LyXTextClass::Read(string const & filename, bool merge)
        bool error = false;
 
         lexrc.setFile(filename);
-       if (!lexrc.IsOK()) error = true; 
+       if (!lexrc.isOK()) error = true; 
 
        // parsing
-       while (lexrc.IsOK() && !error) {
+       while (lexrc.isOK() && !error) {
                int le = lexrc.lex();
-               switch(le) {
+               switch (le) {
                case LyXLex::LEX_FEOF:
                        continue; 
 
@@ -909,7 +866,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                        continue; 
                default: break;
                }
-               switch(static_cast<TextClassTags>(le)) {
+               switch (static_cast<TextClassTags>(le)) {
                case TC_OUTPUTTYPE:   // output type definition
                        readOutputType(lexrc);
                        break;
@@ -917,7 +874,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                case TC_INPUT: // Include file
                        if (lexrc.next()) {
                                string tmp = LibFileSearch("layouts",
-                                                           lexrc.GetString(), 
+                                                           lexrc.getString(), 
                                                            "layout");
                                
                                if (Read(tmp, true)) {
@@ -930,14 +887,14 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 
                case TC_STYLE:
                        if (lexrc.next()) {
-                               string name = subst(lexrc.GetString(),
+                               string name = subst(lexrc.getString(),
                                                    '_', ' ');
                                if (hasLayout(name)) {
                                        LyXLayout & lay = GetLayout(name);
                                        error = do_readStyle(lexrc, lay);
                                } else {
                                        LyXLayout lay;
-                                       lay.name(name);
+                                       lay.setName(name);
                                        if (!(error = do_readStyle(lexrc, lay)))
                                                layoutlist.push_back(lay);
                                }
@@ -950,7 +907,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 
                case TC_NOSTYLE:
                        if (lexrc.next()) {
-                               string style = subst(lexrc.GetString(),
+                               string const style = subst(lexrc.getString(),
                                                     '_', ' ');
                                if (!delete_layout(style))
                                        lexrc.printError("Cannot delete style"
@@ -960,12 +917,12 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 
                case TC_COLUMNS:
                        if (lexrc.next())
-                               columns_ = lexrc.GetInteger();
+                               columns_ = lexrc.getInteger();
                        break;
                        
                case TC_SIDES:
                        if (lexrc.next()) {
-                               switch(lexrc.GetInteger()) {
+                               switch (lexrc.getInteger()) {
                                case 1: sides_ = OneSide; break;
                                case 2: sides_ = TwoSides; break;
                                default:
@@ -980,7 +937,7 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                        
                case TC_PAGESTYLE:
                        lexrc.next();
-                       pagestyle_ = strip(lexrc.GetString());
+                       pagestyle_ = strip(lexrc.getString());
                        break;
                        
                case TC_DEFAULTFONT:
@@ -988,7 +945,12 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                        if (!defaultfont_.resolved()) {
                                lexrc.printError("Warning: defaultfont should "
                                                 "be fully instantiated!");
+#ifndef INHERIT_LANGUAGE
                                defaultfont_.realize(LyXFont(LyXFont::ALL_SANE));
+#else
+                               defaultfont_.realize(LyXFont(LyXFont::ALL_SANE),
+                                                    default_language);
+#endif
                        }
                        break;
 
@@ -998,12 +960,12 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 
                case TC_SECNUMDEPTH:
                        lexrc.next();
-                       secnumdepth_ = lexrc.GetInteger();
+                       secnumdepth_ = lexrc.getInteger();
                        break;
 
                case TC_TOCDEPTH:
                        lexrc.next();
-                       tocdepth_ = lexrc.GetInteger();
+                       tocdepth_ = lexrc.getInteger();
                        break;
 
                        // First step to support options 
@@ -1016,28 +978,28 @@ bool LyXTextClass::Read(string const & filename, bool merge)
                        break;
 
                case TC_PROVIDESAMSMATH:
-                       if (lexrc.next() && lexrc.GetInteger())
+                       if (lexrc.next() && lexrc.getInteger())
                                provides_ |= amsmath;
                        break;
 
                case TC_PROVIDESMAKEIDX:
-                       if (lexrc.next() && lexrc.GetInteger())
+                       if (lexrc.next() && lexrc.getInteger())
                                provides_ |= makeidx;
                        break;
 
                case TC_PROVIDESURL:
-                       if (lexrc.next() && lexrc.GetInteger())
+                       if (lexrc.next() && lexrc.getInteger())
                                provides_ = url;
                        break;
 
                case TC_LEFTMARGIN:     // left margin type
                        if (lexrc.next())
-                               leftmargin_ = lexrc.GetString();
+                               leftmargin_ = lexrc.getString();
                        break;                  
 
                case TC_RIGHTMARGIN:    // right margin type
                        if (lexrc.next())
-                               rightmargin_ = lexrc.GetString();
+                               rightmargin_ = lexrc.getString();
                        break;
                }
        }       
@@ -1055,15 +1017,6 @@ bool LyXTextClass::Read(string const & filename, bool merge)
 }
 
 
-#if 0
-static keyword_item outputTypeTags[] = {
-       { "docbook", DOCBOOK },
-       { "latex", LATEX },
-       { "linuxdoc", LINUXDOC },
-       { "literate", LITERATE }
-};
-#endif
-
 void LyXTextClass::readOutputType(LyXLex & lexrc)
 {
        keyword_item outputTypeTags[] = {
@@ -1076,7 +1029,7 @@ void LyXTextClass::readOutputType(LyXLex & lexrc)
        pushpophelper pph(lexrc, outputTypeTags, LITERATE);
 
        int le = lexrc.lex();
-       switch(le) {
+       switch (le) {
        case LyXLex::LEX_UNDEF:
                lexrc.printError("Unknown output type `$$Token'");
                return;
@@ -1109,22 +1062,6 @@ enum MaxCounterTags {
 };
 
 
-#if 0
-static keyword_item maxCounterTags[] = {
-       {"counter_chapter", MC_COUNTER_CHAPTER },
-       {"counter_enumi", MC_COUNTER_ENUMI },
-       {"counter_enumii", MC_COUNTER_ENUMII },
-       {"counter_enumiii", MC_COUNTER_ENUMIII },
-       {"counter_enumiv", MC_COUNTER_ENUMIV },
-       {"counter_paragraph", MC_COUNTER_PARAGRAPH },
-       {"counter_section", MC_COUNTER_SECTION },
-       {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH },
-       {"counter_subsection", MC_COUNTER_SUBSECTION },
-       {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION }
-};
-#endif
-
-
 void LyXTextClass::readMaxCounter(LyXLex & lexrc)
 {
        keyword_item maxCounterTags[] = {
@@ -1142,7 +1079,7 @@ void LyXTextClass::readMaxCounter(LyXLex & lexrc)
 
        pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV);
        int le = lexrc.lex();
-       switch(le) {
+       switch (le) {
        case LyXLex::LEX_UNDEF:
                lexrc.printError("Unknown MaxCounter tag `$$Token'");
                return; 
@@ -1191,16 +1128,6 @@ enum ClassOptionsTags {
 };
 
 
-#if 0
-static keyword_item classOptionsTags[] = {
-       {"end", CO_END },
-       {"fontsize", CO_FONTSIZE },
-       {"other", CO_OTHER },
-       {"pagestyle", CO_PAGESTYLE }
-};
-#endif
-
-
 void LyXTextClass::readClassOptions(LyXLex & lexrc)
 {
        keyword_item classOptionsTags[] = {
@@ -1212,7 +1139,7 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
 
        lexrc.pushTable(classOptionsTags, CO_END);
        bool getout = false;
-       while (!getout && lexrc.IsOK()) {
+       while (!getout && lexrc.isOK()) {
                int le = lexrc.lex();
                switch (le) {
                case LyXLex::LEX_UNDEF:
@@ -1223,15 +1150,15 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
                switch (static_cast<ClassOptionsTags>(le)) {
                case CO_FONTSIZE:
                        lexrc.next();
-                       opt_fontsize_ = strip(lexrc.GetString());
+                       opt_fontsize_ = strip(lexrc.getString());
                        break;
                case CO_PAGESTYLE:
                        lexrc.next();
-                       opt_pagestyle_ = strip(lexrc.GetString()); 
+                       opt_pagestyle_ = strip(lexrc.getString()); 
                        break;
                case CO_OTHER:
                        lexrc.next();
-                       options_ = lexrc.GetString();
+                       options_ = lexrc.getString();
                        break;
                case CO_END:
                        getout = true;
@@ -1244,49 +1171,43 @@ void LyXTextClass::readClassOptions(LyXLex & lexrc)
 
 bool LyXTextClass::hasLayout(string const & name) const
 {
-       for (LayoutList::const_iterator cit = layoutlist.begin();
-            cit != layoutlist.end(); ++cit) {
-               if ((*cit).name() == name)
-                       return true;
-       }
-       return false;
+       return find_if(layoutlist.begin(), layoutlist.end(),
+                      lyx::compare_memfun(&LyXLayout::name, name))
+               != layoutlist.end();
 }
 
 
 LyXLayout const & LyXTextClass::GetLayout (string const & name) const
 {
-       for (LayoutList::const_iterator cit = layoutlist.begin();
-            cit != layoutlist.end(); ++cit) {
-               if ((*cit).name() == name)
-                       return (*cit);
-       }
-       Assert(false); // we actually require the name to exist.
-       return layoutlist.front();
+       LayoutList::const_iterator cit =
+               find_if(layoutlist.begin(),
+                       layoutlist.end(),
+                       lyx::compare_memfun(&LyXLayout::name, name));
+       lyx::Assert(cit != layoutlist.end()); // we require the name to exist
+       return (*cit);
 }
 
 
 LyXLayout & LyXTextClass::GetLayout(string const & name)
 {
-       for (LayoutList::iterator it = layoutlist.begin();
-            it != layoutlist.end(); ++it) {
-               if ((*it).name() == name)
-                       return (*it);
-       }
-       Assert(false); // we actually require the name to exist.
-       return layoutlist.front();
+       LayoutList::iterator it =
+               find_if(layoutlist.begin(),
+                       layoutlist.end(),
+                       lyx::compare_memfun(&LyXLayout::name, name));
+       lyx::Assert(it != layoutlist.end()); // we require the name to exist
+       return (*it);
 }
 
 
-bool LyXTextClass::delete_layout (string const & name)
+bool LyXTextClass::delete_layout(string const & name)
 {
-       for(LayoutList::iterator it = layoutlist.begin();
-           it != layoutlist.end(); ++it) {
-               if ((*it).name() == name) {
-                       layoutlist.erase(it);
-                       return true;
-               }
-       }
-       return false;
+       LayoutList::iterator it =
+               remove_if(layoutlist.begin(), layoutlist.end(),
+                         lyx::compare_memfun(&LyXLayout::name, name));
+       LayoutList::iterator end = layoutlist.end();
+       bool const ret = (it != end);
+       layoutlist.erase(it, end);
+       return ret;
 }
 
 
@@ -1296,7 +1217,7 @@ void LyXTextClass::load()
        if (loaded) return;
 
        // Read style-file
-       string real_file = LibFileSearch("layouts", name_, "layout");
+       string const real_file = LibFileSearch("layouts", name_, "layout");
 
        if (Read(real_file)) {
                lyxerr << "Error reading `"
@@ -1312,15 +1233,15 @@ void LyXTextClass::load()
 //////////////////////////////////////////
 
 // Gets textclass number from name
-pair<bool, LyXTextClassList::size_type>
+pair<bool, LyXTextClassList::size_type> const
 LyXTextClassList::NumberOfClass(string const & textclass) const
 {
-       for (ClassList::const_iterator cit = classlist.begin();
-            cit != classlist.end(); ++cit) {
-               if ((*cit).name() == textclass)
-                       return make_pair(true, cit - classlist.begin());
-       }
-       return make_pair(false, size_type(0));
+       ClassList::const_iterator cit =
+               find_if(classlist.begin(), classlist.end(),
+                       lyx::compare_memfun(&LyXTextClass::name, textclass));
+       return cit != classlist.end() ?
+               make_pair(true, size_type(cit - classlist.begin())) :
+               make_pair(false, size_type(0));
 }
 
 
@@ -1337,18 +1258,18 @@ LyXTextClassList::Style(LyXTextClassList::size_type textclass,
 
 
 // Gets layout number from name and textclass number
-pair<bool, LyXTextClass::size_type>
+pair<bool, LyXTextClass::size_type> const
 LyXTextClassList::NumberOfLayout(LyXTextClassList::size_type textclass,
                                 string const & name) const
 {
        classlist[textclass].load();
-       for(unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) {
+       for (unsigned int i = 0; i < classlist[textclass].numLayouts(); ++i) {
                if (classlist[textclass][i].name() == name)
                        return make_pair(true, i);
        }
        if (name == "dummy")
-               return make_pair(true, LYX_DUMMY_LAYOUT);
-       return make_pair(false, LyXTextClass::LayoutList::size_type(0)); // not found
+               return make_pair(true, LyXTextClassList::size_type(LYX_DUMMY_LAYOUT));
+       return make_pair(false, LyXTextClass::size_type(0)); // not found
 }
 
 
@@ -1357,7 +1278,7 @@ string const &
 LyXTextClassList::NameOfLayout(LyXTextClassList::size_type textclass,
                               LyXTextClass::size_type layout) const
 {
-       static string dummy("dummy");
+       static string const dummy("dummy");
        classlist[textclass].load();
        if (layout < classlist[textclass].numLayouts())
                return classlist[textclass][layout].name();
@@ -1369,11 +1290,11 @@ LyXTextClassList::NameOfLayout(LyXTextClassList::size_type textclass,
 string const &
 LyXTextClassList::NameOfClass(LyXTextClassList::size_type number) const
 {
-       static string dummy("dummy");
+       static string const dummy("dummy");
        if (classlist.size() == 0) {
                return dummy;
        }
-       Assert(number < classlist.size());
+       lyx::Assert(number < classlist.size());
        return classlist[number].name();
 }
 
@@ -1382,12 +1303,12 @@ LyXTextClassList::NameOfClass(LyXTextClassList::size_type number) const
 string const &
 LyXTextClassList::LatexnameOfClass(LyXTextClassList::size_type number) const
 {
-       static string dummy("dummy");
+       static string const dummy("dummy");
        classlist[number].load();
        if (classlist.size() == 0) {
                return dummy;
        }
-       Assert(number < classlist.size());
+       lyx::Assert(number < classlist.size());
        return classlist[number].latexname();
 }
 
@@ -1396,11 +1317,11 @@ LyXTextClassList::LatexnameOfClass(LyXTextClassList::size_type number) const
 string const &
 LyXTextClassList::DescOfClass(LyXTextClassList::size_type number) const
 {
-       static string dummy("dummy");
+       static string const dummy("dummy");
        if (classlist.size() == 0) {
                return dummy;
        }
-       Assert(number < classlist.size());
+       lyx::Assert(number < classlist.size());
        return classlist[number].description();
 }
 
@@ -1462,32 +1383,32 @@ bool LyXTextClassList::Read ()
                       << real_file << endl;
        }
        
-       if (!lex.IsOK()) {
+       if (!lex.isOK()) {
                lyxerr << "LyXTextClassList::Read: unable to open "
                        "textclass file  `" << MakeDisplayPath(real_file, 1000)
                       << "'\nCheck your installation. LyX can't continue."
                       << endl;
                return false;
        }
+
        bool finished = false;
-       string fname, clname, desc;
        // Parse config-file
        lyxerr[Debug::TCLASS] << "Starting parsing of textclass.lst" << endl;
-       while (lex.IsOK() && !finished) {
+       while (lex.isOK() && !finished) {
                lyxerr[Debug::TCLASS] << "\tline by line" << endl;
                switch (lex.lex()) {
                case LyXLex::LEX_FEOF:
                        finished = true;
                        break;
                default:
-                       fname = lex.GetString();
+                       string const fname = lex.getString();
                        lyxerr[Debug::TCLASS] << "Fname: " << fname << endl;
                        if (lex.next()) {
-                               clname = lex.GetString();
+                               string const clname = lex.getString();
                                lyxerr[Debug::TCLASS]
                                        << "Clname: " << clname << endl;
                                if (lex.next()) {
-                                             desc = lex.GetString();
+                                             string const desc = lex.getString();
                                              lyxerr[Debug::TCLASS]
                                                      << "Desc: " << desc << endl;
                                              // This code is run when we have
@@ -1510,7 +1431,7 @@ bool LyXTextClassList::Read ()
                lyxerr << "LyXTextClassList::Read: no textclasses found!"
                       << endl;
                WriteAlert(_("LyX wasn't able to find any layout description!"),
-                          _("Check the contents of  the file \"textclass.lst\""),
+                          _("Check the contents of the file \"textclass.lst\""),
                           _("Sorry, has to exit :-("));
                return false;
        }
@@ -1551,3 +1472,4 @@ std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p)
        }
        return os;
 }
+