mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
OK, the previous idea, that we don't need to check the masters of other
counters, was silly. So here we do. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37198 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
1ff710d0b6
commit
152aba682f
@ -145,6 +145,15 @@ docstring const & Counter::master() const
|
||||
}
|
||||
|
||||
|
||||
bool Counter::checkAndRemoveMaster(docstring const & cnt)
|
||||
{
|
||||
if (master_ != cnt)
|
||||
return false;
|
||||
master_ = docstring();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
docstring const & Counter::labelString(bool in_appendix) const
|
||||
{
|
||||
return in_appendix ? labelstringappendix_ : labelstring_;
|
||||
@ -296,10 +305,17 @@ void Counters::reset(docstring const & match)
|
||||
|
||||
bool Counters::remove(docstring const & cnt)
|
||||
{
|
||||
// NOTE It might be worth trying to remove this counter
|
||||
// as "master" for any counter that declares it, but we
|
||||
// don't actually need to do so.
|
||||
return counterList_.erase(cnt);
|
||||
bool retval = counterList_.erase(cnt);
|
||||
if (!retval)
|
||||
return false;
|
||||
CounterList::iterator it = counterList_.begin();
|
||||
CounterList::iterator end = counterList_.end();
|
||||
for (; it != end; ++it) {
|
||||
if (it->second.checkAndRemoveMaster(cnt))
|
||||
LYXERR(Debug::TCLASS, "Removed master counter `" +
|
||||
to_utf8(cnt) + "' from counter: " + to_utf8(it->first));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,10 @@ public:
|
||||
void reset();
|
||||
/// Returns the master counter of this counter.
|
||||
docstring const & master() const;
|
||||
/// Checks if the master counter is cnt, and if so removes
|
||||
/// it. This is used when a counter is deleted.
|
||||
/// \return whether we removed the master.
|
||||
bool checkAndRemoveMaster(docstring const & cnt);
|
||||
/// Returns a LaTeX-like string to format the counter.
|
||||
/** This is similar to what one gets in LaTeX when using
|
||||
* "\the<counter>". The \c in_appendix bool tells whether we
|
||||
|
Loading…
Reference in New Issue
Block a user