]> git.lyx.org Git - lyx.git/blobdiff - src/counters.C
oops again! hopefully this works now. Time to go to bed
[lyx.git] / src / counters.C
index 8415c45081c5aa0483227dbbd1e282cc593168ad..328a279efe5525c11fcc66383df34974f2069128 100644 (file)
@@ -9,14 +9,11 @@
  *
  * ====================================================== */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include <config.h>
 
 #include "counters.h"
 #include "debug.h"
+
 #include "support/lstrings.h"
 #include "support/LAssert.h"
 
@@ -59,45 +56,19 @@ void Counter::reset()
        value_ = 0;
 }
 
+
 string Counter::master() const
 {
        return master_;
 }
 
+
 void Counter::setMaster(string const & m)
 {
        master_ = m;
 }
 
 
-Counters::Counters()
-{
-       // Ehh, should this take a textclass arg?
-
-       // Sectioning counters:
-       newCounter("part");
-       newCounter("chapter");
-       newCounter("section", "chapter");
-       newCounter("subsection", "section");
-       newCounter("subsubsection", "subsection");
-       newCounter("paragraph", "subsubsection");
-       newCounter("subparagraph", "paragraph");
-
-       // Enumeration counters:
-       newCounter("enumi");
-       newCounter("enumii", "enumi");
-       newCounter("enumiii", "enumii");
-       newCounter("enumiv", "enumiii");
-
-       // Biblio:
-       newCounter("bibitem");
-
-       // Float counters:
-       newCounter("figure");
-       newCounter("table");
-       newCounter("algorithm");
-}
-
 
 void Counters::newCounter(string const & newc)
 {
@@ -109,8 +80,6 @@ void Counters::newCounter(string const & newc)
                return;
        }
        counterList[newc];
-       cit = counterList.find(newc);
-       cit->second.setMaster("");
 }
 
 
@@ -131,9 +100,7 @@ void Counters::newCounter(string const & newc, string const & masterc)
                return;
        }
 
-       counterList[newc];
-       cit = counterList.find(newc);
-       cit->second.setMaster(masterc);
+       counterList[newc].setMaster(masterc);
 }
 
 
@@ -290,11 +257,11 @@ string Counters::labelItem(string const & ctr,
        CounterList::iterator it = counterList.find(ctr);
        if (it == counterList.end()) {
                lyxerr << "Counter does not exist." << endl;
-               return "";
+               return string();
        }
 
        if (!first) {
-               s << "." << value(ctr);
+               s << '.' << value(ctr);
        } else {
                if (numbertype == "sectioning" || numbertype == "appendix") {
                        if (numbertype == "appendix") {
@@ -307,7 +274,8 @@ string Counters::labelItem(string const & ctr,
                }
                s << o.str();
        }
-       return s.str();
+
+       return STRCONV(s.str());
 }
 
 
@@ -316,7 +284,8 @@ string Counters::numberLabel(string const & ctr,
                             string const & langtype,
                             int head)
 {
-       ostringstream s, o;
+       ostringstream s;
+
        if (numbertype == "sectioning" || numbertype == "appendix") {
                if (ctr == "chapter" && head == 0) {
                        s << labelItem("chapter", numbertype, langtype, true);
@@ -343,9 +312,11 @@ string Counters::numberLabel(string const & ctr,
                }
 
        } else if (numbertype == "enumeration") {
-               ostringstream ei, eii, eiii, eiv;
-               //string ei, eiii, eiv;
-               //char eii;
+               ostringstream ei;
+               ostringstream eii;
+               ostringstream eiii;
+               ostringstream eiv;
+
                if (langtype == "hebrew") {
                        ei << '.' << value("enumi");
                        eii << '(' << hebrewCounter(value("enumii")) << ')';
@@ -367,5 +338,6 @@ string Counters::numberLabel(string const & ctr,
                        s << eiv.str();
                }
        }
-       return s.str();
+
+       return STRCONV(s.str());
 }