]> git.lyx.org Git - lyx.git/blobdiff - src/TextClass.cpp
* GuiDocument.cpp: before accessing the buffer() in paramsToDialog(), check
[lyx.git] / src / TextClass.cpp
index 3a9ba6c664d2fe700e152c6255228403c95752cd..981dcd185c23b99d256cfca5f4add1c9fb26b8e9 100644 (file)
@@ -66,7 +66,7 @@ private:
 };
 
 // Keep the changes documented in the Customization manual. 
-int const FORMAT = 18;
+int const FORMAT = 22;
 
 
 bool layout2layout(FileName const & filename, FileName const & tempfile)
@@ -196,7 +196,8 @@ enum TextClassTags {
        TC_ADDTOHTMLPREAMBLE,
        TC_DEFAULTMODULE,
        TC_PROVIDESMODULE,
-       TC_EXCLUDESMODULE
+       TC_EXCLUDESMODULE,
+       TC_HTMLTOCSECTION
 };
 
 
@@ -215,6 +216,7 @@ namespace {
                { "float",             TC_FLOAT },
                { "format",            TC_FORMAT },
                { "htmlpreamble",      TC_HTMLPREAMBLE },
+               { "htmltocsection",    TC_HTMLTOCSECTION },
                { "ifcounter",         TC_IFCOUNTER },
                { "ifstyle",           TC_IFSTYLE },
                { "input",             TC_INPUT },
@@ -529,6 +531,10 @@ TextClass::ReturnValues TextClass::read(Lexer & lexrc, ReadType rt)
                case TC_HTMLPREAMBLE:
                        htmlpreamble_ = from_utf8(lexrc.getLongString("EndPreamble"));
                        break;
+               
+               case TC_HTMLTOCSECTION:
+                       html_toc_section_ = from_utf8(trim(lexrc.getString()));
+                       break;
 
                case TC_ADDTOPREAMBLE:
                        preamble_ += from_utf8(lexrc.getLongString("EndPreamble"));
@@ -852,8 +858,8 @@ void TextClass::readFloat(Lexer & lexrc)
                FT_LISTNAME,
                FT_BUILTIN,
                FT_HTMLSTYLE,
-               FT_HTMLCLASS,
-               FT_HTMLTYPE,
+               FT_HTMLATTR,
+               FT_HTMLTAG,
                FT_END
        };
 
@@ -861,9 +867,9 @@ void TextClass::readFloat(Lexer & lexrc)
                { "end", FT_END },
                { "extension", FT_EXT },
                { "guiname", FT_NAME },
-               { "htmlclass", FT_HTMLCLASS },
+               { "htmlattr", FT_HTMLATTR },
                { "htmlstyle", FT_HTMLSTYLE },
-               { "htmltype", FT_HTMLTYPE },
+               { "htmltag", FT_HTMLTAG },
                { "latexbuiltin", FT_BUILTIN },
                { "listname", FT_LISTNAME },
                { "numberwithin", FT_WITHIN },
@@ -875,9 +881,9 @@ void TextClass::readFloat(Lexer & lexrc)
        lexrc.pushTable(floatTags);
 
        string ext;
-       string htmlclass;
+       string htmlattr;
        string htmlstyle;
-       string htmltype;
+       string htmltag;
        string listName;
        string name;
        string placement;
@@ -940,17 +946,17 @@ void TextClass::readFloat(Lexer & lexrc)
                        lexrc.next();
                        builtin = lexrc.getBool();
                        break;
-               case FT_HTMLCLASS:
+               case FT_HTMLATTR:
                        lexrc.next();
-                       htmlclass = lexrc.getString();
+                       htmlattr = lexrc.getString();
                        break;
                case FT_HTMLSTYLE:
                        lexrc.next();
                        htmlstyle = lexrc.getLongString("EndHTMLStyle");
                        break;
-               case FT_HTMLTYPE:
+               case FT_HTMLTAG:
                        lexrc.next();
-                       htmltype = lexrc.getString();
+                       htmltag = lexrc.getString();
                        break;
                case FT_END:
                        getout = true;
@@ -961,7 +967,7 @@ void TextClass::readFloat(Lexer & lexrc)
        // Here if have a full float if getout == true
        if (getout) {
                Floating fl(type, placement, ext, within, style, name, 
-                               listName, htmltype, htmlclass, htmlstyle, builtin);
+                               listName, htmltag, htmlattr, htmlstyle, builtin);
                floatlist_.newFloat(fl);
                // each float has its own counter
                counters_.newCounter(from_ascii(type), from_ascii(within),
@@ -1166,6 +1172,7 @@ Layout TextClass::createBasicLayout(docstring const & name, bool unknown) const
        return *defaultLayout;
 }
 
+
 /////////////////////////////////////////////////////////////////////////
 //
 // DocumentClassBundle
@@ -1265,6 +1272,32 @@ bool DocumentClass::hasTocLevels() const
 }
 
 
+Layout const & DocumentClass::htmlTOCLayout() const
+{
+       if (html_toc_section_.empty()) {
+               // we're going to look for the layout with the minimum toclevel
+               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;
+                       // we don't want Part
+                       if (level == Layout::NOT_IN_TOC || level < 0 || level >= minlevel)
+                               continue;
+                       lay = &*lit;
+                       minlevel = level;
+               }
+               if (lay)
+                       html_toc_section_ = lay->name();
+               else
+                       // hmm. that is very odd, so we'll do our best
+                       html_toc_section_ = defaultLayoutName();
+       }
+       return operator[](html_toc_section_);
+}
+
+
 /////////////////////////////////////////////////////////////////////////
 //
 // PageSides