]> git.lyx.org Git - lyx.git/blobdiff - src/counters.C
* src/tabular.[Ch]: simplify plaintext methods, because there
[lyx.git] / src / counters.C
index 78dceb03a7ebe88f28dcf9803bee31b927b4f3be..72b052bd91f57731830025b6ce40d8d0c574405c 100644 (file)
@@ -66,7 +66,7 @@ void Counter::reset()
 }
 
 
-docstring Counter::master() const
+docstring const & Counter::master() const
 {
        return master_;
 }
@@ -277,29 +277,32 @@ docstring const romanCounter(int const n)
 docstring Counters::labelItem(docstring const & ctr,
                              docstring const & numbertype)
 {
-       if (counterList.find(ctr) == counterList.end()) {
+       CounterList::const_iterator const cit = counterList.find(ctr);
+       if (cit == counterList.end()) {
                lyxerr << "Counter "
                       << to_utf8(ctr)
                       << " does not exist." << endl;
                return docstring();
        }
 
+       int val = cit->second.value();
+
        if (numbertype == "hebrew")
-               return docstring(1, hebrewCounter(value(ctr)));
+               return docstring(1, hebrewCounter(val));
 
        if (numbertype == "alph")
-               return docstring(1, loweralphaCounter(value(ctr)));
+               return docstring(1, loweralphaCounter(val));
 
        if (numbertype == "Alph")
-               return docstring(1, alphaCounter(value(ctr)));
+               return docstring(1, alphaCounter(val));
 
        if (numbertype == "roman")
-               return lowerromanCounter(value(ctr));
+               return lowerromanCounter(val);
 
        if (numbertype == "Roman")
-               return romanCounter(value(ctr));
+               return romanCounter(val);
 
-       return convert<docstring>(value(ctr));
+       return convert<docstring>(val);
 }
 
 
@@ -318,12 +321,13 @@ docstring Counters::counterLabel(docstring const & format)
                if (j == docstring::npos)
                        break;
                size_t const k = label.find('}', j + 1);
-               if (k == string::npos)
+               if (k == docstring::npos)
                        break;
                docstring const numbertype(label, i + 1, j - i - 1);
                docstring const counter(label, j + 1, k - j - 1);
                docstring const rep = labelItem(counter, numbertype);
-               label = docstring(label, 0, i) + rep + docstring(label, k + 1, string::npos);
+               label = docstring(label, 0, i) + rep 
+                       + docstring(label, k + 1, docstring::npos);
                //lyxerr << "  : " << " (" << counter  << ","
                //      << numbertype << ") -> " << label << endl;
        }