]> git.lyx.org Git - features.git/commitdiff
fix initialization of insetOwner after undo (bug 1952).
authorJürgen Spitzmüller <spitz@lyx.org>
Thu, 24 Nov 2005 16:22:39 +0000 (16:22 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Thu, 24 Nov 2005 16:22:39 +0000 (16:22 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10619 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/dociterator.C
src/dociterator.h
src/undo.C

index 9658d711d2bc61cea19eca6adaff1b6987a8153f..89edf764a78cd2da23900a6f180093fb3432df30 100644 (file)
@@ -1,3 +1,10 @@
+2005-11-17  Jürgen Spitzmüller  <j.spitzmueller@gmx.de>
+
+       * dociterator.[Ch]: new member realInset() that returns the cell
+       for tabulars and the inset for the rest (bug 1952).
+       * undo.C (textUndoOrRedo): use realInset when resetting insetOwner
+       (bug 1952).
+
 2005-11-15  Jean-Marc Lasgouttes  <lasgouttes@lyx.org>
 
        * text.C (leftMargin): honor the NextNoIndent tag in layouts.
index 51ecd6406738bf716523a8a58eeff748f832bf4e..0b3e0567ec476da5f79e0194247707858ceccd6b 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "mathed/math_data.h"
 #include "mathed/math_inset.h"
+#include "insets/insettabular.h"
 
 #include <boost/assert.hpp>
 #include <boost/current_function.hpp>
@@ -90,6 +91,18 @@ InsetBase const * DocIterator::prevInset() const
 }
 
 
+InsetBase * DocIterator::realInset() const
+{
+       BOOST_ASSERT(inTexted());
+       // if we are in a tabular, we need the cell
+       if (inset().lyxCode() == InsetBase::TABULAR_CODE) {
+               InsetTabular & tabular = static_cast<InsetTabular&>(inset());
+               return tabular.cell(idx()).get();
+       }
+       return &inset();
+}
+
+
 MathAtom const & DocIterator::prevAtom() const
 {
        BOOST_ASSERT(!empty());
index c69c703c515893ecdfd670f09a529558cb86ee67..fa6824b88fe3551cbae3a369d7b4ab7fb1f4b9fb 100644 (file)
@@ -164,6 +164,8 @@ public:
        LyXText * text();
        ///
        LyXText const * text() const;
+       /// the containing inset or the cell, respectively
+       InsetBase * realInset() const;
        ///
        InsetBase * innerInsetOfType(int code) const;
        ///
index d5d34c0c4a6fbf1c63986375a4f42e82b4abcd41..8e5fcc334f9acb23e249bba86f12a1268faf09db 100644 (file)
@@ -187,10 +187,10 @@ bool textUndoOrRedo(BufferView & bv,
 
                // this ugly stuff is needed until we get rid of the
                // inset_owner backpointer
-               ParagraphList::const_iterator pit = undo.pars.begin();
-               ParagraphList::const_iterator end = undo.pars.end();
+               ParagraphList::iterator pit = undo.pars.begin();
+               ParagraphList::iterator const end = undo.pars.end();
                for (; pit != end; ++pit)
-                       const_cast<Paragraph &>(*pit).setInsetOwner(&dit.inset());
+                       pit->setInsetOwner(dit.realInset());
                plist.insert(first, undo.pars.begin(), undo.pars.end());
        }