This is a preliminary patch to finish the counter work. I am not that happy about the .layout syntax and there must be away to have shorter LabelString definitions but apart from that it seems to work rather well.
Not to mention that the new version saves more than 100 lines... Comments? Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson or B. Franklin or both...)
? .lyxlayout.h.swp ? 1.diff ? 2.diff ? 3.diff ? ?t ? counter.diff ? fullredraw.diff ? par-row.diff ? insets/1.diff ? support/.lyxstring.h.swp Index: BufferView_pimpl.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/BufferView_pimpl.C,v retrieving revision 1.436 diff -u -p -r1.436 BufferView_pimpl.C --- BufferView_pimpl.C 9 Sep 2003 22:13:22 -0000 1.436 +++ BufferView_pimpl.C 12 Sep 2003 13:15:09 -0000 @@ -655,7 +655,7 @@ void BufferView::Pimpl::workAreaResize() void BufferView::Pimpl::update() { - lyxerr << "BufferView::update()" << endl; + //lyxerr << "BufferView::update()" << endl; // fix cursor coordinate cache in case something went wrong if (bv_->getLyXText()) { // check needed to survive LyX startup Index: counters.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/counters.C,v retrieving revision 1.26 diff -u -p -r1.26 counters.C --- counters.C 9 Sep 2003 22:13:23 -0000 1.26 +++ counters.C 12 Sep 2003 13:15:09 -0000 @@ -12,17 +12,15 @@ #include <config.h> #include "counters.h" - #include "debug.h" #include "support/lstrings.h" +#include "support/std_sstream.h" +#include "support/tostr.h" #include <boost/assert.hpp> -#include "support/std_sstream.h" - using std::endl; - using std::ostringstream; @@ -198,27 +196,18 @@ void Counters::copy(Counters & from, Cou namespace { -inline char loweralphaCounter(int n) { - if (n < 1 || n > 26) - return '?'; - else - return 'a' + n - 1; + return (n < 1 || n > 26) ? '?' : 'a' + n - 1; } -inline char alphaCounter(int n) { - if (n < 1 || n > 26) - return '?'; - else - return 'A' + n - 1; + return (n < 1 || n > 26) ? '?' : 'A' + n - 1; } -inline char hebrewCounter(int n) { static const char hebrew[22] = { @@ -226,15 +215,12 @@ char hebrewCounter(int n) 'é', 'ë', 'ì', 'î', 'ð', 'ñ', 'ò', 'ô', 'ö', '÷', 'ø', 'ù', 'ú' }; - if (n < 1 || n > 22) - return '?'; - else - return hebrew[n-1]; + + return (n < 1 || n > 22) ? '?' : hebrew[n - 1]; } -inline -string const romanCounter(int n) +string const lowerromanCounter(int n) { static char const * roman[20] = { "i", "ii", "iii", "iv", "v", @@ -242,107 +228,107 @@ string const romanCounter(int n) "xi", "xii", "xiii", "xiv", "xv", "xvi", "xvii", "xviii", "xix", "xx" }; - if (n < 1 || n > 20) - return "??"; - else - return roman[n-1]; + + return (n < 1 || n > 20) ? "??" : roman[n - 1]; +} + + +string const romanCounter(int n) +{ + static char const * roman[20] = { + "I", "II", "III", "IV", "V", + "VI", "VII", "VIII", "IX", "X", + "XI", "XII", "XIII", "XIV", "XV", + "XVI", "XVII", "XVIII", "XIX", "XX" + }; + + return (n < 1 || n > 20) ? "??" : roman[n - 1]; } } // namespace anon -string Counters::labelItem(string const & ctr, - string const & numbertype, - string const & langtype, - bool first) +string Counters::labelItem(string const & ctr, string const & numbertype) { - ostringstream s; - ostringstream o; - - CounterList::iterator it = counterList.find(ctr); - if (it == counterList.end()) { - lyxerr << "Counter does not exist." << endl; + if (counterList.find(ctr) == counterList.end()) { + lyxerr << "Counter " << ctr << " does not exist." << endl; return string(); } - if (!first) { - s << '.' << value(ctr); - } else { - if (numbertype == "sectioning" || numbertype == "appendix") { - if (numbertype == "appendix") { - if (langtype == "hebrew") { - o << hebrewCounter(value(ctr)); - } else { - o << alphaCounter(value(ctr)); - } - } else o << value(ctr); - } - s << o.str(); - } + if (numbertype == "hebrew") + return string(1, hebrewCounter(value(ctr))); + + if (numbertype == "latin") + return string(1, loweralphaCounter(value(ctr))); + + if (numbertype == "Latin") + return string(1, alphaCounter(value(ctr))); - return STRCONV(s.str()); + if (numbertype == "roman") + return lowerromanCounter(value(ctr)); + + if (numbertype == "Roman") + return romanCounter(value(ctr)); + + return tostr(value(ctr)); } -string Counters::numberLabel(string const & ctr, - string const & numbertype, - string const & langtype, - int head) -{ - 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 Counters::counterLabel(string const & ctr, string const & format) +{ + string label = format; + while (true) { + 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 counter(label, i + 1, j - i - 1); + string numbertype(label, j + 1, k - j - 1); + string rep; + if (numbertype.empty()) + rep = counterLabel(counter, "inh: #" + counter + "#arabic#"); + else + rep = labelItem(counter, numbertype); + label = string(label, 0, i) + rep + string(label, k + 1, string::npos); + lyxerr << " : " << " (" << counter << "," + << numbertype << ") -> " << label << endl; + } + lyxerr << "counterLabel: " << ctr << " (" << format << ") -> " + << label << endl; + return label; +} - } else if (numbertype == "enumeration") { - ostringstream ei; - ostringstream eii; - ostringstream eiii; - ostringstream eiv; - - if (langtype == "hebrew") { - ei << '.' << value("enumi"); - eii << '(' << hebrewCounter(value("enumii")) << ')'; - eiii << '.' << romanCounter(value("enumiii")); - eiv << '.' << alphaCounter(value("enumiv")); - } else { - ei << value("enumi") << '.'; - eii << '(' << loweralphaCounter(value("enumii")) << ')'; - eiii << romanCounter(value("enumiii")) << '.'; - eiv << alphaCounter(value("enumiv")) << '.'; - } - if (ctr == "enumii") { - s << eii.str(); - } else if (ctr == "enumi") { - s << ei.str(); - } else if (ctr == "enumiii") { - s << eiii.str(); - } else if (ctr == "enumiv") { - s << eiv.str(); - } + +string Counters::enumLabel(string const & ctr, string const & langtype) +{ + ostringstream os; + + if (langtype == "hebrew") { + if (ctr == "enumi") + os << '.' << value("enumi"); + else if (ctr == "enumii") + os << '(' << hebrewCounter(value("enumii")) << ')'; + else if (ctr == "enumiii") + os << '.' << lowerromanCounter(value("enumiii")); + else if (ctr == "enumiv") + os << '.' << alphaCounter(value("enumiv")); + } else { + if (ctr == "enumi") + os << value("enumi") << '.'; + else if (ctr == "enumii") + os << '(' << loweralphaCounter(value("enumii")) << ')'; + else if (ctr == "enumiii") + os << lowerromanCounter(value("enumiii")) << '.'; + else if (ctr == "enumiv") + os << alphaCounter(value("enumiv")) << '.'; } - return STRCONV(s.str()); + lyxerr << "enumLabel: " << ctr << " -> " << os.str() << endl; + + return STRCONV(os.str()); } Index: counters.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/counters.h,v retrieving revision 1.15 diff -u -p -r1.15 counters.h --- counters.h 5 Sep 2003 17:22:48 -0000 1.15 +++ counters.h 12 Sep 2003 13:15:09 -0000 @@ -74,21 +74,15 @@ public: /// Copy counters whose name matches match from the &from to /// the &to array of counters. Empty string matches all. void copy(Counters & from, Counters & to, string const & match = string()); - /// A numeric label's single item, like .1 for subsection number in - /// the 2.1.4 subsubsection number label. "first" indicates if this - /// is the first item to be displayed, usually chapter or section. - string labelItem(string const & ctr, - string const & labeltype, - string const & langtype = "latin", - bool first = false); - /// A complete numeric label, like 2.1.4 for a subsubsection. - /// "head" indicates sequence number of first item to be - /// displayed, e.g. 0 for chapter, 1 for section. - string numberLabel(string const & ctr, - string const & labeltype, - string const & langtype = "latin", - int head = 0); + /// A complete expanded label, like 2.1.4 for a subsubsection + /// according to the given format + string counterLabel(string const & ctr, string const & format); + /// A complete label, like 1.a for enumerations + string enumLabel(string const & ctr, string const & langtype = "latin"); private: + /// A counter label's single item, 1 for subsection number in + /// the 2.1.4 subsubsection number label. + string labelItem(string const & ctr, string const & numbertype); /// Maps counter (layout) names to actual counters. typedef std::map<string, Counter> CounterList; /// Instantiate. Index: layout.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/layout.h,v retrieving revision 1.43 diff -u -p -r1.43 layout.h --- layout.h 23 Aug 2003 00:16:08 -0000 1.43 +++ layout.h 12 Sep 2003 13:15:09 -0000 @@ -111,17 +111,7 @@ enum LYX_LABEL_TYPES { /// LABEL_SENSITIVE, /// - LABEL_COUNTER_CHAPTER, - /// - LABEL_COUNTER_SECTION, - /// - LABEL_COUNTER_SUBSECTION, - /// - LABEL_COUNTER_SUBSUBSECTION, - /// - LABEL_COUNTER_PARAGRAPH, - /// - LABEL_COUNTER_SUBPARAGRAPH, + LABEL_COUNTER, /// LABEL_COUNTER_ENUMI, /// Index: lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.501 diff -u -p -r1.501 lyxfunc.C --- lyxfunc.C 9 Sep 2003 22:13:25 -0000 1.501 +++ lyxfunc.C 12 Sep 2003 13:15:09 -0000 @@ -1668,8 +1668,7 @@ exit_with_message: if (view()->available()) { if (view()->fitCursor()) { - lyxerr << "LyXFunc->fitCursor->update" << endl; - + //lyxerr << "LyXFunc->fitCursor->update" << endl; view()->update(); } Index: lyxlayout.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlayout.C,v retrieving revision 1.19 diff -u -p -r1.19 lyxlayout.C --- lyxlayout.C 9 Sep 2003 22:13:27 -0000 1.19 +++ lyxlayout.C 12 Sep 2003 13:15:09 -0000 @@ -55,6 +55,7 @@ enum LayoutTags { LT_LABELSEP, LT_LABELSTRING, LT_LABELSTRING_APPENDIX, + LT_LABELCOUNTER, LT_LABELTYPE, LT_ENDLABELSTRING, LT_ENDLABELTYPE, @@ -118,7 +119,7 @@ LyXLayout::LyXLayout () // Reads a layout definition from file -bool LyXLayout::Read (LyXLex & lexrc, LyXTextClass const & tclass) +bool LyXLayout::Read(LyXLex & lexrc, LyXTextClass const & tclass) { // This table is sorted alphabetically [asierra 30March96] keyword_item layoutTags[] = { @@ -138,6 +139,7 @@ bool LyXLayout::Read (LyXLex & lexrc, Ly { "itemsep", LT_ITEMSEP }, { "keepempty", LT_KEEPEMPTY }, { "labelbottomsep", LT_LABEL_BOTTOMSEP }, + { "labelcounter", LT_LABELCOUNTER }, { "labelfont", LT_LABELFONT }, { "labelindent", LT_LABELINDENT }, { "labelsep", LT_LABELSEP }, @@ -420,6 +422,11 @@ bool LyXLayout::Read (LyXLex & lexrc, Ly labelstring_appendix_ = trim(lexrc.getString()); break; + case LT_LABELCOUNTER: // name of counter to use + if (lexrc.next()) + counter = trim(lexrc.getString()); + break; + case LT_FREE_SPACING: // Allow for free spacing. if (lexrc.next()) free_spacing = lexrc.getInteger(); @@ -436,6 +443,9 @@ bool LyXLayout::Read (LyXLex & lexrc, Ly } } lexrc.popTable(); + + if (labelstring_appendix_.empty()) + labelstring_appendix_ = labelstring_; return error; } @@ -537,12 +547,7 @@ enum LabelTypeTags { LA_CENTERED_TOP_ENVIRONMENT, LA_STATIC, LA_SENSITIVE, - LA_COUNTER_CHAPTER, - LA_COUNTER_SECTION, - LA_COUNTER_SUBSECTION, - LA_COUNTER_SUBSUBSECTION, - LA_COUNTER_PARAGRAPH, - LA_COUNTER_SUBPARAGRAPH, + LA_COUNTER, LA_COUNTER_ENUMI, LA_COUNTER_ENUMII, LA_COUNTER_ENUMIII, @@ -556,16 +561,11 @@ void LyXLayout::readLabelType(LyXLex & l keyword_item labelTypeTags[] = { { "bibliography", LA_BIBLIO }, { "centered_top_environment", LA_CENTERED_TOP_ENVIRONMENT }, - { "counter_chapter", LA_COUNTER_CHAPTER }, + { "counter", LA_COUNTER }, { "counter_enumi", LA_COUNTER_ENUMI }, { "counter_enumii", LA_COUNTER_ENUMII }, { "counter_enumiii", LA_COUNTER_ENUMIII }, { "counter_enumiv", LA_COUNTER_ENUMIV }, - { "counter_paragraph", LA_COUNTER_PARAGRAPH }, - { "counter_section", LA_COUNTER_SECTION }, - { "counter_subparagraph", LA_COUNTER_SUBPARAGRAPH }, - { "counter_subsection", LA_COUNTER_SUBSECTION }, - { "counter_subsubsection", LA_COUNTER_SUBSUBSECTION }, { "manual", LA_MANUAL }, { "no_label", LA_NO_LABEL }, { "sensitive", LA_SENSITIVE }, @@ -600,23 +600,8 @@ void LyXLayout::readLabelType(LyXLex & l case LA_SENSITIVE: labeltype = LABEL_SENSITIVE; break; - case LA_COUNTER_CHAPTER: - labeltype = LABEL_COUNTER_CHAPTER; - break; - case LA_COUNTER_SECTION: - labeltype = LABEL_COUNTER_SECTION; - break; - case LA_COUNTER_SUBSECTION: - labeltype = LABEL_COUNTER_SUBSECTION; - break; - case LA_COUNTER_SUBSUBSECTION: - labeltype = LABEL_COUNTER_SUBSUBSECTION; - break; - case LA_COUNTER_PARAGRAPH: - labeltype = LABEL_COUNTER_PARAGRAPH; - break; - case LA_COUNTER_SUBPARAGRAPH: - labeltype = LABEL_COUNTER_SUBPARAGRAPH; + case LA_COUNTER: + labeltype = LABEL_COUNTER; break; case LA_COUNTER_ENUMI: labeltype = LABEL_COUNTER_ENUMI; Index: lyxlayout.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlayout.h,v retrieving revision 1.13 diff -u -p -r1.13 lyxlayout.h --- lyxlayout.h 5 Sep 2003 17:22:49 -0000 1.13 +++ lyxlayout.h 12 Sep 2003 13:15:09 -0000 @@ -173,6 +173,8 @@ public: bool intitle; /// Does this layout allow for an optional parameter? int optionalargs; + /// Which counter to step + string counter; private: /// Name of the layout/paragraph environment Index: lyxtextclass.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxtextclass.C,v retrieving revision 1.38 diff -u -p -r1.38 lyxtextclass.C --- lyxtextclass.C 9 Sep 2003 22:13:28 -0000 1.38 +++ lyxtextclass.C 12 Sep 2003 13:15:09 -0000 @@ -67,7 +67,7 @@ LyXTextClass::LyXTextClass(string const secnumdepth_ = 3; tocdepth_ = 3; pagestyle_ = "default"; - maxcounter_ = LABEL_COUNTER_CHAPTER; + maxcounter_ = 4; defaultfont_ = LyXFont(LyXFont::ALL_SANE); opt_fontsize_ = "10|11|12"; opt_pagestyle_ = "empty|plain|headings|fancy"; @@ -300,7 +300,8 @@ bool LyXTextClass::Read(string const & f break; case TC_MAXCOUNTER: - readMaxCounter(lexrc); + lexrc.next(); + maxcounter_ = lexrc.getInteger(); break; case TC_SECNUMDEPTH: @@ -463,67 +464,6 @@ enum MaxCounterTags { }; -void LyXTextClass::readMaxCounter(LyXLex & lexrc) -{ - keyword_item maxCounterTags[] = { - {"counter_chapter", MC_COUNTER_CHAPTER }, - {"counter_enumi", MC_COUNTER_ENUMI }, - {"counter_enumii", MC_COUNTER_ENUMII }, - {"counter_enumiii", MC_COUNTER_ENUMIII }, - {"counter_enumiv", MC_COUNTER_ENUMIV }, - {"counter_paragraph", MC_COUNTER_PARAGRAPH }, - {"counter_section", MC_COUNTER_SECTION }, - {"counter_subparagraph", MC_COUNTER_SUBPARAGRAPH }, - {"counter_subsection", MC_COUNTER_SUBSECTION }, - {"counter_subsubsection", MC_COUNTER_SUBSUBSECTION } - }; - - pushpophelper pph(lexrc, maxCounterTags, MC_COUNTER_ENUMIV); - - int le = lexrc.lex(); - switch (le) { - case LyXLex::LEX_UNDEF: - lexrc.printError("Unknown MaxCounter tag `$$Token'"); - return; - default: - break; - } - - switch (static_cast<MaxCounterTags>(le)) { - case MC_COUNTER_CHAPTER: - maxcounter_ = LABEL_COUNTER_CHAPTER; - break; - case MC_COUNTER_SECTION: - maxcounter_ = LABEL_COUNTER_SECTION; - break; - case MC_COUNTER_SUBSECTION: - maxcounter_ = LABEL_COUNTER_SUBSECTION; - break; - case MC_COUNTER_SUBSUBSECTION: - maxcounter_ = LABEL_COUNTER_SUBSUBSECTION; - break; - case MC_COUNTER_PARAGRAPH: - maxcounter_ = LABEL_COUNTER_PARAGRAPH; - break; - case MC_COUNTER_SUBPARAGRAPH: - maxcounter_ = LABEL_COUNTER_SUBPARAGRAPH; - break; - case MC_COUNTER_ENUMI: - maxcounter_ = LABEL_COUNTER_ENUMI; - break; - case MC_COUNTER_ENUMII: - maxcounter_ = LABEL_COUNTER_ENUMII; - break; - case MC_COUNTER_ENUMIII: - maxcounter_ = LABEL_COUNTER_ENUMIII; - break; - case MC_COUNTER_ENUMIV: - maxcounter_ = LABEL_COUNTER_ENUMIV; - break; - } -} - - enum ClassOptionsTags { CO_FONTSIZE = 1, CO_PAGESTYLE, @@ -718,7 +658,8 @@ void LyXTextClass::readCounter(LyXLex & } } - // Here if have a full float if getout == true + // Here if have a full counter if getout == true + lyxerr << "ReadCounter: '" << name << "' getout: " << getout << endl; if (getout) { if (within.empty()) { ctrs_->newCounter(name); Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.70 diff -u -p -r1.70 rowpainter.C --- rowpainter.C 9 Sep 2003 17:25:21 -0000 1.70 +++ rowpainter.C 12 Sep 2003 13:15:09 -0000 @@ -742,7 +742,7 @@ void RowPainter::paintFirst() // this is special code for the chapter layout. This is // printed in an extra row and has a pagebreak at // the top. - if (layout->labeltype == LABEL_COUNTER_CHAPTER) { + if (layout->counter == "chapter") { if (buffer.params().secnumdepth >= 0) { float spacing_val = 1.0; if (!parparams.spacing().isDefault()) { Index: text.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text.C,v retrieving revision 1.446 diff -u -p -r1.446 text.C --- text.C 9 Sep 2003 22:13:29 -0000 1.446 +++ text.C 12 Sep 2003 13:15:09 -0000 @@ -1030,9 +1030,7 @@ void LyXText::setHeightOfRow(ParagraphLi // This is special code for the chapter, since the label of this // layout is printed in an extra row - if (layout->labeltype == LABEL_COUNTER_CHAPTER - && bufparams.secnumdepth >= 0) - { + if (layout->counter == "chapter" && bufparams.secnumdepth >= 0) { float spacing_val = 1.0; if (!pit->params().spacing().isDefault()) { spacing_val = pit->params().spacing().getValue(); Index: text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.467 diff -u -p -r1.467 text2.C --- text2.C 9 Sep 2003 22:13:34 -0000 1.467 +++ text2.C 12 Sep 2003 13:15:09 -0000 @@ -876,7 +876,7 @@ void LyXText::setCounter(Buffer const & && boost::prior(pit)->getDepth() > pit->getDepth() && layout->labeltype != LABEL_BIBLIO) { pit->enumdepth = depthHook(pit, ownerParagraphs(), - pit->getDepth())->enumdepth; + pit->getDepth())->enumdepth; } if (!pit->params().labelString().empty()) { @@ -891,75 +891,54 @@ void LyXText::setCounter(Buffer const & } // is it a layout that has an automatic label? - if (layout->labeltype >= LABEL_COUNTER_CHAPTER) { - int const i = layout->labeltype - LABEL_COUNTER_CHAPTER; + if (layout->labeltype == LABEL_COUNTER) { + string numbertype; + string langtype; + + // Is there a label? Useful for Chapter layout + //if (!pit->params().appendix()) + // s << buf.B_(layout->labelstring()); + //else + // s << buf.B_(layout->labelstring_appendix()); + + // Use of an integer is here less than elegant. For now. + string format = pit->params().appendix() ? + layout->labelstring_appendix() : layout->labelstring(); + textclass.counters().step(layout->counter); + string const s = + textclass.counters().counterLabel(layout->counter, format); + //lyxerr << "LABEL_COUNTER: " << layout->counter << ": " << s << endl; + pit->params().labelString(s); + + // reset enum counters + textclass.counters().reset("enum"); + } else if (layout->labeltype < LABEL_COUNTER_ENUMI) { + textclass.counters().reset("enum"); + } else if (layout->labeltype == LABEL_COUNTER_ENUMI) { + // FIXME + // Yes I know this is a really, really! bad solution + // (Lgb) + string enumcounter = "enum"; + + switch (pit->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; + } - ostringstream s; + textclass.counters().step(enumcounter); - if (i >= 0 && i <= bufparams.secnumdepth) { - string numbertype; - string langtype; - - textclass.counters().step(layout->latexname()); - - // Is there a label? Useful for Chapter layout - if (!pit->params().appendix()) { - s << buf.B_(layout->labelstring()); - } else { - s << buf.B_(layout->labelstring_appendix()); - } - - // Use of an integer is here less than elegant. For now. - int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER; - if (!pit->params().appendix()) { - numbertype = "sectioning"; - } else { - numbertype = "appendix"; - if (pit->isRightToLeftPar(bufparams)) - langtype = "hebrew"; - else - langtype = "latin"; - } - - s << " " - << textclass.counters() - .numberLabel(layout->latexname(), - numbertype, langtype, head); - - pit->params().labelString(STRCONV(s.str())); - - // reset enum counters - textclass.counters().reset("enum"); - } else if (layout->labeltype < LABEL_COUNTER_ENUMI) { - textclass.counters().reset("enum"); - } else if (layout->labeltype == LABEL_COUNTER_ENUMI) { - // FIXME - // Yes I know this is a really, really! bad solution - // (Lgb) - string enumcounter("enum"); - - switch (pit->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; - } - - textclass.counters().step(enumcounter); - - s << textclass.counters() - .numberLabel(enumcounter, "enumeration"); - pit->params().labelString(STRCONV(s.str())); - } + pit->params().labelString(textclass.counters().enumLabel(enumcounter)); } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302 textclass.counters().step("bibitem"); int number = textclass.counters().value("bibitem"); Index: toc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/toc.C,v retrieving revision 1.32 diff -u -p -r1.32 toc.C --- toc.C 9 Sep 2003 11:24:22 -0000 1.32 +++ toc.C 12 Sep 2003 13:15:09 -0000 @@ -74,11 +74,14 @@ TocList const getTocList(Buffer const & ParConstIterator pit = buf.par_iterator_begin(); ParConstIterator end = buf.par_iterator_end(); for (; pit != end; ++pit) { + +#warning label stuff broke toc. +#if 0 + #ifdef WITH_WARNINGS #warning bogus type (Lgb) #endif char const labeltype = pit->layout()->labeltype; - if (labeltype >= LABEL_COUNTER_CHAPTER && labeltype <= LABEL_COUNTER_CHAPTER + bufparams.tocdepth) { // insert this into the table of contents @@ -87,6 +90,7 @@ TocList const getTocList(Buffer const & pit->asString(buf, true)); toclist["TOC"].push_back(item); } +#endif // For each paragraph, traverse its insets and look for // FLOAT_CODE or WRAP_CODE
#LyX 1.4.0cvs created this file. For more info see http://www.lyx.org/ \lyxformat 225 \textclass countertest \language english \inputencoding auto \fontscheme default \graphics default \paperfontsize default \spacing single \papersize Default \paperpackage a4 \use_geometry 0 \use_amsmath 1 \use_natbib 0 \use_numerical_citations 0 \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \quotes_times 2 \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes 0 \end_header \begin_layout Section a \end_layout \begin_layout Standard asa \end_layout \begin_layout Theorem acs \end_layout \begin_layout Standard asd \end_layout \begin_layout Theorem casd \end_layout \begin_layout Standard cs \end_layout \begin_layout Definition da \end_layout \begin_layout Subsection a \end_layout \begin_layout Enumerate asdc \end_layout \begin_layout Enumerate ac \end_layout \begin_layout Enumerate sdc \end_layout \begin_deeper \begin_layout Enumerate s \end_layout \begin_layout Enumerate s \end_layout \begin_layout Enumerate sad \end_layout \begin_layout Enumerate sa \end_layout \begin_layout Enumerate sd \end_layout \end_deeper \begin_layout Enumerate dca \end_layout \begin_layout Subsection a \end_layout \begin_layout Subsection a \end_layout \begin_layout Section \start_of_appendix a \end_layout \begin_layout Subsection a \end_layout \begin_layout Subsection a \end_layout \begin_layout Subsection a \end_layout \begin_layout Section a \end_layout \begin_layout Section a \end_layout \begin_layout Subsection a \end_layout \begin_layout Standard a \end_layout \begin_layout Standard \begin_inset Formula $a+\boldsymbol{\alpha}+\alpha$ \end_inset \end_layout \end_document
#% Do not delete the line below; configure depends on this # \DeclareLaTeXClass[scrartcl]{countertest} # General textclass parameters SecNumDepth 2 TocDepth 2 DefaultStyle Standard # Standard style definition Style Standard LatexName dummy ParIndent MM ParSkip 0.4 AlignPossible Block, Left, Right, Center End Input scrclass.inc NoStyle Description # Chapter style definition Style Chapter Margin Static LatexType Command LatexName chapter NeedProtect 1 NextNoIndent 1 ParSkip 0.4 TopSep 4 BottomSep 0.8 ParSep 0.8 Align Block AlignPossible Block, Left LabelType Counter LabelCounter chapter LabelString "#chapter#arabic#" LabelStringAppendix "Appendix #chapter#Latin#" OptionalArgs 1 # standard font definition Font Series Bold Size Huge EndFont End # Section style definition Style Section Margin Dynamic LatexType Command LatexName section NeedProtect 1 NextNoIndent 1 LabelSep xxx ParSkip 0.4 TopSep 1.3 BottomSep 0.7 ParSep 0.7 Align Block AlignPossible Block, Left LabelType Counter LabelCounter section LabelString "#section#arabic#" LabelStringAppendix "#section#Latin#" OptionalArgs 1 # standard font definition Font Series Bold Size Larger EndFont End # Subsection style definition Style Subsection Margin Dynamic LatexType Command LatexName subsection NeedProtect 1 NextNoIndent 1 LabelSep xxx ParSkip 0.4 TopSep 0.9 BottomSep 0.5 ParSep 0.5 Align Block AlignPossible Block, Left LabelType Counter LabelCounter subsection LabelString "#section#arabic#.#subsection#arabic#" LabelStringAppendix "#section#Latin#.#subsection#arabic#" OptionalArgs 1 # standard font definition Font Series Bold Size Large EndFont End # Subsubsection style definition Style Subsubsection Margin Dynamic LatexType Command LatexName subsubsection NeedProtect 1 NextNoIndent 1 LabelSep xxx ParSkip 0.4 TopSep 0.7 BottomSep 0.4 ParSep 0.4 Align Block AlignPossible Block, Left LabelType Counter LabelCounter subsubsection LabelString "#section#arabic#.#subsection#arabic#.#subsubsection#arabic#" LabelStringAppendix "#section#Latin#.#subsection#arabic#.#subsubsection#arabic#" OptionalArgs 1 # standard font definition Font Series Bold Size Normal EndFont End Counter Name theorem Within section End Style Theorem CopyStyle Standard Margin First_Dynamic LatexType Environment LatexName theorem NextNoIndent 1 LabelSep xx ParIndent MMM ParSkip 0.4 ItemSep 0.2 TopSep 0.7 BottomSep 0.7 ParSep 0.3 Align Block AlignPossible Block, Left LabelType Counter LabelCounter theorem LabelString "Satz #section#arabic#.#theorem#arabic#" #define the environment lyxlist Preamble \newtheorem{theorem}{Satz}[section] EndPreamble # standard font definition Font Shape Italic Size Normal EndFont # label font definition LabelFont Shape Up Series Bold Family Sans EndFont End Style Definition CopyStyle Theorem LatexName definition LabelString "Definition #section#arabic#.#theorem#arabic#" Preamble \newtheorem{definition}[theorem]{Definition} EndPreamble Font Shape Up Color Brown EndFont LabelFont Shape Up Series Bold Family Sans EndFont End