X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FTextClass.cpp;h=b352ca29542aed1bdacb4d3de312b0155983be4d;hb=b64d17e9dcaeb84a94095622c93a051e4d93eab7;hp=17e4f09c48ead4e67c95b13531e04ab6af348944;hpb=ead697d4b6c7122a2144b96712e6d2a3184f6fd8;p=lyx.git diff --git a/src/TextClass.cpp b/src/TextClass.cpp index 17e4f09c48..b352ca2954 100644 --- a/src/TextClass.cpp +++ b/src/TextClass.cpp @@ -1507,27 +1507,32 @@ bool DocumentClass::hasTocLevels() const } +Layout const & DocumentClass::getTOCLayout() const +{ + // 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) + return *lay; + // hmm. that is very odd, so we'll do our best. + return operator[](defaultLayoutName()); +} + + 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(); + html_toc_section_ = getTOCLayout().name(); } return operator[](html_toc_section_); }