]> git.lyx.org Git - features.git/commitdiff
Fix a long-standing FIXME by resetting only the counter for top-level
authorRichard Heck <rgheck@lyx.org>
Sat, 21 Jul 2012 18:14:12 +0000 (14:14 -0400)
committerRichard Heck <rgheck@lyx.org>
Sun, 22 Jul 2012 14:44:18 +0000 (10:44 -0400)
sectioning when we see an appendix. This fixes bug #8271, whose root
cause was the fact that we were resetting all the counters inside ERT.

Conflicts:
src/TextClass.h

src/Buffer.cpp
src/TextClass.cpp
src/TextClass.h
src/output_xhtml.cpp
status.20x

index c246190c09f5a9fb280a1536122aa9fd2d961495..061f00ba656321e23b3af8de611017469af73969 100644 (file)
@@ -4145,9 +4145,11 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const
        Counters & counters = textclass.counters();
 
        if (par.params().startOfAppendix()) {
-               // FIXME: only the counter corresponding to toplevel
-               // sectioning should be reset
-               counters.reset();
+               // We want to reset the counter corresponding to toplevel sectioning
+               Layout const & lay = textclass.getTOCLayout();
+               docstring const cnt = lay.counter;
+               if (!cnt.empty())
+                       counters.reset(cnt);
                counters.appendix(true);
        }
        par.params().appendix(counters.appendix());
index 7e431b688957b328dc5d07bdf3999eb1bf96015f..a15f8bf6a4c1ca1e0f87890475f5c2e1082573ab 100644 (file)
@@ -1387,27 +1387,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_);
 }
index 6e20650cc23eec130731ecf5d7461f93e0bdc8cf..dc47192e032d87013f137d2ea485962bcaf5099c 100644 (file)
@@ -397,6 +397,8 @@ public:
        docstring const & preamble() const { return preamble_; }
        ///
        docstring const & htmlpreamble() const { return htmlpreamble_; }
+       ///
+       Layout const & getTOCLayout() const;
        /// the paragraph style to use for TOCs, Bibliography, etc
        /// we will attempt to calculate this if it was not given
        Layout const & htmlTOCLayout() const;
index b882c35aacbb297e56e5309bb6241b9044ec6190..1d604183d52b8f486802a14b67fe1b6ae9c35565 100644 (file)
@@ -947,11 +947,15 @@ void xhtmlParagraphs(Text const & text,
        while (bpit < epit) {
                ParagraphList::const_iterator par = paragraphs.constIterator(bpit);
                if (par->params().startOfAppendix()) {
-                       // FIXME: only the counter corresponding to toplevel
-                       // sectioning should be reset
-                       Counters & cnts = buf.masterBuffer()->params().documentClass().counters();
-                       cnts.reset();
-                       cnts.appendix(true);
+                       // We want to reset the counter corresponding to toplevel sectioning
+                       Layout const & lay =
+                               buf.masterBuffer()->params().documentClass().getTOCLayout();
+                       docstring const cnt = lay.counter;
+                       if (!cnt.empty()) {
+                               Counters & cnts =
+                                       buf.masterBuffer()->params().documentClass().counters();
+                               cnts.reset(cnt);
+                       }
                }
                Layout const & style = par->layout();
                ParagraphList::const_iterator const lastpar = par;
index 158370e8dde56a960f581e528f8f29864e684574..c7205663ab63947bb289bf87499b1c6fd2d1ca6c 100644 (file)
@@ -41,6 +41,8 @@ What's new
 
 * USER INTERFACE
 
+- Reset only the top-level counter when starting the appendix.
+
 - Show backends, not formats, in View>Source (bug #7652).
 
 - Allow native LyX format to be shown in View>Source.
@@ -66,6 +68,8 @@ What's new
 
 * DOCUMENT INPUT/OUTPUT
 
+- Fix assertion when start of appendix is in ERT (bug 8271).
+
 - Do not output empty language switch commands (bug 8216).
 
 - When using Turkish language, use the xkeyval package to avoid