Kaydet (Commit) 6f818613 authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in GraphicHelper::getFormatStrFromGDI_Impl

Change-Id: I54d0f2138763acf5addae53051ca842b878f5680
Reviewed-on: https://gerrit.libreoffice.org/65334
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5fa7ee35
...@@ -56,17 +56,15 @@ ...@@ -56,17 +56,15 @@
using namespace css; 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 ) if ( pGDIMeta )
{ {
SvMemoryStream* pStream = new SvMemoryStream( 65535, 65535 ); std::unique_ptr<SvMemoryStream> pStream(new SvMemoryStream( 65535, 65535 ));
Graphic aGraph( *pGDIMeta ); Graphic aGraph( *pGDIMeta );
if ( GraphicConverter::Export( *pStream, aGraph, nFormat ) == ERRCODE_NONE ) if ( GraphicConverter::Export( *pStream, aGraph, nFormat ) == ERRCODE_NONE )
pResult = pStream; pResult = std::move(pStream);
else
delete pStream;
} }
return pResult; return pResult;
......
...@@ -33,7 +33,7 @@ class GraphicHelper ...@@ -33,7 +33,7 @@ class GraphicHelper
{ {
public: 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 ); static void* getEnhMetaFileFromGDI_Impl( const GDIMetaFile* pGDIMeta );
......
...@@ -2009,7 +2009,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla ...@@ -2009,7 +2009,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
if (xMetaFile) if (xMetaFile)
{ {
std::shared_ptr<SvMemoryStream> xStream( std::unique_ptr<SvMemoryStream> xStream(
GraphicHelper::getFormatStrFromGDI_Impl( GraphicHelper::getFormatStrFromGDI_Impl(
xMetaFile.get(), ConvertDataFormat::EMF ) ); xMetaFile.get(), ConvertDataFormat::EMF ) );
if (xStream) if (xStream)
...@@ -2044,7 +2044,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla ...@@ -2044,7 +2044,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
if (xMetaFile) if (xMetaFile)
{ {
std::shared_ptr<SvMemoryStream> xStream( std::unique_ptr<SvMemoryStream> xStream(
GraphicHelper::getFormatStrFromGDI_Impl( GraphicHelper::getFormatStrFromGDI_Impl(
xMetaFile.get(), ConvertDataFormat::WMF ) ); xMetaFile.get(), ConvertDataFormat::WMF ) );
...@@ -2085,7 +2085,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla ...@@ -2085,7 +2085,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
if (xMetaFile) if (xMetaFile)
{ {
std::shared_ptr<SvMemoryStream> xStream( std::unique_ptr<SvMemoryStream> xStream(
GraphicHelper::getFormatStrFromGDI_Impl( GraphicHelper::getFormatStrFromGDI_Impl(
xMetaFile.get(), ConvertDataFormat::BMP ) ); xMetaFile.get(), ConvertDataFormat::BMP ) );
...@@ -2107,7 +2107,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla ...@@ -2107,7 +2107,7 @@ Any SAL_CALL SfxBaseModel::getTransferData( const datatransfer::DataFlavor& aFla
if (xMetaFile) if (xMetaFile)
{ {
std::shared_ptr<SvMemoryStream> xStream( std::unique_ptr<SvMemoryStream> xStream(
GraphicHelper::getFormatStrFromGDI_Impl( GraphicHelper::getFormatStrFromGDI_Impl(
xMetaFile.get(), ConvertDataFormat::PNG ) ); xMetaFile.get(), ConvertDataFormat::PNG ) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment