]> git.lyx.org Git - lyx.git/blobdiff - src/Counters.cpp
Fix text direction issue for InsetInfo in RTL context
[lyx.git] / src / Counters.cpp
index 56ab1b508c1a544e6e5762aae8190a841150e54e..3bb4d07758bbaf61828297c33388da950516b40f 100644 (file)
@@ -265,6 +265,31 @@ int Counters::value(docstring const & ctr) const
 }
 
 
+void Counters::resetSlaves(docstring const & ctr)
+{
+       CounterList::iterator it = counterList_.begin();
+       CounterList::iterator const end = counterList_.end();
+       for (; it != end; ++it) {
+               if (it->second.master() == ctr) {
+                       it->second.reset();
+                       resetSlaves(it->first);
+               }
+       }
+}
+
+
+void Counters::stepMaster(docstring const & ctr, UpdateType utype)
+{
+       CounterList::iterator it = counterList_.find(ctr);
+       if (it == counterList_.end()) {
+               lyxerr << "step: Counter does not exist: "
+                      << to_utf8(ctr) << endl;
+               return;
+       }
+       step(it->second.master(), utype);
+}
+
+
 void Counters::step(docstring const & ctr, UpdateType utype)
 {
        CounterList::iterator it = counterList_.find(ctr);
@@ -280,13 +305,8 @@ void Counters::step(docstring const & ctr, UpdateType utype)
                counter_stack_.pop_back();
                counter_stack_.push_back(ctr);
        }
-       it = counterList_.begin();
-       CounterList::iterator const end = counterList_.end();
-       for (; it != end; ++it) {
-               if (it->second.master() == ctr) {
-                       it->second.reset();
-               }
-       }
+
+       resetSlaves(ctr);
 }
 
 
@@ -462,7 +482,7 @@ docstring const fnsymbolCounter(int const n)
        };
 }
 
-} // namespace anon
+} // namespace
 
 
 docstring Counters::labelItem(docstring const & ctr,
@@ -525,8 +545,6 @@ docstring Counters::flattenLabelString(docstring const & counter,
                                       string const & lang,
                                       vector<docstring> & callers) const
 {
-       docstring label;
-
        if (find(callers.begin(), callers.end(), counter) != callers.end()) {
                // recursion detected
                lyxerr << "Warning: Recursion in label for counter `"
@@ -679,4 +697,12 @@ void Counters::endEnvironment()
 }
 
 
+void swap(Counters & c1, Counters & c2)
+{
+       Counters tmp = move(c1);
+       c1 = move(c2);
+       c2 = move(tmp);
+}
+
+
 } // namespace lyx