Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi Eike,

On Fri, 2012-01-27 at 00:03 +0100, Eike Rathke wrote:
Maybe worth a thought.

So, I took a second look at this, and came up with the attached version
which I think is better and more correct than the first one.  This one
will correctly honor the delete note flag, and also maintains the option
of deleting the note cell if the right conditions are met (i.e. delete
note flag is set and nobody is listening to it).

As for the pivot table change, that code block is indeed necessary; when
non-empty cells exist that overlaps the range where the new table output
gets written, those cells may survive if they happen to be where the
table content is empty.  So I reverted that part of my initial change.

Kohei

-- 
Kohei Yoshida, LibreOffice hacker, Calc
From 43f1d4516d87aba02fc3f410e1c6def4e45c696b Mon Sep 17 00:00:00 2001
From: Kohei Yoshida <kohei.yoshida@suse.com>
Date: Thu, 26 Jan 2012 15:47:52 -0500
Subject: [PATCH] fdo#44143: Keep cells with broadcasters alive during deletion.

Or else it would partially break formula reference chain.
---
 sc/source/core/data/column3.cxx |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

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
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.