diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-18 14:20:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-18 15:29:14 +0100 |
commit | 6f8186138d560d1949f89f4a525c0bd911af203e (patch) | |
tree | 944c906c3d7e379fbe8969bb12d7717d27fc6383 /sfx2 | |
parent | 5fa7ee35d538862601a9871cf7b1542b98aa92d4 (diff) |
use unique_ptr in GraphicHelper::getFormatStrFromGDI_Impl
Change-Id: I54d0f2138763acf5addae53051ca842b878f5680
Reviewed-on: https://gerrit.libreoffice.org/65334
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/doc/graphhelp.cxx | 10 | ||||
-rw-r--r-- | sfx2/source/doc/graphhelp.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 8 |
3 files changed, 9 insertions, 11 deletions
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx index 80fef06c55b8..1de4de916601 100644 --- a/sfx2/source/doc/graphhelp.cxx +++ b/sfx2/source/doc/graphhelp.cxx @@ -56,17 +56,15 @@ using namespace css; -SvMemoryStream* GraphicHelper::getFormatStrFromGDI_Impl( const GDIMetaFile* pGDIMeta, ConvertDataFormat nFormat ) +std::unique_ptr<SvMemoryStream> GraphicHelper::getFormatStrFromGDI_Impl( const GDIMetaFile* pGDIMeta, ConvertDataFormat nFormat ) { - SvMemoryStream* pResult = nullptr; + std::unique_ptr<SvMemoryStream> pResult; if ( pGDIMeta ) { - SvMemoryStream* pStream = new SvMemoryStream( 65535, 65535 ); + std::unique_ptr<SvMemoryStream> pStream(new SvMemoryStream( 65535, 65535 )); Graphic aGraph( *pGDIMeta ); if ( GraphicConverter::Export( *pStream, aGraph, nFormat ) == ERRCODE_NONE ) - pResult = pStream; - else - delete pStream; + pResult = std::move(pStream); } return pResult; diff --git a/sfx2/source/doc/graphhelp.hxx b/sfx2/source/doc/graphhelp.hxx index 490093e09be0..dd2e9217103c 100644 --- a/sfx2/source/doc/graphhelp.hxx +++ b/sfx2/source/doc/graphhelp.hxx @@ -33,7 +33,7 @@ class GraphicHelper { public: - static SvMemoryStream* getFormatStrFromGDI_Impl( const GDIMetaFile* pGDIMeta, ConvertDataFormat nFormat ); + static std::unique_ptr<SvMemoryStream> getFormatStrFromGDI_Impl( const GDIMetaFile* pGDIMeta, ConvertDataFormat nFormat ); static void* getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta ); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 601937377780..42dc41c53dc9 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -2009,7 +2009,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla if (xMetaFile) { - std::shared_ptr<SvMemoryStream> xStream( + std::unique_ptr<SvMemoryStream> xStream( GraphicHelper::getFormatStrFromGDI_Impl( xMetaFile.get(), ConvertDataFormat::EMF ) ); if (xStream) @@ -2044,7 +2044,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla if (xMetaFile) { - std::shared_ptr<SvMemoryStream> xStream( + std::unique_ptr<SvMemoryStream> xStream( GraphicHelper::getFormatStrFromGDI_Impl( xMetaFile.get(), ConvertDataFormat::WMF ) ); @@ -2085,7 +2085,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla if (xMetaFile) { - std::shared_ptr<SvMemoryStream> xStream( + std::unique_ptr<SvMemoryStream> xStream( GraphicHelper::getFormatStrFromGDI_Impl( xMetaFile.get(), ConvertDataFormat::BMP ) ); @@ -2107,7 +2107,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla if (xMetaFile) { - std::shared_ptr<SvMemoryStream> xStream( + std::unique_ptr<SvMemoryStream> xStream( GraphicHelper::getFormatStrFromGDI_Impl( xMetaFile.get(), ConvertDataFormat::PNG ) ); |