summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-11-21 11:57:23 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-11-21 11:57:23 -0500
commit15bf6a424836cc1acb927371047ec65807e59039 (patch)
tree2ead9c96153c1ecd874dc9e8dc6d7349d96df371
parent535934edc13cc2045bd4e7e85acff1dce59bfe63 (diff)
Handle group area listeners correctly when deleting cells.
Change-Id: Ic37084ed670f53e0354056f7bef54229971dd7c2
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/source/core/data/document.cxx39
-rw-r--r--sc/source/core/data/document10.cxx22
3 files changed, 45 insertions, 17 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index e746d1d6ed71..acf0f67241cd 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1914,6 +1914,7 @@ public:
bool GetHardRecalcState() { return bHardRecalcState; }
void SetHardRecalcState( bool bVal ) { bHardRecalcState = bVal; }
void StartAllListeners();
+ void StartNeededListeners();
const ScFormulaCell* GetFormulaTree() const { return pFormulaTree; }
bool HasForcedFormulas() const { return bHasForcedFormulas; }
void SetForcedFormulas( bool bVal ) { bHasForcedFormulas = bVal; }
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 4fb535d0df00..4e3fd9d433b9 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -1154,19 +1154,6 @@ bool ScDocument::CanInsertRow( const ScRange& rRange ) const
namespace {
-class StartNeededListenersHandler : std::unary_function<ScTable*, void>
-{
- boost::shared_ptr<sc::StartListeningContext> mpCxt;
-public:
- StartNeededListenersHandler( ScDocument& rDoc ) : mpCxt(new sc::StartListeningContext(rDoc)) {}
-
- void operator() (ScTable* p)
- {
- if (p)
- p->StartListeners(*mpCxt, false);
- }
-};
-
struct SetDirtyIfPostponedHandler : std::unary_function<ScTable*, void>
{
void operator() (ScTable* p)
@@ -1276,7 +1263,7 @@ bool ScDocument::InsertRow( SCCOL nStartCol, SCTAB nStartTab,
}
else
{ // Listeners have been removed in UpdateReference
- std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+ StartNeededListeners();
// At least all cells using range names pointing relative to the
// moved range must be recalculated, and all cells marked postponed
@@ -1369,7 +1356,7 @@ void ScDocument::DeleteRow( SCCOL nStartCol, SCTAB nStartTab,
if ( ValidRow(nStartRow+nSize) )
{
// Listeners have been removed in UpdateReference
- std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+ StartNeededListeners();
// At least all cells using range names pointing relative to the moved
// range must be recalculated, and all cells marked postponed dirty.
@@ -1475,7 +1462,7 @@ bool ScDocument::InsertCol( SCROW nStartRow, SCTAB nStartTab,
else
{
// Listeners have been removed in UpdateReference
- std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+ StartNeededListeners();
// At least all cells using range names pointing relative to the
// moved range must be recalculated, and all cells marked postponed
// dirty.
@@ -1564,7 +1551,7 @@ void ScDocument::DeleteCol(SCROW nStartRow, SCTAB nStartTab, SCROW nEndRow, SCTA
if ( ValidCol(sal::static_int_cast<SCCOL>(nStartCol+nSize)) )
{
// Listeners have been removed in UpdateReference
- std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+ StartNeededListeners();
// At least all cells using range names pointing relative to the moved
// range must be recalculated, and all cells marked postponed dirty.
@@ -1777,11 +1764,29 @@ void ScDocument::DeleteArea(
PutInOrder( nCol1, nCol2 );
PutInOrder( nRow1, nRow2 );
+
+ // Record the positions of top and/or bottom formula groups that intersect
+ // the area borders.
+ std::vector<ScAddress> aGroupPos;
+ sc::EndListeningContext aCxt(*this);
+ ScRange aRange(nCol1, nRow1, 0, nCol2, nRow2, 0);
+ for (size_t i = 0; i < maTabs.size(); ++i)
+ {
+ aRange.aStart.SetTab(i);
+ aRange.aEnd.SetTab(i);
+
+ EndListeningIntersectedGroups(aCxt, aRange, &aGroupPos);
+ }
+ aCxt.purgeEmptyBroadcasters();
+
for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); i++)
if (maTabs[i])
if ( rMark.GetTableSelect(i) || bIsUndo )
maTabs[i]->DeleteArea(nCol1, nRow1, nCol2, nRow2, nDelFlag, bBroadcast, pBroadcastSpans);
+ // Re-start listeners on those top bottom groups that have been split.
+ SetNeedsListeningGroups(aGroupPos);
+ StartNeededListeners();
}
void ScDocument::DeleteAreaTab(SCCOL nCol1, SCROW nRow1,
diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx
index c426a196cf56..48e933c9dfc5 100644
--- a/sc/source/core/data/document10.cxx
+++ b/sc/source/core/data/document10.cxx
@@ -384,4 +384,26 @@ void ScDocument::SetNeedsListeningGroups( const std::vector<ScAddress>& rPosArra
}
}
+namespace {
+
+class StartNeededListenersHandler : std::unary_function<ScTable*, void>
+{
+ boost::shared_ptr<sc::StartListeningContext> mpCxt;
+public:
+ StartNeededListenersHandler( ScDocument& rDoc ) : mpCxt(new sc::StartListeningContext(rDoc)) {}
+
+ void operator() (ScTable* p)
+ {
+ if (p)
+ p->StartListeners(*mpCxt, false);
+ }
+};
+
+}
+
+void ScDocument::StartNeededListeners()
+{
+ std::for_each(maTabs.begin(), maTabs.end(), StartNeededListenersHandler(*this));
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */