[Libreoffice-commits] core.git: Branch 'feature/SOSAW080' - include/svx svx/source

Armin Le Grand Armin.Le.Grand at cib.de
Mon Apr 2 10:05:52 UTC 2018


 include/svx/unoshape.hxx          |   15 -
 svx/source/unodraw/tableshape.cxx |   34 +-
 svx/source/unodraw/unoshap2.cxx   |  178 ++++++--------
 svx/source/unodraw/unoshap3.cxx   |  101 +++----
 svx/source/unodraw/unoshap4.cxx   |   80 +++---
 svx/source/unodraw/unoshape.cxx   |  483 +++++++++++++++++++-------------------
 6 files changed, 446 insertions(+), 445 deletions(-)

New commits:
commit f9d2cc0a43faecae76c0f106a4a423d0eb480b4b
Author: Armin Le Grand <Armin.Le.Grand at cib.de>
Date:   Mon Apr 2 12:04:28 2018 +0200

    SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
    
    Change-Id: I17bcb44d2e29920c0c74430c2d9c703b36cfa0ad

diff --git a/include/svx/unoshape.hxx b/include/svx/unoshape.hxx
index 626031962daf..422f6b13b446 100644
--- a/include/svx/unoshape.hxx
+++ b/include/svx/unoshape.hxx
@@ -137,8 +137,10 @@ protected:
     const SvxItemPropertySet* mpPropSet;
     const SfxItemPropertyMapEntry* maPropMapEntries;
 
-    ::tools::WeakReference< SdrObject > mpObj;
-    SdrModel* mpModel;
+private:
+    ::tools::WeakReference< SdrObject > mpSdrObjectWeakReference;
+
+protected:
     // translations for writer, which works in TWIPS
     void ForceMetricToItemPoolMetric(Pair& rPoint) const throw();
     void ForceMetricToItemPoolMetric(Point& rPoint) const throw() { ForceMetricToItemPoolMetric(rPoint.toPair()); }
@@ -206,8 +208,13 @@ public:
     void TakeSdrObjectOwnership();
     bool HasSdrObjectOwnership() const;
 
-    void InvalidateSdrObject() { mpObj.reset( nullptr ); };
-    SdrObject* GetSdrObject() const {return mpObj.get();}
+    // used exclusively by SdrObject
+    void InvalidateSdrObject();
+
+    // Encapsulated access to SdrObject
+    SdrObject* GetSdrObject() const { return mpSdrObjectWeakReference.get(); }
+    bool HasSdrObject() const { return mpSdrObjectWeakReference.is(); }
+
     void SetShapeType( const OUString& ShapeType ) { maShapeType = ShapeType; }
     /// @throws css::uno::RuntimeException
     css::uno::Any GetBitmap( bool bMetaFile = false ) const;
diff --git a/svx/source/unodraw/tableshape.cxx b/svx/source/unodraw/tableshape.cxx
index a34815611bca..281dfa288ea9 100644
--- a/svx/source/unodraw/tableshape.cxx
+++ b/svx/source/unodraw/tableshape.cxx
@@ -59,8 +59,8 @@ bool SvxTableShape::setPropertyValueImpl(
         if( !(rValue >>= xTemplate) )
             throw IllegalArgumentException();
 
-        if( mpObj.is() )
-            static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyle(xTemplate);
+        if( HasSdrObject() )
+            static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyle(xTemplate);
 
         return true;
     }
