]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
adjust
[lyx.git] / src / DocIterator.cpp
index d898ff0608c456e55ae47394bb267903480a9718..7bfc2fb1f5635839462eb3d6bfc7a440bcde728d 100644 (file)
@@ -78,7 +78,7 @@ Inset * DocIterator::prevInset() const
        BOOST_ASSERT(!empty());
        if (pos() == 0)
                return 0;
-       if (inMathed())
+       if (inMathed()) {
                if (cell().empty())
                        // FIXME: this should not happen but it does.
                        // See bug 3189
@@ -86,6 +86,7 @@ Inset * DocIterator::prevInset() const
                        return 0;
                else
                        return prevAtom().nucleus();
+       }
        return paragraph().isInset(pos() - 1) ? paragraph().getInset(pos() - 1) : 0;
 }
 
@@ -94,7 +95,7 @@ Inset * DocIterator::realInset() const
 {
        BOOST_ASSERT(inTexted());
        // if we are in a tabular, we need the cell
-       if (inset().lyxCode() == Inset::TABULAR_CODE) {
+       if (inset().lyxCode() == TABULAR_CODE) {
                InsetTabular & tabular = static_cast<InsetTabular&>(inset());
                return tabular.cell(idx()).get();
        }
@@ -136,18 +137,26 @@ Paragraph & DocIterator::paragraph() const
 
 
 Paragraph & DocIterator::innerParagraph() const
+{
+       BOOST_ASSERT(!empty());
+       return innerTextSlice().paragraph();
+}
+
+
+CursorSlice const & DocIterator::innerTextSlice() const
 {
        BOOST_ASSERT(!empty());
        // go up until first non-0 text is hit
        // (innermost text is 0 in mathed)
        for (int i = depth() - 1; i >= 0; --i)
                if (slices_[i].text())
-                       return slices_[i].paragraph();
+                       return slices_[i];
 
        // This case is in principe not possible. We _must_
-       // be inside a Paragraph.
+       // be inside a Text.
        BOOST_ASSERT(false);
-       return paragraph();
+       static CursorSlice dummy;
+       return dummy;
 }