]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.cpp
Micro-optimization.
[lyx.git] / src / TextClass.cpp
index 5e077de161fb7b752c1d58e45e73b1f4638c8fe2..0cf0372b793d9896a8863179b37d69485ef38dae 100644 (file)
@@ -66,7 +66,7 @@ private:
 };
 
 // Keep the changes documented in the Customization manual. 
-int const FORMAT = 21;
+int const FORMAT = 24;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
@@ -856,10 +856,11 @@ void TextClass::readFloat(Lexer & lexrc)
                FT_WITHIN,
                FT_STYLE,
                FT_LISTNAME,
-               FT_BUILTIN,
+               FT_NEEDSFLOAT,
                FT_HTMLSTYLE,
                FT_HTMLATTR,
                FT_HTMLTAG,
+               FT_LISTCOMMAND,
                FT_END
        };
 
@@ -870,8 +871,9 @@ void TextClass::readFloat(Lexer & lexrc)
                { "htmlattr", FT_HTMLATTR },
                { "htmlstyle", FT_HTMLSTYLE },
                { "htmltag", FT_HTMLTAG },
-               { "latexbuiltin", FT_BUILTIN },
+               { "listcommand", FT_LISTCOMMAND },
                { "listname", FT_LISTNAME },
+               { "needsfloatpkg", FT_NEEDSFLOAT },
                { "numberwithin", FT_WITHIN },
                { "placement", FT_PLACEMENT },
                { "style", FT_STYLE },
@@ -885,12 +887,13 @@ void TextClass::readFloat(Lexer & lexrc)
        string htmlstyle;
        string htmltag;
        string listName;
+       string listCommand;
        string name;
        string placement;
        string style;
        string type;
        string within;
-       bool builtin = false;
+       bool needsfloat = true;
 
        bool getout = false;
        while (!getout && lexrc.isOK()) {
@@ -913,7 +916,8 @@ void TextClass::readFloat(Lexer & lexrc)
                                style = fl.style();
                                name = fl.name();
                                listName = fl.listName();
-                               builtin = fl.builtin();
+                               needsfloat = fl.needsFloatPkg();
+                               listCommand = fl.listCommand();
                        } 
                        break;
                case FT_NAME:
@@ -938,13 +942,17 @@ void TextClass::readFloat(Lexer & lexrc)
                        lexrc.next();
                        style = lexrc.getString();
                        break;
+               case FT_LISTCOMMAND:
+                       lexrc.next();
+                       listCommand = lexrc.getString();
+                       break;
                case FT_LISTNAME:
                        lexrc.next();
                        listName = lexrc.getString();
                        break;
-               case FT_BUILTIN:
+               case FT_NEEDSFLOAT:
                        lexrc.next();
-                       builtin = lexrc.getBool();
+                       needsfloat = lexrc.getBool();
                        break;
                case FT_HTMLATTR:
                        lexrc.next();
@@ -964,10 +972,15 @@ void TextClass::readFloat(Lexer & lexrc)
                }
        }
 
-       // Here if have a full float if getout == true
+       // Here we have a full float if getout == true
        if (getout) {
+               if (!needsfloat && listCommand.empty())
+                       LYXERR0("The layout does not provide a list command " <<
+                               "for the builtin float `" << type << "'. LyX will " <<
+                               "not be able to produce a float list.");
                Floating fl(type, placement, ext, within, style, name, 
-                               listName, htmltag, htmlattr, htmlstyle, builtin);
+                               listName, listCommand, htmltag, htmlattr, htmlstyle, 
+                               needsfloat);
                floatlist_.newFloat(fl);
                // each float has its own counter
                counters_.newCounter(from_ascii(type), from_ascii(within),
@@ -1276,15 +1289,14 @@ Layout const & DocumentClass::htmlTOCLayout() const
 {
        if (html_toc_section_.empty()) {
                // we're going to look for the layout with the minimum toclevel
-               // number > 0, because we don't want Part. 
-               // we'll take the first one, just because.
                TextClass::LayoutList::const_iterator lit = begin();
                TextClass::LayoutList::const_iterator const len = end();
                int minlevel = 1000;
                Layout const * lay = NULL;
                for (; lit != len; ++lit) {
                        int const level = lit->toclevel;
-                       if (level > 0 && (level == Layout::NOT_IN_TOC || level >= minlevel))
+                       // we don't want Part
+                       if (level == Layout::NOT_IN_TOC || level < 0 || level >= minlevel)
                                continue;
                        lay = &*lit;
                        minlevel = level;