]> git.lyx.org Git - lyx.git/blobdiff - src/dociterator.C
Partial fix bug 2092: branches not propagated to child documents
[lyx.git] / src / dociterator.C
index 2ede4d4518fdc1c5f27a41bf54f01ebe5ec4dcbf..51ecd6406738bf716523a8a58eeff748f832bf4e 100644 (file)
@@ -30,12 +30,12 @@ using std::endl;
 // We could be able to get rid of this if only every BufferView were
 // associated to a buffer on construction.
 DocIterator::DocIterator()
-       : inset_(0), boundary_(false)
+       : boundary_(false), inset_(0)
 {}
 
 
 DocIterator::DocIterator(InsetBase & inset)
-       : inset_(&inset), boundary_(false)
+       : boundary_(false), inset_(&inset)
 {}
 
 
@@ -490,6 +490,25 @@ bool DocIterator::hasPart(DocIterator const & it) const
 }
 
 
+void DocIterator::updateInsets(InsetBase * inset) 
+{
+       // this function re-creates the cache of inset pointers.
+       // code taken in part from StableDocIterator::asDocIterator.
+       //lyxerr << "converting:\n" << *this << endl;
+       DocIterator dit = DocIterator(*inset);
+       size_t const n = slices_.size();
+       for (size_t i = 0 ; i < n; ++i) {
+               BOOST_ASSERT(inset);
+               dit.push_back(slices_[i]);
+               dit.top().inset_ = inset;
+               if (i + 1 != n)
+                       inset = dit.nextInset();
+       }
+       //lyxerr << "converted:\n" << *this << endl;
+       operator=(dit);
+}
+
+
 std::ostream & operator<<(std::ostream & os, DocIterator const & dit)
 {
        for (size_t i = 0, n = dit.depth(); i != n; ++i)