@@ -71,9 +71,9 @@ bool SvxTableShape::setPropertyValueImpl(
     case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
     case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
     {
-        if( mpObj.is() )
+        if( HasSdrObject() )
         {
-            TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
+            TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
 
             switch( pProperty->nWID )
             {
@@ -85,7 +85,7 @@ bool SvxTableShape::setPropertyValueImpl(
             case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:    rValue >>= aSettings.mbUseColumnBanding; break;
             }
 
-            static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->setTableStyleSettings(aSettings);
+            static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->setTableStyleSettings(aSettings);
         }
 
         return true;
@@ -106,25 +106,25 @@ bool SvxTableShape::getPropertyValueImpl(
     {
     case OWN_ATTR_OLEMODEL:
     {
-        if( mpObj.is() )
+        if( HasSdrObject() )
         {
-            rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTable();
+            rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTable();
         }
         return true;
     }
     case OWN_ATTR_TABLETEMPLATE:
     {
-        if( mpObj.is() )
+        if( HasSdrObject() )
         {
-            rValue <<= static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyle();
+            rValue <<= static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyle();
         }
         return true;
     }
     case OWN_ATTR_BITMAP:
     {
-        if( mpObj.is() )
+        if( HasSdrObject() )
         {
-            Graphic aGraphic( SvxGetGraphicForShape( *mpObj.get() ) );
+            Graphic aGraphic( SvxGetGraphicForShape( *GetSdrObject() ) );
             rValue <<= aGraphic.GetXGraphic();
         }
         return true;
@@ -136,9 +136,9 @@ bool SvxTableShape::getPropertyValueImpl(
     case OWN_ATTR_TABLETEMPLATE_BANDINGROWS:
     case OWN_ATTR_TABLETEMPLATE_BANDINGCOULUMNS:
     {
-        if( mpObj.is() )
+        if( HasSdrObject() )
         {
-            TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->getTableStyleSettings() );
+            TableStyleSettings aSettings( static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->getTableStyleSettings() );
 
             switch( pProperty->nWID )
             {
@@ -163,14 +163,14 @@ bool SvxTableShape::getPropertyValueImpl(
 void SvxTableShape::lock()
 {
     SvxShape::lock();
-    if( mpObj.is() )
-        static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_lock();
+    if( HasSdrObject() )
+        static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_lock();
 }
 
 void SvxTableShape::unlock()
 {
-    if( mpObj.is() )
-        static_cast< sdr::table::SdrTableObj* >( mpObj.get() )->uno_unlock();
+    if( HasSdrObject() )
+        static_cast< sdr::table::SdrTableObj* >( GetSdrObject() )->uno_unlock();
     SvxShape::unlock();
 }
 
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 3ef19a65ddf1..02fa0736e550 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -182,7 +182,7 @@ void SAL_CALL SvxShapeGroup::leaveGroup(  )
 
 void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape, size_t nPos )
 {
-    if (!mpObj.is() || !mxPage.is())
+    if (!HasSdrObject() || !mxPage.is())
     {
         OSL_FAIL("could not add XShape to group shape!");
         return;
@@ -202,10 +202,10 @@ void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape
     if( pSdrShape->IsInserted() )
         pSdrShape->GetObjList()->RemoveObject( pSdrShape->GetOrdNum() );
 
-    mpObj->GetSubList()->InsertObject(pSdrShape, nPos);
+    GetSdrObject()->GetSubList()->InsertObject(pSdrShape, nPos);
     // TTTT Was created using mpModel in CreateSdrObject_ above
     // TTTT may be good to add a assertion here for the future
-    // pSdrShape->SetModel(mpObj->GetModel());
+    // pSdrShape->SetModel(GetSdrObject()->GetModel());
 
     // #85922# It makes no sense to set the layer asked
     // from the group object since these is an iteration
@@ -220,8 +220,7 @@ void SvxShapeGroup::addUnoShape( const uno::Reference< drawing::XShape >& xShape
     // would be created when this connection would not already exist.
     pShape->Create( pSdrShape, mxPage.get() );
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 // XShapes
@@ -244,7 +243,7 @@ void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xS
     if( pShape )
         pSdrShape = pShape->GetSdrObject();
 
-    if( !mpObj.is() || pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get() )
+    if( !HasSdrObject() || pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != GetSdrObject() )
         throw uno::RuntimeException();
 
     SdrObjList& rList = *pSdrShape->GetObjList();
@@ -281,8 +280,7 @@ void SAL_CALL SvxShapeGroup::remove( const uno::Reference< drawing::XShape >& xS
         SAL_WARN( "svx", "Fatality! SdrObject is not belonging to its SdrObjList! [CL]" );
     }
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 void SAL_CALL SvxShapeGroup::addTop( const uno::Reference< drawing::XShape >& xShape )
@@ -308,10 +306,10 @@ sal_Int32 SAL_CALL SvxShapeGroup::getCount()
 {
     ::SolarMutexGuard aGuard;
 
-    if(!mpObj.is() || !mpObj->GetSubList())
+    if(!HasSdrObject() || !GetSdrObject()->GetSubList())
         throw uno::RuntimeException();
 
-    sal_Int32 nRetval = mpObj->GetSubList()->GetObjCount();
+    sal_Int32 nRetval = GetSdrObject()->GetSubList()->GetObjCount();
     return nRetval;
 }
 
@@ -320,13 +318,13 @@ uno::Any SAL_CALL SvxShapeGroup::getByIndex( sal_Int32 Index )
 {
     ::SolarMutexGuard aGuard;
 
-    if( !mpObj.is() || mpObj->GetSubList() == nullptr )
+    if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
         throw uno::RuntimeException();
 
-    if( Index<0 || mpObj->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
+    if( Index<0 || GetSdrObject()->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
         throw lang::IndexOutOfBoundsException();
 
-    SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
+    SdrObject* pDestObj = GetSdrObject()->GetSubList()->GetObj( Index );
 
     if(pDestObj == nullptr)
         throw lang::IndexOutOfBoundsException();
@@ -348,7 +346,7 @@ sal_Bool SAL_CALL SvxShapeGroup::hasElements()
 {
     ::SolarMutexGuard aGuard;
 
-    return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
+    return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
 }
 
 SvxShapeConnector::SvxShapeConnector(SdrObject* pObj)
@@ -441,10 +439,9 @@ void SAL_CALL SvxShapeConnector::connectStart( const uno::Reference< drawing::XC
     SvxShape* pShape = SvxShape::getImplementation( xRef );
 
     if( pShape )
-        mpObj->ConnectToNode( true, pShape->mpObj.get() );
+        GetSdrObject()->ConnectToNode( true, pShape->GetSdrObject() );
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 
@@ -455,11 +452,10 @@ void SAL_CALL SvxShapeConnector::connectEnd( const uno::Reference< drawing::XCon
     Reference< drawing::XShape > xRef( xShape, UNO_QUERY );
     SvxShape* pShape = SvxShape::getImplementation( xRef );
 
-    if( mpObj.is() && pShape )
-        mpObj->ConnectToNode( false, pShape->mpObj.get() );
+    if( HasSdrObject() && pShape )
+        GetSdrObject()->ConnectToNode( false, pShape->GetSdrObject() );
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 
@@ -467,11 +463,10 @@ void SAL_CALL SvxShapeConnector::disconnectBegin( const uno::Reference< drawing:
 {
     ::SolarMutexGuard aGuard;
 
-    if(mpObj.is())
-        mpObj->DisconnectFromNode( true );
+    if(HasSdrObject())
+        GetSdrObject()->DisconnectFromNode( true );
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 
@@ -479,11 +474,10 @@ void SAL_CALL SvxShapeConnector::disconnectEnd( const uno::Reference< drawing::X
 {
     ::SolarMutexGuard aGuard;
 
-    if(mpObj.is())
-        mpObj->DisconnectFromNode( false );
+    if(HasSdrObject())
+        GetSdrObject()->DisconnectFromNode( false );
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 SvxShapeControl::SvxShapeControl(SdrObject* pObj)
@@ -575,7 +569,7 @@ Reference< awt::XControlModel > SAL_CALL SvxShapeControl::getControl()
 
     Reference< awt::XControlModel > xModel;
 
-    SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
+    SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(GetSdrObject());
     if( pUnoObj )
         xModel = pUnoObj->GetUnoControlModel();
 
@@ -587,12 +581,11 @@ void SAL_CALL SvxShapeControl::setControl( const Reference< awt::XControlModel >
 {
     ::SolarMutexGuard aGuard;
 
-    SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(mpObj.get());
+    SdrUnoObj* pUnoObj = dynamic_cast< SdrUnoObj * >(GetSdrObject());
     if( pUnoObj )
         pUnoObj->SetUnoControlModel( xControl );
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 static struct
@@ -986,14 +979,14 @@ bool SvxShapePolyPolygon::setPropertyValueImpl( const OUString& rName, const Sfx
     {
         if( auto s = o3tl::tryAccess<drawing::PointSequenceSequence>(rValue) )
         {
-            if( mpObj.is() )
+            if( HasSdrObject() )
             {
                 basegfx::B2DPolyPolygon aNewPolyPolygon;
                 basegfx::B2DHomMatrix aNewHomogenMatrix;
 
-                mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+                GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
                 aNewPolyPolygon = ImplSvxPointSequenceSequenceToB2DPolyPolygon(s);
-                mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+                GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
             }
             return true;
         }
@@ -1096,8 +1089,8 @@ bool SvxShapePolyPolygon::getPropertyValueImpl( const OUString& rName, const Sfx
         basegfx::B2DPolyPolygon aNewPolyPolygon;
         basegfx::B2DHomMatrix aNewHomogenMatrix;
 
-        if(mpObj.is())
-            mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+        if(HasSdrObject())
+            GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
 
         drawing::PointSequenceSequence aRetval(aNewPolyPolygon.count());
         B2DPolyPolygonToSvxPointSequenceSequence(aNewPolyPolygon, aRetval);
@@ -1150,8 +1143,8 @@ void SvxShapePolyPolygon::SetPolygon(const basegfx::B2DPolyPolygon& rNew)
 {
     ::SolarMutexGuard aGuard;
 
-    if(mpObj.is())
-        static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
+    if(HasSdrObject())
+        static_cast<SdrPathObj*>(GetSdrObject())->SetPathPoly(rNew);
 }
 
 
@@ -1159,9 +1152,9 @@ basegfx::B2DPolyPolygon SvxShapePolyPolygon::GetPolygon() const throw()
 {
     ::SolarMutexGuard aGuard;
 
-    if(mpObj.is())
+    if(HasSdrObject())
     {
-        return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
+        return static_cast<SdrPathObj*>(GetSdrObject())->GetPathPoly();
     }
     else
     {
@@ -1198,15 +1191,15 @@ bool SvxShapePolyPolygonBezier::setPropertyValueImpl( const OUString& rName, con
     {
         if( auto s = o3tl::tryAccess<drawing::PolyPolygonBezierCoords>(rValue) )
         {
-            if( mpObj.is() )
+            if( HasSdrObject() )
             {
                 basegfx::B2DPolyPolygon aNewPolyPolygon;
                 basegfx::B2DHomMatrix aNewHomogenMatrix;
 
-                mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+                GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
                 aNewPolyPolygon = basegfx::unotools::polyPolygonBezierToB2DPolyPolygon(
                     *s);
-                mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+                GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
             }
             return true;
         }
@@ -1239,7 +1232,7 @@ bool SvxShapePolyPolygonBezier::getPropertyValueImpl( const OUString& rName, con
         // pack a tools::PolyPolygon in a struct tools::PolyPolygon
         basegfx::B2DPolyPolygon aNewPolyPolygon;
         basegfx::B2DHomMatrix aNewHomogenMatrix;
-        mpObj.get()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+        GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
         drawing::PolyPolygonBezierCoords aRetval;
         basegfx::unotools::b2DPolyPolygonToPolyPolygonBezier(aNewPolyPolygon, aRetval);
 
@@ -1262,8 +1255,8 @@ void SvxShapePolyPolygonBezier::SetPolygon(const basegfx::B2DPolyPolygon& rNew)
 {
     ::SolarMutexGuard aGuard;
 
-    if(mpObj.is())
-        static_cast<SdrPathObj*>(mpObj.get())->SetPathPoly(rNew);
+    if(HasSdrObject())
+        static_cast<SdrPathObj*>(GetSdrObject())->SetPathPoly(rNew);
 }
 
 
@@ -1271,9 +1264,9 @@ basegfx::B2DPolyPolygon SvxShapePolyPolygonBezier::GetPolygon() const throw()
 {
     ::SolarMutexGuard aGuard;
 
-    if(mpObj.is())
+    if(HasSdrObject())
     {
-        return static_cast<SdrPathObj*>(mpObj.get())->GetPathPoly();
+        return static_cast<SdrPathObj*>(GetSdrObject())->GetPathPoly();
     }
     else
     {
@@ -1306,7 +1299,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
 
             if( GraphicConverter::Import( aMemStm, aGraphic ) == ERRCODE_NONE )
             {
-                static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
+                static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic);
                 bOk = true;
             }
         }
@@ -1315,7 +1308,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
             auto xGraphic = rValue.get<uno::Reference<graphic::XGraphic>>();
             if (xGraphic.is())
             {
-                static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(Graphic(xGraphic));
+                static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(Graphic(xGraphic));
                 bOk = true;
             }
         }
@@ -1326,7 +1319,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
             {
                 uno::Reference<graphic::XGraphic> xGraphic(xBitmap, uno::UNO_QUERY);
                 Graphic aGraphic(xGraphic);
-                static_cast<SdrGrafObj*>(mpObj.get())->SetGraphic(aGraphic);
+                static_cast<SdrGrafObj*>(GetSdrObject())->SetGraphic(aGraphic);
                 bOk = true;
             }
         }
@@ -1342,9 +1335,9 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
             if( !aStreamURL.startsWith( UNO_NAME_GRAPHOBJ_URLPKGPREFIX ) )
                 aStreamURL.clear();
 
-            if( mpObj.is() )
+            if( HasSdrObject() )
             {
-                static_cast<SdrGrafObj*>(mpObj.get())->SetGrafStreamURL( aStreamURL );
+                static_cast<SdrGrafObj*>(GetSdrObject())->SetGrafStreamURL( aStreamURL );
             }
             bOk = true;
         }
@@ -1356,7 +1349,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
         if( xGraphic.is() )
         {
-            static_cast< SdrGrafObj*>( mpObj.get() )->SetGraphic( xGraphic );
+            static_cast< SdrGrafObj*>( GetSdrObject() )->SetGraphic( xGraphic );
             bOk = true;
         }
         break;
@@ -1367,7 +1360,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         bool bIsSignatureLine;
         if (rValue >>= bIsSignatureLine)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setIsSignatureLine(bIsSignatureLine);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setIsSignatureLine(bIsSignatureLine);
             bOk = true;
         }
         break;
@@ -1378,7 +1371,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         OUString aSignatureLineId;
         if (rValue >>= aSignatureLineId)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineId(aSignatureLineId);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineId(aSignatureLineId);
             bOk = true;
         }
         break;
@@ -1389,7 +1382,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         OUString aSuggestedSignerName;
         if (rValue >>= aSuggestedSignerName)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSuggestedSignerName(aSuggestedSignerName);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSuggestedSignerName(aSuggestedSignerName);
             bOk = true;
         }
         break;
@@ -1400,7 +1393,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         OUString aSuggestedSignerTitle;
         if (rValue >>= aSuggestedSignerTitle)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSuggestedSignerTitle(aSuggestedSignerTitle);
             bOk = true;
         }
         break;
@@ -1411,7 +1404,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         OUString aSuggestedSignerEmail;
         if (rValue >>= aSuggestedSignerEmail)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSuggestedSignerEmail(aSuggestedSignerEmail);
             bOk = true;
         }
         break;
@@ -1422,7 +1415,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         OUString aSigningInstructions;
         if (rValue >>= aSigningInstructions)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineSigningInstructions(aSigningInstructions);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineSigningInstructions(aSigningInstructions);
             bOk = true;
         }
         break;
@@ -1433,7 +1426,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         bool bShowSignDate;
         if (rValue >>= bShowSignDate)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineShowSignDate(bShowSignDate);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineShowSignDate(bShowSignDate);
             bOk = true;
         }
         break;
@@ -1444,7 +1437,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         bool bCanAddComment;
         if (rValue >>= bCanAddComment)
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineCanAddComment(bCanAddComment);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineCanAddComment(bCanAddComment);
             bOk = true;
         }
         break;
@@ -1455,7 +1448,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
         Reference<graphic::XGraphic> xGraphic(rValue, uno::UNO_QUERY);
         if (xGraphic.is())
         {
-            static_cast<SdrGrafObj*>(mpObj.get())->setSignatureLineUnsignedGraphic(xGraphic);
+            static_cast<SdrGrafObj*>(GetSdrObject())->setSignatureLineUnsignedGraphic(xGraphic);
             bOk = true;
         }
         break;
@@ -1468,8 +1461,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte
     if( !bOk )
         throw lang::IllegalArgumentException();
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 
     return true;
 }
@@ -1480,7 +1472,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
     {
     case OWN_ATTR_VALUE_FILLBITMAP:
     {
-        const Graphic& rGraphic = static_cast<SdrGrafObj*>(mpObj.get())->GetGraphic();
+        const Graphic& rGraphic = static_cast<SdrGrafObj*>(GetSdrObject())->GetGraphic();
 
         if (rGraphic.GetType() != GraphicType::GdiMetafile)
         {
@@ -1502,7 +1494,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
 
     case OWN_ATTR_REPLACEMENT_GRAPHIC:
     {
-        const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(mpObj.get())->GetReplacementGraphicObject();
+        const GraphicObject* pGrafObj = static_cast< SdrGrafObj* >(GetSdrObject())->GetReplacementGraphicObject();
 
         if (pGrafObj)
         {
@@ -1514,7 +1506,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
 
     case OWN_ATTR_GRAFSTREAMURL:
     {
-        const OUString  aStreamURL( static_cast<SdrGrafObj*>( mpObj.get() )->GetGrafStreamURL() );
+        const OUString  aStreamURL( static_cast<SdrGrafObj*>( GetSdrObject() )->GetGrafStreamURL() );
         if( !aStreamURL.isEmpty() )
             rValue <<= aStreamURL;
         break;
@@ -1523,7 +1515,7 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
     case OWN_ATTR_VALUE_GRAPHIC:
     {
         Reference<graphic::XGraphic> xGraphic;
-        auto pSdrGraphicObject = static_cast<SdrGrafObj*>(mpObj.get());
+        auto pSdrGraphicObject = static_cast<SdrGrafObj*>(GetSdrObject());
         if (pSdrGraphicObject->GetGraphicObject().GetType() != GraphicType::NONE)
             xGraphic = pSdrGraphicObject->GetGraphic().GetXGraphic();
         rValue <<= xGraphic;
@@ -1532,62 +1524,62 @@ bool SvxGraphicObject::getPropertyValueImpl( const OUString& rName, const SfxIte
 
     case OWN_ATTR_GRAPHIC_STREAM:
     {
-        rValue <<= static_cast< SdrGrafObj* >( mpObj.get() )->getInputStream();
+        rValue <<= static_cast< SdrGrafObj* >( GetSdrObject() )->getInputStream();
         break;
     }
 
     case OWN_ATTR_IS_SIGNATURELINE:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->isSignatureLine();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->isSignatureLine();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_ID:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineId();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineId();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_NAME:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSuggestedSignerName();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSuggestedSignerName();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_TITLE:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSuggestedSignerTitle();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSuggestedSignerTitle();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_SUGGESTED_SIGNER_EMAIL:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSuggestedSignerEmail();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSuggestedSignerEmail();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_SIGNING_INSTRUCTIONS:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineSigningInstructions();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineSigningInstructions();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_SHOW_SIGN_DATE:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->isSignatureLineShowSignDate();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->isSignatureLineShowSignDate();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_CAN_ADD_COMMENT:
     {
-        rValue <<= static_cast<SdrGrafObj*>(mpObj.get())->isSignatureLineCanAddComment();
+        rValue <<= static_cast<SdrGrafObj*>(GetSdrObject())->isSignatureLineCanAddComment();
         break;
     }
 
     case OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE:
     {
         Reference<graphic::XGraphic> xGraphic(
-            static_cast<SdrGrafObj*>(mpObj.get())->getSignatureLineUnsignedGraphic());
+            static_cast<SdrGrafObj*>(GetSdrObject())->getSignatureLineUnsignedGraphic());
         rValue <<= xGraphic;
         break;
     }
@@ -1658,21 +1650,21 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxCustomShape::getImplementationId()
 awt::Point SAL_CALL SvxCustomShape::getPosition()
 {
     ::SolarMutexGuard aGuard;
-    if ( mpModel && mpObj.is() )
+    if ( HasSdrObject() )
     {
         SdrAShapeObjGeoData aCustomShapeGeoData;
-        static_cast<SdrObjCustomShape*>(mpObj.get())->SaveGeoData( aCustomShapeGeoData );
+        static_cast<SdrObjCustomShape*>(GetSdrObject())->SaveGeoData( aCustomShapeGeoData );
 
         bool bMirroredX = false;
         bool bMirroredY = false;
 
-        if ( mpObj.is() )
+        if ( HasSdrObject() )
         {
-            bMirroredX = static_cast<SdrObjCustomShape*>(mpObj.get())->IsMirroredX();
-            bMirroredY = static_cast<SdrObjCustomShape*>(mpObj.get())->IsMirroredY();
+            bMirroredX = static_cast<SdrObjCustomShape*>(GetSdrObject())->IsMirroredX();
+            bMirroredY = static_cast<SdrObjCustomShape*>(GetSdrObject())->IsMirroredY();
         }
         // get aRect, this is the unrotated snaprect
-        tools::Rectangle aRect(static_cast<SdrObjCustomShape*>(mpObj.get())->GetLogicRect());
+        tools::Rectangle aRect(static_cast<SdrObjCustomShape*>(GetSdrObject())->GetLogicRect());
         tools::Rectangle aRectangle( aRect );
 
         if ( bMirroredX || bMirroredY )
@@ -1726,8 +1718,8 @@ awt::Point SAL_CALL SvxCustomShape::getPosition()
         }
         Point aPt( aRectangle.TopLeft() );
 
-        if( mpModel->IsWriter() )
-            aPt -= mpObj->GetAnchorPos();
+        if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+            aPt -= GetSdrObject()->GetAnchorPos();
 
         ForceMetricTo100th_mm(aPt);
         return css::awt::Point( aPt.X(), aPt.Y() );
@@ -1741,7 +1733,7 @@ void SAL_CALL SvxCustomShape::setPropertyValue( const OUString& aPropertyName, c
 {
     ::SolarMutexGuard aGuard;
 
-    SdrObject* pObject = mpObj.get();
+    SdrObject* pObject = GetSdrObject();
 
     // tdf#98163 Use a custom slot to have filter code flush the UNO
     // API implementations of SdrObjCustomShape. Used e.g. by
@@ -1827,7 +1819,7 @@ bool SvxCustomShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
     {
     case SDRATTR_ROTATEANGLE:
     {
-        double fAngle = static_cast<SdrObjCustomShape*>(mpObj.get())->GetObjectRotation();
+        double fAngle = static_cast<SdrObjCustomShape*>(GetSdrObject())->GetObjectRotation();
         fAngle *= 100;
         rValue <<= static_cast<sal_Int32>(fAngle);
         return true;
@@ -1839,13 +1831,13 @@ bool SvxCustomShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
 
 void SvxCustomShape::createCustomShapeDefaults( const OUString& rValueType )
 {
-    if (!mpObj.is())
+    if (!HasSdrObject())
     {
         OSL_FAIL("could not create Custom Shape Defaults!");
         return;
     }
 
-    static_cast<SdrObjCustomShape*>(mpObj.get())->MergeDefaultAttributes( &rValueType );
+    static_cast<SdrObjCustomShape*>(GetSdrObject())->MergeDefaultAttributes( &rValueType );
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/source/unodraw/unoshap3.cxx b/svx/source/unodraw/unoshap3.cxx
index c7bbc8bc1c65..663dcc9f6bd9 100644
--- a/svx/source/unodraw/unoshap3.cxx
+++ b/svx/source/unodraw/unoshap3.cxx
@@ -119,13 +119,13 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape
 
     SvxShape* pShape = SvxShape::getImplementation( xShape );
 
-    if(!mpObj.is() || !mxPage.is() || pShape == nullptr || nullptr != pShape->GetSdrObject() )
+    if(!HasSdrObject() || !mxPage.is() || pShape == nullptr || nullptr != pShape->GetSdrObject() )
         throw uno::RuntimeException();
 
     SdrObject* pSdrShape = mxPage->CreateSdrObject_( xShape );
     if( dynamic_cast<const E3dObject* >(pSdrShape) !=  nullptr )
     {
-        mpObj->GetSubList()->NbcInsertObject( pSdrShape );
+        GetSdrObject()->GetSubList()->NbcInsertObject( pSdrShape );
 
         if(pShape)
             pShape->Create( pSdrShape, mxPage.get()  );
@@ -136,8 +136,7 @@ void SAL_CALL Svx3DSceneObject::add( const Reference< drawing::XShape >& xShape
         throw uno::RuntimeException();
     }
 
-    if( mpModel )
-        mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 }
 
 
@@ -147,11 +146,11 @@ void SAL_CALL Svx3DSceneObject::remove( const Reference< drawing::XShape >& xSha
 
     SvxShape* pShape = SvxShape::getImplementation( xShape );
 
-    if(!mpObj.is() || pShape == nullptr)
+    if(!HasSdrObject() || pShape == nullptr)
         throw uno::RuntimeException();
 
     SdrObject* pSdrShape = pShape->GetSdrObject();
-    if(pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != mpObj.get())
+    if(pSdrShape == nullptr || pSdrShape->GetObjList()->GetOwnerObj() != GetSdrObject())
     {
         throw uno::RuntimeException();
     }
@@ -185,8 +184,8 @@ sal_Int32 SAL_CALL Svx3DSceneObject::getCount()
 
     sal_Int32 nRetval = 0;
 
-    if(mpObj.is() && dynamic_cast<const E3dScene* >(mpObj.get()) != nullptr && mpObj->GetSubList())
-        nRetval = mpObj->GetSubList()->GetObjCount();
+    if(HasSdrObject() && dynamic_cast<const E3dScene* >(GetSdrObject()) != nullptr && GetSdrObject()->GetSubList())
+        nRetval = GetSdrObject()->GetSubList()->GetObjCount();
     return nRetval;
 }
 
@@ -195,13 +194,13 @@ uno::Any SAL_CALL Svx3DSceneObject::getByIndex( sal_Int32 Index )
 {
     SolarMutexGuard aGuard;
 
-    if( !mpObj.is() || mpObj->GetSubList() == nullptr )
+    if( !HasSdrObject() || GetSdrObject()->GetSubList() == nullptr )
         throw uno::RuntimeException();
 
-    if( Index<0 || mpObj->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
+    if( Index<0 || GetSdrObject()->GetSubList()->GetObjCount() <= static_cast<size_t>(Index) )
         throw lang::IndexOutOfBoundsException();
 
-    SdrObject* pDestObj = mpObj->GetSubList()->GetObj( Index );
+    SdrObject* pDestObj = GetSdrObject()->GetSubList()->GetObj( Index );
     if(pDestObj == nullptr)
         throw lang::IndexOutOfBoundsException();
 
@@ -222,7 +221,7 @@ sal_Bool SAL_CALL Svx3DSceneObject::hasElements()
 {
     SolarMutexGuard aGuard;
 
-    return mpObj.is() && mpObj->GetSubList() && (mpObj->GetSubList()->GetObjCount() > 0);
+    return HasSdrObject() && GetSdrObject()->GetSubList() && (GetSdrObject()->GetSubList()->GetObjCount() > 0);
 }
 
 
@@ -259,14 +258,14 @@ bool Svx3DSceneObject::setPropertyValueImpl( const OUString& rName, const SfxIte
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // patch transformation matrix to the object
-        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
             return true;
         break;
     }
     case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY:
     {
         // set CameraGeometry at scene
-        E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() );
+        E3dScene* pScene = static_cast< E3dScene* >( GetSdrObject() );
         drawing::CameraGeometry aCamGeo;
 
         if(rValue >>= aCamGeo)
@@ -371,13 +370,13 @@ bool Svx3DSceneObject::getPropertyValueImpl(const OUString& rName, const SfxItem
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // patch object to a homogeneous 4x4 matrix
-        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
         break;
     }
     case OWN_ATTR_3D_VALUE_CAMERA_GEOMETRY:
     {
         // get CameraGeometry from scene
-        E3dScene* pScene = static_cast< E3dScene* >( mpObj.get() );
+        E3dScene* pScene = static_cast< E3dScene* >( GetSdrObject() );
         drawing::CameraGeometry aCamGeo;
 
         // fill Vectors from scene camera
@@ -433,7 +432,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformationmatrix to the object
-        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
             return true;
         break;
     }
@@ -444,7 +443,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
         if( rValue >>= aUnoPos )
         {
             basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ);
-            static_cast< E3dCubeObj* >( mpObj.get() )->SetCubePos(aPos);
+            static_cast< E3dCubeObj* >( GetSdrObject() )->SetCubePos(aPos);
             return true;
         }
         break;
@@ -456,7 +455,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
         if( rValue >>= aDirection )
         {
             basegfx::B3DVector aSize(aDirection.DirectionX, aDirection.DirectionY, aDirection.DirectionZ);
-            static_cast< E3dCubeObj* >( mpObj.get() )->SetCubeSize(aSize);
+            static_cast< E3dCubeObj* >( GetSdrObject() )->SetCubeSize(aSize);
             return true;
         }
         break;
@@ -467,7 +466,7 @@ bool Svx3DCubeObject::setPropertyValueImpl( const OUString& rName, const SfxItem
         // pack sal_Bool bPosIsCenter to the object
         if( rValue >>= bNew )
         {
-            static_cast< E3dCubeObj* >( mpObj.get() )->SetPosIsCenter(bNew);
+            static_cast< E3dCubeObj* >( GetSdrObject() )->SetPosIsCenter(bNew);
             return true;
         }
         break;
@@ -486,13 +485,13 @@ bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItem
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformation to a homogeneous matrix
-        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
         break;
     }
     case OWN_ATTR_3D_VALUE_POSITION:
     {
         // pack position
-        const basegfx::B3DPoint& rPos = static_cast<E3dCubeObj*>(mpObj.get())->GetCubePos();
+        const basegfx::B3DPoint& rPos = static_cast<E3dCubeObj*>(GetSdrObject())->GetCubePos();
         drawing::Position3D aPos;
 
         aPos.PositionX = rPos.getX();
@@ -505,7 +504,7 @@ bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItem
     case OWN_ATTR_3D_VALUE_SIZE:
     {
         // pack size
-        const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(mpObj.get())->GetCubeSize();
+        const basegfx::B3DVector& rSize = static_cast<E3dCubeObj*>(GetSdrObject())->GetCubeSize();
         drawing::Direction3D aDir;
 
         aDir.DirectionX = rSize.getX();
@@ -517,7 +516,7 @@ bool Svx3DCubeObject::getPropertyValueImpl( const OUString& rName, const SfxItem
     }
     case OWN_ATTR_3D_VALUE_POS_IS_CENTER:
     {
-        rValue <<= static_cast<E3dCubeObj*>(mpObj.get())->GetPosIsCenter();
+        rValue <<= static_cast<E3dCubeObj*>(GetSdrObject())->GetPosIsCenter();
         break;
     }
     default:
@@ -552,7 +551,7 @@ bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxIt
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformation matrix to the object
-        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
             return true;
         break;
     }
@@ -564,7 +563,7 @@ bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxIt
         if( rValue >>= aUnoPos )
         {
             basegfx::B3DPoint aPos(aUnoPos.PositionX, aUnoPos.PositionY, aUnoPos.PositionZ);
-            static_cast<E3dSphereObj*>(mpObj.get())->SetCenter(aPos);
+            static_cast<E3dSphereObj*>(GetSdrObject())->SetCenter(aPos);
             return true;
         }
         break;
@@ -577,7 +576,7 @@ bool Svx3DSphereObject::setPropertyValueImpl( const OUString& rName, const SfxIt
         if( rValue >>= aDir )
         {
             basegfx::B3DVector aPos(aDir.DirectionX, aDir.DirectionY, aDir.DirectionZ);
-            static_cast<E3dSphereObj*>(mpObj.get())->SetSize(aPos);
+            static_cast<E3dSphereObj*>(GetSdrObject())->SetSize(aPos);
             return true;
         }
         break;
@@ -596,13 +595,13 @@ bool Svx3DSphereObject::getPropertyValueImpl( const OUString& rName, const SfxIt
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformation to a homogeneous matrix
-        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
         break;
     }
     case OWN_ATTR_3D_VALUE_POSITION:
     {
         // pack position
-        const basegfx::B3DPoint& rPos = static_cast<E3dSphereObj*>(mpObj.get())->Center();
+        const basegfx::B3DPoint& rPos = static_cast<E3dSphereObj*>(GetSdrObject())->Center();
         drawing::Position3D aPos;
 
         aPos.PositionX = rPos.getX();
@@ -615,7 +614,7 @@ bool Svx3DSphereObject::getPropertyValueImpl( const OUString& rName, const SfxIt
     case OWN_ATTR_3D_VALUE_SIZE:
     {
         // pack size
-        const basegfx::B3DVector& rSize = static_cast<E3dSphereObj*>(mpObj.get())->Size();
+        const basegfx::B3DVector& rSize = static_cast<E3dSphereObj*>(GetSdrObject())->Size();
         drawing::Direction3D aDir;
 
         aDir.DirectionX = rSize.getX();
@@ -745,7 +744,7 @@ bool Svx3DLatheObject::setPropertyValueImpl( const OUString& rName, const SfxIte
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformation matrix to the object
-        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
             return true;
         break;
     }
@@ -760,18 +759,18 @@ bool Svx3DLatheObject::setPropertyValueImpl( const OUString& rName, const SfxIte
             // #105127# SetPolyPoly3D sets the Svx3DVerticalSegmentsItem to the number
             // of points of the polygon. Thus, value gets lost. To avoid this, rescue
             // item here and re-set after setting the polygon.
-            const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments());
+            const sal_uInt32 nPrevVerticalSegs(static_cast<E3dLatheObj*>(GetSdrObject())->GetVerticalSegments());
 
             // set polygon
             const basegfx::B3DHomMatrix aIdentity;
             const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
-            static_cast<E3dLatheObj*>(mpObj.get())->SetPolyPoly2D(aB2DPolyPolygon);
-            const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(mpObj.get())->GetVerticalSegments());
+            static_cast<E3dLatheObj*>(GetSdrObject())->SetPolyPoly2D(aB2DPolyPolygon);
+            const sal_uInt32 nPostVerticalSegs(static_cast<E3dLatheObj*>(GetSdrObject())->GetVerticalSegments());
 
             if(nPrevVerticalSegs != nPostVerticalSegs)
             {
                 // restore the vertical segment count
-                static_cast<E3dLatheObj*>(mpObj.get())->SetMergedItem(makeSvx3DVerticalSegmentsItem(nPrevVerticalSegs));
+                static_cast<E3dLatheObj*>(GetSdrObject())->SetMergedItem(makeSvx3DVerticalSegmentsItem(nPrevVerticalSegs));
             }
             return true;
         }
@@ -792,14 +791,14 @@ bool Svx3DLatheObject::getPropertyValueImpl( const OUString& rName, const SfxIte
     {
         // pack transformation to a homogeneous matrix
         drawing::HomogenMatrix aHomMat;
-        basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform();
+        basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(GetSdrObject())->GetTransform();
         basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat);
         rValue <<= aHomMat;
         break;
     }
     case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
     {
-        const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(mpObj.get())->GetPolyPoly2D();
+        const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dLatheObj*>(GetSdrObject())->GetPolyPoly2D();
         const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
 
         B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue);
@@ -837,7 +836,7 @@ bool Svx3DExtrudeObject::setPropertyValueImpl( const OUString& rName, const SfxI
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformation matrix to the object
-        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
             return true;
         break;
     }
@@ -853,7 +852,7 @@ bool Svx3DExtrudeObject::setPropertyValueImpl( const OUString& rName, const SfxI
             // set polygon
             const basegfx::B3DHomMatrix aIdentity;
             const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
-            static_cast<E3dExtrudeObj*>(mpObj.get())->SetExtrudePolygon(aB2DPolyPolygon);
+            static_cast<E3dExtrudeObj*>(GetSdrObject())->SetExtrudePolygon(aB2DPolyPolygon);
             return true;
         }
         break;
@@ -873,7 +872,7 @@ bool Svx3DExtrudeObject::getPropertyValueImpl( const OUString& rName, const SfxI
     {
         // pack transformation to a homogeneous matrix
         drawing::HomogenMatrix aHomMat;
-        basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(mpObj.get())->GetTransform();
+        basegfx::B3DHomMatrix aMat = static_cast<E3dObject*>(GetSdrObject())->GetTransform();
         basegfx::utils::B3DHomMatrixToUnoHomogenMatrix(aMat, aHomMat);
         rValue <<= aHomMat;
         break;
@@ -882,7 +881,7 @@ bool Svx3DExtrudeObject::getPropertyValueImpl( const OUString& rName, const SfxI
     case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
     {
         // pack polygon definition
-        const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(mpObj.get())->GetExtrudePolygon();
+        const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dExtrudeObj*>(GetSdrObject())->GetExtrudePolygon();
         const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
 
         B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon, rValue);
@@ -920,7 +919,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
         // pack transformation matrix to the object
-        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( mpObj.get() ), rValue ) )
+        if( ConvertHomogenMatrixToObject( static_cast< E3dObject* >( GetSdrObject() ), rValue ) )
             return true;
         break;
     }
@@ -934,7 +933,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
         if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
         {
             // set polygon
-            static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyPolygon3D(aNewB3DPolyPolygon);
+            static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyPolygon3D(aNewB3DPolyPolygon);
             return true;
         }
         break;
@@ -948,7 +947,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
         if( PolyPolygonShape3D_to_B3dPolyPolygon( rValue, aNewB3DPolyPolygon, false ) )
         {
             // set polygon
-            static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyNormals3D(aNewB3DPolyPolygon);
+            static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyNormals3D(aNewB3DPolyPolygon);
             return true;
         }
         break;
@@ -964,7 +963,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
             // set polygon
             const basegfx::B3DHomMatrix aIdentity;
             const basegfx::B2DPolyPolygon aB2DPolyPolygon(basegfx::utils::createB2DPolyPolygonFromB3DPolyPolygon(aNewB3DPolyPolygon, aIdentity));
-            static_cast<E3dPolygonObj*>(mpObj.get())->SetPolyTexture2D(aB2DPolyPolygon);
+            static_cast<E3dPolygonObj*>(GetSdrObject())->SetPolyTexture2D(aB2DPolyPolygon);
             return true;
         }
         break;
@@ -974,7 +973,7 @@ bool Svx3DPolygonObject::setPropertyValueImpl( const OUString& rName, const SfxI
         bool bNew = false;
         if( rValue >>= bNew )
         {
-            static_cast<E3dPolygonObj*>(mpObj.get())->SetLineOnly(bNew);
+            static_cast<E3dPolygonObj*>(GetSdrObject())->SetLineOnly(bNew);
             return true;
         }
         break;
@@ -992,26 +991,26 @@ bool Svx3DPolygonObject::getPropertyValueImpl( const OUString& rName, const SfxI
     {
     case OWN_ATTR_3D_VALUE_TRANSFORM_MATRIX:
     {
-        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( mpObj.get() ), rValue );
+        ConvertObjectToHomogenMatric( static_cast< E3dObject* >( GetSdrObject() ), rValue );
         break;
     }
 
     case OWN_ATTR_3D_VALUE_POLYPOLYGON3D:
     {
-        B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyPolygon3D(),rValue);
+        B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyPolygon3D(),rValue);
         break;
     }
 
     case OWN_ATTR_3D_VALUE_NORMALSPOLYGON3D:
     {
-        B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyNormals3D(),rValue);
+        B3dPolyPolygon_to_PolyPolygonShape3D(static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyNormals3D(),rValue);
         break;
     }
 
     case OWN_ATTR_3D_VALUE_TEXTUREPOLYGON3D:
     {
         // pack texture definition
-        const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(mpObj.get())->GetPolyTexture2D();
+        const basegfx::B2DPolyPolygon& rPolyPoly = static_cast<E3dPolygonObj*>(GetSdrObject())->GetPolyTexture2D();
         const basegfx::B3DPolyPolygon aB3DPolyPolygon(basegfx::utils::createB3DPolyPolygonFromB2DPolyPolygon(rPolyPoly));
 
         B3dPolyPolygon_to_PolyPolygonShape3D(aB3DPolyPolygon,rValue);
@@ -1020,7 +1019,7 @@ bool Svx3DPolygonObject::getPropertyValueImpl( const OUString& rName, const SfxI
 
     case OWN_ATTR_3D_VALUE_LINEONLY:
     {
-        rValue <<= static_cast<E3dPolygonObj*>(mpObj.get())->GetLineOnly();
+        rValue <<= static_cast<E3dPolygonObj*>(GetSdrObject())->GetLineOnly();
         break;
     }
 
diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx
index 08e33cf04c0f..c9e40652e372 100644
--- a/svx/source/unodraw/unoshap4.cxx
+++ b/svx/source/unodraw/unoshap4.cxx
@@ -90,10 +90,10 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
         // TODO/LATER: seems to make no sense for iconified object
 
         awt::Rectangle aVisArea;
-        if( (rValue >>= aVisArea) && dynamic_cast<const SdrOle2Obj* >(mpObj.get()) != nullptr)
+        if( (rValue >>= aVisArea) && dynamic_cast<const SdrOle2Obj* >(GetSdrObject()) != nullptr)
         {
             Size aTmp( aVisArea.X + aVisArea.Width, aVisArea.Y + aVisArea.Height );
-            uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef();
+            uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef();
             if( xObj.is() )
             {
                 try
@@ -118,7 +118,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
         sal_Int64 nAspect = 0;
         if( rValue >>= nAspect )
         {
-            static_cast<SdrOle2Obj*>(mpObj.get())->SetAspect( nAspect );
+            static_cast<SdrOle2Obj*>(GetSdrObject())->SetAspect( nAspect );
             return true;
         }
         break;
@@ -144,7 +144,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
         if( xGraphic.is() )
         {
             const Graphic aGraphic(xGraphic);
-            static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic(aGraphic);
+            static_cast<SdrOle2Obj*>(GetSdrObject())->SetGraphic(aGraphic);
             return true;
         }
         break;
@@ -154,7 +154,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
         uno::Reference< graphic::XGraphic > xGraphic( rValue, uno::UNO_QUERY );
         if( xGraphic.is() )
         {
-            SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+            SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
             if( pOle )
             {
                 GraphicObject aGrafObj( xGraphic );
@@ -172,10 +172,10 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro
         {
             SdrOle2Obj *pOle;
 #if OSL_DEBUG_LEVEL > 0
-            pOle = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+            pOle = dynamic_cast<SdrOle2Obj*>(GetSdrObject());
             assert(pOle);
 #else
-            pOle = static_cast<SdrOle2Obj*>(mpObj.get());
+            pOle = static_cast<SdrOle2Obj*>(GetSdrObject());
 #endif
             pOle->SetPersistName( aPersistName );
             return true;
@@ -220,7 +220,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
 
     case OWN_ATTR_METAFILE:
     {
-        SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get());
+        SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(GetSdrObject());
         if( pObj )
         {
             const Graphic* pGraphic = pObj->GetGraphic();
@@ -260,10 +260,10 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
     case OWN_ATTR_OLE_VISAREA:
     {
         awt::Rectangle aVisArea;
-        if( dynamic_cast<const SdrOle2Obj* >(mpObj.get()) != nullptr)
+        if( dynamic_cast<const SdrOle2Obj* >(GetSdrObject()) != nullptr)
         {
             MapMode aMapMode( MapUnit::Map100thMM ); // the API uses this map mode
-            Size aTmp = static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode
+            Size aTmp = static_cast<SdrOle2Obj*>(GetSdrObject())->GetOrigObjSize( &aMapMode ); // get the size in the requested map mode
             aVisArea = awt::Rectangle( 0, 0, aTmp.Width(), aTmp.Height() );
         }
 
@@ -273,14 +273,14 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
 
     case OWN_ATTR_OLESIZE:
     {
-        Size aTmp( static_cast<SdrOle2Obj*>(mpObj.get())->GetOrigObjSize() );
+        Size aTmp( static_cast<SdrOle2Obj*>(GetSdrObject())->GetOrigObjSize() );
         rValue <<= awt::Size( aTmp.Width(), aTmp.Height() );
         break;
     }
 
     case OWN_ATTR_OLE_ASPECT:
     {
-        rValue <<= static_cast<SdrOle2Obj*>(mpObj.get())->GetAspect();
+        rValue <<= static_cast<SdrOle2Obj*>(GetSdrObject())->GetAspect();
         break;
     }
 
@@ -288,7 +288,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
     case OWN_ATTR_OLE_EMBEDDED_OBJECT:
     case OWN_ATTR_OLE_EMBEDDED_OBJECT_NONEWCLIENT:
     {
-        SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( mpObj.get() );
+        SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>( GetSdrObject() );
         if( pObj )
         {
             uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
@@ -315,7 +315,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
     case OWN_ATTR_VALUE_GRAPHIC:
     {
         uno::Reference< graphic::XGraphic > xGraphic;
-        const Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic();
+        const Graphic* pGraphic = static_cast<SdrOle2Obj*>( GetSdrObject() )->GetGraphic();
         if( pGraphic )
             xGraphic = pGraphic->GetXGraphic();
         rValue <<= xGraphic;
@@ -325,7 +325,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
     case OWN_ATTR_THUMBNAIL:
     {
         uno::Reference< graphic::XGraphic > xGraphic;
-        const Graphic* pGraphic = static_cast<SdrOle2Obj*>( mpObj.get() )->GetGraphic();
+        const Graphic* pGraphic = static_cast<SdrOle2Obj*>( GetSdrObject() )->GetGraphic();
         if( pGraphic )
             xGraphic = pGraphic->GetXGraphic();
         rValue <<= xGraphic;
@@ -334,14 +334,14 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
     case OWN_ATTR_PERSISTNAME:
     {
         OUString    aPersistName;
-        SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+        SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
 
         if( pOle )
         {
             aPersistName = pOle->GetPersistName();
             if( !aPersistName.isEmpty() )
             {
-                ::comphelper::IEmbeddedHelper* pPersist(mpObj->getSdrModelFromSdrObject().GetPersist());
+                ::comphelper::IEmbeddedHelper* pPersist(GetSdrObject()->getSdrModelFromSdrObject().GetPersist());
                 if( (nullptr == pPersist) || !pPersist->getEmbeddedObjectContainer().HasEmbeddedObject( pOle->GetPersistName() ) )
                     aPersistName.clear();
             }
@@ -353,7 +353,7 @@ bool SvxOle2Shape::getPropertyValueImpl( const OUString& rName, const SfxItemPro
     case OWN_ATTR_OLE_LINKURL:
     {
         OUString    aLinkURL;
-        SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+        SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
 
         if( pOle )
         {
@@ -376,12 +376,12 @@ bool SvxOle2Shape::createObject( const SvGlobalName &aClassName )
 {
     DBG_TESTSOLARMUTEX();
 
-    SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+    SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
     if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
         return false;
 
     // create storage and inplace object
-    ::comphelper::IEmbeddedHelper*     pPersist = mpModel->GetPersist();
+    ::comphelper::IEmbeddedHelper*     pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
     OUString              aPersistName;
     OUString            aTmpStr;
     if( SvxShape::getPropertyValue( UNO_NAME_OLE2_PERSISTNAME ) >>= aTmpStr )
@@ -438,13 +438,13 @@ void SvxOle2Shape::createLink( const OUString& aLinkURL )
 {
     DBG_TESTSOLARMUTEX();
 
-    SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+    SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
     if ( !pOle2Obj || !pOle2Obj->IsEmpty() )
         return;
 
     OUString aPersistName;
 
-    ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+    ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
 
     uno::Sequence< beans::PropertyValue > aMediaDescr( 1 );
     aMediaDescr[0].Name = "URL";
@@ -497,10 +497,10 @@ void SvxOle2Shape::createLink( const OUString& aLinkURL )
 
 void SvxOle2Shape::resetModifiedState()
 {
-    ::comphelper::IEmbeddedHelper* pPersist = mpModel ? mpModel->GetPersist() : nullptr;
+    ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
     if( pPersist && !pPersist->isEnableSetModified() )
     {
-        SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+        SdrOle2Obj* pOle = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
         if( pOle && !pOle->IsEmpty() )
         {
             uno::Reference < util::XModifiable > xMod( pOle->GetObjRef(), uno::UNO_QUERY );
@@ -515,7 +515,7 @@ const SvGlobalName SvxOle2Shape::GetClassName_Impl(OUString& rHexCLSID)
 {
     DBG_TESTSOLARMUTEX();
     SvGlobalName aClassName;
-    SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( mpObj.get() );
+    SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( GetSdrObject() );
 
     if( pOle2Obj )
     {
@@ -523,7 +523,7 @@ const SvGlobalName SvxOle2Shape::GetClassName_Impl(OUString& rHexCLSID)
 
         if( pOle2Obj->IsEmpty() )
         {
-            ::comphelper::IEmbeddedHelper* pPersist = mpModel->GetPersist();
+            ::comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist();
             if( pPersist )
             {
                 uno::Reference < embed::XEmbeddedObject > xObj =
@@ -584,9 +584,9 @@ bool SvxAppletShape::setPropertyValueImpl( const OUString& rName, const SfxItemP
 {
     if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) )
     {
-        if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+        if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
         {
-            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
             if( xSet.is() )
             {
                 // allow exceptions to pass through
@@ -605,9 +605,9 @@ bool SvxAppletShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
 {
     if( (pProperty->nWID >= OWN_ATTR_APPLET_DOCBASE) && (pProperty->nWID <= OWN_ATTR_APPLET_ISSCRIPT) )
     {
-        if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+        if ( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
         {
-            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
             if( xSet.is() )
             {
                 rValue = xSet->getPropertyValue( rName );
@@ -655,9 +655,9 @@ bool SvxPluginShape::setPropertyValueImpl( const OUString& rName, const SfxItemP
 {
     if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) )
     {
-        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
         {
-            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
             if( xSet.is() )
             {
                 // allow exceptions to pass through
@@ -676,9 +676,9 @@ bool SvxPluginShape::getPropertyValueImpl( const OUString& rName, const SfxItemP
 {
     if( (pProperty->nWID >= OWN_ATTR_PLUGIN_MIMETYPE) && (pProperty->nWID <= OWN_ATTR_PLUGIN_COMMANDS) )
     {
-        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
         {
-            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
             if( xSet.is() )
             {
                 rValue = xSet->getPropertyValue( rName );
@@ -727,9 +727,9 @@ bool SvxFrameShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
 {
     if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) )
     {
-        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
         {
-            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
             if( xSet.is() )
             {
                 // allow exceptions to pass through
@@ -749,9 +749,9 @@ bool SvxFrameShape::getPropertyValueImpl(const OUString& rName, const SfxItemPro
 {
     if( (pProperty->nWID >= OWN_ATTR_FRAME_URL) && (pProperty->nWID <= OWN_ATTR_FRAME_MARGIN_HEIGHT) )
     {
-        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef() ) )
+        if( svt::EmbeddedObjectRef::TryRunningState( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef() ) )
         {
-            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(mpObj.get())->GetObjRef()->getComponent(), uno::UNO_QUERY );
+            uno::Reference < beans::XPropertySet > xSet( static_cast<SdrOle2Obj*>(GetSdrObject())->GetObjRef()->getComponent(), uno::UNO_QUERY );
             if( xSet.is() )
             {
                 rValue = xSet->getPropertyValue( rName );
@@ -783,7 +783,7 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr
         || (pProperty->nWID == OWN_ATTR_MEDIA_STREAM)
         || (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE) )
     {
-        SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
+        SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
         ::avmedia::MediaItem aItem;
         bool bOk = false;
 
@@ -926,7 +926,7 @@ bool SvxMediaShape::getPropertyValueImpl( const OUString& rName, const SfxItemPr
         || (pProperty->nWID == OWN_ATTR_MEDIA_MIMETYPE)
         || (pProperty->nWID == OWN_ATTR_FALLBACK_GRAPHIC))
     {
-        SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( mpObj.get() );
+        SdrMediaObj* pMedia = static_cast< SdrMediaObj* >( GetSdrObject() );
         const ::avmedia::MediaItem aItem( pMedia->getMediaProperties() );
 
         switch( pProperty->nWID )
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 2fed79812c7d..506e6143f1e0 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -180,8 +180,7 @@ SvxShape::SvxShape( SdrObject* pObject )
 ,   mbIsMultiPropertyCall(false)
 ,   mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
 ,   maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
-,   mpObj(pObject)
-,   mpModel(nullptr)
+,   mpSdrObjectWeakReference(pObject)
 ,   mnLockCount(0)
 {
     impl_construct();
@@ -194,8 +193,7 @@ SvxShape::SvxShape( SdrObject* pObject, const SfxItemPropertyMapEntry* pEntries,
 ,   mbIsMultiPropertyCall(false)
 ,   mpPropSet(pPropertySet)
 ,   maPropMapEntries(pEntries)
-,   mpObj(pObject)
-,   mpModel(nullptr)
+,   mpSdrObjectWeakReference(pObject)
 ,   mnLockCount(0)
 {
     impl_construct();
@@ -208,8 +206,7 @@ SvxShape::SvxShape()
 ,   mbIsMultiPropertyCall(false)
 ,   mpPropSet(getSvxMapProvider().GetPropertySet(SVXMAP_SHAPE, SdrObject::GetGlobalDrawObjectItemPool()))
 ,   maPropMapEntries(getSvxMapProvider().GetMap(SVXMAP_SHAPE))
-,   mpObj(nullptr)
-,   mpModel(nullptr)
+,   mpSdrObjectWeakReference(nullptr)
 ,   mnLockCount(0)
 {
     impl_construct();
@@ -222,19 +219,19 @@ SvxShape::~SvxShape() throw()
 
     DBG_ASSERT( mnLockCount == 0, "Locked shape was disposed!" );
 
-    if ( mpModel )
-        EndListening( *mpModel );
-
     if ( mpImpl->mpMaster )
         mpImpl->mpMaster->dispose();
 
-    if ( mpObj.is() )
-        mpObj->setUnoShape(nullptr);
+    if ( HasSdrObject() )
+    {
+        EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+        GetSdrObject()->setUnoShape(nullptr);
+    }
 
-    if( HasSdrObjectOwnership() && mpObj.is() )
+    if( HasSdrObjectOwnership() && HasSdrObject() )
     {
         mpImpl->mbHasSdrObjectOwnership = false;
-        SdrObject* pObject = mpObj.get();
+        SdrObject* pObject = GetSdrObject();
         SdrObject::Free( pObject );
     }
 
@@ -248,13 +245,23 @@ void SvxShape::TakeSdrObjectOwnership()
 }
 
 
+void SvxShape::InvalidateSdrObject()
+{
+    if(HasSdrObject())
+    {
+        EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+    }
+
+    mpSdrObjectWeakReference.reset( nullptr );
+};
+
 bool SvxShape::HasSdrObjectOwnership() const
 {
     if ( !mpImpl->mbHasSdrObjectOwnership )
         return false;
 
-    OSL_ENSURE( mpObj.is(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
-    return mpObj.is();
+    OSL_ENSURE( HasSdrObject(), "SvxShape::HasSdrObjectOwnership: have the ownership of an object which I don't know!" );
+    return HasSdrObject();
 }
 
 
@@ -335,40 +342,31 @@ void SvxShape::impl_construct()
     mpImpl->maPropertyNotifier.registerProvider( svx::ShapeProperty::Size,
         std::shared_ptr<svx::IPropertyValueProvider>( new ShapeSizeProvider( *mpImpl ) ) );
 
-    if ( mpObj.is() )
+    if ( HasSdrObject() )
+    {
+        StartListening(GetSdrObject()->getSdrModelFromSdrObject());
         impl_initFromSdrObject();
+    }
 }
 
 
 void SvxShape::impl_initFromSdrObject()
 {
     DBG_TESTSOLARMUTEX();
-    OSL_PRECOND( mpObj.is(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
-    if ( !mpObj.is() )
+    OSL_PRECOND( HasSdrObject(), "SvxShape::impl_initFromSdrObject: not to be called without SdrObject!" );
+    if ( !HasSdrObject() )
         return;
 
     osl_atomic_increment( &m_refCount );
     {
-        mpObj->setUnoShape(*this);
+        GetSdrObject()->setUnoShape(*this);
     }
     osl_atomic_decrement( &m_refCount );
 
-    auto pNewModel = &mpObj->getSdrModelFromSdrObject();
-
-    if (pNewModel != mpModel)
-    {
-        if (mpModel)
-            EndListening( *mpModel );
-        if (pNewModel)
-            StartListening( *pNewModel );
-        mpModel = pNewModel;
-    }
-
     // #i40944#
     // Do not simply return when no model but do the type corrections
     // following below.
-
-    const SdrInventor nInventor = mpObj->GetObjInventor();
+    const SdrInventor nInventor = GetSdrObject()->GetObjInventor();
 
     // is it one of ours (svx) ?
     if( nInventor == SdrInventor::Default || nInventor == SdrInventor::E3d || nInventor == SdrInventor::FmForm )
@@ -379,7 +377,7 @@ void SvxShape::impl_initFromSdrObject()
         }
         else
         {
-            mpImpl->mnObjId = mpObj->GetObjIdentifier();
+            mpImpl->mnObjId = GetSdrObject()->GetObjIdentifier();
             if( nInventor == SdrInventor::E3d )
                 mpImpl->mnObjId |= E3D_INVENTOR_FLAG;
         }
@@ -415,12 +413,17 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
     // Correct condition (#i52126#)
     mpImpl->mpCreatedObj = pNewObj;
 
-    if( mpObj.is() )
+    if( HasSdrObject() )
     {
-        EndListening( mpObj->getSdrModelFromSdrObject() );
+        EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
     }
 
-    mpObj.reset( pNewObj );
+    mpSdrObjectWeakReference.reset( pNewObj );
+
+    if( HasSdrObject() )
+    {
+        StartListening( GetSdrObject()->getSdrModelFromSdrObject() );
+    }
 
     OSL_ENSURE( !mbIsMultiPropertyCall, "SvxShape::Create: hmm?" );
         // this was previously set in impl_initFromSdrObject, but I think it was superfluous
@@ -431,19 +434,19 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
     ObtainSettingsFromPropertySet( *mpPropSet );
 
     // save user call
-    SdrObjUserCall* pUser = mpObj->GetUserCall();
-    mpObj->SetUserCall(nullptr);
+    SdrObjUserCall* pUser = GetSdrObject()->GetUserCall();
+    GetSdrObject()->SetUserCall(nullptr);
 
     setPosition( maPosition );
     setSize( maSize );
 
     // restore user call after we set the initial size
-    mpObj->SetUserCall( pUser );
+    GetSdrObject()->SetUserCall( pUser );
 
     // if this shape was already named, use this name
     if( !maShapeName.isEmpty() )
     {
-        mpObj->SetName( maShapeName );
+        GetSdrObject()->SetName( maShapeName );
         maShapeName.clear();
     }
 }
@@ -451,9 +454,9 @@ void SvxShape::Create( SdrObject* pNewObj, SvxDrawPage* /*pNewPage*/ )
 void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
 {
     DBG_TESTSOLARMUTEX();
-    if(mpModel)
+    if(HasSdrObject())
     {
-        MapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
+        MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
         if(eMapUnit != MapUnit::Map100thMM)
         {
             switch(eMapUnit)
@@ -477,9 +480,9 @@ void SvxShape::ForceMetricToItemPoolMetric(Pair& rPoint) const throw()
 void SvxShape::ForceMetricToItemPoolMetric(basegfx::B2DPolyPolygon& rPolyPolygon) const throw()
 {
     DBG_TESTSOLARMUTEX();
-    if(mpModel)
+    if(HasSdrObject())
     {
-        MapUnit eMapUnit = mpModel->GetItemPool().GetMetric(0);
+        MapUnit eMapUnit(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0));
         if(eMapUnit != MapUnit::Map100thMM)
         {
             switch(eMapUnit)
@@ -507,9 +510,9 @@ void SvxShape::ForceMetricTo100th_mm(Pair& rPoint) const throw()
 {
     DBG_TESTSOLARMUTEX();
     MapUnit eMapUnit = MapUnit::Map100thMM;
-    if(mpModel)
+    if(HasSdrObject())
     {
-        eMapUnit = mpModel->GetItemPool().GetMetric(0);
+        eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
         if(eMapUnit != MapUnit::Map100thMM)
         {
             switch(eMapUnit)
@@ -534,9 +537,9 @@ void SvxShape::ForceMetricTo100th_mm(basegfx::B2DPolyPolygon& rPolyPolygon) cons
 {
     DBG_TESTSOLARMUTEX();
     MapUnit eMapUnit = MapUnit::Map100thMM;
-    if(mpModel)
+    if(HasSdrObject())
     {
-        eMapUnit = mpModel->GetItemPool().GetMetric(0);
+        eMapUnit = GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetMetric(0);
         if(eMapUnit != MapUnit::Map100thMM)
         {
             switch(eMapUnit)
@@ -616,15 +619,15 @@ void SvxItemPropertySet_ObtainSettingsFromPropertySet(const SvxItemPropertySet&
 void SvxShape::ObtainSettingsFromPropertySet(const SvxItemPropertySet& rPropSet)
 {
     DBG_TESTSOLARMUTEX();
-    if(mpObj.is() && rPropSet.AreThereOwnUsrAnys() && mpModel)
+    if(HasSdrObject() && rPropSet.AreThereOwnUsrAnys())
     {
-        SfxItemSet aSet( mpModel->GetItemPool(), svl::Items<SDRATTR_START, SDRATTR_END>{});
+        SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), svl::Items<SDRATTR_START, SDRATTR_END>{});
         Reference< beans::XPropertySet > xShape( static_cast<OWeakObject*>(this), UNO_QUERY );
         SvxItemPropertySet_ObtainSettingsFromPropertySet(rPropSet, aSet, xShape, &mpPropSet->getPropertyMap() );
 
-        mpObj->SetMergedItemSetAndBroadcast(aSet);
+        GetSdrObject()->SetMergedItemSetAndBroadcast(aSet);
 
-        mpObj->ApplyNotPersistAttr( aSet );
+        GetSdrObject()->ApplyNotPersistAttr( aSet );
     }
 }
 
@@ -633,21 +636,21 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
     DBG_TESTSOLARMUTEX();
     uno::Any aAny;
 
-    if( !mpObj.is() || mpModel == nullptr || !mpObj->IsInserted() || nullptr == mpObj->GetPage() )
+    if( !HasSdrObject() || !GetSdrObject()->IsInserted() || nullptr == GetSdrObject()->GetPage() )
         return aAny;
 
     ScopedVclPtrInstance< VirtualDevice > pVDev;
     pVDev->SetMapMode(MapMode(MapUnit::Map100thMM));
-    SdrPage* pPage = mpObj->GetPage();
+    SdrPage* pPage = GetSdrObject()->GetPage();
 
     std::unique_ptr<E3dView> pView(
         new E3dView(
-            mpObj->getSdrModelFromSdrObject(),
+            GetSdrObject()->getSdrModelFromSdrObject(),
             pVDev.get()));
     pView->hideMarkHandles();
     SdrPageView* pPageView = pView->ShowSdrPage(pPage);
 
-    SdrObject *pTempObj = mpObj.get();
+    SdrObject *pTempObj = GetSdrObject();
     pView->MarkObj(pTempObj,pPageView);
 
     tools::Rectangle aRect(pTempObj->GetCurrentBoundRect());
@@ -977,7 +980,7 @@ uno::Sequence< sal_Int8 > SAL_CALL SvxShape::getImplementationId()
 void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
 {
     DBG_TESTSOLARMUTEX();
-    if( !mpObj.is() )
+    if( !HasSdrObject() )
         return;
 
     // #i55919# SdrHintKind::ObjectChange is only interesting if it's for this object
@@ -985,13 +988,14 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
     const SdrHint* pSdrHint = dynamic_cast<const SdrHint*>(&rHint);
     if (!pSdrHint ||
         ((pSdrHint->GetKind() != SdrHintKind::ModelCleared) &&
-         (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != mpObj.get() )))
+         (pSdrHint->GetKind() != SdrHintKind::ObjectChange || pSdrHint->GetObject() != GetSdrObject() )))
         return;
 
-    uno::Reference< uno::XInterface > xSelf( mpObj->getWeakUnoShape() );
+    uno::Reference< uno::XInterface > xSelf( GetSdrObject()->getWeakUnoShape() );
     if( !xSelf.is() )
     {
-        mpObj.reset( nullptr );
+        EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+        mpSdrObjectWeakReference.reset( nullptr );
         return;
     }
 
@@ -1007,7 +1011,6 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
         case SdrHintKind::ModelCleared:
         {
             bClearMe = true;
-            mpModel = nullptr;
             break;
         }
         default:
@@ -1017,9 +1020,13 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw()
     if( bClearMe )
     {
         if( !HasSdrObjectOwnership() ) {
-            if( mpObj.is() )
-                mpObj->setUnoShape( nullptr );
-            mpObj.reset( nullptr );
+            if( HasSdrObject() )
+            {
+                EndListening(GetSdrObject()->getSdrModelFromSdrObject());
+                GetSdrObject()->setUnoShape( nullptr );
+            }
+
+            mpSdrObjectWeakReference.reset( nullptr );
         }
         if ( !mpImpl->mbDisposing )
             dispose();
@@ -1091,14 +1098,14 @@ awt::Point SAL_CALL SvxShape::getPosition()
 {
     ::SolarMutexGuard aGuard;
 
-    if( mpObj.is() && mpModel)
+    if(HasSdrObject())
     {
-        tools::Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+        tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
         Point aPt( aRect.Left(), aRect.Top() );
 
         // Position is relative to anchor, so recalc to absolute position
-        if( mpModel->IsWriter() )
-            aPt -= mpObj->GetAnchorPos();
+        if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+            aPt -= GetSdrObject()->GetAnchorPos();
 
         ForceMetricTo100th_mm(aPt);
         return css::awt::Point( aPt.X(), aPt.Y() );
@@ -1114,25 +1121,25 @@ void SAL_CALL SvxShape::setPosition( const awt::Point& Position )
 {
     ::SolarMutexGuard aGuard;
 
-    if( mpObj.is() && mpModel )
+    if(HasSdrObject())
     {
         // do NOT move 3D objects, this would change the homogen
         // transformation matrix
-        if(dynamic_cast<const E3dCompoundObject* >(mpObj.get()) == nullptr)
+        if(dynamic_cast<const E3dCompoundObject* >(GetSdrObject()) == nullptr)
         {
-            tools::Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+            tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
             Point aLocalPos( Position.X, Position.Y );
             ForceMetricToItemPoolMetric(aLocalPos);
 
             // Position is absolute, so recalc to position relative to anchor
-            if( mpModel->IsWriter() )
-                aLocalPos += mpObj->GetAnchorPos();
+            if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+                aLocalPos += GetSdrObject()->GetAnchorPos();
 
             long nDX = aLocalPos.X() - aRect.Left();
             long nDY = aLocalPos.Y() - aRect.Top();
 
-            mpObj->Move( Size( nDX, nDY ) );
-            mpModel->SetChanged();
+            GetSdrObject()->Move( Size( nDX, nDY ) );
+            GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
         }
     }
 
@@ -1144,9 +1151,9 @@ awt::Size SAL_CALL SvxShape::getSize()
 {
     ::SolarMutexGuard aGuard;
 
-    if( mpObj.is() && mpModel)
+    if(HasSdrObject())
     {
-        tools::Rectangle aRect( svx_getLogicRectHack(mpObj.get()) );
+        tools::Rectangle aRect( svx_getLogicRectHack(GetSdrObject()) );
         Size aObjSize( aRect.getWidth(), aRect.getHeight() );
         ForceMetricTo100th_mm(aObjSize);
         return css::awt::Size( aObjSize.getWidth(), aObjSize.getHeight() );
@@ -1160,26 +1167,26 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
 {
     ::SolarMutexGuard aGuard;
 
-    if( mpObj.is() && mpModel)
+    if(HasSdrObject())
     {
         // #i123539# optimization for 3D chart object generation: do not use UNO
         // API commands to get the range, this is too expensive since for 3D
         // scenes it may recalculate the whole scene since in AOO this depends
         // on the contained geometry (layouted to show all content)
-        const bool b3DConstruction(dynamic_cast< E3dObject* >(mpObj.get()) && mpModel->isLocked());
+        const bool b3DConstruction(dynamic_cast< E3dObject* >(GetSdrObject()) && GetSdrObject()->getSdrModelFromSdrObject().isLocked());
         tools::Rectangle aRect(
             b3DConstruction ?
                 tools::Rectangle(maPosition.X, maPosition.Y, maSize.Width, maSize.Height) :
-                svx_getLogicRectHack(mpObj.get()) );
+                svx_getLogicRectHack(GetSdrObject()) );
         Size aLocalSize( rSize.Width, rSize.Height );
         ForceMetricToItemPoolMetric(aLocalSize);
 
-        if(mpObj->GetObjInventor() == SdrInventor::Default && mpObj->GetObjIdentifier() == OBJ_MEASURE )
+        if(GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == OBJ_MEASURE )
         {
             Fraction aWdt(aLocalSize.Width(),aRect.Right()-aRect.Left());
             Fraction aHgt(aLocalSize.Height(),aRect.Bottom()-aRect.Top());
-            Point aPt = mpObj->GetSnapRect().TopLeft();
-            mpObj->Resize(aPt,aWdt,aHgt);
+            Point aPt = GetSdrObject()->GetSnapRect().TopLeft();
+            GetSdrObject()->Resize(aPt,aWdt,aHgt);
         }
         else
         {
@@ -1197,10 +1204,10 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
             else
                 aRect.setHeight(aLocalSize.Height());
 
-            svx_setLogicRectHack( mpObj.get(), aRect );
+            svx_setLogicRectHack( GetSdrObject(), aRect );
         }
 
-        mpModel->SetChanged();
+        GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
     }
     maSize = rSize;
 }
@@ -1210,9 +1217,9 @@ void SAL_CALL SvxShape::setSize( const awt::Size& rSize )
 OUString SAL_CALL SvxShape::getName(  )
 {
     ::SolarMutexGuard aGuard;
-    if( mpObj.is() )
+    if( HasSdrObject() )
     {
-        return mpObj->GetName();
+        return GetSdrObject()->GetName();
     }
     else
     {
@@ -1224,9 +1231,9 @@ OUString SAL_CALL SvxShape::getName(  )
 void SAL_CALL SvxShape::setName( const OUString& aName )
 {
     ::SolarMutexGuard aGuard;
-    if( mpObj.is() )
+    if( HasSdrObject() )
     {
-        mpObj->SetName( aName );
+        GetSdrObject()->SetName( aName );
     }
     else
     {
@@ -1262,47 +1269,42 @@ void SAL_CALL SvxShape::dispose()
     mpImpl->maDisposeListeners.disposeAndClear(aEvt);
     mpImpl->maPropertyNotifier.disposing();
 
-    if ( mpObj.is() )
+    if ( HasSdrObject() )
     {
+        EndListening( GetSdrObject()->getSdrModelFromSdrObject() );
         bool bFreeSdrObject = false;
 
-        if ( mpObj->IsInserted() && mpObj->GetPage() )
+        if ( GetSdrObject()->IsInserted() && GetSdrObject()->GetPage() )
         {
             OSL_ENSURE( HasSdrObjectOwnership(), "SvxShape::dispose: is the below code correct?" );
                 // normally, we are allowed to free the SdrObject only if we have its ownership.
                 // Why isn't this checked here?
 
-            SdrPage* pPage = mpObj->GetPage();
+            SdrPage* pPage = GetSdrObject()->GetPage();
             // delete the SdrObject from the page
             const size_t nCount = pPage->GetObjCount();
             for ( size_t nNum = 0; nNum < nCount; ++nNum )
             {
-                if ( pPage->GetObj( nNum ) == mpObj.get() )
+                if ( pPage->GetObj( nNum ) == GetSdrObject() )
                 {
-                    OSL_VERIFY( pPage->RemoveObject( nNum ) == mpObj.get() );
+                    OSL_VERIFY( pPage->RemoveObject( nNum ) == GetSdrObject() );
                     bFreeSdrObject = true;
                     break;
                 }
             }
         }
 
-        mpObj->setUnoShape(nullptr);
+        GetSdrObject()->setUnoShape(nullptr);
 
         if ( bFreeSdrObject )
         {
             // in case we have the ownership of the SdrObject, a Free
             // would do nothing. So ensure the ownership is reset.
             mpImpl->mbHasSdrObjectOwnership = false;
-            SdrObject* pObject = mpObj.get();
+            SdrObject* pObject = GetSdrObject();
             SdrObject::Free( pObject );
         }
     }
-
-    if( mpModel )
-    {
-        EndListening( *mpModel );
-        mpModel = nullptr;
-    }
 }
 
 
@@ -1368,19 +1370,20 @@ void SAL_CALL SvxShape::removeVetoableChangeListener( const OUString& , const Re
 
 bool SvxShape::SetFillAttribute( sal_uInt16 nWID, const OUString& rName )
 {
-    SfxItemSet aSet( mpModel->GetItemPool(),    {{nWID, nWID}} );
-
-    if( SetFillAttribute( nWID, rName, aSet, mpModel ) )
+    if(HasSdrObject())
     {
-        //mpObj->SetItemSetAndBroadcast(aSet);
-        mpObj->SetMergedItemSetAndBroadcast(aSet);
+        SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{nWID, nWID}} );
 
-        return true;
-    }
-    else
-    {
-        return false;
+        if( SetFillAttribute( nWID, rName, aSet, &GetSdrObject()->getSdrModelFromSdrObject() ) )
+        {
+            //GetSdrObject()->SetItemSetAndBroadcast(aSet);
+            GetSdrObject()->SetMergedItemSetAndBroadcast(aSet);
+
+            return true;
+        }
     }
+
+    return false;
 }
 
 
@@ -1563,7 +1566,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
 
     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(rPropertyName);
 
-    if (!mpObj.is() || !mpModel)
+    if (!HasSdrObject())
     {
         // Since we have no actual sdr object right now, remember all
         // properties in a list. These properties will be set when the sdr
@@ -1578,6 +1581,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
             //        supported after creation.
             mpPropSet->setPropertyValue( pMap, rVal );
         }
+
         return;
     }
 
@@ -1592,7 +1596,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
             "Readonly property can't be set: " + rPropertyName,
             uno::Reference<drawing::XShape>(this));
 
-    mpModel->SetChanged();
+    GetSdrObject()->getSdrModelFromSdrObject().SetChanged();
 
     if (setPropertyValueImpl(rPropertyName, pMap, rVal))
         return;
@@ -1614,7 +1618,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
     {
         if( mpImpl->mpItemSet == nullptr )
         {
-            pSet = mpImpl->mpItemSet = mpObj->GetMergedItemSet().Clone();
+            pSet = mpImpl->mpItemSet = GetSdrObject()->GetMergedItemSet().Clone();
         }
         else
         {
@@ -1623,11 +1627,11 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
     }
     else
     {
-        pSet = new SfxItemSet( mpModel->GetItemPool(),  {{pMap->nWID, pMap->nWID}});
+        pSet = new SfxItemSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(),  {{pMap->nWID, pMap->nWID}});
     }
 
     if( pSet->GetItemState( pMap->nWID ) != SfxItemState::SET )
-        pSet->Put(mpObj->GetMergedItem(pMap->nWID));
+        pSet->Put(GetSdrObject()->GetMergedItem(pMap->nWID));
 
     if( !SvxUnoTextRangeBase::SetPropertyValueHelper( pMap, rVal, *pSet ))
     {
@@ -1636,7 +1640,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
             if(bIsNotPersist)
             {
                 // not-persistent attribute, get those extra
-                mpObj->TakeNotPersistAttr(*pSet);
+                GetSdrObject()->TakeNotPersistAttr(*pSet);
             }
         }
 
@@ -1644,7 +1648,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
         {
             // get default from ItemPool
             if(SfxItemPool::IsWhich(pMap->nWID))
-                pSet->Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+                pSet->Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
         }
 
         if( pSet->GetItemState( pMap->nWID ) == SfxItemState::SET )
@@ -1656,7 +1660,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
     if(bIsNotPersist)
     {
         // set not-persistent attribute extra
-        mpObj->ApplyNotPersistAttr( *pSet );
+        GetSdrObject()->ApplyNotPersistAttr( *pSet );
         delete pSet;
     }
     else
@@ -1665,7 +1669,7 @@ void SvxShape::_setPropertyValue( const OUString& rPropertyName, const uno::Any&
         // will be set in setPropertyValues later
         if( !mbIsMultiPropertyCall )
         {
-            mpObj->SetMergedItemSetAndBroadcast( *pSet );
+            GetSdrObject()->SetMergedItemSetAndBroadcast( *pSet );
 
             delete pSet;
         }
@@ -1689,7 +1693,7 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
 
     uno::Any aAny;
-    if( mpObj.is() && mpModel )
+    if(HasSdrObject())
     {
         if(pMap == nullptr )
             throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
@@ -1699,8 +1703,8 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
             DBG_ASSERT( pMap->nWID == SDRATTR_TEXTDIRECTION || (pMap->nWID < SDRATTR_NOTPERSIST_FIRST || pMap->nWID > SDRATTR_NOTPERSIST_LAST), "Not persist item not handled!" );
             DBG_ASSERT( pMap->nWID < OWN_ATTR_VALUE_START || pMap->nWID > OWN_ATTR_VALUE_END, "Not item property not handled!" );
 
-            SfxItemSet aSet( mpModel->GetItemPool(),    {{pMap->nWID, pMap->nWID}});
-            aSet.Put(mpObj->GetMergedItem(pMap->nWID));
+            SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(),    {{pMap->nWID, pMap->nWID}});
+            aSet.Put(GetSdrObject()->GetMergedItem(pMap->nWID));
 
             if(SvxUnoTextRangeBase::GetPropertyValueHelper(  aSet, pMap, aAny ))
                 return aAny;
@@ -1710,7 +1714,7 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
                 if(pMap->nWID >= SDRATTR_NOTPERSIST_FIRST && pMap->nWID <= SDRATTR_NOTPERSIST_LAST)
                 {
                     // not-persistent attribute, get those extra
-                    mpObj->TakeNotPersistAttr(aSet);
+                    GetSdrObject()->TakeNotPersistAttr(aSet);
                 }
             }
 
@@ -1718,7 +1722,7 @@ uno::Any SvxShape::_getPropertyValue( const OUString& PropertyName )
             {
                 // get default from ItemPool
                 if(SfxItemPool::IsWhich(pMap->nWID))
-                    aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID));
+                    aSet.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID));
             }
 
             if(aSet.Count())
@@ -1783,8 +1787,8 @@ void SAL_CALL SvxShape::setPropertyValues( const css::uno::Sequence< OUString >&
         }
     }
 
-    if( mpImpl->mpItemSet && mpObj.is() )
-        mpObj->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
+    if( mpImpl->mpItemSet && HasSdrObject() )
+        GetSdrObject()->SetMergedItemSetAndBroadcast( *mpImpl->mpItemSet );
 }
 
 
@@ -1886,10 +1890,10 @@ uno::Any SvxShape::GetAnyForItem( SfxItemSet const & aSet, const SfxItemProperty
 
     case SDRATTR_CIRCKIND:
     {
-        if( mpObj->GetObjInventor() == SdrInventor::Default)
+        if( GetSdrObject()->GetObjInventor() == SdrInventor::Default)
         {
             drawing::CircleKind eKind;
-            switch(mpObj->GetObjIdentifier())
+            switch(GetSdrObject()->GetObjIdentifier())
             {
             case OBJ_CIRC:          // circle, ellipse
                 eKind = drawing::CircleKind_FULL;
@@ -1954,13 +1958,13 @@ beans::PropertyState SvxShape::_getPropertyState( const OUString& PropertyName )
 
     const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(PropertyName);
 
-    if( !mpObj.is() || pMap == nullptr )
+    if( !HasSdrObject() || pMap == nullptr )
         throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this));
 
     beans::PropertyState eState;
     if( !getPropertyStateImpl( pMap, eState ) )
     {
-        const SfxItemSet& rSet = mpObj->GetMergedItemSet();
+        const SfxItemSet& rSet = GetSdrObject()->GetMergedItemSet();
 
         switch( rSet.GetItemState( pMap->nWID, false ) )
         {
@@ -2029,7 +2033,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
             // #90763# position is relative to top left, make it absolute
             basegfx::B2DPolyPolygon aNewPolyPolygon;
             basegfx::B2DHomMatrix aNewHomogenMatrix;
-            mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+            GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
 
             aVclPoint.AdjustX(basegfx::fround(aNewHomogenMatrix.get(0, 2)) );
             aVclPoint.AdjustY(basegfx::fround(aNewHomogenMatrix.get(1, 2)) );
@@ -2038,12 +2042,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
             ForceMetricToItemPoolMetric(aVclPoint);
 
             // #88491# position relative to anchor
-            if( mpModel->IsWriter() )
+            if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
             {
-                aVclPoint += mpObj->GetAnchorPos();
+                aVclPoint += GetSdrObject()->GetAnchorPos();
             }
 
-            static_cast<SdrCaptionObj*>(mpObj.get())->SetTailPos(aVclPoint);
+            static_cast<SdrCaptionObj*>(GetSdrObject())->SetTailPos(aVclPoint);
 
             return true;
         }
@@ -2057,7 +2061,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
             basegfx::B2DPolyPolygon aNewPolyPolygon;
             basegfx::B2DHomMatrix aNewHomogenMatrix;
 
-            mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+            GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
 
             aNewHomogenMatrix.set(0, 0, aMatrix.Line1.Column1);
             aNewHomogenMatrix.set(0, 1, aMatrix.Line1.Column2);
@@ -2069,7 +2073,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
             aNewHomogenMatrix.set(2, 1, aMatrix.Line3.Column2);
             aNewHomogenMatrix.set(2, 2, aMatrix.Line3.Column3);
 
-            mpObj->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
+            GetSdrObject()->TRSetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon);
             return true;
         }
         break;
@@ -2080,12 +2084,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
         sal_Int32 nNewOrdNum = 0;
         if(rValue >>= nNewOrdNum)
         {
-            SdrObjList* pObjList = mpObj->GetObjList();
+            SdrObjList* pObjList = GetSdrObject()->GetObjList();
             if( pObjList )
             {
                 SdrObject* pCheck =
-                            pObjList->SetObjectOrdNum( mpObj->GetOrdNum(), static_cast<size_t>(nNewOrdNum) );
-                DBG_ASSERT( pCheck == mpObj.get(), "GetOrdNum() failed!" );
+                            pObjList->SetObjectOrdNum( GetSdrObject()->GetOrdNum(), static_cast<size_t>(nNewOrdNum) );
+                DBG_ASSERT( pCheck == GetSdrObject(), "GetOrdNum() failed!" );
             }
             return true;
         }
@@ -2103,7 +2107,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
             tools::Rectangle aRect;
             aRect.SetPos(aTopLeft);
             aRect.SetSize(aObjSize);
-            mpObj->SetSnapRect(aRect);
+            GetSdrObject()->SetSnapRect(aRect);
             return true;
         }
         break;
@@ -2113,7 +2117,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
         bool bMirror;
         if(rValue >>= bMirror )
         {
-            SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( mpObj.get() );
+            SdrGrafObj* pObj = dynamic_cast< SdrGrafObj* >( GetSdrObject() );
             if( pObj )
                 pObj->SetMirrored(bMirror);
             return true;
@@ -2128,7 +2132,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
     case OWN_ATTR_EDGE_END_POS:
     case OWN_ATTR_EDGE_POLYPOLYGONBEZIER:
     {
-        SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(mpObj.get());
+        SdrEdgeObj* pEdgeObj = dynamic_cast< SdrEdgeObj* >(GetSdrObject());
         if(pEdgeObj)
         {
             switch(pProperty->nWID)
@@ -2162,8 +2166,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
                         // perform metric change before applying anchor position,
                         // because the anchor position is in pool metric.
                         ForceMetricToItemPoolMetric( aPoint );
-                        if( mpModel->IsWriter() )
-                            aPoint += mpObj->GetAnchorPos();
+                        if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
+                            aPoint += GetSdrObject()->GetAnchorPos();
 
                         pEdgeObj->SetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS, aPoint );
                         return true;
@@ -2204,9 +2208,9 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
                     {
                         // Reintroduction of fix for issue i59051 (#i108851#)
                         ForceMetricToItemPoolMetric( aNewPolyPolygon );
-                        if( mpModel->IsWriter() )
+                        if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() )
                         {
-                            Point aPoint( mpObj->GetAnchorPos() );
+                            Point aPoint( GetSdrObject()->GetAnchorPos() );

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list