summaryrefslogtreecommitdiff
path: root/sc/source/core/data/documen7.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/core/data/documen7.cxx')
-rw-r--r--sc/source/core/data/documen7.cxx40
1 files changed, 38 insertions, 2 deletions
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index 02a75fb2add2..a960c5a7011b 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -130,6 +130,22 @@ void ScDocument::BroadcastCells( const ScRange& rRange, sal_uLong nHint )
BroadcastUno(SfxSimpleHint(SC_HINT_DATACHANGED));
}
+namespace {
+
+class RefMovedNotifier : std::unary_function<SvtListener*, void>
+{
+ const sc::RefMovedHint& mrHint;
+public:
+ RefMovedNotifier( const sc::RefMovedHint& rHint ) : mrHint(rHint) {}
+
+ void operator() ( SvtListener* p )
+ {
+ p->Notify(mrHint);
+ }
+};
+
+}
+
void ScDocument::BroadcastRefMoved( const sc::RefMovedHint& rHint )
{
if (!pBASM)
@@ -150,6 +166,28 @@ void ScDocument::BroadcastRefMoved( const sc::RefMovedHint& rHint )
}
}
+ // Collect all listeners listening into the range.
+ std::vector<SvtListener*> aListeners;
+ for (SCTAB nTab = rSrcRange.aStart.Tab(); nTab <= rSrcRange.aEnd.Tab(); ++nTab)
+ {
+ ScTable* pTab = FetchTable(nTab);
+ if (!pTab)
+ continue;
+
+ pTab->CollectListeners(
+ aListeners,
+ rSrcRange.aStart.Col(), rSrcRange.aStart.Row(),
+ rSrcRange.aEnd.Col(), rSrcRange.aEnd.Row());
+ }
+
+ // Remove any duplicate listener entries. We must ensure that we notify
+ // each unique listener only once.
+ std::sort(aListeners.begin(), aListeners.end());
+ aListeners.erase(std::unique(aListeners.begin(), aListeners.end()), aListeners.end());
+
+ // Notify the listeners.
+ std::for_each(aListeners.begin(), aListeners.end(), RefMovedNotifier(rHint));
+
for (SCTAB nTab = rSrcRange.aStart.Tab(); nTab <= rSrcRange.aEnd.Tab(); ++nTab)
{
ScTable* pTab = FetchTable(nTab);
@@ -161,8 +199,6 @@ void ScDocument::BroadcastRefMoved( const sc::RefMovedHint& rHint )
if (!pDestTab)
continue;
- // Adjust the references.
- pTab->BroadcastRefMoved(rHint);
// Move the listeners from the old location to the new.
pTab->TransferListeners(
*pDestTab, rSrcRange.aStart.Col(), rSrcRange.aStart.Row(),