summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2022-09-09 20:18:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2022-09-10 11:47:14 +0200
commit94c5c9281ac09186242143191f3e383bef2a89a7 (patch)
treed4f4cec0d08dd442594533d085bcbb5f6aa44716 /sd
parent37af3c83bda0d56cf6d0d7a58665cbcaa60a3cc1 (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 'sd')
-rw-r--r--sd/source/ui/app/sdxfer.cxx20
-rw-r--r--sd/source/ui/inc/sdxfer.hxx3
2 files changed, 12 insertions, 11 deletions
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index d5a6e3c1fadf..3c3fdcd6d912 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -129,7 +129,7 @@ SdTransferable::~SdTransferable()
if( mbOwnDocument )
delete mpSdDrawDocumentIntern;
- mpGraphic.reset();
+ moGraphic.reset();
mpBookmark.reset();
mpImageMap.reset();
@@ -146,7 +146,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
return;
mpOLEDataHelper.reset();
- mpGraphic.reset();
+ moGraphic.reset();
mpBookmark.reset();
mpImageMap.reset();
@@ -164,7 +164,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
// The EmbedDataHelper should bring the graphic in future
const Graphic* pObjGr = pOleObj->GetGraphic();
if ( pObjGr )
- mpGraphic.reset( new Graphic( *pObjGr ) );
+ moGraphic.emplace(*pObjGr);
}
}
catch( uno::Exception& )
@@ -172,7 +172,7 @@ void SdTransferable::CreateObjectReplacement( SdrObject* pObj )
}
else if( dynamic_cast< const SdrGrafObj *>( pObj ) != nullptr && (mpSourceDoc && !SdDrawDocument::GetAnimationInfo( pObj )) )
{
- mpGraphic.reset( new Graphic( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() ) );
+ moGraphic.emplace( static_cast< SdrGrafObj* >( pObj )->GetTransformedGraphic() );
}
else if( pObj->IsUnoObj() && SdrInventor::FmForm == pObj->GetObjInventor() && ( pObj->GetObjIdentifier() == SdrObjKind::FormButton ) )
{
@@ -394,14 +394,14 @@ void SdTransferable::AddSupportedFormats()
for( const auto& rItem : aVector )
AddFormat( rItem );
}
- else if( mpGraphic )
+ else if( moGraphic )
{
// #i25616#
AddFormat( SotClipboardFormatId::DRAWING );
AddFormat( SotClipboardFormatId::SVXB );
- if( mpGraphic->GetType() == GraphicType::Bitmap )
+ if( moGraphic->GetType() == GraphicType::Bitmap )
{
AddFormat( SotClipboardFormatId::PNG );
AddFormat( SotClipboardFormatId::BITMAP );
@@ -457,8 +457,8 @@ bool SdTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
else if( mpOLEDataHelper && mpOLEDataHelper->HasFormat( rFlavor ) )
{
// TODO/LATER: support all the graphical formats, the embedded object scenario should not have separated handling
- if( nFormat == SotClipboardFormatId::GDIMETAFILE && mpGraphic )
- bOK = SetGDIMetaFile( mpGraphic->GetGDIMetaFile() );
+ if( nFormat == SotClipboardFormatId::GDIMETAFILE && moGraphic )
+ bOK = SetGDIMetaFile( moGraphic->GetGDIMetaFile() );
else
bOK = SetAny( mpOLEDataHelper->GetAny(rFlavor, rDestDoc) );
}
@@ -523,9 +523,9 @@ bool SdTransferable::GetData( const DataFlavor& rFlavor, const OUString& rDestDo
{
bOK = SetString( mpBookmark->GetURL() );
}
- else if( ( nFormat == SotClipboardFormatId::SVXB ) && mpGraphic )
+ else if( ( nFormat == SotClipboardFormatId::SVXB ) && moGraphic )
{
- bOK = SetGraphic( *mpGraphic );
+ bOK = SetGraphic( *moGraphic );
}
else if( ( nFormat == SotClipboardFormatId::SVIM ) && mpImageMap )
{
diff --git a/sd/source/ui/inc/sdxfer.hxx b/sd/source/ui/inc/sdxfer.hxx
index 5e25ba682711..8393e8f7aea0 100644
--- a/sd/source/ui/inc/sdxfer.hxx
+++ b/sd/source/ui/inc/sdxfer.hxx
@@ -19,6 +19,7 @@
#pragma once
+#include <vcl/graph.hxx>
#include <vcl/transfer.hxx>
#include <vcl/vclptr.hxx>
#include <sfx2/objsh.hxx>
@@ -125,7 +126,7 @@ private:
SdDrawDocument* mpSourceDoc;
VclPtr<VirtualDevice> mpVDev;
std::unique_ptr<INetBookmark> mpBookmark;
- std::unique_ptr<Graphic> mpGraphic;
+ std::optional<Graphic> moGraphic;
std::unique_ptr<ImageMap> mpImageMap;
::tools::Rectangle maVisArea;
Point maStartPos;