From 09466ad2db441c030a539d5ce950a091ad137527 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 2 Dec 2010 20:22:10 +0000 Subject: [PATCH] Some cleanup of the counters code. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36663 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Counters.cpp | 23 +++++++++-------------- src/Counters.h | 4 ++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/Counters.cpp b/src/Counters.cpp index d75243e703..c4ec31b017 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -157,6 +157,13 @@ Counter::StringMap & Counter::flatLabelStrings(bool in_appendix) const } +Counters::Counters() : appendix_(false), subfloat_(false) +{ + layout_stack_.push_back(0); + counter_stack_.push_back(0); +} + + void Counters::newCounter(docstring const & newc, docstring const & masterc, docstring const & ls, @@ -269,6 +276,7 @@ void Counters::reset() it->second.reset(); counter_stack_.clear(); counter_stack_.push_back(from_ascii("")); + layout_stack_.clear(); layout_stack_.push_back(0); } @@ -598,14 +606,7 @@ void Counters::setActiveLayout(Layout const & lay) void Counters::beginEnvironment() { - docstring cnt = counter_stack_.back(); - counter_stack_.push_back(cnt); - deque::const_iterator it = counter_stack_.begin(); - deque::const_iterator en = counter_stack_.end(); -// docstring d; -// for (; it != en; ++it) -// d += " --> " + *it; -// LYXERR0(counter_stack_.size() << ": " << d); + counter_stack_.push_back(counter_stack_.back()); } @@ -613,12 +614,6 @@ void Counters::endEnvironment() { LASSERT(!counter_stack_.empty(), return); counter_stack_.pop_back(); - deque::const_iterator it = counter_stack_.begin(); - deque::const_iterator en = counter_stack_.end(); -// docstring d; -// for (; it != en; ++it) -// d += " --> " + *it; -// LYXERR0(counter_stack_.size() << ": " << d); } diff --git a/src/Counters.h b/src/Counters.h index 509733f466..386602a0bc 100644 --- a/src/Counters.h +++ b/src/Counters.h @@ -99,7 +99,7 @@ private: class Counters { public: /// - Counters() : appendix_(false), subfloat_(false) {} + Counters(); /// Add new counter newc having masterc as its master, /// ls as its label, and lsa as its appendix label. void newCounter(docstring const & newc, @@ -174,7 +174,7 @@ public: /// Call this when entering things like footnotes, where there is now /// no "last layout" and we want to restore the "last layout" on exit. void clearLastLayout() { layout_stack_.push_back(0); } - /// Call then when existing things like footnotes. + /// Call this when existing things like footnotes. void restoreLastLayout() { layout_stack_.pop_back(); } /// void saveLastCounter() -- 2.39.2