]> git.lyx.org Git - lyx.git/blobdiff - src/Counters.cpp
Correct the mess introduced in r33250.
[lyx.git] / src / Counters.cpp
index 626596a83301d6121dd742f625ced09751f66f4e..d6865d107d99dd6954b1e4a3d697c7449a2f8acd 100644 (file)
@@ -52,6 +52,7 @@ bool Counter::read(Lexer & lex)
                CT_WITHIN = 1,
                CT_LABELSTRING,
                CT_LABELSTRING_APPENDIX,
+               CT_PRETTYFORMAT,
                CT_END
        };
 
@@ -59,6 +60,7 @@ bool Counter::read(Lexer & lex)
                { "end", CT_END },
                { "labelstring", CT_LABELSTRING },
                { "labelstringappendix", CT_LABELSTRING_APPENDIX },
+               { "prettyformat", CT_PRETTYFORMAT },
                { "within", CT_WITHIN }
        };
 
@@ -81,6 +83,10 @@ bool Counter::read(Lexer & lex)
                                if (master_ == "none")
                                        master_.erase();
                                break;
+                       case CT_PRETTYFORMAT:
+                               lex.next();
+                               prettyformat_ = lex.getDocString();
+                               break;
                        case CT_LABELSTRING:
                                lex.next();
                                labelstring_ = lex.getDocString();
@@ -539,6 +545,22 @@ docstring Counters::counterLabel(docstring const & format,
 }
 
 
+docstring Counters::prettyCounter(docstring const & name,
+                              string const & lang) const
+{
+       CounterList::const_iterator it = counterList_.find(name); 
+       if (it == counterList_.end())
+               return from_ascii("??");
+       Counter const & ctr = it->second;
+
+       docstring const value = theCounter(name, lang);
+       docstring const & format = ctr.prettyFormat();
+       if (format.empty())
+               return value;
+       return subst(format, from_ascii("##"), value);
+}
+
+
 docstring Counters::currentCounter() const
 { 
        LASSERT(!counter_stack_.empty(), /* */);