My simple testing of Martins patch, shows that it works as expected.

Applied.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4883 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2002-08-06 22:40:59 +00:00
parent 6b5c9696b6
commit 960db78b52
7 changed files with 365 additions and 351 deletions

View File

@ -1,3 +1,11 @@
2002-08-06 Martin Vermeer <martin.vermeer@hut.fi>
* counters.[Ch]
* text2.C
* paragraph.[Ch]
* makefile.am: move counters functionality over from
text2.C/paragraph.[Ch] to counters.[Ch], and make proper C++.
2002-08-06 John Levon <levon@movementarian.org>
* WordLangTuple.h: new file for word + language code tuple
@ -82,6 +90,14 @@
* lyxfunc.C: don't check for isp_command == "none" any more, it
didn't make any sense
2002-08-06 Martin Vermeer <martin.vermeer@hut.fi>
* counters.[Ch]
* text2.C
* paragraph.[Ch]
* makefile.am: move counters functionality over
from text2.C/paragraph.[Ch] to counters.[Ch], and
make proper C++.
2002-08-02 John Levon <levon@movementarian.org>
* buffer.C: s/lyxconvert/lyx2lyx/

View File

@ -35,8 +35,6 @@ EXTRA_DIST = config.h.in stamp-h.in cheaders ext_l10n.h version.C.in \
Sectioning.C \
Variables.C \
Variables.h \
counters.C \
counters.h \
tracer.C \
tracer.h
@ -109,6 +107,8 @@ lyx_SOURCES = \
config.h.in \
converter.C \
converter.h \
counters.C \
counters.h \
debug.C \
debug.h \
encoding.C \

View File

