Don't #include "counters.h" in paragraph.h.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4892 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-08-07 16:31:45 +00:00
parent 509ed151ac
commit 22909c4ae1
4 changed files with 40 additions and 27 deletions

View File

@ -2197,3 +2197,10 @@ bool Paragraph::isFreeSpacing() const
return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE); return (pimpl_->inset_owner->owner()->lyxCode() == Inset::ERT_CODE);
return false; return false;
} }
Counters & Paragraph::counters()
{
return pimpl_->ctrs;
}

View File

@ -13,21 +13,23 @@
#pragma interface #pragma interface
#endif #endif
#include "lyxlayout_ptr_fwd.h"
#include "lyxfont.h" // Just for LyXFont::FONT_SIZE
#include "insets/inset.h" // Just for Inset::Code
#include "support/types.h"
#include "LString.h" #include "LString.h"
#include "lyxlayout_ptr_fwd.h"
#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; class BufferParams;
class TexRow;
class LaTeXFeatures;
class InsetBibKey;
class BufferView; class BufferView;
class Counters;
class InsetBibKey;
class Language; class Language;
class LaTeXFeatures;
class ParagraphParameters;
class TexRow;
// After 1.2.0 is released, during 1.3.0cvs, we enable this. And after // After 1.2.0 is released, during 1.3.0cvs, we enable this. And after
// a while we verify that reading of 1.2.x files work perfectly we remove // a while we verify that reading of 1.2.x files work perfectly we remove
@ -396,7 +398,7 @@ public:
inset_iterator InsetIterator(lyx::pos_type pos); inset_iterator InsetIterator(lyx::pos_type pos);
/// ///
Counters ctrs; Counters & counters();
private: private:
/// if anything uses this we don't want it to. /// if anything uses this we don't want it to.

View File

