[Libreoffice-commits] core.git: sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Sat Mar 15 12:37:18 PDT 2014
sc/source/core/data/bcaslot.cxx | 17 ++++++++++++-----
sc/source/core/data/documen7.cxx | 18 ++++++++----------
sc/source/core/inc/bcaslot.hxx | 14 ++++++++++++--
3 files changed, 32 insertions(+), 17 deletions(-)
New commits:
commit 83ee6b640eaf86f9aef6f42a4dd9c8a930cf9135
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Sat Mar 15 15:29:36 2014 -0400
Use listener's listening range when re-activating area listeners.
Otherwise listeners may end up listening to larger areas than their original
listening areas after the relocation.
Change-Id: I12a7f49aec1c78611db5c31ba2d18574e91a5416
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index cccddb0..2dfc9a7 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -446,7 +446,7 @@ void ScBroadcastAreaSlot::EraseArea( ScBroadcastAreas::iterator& rIter )
}
}
-void ScBroadcastAreaSlot::GetAllListeners( const ScRange& rRange, std::vector<SvtListener*>& rListeners )
+void ScBroadcastAreaSlot::GetAllListeners( const ScRange& rRange, std::vector<sc::AreaListener>& rListeners )
{
for (ScBroadcastAreas::const_iterator aIter( aBroadcastAreaTbl.begin()),
aIterEnd( aBroadcastAreaTbl.end()); aIter != aIterEnd; ++aIter )
@@ -456,11 +456,18 @@ void ScBroadcastAreaSlot::GetAllListeners( const ScRange& rRange, std::vector<Sv
ScBroadcastArea* pArea = (*aIter).mpArea;
const ScRange& rAreaRange = pArea->GetRange();
- if (!rAreaRange.Intersects(rRange))
+ if (!rRange.In(rAreaRange))
continue;
SvtBroadcaster::ListenersType& rLst = pArea->GetBroadcaster().GetAllListeners();
- std::copy(rLst.begin(), rLst.end(), std::back_inserter(rListeners));
+ SvtBroadcaster::ListenersType::iterator itLst = rLst.begin(), itLstEnd = rLst.end();
+ for (; itLst != itLstEnd; ++itLst)
+ {
+ sc::AreaListener aEntry;
+ aEntry.maArea = rAreaRange;
+ aEntry.mpListener = *itLst;
+ rListeners.push_back(aEntry);
+ }
}
}
@@ -993,9 +1000,9 @@ void ScBroadcastAreaSlotMachine::FinallyEraseAreas( ScBroadcastAreaSlot* pSlot )
maAreasToBeErased.swap( aCopy);
}
-std::vector<SvtListener*> ScBroadcastAreaSlotMachine::GetAllListeners( const ScRange& rRange )
+std::vector<sc::AreaListener> ScBroadcastAreaSlotMachine::GetAllListeners( const ScRange& rRange )
{
- std::vector<SvtListener*> aRet;
+ std::vector<sc::AreaListener> aRet;
SCTAB nEndTab = rRange.aEnd.Tab();
for (TableSlotsMap::const_iterator iTab( aTableSlotsMap.lower_bound( rRange.aStart.Tab()));
diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx
index d48acbf..658bd8d 100644
--- a/sc/source/core/data/documen7.cxx
+++ b/sc/source/core/data/documen7.cxx
@@ -140,14 +140,13 @@ void ScDocument::BroadcastRefMoved( const sc::RefMovedHint& rHint )
const ScAddress& rDelta = rHint.getDelta();
// Get all area listeners that listens on the old range, and end their listening.
- std::vector<SvtListener*> aAreaListeners = pBASM->GetAllListeners(rSrcRange);
+ std::vector<sc::AreaListener> aAreaListeners = pBASM->GetAllListeners(rSrcRange);
{
- std::vector<SvtListener*>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
+ std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
for (; it != itEnd; ++it)
{
- SvtListener* p = *it;
- pBASM->EndListeningArea(rSrcRange, p);
- p->Notify(rHint); // Adjust the references.
+ pBASM->EndListeningArea(it->maArea, it->mpListener);
+ it->mpListener->Notify(rHint); // Adjust the references.
}
}
@@ -171,14 +170,13 @@ void ScDocument::BroadcastRefMoved( const sc::RefMovedHint& rHint )
}
// Re-start area listeners on the new range.
- ScRange aNewRange = rSrcRange;
- aNewRange.Move(rDelta.Col(), rDelta.Row(), rDelta.Tab());
{
- std::vector<SvtListener*>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
+ std::vector<sc::AreaListener>::iterator it = aAreaListeners.begin(), itEnd = aAreaListeners.end();
for (; it != itEnd; ++it)
{
- SvtListener* p = *it;
- pBASM->StartListeningArea(aNewRange, p);
+ ScRange aNewRange = it->maArea;
+ aNewRange.Move(rDelta.Col(), rDelta.Row(), rDelta.Tab());
+ pBASM->StartListeningArea(aNewRange, it->mpListener);
}
}
}
diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx
index 9bd416c..4509cc9 100644
--- a/sc/source/core/inc/bcaslot.hxx
+++ b/sc/source/core/inc/bcaslot.hxx
@@ -28,6 +28,16 @@
#include "global.hxx"
#include "brdcst.hxx"
+namespace sc {
+
+struct AreaListener
+{
+ ScRange maArea;
+ SvtListener* mpListener;
+};
+
+}
+
/**
Used in a Unique Associative Container.
*/
@@ -211,7 +221,7 @@ public:
*/
void EraseArea( ScBroadcastAreas::iterator& rIter );
- void GetAllListeners( const ScRange& rRange, std::vector<SvtListener*>& rListeners );
+ void GetAllListeners( const ScRange& rRange, std::vector<sc::AreaListener>& rListeners );
};
@@ -307,7 +317,7 @@ public:
// only for ScBroadcastAreaSlot
void FinallyEraseAreas( ScBroadcastAreaSlot* pSlot );
- std::vector<SvtListener*> GetAllListeners( const ScRange& rRange );
+ std::vector<sc::AreaListener> GetAllListeners( const ScRange& rRange );
};
More information about the Libreoffice-commits
mailing list