On Tue, Jan 21, 2003 at 06:20:09PM +0100, Moritz Moeller-Herrmann wrote: > [...]
Here we go. Very quick&dirty and only barely functional (it takes a while after an insertion until the change has "propagated") Moritz could apply this in hid local tree and remind us during the 1.4 cycle to discuss this issue again. Andre' -- Those who desire to give up Freedom in order to gain Security, will not have, nor do they deserve, either one. (T. Jefferson)
Index: lib/layouts/stdcounters.inc =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/layouts/stdcounters.inc,v retrieving revision 1.1 diff -u -p -r1.1 stdcounters.inc --- lib/layouts/stdcounters.inc 6 Sep 2002 14:47:58 -0000 1.1 +++ lib/layouts/stdcounters.inc 21 Jan 2003 17:53:36 -0000 @@ -71,3 +71,8 @@ End Counter Name algorithm End + +Counter + Name footnote +End + Index: src/text2.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text2.C,v retrieving revision 1.269 diff -u -p -r1.269 text2.C --- src/text2.C 18 Dec 2002 14:36:28 -0000 1.269 +++ src/text2.C 21 Jan 2003 17:53:36 -0000 @@ -38,6 +38,7 @@ #include "insets/insetbib.h" #include "insets/insetspecialchar.h" #include "insets/insettext.h" +#include "insets/insetfoot.h" #include "insets/insetfloat.h" #include "insets/insetwrap.h" @@ -1170,7 +1171,6 @@ void LyXText::setCounter(Buffer const * LyXLayout_ptr const & layout = par->layout(); if (par->previous()) { - par->params().appendix(par->previous()->params().appendix()); if (!par->params().appendix() && par->params().startOfAppendix()) { par->params().appendix(true); @@ -1358,6 +1358,16 @@ void LyXText::setCounter(Buffer const * textclass.counters().reset("enumiii"); case 3: textclass.counters().reset("enumiv"); + } + } + + // search for footnotes + for (lyx::pos_type pos = 0, n = par->size(); pos < n; ++pos) { + Inset * inset = par->getInset(pos); + if (inset && inset->lyxCode() == Inset::FOOT_CODE) { + textclass.counters().step("footnote"); + static_cast<InsetFoot*>(inset) + ->number(textclass.counters().value("footnote")); } } } Index: src/text3.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v retrieving revision 1.29 diff -u -p -r1.29 text3.C --- src/text3.C 17 Jan 2003 09:57:50 -0000 1.29 +++ src/text3.C 21 Jan 2003 17:53:36 -0000 @@ -1623,7 +1623,6 @@ Inset::RESULT LyXText::dispatch(FuncRequ case LFUN_INSERT_NOTE: case LFUN_INSET_ERT: case LFUN_INSET_FLOAT: - case LFUN_INSET_FOOTNOTE: case LFUN_INSET_MARGINAL: case LFUN_INSET_MINIPAGE: case LFUN_INSET_OPTARG: @@ -1633,6 +1632,11 @@ Inset::RESULT LyXText::dispatch(FuncRequ // Open the inset, and move the current selection // inside it. doInsertInset(this, cmd, true, true); + break; + + case LFUN_INSET_FOOTNOTE: + doInsertInset(this, cmd, true, true); + bv->text->updateCounters(bv); break; case LFUN_INSERT_URL: Index: src/insets/insetfoot.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfoot.C,v retrieving revision 1.50 diff -u -p -r1.50 insetfoot.C --- src/insets/insetfoot.C 25 Sep 2002 14:26:10 -0000 1.50 +++ src/insets/insetfoot.C 21 Jan 2003 17:53:36 -0000 @@ -28,23 +28,24 @@ #include "lyxlayout.h" #include "buffer.h" #include "paragraph.h" +#include "Lsstream.h" using std::ostream; InsetFoot::InsetFoot(BufferParams const & bp) - : InsetFootlike(bp) + : InsetFootlike(bp), number_(0) { - setLabel(_("foot")); + relabel(); setInsetName("Foot"); } InsetFoot::InsetFoot(InsetFoot const & in, bool same_id) - : InsetFootlike(in, same_id) + : InsetFootlike(in, same_id), number_(0) { - setLabel(_("foot")); + relabel(); setInsetName("Foot"); } @@ -83,6 +84,20 @@ int InsetFoot::docbook(Buffer const * bu os << "<footnote>"; int const i = inset.docbook(buf, os, mixcont); os << "</footnote>"; - return i; +} + + +void InsetFoot::relabel() +{ + ostringstream os; + os << _("foot") << ": " << number_; + setLabel(os.str()); +} + + +void InsetFoot::number(int n) +{ + number_ = n; + relabel(); } Index: src/insets/insetfoot.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfoot.h,v retrieving revision 1.34 diff -u -p -r1.34 insetfoot.h --- src/insets/insetfoot.h 25 Sep 2002 14:26:10 -0000 1.34 +++ src/insets/insetfoot.h 21 Jan 2003 17:53:36 -0000 @@ -39,6 +39,15 @@ public: int docbook(Buffer const *, std::ostream &, bool mixcont) const; /// string const editMessage() const; + /// write access to number + void number(int); + /// read access to number + int number() const { return number_; } +private: + /// + void relabel(); + /// sequential number + int number_; }; #endif