Fix a long-standing FIXME by resetting only the counter for top-level

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
This commit is contained in:
Richard Heck 2012-07-21 14:14:12 -04:00
parent e5b0444bbb
commit ecb65e7038
5 changed files with 43 additions and 26 deletions

View 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());

View 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_);
}

View 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;

View 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;

View 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