From: Richard Kimberly Heck Date: Thu, 12 Nov 2020 22:20:48 +0000 (-0500) Subject: Move updateMacros code into InsetTabular X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=c41b72acc491e330c4b77393cb53ecb3abafdbe6;p=features.git Move updateMacros code into InsetTabular --- diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index e6c9892025..75886f5005 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -4813,6 +4813,19 @@ void InsetTabular::edit(Cursor & cur, bool front, EntryDirection) } +void InsetTabular::updateMacros(DocIterator const & us, DocIterator const & scope) +{ + DocIterator pos = us; + size_t const numcells = pos.nargs(); + for (size_t c = 0; c < numcells; ++c, pos.top().forwardIdx()) { + shared_ptr cp = cell(c); + // this test should be unnecessary, right? + if (cp) + cp->updateMacros(pos, scope); + } +} + + void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype, bool const /*deleted*/) { // In a longtable, tell captions what the current float is diff --git a/src/insets/InsetTabular.h b/src/insets/InsetTabular.h index 2ee107a192..c27fec05ad 100644 --- a/src/insets/InsetTabular.h +++ b/src/insets/InsetTabular.h @@ -1054,6 +1054,8 @@ public: /// Update the counters of this inset and of its contents void updateBuffer(ParIterator const &, UpdateType, bool const deleted = false) override; /// + void updateMacros(DocIterator const & us, DocIterator const & scope) override; + /// void addToToc(DocIterator const & di, bool output_active, UpdateType utype, TocBackend & backend) const override; diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index 95768ae1ca..d268d2e313 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -62,6 +62,7 @@ #include "mathed/InsetMathHull.h" #include "mathed/MacroTable.h" #include "mathed/InsetMathMacroTemplate.h" +#include "insets/InsetTabular.h" #include "support/convert.h" #include "support/debug.h" @@ -938,14 +939,10 @@ void InsetText::updateMacros(DocIterator const & us, DocIterator const & scope) continue; } - if (insit.inset->asInsetTabular()) { - CursorSlice slice(*insit.inset); - size_t const numcells = slice.nargs(); - for (; slice.idx() < numcells; slice.forwardIdx()) { - it.push_back(slice); - updateMacros(it, ourscope); - it.pop_back(); - } + if (InsetTabular * itext = insit.inset->asInsetTabular()) { + it.push_back(CursorSlice(*insit.inset)); + itext->updateMacros(it, ourscope); + it.pop_back(); continue; }