]> git.lyx.org Git - features.git/commitdiff
Fix updating inset inside insets (typically graphics after loading).
authorJürgen Vigna <jug@sad.it>
Fri, 8 Mar 2002 11:42:30 +0000 (11:42 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 8 Mar 2002 11:42:30 +0000 (11:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3701 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/insets/ChangeLog
src/insets/insettabular.C
src/insets/insettext.C

index 4a11df383f117c610d2cb09c279744fddcc2fbc5..e7f22b169954cff63e0ac82d99e2909e44219bc3 100644 (file)
@@ -1192,7 +1192,8 @@ void BufferView::Pimpl::cursorNext(LyXText * text)
 
 bool BufferView::Pimpl::available() const
 {
-       if (buffer_ && bv_->text) return true;
+       if (buffer_ && bv_->text)
+               return true;
        return false;
 }
 
@@ -3405,7 +3406,7 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
 
 void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
 {
-       if (!inset)
+       if (!inset || !available())
                return;
 
        // first check for locking insets
@@ -3431,9 +3432,14 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
                }
        }
   
-       // then check the current buffer
-       if (available()) {
-               hideCursor();
+       // then check if the inset is a top_level inset (has no owner)
+       // if yes do the update as always otherwise we have to update the
+       // toplevel inset where this inset is inside
+       Inset * tl_inset = inset;
+       while(tl_inset->owner())
+               tl_inset = tl_inset->owner();
+       hideCursor();
+       if (tl_inset == inset) {
                update(bv_->text, BufferView::UPDATE);
                if (bv_->text->updateInset(bv_, inset)) {
                        if (mark_dirty) {
@@ -3446,6 +3452,13 @@ void BufferView::Pimpl::updateInset(Inset * inset, bool mark_dirty)
                        }
                        return;
                }
+       } else if (static_cast<UpdatableInset *>(tl_inset)
+                          ->updateInsetInInset(bv_, inset))
+       {
+                       if (bv_->text->updateInset(bv_,  tl_inset)) {
+                               update();
+                               updateScrollbar();
+                       }
        }
 }
 
index 343b1dbd1e5046678ac70dca91bb493dc8336de3..85c7809ffcf7fa0eb2e1135fd609b8a826c33d7d 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-08  Juergen Vigna  <jug@sad.it>
+
+       * BufferView_pimpl.C (updateInset): update inset inside inset also
+       if it isn't inside theLockingInset().
+
 2002-03-07  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * buffer.C (asciiParagraph): redo some of the word and line length
index d127886555363e38028228dc039d1fa05f50c279..a300dfe4c8736d44ae7db9becd284d41e05f4ae1 100644 (file)
@@ -1,3 +1,13 @@
+2002-03-08  Juergen Vigna  <jug@sad.it>
+
+       * insettabular.C (updateLocal): do a FULL update if we're not locked
+       and only a CELL update is asked.
+
+       * insettext.C (updateInsetInInset): update insets inside inset also
+       if it isn't inside the_locking_inset.
+
+       * insettabular.C (updateInsetInInset): ditto.
+
 2002-03-06  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
        * insetexternal.C (doSubstitution): check whether we are using a
index 3a3d04cef4f4e1a4915345ce000b01d7f90b84da..0f57c91d360cfeef94a075c963e3e5e2037f72fd 100644 (file)
@@ -618,6 +618,8 @@ void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what,
                LyXFont font;
                calculate_dimensions_of_cells(bv, font, true);
        }
+       if (!locked && what == CELL)
+               what = FULL;
        if (need_update < what) // only set this if it has greater update
                need_update = what;
 #if 0 // maybe this should not be done!
@@ -709,10 +711,16 @@ bool InsetTabular::unlockInsetInInset(BufferView * bv, UpdatableInset * inset,
 
 bool InsetTabular::updateInsetInInset(BufferView * bv, Inset * inset)
 {
-       if (!the_locking_inset)
+       Inset * tl_inset = inset;
+       // look if this inset is really inside myself!
+       while(tl_inset->owner() && tl_inset->owner() != this)
+               tl_inset = tl_inset->owner();
+       // if we enter here it's not ower inset
+       if (!tl_inset->owner())
                return false;
-       if (the_locking_inset != inset) {
-               if (!the_locking_inset->updateInsetInInset(bv, inset))
+       // we only have to do this if this is a subinset of our cells
+       if (tl_inset != inset) {
+               if (!static_cast<InsetText *>(tl_inset)->updateInsetInInset(bv, inset))
                        return false;
        }
        updateLocal(bv, CELL, false);
index 844d321b2b55ee95a8937245b3d3de7b3852e23c..879e3ffc81656a41c9dd7f610b635d85304fca72 100644 (file)
@@ -869,15 +869,7 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
                lt = getLyXText(bv);
                clear = true;
        }
-       if (!the_locking_inset) {
-               bool found = lt->updateInset(bv, inset);
-               if (clear)
-                       lt = 0;
-               if (found)
-                       setUpdateStatus(bv, NONE);
-               return found;
-       }
-       if (the_locking_inset != inset) {
+       if (inset->owner() != this) {
                bool found = the_locking_inset->updateInsetInInset(bv, inset);
                if (clear)
                        lt = 0;
@@ -890,7 +882,9 @@ bool InsetText::updateInsetInInset(BufferView * bv, Inset * inset)
                lt = 0;
        if (found) {
                setUpdateStatus(bv, CURSOR_PAR);
-               if (cpar(bv) == inset_par && cpos(bv) == inset_pos) {
+               if (the_locking_inset &&
+                   cpar(bv) == inset_par && cpos(bv) == inset_pos)
+               {
                        inset_x = cx(bv) - top_x + drawTextXOffset;
                        inset_y = cy(bv) + drawTextYOffset;
                }