+2002-09-05 Lars Gullik Bjønnes <larsbj@gullik.net>
+
+ * text2.C (setCounter): lookup the counter with layouts latexname
+ instead of by section number.
+ (setCounter): use a hackish way to lookup the correct enum
+ counter.
+ a float name->type change
+ reset enum couners with counter name directly instead of depth value.
+
+ * counters.C (Counters): remove the push_backs, change to use the
+ float type not the float name.
+ (labelItem): remove unused string, float name->type change
+
+ * counters.h: don't include vector, loose the enums and sects vectors
+
2002-09-04 Lars Gullik Bjønnes <larsbj@gullik.net>
* lyxtextclass.C (TextClassTags): add TC_FLOAT
newCounter("paragraph", "subsubsection");
newCounter("subparagraph", "paragraph");
- sects.push_back("chapter");
- sects.push_back("section");
- sects.push_back("subsection");
- sects.push_back("subsubsection");
- sects.push_back("paragraph");
- sects.push_back("subparagraph");
-
// Enumeration counters:
newCounter("enumi");
newCounter("enumii", "enumi");
newCounter("enumiii", "enumii");
newCounter("enumiv", "enumiii");
- enums.push_back("enumi");
- enums.push_back("enumii");
- enums.push_back("enumiii");
- enums.push_back("enumiv");
-
// Biblio:
newCounter("bibitem");
// Float counters:
- newCounter("Figure");
- newCounter("Table");
+ newCounter("figure");
+ newCounter("table");
}
string const & langtype,
bool first)
{
- ostringstream s, o;
+ ostringstream s;
+ ostringstream o;
+
CounterList::iterator it = counterList.find(ctr);
if (it == counterList.end()) {
lyxerr << "Counter does not exist." << endl;
return "";
}
- string mstr = it->second.master();
+
if (!first) {
s << "." << value(ctr);
} else {
} else if (ctr == "subparagraph" && head <= 5) {
s << numberLabel("paragraph", numbertype, langtype, head)
<< labelItem("subparagraph", numbertype, langtype, head == 5);
- } else if (ctr == "Figure" || ctr == "Table") {
+ } else if (ctr == "figure" || ctr == "table") {
// figure, table, ...
lyxerr << "Counter:" << ctr << endl;
s << numberLabel("chapter", numbertype, langtype, head)
#include "LString.h"
#include <map>
-#include <vector>
+
/// This represents a single counter.
class Counter {
string master() const;
/// sets the master counter for this counter
void setMaster(string const & m);
- ///
-
private:
+ ///
int value_;
/// contains master counter name; master counter is the counter
/// that, if stepped (incremented) zeroes this counter. E.g.
string const & labeltype,
string const & langtype = "latin",
int head = 0);
- /// Maps numbers to enumeration of sectioning counter name strings.
- std::vector<string> enums;
- std::vector<string> sects;
-
private:
/// Maps counter (layout) names to actual counters.
typedef std::map<string, Counter> CounterList;
if (layout->labeltype >= LABEL_COUNTER_CHAPTER) {
int i = layout->labeltype - LABEL_COUNTER_CHAPTER;
- string numbertype, langtype;
+ string numbertype;
+ string langtype;
ostringstream s;
if (i >= 0 && i <= buf->params.secnumdepth) {
- buf->counters().step(buf->counters().sects[i]);
+ buf->counters().step(layout->latexname());
// Is there a label? Useful for Chapter layout
if (!par->params().appendix()) {
langtype = "latin";
}
- s << buf->counters().numberLabel(buf->counters().sects[i],
- numbertype, langtype, head);
+ s << buf->counters()
+ .numberLabel(layout->latexname(),
+ numbertype, langtype, head);
par->params().labelString(par->params().labelString() + s.str().c_str());
// We really want to remove the c_str as soon as
} else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
buf->counters().reset("enum");
} else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
- buf->counters().step(buf->counters().enums[par->enumdepth]);
+ // FIXME
+ // Yes I know this is a really, really! bad solution
+ // (Lgb)
+ string enumcounter("enum");
+
+ switch (par->enumdepth) {
+ case 2:
+ enumcounter += 'i';
+ case 1:
+ enumcounter += 'i';
+ case 0:
+ enumcounter += 'i';
+ break;
+ case 3:
+ enumcounter += "iv";
+ break;
+ default:
+ // not a valid enumdepth...
+ break;
+ }
- s << buf->counters().numberLabel(buf->counters().enums[par->enumdepth],
- "enumeration", langtype);
- par->params().labelString(s.str().c_str());
+ buf->counters().step(enumcounter);
+ s << buf->counters()
+ .numberLabel(enumcounter,
+ "enumeration", langtype);
+ par->params().labelString(s.str().c_str());
}
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
buf->counters().step("bibitem");
int number = buf->counters().value("bibitem");
if (!par->bibkey) {
- InsetCommandParams p("bibitem" );
+ InsetCommandParams p("bibitem");
par->bibkey = new InsetBibKey(p);
}
par->bibkey->setCounter(number);
Floating const & fl
= textclass.floats().getType(static_cast<InsetFloat*>(in)->type());
- buf->counters().step(fl.name());
+ buf->counters().step(fl.type());
// Doesn't work... yet.
ostringstream o;
// reset the enumeration counter. They are always resetted
// when there is any other layout between
- for (int i = par->enumdepth; i < 4; ++i) {
- buf->counters().set(buf->counters().enums[i], 0);
+ switch (par->enumdepth) {
+ case 0:
+ buf->counters().reset("enumi");
+ case 1:
+ buf->counters().reset("enumii");
+ case 2:
+ buf->counters().reset("enumiii");
+ case 3:
+ buf->counters().reset("enumiv");
}
}
}