diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-02 12:04:28 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-06 18:06:37 +0200 |
commit | ccba0c81c5f560ddb0287c442d5a3b471d66bf0a (patch) | |
tree | 24eacda9033183171cadc783e40297595cdd409b | |
parent | b11248537d7fbc1d914118f24a1611d8f069c2c2 (diff) |
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
Change-Id: I17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
-rw-r--r-- | include/svx/unoshape.hxx | 15 | ||||
-rw-r--r-- | svx/source/unodraw/tableshape.cxx | 34 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap2.cxx | 178 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap3.cxx | 101 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap4.cxx | 80 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 483 |
6 files changed, 446 insertions, 445 deletions
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 d3931b6134a4..34106635f1cb 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -181,7 +181,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; @@ -201,10 +201,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 @@ -219,8 +219,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 @@ -243,7 +242,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(); @@ -280,8 +279,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 ) @@ -307,10 +305,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; } @@ -319,13 +317,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(); @@ -347,7 +345,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) @@ -440,10 +438,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(); } @@ -454,11 +451,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(); } @@ -466,11 +462,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(); } @@ -478,11 +473,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) @@ -574,7 +568,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(); @@ -586,12 +580,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 @@ -985,14 +978,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; } @@ -1095,8 +1088,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); @@ -1149,8 +1142,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); } @@ -1158,9 +1151,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 { @@ -1197,15 +1190,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; } @@ -1238,7 +1231,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); @@ -1261,8 +1254,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); } @@ -1270,9 +1263,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 { @@ -1305,7 +1298,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; } } @@ -1314,7 +1307,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; } } @@ -1325,7 +1318,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; } } @@ -1341,9 +1334,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; } @@ -1355,7 +1348,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; @@ -1366,7 +1359,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; @@ -1377,7 +1370,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; @@ -1388,7 +1381,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; @@ -1399,7 +1392,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; @@ -1410,7 +1403,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; @@ -1421,7 +1414,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; @@ -1432,7 +1425,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; @@ -1443,7 +1436,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; @@ -1454,7 +1447,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; @@ -1467,8 +1460,7 @@ bool SvxGraphicObject::setPropertyValueImpl( const OUString& rName, const SfxIte if( !bOk ) throw lang::IllegalArgumentException(); - if( mpModel ) - mpModel->SetChanged(); + GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); return true; } @@ -1479,7 +1471,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) { @@ -1501,7 +1493,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) { @@ -1513,7 +1505,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; @@ -1522,7 +1514,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; @@ -1531,62 +1523,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; } @@ -1657,21 +1649,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 ) @@ -1725,8 +1717,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() ); @@ -1740,7 +1732,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 @@ -1826,7 +1818,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; @@ -1838,13 +1830,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 18572b659066..ba0aa389a447 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() ); aNewPolyPolygon.transform(basegfx::utils::createTranslateB2DHomMatrix(aPoint.X(), aPoint.Y())); } pEdgeObj->SetEdgeTrackPath( aNewPolyPolygon ); @@ -2220,7 +2224,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_MEASURE_START_POS: case OWN_ATTR_MEASURE_END_POS: { - SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(mpObj.get()); + SdrMeasureObj* pMeasureObj = dynamic_cast< SdrMeasureObj* >(GetSdrObject()); awt::Point aUnoPoint; if(pMeasureObj && ( rValue >>= aUnoPoint ) ) { @@ -2228,8 +2232,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl // Reintroduction of fix for issue #i59051# (#i108851#) ForceMetricToItemPoolMetric( aPoint ); - if( mpModel->IsWriter() ) - aPoint += mpObj->GetAnchorPos(); + if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() ) + aPoint += GetSdrObject()->GetAnchorPos(); pMeasureObj->NbcSetPoint( aPoint, pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ); pMeasureObj->SetChanged(); @@ -2249,8 +2253,8 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl eMode = static_cast<drawing::BitmapMode>(nMode); } - mpObj->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) ); - mpObj->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) ); + GetSdrObject()->SetMergedItem( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) ); + GetSdrObject()->SetMergedItem( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) ); return true; } @@ -2259,10 +2263,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl sal_Int16 nLayerId = sal_Int16(); if( rValue >>= nLayerId ) { - SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId)); + SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(SdrLayerID(nLayerId)); if( pLayer ) { - mpObj->SetLayer(SdrLayerID(nLayerId)); + GetSdrObject()->SetLayer(SdrLayerID(nLayerId)); return true; } } @@ -2274,10 +2278,10 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl OUString aLayerName; if( rValue >>= aLayerName ) { - const SdrLayer* pLayer=mpModel->GetLayerAdmin().GetLayer(aLayerName); + const SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayer(aLayerName); if( pLayer != nullptr ) { - mpObj->SetLayer( pLayer->GetID() ); + GetSdrObject()->SetLayer( pLayer->GetID() ); return true; } } @@ -2288,13 +2292,13 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl sal_Int32 nAngle = 0; if( rValue >>= nAngle ) { - Point aRef1(mpObj->GetSnapRect().Center()); - nAngle -= mpObj->GetRotateAngle(); + Point aRef1(GetSdrObject()->GetSnapRect().Center()); + nAngle -= GetSdrObject()->GetRotateAngle(); if (nAngle!=0) { double nSin=sin(nAngle*nPi180); double nCos=cos(nAngle*nPi180); - mpObj->Rotate(aRef1,nAngle,nSin,nCos); + GetSdrObject()->Rotate(aRef1,nAngle,nSin,nCos); } return true; } @@ -2307,12 +2311,12 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl sal_Int32 nShear = 0; if( rValue >>= nShear ) { - nShear -= mpObj->GetShearAngle(); + nShear -= GetSdrObject()->GetShearAngle(); if(nShear != 0 ) { - Point aRef1(mpObj->GetSnapRect().Center()); + Point aRef1(GetSdrObject()->GetSnapRect().Center()); double nTan=tan(nShear*nPi180); - mpObj->Shear(aRef1,nShear,nTan,false); + GetSdrObject()->Shear(aRef1,nShear,nTan,false); return true; } } @@ -2322,7 +2326,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_INTEROPGRABBAG: { - mpObj->SetGrabBagItem(rValue); + GetSdrObject()->SetGrabBagItem(rValue); return true; } @@ -2331,7 +2335,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl bool bMoveProtect; if( rValue >>= bMoveProtect ) { - mpObj->SetMoveProtect(bMoveProtect); + GetSdrObject()->SetMoveProtect(bMoveProtect); return true; } break; @@ -2341,7 +2345,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl OUString aName; if( rValue >>= aName ) { - mpObj->SetName( aName ); + GetSdrObject()->SetName( aName ); return true; } break; @@ -2353,7 +2357,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl OUString aTitle; if( rValue >>= aTitle ) { - mpObj->SetTitle( aTitle ); + GetSdrObject()->SetTitle( aTitle ); return true; } break; @@ -2363,7 +2367,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl OUString aDescription; if( rValue >>= aDescription ) { - mpObj->SetDescription( aDescription ); + GetSdrObject()->SetDescription( aDescription ); return true; } break; @@ -2374,7 +2378,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl bool bPrintable; if( rValue >>= bPrintable ) { - mpObj->SetPrintable(bPrintable); + GetSdrObject()->SetPrintable(bPrintable); return true; } break; @@ -2384,7 +2388,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl bool bVisible; if( rValue >>= bVisible ) { - mpObj->SetVisible(bVisible); + GetSdrObject()->SetVisible(bVisible); return true; } break; @@ -2394,7 +2398,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl bool bResizeProtect; if( rValue >>= bResizeProtect ) { - mpObj->SetResizeProtect(bResizeProtect); + GetSdrObject()->SetResizeProtect(bResizeProtect); return true; } break; @@ -2404,7 +2408,7 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl sal_Int32 nPageNum = 0; if( (rValue >>= nPageNum) && ( nPageNum >= 0 ) && ( nPageNum <= 0xffff ) ) { - SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(mpObj.get()); + SdrPageObj* pPageObj = dynamic_cast< SdrPageObj* >(GetSdrObject()); if( pPageObj ) { SdrModel& rModel(pPageObj->getSdrModelFromSdrObject()); @@ -2461,12 +2465,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl { case OWN_ATTR_CAPTION_POINT: { - Point aVclPoint = static_cast<SdrCaptionObj*>(mpObj.get())->GetTailPos(); + Point aVclPoint = static_cast<SdrCaptionObj*>(GetSdrObject())->GetTailPos(); // #88491# make pos relative to anchor - if( mpModel->IsWriter() ) + if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() ) { - aVclPoint -= mpObj->GetAnchorPos(); + aVclPoint -= GetSdrObject()->GetAnchorPos(); } // #88657# metric of pool maybe twips (writer) @@ -2475,7 +2479,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl // #90763# pos is absolute, make it relative to top left 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))) ); @@ -2489,7 +2493,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl { basegfx::B2DPolyPolygon aNewPolyPolygon; basegfx::B2DHomMatrix aNewHomogenMatrix; - mpObj->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); + GetSdrObject()->TRGetBaseGeometry(aNewHomogenMatrix, aNewPolyPolygon); drawing::HomogenMatrix3 aMatrix; aMatrix.Line1.Column1 = aNewHomogenMatrix.get(0, 0); @@ -2509,7 +2513,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_ZORDER: { - rValue <<= static_cast<sal_Int32>(mpObj->GetOrdNum()); + rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetOrdNum()); break; } @@ -2524,13 +2528,13 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_ISFONTWORK: { - rValue <<= dynamic_cast<const SdrTextObj*>(mpObj.get()) != nullptr && static_cast<SdrTextObj*>(mpObj.get())->IsFontwork(); + rValue <<= dynamic_cast<const SdrTextObj*>(GetSdrObject()) != nullptr && static_cast<SdrTextObj*>(GetSdrObject())->IsFontwork(); break; } case OWN_ATTR_FRAMERECT: { - tools::Rectangle aRect( mpObj->GetSnapRect() ); + tools::Rectangle aRect( GetSdrObject()->GetSnapRect() ); Point aTopLeft( aRect.TopLeft() ); Size aObjSize( aRect.GetWidth(), aRect.GetHeight() ); ForceMetricTo100th_mm(aTopLeft); @@ -2544,7 +2548,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_BOUNDRECT: { - tools::Rectangle aRect( mpObj->GetCurrentBoundRect() ); + tools::Rectangle aRect( GetSdrObject()->GetCurrentBoundRect() ); Point aTopLeft( aRect.TopLeft() ); Size aObjSize( aRect.GetWidth(), aRect.GetHeight() ); ForceMetricTo100th_mm(aTopLeft); @@ -2558,7 +2562,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_LDNAME: { - OUString aName( mpObj->GetName() ); + OUString aName( GetSdrObject()->GetName() ); rValue <<= aName; break; } @@ -2566,11 +2570,11 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_LDBITMAP: { OUString sId; - if( mpObj->GetObjInventor() == SdrInventor::Default && mpObj->GetObjIdentifier() == OBJ_OLE2 ) + if( GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == OBJ_OLE2 ) { sId = RID_UNODRAW_OLE2; } - else if( mpObj->GetObjInventor() == SdrInventor::Default && mpObj->GetObjIdentifier() == OBJ_GRAF ) + else if( GetSdrObject()->GetObjInventor() == SdrInventor::Default && GetSdrObject()->GetObjIdentifier() == OBJ_GRAF ) { sId = RID_UNODRAW_GRAPHICS; } @@ -2589,8 +2593,8 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_MIRRORED: { bool bMirror = false; - if( mpObj.is() && dynamic_cast<const SdrGrafObj*>(mpObj.get()) != nullptr ) - bMirror = static_cast<SdrGrafObj*>(mpObj.get())->IsMirrored(); + if( HasSdrObject() && dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr ) + bMirror = static_cast<SdrGrafObj*>(GetSdrObject())->IsMirrored(); rValue <<= bMirror; break; @@ -2604,7 +2608,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_GLUEID_TAIL: case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: { - SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(mpObj.get()); + SdrEdgeObj* pEdgeObj = dynamic_cast<SdrEdgeObj*>(GetSdrObject()); if(pEdgeObj) { switch(pProperty->nWID) @@ -2627,8 +2631,8 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_EDGE_END_POS: { Point aPoint( pEdgeObj->GetTailPoint( pProperty->nWID == OWN_ATTR_EDGE_START_POS ) ); - if( mpModel->IsWriter() ) - aPoint -= mpObj->GetAnchorPos(); + if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() ) + aPoint -= GetSdrObject()->GetAnchorPos(); ForceMetricTo100th_mm( aPoint ); awt::Point aUnoPoint( aPoint.X(), aPoint.Y() ); @@ -2645,9 +2649,9 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_EDGE_POLYPOLYGONBEZIER: { basegfx::B2DPolyPolygon aPolyPoly( pEdgeObj->GetEdgeTrackPath() ); - if( mpModel->IsWriter() ) + if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() ) { - Point aPoint( mpObj->GetAnchorPos() ); + Point aPoint( GetSdrObject()->GetAnchorPos() ); aPolyPoly.transform(basegfx::utils::createTranslateB2DHomMatrix(-aPoint.X(), -aPoint.Y())); } // Reintroduction of fix for issue #i59051# (#i108851#) @@ -2665,12 +2669,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_MEASURE_START_POS: case OWN_ATTR_MEASURE_END_POS: { - SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(mpObj.get()); + SdrMeasureObj* pMeasureObj = dynamic_cast<SdrMeasureObj*>(GetSdrObject()); if(pMeasureObj) { Point aPoint( pMeasureObj->GetPoint( pProperty->nWID == OWN_ATTR_MEASURE_START_POS ? 0 : 1 ) ); - if( mpModel->IsWriter() ) - aPoint -= mpObj->GetAnchorPos(); + if( GetSdrObject()->getSdrModelFromSdrObject().IsWriter() ) + aPoint -= GetSdrObject()->GetAnchorPos(); // Reintroduction of fix for issue #i59051# (#i108851#) ForceMetricTo100th_mm( aPoint ); @@ -2684,7 +2688,7 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_FILLBMP_MODE: { - const SfxItemSet& rObjItemSet = mpObj->GetMergedItemSet(); + const SfxItemSet& rObjItemSet = GetSdrObject()->GetMergedItemSet(); const XFillBmpStretchItem* pStretchItem = &rObjItemSet.Get(XATTR_FILLBMP_STRETCH); const XFillBmpTileItem* pTileItem = &rObjItemSet.Get(XATTR_FILLBMP_TILE); @@ -2704,12 +2708,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl break; } case SDRATTR_LAYERID: - rValue <<= sal_uInt16(sal_uInt8(mpObj->GetLayer())); + rValue <<= sal_uInt16(sal_uInt8(GetSdrObject()->GetLayer())); break; case SDRATTR_LAYERNAME: { - SdrLayer* pLayer = mpModel->GetLayerAdmin().GetLayerPerID(mpObj->GetLayer()); + SdrLayer* pLayer = GetSdrObject()->getSdrModelFromSdrObject().GetLayerAdmin().GetLayerPerID(GetSdrObject()->GetLayer()); if( pLayer ) { OUString aName( pLayer->GetName() ); @@ -2719,26 +2723,26 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl } case SDRATTR_ROTATEANGLE: - rValue <<= static_cast<sal_Int32>(mpObj->GetRotateAngle()); + rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetRotateAngle()); break; case SDRATTR_SHEARANGLE: - rValue <<= static_cast<sal_Int32>(mpObj->GetShearAngle()); + rValue <<= static_cast<sal_Int32>(GetSdrObject()->GetShearAngle()); break; case OWN_ATTR_INTEROPGRABBAG: { - mpObj->GetGrabBagItem(rValue); + GetSdrObject()->GetGrabBagItem(rValue); break; } case SDRATTR_OBJMOVEPROTECT: - rValue <<= mpObj->IsMoveProtect(); + rValue <<= GetSdrObject()->IsMoveProtect(); break; case SDRATTR_OBJECTNAME: { - OUString aName( mpObj->GetName() ); + OUString aName( GetSdrObject()->GetName() ); rValue <<= aName; break; } @@ -2746,33 +2750,33 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl // #i68101# case OWN_ATTR_MISC_OBJ_TITLE: { - OUString aTitle( mpObj->GetTitle() ); + OUString aTitle( GetSdrObject()->GetTitle() ); rValue <<= aTitle; break; } case OWN_ATTR_MISC_OBJ_DESCRIPTION: { - OUString aDescription( mpObj->GetDescription() ); + OUString aDescription( GetSdrObject()->GetDescription() ); rValue <<= aDescription; break; } case SDRATTR_OBJPRINTABLE: - rValue <<= mpObj->IsPrintable(); + rValue <<= GetSdrObject()->IsPrintable(); break; case SDRATTR_OBJVISIBLE: - rValue <<= mpObj->IsVisible(); + rValue <<= GetSdrObject()->IsVisible(); break; case SDRATTR_OBJSIZEPROTECT: - rValue <<= mpObj->IsResizeProtect(); + rValue <<= GetSdrObject()->IsResizeProtect(); break; case OWN_ATTR_PAGE_NUMBER: { - SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(mpObj.get()); + SdrPageObj* pPageObj = dynamic_cast<SdrPageObj*>(GetSdrObject()); if(pPageObj) { SdrPage* pPage = pPageObj->GetReferencedPage(); @@ -2786,18 +2790,18 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl case OWN_ATTR_UINAME_SINGULAR: { - rValue <<= mpObj->TakeObjNameSingul(); + rValue <<= GetSdrObject()->TakeObjNameSingul(); break; } case OWN_ATTR_UINAME_PLURAL: { - rValue <<= mpObj->TakeObjNamePlural(); + rValue <<= GetSdrObject()->TakeObjNamePlural(); break; } case OWN_ATTR_METAFILE: { - SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(mpObj.get()); + SdrOle2Obj* pObj = dynamic_cast<SdrOle2Obj*>(GetSdrObject()); if( pObj ) { const Graphic* pGraphic = pObj->GetGraphic(); @@ -2846,7 +2850,7 @@ bool SvxShape::getPropertyStateImpl( const SfxItemPropertySimpleEntry* pProperty { if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE ) { - const SfxItemSet& rSet = mpObj->GetMergedItemSet(); + const SfxItemSet& rSet = GetSdrObject()->GetMergedItemSet(); if( rSet.GetItemState( XATTR_FILLBMP_STRETCH, false ) == SfxItemState::SET || rSet.GetItemState( XATTR_FILLBMP_TILE, false ) == SfxItemState::SET ) @@ -2876,8 +2880,8 @@ bool SvxShape::setPropertyToDefaultImpl( const SfxItemPropertySimpleEntry* pProp { if( pProperty->nWID == OWN_ATTR_FILLBMP_MODE ) { - mpObj->ClearMergedItem( XATTR_FILLBMP_STRETCH ); - mpObj->ClearMergedItem( XATTR_FILLBMP_TILE ); + GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_STRETCH ); + GetSdrObject()->ClearMergedItem( XATTR_FILLBMP_TILE ); return true; } else if((pProperty->nWID >= OWN_ATTR_VALUE_START && pProperty->nWID <= OWN_ATTR_VALUE_END ) || @@ -2925,15 +2929,15 @@ void SvxShape::_setPropertyToDefault( const OUString& PropertyName ) const SfxItemPropertySimpleEntry* pProperty = mpPropSet->getPropertyMapEntry(PropertyName); - if( !mpObj.is() || mpModel == nullptr || pProperty == nullptr ) + if( !HasSdrObject() || pProperty == nullptr ) throw beans::UnknownPropertyException( PropertyName, static_cast<cppu::OWeakObject*>(this)); if( !setPropertyToDefaultImpl( pProperty ) ) { - mpObj->ClearMergedItem( pProperty->nWID ); + GetSdrObject()->ClearMergedItem( pProperty->nWID ); } - mpModel->SetChanged(); + GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); } @@ -2955,7 +2959,7 @@ uno::Any SvxShape::_getPropertyDefault( const OUString& aPropertyName ) const SfxItemPropertySimpleEntry* pMap = mpPropSet->getPropertyMapEntry(aPropertyName); - if( !mpObj.is() || pMap == nullptr || mpModel == nullptr ) + if( !HasSdrObject() || pMap == nullptr ) throw beans::UnknownPropertyException( aPropertyName, static_cast<cppu::OWeakObject*>(this)); if(( pMap->nWID >= OWN_ATTR_VALUE_START && pMap->nWID <= OWN_ATTR_VALUE_END ) || @@ -2968,8 +2972,8 @@ uno::Any SvxShape::_getPropertyDefault( const OUString& aPropertyName ) if(!SfxItemPool::IsWhich(pMap->nWID)) throw beans::UnknownPropertyException( "No WhichID " + OUString::number(pMap->nWID) + " for " + aPropertyName, static_cast<cppu::OWeakObject*>(this)); - SfxItemSet aSet( mpModel->GetItemPool(), {{pMap->nWID, pMap->nWID}}); - aSet.Put(mpModel->GetItemPool().GetDefaultItem(pMap->nWID)); + SfxItemSet aSet( GetSdrObject()->getSdrModelFromSdrObject().GetItemPool(), {{pMap->nWID, pMap->nWID}}); + aSet.Put(GetSdrObject()->getSdrModelFromSdrObject().GetItemPool().GetDefaultItem(pMap->nWID)); return GetAnyForItem( aSet, pMap ); } @@ -2979,15 +2983,15 @@ void SvxShape::setAllPropertiesToDefault() { ::SolarMutexGuard aGuard; - if( !mpObj.is() ) + if( !HasSdrObject() ) throw lang::DisposedException(); - mpObj->ClearMergedItem(); // nWhich == 0 => all + GetSdrObject()->ClearMergedItem(); // nWhich == 0 => all - if(dynamic_cast<const SdrGrafObj*>(mpObj.get()) != nullptr) + if(dynamic_cast<const SdrGrafObj*>(GetSdrObject()) != nullptr) { // defaults for graphic objects have changed: - mpObj->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) ); - mpObj->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) ); + GetSdrObject()->SetMergedItem( XFillStyleItem( drawing::FillStyle_NONE ) ); + GetSdrObject()->SetMergedItem( XLineStyleItem( drawing::LineStyle_NONE ) ); } // #i68523# special handling for Svx3DCharacterModeItem, this is not saved @@ -2995,13 +2999,12 @@ void SvxShape::setAllPropertiesToDefault() // does not load lathe or extrude objects, it is possible to set the items // here. // For other solution possibilities, see task description. - if( dynamic_cast<const E3dLatheObj* >(mpObj.get()) != nullptr|| dynamic_cast<const E3dExtrudeObj* >(mpObj.get()) != nullptr) + if( dynamic_cast<const E3dLatheObj* >(GetSdrObject()) != nullptr|| dynamic_cast<const E3dExtrudeObj* >(GetSdrObject()) != nullptr) { - mpObj->SetMergedItem(Svx3DCharacterModeItem(true)); + GetSdrObject()->SetMergedItem(Svx3DCharacterModeItem(true)); } - if (mpModel) - mpModel->SetChanged(); + GetSdrObject()->getSdrModelFromSdrObject().SetChanged(); } void SvxShape::setPropertiesToDefault( @@ -3089,9 +3092,9 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() { ::SolarMutexGuard aGuard; - if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor::Default) + if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::Default) { - const sal_uInt16 nIdent = mpObj->GetObjIdentifier(); + const sal_uInt16 nIdent = GetSdrObject()->GetObjIdentifier(); switch(nIdent) { @@ -3616,10 +3619,10 @@ uno::Sequence< OUString > SvxShape::_getSupportedServiceNames() } } } - else if( mpObj.is() && mpObj->GetObjInventor() == SdrInventor::FmForm) + else if( HasSdrObject() && GetSdrObject()->GetObjInventor() == SdrInventor::FmForm) { #if OSL_DEBUG_LEVEL > 0 - const sal_uInt16 nIdent = mpObj->GetObjIdentifier(); + const sal_uInt16 nIdent = GetSdrObject()->GetObjIdentifier(); OSL_ENSURE( nIdent == OBJ_UNO, "SvxShape::_getSupportedServiceNames: SdrInventor::FmForm, but no UNO object?" ); #endif static uno::Sequence< OUString > *pSeq = nullptr; @@ -3650,9 +3653,9 @@ uno::Reference< container::XIndexContainer > SAL_CALL SvxShape::getGluePoints() ::SolarMutexGuard aGuard; uno::Reference< container::XIndexContainer > xGluePoints( mxGluePoints ); - if( mpObj.is() && !xGluePoints.is() ) + if( HasSdrObject() && !xGluePoints.is() ) { - uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( mpObj.get() ), uno::UNO_QUERY ); + uno::Reference< container::XIndexContainer > xNew( SvxUnoGluePointAccess_createInstance( GetSdrObject() ), uno::UNO_QUERY ); mxGluePoints = xGluePoints = xNew; } @@ -3664,9 +3667,9 @@ uno::Reference<uno::XInterface> SAL_CALL SvxShape::getParent() { ::SolarMutexGuard aGuard; - if( mpObj.is() && mpObj->GetObjList() ) + if( HasSdrObject() && GetSdrObject()->GetObjList() ) { - SdrObjList* pObjList = mpObj->GetObjList(); + SdrObjList* pObjList = GetSdrObject()->GetObjList(); switch (pObjList->GetListKind()) { @@ -3786,7 +3789,7 @@ void SvxShape::updateShapeKind() case OBJ_PATHPOLY: case OBJ_PATHPLIN: { - const sal_uInt32 nId = mpObj->GetObjIdentifier(); + const sal_uInt32 nId = GetSdrObject()->GetObjIdentifier(); if( nId != mpImpl->mnObjId ) { @@ -3965,7 +3968,7 @@ bool SvxShapeText::setPropertyValueImpl( const OUString& rName, const SfxItemPro if( pProperty->nWID == SDRATTR_TEXTDIRECTION ) { - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() ); + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetSdrObject() ); if( pTextObj ) { css::text::WritingMode eMode; @@ -3983,7 +3986,7 @@ bool SvxShapeText::getPropertyValueImpl( const OUString& rName, const SfxItemPro { if( pProperty->nWID == SDRATTR_TEXTDIRECTION ) { - SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( mpObj.get() ); + SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( GetSdrObject() ); if( pTextObj && pTextObj->IsVerticalWriting() ) rValue <<= css::text::WritingMode_TB_RL; else |