From a9614f15d244b6eda60b93f971f56b40e838d351 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Thu, 23 May 2013 16:36:59 -0400 Subject: [PATCH] We already allowed a counter declaraton for flex insets. We just didn't do anything with it. So let's do something with it. Fixes bug #8470. --- lib/layouts/endnotes.module | 21 +++++++++++++-------- src/insets/InsetFlex.cpp | 24 ++++++++++++++++++++++++ src/insets/InsetFlex.h | 2 ++ src/insets/InsetFoot.cpp | 4 ++-- 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/lib/layouts/endnotes.module b/lib/layouts/endnotes.module index ffd3ab2626..29169f8855 100644 --- a/lib/layouts/endnotes.module +++ b/lib/layouts/endnotes.module @@ -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 diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 5609934b6d..9679b06240 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -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 diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index a51f30ae41..04fbb5f73d 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -45,6 +45,8 @@ public: FuncStatus &) const; /// void doDispatch(Cursor & cur, FuncRequest & cmd); + /// + void updateBuffer(ParIterator const & it, UpdateType utype); protected: /// diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index e48d67cb08..39a1fd7eea 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -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_); } -- 2.39.2