]> git.lyx.org Git - lyx.git/blobdiff - src/iterators.C
the spellcheck cleanup
[lyx.git] / src / iterators.C
index acbe21237c7090aa349a9fb4cc8651a7be8628a8..609f6e6bbad3863183e3c777fa27dbd486fc9cd0 100644 (file)
 #include "paragraph.h"
 #include "PosIterator.h"
 #include "cursor.h"
+#include "BufferView.h"
+#include "funcrequest.h"
+#include "dispatchresult.h"
+
 
 
 #include "insets/inset.h"
+#include "insets/updatableinset.h"
+#include "insets/insettext.h"
 
 #include <boost/next_prior.hpp>
 #include <boost/optional.hpp>
@@ -363,7 +369,7 @@ bool operator!=(ParConstIterator const & iter1, ParConstIterator const & iter2)
 PosIterator ParIterator::asPosIterator(lyx::pos_type pos) const
 {
        PosIterator p;
-       
+
        int const last = size() - 1;
        for (int i = 0; i < last; ++i) {
                ParPosition & pp = pimpl_->positions[i];
@@ -374,3 +380,25 @@ PosIterator ParIterator::asPosIterator(lyx::pos_type pos) const
                                      pp.pit, pos, 0));
        return p;
 }
+
+
+void ParIterator::lockPath(BufferView * bv) const
+{
+       bv->insetUnlock();
+       int last = size() - 1;
+       for (int i = 0; i < last; ++i) {
+               UpdatableInset * outer = dynamic_cast<UpdatableInset *>((*pimpl_->positions[i].it)->inset);
+               FuncRequest cmd(bv, LFUN_INSET_EDIT);
+               outer->dispatch(cmd);
+               LyXText * txt = outer->getText(*pimpl_->positions[i].index);
+               InsetText * inner = txt->inset_owner;
+               // deep vodoo magic: on a table, the edit call locks the first
+               // cell and further lock calls get lost there.
+               // We have to unlock it to then lock the correct one.
+               if (outer != inner) {
+                       outer->insetUnlock(bv);
+                       outer->lockInsetInInset(bv, inner);
+                       inner->dispatch(FuncRequest(bv, LFUN_INSET_EDIT));
+               }
+       }
+}