Jean-Marc Lasgouttes wrote:
> Juergen> Then I have to convert it back to InsetBase in undo.C to pass
> Juergen> it to setInsetOwner. How can I do this?
>
> Why do you need that? Doesn't InsetText derive from InsetBase?
I just can't get it to compile. Attached is what I have now.
Or do you mean I should use a InsetBase * DocIterator::textInset() method and
just return an insettext?
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 24 Nov 2005 15:13:17 -0000
@@ -20,6 +20,8 @@
#include "mathed/math_data.h"
#include "mathed/math_inset.h"
+#include "insets/insettabular.h"
+#include "insets/insettext.h"
#include <boost/assert.hpp>
#include <boost/current_function.hpp>
@@ -87,6 +89,18 @@ InsetBase const * DocIterator::prevInset
if (inMathed())
return prevAtom().nucleus();
return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
+}
+
+
+InsetText * DocIterator::textInset() 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 static_cast<InsetText*>(&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 24 Nov 2005 15:13:18 -0000
@@ -18,6 +18,7 @@
#include <iosfwd>
class LyXText;
+class InsetText;
class MathAtom;
class Paragraph;
class Row;
@@ -164,6 +165,8 @@ public:
LyXText * text();
///
LyXText const * text() const;
+ /// the containing text inset (i.e. cell in tabular)
+ InsetText * 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 24 Nov 2005 15:13:19 -0000
@@ -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.textInset());
plist.insert(first, undo.pars.begin(), undo.pars.end());
}