[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sc/source

Eike Rathke erack at kemper.freedesktop.org
Fri Jan 27 04:58:38 PST 2012


 sc/source/core/data/column3.cxx |   29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

New commits:
commit 08adeedce926bac1a010c26f2a4ae2d5fb761376
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Thu Jan 26 15:47:52 2012 -0500

    fdo#44143: Keep cells with broadcasters alive during deletion.
    
    Or else it would partially break formula reference chain.
    (cherry picked from commit 41e92ab2b7a8fcb7f5738f656bdac47bc0847f29)
    
    Signed-off-by: Eike Rathke <erack at redhat.com>

diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index fbeb951..5d96af1 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -35,6 +35,7 @@
 #include <sfx2/objsh.hxx>
 #include <svl/zforlist.hxx>
 #include <svl/zformat.hxx>
+#include <svl/broadcast.hxx>
 
 #include "scitems.hxx"
 #include "column.hxx"
@@ -465,14 +466,25 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
             if (bDelete)
             {
                 // try to create a replacement note cell, if note or broadcaster exists
-                ScNoteCell* pNoteCell = 0;
-                if (eCellType != CELLTYPE_NOTE)
+                ScNoteCell* pNoteCell = NULL;
+                SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
+                bool bKeepBC = pBC && pBC->HasListeners();
+                if (eCellType == CELLTYPE_NOTE)
+                {
+                    if (bKeepBC)
+                    {
+                        // We need to keep this "note" cell to keep the broadcaster.
+                        pNoteCell = static_cast<ScNoteCell*>(pOldCell);
+                        if (bDeleteNote)
+                            pOldCell->DeleteNote();
+                    }
+                }
+                else
                 {
                     // do not rescue note if it has to be deleted according to passed flags
                     ScPostIt* pNote = bDeleteNote ? 0 : pOldCell->ReleaseNote();
                     // #i99844# do not release broadcaster from old cell, it still has to notify deleted content
-                    SvtBroadcaster* pBC = pOldCell->GetBroadcaster();
-                    if( pNote || pBC )
+                    if (pNote || bKeepBC)
                         pNoteCell = new ScNoteCell( pNote, pBC );
                 }
 
@@ -498,9 +510,12 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
                     aHint.GetAddress().SetRow( nOldRow );
                     aHint.SetCell( pOldCell );
                     pDocument->Broadcast( aHint );
-                    // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pNoteCell)
-                    pOldCell->ReleaseBroadcaster();
-                    pOldCell->Delete();
+                    if (pNoteCell != pOldCell)
+                    {
+                        // #i99844# after broadcasting, old cell has to forget the broadcaster (owned by pNoteCell)
+                        pOldCell->ReleaseBroadcaster();
+                        pOldCell->Delete();
+                    }
                 }
             }
             else


More information about the Libreoffice-commits mailing list