diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-05-07 15:42:35 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-05-07 17:24:18 +0100 |
commit | 0e99a36c695d6349c8096654ddad70f962f312d0 (patch) | |
tree | e8a74e81bd5d0b42570846c83f7f21352c9a5156 | |
parent | 274e3ec0c06e667868eca1b75193500ba92d7c14 (diff) |
split clear and set graphic
Change-Id: I3e98e872574e9edbe97099e93d787cbbcced60dd
-rw-r--r-- | include/svx/svdoole2.hxx | 4 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unoobj.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/viewshe2.cxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdoole2.cxx | 26 | ||||
-rw-r--r-- | svx/source/unodraw/unoshap4.cxx | 2 |
6 files changed, 25 insertions, 19 deletions
diff --git a/include/svx/svdoole2.hxx b/include/svx/svdoole2.hxx index fc9af9e3651a..80fb05ed1b9a 100644 --- a/include/svx/svdoole2.hxx +++ b/include/svx/svdoole2.hxx @@ -55,7 +55,6 @@ private: SVX_DLLPRIVATE void AddListeners_Impl(); SVX_DLLPRIVATE void RemoveListeners_Impl(); SVX_DLLPRIVATE void GetObjRef_Impl(); - SVX_DLLPRIVATE void SetGraphic_Impl(const Graphic* pGrf); // #i118485# helper added SVX_DLLPRIVATE SdrObject* createSdrGrafObjReplacement(bool bAddText) const; @@ -81,7 +80,8 @@ public: // An OLE graphic object can contain a StarView graphic, // which will be displayed if the OLE object is empty. - void SetGraphic(const Graphic* pGrf); + void SetGraphic(const Graphic& rGrf); + void ClearGraphic(); const Graphic* GetGraphic() const; void GetNewReplacement(); diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 1395fe678ae1..d0220f6b631f 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -357,7 +357,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t pSdrObj = new SdrOle2Obj(); BitmapEx aBmpEx(BMP_PRESOBJ_OBJECT); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(&aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); } break; @@ -367,7 +367,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarChart" ); BitmapEx aBmpEx(BMP_PRESOBJ_CHART); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(&aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); } break; @@ -377,7 +377,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarOrg" ); BitmapEx aBmpEx(BMP_PRESOBJ_ORGCHART); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(&aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); } break; @@ -388,7 +388,7 @@ SdrObject* SdPage::CreatePresObj(PresObjKind eObjKind, bool bVertical, const ::t static_cast<SdrOle2Obj*>(pSdrObj)->SetProgName( "StarCalc" ); BitmapEx aBmpEx(BMP_PRESOBJ_TABLE); Graphic aGraphic( aBmpEx ); - static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(&aGraphic); + static_cast<SdrOle2Obj*>(pSdrObj)->SetGraphic(aGraphic); } break; diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index da02589c0526..685bd6f5de1e 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -951,7 +951,7 @@ void SdXShape::SetEmptyPresObj(bool bEmpty) SdrOle2Obj* pOleObj = dynamic_cast< SdrOle2Obj* >( pObj ); if( pOleObj ) { - pOleObj->SetGraphic( nullptr ); + pOleObj->ClearGraphic(); } } } diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index c56e19ac138e..7d409d7021bf 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -779,7 +779,7 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, long nVerb) // OLE object is no longer empty pObj->SetEmptyPresObj(false); pObj->SetOutlinerParaObject(nullptr); - pObj->SetGraphic(nullptr); + pObj->ClearGraphic(); // the empty OLE object gets a new IPObj if (!aName.isEmpty()) diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index b331d5d848d7..1ab690845bb2 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -758,8 +758,9 @@ bool SdrOle2Obj::isUiActive() const return mpImpl->mxObjRef.is() && embed::EmbedStates::UI_ACTIVE == mpImpl->mxObjRef->getCurrentState(); } -void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf) +void SdrOle2Obj::SetGraphic(const Graphic& rGrf) { + // only for setting a preview graphic if (mpImpl->mpGraphic) { delete mpImpl->mpGraphic; @@ -768,20 +769,25 @@ void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf) mpImpl->mpGraphicObject = nullptr; } - if (pGrf) - { - mpImpl->mpGraphic = new Graphic(*pGrf); - mpImpl->mpGraphicObject = new GraphicObject(*mpImpl->mpGraphic); - } + mpImpl->mpGraphic = new Graphic(rGrf); + mpImpl->mpGraphicObject = new GraphicObject(*mpImpl->mpGraphic); SetChanged(); BroadcastObjectChange(); } -void SdrOle2Obj::SetGraphic(const Graphic* pGrf) +void SdrOle2Obj::ClearGraphic() { - // only for setting a preview graphic - SetGraphic_Impl( pGrf ); + if (mpImpl->mpGraphic) + { + delete mpImpl->mpGraphic; + mpImpl->mpGraphic = nullptr; + delete mpImpl->mpGraphicObject; + mpImpl->mpGraphicObject = nullptr; + } + + SetChanged(); + BroadcastObjectChange(); } void SdrOle2Obj::SetProgName( const OUString& rName ) @@ -1896,7 +1902,7 @@ void SdrOle2Obj::GetObjRef_Impl() // perhaps preview not valid anymore // This line changes the modified state of the model - SetGraphic_Impl( nullptr ); + ClearGraphic(); // if status was not set before, force it back // to not set, so that SetGraphic(0L) above does not diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 46e76c35f9a8..59f39cbbb702 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -143,7 +143,7 @@ bool SvxOle2Shape::setPropertyValueImpl( const OUString& rName, const SfxItemPro if( rValue >>= aURL ) { GraphicObject aGrafObj( GraphicObject::CreateGraphicObjectFromURL( aURL ) ); - static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic( &aGrafObj.GetGraphic() ); + static_cast<SdrOle2Obj*>(mpObj.get())->SetGraphic(aGrafObj.GetGraphic()); return true; } break; |