@ -18,6 +18,7 @@
#include "paragraph.h" #include "paragraph.h"
#include "ParagraphParameters.h" #include "ParagraphParameters.h"
#include "counters.h"
#include <boost/array.hpp> #include <boost/array.hpp>
@ -154,6 +155,9 @@ struct Paragraph::Pimpl {
static unsigned int paragraph_id; static unsigned int paragraph_id;
/// ///
ParagraphParameters params; ParagraphParameters params;
///
Counters ctrs;
private: private:
/// match a string against a particular point in the paragraph /// match a string against a particular point in the paragraph
bool isTextAt(string const & str, lyx::pos_type pos) const; bool isTextAt(string const & str, lyx::pos_type pos) const;

View File

@ -1222,17 +1222,17 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
// unless this is the first paragraph // unless this is the first paragraph
if (par->previous()) { if (par->previous()) {
par->ctrs.copy(par->previous()->ctrs, par->ctrs, ""); par->counters().copy(par->previous()->counters(), par->counters(), "");
par->params().appendix(par->previous()->params().appendix()); par->params().appendix(par->previous()->params().appendix());
if (!par->params().appendix() && par->params().startOfAppendix()) { if (!par->params().appendix() && par->params().startOfAppendix()) {
par->params().appendix(true); par->params().appendix(true);
par->ctrs.reset(""); par->counters().reset("");
} }
par->enumdepth = par->previous()->enumdepth; par->enumdepth = par->previous()->enumdepth;
par->itemdepth = par->previous()->itemdepth; par->itemdepth = par->previous()->itemdepth;
} else { } else {
par->ctrs.reset(""); par->counters().reset("");
par->params().appendix(par->params().startOfAppendix()); par->params().appendix(par->params().startOfAppendix());
par->enumdepth = 0; par->enumdepth = 0;
par->itemdepth = 0; par->itemdepth = 0;
@ -1258,8 +1258,8 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
&& par->previous()->getDepth() > par->getDepth() && par->previous()->getDepth() > par->getDepth()
&& layout->labeltype != LABEL_BIBLIO) { && layout->labeltype != LABEL_BIBLIO) {
par->enumdepth = par->depthHook(par->getDepth())->enumdepth; par->enumdepth = par->depthHook(par->getDepth())->enumdepth;
par->ctrs.set(par->ctrs.enums[par->enumdepth], par->counters().set(par->counters().enums[par->enumdepth],
par->depthHook(par->getDepth())->ctrs.value(par->ctrs.enums[par->enumdepth])); par->depthHook(par->getDepth())->counters().value(par->counters().enums[par->enumdepth]));
} }
if (!par->params().labelString().empty()) { if (!par->params().labelString().empty()) {
@ -1283,7 +1283,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
if (i >= 0 && i<= buf->params.secnumdepth) { if (i >= 0 && i<= buf->params.secnumdepth) {
par->ctrs.step(par->ctrs.sects[i]); par->counters().step(par->counters().sects[i]);
// Is there a label? Useful for Chapter layout // Is there a label? Useful for Chapter layout
if (!par->params().appendix()) { if (!par->params().appendix()) {
@ -1310,7 +1310,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
langtype = "latin"; langtype = "latin";
} }
s << par->ctrs.numberLabel(par->ctrs.sects[i], s << par->counters().numberLabel(par->counters().sects[i],
numbertype, langtype, head); numbertype, langtype, head);
par->params().labelString(par->params().labelString() +s.str().c_str()); par->params().labelString(par->params().labelString() +s.str().c_str());
@ -1318,20 +1318,20 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
// possible... // possible...
// reset enum counters // reset enum counters
par->ctrs.reset("enum"); par->counters().reset("enum");
} else if (layout->labeltype < LABEL_COUNTER_ENUMI) { } else if (layout->labeltype < LABEL_COUNTER_ENUMI) {
par->ctrs.reset("enum"); par->counters().reset("enum");
} else if (layout->labeltype == LABEL_COUNTER_ENUMI) { } else if (layout->labeltype == LABEL_COUNTER_ENUMI) {
par->ctrs.step(par->ctrs.enums[par->enumdepth]); par->counters().step(par->counters().enums[par->enumdepth]);
s << par->ctrs.numberLabel(par->ctrs.enums[par->enumdepth], s << par->counters().numberLabel(par->counters().enums[par->enumdepth],
"enumeration", langtype); "enumeration", langtype);
par->params().labelString(s.str().c_str()); par->params().labelString(s.str().c_str());
} }
} else if (layout->labeltype == LABEL_BIBLIO) {// ale970302 } else if (layout->labeltype == LABEL_BIBLIO) {// ale970302
par->ctrs.step("bibitem"); par->counters().step("bibitem");
int number = par->ctrs.value("bibitem"); int number = par->counters().value("bibitem");
if (!par->bibkey) { if (!par->bibkey) {
InsetCommandParams p("bibitem" ); InsetCommandParams p("bibitem" );
par->bibkey = new InsetBibKey(p); par->bibkey = new InsetBibKey(p);
@ -1354,10 +1354,10 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
= floatList.getType(tmp->type()); = floatList.getType(tmp->type());
// Why doesn't it work? -- MV // Why doesn't it work? -- MV
par->ctrs.step(fl.name()); par->counters().step(fl.name());
// We should get the correct number here too. // We should get the correct number here too.
ostringstream o; ostringstream o;
o << fl.name() << " " << par->ctrs.value(fl.name()) << ":"; o << fl.name() << " " << par->counters().value(fl.name()) << ":";
s = o.str(); s = o.str();
} else { } else {
/* par->SetLayout(0); /* par->SetLayout(0);
@ -1371,7 +1371,7 @@ void LyXText::setCounter(Buffer const * buf, Paragraph * par) const
/* reset the enumeration counter. They are always resetted /* reset the enumeration counter. They are always resetted
* when there is any other layout between */ * when there is any other layout between */
for (int i = par->enumdepth + 1; i < 4; i++) { for (int i = par->enumdepth + 1; i < 4; i++) {
par->ctrs.set(par->ctrs.enums[i], 0); par->counters().set(par->counters().enums[i], 0);
} }
} }
} }