From b0d1a6b717c428396fe204dd59ef4a31e2edb09c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Mon, 13 Aug 2007 20:29:33 +0000 Subject: [PATCH] Fix bug 409 (Add support for numbered footnotes) * src/insets/InsetFoot.cpp (updateLabels): number the footnote if (1) the footnote counter exists and (2) it is not in a title layout * lib/layouts/stdcounters.inc: add a footnote counter. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19524 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/layouts/stdcounters.inc | 4 ++++ src/insets/InsetFoot.cpp | 24 +++++++++++++++++++++++- src/insets/InsetFoot.h | 3 +++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/layouts/stdcounters.inc b/lib/layouts/stdcounters.inc index e3a14768ee..355eabbf97 100644 --- a/lib/layouts/stdcounters.inc +++ b/lib/layouts/stdcounters.inc @@ -80,3 +80,7 @@ End Counter Name listing End + +Counter + Name footnote +End diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 5bd2a9d044..a2b6cbf26c 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -10,17 +10,22 @@ */ #include +#include "debug.h" #include "InsetFoot.h" #include "Buffer.h" +#include "BufferParams.h" +#include "Counters.h" #include "gettext.h" // the following is needed just to get the layout of the enclosing // paragraph. This seems a bit too much to me (JMarc) #include "OutputParams.h" +#include "ParIterator.h" +#include "support/convert.h" #include "support/std_ostream.h" - +#include "support/lstrings.h" namespace lyx { @@ -53,6 +58,23 @@ docstring const InsetFoot::editMessage() const } +void InsetFoot::updateLabels(Buffer const & buf, ParIterator const & it) +{ + TextClass const & tclass = buf.params().getTextClass(); + Counters & cnts = tclass.counters(); + docstring const & foot = from_ascii("footnote"); + Paragraph const & outer = it.paragraph(); + if (!outer.layout()->intitle && cnts.hasCounter(foot)) { + cnts.step(foot); + //FIXME: the counter should format itself. + setLabel(support::bformat(from_ascii("%1$s %2$s"), + getLayout(buf.params()).labelstring, + convert(cnts.value(foot)))); + + } + InsetCollapsable::updateLabels(buf, it); +} + int InsetFoot::latex(Buffer const & buf, odocstream & os, OutputParams const & runparams_in) const { diff --git a/src/insets/InsetFoot.h b/src/insets/InsetFoot.h index f10c11097d..1c7b748101 100644 --- a/src/insets/InsetFoot.h +++ b/src/insets/InsetFoot.h @@ -40,6 +40,9 @@ public: OutputParams const &) const; /// virtual docstring const editMessage() const; + /// Update the counters of this inset and of its contents + void updateLabels(Buffer const &, ParIterator const &); + protected: InsetFoot(InsetFoot const &); private: