diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-04 15:46:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-05-05 08:37:53 +0200 |
commit | c895edf3f67f19d8d2012674c084456a7851436e (patch) | |
tree | 0e4f75a39db4fc292c830fe0b68599aa8b5042ab /svx/source/unodraw | |
parent | d7fbea57ef945c1444185581787d17a93dda8cd9 (diff) |
tdf#148921 Smartart: Incorrect Text position
Revert
commit b6fe3b13206eee0543ded37c3a1566add284e6da.
no need to have two weak references to SdrObject in SvxShape
Change-Id: Ie29d0002fd86226eb7634f621b43e7cb8dfc8aa0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133833
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx/source/unodraw')
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 499c72092f40..4d6431f51433 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -116,6 +116,13 @@ struct SvxShapeImpl bool mbHasSdrObjectOwnership; bool mbDisposing; + /** CL, OD 2005-07-19 #i52126# - this is initially 0 and set when + * a SvxShape::Create() call is executed. It is then set to the created + * SdrObject so a multiple call to SvxShape::Create() with same SdrObject + * is prohibited. + */ + ::tools::WeakReference< SdrObject > mpCreatedObj; + // for xComponent ::comphelper::OInterfaceContainerHelper3<css::lang::XEventListener> maDisposeListeners; svx::PropertyChangeNotifier maPropertyNotifier; @@ -379,7 +386,7 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) if ( !pNewObj ) return; - SdrObject* pCreatedObj = mpSdrObjectWeakReference.get(); + SdrObject* pCreatedObj = mpImpl->mpCreatedObj.get(); assert( ( !pCreatedObj || ( pCreatedObj == pNewObj ) ) && "SvxShape::Create: the same shape used for two different objects?! Strange ..." ); @@ -387,14 +394,20 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) if ( pCreatedObj == pNewObj ) return; - if( pCreatedObj ) + // Correct condition (#i52126#) + mpImpl->mpCreatedObj = pNewObj; + + if( HasSdrObject() ) { - EndListening( pCreatedObj->getSdrModelFromSdrObject() ); + EndListening( GetSdrObject()->getSdrModelFromSdrObject() ); } mpSdrObjectWeakReference.reset( pNewObj ); - StartListening( pNewObj->getSdrModelFromSdrObject() ); + if( HasSdrObject() ) + { + StartListening( GetSdrObject()->getSdrModelFromSdrObject() ); + } OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" ); // this was previously set in impl_initFromSdrObject, but I think it was superfluous @@ -405,19 +418,19 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ ) ObtainSettingsFromPropertySet( *mpPropSet ); // save user call - SdrObjUserCall* pUser = pNewObj->GetUserCall(); - pNewObj->SetUserCall(nullptr); + SdrObjUserCall* pUser = GetSdrObject()->GetUserCall(); + GetSdrObject()->SetUserCall(nullptr); setPosition( maPosition ); setSize( maSize ); // restore user call after we set the initial size - pNewObj->SetUserCall( pUser ); + GetSdrObject()->SetUserCall( pUser ); // if this shape was already named, use this name if( !maShapeName.isEmpty() ) { - pNewObj->SetName( maShapeName ); + GetSdrObject()->SetName( maShapeName ); maShapeName.clear(); } } |