- ostringstream s;
-
- if (numbertype == "sectioning" || numbertype == "appendix") {
- if (ctr == "chapter" && head == 0) {
- s << labelItem("chapter", numbertype, langtype, true);
- } else if (ctr == "section" && head <= 1) {
- s << numberLabel("chapter", numbertype, langtype, head)
- << labelItem("section", numbertype, langtype, head == 1);
- } else if (ctr == "subsection" && head <= 2) {
- s << numberLabel("section", numbertype, langtype, head)
- << labelItem("subsection", numbertype, langtype, head == 2);
- } else if (ctr == "subsubsection" && head <= 3) {
- s << numberLabel("subsection", numbertype, langtype, head)
- << labelItem("subsubsection", numbertype, langtype, head == 3);
- } else if (ctr == "paragraph" && head <= 4) {
- s << numberLabel("subsubsection", numbertype, langtype, head)
- << labelItem("paragraph", numbertype, langtype, head == 4);
- } else if (ctr == "subparagraph" && head <= 5) {
- s << numberLabel("paragraph", numbertype, langtype, head)
- << labelItem("subparagraph", numbertype, langtype, head == 5);
- } else if (ctr == "figure" || ctr == "table") {
- // figure, table, ...
- lyxerr << "Counter:" << ctr << endl;
- s << numberLabel("chapter", numbertype, langtype, head)
- << labelItem(ctr, numbertype, langtype, head == 1);
- }
+ string label = format;
+ while (true) {
+#ifdef WITH_WARNINGS
+#warning Using boost::regex would make this code a lot simpler... (Lgb)
+#endif
+
+ size_t const i = label.find('\\', 0);
+ if (i == string::npos)
+ break;
+ size_t const j = label.find('{', i + 1);
+ if (j == string::npos)
+ break;
+ size_t const k = label.find('}', j + 1);
+ if (k == string::npos)
+ break;
+ string const numbertype(label, i + 1, j - i - 1);
+ string const counter(label, j + 1, k - j - 1);
+ string const rep = labelItem(counter, numbertype);
+ label = string(label, 0, i) + rep + string(label, k + 1, string::npos);
+ //lyxerr << " : " << " (" << counter << ","
+ // << numbertype << ") -> " << label << endl;
+ }
+ //lyxerr << "counterLabel: " << format << " -> " << label << endl;
+ return label;
+}