]> git.lyx.org Git - lyx.git/blobdiff - src/DocIterator.cpp
prepare Qt 5.6 builds
[lyx.git] / src / DocIterator.cpp
index 6e3775b4e36e8886a53123ddda16948d4a767e06..a059ad18d2110b52fe88153b65ef4d5669ed288e 100644 (file)
@@ -217,7 +217,7 @@ CursorSlice const & DocIterator::innerTextSlice() const
                if (slices_[i].text())
                        return slices_[i];
 
-       // This case is in principe not possible. We _must_
+       // This case is in principle not possible. We _must_
        // be inside a Text.
        LBUFERR(false);
        // Squash warning
@@ -226,6 +226,15 @@ CursorSlice const & DocIterator::innerTextSlice() const
 }
 
 
+DocIterator DocIterator::getInnerText() const
+{
+       DocIterator texted = *this;
+       while (!texted.inTexted()) 
+               texted.pop_back();
+       return texted;
+}
+
+
 pit_type DocIterator::lastpit() const
 {
        return inMathed() ? 0 : text()->paragraphs().size() - 1;
@@ -449,6 +458,28 @@ void DocIterator::backwardPos()
 }
 
 
+#if 0
+// works, but currently not needed
+void DocIterator::backwardInset()
+{
+       backwardPos();
+
+       while (!empty() && !nextInset()) {
+               if (inTexted()) {
+                       pos_type const lastp = lastpos();
+                       Paragraph const & par = paragraph();
+                       pos_type & pos = top().pos();
+                       while (pos > 0 && (pos == lastp || !par.isInset(pos)))
+                               --pos;
+                       if (pos > 0)
+                               break;
+               }
+               backwardPos();
+       }
+}
+#endif
+
+
 bool DocIterator::hasPart(DocIterator const & it) const
 {
        // it can't be a part if it is larger
@@ -460,6 +491,19 @@ bool DocIterator::hasPart(DocIterator const & it) const
 }
 
 
+bool DocIterator::allowSpellCheck() const
+{
+       /// spell check is disabled if the iterator position
+       /// is inside of an inset which disables the spell checker
+       size_t const n = depth();
+       for (size_t i = 0; i < n; ++i) {
+               if (!slices_[i].inset_->allowSpellCheck())
+                       return false;
+       }
+       return true;
+}
+
+
 void DocIterator::updateInsets(Inset * inset)
 {
        // this function re-creates the cache of inset pointers.
@@ -555,6 +599,11 @@ void DocIterator::sanitize()
                        fixIfBroken();
                        break;
                }
+               if (!inset->isActive()) {
+                       LYXERR0("Inset found on cursor stack is not active.");
+                       fixIfBroken();
+                       break;
+               }
                push_back(sl[i]);
                top().inset_ = inset;
                if (fixIfBroken())