+
+ it->second.step();
+ it = counterList.begin();
+ CounterList::iterator const end = counterList.end();
+ for (; it != end; ++it) {
+ if (it->second.master() == ctr) {
+ it->second.reset();
+ }
+ }
+}
+
+
+void Counters::reset()
+{
+ CounterList::iterator it = counterList.begin();
+ CounterList::iterator const end = counterList.end();
+ for (; it != end; ++it) {
+ it->second.reset();
+ }
+}
+
+
+void Counters::reset(docstring const & match)
+{
+ BOOST_ASSERT(!match.empty());
+
+ CounterList::iterator it = counterList.begin();
+ CounterList::iterator end = counterList.end();
+ for (; it != end; ++it) {
+ if (it->first.find(match) != string::npos)
+ it->second.reset();
+ }
+}
+
+
+void Counters::copy(Counters & from, Counters & to, docstring const & match)
+{
+ CounterList::iterator it = counterList.begin();
+ CounterList::iterator end = counterList.end();
+ for (; it != end; ++it) {
+ if (it->first.find(match) != string::npos || match == "") {
+ to.set(it->first, from.value(it->first));
+ }
+ }
+}
+
+
+namespace {
+
+char loweralphaCounter(int const n)
+{
+ if (n < 1 || n > 26)
+ return '?';
+ return 'a' + n - 1;
+}
+
+
+char alphaCounter(int const n)
+{
+ if (n < 1 || n > 26)
+ return '?';
+ return 'A' + n - 1;
+}
+
+
+char hebrewCounter(int const n)
+{
+ static const char hebrew[22] = {
+ 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è',
+ 'é', 'ë', 'ì', 'î', 'ð', 'ñ', 'ò', 'ô', 'ö',
+ '÷', 'ø', 'ù', 'ú'
+ };
+
+ if (n < 1 || n > 22)
+ return '?';
+ return hebrew[n - 1];
+}
+
+
+docstring const lowerromanCounter(int const n)
+{
+ static char const * const roman[20] = {
+ "i", "ii", "iii", "iv", "v",
+ "vi", "vii", "viii", "ix", "x",
+ "xi", "xii", "xiii", "xiv", "xv",
+ "xvi", "xvii", "xviii", "xix", "xx"
+ };
+
+ if (n < 1 || n > 20)
+ return from_ascii("??");
+ return from_ascii(roman[n - 1]);
+}
+
+
+docstring const romanCounter(int const n)
+{
+ static char const * const roman[20] = {
+ "I", "II", "III", "IV", "V",
+ "VI", "VII", "VIII", "IX", "X",
+ "XI", "XII", "XIII", "XIV", "XV",
+ "XVI", "XVII", "XVIII", "XIX", "XX"
+ };
+
+ if (n < 1 || n > 20)
+ return from_ascii("??");
+ return from_ascii(roman[n - 1]);
+}
+
+} // namespace anon
+
+
+docstring Counters::labelItem(docstring const & ctr,
+ docstring const & numbertype)
+{
+ if (counterList.find(ctr) == counterList.end()) {
+ lyxerr << "Counter "
+ << to_utf8(ctr)
+ << " does not exist." << endl;
+ return docstring();
+ }
+
+ if (numbertype == "hebrew")
+ return docstring(1, hebrewCounter(value(ctr)));
+
+ if (numbertype == "alph")
+ return docstring(1, loweralphaCounter(value(ctr)));
+
+ if (numbertype == "Alph")
+ return docstring(1, alphaCounter(value(ctr)));
+
+ if (numbertype == "roman")
+ return lowerromanCounter(value(ctr));
+
+ if (numbertype == "Roman")
+ return romanCounter(value(ctr));
+
+ return convert<docstring>(value(ctr));