]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetFlex.cpp
We already allowed a counter declaraton for flex insets. We just
[features.git] / src / insets / InsetFlex.cpp
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