Kaydet (Commit) f60c1cd2 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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.
üst d5921135
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
#include "externalrefmgr.hxx" #include "externalrefmgr.hxx"
#include "tabprotection.hxx" #include "tabprotection.hxx"
#include "clipparam.hxx" #include "clipparam.hxx"
#include "stlalgorithm.hxx"
#include <map> #include <map>
#include <limits> #include <limits>
...@@ -651,17 +652,19 @@ bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc ) ...@@ -651,17 +652,19 @@ bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc )
if ( pUnoBroadcaster ) if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) ); pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) );
SCTAB i; for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
for (i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
if (maTabs[i]) if (maTabs[i])
maTabs[i]->UpdateDeleteTab(nTab,false, maTabs[i]->UpdateDeleteTab(
pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0); nTab, false, pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0);
maTabs.erase(maTabs.begin()+ nTab);
TableContainer::iterator it = maTabs.begin() + nTab;
delete *it;
maTabs.erase(it);
// UpdateBroadcastAreas must be called between UpdateDeleteTab, // UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify // which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners. // areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1); UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1);
TableContainer::iterator it = maTabs.begin(); it = maTabs.begin();
for (; it != maTabs.end(); ++it) for (; it != maTabs.end(); ++it)
if ( *it ) if ( *it )
(*it)->UpdateCompile(); (*it)->UpdateCompile();
...@@ -738,17 +741,20 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* pRefUndoDoc ...@@ -738,17 +741,20 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* pRefUndoDoc
if ( pUnoBroadcaster ) if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) ); pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) );
SCTAB i; for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
for (i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
if (maTabs[i]) if (maTabs[i])
maTabs[i]->UpdateDeleteTab(nTab,false, maTabs[i]->UpdateDeleteTab(
pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0,nSheets); nTab, false, pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0,nSheets);
maTabs.erase(maTabs.begin()+ nTab, maTabs.begin() + nTab + 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, // UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify // which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners. // areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets); UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets);
TableContainer::iterator it = maTabs.begin(); it = maTabs.begin();
for (; it != maTabs.end(); ++it) for (; it != maTabs.end(); ++it)
if ( *it ) if ( *it )
(*it)->UpdateCompile(); (*it)->UpdateCompile();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment