]> git.lyx.org Git - features.git/commitdiff
Move updateMacros code into InsetTabular
authorRichard Kimberly Heck <rikiheck@lyx.org>
Thu, 12 Nov 2020 22:20:48 +0000 (17:20 -0500)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Fri, 13 Nov 2020 00:27:28 +0000 (19:27 -0500)
src/insets/InsetTabular.cpp
src/insets/InsetTabular.h
src/insets/InsetText.cpp

index e6c98920257144da46704d8198822e4a83b99440..75886f50056717e9b945ba35b34507d1b2079231 100644 (file)
@@ -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<InsetTableCell> 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
index 2ee107a1926946ce8948eb4f300c33df2a988a11..c27fec05ad0a0027f89d1825c5f572c8c9130b58 100644 (file)
@@ -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;
 
index 95768ae1ca89a88efd143cd2a053d51a61b193fa..d268d2e3132eeba19d65ac5707aecb13b24b2b79 100644 (file)
@@ -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;
                        }