X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fcounters.C;h=72b052bd91f57731830025b6ce40d8d0c574405c;hb=e7f4618bcce770369cf46335c2c7f0164b4b8857;hp=78dceb03a7ebe88f28dcf9803bee31b927b4f3be;hpb=6c300f72a217722652dc27db9108e1050028979c;p=lyx.git diff --git a/src/counters.C b/src/counters.C index 78dceb03a7..72b052bd91 100644 --- a/src/counters.C +++ b/src/counters.C @@ -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(value(ctr)); + return convert(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; }