From f08d33f87799848597e2818cd5e173ab3fdc510b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 25 Jan 2017 13:12:03 +0000 Subject: [PATCH] use a std::unique_ptr Change-Id: I1ab99995e35714d6ef3358400b0805723c44678c --- sd/source/ui/docshell/docshel4.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx index 697323db60c1..686ce6aa411e 100644 --- a/sd/source/ui/docshell/docshel4.cxx +++ b/sd/source/ui/docshell/docshel4.cxx @@ -603,47 +603,45 @@ bool DrawDocShell::ConvertTo( SfxMedium& rMedium ) { std::shared_ptr pMediumFilter = rMedium.GetFilter(); const OUString aTypeName( pMediumFilter->GetTypeName() ); - SdFilter* pFilter = nullptr; + std::unique_ptr xFilter; if( aTypeName.indexOf( "graphic_HTML" ) >= 0 ) { - pFilter = new SdHTMLFilter( rMedium, *this ); + xFilter = std::make_unique(rMedium, *this); } else if( aTypeName.indexOf( "MS_PowerPoint_97" ) >= 0 ) { - pFilter = new SdPPTFilter( rMedium, *this ); - static_cast(pFilter)->PreSaveBasic(); + xFilter = std::make_unique(rMedium, *this); + static_cast(xFilter.get())->PreSaveBasic(); } else if ( aTypeName.indexOf( "CGM_Computer_Graphics_Metafile" ) >= 0 ) { - pFilter = new SdCGMFilter( rMedium, *this ); + xFilter = std::make_unique(rMedium, *this); } else if( aTypeName.indexOf( "draw8" ) >= 0 || aTypeName.indexOf( "impress8" ) >= 0 ) { - pFilter = new SdXMLFilter( rMedium, *this ); + xFilter = std::make_unique(rMedium, *this); } else if( aTypeName.indexOf( "StarOffice_XML_Impress" ) >= 0 || aTypeName.indexOf( "StarOffice_XML_Draw" ) >= 0 ) { - pFilter = new SdXMLFilter( rMedium, *this, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60 ); + xFilter = std::make_unique(rMedium, *this, SDXMLMODE_Normal, SOFFICE_FILEFORMAT_60); } else { - pFilter = new SdGRFFilter( rMedium, *this ); + xFilter = std::make_unique(rMedium, *this); } - if( pFilter ) + if (xFilter) { const SdrSwapGraphicsMode nOldSwapMode = mpDoc->GetSwapGraphicsMode(); mpDoc->SetSwapGraphicsMode( SdrSwapGraphicsMode::TEMP ); - bRet = pFilter->Export(); + bRet = xFilter->Export(); if( !bRet ) mpDoc->SetSwapGraphicsMode( nOldSwapMode ); - - delete pFilter; } }