]> git.lyx.org Git - lyx.git/blobdiff - src/Counters.cpp
Rename a couple routines in preparation for more.
[lyx.git] / src / Counters.cpp
index 83fbf9a8dcda5d19dde34c4983267e1ef126a346..3921cf2890db3742cad8d6a6bbfd51dc6c0911d9 100644 (file)
@@ -21,6 +21,7 @@
 #include "support/lassert.h"
 #include "support/lstrings.h"
 
+#include <algorithm>
 #include <sstream>
 
 using namespace std;
@@ -148,8 +149,7 @@ docstring const & Counter::flatLabelString(bool in_appendix) const
 }
 
 
-docstring const & Counter::setFlatLabelStrings(docstring const & fls,
-                                              docstring const & flsa)
+void Counter::setFlatLabelStrings(docstring const & fls, docstring const & flsa)
 {
        flatlabelstring_ = fls;
        flatlabelstringappendix_ = flsa;
@@ -265,8 +265,8 @@ void Counters::reset()
                // It only needs to be done when the textclass is
                // updated, but in practice the extra work is probably
                // not noticeable (JMarc)
-               docstring const fls = flattenLabelString(it->first, false, callers);
-               docstring const flsa = flattenLabelString(it->first, true, callers);
+               docstring const fls = flattenLabelString(it->first, false, callers);
+               docstring const flsa = flattenLabelString(it->first, true, callers);
                it->second.setFlatLabelStrings(fls, flsa);
        }
 }
@@ -330,10 +330,10 @@ char hebrewCounter(int const n)
 
 
 
-//On the special cases, see http://mathworld.wolfram.com/RomanNumerals.html
-//and for a list of roman numerals up to and including 3999, see 
-//http://www.research.att.com/~njas/sequences/a006968.txt. (Thanks to Joost
-//for this info.)
+// On the special cases, see http://mathworld.wolfram.com/RomanNumerals.html
+// and for a list of roman numerals up to and including 3999, see 
+// http://www.research.att.com/~njas/sequences/a006968.txt. (Thanks to Joost
+// for this info.)
 docstring const romanCounter(int const n)
 {
        static char const * const ones[9] = {
@@ -435,11 +435,13 @@ docstring Counters::theCounter(docstring const & counter) const
        CounterList::const_iterator it = counterList_.find(counter); 
        if (it == counterList_.end())
                return from_ascii("??");
+       // FIXME: this should get translated.
        return counterLabel(it->second.flatLabelString(appendix()));
 }
 
 
-docstring Counters::flattenLabelString(docstring const & counter, bool in_appendix, 
+docstring Counters::flattenLabelString(docstring const & counter, 
+                                      bool in_appendix, 
                                       vector<docstring> & callers) const
 {
        docstring label;
@@ -478,8 +480,8 @@ docstring Counters::flattenLabelString(docstring const & counter, bool in_append
                while (k < ls.size() && lowercase(ls[k]) >= 'a' 
                       && lowercase(ls[k]) <= 'z')
                        ++k;
-               docstring const newc = ls.substr(j, k - j);
-               docstring const repl = flattenLabelString(newc, in_appendix, callers);
+               docstring const newc = ls.substr(j, k - j);
+               docstring const repl = flattenLabelString(newc, in_appendix, callers);
                ls.replace(i, k - j + 4, repl);
        }
        callers.pop_back();
@@ -504,8 +506,8 @@ docstring Counters::counterLabel(docstring const & format) const
                while (k < label.size() && lowercase(label[k]) >= 'a' 
                       && lowercase(label[k]) <= 'z')
                        ++k;
-               docstring const newc = label.substr(j, k - j);
-               docstring const repl = theCounter(newc);
+               docstring const newc = label.substr(j, k - j);
+               docstring const repl = theCounter(newc);
                label.replace(i, k - j + 4, repl);
        }
        while (true) {
@@ -522,7 +524,7 @@ docstring Counters::counterLabel(docstring const & format) const
                        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);
+               docstring const rep = labelItem(counter, numbertype);
                label = docstring(label, 0, i) + rep
                        + docstring(label, k + 1, docstring::npos);
        }