]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
revert r37459 and add a note to the sources:
[lyx.git] / src / DocIterator.cpp
index ecf121582886c6a70ac810491d8570c3a7eb25fc..0555a9f75f1db9dc2b467c22ee80f54415e4becf 100644 (file)
@@ -72,10 +72,30 @@ DocIterator doc_iterator_end(const Buffer * buf0, const Inset * inset0)
 }
 
 
+DocIterator DocIterator::clone(Buffer * buffer) const
+{
+       LASSERT(buffer->isClone(), return DocIterator());
+       Inset * inset = &buffer->inset();
+       DocIterator dit(buffer);
+       size_t const n = slices_.size();
+       for (size_t i = 0 ; i != n; ++i) {
+               LASSERT(inset, /**/);
+               dit.push_back(slices_[i]);
+               dit.top().inset_ = inset;
+               if (i + 1 != n)
+                       inset = dit.nextInset();
+       }
+       return dit;
+}
+
+
 bool DocIterator::inRegexped() const
 {
-       InsetMathHull * i = dynamic_cast<InsetMathHull *>(inset().asInsetMath());
-       return i && i->getType() == hullRegexp;
+       InsetMath * im = inset().asInsetMath();
+       if (!im) 
+               return false;
+       InsetMathHull * hull = im->asHullInset();
+       return hull && hull->getType() == hullRegexp;
 }
 
 
@@ -111,7 +131,7 @@ Inset * DocIterator::prevInset() const
                if (cell().empty())
                        // FIXME: this should not happen but it does.
                        // See bug 3189
-                       // http://bugzilla.lyx.org/show_bug.cgi?id=3189
+                       // http://www.lyx.org/trac/ticket/3189
                        return 0;
                else
                        return prevAtom().nucleus();
@@ -125,8 +145,8 @@ Inset * DocIterator::realInset() const
        LASSERT(inTexted(), /**/);
        // if we are in a tabular, we need the cell
        if (inset().lyxCode() == TABULAR_CODE) {
-               InsetTabular & tabular = static_cast<InsetTabular&>(inset());
-               return tabular.cell(idx()).get();
+               InsetTabular * tabular = inset().asInsetTabular();
+               return tabular->cell(idx()).get();
        }
        return &inset();
 }
@@ -172,6 +192,16 @@ Paragraph & DocIterator::innerParagraph() const
 }
 
 
+FontSpan DocIterator::locateWord(word_location const loc) const
+{
+       FontSpan f = FontSpan();
+
+       f.first = pos();
+       top().paragraph().locateWord(f.first, f.last, loc);
+       return f;
+}
+
+       
 CursorSlice const & DocIterator::innerTextSlice() const
 {
        LASSERT(!empty(), /**/);