]> git.lyx.org Git - features.git/commitdiff
We already allowed a counter declaraton for flex insets. We just
authorRichard Heck <rgheck@lyx.org>
Thu, 23 May 2013 20:36:59 +0000 (16:36 -0400)
committerRichard Heck <rgheck@lyx.org>
Tue, 28 May 2013 04:11:43 +0000 (00:11 -0400)
didn't do anything with it. So let's do something with it.

Fixes bug #8470.

lib/layouts/endnotes.module
src/insets/InsetFlex.cpp
src/insets/InsetFlex.h
src/insets/InsetFoot.cpp

index ffd3ab262644d4bf8c3f1ecd44e3339ca9fedd32..29169f8855881ba08dd0d69f544e5a42356ae783 100644 (file)
@@ -6,15 +6,20 @@
 
 Format 45
 
+Counter endnotes
+    PrettyFormat "Endnote ##"
+End
+
 InsetLayout Flex:Endnote
-   LyXType     custom
-   LatexName   endnote
-   LatexType   command
-   Decoration classic
+   LyXType     custom
+   LatexName   endnote
+   LatexType   command
+   Counter     endnotes
+   Decoration  classic
    Font
-     Size      Small
+     Size Small
    EndFont
-   MultiPar true
-   LabelString endnote
-   Requires    endnotes
+   MultiPar    true
+   LabelString endnote
+   Requires    endnotes
 End
index 5609934b6d16cb144b3dfc18b5a29190f5787ba9..9679b06240ec7dc658a1c34b0eea806cc8917525 100644 (file)
@@ -19,7 +19,9 @@
 #include "Cursor.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
+#include "Language.h"
 #include "Lexer.h"
+#include "ParIterator.h"
 #include "TextClass.h"
 
 #include "support/gettext.h"
@@ -124,4 +126,26 @@ void InsetFlex::doDispatch(Cursor & cur, FuncRequest & cmd)
 }
 
 
+void InsetFlex::updateBuffer(ParIterator const & it, UpdateType utype)
+{
+       BufferParams const & bp = buffer().masterBuffer()->params();
+       Counters & cnts = bp.documentClass().counters();
+       if (utype == OutputUpdate) {
+               // the counter is local to this inset
+               cnts.saveLastCounter();
+       }
+       InsetLayout const & il = getLayout();
+       docstring const & count = il.counter();
+       docstring custom_label = translateIfPossible(il.labelstring());
+       if (cnts.hasCounter(count))
+               cnts.step(count, utype);
+       custom_label += ' ' +
+               cnts.theCounter(count, it.paragraph().getParLanguage(bp)->code());
+       setLabel(custom_label);
+       InsetCollapsable::updateBuffer(it, utype);
+       if (utype == OutputUpdate)
+               cnts.restoreLastCounter();
+}
+
+
 } // namespace lyx
index a51f30ae412aebf036930ec36a046163250908bf..04fbb5f73d604841bd9b39fb731508b18d8aeb34 100644 (file)
@@ -45,6 +45,8 @@ public:
                FuncStatus &) const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       void updateBuffer(ParIterator const & it, UpdateType utype);
 
 protected:
        ///
index e48d67cb0869c5406468f7d993e123b476267e59..39a1fd7eea05538d18c3cff92e214541fe6678b1 100644 (file)
@@ -48,10 +48,10 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
        if (!outer.layout().intitle) {
                InsetLayout const & il = getLayout();
                docstring const & count = il.counter();
-               custom_label_ = translateIfPossible(il.labelstring()) + ' ';
+               custom_label_ = translateIfPossible(il.labelstring());
                if (cnts.hasCounter(count))
                        cnts.step(count, utype);
-               custom_label_ += 
+               custom_label_ += ' ' +
                        cnts.theCounter(count, outer.getParLanguage(bp)->code());
                setLabel(custom_label_);
        }