summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-01-06 20:56:20 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-01-06 21:00:11 -0500
commitf60c1cd239da3e2fcb30f4af8761013c8ae9c0fc (patch)
tree9a6636340c81a1ddad6d128ba47988bced48a90b /sc
parentd59211357a4ae75365f23479ac2e1cd2376a5dab (diff)
fdo#44467: Deleting sheets should adjust drawing object pages as well.
Good thing we caught this, because we were also leaking memory by not deleting the deleted sheet instances.
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/document.cxx30
1 files changed, 18 insertions, 12 deletions
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index eb03a7420b99..15d529576f6d 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -95,6 +95,7 @@
#include "externalrefmgr.hxx"
#include "tabprotection.hxx"
#include "clipparam.hxx"
+#include "stlalgorithm.hxx"
#include <map>
#include <limits>
@@ -651,17 +652,19 @@ bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc )
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) );
- SCTAB i;
- for (i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
+ for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
if (maTabs[i])
- maTabs[i]->UpdateDeleteTab(nTab,false,
- pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0);
- maTabs.erase(maTabs.begin()+ nTab);
+ maTabs[i]->UpdateDeleteTab(
+ nTab, false, pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0);
+
+ TableContainer::iterator it = maTabs.begin() + nTab;
+ delete *it;
+ maTabs.erase(it);
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1);
- TableContainer::iterator it = maTabs.begin();
+ it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();
@@ -738,17 +741,20 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* pRefUndoDoc
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) );
- SCTAB i;
- for (i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
+ for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
if (maTabs[i])
- maTabs[i]->UpdateDeleteTab(nTab,false,
- pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0,nSheets);
- maTabs.erase(maTabs.begin()+ nTab, maTabs.begin() + nTab + nSheets);
+ maTabs[i]->UpdateDeleteTab(
+ nTab, false, pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0,nSheets);
+
+ TableContainer::iterator it = maTabs.begin() + nTab;
+ TableContainer::iterator itEnd = it + nSheets;
+ std::for_each(it, itEnd, ScDeleteObjectByPtr<ScTable>());
+ maTabs.erase(it, itEnd);
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets);
- TableContainer::iterator it = maTabs.begin();
+ it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();