@ -17,8 +17,10 @@
#include "counters.h"
#include "debug.h"
#include "support/lstrings.h"
using std::endl;
using std::vector;
Counter::Counter()
@ -48,7 +50,6 @@ int Counter::value() const
void Counter::step()
{
++value_;
onstep.emit();
}
@ -57,15 +58,54 @@ void Counter::reset()
value_ = 0;
}
Counters::~Counters()
string Counter::master() const
{
// We need this since we store the Counter's as pointers in
// the counterList.
for (CounterList::iterator it = counterList.begin();
it != counterList.end();
++it)
delete it->second;
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");
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");
}
@ -73,36 +113,37 @@ void Counters::newCounter(string const & newc)
{
// First check if newc already exist
CounterList::iterator cit = counterList.find(newc);
// if alrady exist give warning and return
// if already exist give warning and return
if (cit != counterList.end()) {
lyxerr << "The new counter already exist." << endl;
lyxerr << "The new counter already exists." << endl;
return;
}
counterList[newc] = new Counter;
counterList[newc];
cit = counterList.find(newc);
cit->second.setMaster("");
}
void Counters::newCounter(string const & newc, string const & oldc)
void Counters::newCounter(string const & newc, string const & masterc)
{
// First check if newc already exist
// First check if newc already exists
CounterList::iterator cit = counterList.find(newc);
// if already existant give warning and return
if (cit != counterList.end()) {
lyxerr << "The new counter already exist." << endl;
lyxerr << "The new counter already exists." << endl;
return;
}
// then check if oldc exist
CounterList::iterator it = counterList.find(oldc);
// then check if masterc exists
CounterList::iterator it = counterList.find(masterc);
// if not give warning and return
if (it == counterList.end()) {
lyxerr << "The old counter does not exist." << endl;
lyxerr << "The master counter does not exist." << endl;
return;
}
Counter * tmp = new Counter;
it->second->onstep.connect(SigC::slot(tmp,
&Counter::reset));
counterList[newc] = tmp;
counterList[newc];
cit = counterList.find(newc);
cit->second.setMaster(masterc);
}
@ -110,10 +151,10 @@ void Counters::set(string const & ctr, int val)
{
CounterList::iterator it = counterList.find(ctr);
if (it == counterList.end()) {
lyxerr << "Counter does not exist." << endl;
lyxerr << "set: Counter does not exist: " << ctr << endl;
return;
}
it->second->set(val);
it->second.set(val);
}
@ -121,10 +162,10 @@ void Counters::addto(string const & ctr, int val)
{
CounterList::iterator it = counterList.find(ctr);
if (it == counterList.end()) {
lyxerr << "Counter does not exist." << endl;
lyxerr << "addto: Counter does not exist: " << ctr << endl;
return;
}
it->second->addto(val);
it->second.addto(val);
}
@ -132,10 +173,10 @@ int Counters::value(string const & ctr) const
{
CounterList::const_iterator cit = counterList.find(ctr);
if (cit == counterList.end()) {
lyxerr << "Counter does not exist." << endl;
lyxerr << "value: Counter does not exist: " << ctr << endl;
return 0;
}
return cit->second->value();
return cit->second.value();
}
@ -143,8 +184,177 @@ void Counters::step(string const & ctr)
{
CounterList::iterator it = counterList.find(ctr);
if (it == counterList.end()) {
lyxerr << "Counter does not exist." << endl;
lyxerr << "step: Counter does not exist: " << ctr << endl;
return;
}
it->second->step();
it->second.step();
it = counterList.begin();
CounterList::iterator end = counterList.end();
for (; it != end; ++it) {
if (it->second.master() == ctr) {
it->second.reset();
}
}
}
void Counters::reset(string const & match)
{
CounterList::iterator it = counterList.begin();
CounterList::iterator end = counterList.end();
for (; it != end; ++it) {
if (it->first.find(match) != string::npos || match == "")
it->second.reset();
}
}
void Counters::copy(Counters & from, Counters & to, string const & match)
{
CounterList::iterator it = counterList.begin();
CounterList::iterator end = counterList.end();
for (; it != end; ++it) {
if (it->first.find(match) != string::npos || match == "") {
to.set(it->first, from.value(it->first));
}
}
}
namespace {
inline
char loweralphaCounter(int n)
{
if (n < 1 || n > 26)
return '?';
else
return 'a' + n - 1;
}
inline
char alphaCounter(int n)
{
if (n < 1 || n > 26)
return '?';
else
return 'A' + n - 1;
}
inline
char hebrewCounter(int n)
{
static const char hebrew[22] = {
'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è',
'é', 'ë', 'ì', 'î', 'ð', 'ñ', 'ò', 'ô', 'ö',
'÷', 'ø', 'ù', 'ú'
};
if (n < 1 || n > 22)
return '?';
else
return hebrew[n-1];
}
inline
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"
};
if (n < 1 || n > 20)
return "??";
else
return roman[n-1];
}
} // namespace anon
string Counters::labelItem(string const & ctr,
string const & numbertype,
string const & langtype,
bool first)
{
ostringstream s, 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 {
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();
}
return s.str();
}
string Counters::numberLabel(string const & ctr,
string const & numbertype,
string const & langtype,
int head)
{
ostringstream s, o;
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);
}
} else if (numbertype == "enumeration") {
ostringstream ei, eii, eiii, eiv;
//string ei, eiii, eiv;
//char eii;
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();
}
}
return s.str();
}

View File

