diff options
-rw-r--r-- | include/unotools/ucbstreamhelper.hxx | 15 | ||||
-rw-r--r-- | unotools/source/ucbhelper/ucbstreamhelper.cxx | 34 | ||||
-rw-r--r-- | vcl/source/graphic/GraphicLoader.cxx | 4 |
3 files changed, 27 insertions, 26 deletions
diff --git a/include/unotools/ucbstreamhelper.hxx b/include/unotools/ucbstreamhelper.hxx index 68309d094acf..d89048500bcd 100644 --- a/include/unotools/ucbstreamhelper.hxx +++ b/include/unotools/ucbstreamhelper.hxx @@ -25,6 +25,7 @@ #include <unotools/unotoolsdllapi.h> #include <tools/stream.hxx> +#include <memory> namespace com { @@ -52,13 +53,13 @@ namespace utl class UNOTOOLS_DLLPUBLIC UcbStreamHelper { public: - static SvStream* CreateStream( const OUString& rFileName, StreamMode eOpenMode ); - static SvStream* CreateStream( const OUString& rFileName, StreamMode eOpenMode, - bool bFileExists ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XStream >& xStream ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream, bool bCloseStream ); - static SvStream* CreateStream( const css::uno::Reference < css::io::XStream >& xStream, bool bCloseStream ); + static std::unique_ptr<SvStream> CreateStream( const OUString& rFileName, StreamMode eOpenMode ); + static std::unique_ptr<SvStream> CreateStream( const OUString& rFileName, StreamMode eOpenMode, + bool bFileExists ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XStream >& xStream ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XInputStream >& xStream, bool bCloseStream ); + static std::unique_ptr<SvStream> CreateStream( const css::uno::Reference < css::io::XStream >& xStream, bool bCloseStream ); }; } diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx b/unotools/source/ucbhelper/ucbstreamhelper.cxx index 63260f632b91..87f7d903a481 100644 --- a/unotools/source/ucbhelper/ucbstreamhelper.cxx +++ b/unotools/source/ucbhelper/ucbstreamhelper.cxx @@ -42,11 +42,11 @@ using namespace ::com::sun::star::beans; namespace utl { -static SvStream* lcl_CreateStream( const OUString& rFileName, StreamMode eOpenMode, +static std::unique_ptr<SvStream> lcl_CreateStream( const OUString& rFileName, StreamMode eOpenMode, const Reference < XInteractionHandler >& xInteractionHandler, bool bEnsureFileExists ) { - SvStream* pStream = nullptr; + std::unique_ptr<SvStream> pStream; UcbLockBytesRef xLockBytes; if ( eOpenMode & StreamMode::WRITE ) { @@ -119,7 +119,7 @@ static SvStream* lcl_CreateStream( const OUString& rFileName, StreamMode eOpenMo eOpenMode, xInteractionHandler ); if ( xLockBytes.is() ) { - pStream = new SvStream( xLockBytes.get() ); + pStream.reset(new SvStream( xLockBytes.get() )); pStream->SetBufferSize( 4096 ); pStream->SetError( xLockBytes->GetError() ); } @@ -137,7 +137,7 @@ static SvStream* lcl_CreateStream( const OUString& rFileName, StreamMode eOpenMo return pStream; } -SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode ) +std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode ) { // related tdf#99312 // create a specialized interaction handler to manages Web certificates and Web credentials when needed @@ -149,7 +149,7 @@ SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode e return lcl_CreateStream( rFileName, eOpenMode, xIHScoped, true /* bEnsureFileExists */ ); } -SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode, +std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode eOpenMode, bool bFileExists ) { // related tdf#99312 @@ -162,13 +162,13 @@ SvStream* UcbStreamHelper::CreateStream( const OUString& rFileName, StreamMode e } -SvStream* UcbStreamHelper::CreateStream( const Reference < XInputStream >& xStream ) +std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const Reference < XInputStream >& xStream ) { - SvStream* pStream = nullptr; + std::unique_ptr<SvStream> pStream; UcbLockBytesRef xLockBytes = UcbLockBytes::CreateInputLockBytes( xStream ); if ( xLockBytes.is() ) { - pStream = new SvStream( xLockBytes.get() ); + pStream.reset(new SvStream( xLockBytes.get() )); pStream->SetBufferSize( 4096 ); pStream->SetError( xLockBytes->GetError() ); } @@ -176,15 +176,15 @@ SvStream* UcbStreamHelper::CreateStream( const Reference < XInputStream >& xStre return pStream; } -SvStream* UcbStreamHelper::CreateStream( const Reference < XStream >& xStream ) +std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const Reference < XStream >& xStream ) { - SvStream* pStream = nullptr; + std::unique_ptr<SvStream> pStream; if ( xStream->getOutputStream().is() ) { UcbLockBytesRef xLockBytes = UcbLockBytes::CreateLockBytes( xStream ); if ( xLockBytes.is() ) { - pStream = new SvStream( xLockBytes.get() ); + pStream.reset(new SvStream( xLockBytes.get() )); pStream->SetBufferSize( 4096 ); pStream->SetError( xLockBytes->GetError() ); } @@ -195,16 +195,16 @@ SvStream* UcbStreamHelper::CreateStream( const Reference < XStream >& xStream ) return pStream; } -SvStream* UcbStreamHelper::CreateStream( const Reference < XInputStream >& xStream, bool bCloseStream ) +std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const Reference < XInputStream >& xStream, bool bCloseStream ) { - SvStream* pStream = nullptr; + std::unique_ptr<SvStream> pStream; UcbLockBytesRef xLockBytes = UcbLockBytes::CreateInputLockBytes( xStream ); if ( xLockBytes.is() ) { if ( !bCloseStream ) xLockBytes->setDontClose_Impl(); - pStream = new SvStream( xLockBytes.get() ); + pStream.reset(new SvStream( xLockBytes.get() )); pStream->SetBufferSize( 4096 ); pStream->SetError( xLockBytes->GetError() ); } @@ -212,9 +212,9 @@ SvStream* UcbStreamHelper::CreateStream( const Reference < XInputStream >& xStre return pStream; }; -SvStream* UcbStreamHelper::CreateStream( const Reference < XStream >& xStream, bool bCloseStream ) +std::unique_ptr<SvStream> UcbStreamHelper::CreateStream( const Reference < XStream >& xStream, bool bCloseStream ) { - SvStream* pStream = nullptr; + std::unique_ptr<SvStream> pStream; if ( xStream->getOutputStream().is() ) { UcbLockBytesRef xLockBytes = UcbLockBytes::CreateLockBytes( xStream ); @@ -223,7 +223,7 @@ SvStream* UcbStreamHelper::CreateStream( const Reference < XStream >& xStream, b if ( !bCloseStream ) xLockBytes->setDontClose_Impl(); - pStream = new SvStream( xLockBytes.get() ); + pStream.reset(new SvStream( xLockBytes.get() )); pStream->SetBufferSize( 4096 ); pStream->SetError( xLockBytes->GetError() ); } diff --git a/vcl/source/graphic/GraphicLoader.cxx b/vcl/source/graphic/GraphicLoader.cxx index 9c453acf0864..d7f66c0fde7f 100644 --- a/vcl/source/graphic/GraphicLoader.cxx +++ b/vcl/source/graphic/GraphicLoader.cxx @@ -34,8 +34,8 @@ Graphic loadFromURL(OUString const& rURL, sal_Int16 nExtWidth, sal_Int16 nExtHei Graphic aGraphic; - std::unique_ptr<SvStream> pInputStream; - pInputStream.reset(utl::UcbStreamHelper::CreateStream(rURL, StreamMode::READ)); + std::unique_ptr<SvStream> pInputStream + = utl::UcbStreamHelper::CreateStream(rURL, StreamMode::READ); if (pInputStream) { |