summaryrefslogtreecommitdiff
path: root/sc/source/core/data/document.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-30 01:36:28 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-30 23:50:02 -0400
commit5a1960f5ea9f225fda493df746e5674e3bd1cce9 (patch)
tree7f77a380e2e16500e39fdde51d379d9606507d1c /sc/source/core/data/document.cxx
parented671a33a31b8d8cd81e3774be603c13e8b9a6f3 (diff)
Update range names on sheet deletion.
It works fine with live calc instance, but somehow fails in unit test. Change-Id: Ie60774b4f1f8391801e0d9358f6cca78d8e52397
Diffstat (limited to 'sc/source/core/data/document.cxx')
-rw-r--r--sc/source/core/data/document.cxx24
1 files changed, 13 insertions, 11 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index 90cadf72cf35..25fc4c3ef271 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -617,8 +617,9 @@ bool ScDocument::DeleteTab( SCTAB nTab )
SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
if (nTabCount > 1)
{
- bool bOldAutoCalc = GetAutoCalc();
- SetAutoCalc( false ); // avoid multiple calculations
+ sc::AutoCalcSwitch aACSwitch(*this, false);
+ sc::RefUpdateDeleteTabContext aCxt(nTab, 1);
+
ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab );
DelBroadcastAreasInRange( aRange );
@@ -640,7 +641,7 @@ bool ScDocument::DeleteTab( SCTAB nTab )
xColNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,-1 );
xRowNameRanges->UpdateReference( URM_INSDEL, this, aRange, 0,0,-1 );
if (pRangeName)
- pRangeName->UpdateTabRef(nTab, ScRangeData::Delete);
+ pRangeName->UpdateDeleteTab(aCxt);
pDBCollection->UpdateReference(
URM_INSDEL, 0,0,nTab, MAXCOL,MAXROW,MAXTAB, 0,0,-1 );
if (pDPCollection)
@@ -656,7 +657,7 @@ bool ScDocument::DeleteTab( SCTAB nTab )
for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
if (maTabs[i])
- maTabs[i]->UpdateDeleteTab(nTab);
+ maTabs[i]->UpdateDeleteTab(aCxt);
TableContainer::iterator it = maTabs.begin() + nTab;
delete *it;
@@ -682,7 +683,6 @@ bool ScDocument::DeleteTab( SCTAB nTab )
// sheet names of references are not valid until sheet is deleted
pChartListenerCollection->UpdateScheduledSeriesRanges();
- SetAutoCalc( bOldAutoCalc );
bValid = true;
}
}
@@ -701,8 +701,9 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
SCTAB nTabCount = static_cast<SCTAB>(maTabs.size());
if (nTabCount > nSheets)
{
- bool bOldAutoCalc = GetAutoCalc();
- SetAutoCalc( false ); // avoid multiple calculations
+ sc::AutoCalcSwitch aACSwitch(*this, false);
+ sc::RefUpdateDeleteTabContext aCxt(nTab, nSheets);
+
for (SCTAB aTab = 0; aTab < nSheets; ++aTab)
{
ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTab + aTab );
@@ -719,9 +720,11 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
if (pDetOpList)
pDetOpList->DeleteOnTab( nTab + aTab );
DeleteAreaLinksOnTab( nTab + aTab );
- if (pRangeName)
- pRangeName->UpdateTabRef(nTab + aTab, ScRangeData::Delete);
}
+
+ if (pRangeName)
+ pRangeName->UpdateDeleteTab(aCxt);
+
// normal reference update
ScRange aRange( 0, 0, nTab, MAXCOL, MAXROW, nTabCount - 1 );
@@ -742,7 +745,7 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
if (maTabs[i])
- maTabs[i]->UpdateDeleteTab(nTab, nSheets);
+ maTabs[i]->UpdateDeleteTab(aCxt);
TableContainer::iterator it = maTabs.begin() + nTab;
TableContainer::iterator itEnd = it + nSheets;
@@ -769,7 +772,6 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets )
// sheet names of references are not valid until sheet is deleted
pChartListenerCollection->UpdateScheduledSeriesRanges();
- SetAutoCalc( bOldAutoCalc );
bValid = true;
}
}