@ -19,14 +19,11 @@
#endif
#include "LString.h"
#include <boost/signals/signal0.hpp>
#include <boost/signals/trackable.hpp>
#include <map>
#include <vector>
///
class Counter : public boost::trackable {
class Counter {
public:
///
Counter();
@ -41,10 +38,15 @@ public:
///
void reset();
///
boost::signal0<void> onstep;
private:
string master() const;
///
void setMaster(string const & m);
///
private:
int value_;
///
string master_;
};
@ -54,7 +56,9 @@ private:
class Counters {
public:
///
~Counters();
Counters();
///
//~Counters();
///
void newCounter(string const & newc);
///
@ -67,12 +71,29 @@ public:
int value(string const & ctr) const;
///
void step(string const & ctr);
// string refstep(string const & cou);
///
void reset(string const & match = "");
///
void copy(Counters & from, Counters & to, string const & match = "");
///
string labelItem(string const & ctr,
string const & labeltype,
string const & langtype = "latin",
bool first = false);
///
string numberLabel(string const & ctr,
string const & labeltype,
string const & langtype = "latin",
int head = 0);
///
std::vector<string> enums, sects;
private:
///
typedef std::map<string, Counter*> CounterList;
typedef std::map<string, Counter> CounterList;
///
CounterList counterList;
};
#endif

View File

@ -77,8 +77,6 @@ extern BufferView * current_view;
Paragraph::Paragraph()
: pimpl_(new Paragraph::Pimpl(this))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
next_ = 0;
previous_ = 0;
enumdepth = 0;
@ -92,8 +90,6 @@ Paragraph::Paragraph()
Paragraph::Paragraph(Paragraph * par)
: pimpl_(new Paragraph::Pimpl(this))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
enumdepth = 0;
itemdepth = 0;
@ -113,8 +109,6 @@ Paragraph::Paragraph(Paragraph * par)
Paragraph::Paragraph(Paragraph const & lp, bool same_ids)
: pimpl_(new Paragraph::Pimpl(*lp.pimpl_, this, same_ids))
{
for (int i = 0; i < 10; ++i)
setCounter(i, 0);
enumdepth = 0;
itemdepth = 0;
next_ = 0;
@ -2154,25 +2148,6 @@ void Paragraph::clearContents()
pimpl_->clear();
}
void Paragraph::setCounter(int i, int v)
{
pimpl_->counter_[i] = v;
}
int Paragraph::getCounter(int i) const
{
return pimpl_->counter_[i];
}
void Paragraph::incCounter(int i)
{
pimpl_->counter_[i]++;
}
void Paragraph::setChar(pos_type pos, value_type c)
{
pimpl_->setChar(pos, c);

View File

@ -19,6 +19,7 @@
#include "insets/inset.h" // Just for Inset::Code
#include "lyxfont.h" // Just for LyXFont::FONT_SIZE
#include "support/types.h"
#include "counters.h"
class ParagraphParameters;
class BufferParams;
@ -169,13 +170,6 @@ public:
///
void layout(LyXLayout_ptr const & new_layout);
///
void setCounter(int i, int v);
///
int getCounter(int i) const;
///
void incCounter(int i);
///
char enumdepth;
@ -401,6 +395,9 @@ public:
/// returns inset iterator of the first inset at or after pos.
inset_iterator InsetIterator(lyx::pos_type pos);
///
Counters ctrs;
private:
/// if anything uses this we don't want it to.
Paragraph(Paragraph const &);

View File

@ -32,6 +32,7 @@
#include "FloatList.h"
#include "language.h"
#include "ParagraphParameters.h"
#include "counters.h"
#include "insets/inseterror.h"
#include "insets/insetbib.h"
@ -387,7 +388,7 @@ void LyXText::insertParagraph(BufferView * bview, Paragraph * par,
Row * row) const
{
insertRow(row, par, 0); /* insert a new row, starting
* at postition 0 */
* at position 0 */
setCounter(bview->buffer(), par); // set the counters
@ -1211,60 +1212,6 @@ void LyXText::setParagraph(BufferView * bview,
}
char loweralphaCounter(int n)
{
if (n < 1 || n > 26)
return '?';
else
return 'a' + n - 1;
}
namespace {
inline
char alphaCounter(int n)
{
if (n < 1 || n > 26)
return '?';
else
return 'A' + n - 1;
}
inline
char hebrewCounter(int n)
{
static const char hebrew[22] = {
'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è',
'é', 'ë', 'ì', 'î', 'ð', 'ñ', 'ò', 'ô', 'ö',
'÷', 'ø', 'ù', 'ú'
};
if (n < 1 || n > 22)
return '?';
else
return hebrew[n-1];
}
inline
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"
};
if (n < 1 || n > 20)
return "??";
else
return roman[n-1];
}
} // namespace anon
// set the counter of a paragraph. This includes the labels
void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
{
@ -1274,22 +1221,18 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
// copy the prev-counters to this one,
// unless this is the first paragraph
if (par->previous()) {
for (int i = 0; i < 10; ++i) {
par->setCounter(i, par->previous()->getFirstCounter(i));
}
par->ctrs.copy(par->previous()->ctrs, par->ctrs, "");
par->params().appendix(par->previous()->params().appendix());
if (!par->params().appendix() && par->params().startOfAppendix()) {
par->params().appendix(true);
for (int i = 0; i < 10; ++i) {
par->setCounter(i, 0);
}
par->ctrs.reset("");
}
par->enumdepth = par->previous()->enumdepth;
par->itemdepth = par->previous()->itemdepth;
} else {
for (int i = 0; i < 10; ++i) {
par->setCounter(i, 0);
}
par->ctrs.reset("");
par->params().appendix(par->params().startOfAppendix());
par->enumdepth = 0;
par->itemdepth = 0;
@ -1315,11 +1258,8 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
&& par->previous()->getDepth() > par->getDepth()
&& layout->labeltype != LABEL_BIBLIO) {
par->enumdepth = par->depthHook(par->getDepth())->enumdepth;
par->setCounter(6 + par->enumdepth,
par->depthHook(par->getDepth())->getCounter(6 + par->enumdepth));
// reset the counters.A depth change is like a breaking layout
for (int i = 6 + par->enumdepth + 1; i < 10; ++i)
par->setCounter(i, 0);
par->ctrs.set(par->ctrs.enums[par->enumdepth],
par->depthHook(par->getDepth())->ctrs.value(par->ctrs.enums[par->enumdepth]));
}
if (!par->params().labelString().empty()) {
@ -1338,8 +1278,12 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
if (layout->labeltype >= LABEL_COUNTER_CHAPTER) {
int i = layout->labeltype - LABEL_COUNTER_CHAPTER;
string numbertype, langtype;
ostringstream s;
if (i >= 0 && i<= buf->params.secnumdepth) {
par->incCounter(i); // increment the counter
par->ctrs.step(par->ctrs.sects[i]);
// Is there a label? Useful for Chapter layout
if (!par->params().appendix()) {
@ -1354,195 +1298,40 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
par->params().labelString(string());
}
ostringstream s;
// Use if an integer is here less than elegant. For now.
int head = textclass.maxcounter() - LABEL_COUNTER_CHAPTER;
if (!par->params().appendix()) {
switch (2 * LABEL_COUNTER_CHAPTER -
textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
s << par->getCounter(i);
break;
case LABEL_COUNTER_SECTION:
s << par->getCounter(i - 1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBSECTION:
s << par->getCounter(i - 2) << '.'
<< par->getCounter(i - 1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBSUBSECTION:
s << par->getCounter(i - 3) << '.'
<< par->getCounter(i - 2) << '.'
<< par->getCounter(i - 1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_PARAGRAPH:
s << par->getCounter(i - 4) << '.'
<< par->getCounter(i - 3) << '.'
<< par->getCounter(i - 2) << '.'
<< par->getCounter(i - 1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBPARAGRAPH:
s << par->getCounter(i - 5) << '.'
<< par->getCounter(i - 4) << '.'
<< par->getCounter(i - 3) << '.'
<< par->getCounter(i - 2) << '.'
<< par->getCounter(i - 1) << '.'
<< par->getCounter(i);
break;
default:
// Can this ever be reached? And in the
// case it is, how can this be correct?
// (Lgb)
s << par->getCounter(i) << '.';
break;
numbertype = "sectioning";
} else {
numbertype = "appendix";
if (par->isRightToLeftPar(buf->params))
langtype = "hebrew";
else
langtype = "latin";
}
} else { // appendix
switch (2 * LABEL_COUNTER_CHAPTER - textclass.maxcounter() + i) {
case LABEL_COUNTER_CHAPTER:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i));
else
s << alphaCounter(par->getCounter(i));
break;
case LABEL_COUNTER_SECTION:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i - 1));
else
s << alphaCounter(par->getCounter(i - 1));
s << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBSECTION:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i - 2));
else
s << alphaCounter(par->getCounter(i - 2));
s << '.'
<< par->getCounter(i-1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBSUBSECTION:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i-3));
else
s << alphaCounter(par->getCounter(i-3));
s << '.'
<< par->getCounter(i-2) << '.'
<< par->getCounter(i-1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_PARAGRAPH:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i-4));
else
s << alphaCounter(par->getCounter(i-4));
s << '.'
<< par->getCounter(i-3) << '.'
<< par->getCounter(i-2) << '.'
<< par->getCounter(i-1) << '.'
<< par->getCounter(i);
break;
case LABEL_COUNTER_SUBPARAGRAPH:
if (par->isRightToLeftPar(buf->params))
s << hebrewCounter(par->getCounter(i-5));
else
s << alphaCounter(par->getCounter(i-5));
s << '.'
<< par->getCounter(i-4) << '.'
<< par->getCounter(i-3) << '.'
<< par->getCounter(i-2) << '.'
<< par->getCounter(i-1) << '.'
<< par->getCounter(i);
break;
default:
// Can this ever be reached? And in the
// case it is, how can this be correct?
// (Lgb)
s << par->getCounter(i) << '.';
break;
}
}
s << par->ctrs.numberLabel(par->ctrs.sects[i],
numbertype, langtype, head);
par->params().labelString(par->params().labelString() +s.str().c_str());
// We really want to remove the c_str as soon as
// possible...
for (i++; i < 10; ++i) {
// reset the following counters
par->setCounter(i, 0);
}
// reset enum counters
par->ctrs.reset("enum");
} else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
for (i++; i < 10; ++i) {
// reset the following counters
par->setCounter(i, 0);
}
par->ctrs.reset("enum");
} else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
par->incCounter(i + par->enumdepth);
int number = par->getCounter(i + par->enumdepth);
ostringstream s;
switch (par->enumdepth) {
case 1:
if (par->isRightToLeftPar(buf->params))
s << '('
<< hebrewCounter(number)
<< ')';
else
s << '('
<< loweralphaCounter(number)
<< ')';
break;
case 2:
if (par->isRightToLeftPar(buf->params))
s << '.' << romanCounter(number);
else
s << romanCounter(number) << '.';
break;
case 3:
if (par->isRightToLeftPar(buf->params))
s << '.'
<< alphaCounter(number);
else
s << alphaCounter(number)
<< '.';
break;
default:
if (par->isRightToLeftPar(buf->params))
s << '.' << number;
else
s << number << '.';
break;
}
par->ctrs.step(par->ctrs.enums[par->enumdepth]);
s << par->ctrs.numberLabel(par->ctrs.enums[par->enumdepth],
"enumeration", langtype);
par->params().labelString(s.str().c_str());
for (i += par->enumdepth + 1; i < 10; ++i) {
// reset the following counters
par->setCounter(i, 0);
}
}
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
int i = LABEL_COUNTER_ENUMI - LABEL_COUNTER_CHAPTER + par->enumdepth;
par->incCounter(i);
int number = par->getCounter(i);
par->ctrs.step("bibitem");
int number = par->ctrs.value("bibitem");
if (!par->bibkey) {
InsetCommandParams p("bibitem" );
par->bibkey = new InsetBibKey(p);
@ -1563,8 +1352,13 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
InsetFloat * tmp = static_cast<InsetFloat*>(par->inInset()->owner());
Floating const & fl
= floatList.getType(tmp->type());
// Why doesn't it work? -- MV
par->ctrs.step(fl.name());
// We should get the correct number here too.
s = fl.name() + " #:";
ostringstream o;
o << fl.name() << " " << par->ctrs.value(fl.name()) << ":";
s = o.str();
} else {
/* par->SetLayout(0);
s = layout->labelstring; */
@ -1576,8 +1370,9 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
/* reset the enumeration counter. They are always resetted
* when there is any other layout between */
for (int i = 6 + par->enumdepth; i < 10; ++i)
par->setCounter(i, 0);
for (int i = par->enumdepth + 1; i < 4; i++) {
par->ctrs.set(par->ctrs.enums[i], 0);
}
}
}