X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextClass.cpp;h=981dcd185c23b99d256cfca5f4add1c9fb26b8e9;hb=4b7f1b3c3918cd32070c72b6d8e95a888981c7a2;hp=c73857f6e3214ecbf82f34d95bc168197ee9494d;hpb=ebfb4c09ad519401f476052996f1a2fb32fdcdae;p=lyx.git diff --git a/src/TextClass.cpp b/src/TextClass.cpp index c73857f6e3..981dcd185c 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -66,7 +66,7 @@ private: }; // Keep the changes documented in the Customization manual. -int const FORMAT = 20; +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")); @@ -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