Jean-Marc Lasgouttes wrote:
> At least, you could move your code that determines what the real text
> inset is into dociterator.C.
is attached.
Jürgen
Index: dociterator.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.C,v
retrieving revision 1.32
diff -p -u -r1.32 dociterator.C
--- dociterator.C 25 Oct 2005 09:14:11 -0000 1.32
+++ dociterator.C 21 Nov 2005 19:05:28 -0000
@@ -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>
@@ -87,6 +88,18 @@ InsetBase const * DocIterator::prevInset
if (inMathed())
return prevAtom().nucleus();
return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
+}
+
+
+InsetBase * DocIterator::textInset() const
+{
+ BOOST_ASSERT(!empty());
+ // 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();
}
Index: dociterator.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/dociterator.h,v
retrieving revision 1.24
diff -p -u -r1.24 dociterator.h
--- dociterator.h 25 Oct 2005 09:14:11 -0000 1.24
+++ dociterator.h 21 Nov 2005 19:05:29 -0000
@@ -164,6 +164,8 @@ public:
LyXText * text();
///
LyXText const * text() const;
+ /// the containing text inset (i.e. cell in tabular)
+ InsetBase * textInset() const;
///
InsetBase * innerInsetOfType(int code) const;
///
Index: undo.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/undo.C,v
retrieving revision 1.68
diff -p -u -r1.68 undo.C
--- undo.C 13 Oct 2005 17:20:30 -0000 1.68
+++ undo.C 21 Nov 2005 19:05:30 -0000
@@ -190,7 +190,7 @@ bool textUndoOrRedo(BufferView & bv,
ParagraphList::const_iterator pit = undo.pars.begin();
ParagraphList::const_iterator end = undo.pars.end();
for (; pit != end; ++pit)
- const_cast<Paragraph &>(*pit).setInsetOwner(&dit.inset());
+ const_cast<Paragraph &>(*pit).setInsetOwner(dit.textInset());
plist.insert(first, undo.pars.begin(), undo.pars.end());
}