]> git.lyx.org Git - lyx.git/blobdiff - src/Counters.cpp
de.po
[lyx.git] / src / Counters.cpp
index 830c7e0b7a9ede0b933579273fad6d53ccfc5a73..144f5abbb38c4db326fe84c618b69eb31d1aa565 100644 (file)
@@ -34,15 +34,16 @@ namespace lyx {
 
 
 Counter::Counter()
-       : initial_value_(0)
+       : initial_value_(0), saved_value_(0)
 {
        reset();
 }
 
 
 Counter::Counter(docstring const & mc, docstring const & ls,
-                docstring const & lsa)
-       : initial_value_(0), master_(mc), labelstring_(ls), labelstringappendix_(lsa)
+               docstring const & lsa, docstring const & guiname)
+       : initial_value_(0), saved_value_(0), master_(mc), labelstring_(ls),
+         labelstringappendix_(lsa), guiname_(guiname)
 {
        reset();
 }
@@ -56,12 +57,14 @@ bool Counter::read(Lexer & lex)
                CT_LABELSTRING_APPENDIX,
                CT_PRETTYFORMAT,
                CT_INITIALVALUE,
+               CT_GUINAME,
                CT_END
        };
 
        LexerKeyword counterTags[] = {
                { "end", CT_END },
-         { "initialvalue", CT_INITIALVALUE},
+               { "guiname", CT_GUINAME },
+               { "initialvalue", CT_INITIALVALUE},
                { "labelstring", CT_LABELSTRING },
                { "labelstringappendix", CT_LABELSTRING_APPENDIX },
                { "prettyformat", CT_PRETTYFORMAT },
@@ -112,6 +115,10 @@ bool Counter::read(Lexer & lex)
                                lex.next();
                                labelstringappendix_ = lex.getDocString();
                                break;
+                       case CT_GUINAME:
+                               lex.next();
+                               guiname_ = lex.getDocString();
+                               break;
                        case CT_END:
                                getout = true;
                                break;
@@ -205,7 +212,8 @@ Counters::Counters() : appendix_(false), subfloat_(false), longtable_(false)
 void Counters::newCounter(docstring const & newc,
                          docstring const & masterc,
                          docstring const & ls,
-                         docstring const & lsa)
+                         docstring const & lsa,
+                         docstring const & guiname)
 {
        if (!masterc.empty() && !hasCounter(masterc)) {
                lyxerr << "Master counter does not exist: "
@@ -213,7 +221,7 @@ void Counters::newCounter(docstring const & newc,
                       << endl;
                return;
        }
-       counterList_[newc] = Counter(masterc, ls, lsa);
+       counterList_[newc] = Counter(masterc, ls, lsa, guiname);
 }
 
 
@@ -349,6 +357,22 @@ void Counters::step(docstring const & ctr, UpdateType utype)
 }
 
 
+docstring const & Counters::guiName(docstring const & cntr) const
+{
+       CounterList::const_iterator it = counterList_.find(cntr);
+       if (it == counterList_.end()) {
+               lyxerr << "step: Counter does not exist: "
+                          << to_utf8(cntr) << endl;
+               return empty_docstring();
+       }
+
+       docstring const & guiname = it->second.guiName();
+       if (guiname.empty())
+               return cntr;
+       return guiname;
+}
+
+
 void Counters::reset()
 {
        appendix_ = false;