diff options
author | Noel <noel.grandin@collabora.co.uk> | 2021-02-04 10:22:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-04 11:19:35 +0100 |
commit | 18982376918c88ec09c2c7fd42ef635e93897b05 (patch) | |
tree | 33745acca3f3b8155628981b81438a15131fc157 /svx/source/unodraw/unopage.cxx | |
parent | 380ab85b6594a013f34f5e6ec69fb569336bbb48 (diff) |
use more getSdrObjectFromXShape
Change-Id: Ia237643ab040425f231f781c86e7e060f0b53717
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110400
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/unodraw/unopage.cxx')
-rw-r--r-- | svx/source/unodraw/unopage.cxx | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/svx/source/unodraw/unopage.cxx b/svx/source/unodraw/unopage.cxx index d139fe2ab5c2..23fe9dabd1a6 100644 --- a/svx/source/unodraw/unopage.cxx +++ b/svx/source/unodraw/unopage.cxx @@ -288,40 +288,35 @@ void SAL_CALL SvxDrawPage::remove( const Reference< drawing::XShape >& xShape ) if( (mpModel == nullptr) || (mpPage == nullptr) ) throw lang::DisposedException(); - SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( xShape ); + SdrObject* pObj = SdrObject::getSdrObjectFromXShape( xShape ); + if (!pObj) + return; - if (pShape) + // remove SdrObject from page + const size_t nCount = mpPage->GetObjCount(); + for( size_t nNum = 0; nNum < nCount; ++nNum ) { - SdrObject* pObj = pShape->GetSdrObject(); - if (pObj) + if(mpPage->GetObj(nNum) == pObj) { - // remove SdrObject from page - const size_t nCount = mpPage->GetObjCount(); - for( size_t nNum = 0; nNum < nCount; ++nNum ) - { - if(mpPage->GetObj(nNum) == pObj) - { - const bool bUndoEnabled = mpModel->IsUndoEnabled(); + const bool bUndoEnabled = mpModel->IsUndoEnabled(); - if (bUndoEnabled) - { - mpModel->BegUndo(SvxResId(STR_EditDelete), - pObj->TakeObjNameSingul(), SdrRepeatFunc::Delete); + if (bUndoEnabled) + { + mpModel->BegUndo(SvxResId(STR_EditDelete), + pObj->TakeObjNameSingul(), SdrRepeatFunc::Delete); - mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); - } + mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoDeleteObject(*pObj)); + } - OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj ); + OSL_VERIFY( mpPage->RemoveObject( nNum ) == pObj ); - if (!bUndoEnabled) - SdrObject::Free(pObj); + if (!bUndoEnabled) + SdrObject::Free(pObj); - if (bUndoEnabled) - mpModel->EndUndo(); + if (bUndoEnabled) + mpModel->EndUndo(); - break; - } - } + break; } } @@ -386,11 +381,7 @@ namespace { void lcl_markSdrObjectOfShape( const Reference< drawing::XShape >& _rxShape, SdrView& _rView, SdrPageView& _rPageView ) { - SvxShape* pShape = comphelper::getUnoTunnelImplementation<SvxShape>( _rxShape ); - if ( !pShape ) - return; - - SdrObject* pObj = pShape->GetSdrObject(); + SdrObject* pObj = SdrObject::getSdrObjectFromXShape( _rxShape ); if ( !pObj ) return; |