diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-09-09 20:18:12 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-10 11:47:14 +0200 |
commit | 94c5c9281ac09186242143191f3e383bef2a89a7 (patch) | |
tree | d4f4cec0d08dd442594533d085bcbb5f6aa44716 /svx | |
parent | 37af3c83bda0d56cf6d0d7a58665cbcaa60a3cc1 (diff) |
unique_ptr->optional for Graphic
Graphic is just a wrapper around shared_ptr, so no need to
allocate this separately
Change-Id: I30de73ac8a7e29adbc5ffe681f3ce88cd700b68c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139738
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/gallery2/galtheme.cxx | 10 | ||||
-rw-r--r-- | svx/source/svdraw/svdoole2.cxx | 20 |
2 files changed, 15 insertions, 15 deletions
diff --git a/svx/source/gallery2/galtheme.cxx b/svx/source/gallery2/galtheme.cxx index be3430acbf15..94940f355a42 100644 --- a/svx/source/gallery2/galtheme.cxx +++ b/svx/source/gallery2/galtheme.cxx @@ -538,7 +538,7 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans if( rxTransferable.is() ) { TransferableDataHelper aDataHelper( rxTransferable ); - std::unique_ptr<Graphic> pGraphic; + std::optional<Graphic> oGraphic; if( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) ) { @@ -591,10 +591,10 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans nFormat = SotClipboardFormatId::BITMAP; if( nFormat != SotClipboardFormatId::NONE && aDataHelper.GetGraphic( nFormat, aGraphic ) ) - pGraphic.reset(new Graphic( aGraphic )); + oGraphic.emplace( aGraphic ); } - if( pGraphic ) + if( oGraphic ) { bRet = false; @@ -611,7 +611,7 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans if( aModel.GetModel() ) { SdrPage* pPage = aModel.GetModel()->GetPage(0); - rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(*aModel.GetModel(), *pGraphic ); + rtl::Reference<SdrGrafObj> pGrafObj = new SdrGrafObj(*aModel.GetModel(), *oGraphic ); pGrafObj->AppendUserData( std::unique_ptr<SdrObjUserData>(new SgaIMapInfo( aImageMap )) ); pPage->InsertObject( pGrafObj.get() ); @@ -621,7 +621,7 @@ bool GalleryTheme::InsertTransferable(const uno::Reference< datatransfer::XTrans } if( !bRet ) - bRet = InsertGraphic( *pGraphic, nInsertPos ); + bRet = InsertGraphic( *oGraphic, nInsertPos ); } } diff --git a/svx/source/svdraw/svdoole2.cxx b/svx/source/svdraw/svdoole2.cxx index 6419c1041061..304ed04a0051 100644 --- a/svx/source/svdraw/svdoole2.cxx +++ b/svx/source/svdraw/svdoole2.cxx @@ -598,7 +598,7 @@ class SdrOle2ObjImpl public: svt::EmbeddedObjectRef mxObjRef; - std::unique_ptr<Graphic> mxGraphic; + std::optional<Graphic> moGraphic; OUString maProgName; OUString aPersistName; // name of object in persist rtl::Reference<SdrLightEmbeddedClient_Impl> mxLightClient; // must be registered as client only using AddOwnLightClient() call @@ -642,7 +642,7 @@ public: ~SdrOle2ObjImpl() { - mxGraphic.reset(); + moGraphic.reset(); if (mxModifyListener.is()) { @@ -723,9 +723,9 @@ SdrOle2Obj::SdrOle2Obj(SdrModel& rSdrModel, SdrOle2Obj const & rSource) mpImpl->maProgName = rSource.mpImpl->maProgName; mpImpl->mbFrame = rSource.mpImpl->mbFrame; - if (rSource.mpImpl->mxGraphic) + if (rSource.mpImpl->moGraphic) { - mpImpl->mxGraphic.reset(new Graphic(*rSource.mpImpl->mxGraphic)); + mpImpl->moGraphic.emplace(*rSource.mpImpl->moGraphic); } if( IsEmptyPresObj() ) @@ -827,7 +827,7 @@ bool SdrOle2Obj::isUiActive() const void SdrOle2Obj::SetGraphic(const Graphic& rGrf) { // only for setting a preview graphic - mpImpl->mxGraphic.reset(new Graphic(rGrf)); + mpImpl->moGraphic.emplace(rGrf); SetChanged(); BroadcastObjectChange(); @@ -835,7 +835,7 @@ void SdrOle2Obj::SetGraphic(const Graphic& rGrf) void SdrOle2Obj::ClearGraphic() { - mpImpl->mxGraphic.reset(); + mpImpl->moGraphic.reset(); SetChanged(); BroadcastObjectChange(); @@ -1318,7 +1318,7 @@ void SdrOle2Obj::SetObjRef( const css::uno::Reference < css::embed::XEmbeddedObj if ( mpImpl->mxObjRef.is() ) { - mpImpl->mxGraphic.reset(); + mpImpl->moGraphic.reset(); if ( mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) SetResizeProtect(true); @@ -1636,7 +1636,7 @@ const Graphic* SdrOle2Obj::GetGraphic() const { if ( mpImpl->mxObjRef.is() ) return mpImpl->mxObjRef.GetGraphic(); - return mpImpl->mxGraphic.get(); + return mpImpl->moGraphic ? &*mpImpl->moGraphic : nullptr; } void SdrOle2Obj::GetNewReplacement() @@ -1823,7 +1823,7 @@ void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic ) // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback if (const Graphic* pObjGraphic = mpImpl->mxObjRef.is() ? nullptr : mpImpl->mxObjRef.GetGraphic()) - mpImpl->mxGraphic.reset(new Graphic(*pObjGraphic)); + mpImpl->moGraphic.emplace(*pObjGraphic); } void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const OUString& aMediaType ) @@ -1832,7 +1832,7 @@ void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrS // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback if (const Graphic* pObjGraphic = mpImpl->mxObjRef.is() ? nullptr : mpImpl->mxObjRef.GetGraphic()) - mpImpl->mxGraphic.reset(new Graphic(*pObjGraphic)); + mpImpl->moGraphic.emplace(*pObjGraphic); } bool SdrOle2Obj::IsCalc() const |