A 3-digits bug for a change...

Here is a patch to number footnotes one screen. I chose to keep the
'foot' besides the number, so that the label is clearer.

The footnote will only be numbered if the "footnote" counter exists.
This allows to disable the numbering for certain classes.

I would be interested to see whether this works fine. If it turns out
to be too often off, I may have to revert the patch. We'll see.

JMarc

Index: src/insets/InsetFoot.cpp
===================================================================
--- src/insets/InsetFoot.cpp	(révision 19518)
+++ src/insets/InsetFoot.cpp	(copie de travail)
@@ -10,18 +10,23 @@
  */
 
 #include <config.h>
+#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 {
 
 using std::string;
@@ -53,6 +58,23 @@
 }
 
 
+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<docstring>(cnts.value(foot))));
+	
+	}
+	InsetCollapsable::updateLabels(buf, it);
+}
+
 int InsetFoot::latex(Buffer const & buf, odocstream & os,
 		     OutputParams const & runparams_in) const
 {
Index: src/insets/InsetFoot.h
===================================================================
--- src/insets/InsetFoot.h	(révision 19518)
+++ src/insets/InsetFoot.h	(copie de travail)
@@ -40,6 +40,9 @@
 		    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:
Index: lib/layouts/stdcounters.inc
===================================================================
--- lib/layouts/stdcounters.inc	(révision 19518)
+++ lib/layouts/stdcounters.inc	(copie de travail)
@@ -80,3 +80,7 @@
 Counter
 	Name                 listing
 End
+
+Counter
+	Name                 footnote
+End

Reply via email to