cui/source/dialogs/hldocntp.cxx                         |    4 -
 dbaccess/source/filter/hsqldb/rowinputbinary.cxx        |    2 
 desktop/source/migration/services/wordbookmigration.cxx |    3 -
 filter/source/svg/svgexport.cxx                         |    2 
 filter/source/textfilterdetect/filterdetect.cxx         |    4 -
 forms/source/component/DatabaseForm.cxx                 |    9 +---
 forms/source/component/ImageControl.cxx                 |    2 
 forms/source/component/imgprod.cxx                      |    4 -
 forms/source/richtext/richtextvclcontrol.cxx            |    3 -
 framework/source/fwe/classes/addonsoptions.cxx          |    4 -
 include/svtools/embedhlp.hxx                            |    2 
 include/unotools/streamwrap.hxx                         |    3 +
 include/unotools/ucbstreamhelper.hxx                    |   15 +++----
 include/vcl/graphicfilter.hxx                           |    2 
 sax/qa/cppunit/xmlimport.cxx                            |    4 -
 sc/source/filter/excel/xeescher.cxx                     |    2 
 sc/source/filter/xcl97/xcl97esc.cxx                     |    2 
 sc/source/ui/app/drwtrans.cxx                           |    4 -
 sc/source/ui/app/transobj.cxx                           |    4 -
 sc/source/ui/unoobj/filtuno.cxx                         |    4 -
 sd/source/core/CustomAnimationPreset.cxx                |    4 -
 sd/source/filter/eppt/pptexsoundcollection.cxx          |    3 -
 sd/source/filter/html/htmlex.cxx                        |    6 +-
 sd/source/filter/html/pubdlg.cxx                        |    4 -
 sd/source/filter/ppt/pptin.cxx                          |    4 -
 sd/source/ui/app/sdmod.cxx                              |    4 -
 sd/source/ui/app/sdxfer.cxx                             |    4 -
 sd/source/ui/dlg/PhotoAlbumDialog.cxx                   |    3 -
 sfx2/source/dialog/filedlghelper.cxx                    |    3 -
 sfx2/source/doc/docfile.cxx                             |   28 ++++++-------
 sfx2/source/doc/graphhelp.cxx                           |    4 -
 sfx2/source/view/classificationhelper.cxx               |    4 -
 sot/source/sdstor/storage.cxx                           |    8 +--
 sot/source/sdstor/ucbstorage.cxx                        |   15 +++----
 sot/source/unoolestorage/xolesimplestorage.cxx          |    6 +-
 sot/source/unoolestorage/xolesimplestorage.hxx          |    2 
 svl/source/fsstor/fsstorage.cxx                         |   12 +----
 svtools/source/misc/embedhlp.cxx                        |    7 +--
 svtools/source/misc/embedtransfer.cxx                   |    2 
 svtools/source/misc/templatefoldercache.cxx             |    4 -
 svx/source/xml/xmlgrhlp.cxx                             |    8 +--
 sw/qa/extras/inc/swmodeltestbase.hxx                    |    4 -
 sw/qa/extras/ooxmlexport/ooxmlexport10.cxx              |    4 -
 sw/source/core/swg/SwXMLTextBlocks.cxx                  |    5 --
 sw/source/core/text/txtftn.cxx                          |    6 +-
 sw/source/filter/ww8/rtfexportfilter.cxx                |    5 --
 sw/source/filter/ww8/wrtww8.cxx                         |    4 -
 sw/source/filter/ww8/wrtww8gr.cxx                       |    4 -
 sw/source/filter/xml/swxml.cxx                          |    3 -
 sw/source/filter/xml/wrtxml.cxx                         |    4 -
 sw/source/uibase/uno/SwXFilterOptions.cxx               |    2 
 unotools/source/streaming/streamwrap.cxx                |   11 +++++
 unotools/source/ucbhelper/ucbstreamhelper.cxx           |   34 ++++++++--------
 vcl/source/filter/graphicfilter.cxx                     |   24 +++++------
 vcl/source/filter/graphicfilter2.cxx                    |    2 
 vcl/source/gdi/impgraph.cxx                             |    4 -
 vcl/source/graphic/GraphicLoader.cxx                    |    4 -
 vcl/source/graphic/UnoGraphicProvider.cxx               |   17 +++-----
 writerfilter/source/filter/RtfFilter.cxx                |    4 -
 writerfilter/source/rtftok/rtfdocumentimpl.cxx          |    2 
 writerperfect/source/common/WPXSvInputStream.cxx        |    6 +-
 xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx           |   12 ++---
 62 files changed, 179 insertions(+), 196 deletions(-)

New commits:
commit 62cf9b479232c72648dbca426aff1309b897dc7a
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Wed Jul 4 10:45:32 2018 +0200

    loplugin:useuniqueptr in SwFootnoteSave
    
    Change-Id: If70990222a6a59cede90bb52413f22540dd06a75
    Reviewed-on: https://gerrit.libreoffice.org/57198
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx
index 3df8571b4ed0..78e30ed4f3e8 100644
--- a/sw/source/core/text/txtftn.cxx
+++ b/sw/source/core/text/txtftn.cxx
@@ -1211,7 +1211,7 @@ class SwFootnoteSave
 {
     SwTextSizeInfo *pInf;
     SwFont       *pFnt;
-    SwFont       *pOld;
+    std::unique_ptr<SwFont> pOld;
 
     SwFootnoteSave(const SwFootnoteSave&) = delete;
     SwFootnoteSave& operator=(const SwFootnoteSave&) = delete;
@@ -1235,7 +1235,7 @@ SwFootnoteSave::SwFootnoteSave( const SwTextSizeInfo 
&rInf,
     if( pTextFootnote && rInf.GetTextFrame() )
     {
         pFnt = const_cast<SwTextSizeInfo&>(rInf).GetFont();
-          pOld = new SwFont( *pFnt );
+        pOld.reset( new SwFont( *pFnt ) );
         pOld->GetTox() = pFnt->GetTox();
         pFnt->GetTox() = 0;
         SwFormatFootnote& rFootnote = 
const_cast<SwFormatFootnote&>(pTextFootnote->GetFootnote());
@@ -1295,7 +1295,7 @@ SwFootnoteSave::~SwFootnoteSave() COVERITY_NOEXCEPT_FALSE
         *pFnt = *pOld;
         pFnt->GetTox() = pOld->GetTox();
         pFnt->ChgPhysFnt( pInf->GetVsh(), *pInf->GetOut() );
-        delete pOld;
+        pOld.reset();
     }
 }
 
commit 65e41592a650887c8d00586385119effa54de5fa
Author: Noel Grandin <noel.gran...@collabora.co.uk>
Date:   Mon Jul 9 17:10:49 2018 +0200

    pass SvStream around by std::unique_ptr
    
    and give utl::OStreamWrapper a new constructor so that it knows it is
    taking ownership of  the SvStream, which appears to fix several leaks
    
    Change-Id: Idcbcca9b81a4f0345fd8b8c8a2f4e84213686a6b
    Reviewed-on: https://gerrit.libreoffice.org/57187
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/cui/source/dialogs/hldocntp.cxx b/cui/source/dialogs/hldocntp.cxx
index 962298168b49..96a2fcac3ed8 100644
--- a/cui/source/dialogs/hldocntp.cxx
+++ b/cui/source/dialogs/hldocntp.cxx
@@ -390,11 +390,11 @@ void SvxHyperlinkNewDocTp::DoApply ()
         try
         {
             // check if file exists, warn before we overwrite it
-            SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( 
aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
+            std::unique_ptr<SvStream> pIStm = 
::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
 
             bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE);
 
-            delete pIStm;
+            pIStm.reset();
 
             if( bOk )
             {
diff --git a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx 
b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
index d40d5332851e..9b6df5d61a70 100644
--- a/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
+++ b/dbaccess/source/filter/hsqldb/rowinputbinary.cxx
@@ -140,7 +140,7 @@ HsqlRowInputStream::HsqlRowInputStream() {}
 
 void HsqlRowInputStream::setInputStream(Reference<XInputStream> const& rStream)
 {
-    m_pStream.reset(utl::UcbStreamHelper::CreateStream(rStream, true));
+    m_pStream = utl::UcbStreamHelper::CreateStream(rStream, true);
     m_pStream->SetEndian(SvStreamEndian::BIG);
 }
 
diff --git a/desktop/source/migration/services/wordbookmigration.cxx 
b/desktop/source/migration/services/wordbookmigration.cxx
index 3a0f4bd1c165..683813a9df48 100644
--- a/desktop/source/migration/services/wordbookmigration.cxx
+++ b/desktop/source/migration/services/wordbookmigration.cxx
@@ -107,7 +107,7 @@ namespace migration
 bool IsUserWordbook( const OUString& rFile )
 {
     bool bRet = false;
-    SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( rFile, 
StreamMode::STD_READ );
+    std::unique_ptr<SvStream> pStream = ::utl::UcbStreamHelper::CreateStream( 
rFile, StreamMode::STD_READ );
     if ( pStream && !pStream->GetError() )
     {
         static const sal_Char* const pVerOOo7    = "OOoUserDict1";
@@ -137,7 +137,6 @@ bool IsUserWordbook( const OUString& rFile )
         }
     }
 
-    delete pStream;
     return bRet;
 }
 
diff --git a/filter/source/svg/svgexport.cxx b/filter/source/svg/svgexport.cxx
index d4db26ef8e52..91a1d35c3bb4 100644
--- a/filter/source/svg/svgexport.cxx
+++ b/filter/source/svg/svgexport.cxx
@@ -517,7 +517,7 @@ bool SVGFilter::implExport( const Sequence< PropertyValue 
>& rDescriptor )
             OUString aFileName;
 
             pValue[ i ].Value >>= aFileName;
-            pOStm.reset(::utl::UcbStreamHelper::CreateStream( aFileName, 
StreamMode::WRITE | StreamMode::TRUNC ));
+            pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, 
StreamMode::WRITE | StreamMode::TRUNC );
 
             if( pOStm )
                 xOStm.set( new ::utl::OOutputStreamWrapper ( *pOStm ) );
diff --git a/filter/source/textfilterdetect/filterdetect.cxx 
b/filter/source/textfilterdetect/filterdetect.cxx
index 2e3e08028683..3eeb0b1ee485 100644
--- a/filter/source/textfilterdetect/filterdetect.cxx
+++ b/filter/source/textfilterdetect/filterdetect.cxx
@@ -165,9 +165,9 @@ OUString SAL_CALL 
PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyVal
             ZCodec aCodecGZ;
             std::unique_ptr<SvStream> pInStream;
             if (xStream.is())
-                pInStream.reset(utl::UcbStreamHelper::CreateStream(xStream));
+                pInStream = utl::UcbStreamHelper::CreateStream(xStream);
             else
-                pInStream.reset(utl::UcbStreamHelper::CreateStream(xInStream));
+                pInStream = utl::UcbStreamHelper::CreateStream(xInStream);
             std::unique_ptr<SvMemoryStream> pDecompressedStream(new 
SvMemoryStream());
             if (aCodecGZ.AttemptDecompression(*pInStream, 
*pDecompressedStream))
             {
diff --git a/forms/source/component/DatabaseForm.cxx 
b/forms/source/component/DatabaseForm.cxx
index 4d7cc390171a..0808b029edf7 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -963,7 +963,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& 
rParent, const OUString& rN
 {
     OUString aFileName(rFileName);
     OUString aContentType(CONTENT_TYPE_STR_TEXT_PLAIN);
-    SvStream *pStream = nullptr;
+    std::unique_ptr<SvStream> pStream;
 
     if (!aFileName.isEmpty())
     {
@@ -977,8 +977,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& 
rParent, const OUString& rN
             pStream = ::utl::UcbStreamHelper::CreateStream(aFileName, 
StreamMode::READ);
             if (!pStream || (pStream->GetError() != ERRCODE_NONE))
             {
-                delete pStream;
-                pStream = nullptr;
+                pStream.reset();
             }
             sal_Int32 nSepInd = aFileName.lastIndexOf('.');
             OUString aExtension = aFileName.copy( nSepInd + 1 );
@@ -990,7 +989,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& 
rParent, const OUString& rN
 
     // If something didn't work, we create an empty MemoryStream
     if( !pStream )
-        pStream = new SvMemoryStream;
+        pStream.reset( new SvMemoryStream );
 
 
     // Create part as MessageChild
@@ -1013,7 +1012,7 @@ bool ODatabaseForm::InsertFilePart( INetMIMEMessage& 
rParent, const OUString& rN
 
 
     // Body
-    pChild->SetDocumentLB( new SvLockBytes(pStream, true) );
+    pChild->SetDocumentLB( new SvLockBytes(pStream.release(), true) );
     rParent.AttachChild( std::move(pChild) );
 
     return true;
diff --git a/forms/source/component/ImageControl.cxx 
b/forms/source/component/ImageControl.cxx
index b75b08270334..0db96134a902 100644
--- a/forms/source/component/ImageControl.cxx
+++ b/forms/source/component/ImageControl.cxx
@@ -400,7 +400,7 @@ bool OImageControlModel::impl_updateStreamForURL_lck( const 
OUString& _rURL, Val
     }
     else
     {
-        pImageStream.reset( ::utl::UcbStreamHelper::CreateStream( _rURL, 
StreamMode::READ ) );
+        pImageStream = ::utl::UcbStreamHelper::CreateStream( _rURL, 
StreamMode::READ );
         bool bSetNull = ( pImageStream.get() == nullptr ) || ( ERRCODE_NONE != 
pImageStream->GetErrorCode() );
 
         if ( !bSetNull )
diff --git a/forms/source/component/imgprod.cxx 
b/forms/source/component/imgprod.cxx
index 0b55ecd942f1..9e2700f0b971 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -209,9 +209,9 @@ void ImageProducer::SetImage( const OUString& rPath )
     }
     else if( !maURL.isEmpty() )
     {
-        SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( maURL, 
StreamMode::STD_READ );
+        std::unique_ptr<SvStream> pIStm = 
::utl::UcbStreamHelper::CreateStream( maURL, StreamMode::STD_READ );
         if (pIStm)
-            mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm, true ) ) );
+            mpStm.reset( new SvStream( new ImgProdLockBytes( pIStm.release(), 
true ) ) );
     }
 }
 
diff --git a/forms/source/richtext/richtextvclcontrol.cxx 
b/forms/source/richtext/richtextvclcontrol.cxx
index fd466cf25b2c..e5f0848eebf4 100644
--- a/forms/source/richtext/richtextvclcontrol.cxx
+++ b/forms/source/richtext/richtextvclcontrol.cxx
@@ -246,7 +246,7 @@ namespace frm
                     if ( nResult == ERRCODE_NONE )
                     {
                         OUString sFileName = aFP.GetPath();
-                        SvStream* pStream = 
::utl::UcbStreamHelper::CreateStream(
+                        std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream(
                             sFileName, ( bLoad ? StreamMode::READ : 
StreamMode::WRITE | StreamMode::TRUNC ) | StreamMode::SHARE_DENYALL
                         );
                         if ( pStream )
@@ -272,7 +272,6 @@ namespace frm
                                 getEngine().Write( *pStream, eFormat );
                             }
                         }
-                        DELETEZ( pStream );
                     }
                     return true;   // handled
                 }
diff --git a/framework/source/fwe/classes/addonsoptions.cxx 
b/framework/source/fwe/classes/addonsoptions.cxx
index 8c45c86157ea..136cc7c26984 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -1277,7 +1277,7 @@ Image AddonsOptions_Impl::ReadImageFromURL(const 
OUString& aImageURL)
 {
     Image aImage;
 
-    SvStream* pStream = UcbStreamHelper::CreateStream( aImageURL, 
StreamMode::STD_READ );
+    std::unique_ptr<SvStream> pStream = UcbStreamHelper::CreateStream( 
aImageURL, StreamMode::STD_READ );
     if ( pStream && ( pStream->GetErrorCode() == ERRCODE_NONE ))
     {
         // Use graphic class to also support more graphic formats (bmp,png,...)
@@ -1299,8 +1299,6 @@ Image AddonsOptions_Impl::ReadImageFromURL(const 
OUString& aImageURL)
         }
     }
 
-    delete pStream;
-
     return aImage;
 }
 
diff --git a/include/svtools/embedhlp.hxx b/include/svtools/embedhlp.hxx
index 30a5cdc6338e..27e3e89eb590 100644
--- a/include/svtools/embedhlp.hxx
+++ b/include/svtools/embedhlp.hxx
@@ -48,7 +48,7 @@ class SVT_DLLPUBLIC EmbeddedObjectRef
 {
     std::unique_ptr<EmbeddedObjectRef_Impl> mpImpl;
 
-    SVT_DLLPRIVATE SvStream* GetGraphicStream( bool bUpdate ) const;
+    SVT_DLLPRIVATE std::unique_ptr<SvStream> GetGraphicStream( bool bUpdate ) 
const;
     SVT_DLLPRIVATE void GetReplacement( bool bUpdate );
 
     EmbeddedObjectRef& operator = ( const EmbeddedObjectRef& ) = delete;
diff --git a/include/unotools/streamwrap.hxx b/include/unotools/streamwrap.hxx
index 81f463ea6e2c..299b6dfd081f 100644
--- a/include/unotools/streamwrap.hxx
+++ b/include/unotools/streamwrap.hxx
@@ -29,6 +29,7 @@
 #include <com/sun/star/io/XStream.hpp>
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/implbase1.hxx>
+#include <memory>
 
 class SvStream;
 
@@ -53,6 +54,7 @@ protected:
 public:
     OInputStreamWrapper(SvStream& _rStream);
     OInputStreamWrapper(SvStream* pStream, bool bOwner=false);
+    OInputStreamWrapper(std::unique_ptr<SvStream> pStream);
     virtual ~OInputStreamWrapper() override;
 
 // css::io::XInputStream
@@ -152,6 +154,7 @@ protected:
 
 public:
     OStreamWrapper(SvStream& _rStream);
+    OStreamWrapper(std::unique_ptr<SvStream> _rStream);
 
 // css::io::XStream
     virtual css::uno::Reference< css::io::XInputStream > SAL_CALL 
getInputStream(  ) override;
diff --git a/include/unotools/ucbstreamhelper.hxx 
b/include/unotools/ucbstreamhelper.hxx
index 68309d094acf..f037571fe212 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/include/vcl/graphicfilter.hxx b/include/vcl/graphicfilter.hxx
index 2f24cf10e085..8c5ce93221f2 100644
--- a/include/vcl/graphicfilter.hxx
+++ b/include/vcl/graphicfilter.hxx
@@ -285,7 +285,7 @@ public:
     /// Imports multiple graphics.
     ///
     /// The resulting graphic is added to rGraphics on success, nullptr is 
added on failure.
-    void ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGraphics, 
const std::vector< std::shared_ptr<SvStream> >& rStreams);
+    void ImportGraphics(std::vector< std::shared_ptr<Graphic> >& rGraphics, 
std::vector< std::unique_ptr<SvStream> > vStreams);
 
     ErrCode             ImportGraphic( Graphic& rGraphic, const OUString& 
rPath,
                                    SvStream& rStream,
diff --git a/sax/qa/cppunit/xmlimport.cxx b/sax/qa/cppunit/xmlimport.cxx
index f7ea3ec92c19..b22f9d268e8a 100644
--- a/sax/qa/cppunit/xmlimport.cxx
+++ b/sax/qa/cppunit/xmlimport.cxx
@@ -65,10 +65,10 @@ Reference< XInputStream > createStreamFromFile (
     Reference<  XInputStream >  xInputStream;
     OUString aInStr;
     FileBase::getFileURLFromSystemPath(filePath, aInStr);
-    SvStream* pStream = utl::UcbStreamHelper::CreateStream(aInStr, 
StreamMode::READ);
+    std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream(aInStr, StreamMode::READ);
     if(pStream == nullptr)
         CPPUNIT_ASSERT(false);
-    Reference< XStream > xStream(new utl::OStreamWrapper(*pStream));
+    Reference< XStream > xStream(new utl::OStreamWrapper(std::move(pStream)));
     xInputStream.set(xStream, UNO_QUERY);
     return xInputStream;
 }
diff --git a/sc/source/filter/excel/xeescher.cxx 
b/sc/source/filter/excel/xeescher.cxx
index 971eb25998f6..855f28cd0433 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -1575,7 +1575,7 @@ void XclExpObjectManager::InitStream( bool bTempFile )
         if( mxTempFile->IsValid() )
         {
             mxTempFile->EnableKillingFile();
-            mxDffStrm.reset( ::utl::UcbStreamHelper::CreateStream( 
mxTempFile->GetURL(), StreamMode::STD_READWRITE ) );
+            mxDffStrm = ::utl::UcbStreamHelper::CreateStream( 
mxTempFile->GetURL(), StreamMode::STD_READWRITE );
         }
     }
 
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx 
b/sc/source/filter/xcl97/xcl97esc.cxx
index b5030ce78304..d81846249a90 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -85,7 +85,7 @@ SvStream* XclEscherExGlobal::ImplQueryPictureStream()
     if( mxPicTempFile->IsValid() )
     {
         mxPicTempFile->EnableKillingFile();
-        mxPicStrm.reset( ::utl::UcbStreamHelper::CreateStream( 
mxPicTempFile->GetURL(), StreamMode::STD_READWRITE ) );
+        mxPicStrm = ::utl::UcbStreamHelper::CreateStream( 
mxPicTempFile->GetURL(), StreamMode::STD_READWRITE );
         mxPicStrm->SetEndian( SvStreamEndian::LITTLE );
     }
     return mxPicStrm.get();
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
index 5b74ca09ee8d..7f60ebcd3ad8 100644
--- a/sc/source/ui/app/drwtrans.cxx
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -565,12 +565,12 @@ bool ScDrawTransferObj::WriteObject( 
tools::SvRef<SotStorageStream>& rxOStm, voi
                     if ( xTransact.is() )
                         xTransact->commit();
 
-                    SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( 
aTempFile.GetURL(), StreamMode::READ );
+                    std::unique_ptr<SvStream> pSrcStm = 
::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ );
                     if( pSrcStm )
                     {
                         rxOStm->SetBufferSize( 0xff00 );
                         rxOStm->WriteStream( *pSrcStm );
-                        delete pSrcStm;
+                        pSrcStm.reset();
                     }
 
                     xWorkStore->dispose();
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index af6a63f522ef..8fcfde1baab1 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -496,12 +496,12 @@ bool ScTransferObj::WriteObject( 
tools::SvRef<SotStorageStream>& rxOStm, void* p
                 if ( xTransact.is() )
                     xTransact->commit();
 
-                SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( 
aTempFile.GetURL(), StreamMode::READ );
+                std::unique_ptr<SvStream> pSrcStm = 
::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ );
                 if( pSrcStm )
                 {
                     rxOStm->SetBufferSize( 0xff00 );
                     rxOStm->WriteStream( *pSrcStm );
-                    delete pSrcStm;
+                    pSrcStm.reset();
                 }
 
                 bRet = true;
diff --git a/sc/source/ui/unoobj/filtuno.cxx b/sc/source/ui/unoobj/filtuno.cxx
index d15425eb92ad..4d2697563dd5 100644
--- a/sc/source/ui/unoobj/filtuno.cxx
+++ b/sc/source/ui/unoobj/filtuno.cxx
@@ -188,7 +188,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
         OUString aPrivDatName(aURL.getName());
         std::unique_ptr<SvStream> pInStream;
         if ( xInputStream.is() )
-            pInStream.reset(utl::UcbStreamHelper::CreateStream( xInputStream 
));
+            pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
 
         ScopedVclPtr<AbstractScImportAsciiDlg> 
pDlg(pFact->CreateScImportAsciiDlg(nullptr, aPrivDatName, pInStream.get(), 
SC_IMPORTFILE));
         if ( pDlg->Execute() == RET_OK )
@@ -272,7 +272,7 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute()
 
             std::unique_ptr<SvStream> pInStream;
             if ( xInputStream.is() )
-                pInStream.reset(utl::UcbStreamHelper::CreateStream( 
xInputStream ));
+                pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
             switch(load_CharSet( eEncoding, bExport, pInStream.get()))
             {
                 case charsetSource::charset_from_file:
diff --git a/sd/source/core/CustomAnimationPreset.cxx 
b/sd/source/core/CustomAnimationPreset.cxx
index e420c5885800..9eac96516f82 100644
--- a/sd/source/core/CustomAnimationPreset.cxx
+++ b/sd/source/core/CustomAnimationPreset.cxx
@@ -244,8 +244,8 @@ Reference< XAnimationNode > implImportEffects( const 
Reference< XMultiServiceFac
     try
     {
         // create stream
-        SvStream*   pIStm = ::utl::UcbStreamHelper::CreateStream( rPath, 
StreamMode::READ );
-        Reference<XInputStream> xInputStream( new utl::OInputStreamWrapper( 
pIStm, true ) );
+        std::unique_ptr<SvStream> pIStm = 
::utl::UcbStreamHelper::CreateStream( rPath, StreamMode::READ );
+        Reference<XInputStream> xInputStream( new utl::OInputStreamWrapper( 
std::move(pIStm) ) );
 
         // prepare ParserInputSrouce
         xml::sax::InputSource aParserInput;
diff --git a/sd/source/filter/eppt/pptexsoundcollection.cxx 
b/sd/source/filter/eppt/pptexsoundcollection.cxx
index 287853b05c51..8a3330237fa0 100644
--- a/sd/source/filter/eppt/pptexsoundcollection.cxx
+++ b/sd/source/filter/eppt/pptexsoundcollection.cxx
@@ -127,7 +127,7 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) 
const
 
         rSt.WriteUInt32( EPP_SoundData << 16 ).WriteUInt32( nFileSize );
         sal_uInt32 nBytesLeft = nFileSize;
-        SvStream* pSourceFile = ::utl::UcbStreamHelper::CreateStream( 
aSoundURL, StreamMode::READ );
+        std::unique_ptr<SvStream> pSourceFile = 
::utl::UcbStreamHelper::CreateStream( aSoundURL, StreamMode::READ );
         if ( pSourceFile )
         {
             std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ 0x10000 ] );   
// 64 kB  Buffer
@@ -138,7 +138,6 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) 
const
                 rSt.WriteBytes(pBuf.get(), nToDo);
                 nBytesLeft -= nToDo;
             }
-            delete pSourceFile;
         }
     }
     catch( css::uno::Exception& )
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index 0e47c46add57..b0a6dd8c2e04 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -2866,7 +2866,7 @@ bool HtmlExport::CopyScript( const OUString& rPath, const 
OUString& rSource, con
     meEC.SetContext( STR_HTMLEXP_ERROR_OPEN_FILE, rSource );
 
     ErrCode     nErr = ERRCODE_NONE;
-    SvStream*   pIStm = ::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
+    std::unique_ptr<SvStream> pIStm = ::utl::UcbStreamHelper::CreateStream( 
aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
 
     if( pIStm )
     {
@@ -2886,7 +2886,7 @@ bool HtmlExport::CopyScript( const OUString& rPath, const 
OUString& rSource, con
         }
 
         nErr = pIStm->GetError();
-        delete pIStm;
+        pIStm.reset();
     }
 
     if( nErr != ERRCODE_NONE )
@@ -3141,7 +3141,7 @@ ErrCode EasyFile::createStream(  const OUString& rUrl, 
SvStream* &rpStr )
     createFileName( rUrl, aFileName );
 
     ErrCode nErr = ERRCODE_NONE;
-    pOStm.reset( ::utl::UcbStreamHelper::CreateStream( aFileName, 
StreamMode::WRITE | StreamMode::TRUNC ) );
+    pOStm = ::utl::UcbStreamHelper::CreateStream( aFileName, StreamMode::WRITE 
| StreamMode::TRUNC );
     if( pOStm )
     {
         bOpen = true;
diff --git a/sd/source/filter/html/pubdlg.cxx b/sd/source/filter/html/pubdlg.cxx
index 538eb71e57bd..79df8be785cf 100644
--- a/sd/source/filter/html/pubdlg.cxx
+++ b/sd/source/filter/html/pubdlg.cxx
@@ -1514,12 +1514,10 @@ void SdPublishingDlg::Load()
 
     // check if file exists, SfxMedium shows an errorbox else
     {
-        SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( 
aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
+        std::unique_ptr<SvStream> pIStm = 
::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READ );
 
         bool bOk = pIStm && ( pIStm->GetError() == ERRCODE_NONE);
 
-        delete pIStm;
-
         if( !bOk )
             return;
     }
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index ab97f71ce73d..364c07662181 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1961,7 +1961,7 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) 
const
                             std::vector<sal_uInt8> aBuf(nSoundDataLen);
 
                             rStCtrl.ReadBytes(aBuf.data(), nSoundDataLen);
-                            SvStream* pOStm = 
::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC );
+                            std::unique_ptr<SvStream> pOStm = 
::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC );
 
                             if( pOStm )
                             {
@@ -1972,8 +1972,6 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) 
const
                                     GalleryExplorer::InsertURL( 
GALLERY_THEME_USERSOUNDS, aGalleryUserSound.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ) );
                                     aRetval = aGalleryUserSound.GetMainURL( 
INetURLObject::DecodeMechanism::NONE );
                                 }
-
-                                delete pOStm;
                             }
                         }
                     }
diff --git a/sd/source/ui/app/sdmod.cxx b/sd/source/ui/app/sdmod.cxx
index c519302a8fa5..b55213c44ed2 100644
--- a/sd/source/ui/app/sdmod.cxx
+++ b/sd/source/ui/app/sdmod.cxx
@@ -183,10 +183,10 @@ tools::SvRef<SotStorageStream> SdModule::GetOptionStream( 
const OUString& rOptio
 
             aURL.Append( "drawing.cfg" );
 
-            SvStream* pStm = ::utl::UcbStreamHelper::CreateStream( 
aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::READWRITE 
);
+            std::unique_ptr<SvStream> pStm = 
::utl::UcbStreamHelper::CreateStream( aURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READWRITE );
 
             if( pStm )
-                xOptionStorage = new SotStorage( pStm, true );
+                xOptionStorage = new SotStorage( pStm.release(), true );
         }
 
         OUString        aStmName;
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index a8118228cc9e..7523b53af472 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -640,12 +640,12 @@ bool SdTransferable::WriteObject( 
tools::SvRef<SotStorageStream>& rxOStm, void*
                 if ( xTransact.is() )
                     xTransact->commit();
 
-                SvStream* pSrcStm = ::utl::UcbStreamHelper::CreateStream( 
aTempFile.GetURL(), StreamMode::READ );
+                std::unique_ptr<SvStream> pSrcStm = 
::utl::UcbStreamHelper::CreateStream( aTempFile.GetURL(), StreamMode::READ );
                 if( pSrcStm )
                 {
                     rxOStm->SetBufferSize( 0xff00 );
                     rxOStm->WriteStream( *pSrcStm );
-                    delete pSrcStm;
+                    pSrcStm.reset();
                 }
 
                 bRet = true;
diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx 
b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
index bd14bce7f6fe..1f728df73aa8 100644
--- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx
+++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx
@@ -610,13 +610,12 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, 
weld::TreeView&, void)
         // remote?
         if ( INetProtocol::File != aURLObj.GetProtocol() )
         {
-            SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( sImgUrl, 
StreamMode::READ );
+            std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( sImgUrl, StreamMode::READ );
 
             if( pStream )
                 m_pGraphicFilter->ImportGraphic( aGraphic, sImgUrl, *pStream, 
nFilter, nullptr, nFilterImportFlags );
             else
                 m_pGraphicFilter->ImportGraphic( aGraphic, aURLObj, nFilter, 
nullptr, nFilterImportFlags );
-            delete pStream;
         }
         else
         {
diff --git a/sfx2/source/dialog/filedlghelper.cxx 
b/sfx2/source/dialog/filedlghelper.cxx
index 5d20a0f5b0c8..040dd203dbb8 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -765,13 +765,12 @@ ErrCode FileDialogHelper_Impl::getGraphic( const 
OUString& rURL,
     // non-local?
     if ( INetProtocol::File != aURLObj.GetProtocol() )
     {
-        SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( rURL, 
StreamMode::READ );
+        std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( rURL, StreamMode::READ );
 
         if( pStream )
             nRet = mpGraphicFilter->ImportGraphic( rGraphic, rURL, *pStream, 
nFilter, nullptr, nFilterImportFlags );
         else
             nRet = mpGraphicFilter->ImportGraphic( rGraphic, aURLObj, nFilter, 
nullptr, nFilterImportFlags );
-        delete pStream;
     }
     else
     {
diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx
index d6ea0e8f6c54..56a976572e25 100644
--- a/sfx2/source/doc/docfile.cxx
+++ b/sfx2/source/doc/docfile.cxx
@@ -260,8 +260,8 @@ public:
     std::shared_ptr<const SfxFilter> m_pFilter;
     std::shared_ptr<const SfxFilter> m_pCustomFilter;
 
-    SvStream* m_pInStream;
-    SvStream* m_pOutStream;
+    std::unique_ptr<SvStream> m_pInStream;
+    std::unique_ptr<SvStream> m_pOutStream;
 
     std::shared_ptr<const SfxFilter> pOrigFilter;
     OUString    aOrigURL;
@@ -536,11 +536,11 @@ bool SfxMedium::IsSkipImages()
 SvStream* SfxMedium::GetInStream()
 {
     if ( pImpl->m_pInStream )
-        return pImpl->m_pInStream;
+        return pImpl->m_pInStream.get();
 
     if ( pImpl->pTempFile )
     {
-        pImpl->m_pInStream = new SvFileStream(pImpl->m_aName, 
pImpl->m_nStorOpenMode);
+        pImpl->m_pInStream.reset( new SvFileStream(pImpl->m_aName, 
pImpl->m_nStorOpenMode) );
 
         pImpl->m_eError = pImpl->m_pInStream->GetError();
 
@@ -548,11 +548,10 @@ SvStream* SfxMedium::GetInStream()
                     && ! pImpl->m_pInStream->IsWritable() )
         {
             pImpl->m_eError = ERRCODE_IO_ACCESSDENIED;
-            delete pImpl->m_pInStream;
-            pImpl->m_pInStream = nullptr;
+            pImpl->m_pInStream.reset();
         }
         else
-            return pImpl->m_pInStream;
+            return pImpl->m_pInStream.get();
     }
 
     GetMedium_Impl();
@@ -560,7 +559,7 @@ SvStream* SfxMedium::GetInStream()
     if ( GetError() )
         return nullptr;
 
-    return pImpl->m_pInStream;
+    return pImpl->m_pInStream.get();
 }
 
 
@@ -586,7 +585,7 @@ void SfxMedium::CloseInStream_Impl()
         return;
     }
 
-    DELETEZ( pImpl->m_pInStream );
+    pImpl->m_pInStream.reset();
     if ( pImpl->m_pSet )
         pImpl->m_pSet->ClearItem( SID_INPUTSTREAM );
 
@@ -628,14 +627,14 @@ SvStream* SfxMedium::GetOutStream()
             {
             // On Unix don't try to re-use XOutStream from xStream if that 
exists;
             // it causes fdo#59022 (fails opening files via SMB on Linux)
-                pImpl->m_pOutStream = new SvFileStream(
-                            pImpl->m_aName, StreamMode::STD_READWRITE);
+                pImpl->m_pOutStream.reset( new SvFileStream(
+                            pImpl->m_aName, StreamMode::STD_READWRITE) );
             }
             CloseStorage();
         }
     }
 
-    return pImpl->m_pOutStream;
+    return pImpl->m_pOutStream.get();
 }
 
 
@@ -659,8 +658,7 @@ void SfxMedium::CloseOutStream_Impl()
                 CloseStorage();
         }
 
-        delete pImpl->m_pOutStream;
-        pImpl->m_pOutStream = nullptr;
+        pImpl->m_pOutStream.reset();
     }
 
     if ( !pImpl->m_pInStream )
@@ -752,7 +750,7 @@ bool SfxMedium::IsStorage()
     }
     else if ( GetInStream() )
     {
-        pImpl->bIsStorage = SotStorage::IsStorageFile( pImpl->m_pInStream ) && 
!SotStorage::IsOLEStorage( pImpl->m_pInStream );
+        pImpl->bIsStorage = SotStorage::IsStorageFile( 
pImpl->m_pInStream.get() ) && !SotStorage::IsOLEStorage( 
pImpl->m_pInStream.get() );
         if ( !pImpl->m_pInStream->GetError() && !pImpl->bIsStorage )
             pImpl->m_bTriedStorage = true;
     }
diff --git a/sfx2/source/doc/graphhelp.cxx b/sfx2/source/doc/graphhelp.cxx
index f9c9feb256be..c2bd23e05a76 100644
--- a/sfx2/source/doc/graphhelp.cxx
+++ b/sfx2/source/doc/graphhelp.cxx
@@ -87,13 +87,13 @@ void* GraphicHelper::getEnhMetaFileFromGDI_Impl( const 
GDIMetaFile* pGDIMeta )
         OUString aMetaFile = aTempFile.GetFileName();
         OUString aMetaURL = aTempFile.GetURL();
 
-        SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aMetaURL, 
StreamMode::STD_READWRITE );
+        std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( aMetaURL, StreamMode::STD_READWRITE );
         if ( pStream )
         {
             Graphic aGraph( *pGDIMeta );
             ErrCode nFailed = GraphicConverter::Export( *pStream, aGraph, 
ConvertDataFormat::EMF );
             pStream->Flush();
-            delete pStream;
+            pStream.reset();
 
             if ( !nFailed )
                 pResult = GetEnhMetaFileW( o3tl::toW(aMetaFile.getStr()) );
diff --git a/sfx2/source/view/classificationhelper.cxx 
b/sfx2/source/view/classificationhelper.cxx
index a642d19b65e8..49020b28e086 100644
--- a/sfx2/source/view/classificationhelper.cxx
+++ b/sfx2/source/view/classificationhelper.cxx
@@ -390,8 +390,8 @@ void SfxClassificationHelper::Impl::parsePolicy()
             aPath = aLocalized;
     }
 
-    SvStream* pStream = utl::UcbStreamHelper::CreateStream(aPath, 
StreamMode::READ);
-    uno::Reference<io::XInputStream> xInputStream(new 
utl::OStreamWrapper(*pStream));
+    std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream(aPath, StreamMode::READ);
+    uno::Reference<io::XInputStream> xInputStream(new 
utl::OStreamWrapper(std::move(pStream)));
     xml::sax::InputSource aParserInput;
     aParserInput.aInputStream = xInputStream;
 
diff --git a/sot/source/sdstor/storage.cxx b/sot/source/sdstor/storage.cxx
index 65f9d8a54416..3848fd941585 100644
--- a/sot/source/sdstor/storage.cxx
+++ b/sot/source/sdstor/storage.cxx
@@ -304,7 +304,7 @@ void SotStorage::CreateStorage( bool bForceUCBStorage, 
StreamMode nMode )
         }
 
         // check the stream
-        m_pStorStm = ::utl::UcbStreamHelper::CreateStream( m_aName, nMode );
+        m_pStorStm = ::utl::UcbStreamHelper::CreateStream( m_aName, nMode 
).release();
         if ( m_pStorStm && m_pStorStm->GetError() )
             DELETEZ( m_pStorStm );
 
@@ -730,7 +730,7 @@ SotStorage* SotStorage::OpenOLEStorage( const 
css::uno::Reference < css::embed::
     if ( nMode & StreamMode::NOCREATE )
         nEleMode |= embed::ElementModes::NOCREATE;
 
-    SvStream* pStream = nullptr;
+    std::unique_ptr<SvStream> pStream;
     try
     {
         uno::Reference < io::XStream > xStream = xStorage->openStreamElement( 
rEleName, nEleMode );
@@ -748,11 +748,11 @@ SotStorage* SotStorage::OpenOLEStorage( const 
css::uno::Reference < css::embed::
     catch ( uno::Exception& )
     {
         //TODO/LATER: ErrorHandling
-        pStream = new SvMemoryStream;
+        pStream.reset( new SvMemoryStream );
         pStream->SetError( ERRCODE_IO_GENERAL );
     }
 
-    return new SotStorage( pStream, true );
+    return new SotStorage( pStream.release(), true );
 }
 
 SotClipboardFormatId SotStorage::GetFormatID( const css::uno::Reference < 
css::embed::XStorage >& xStorage )
diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx
index 148c23fefaa5..d7ffbbf7a756 100644
--- a/sot/source/sdstor/ucbstorage.cxx
+++ b/sot/source/sdstor/ucbstorage.cxx
@@ -86,7 +86,7 @@ class FileStreamWrapper_Impl : public 
FileInputStreamWrapper_Base
 protected:
     ::osl::Mutex    m_aMutex;
     OUString        m_aURL;
-    SvStream*       m_pSvStream;
+    std::unique_ptr<SvStream> m_pSvStream;
 
 public:
     explicit FileStreamWrapper_Impl(const OUString& rName);
@@ -119,7 +119,7 @@ FileStreamWrapper_Impl::~FileStreamWrapper_Impl()
 {
     if ( m_pSvStream )
     {
-        delete m_pSvStream;
+        m_pSvStream.reset();
 #if OSL_DEBUG_LEVEL > 0
         --nOpenFiles;
 #endif
@@ -224,7 +224,7 @@ void SAL_CALL FileStreamWrapper_Impl::closeInput()
 
     ::osl::MutexGuard aGuard( m_aMutex );
     checkConnected();
-    DELETEZ( m_pSvStream );
+    m_pSvStream.reset();
 #if OSL_DEBUG_LEVEL > 0
     --nOpenFiles;
 #endif
@@ -414,7 +414,7 @@ public:
     OString                     m_aKey;
     ::ucbhelper::Content*       m_pContent;     // the content that provides 
the data
     Reference<XInputStream>     m_rSource;      // the stream covering the 
original data of the content
-    SvStream*                   m_pStream;      // the stream worked on; for 
readonly streams it is the original stream of the content
+    std::unique_ptr<SvStream>   m_pStream;      // the stream worked on; for 
readonly streams it is the original stream of the content
                                                 // for read/write streams it's 
a copy into a temporary file
     OUString                    m_aTempURL;     // URL of this temporary stream
     ErrCode                     m_nError;
@@ -672,7 +672,7 @@ UCBStorageStream_Impl::~UCBStorageStream_Impl()
     if( m_rSource.is() )
         m_rSource.clear();
 
-    delete m_pStream;
+    m_pStream.reset();
 
     if (!m_aTempURL.isEmpty())
         osl::File::remove(m_aTempURL);
@@ -1175,7 +1175,7 @@ void UCBStorageStream_Impl::Free()
 #endif
 
     m_rSource.clear();
-    DELETEZ( m_pStream );
+    m_pStream.reset();
 }
 
 void UCBStorageStream_Impl::PrepareCachedForReopen( StreamMode nMode )
@@ -1520,8 +1520,7 @@ UCBStorage_Impl::UCBStorage_Impl( const OUString& rName, 
StreamMode nMode, UCBSt
         if ( m_nMode & StreamMode::WRITE )
         {
             // the root storage opens the package, so make sure that there is 
any
-            SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( aName, 
StreamMode::STD_READWRITE, m_pTempFile != nullptr /* bFileExists */ );
-            delete pStream;
+            ::utl::UcbStreamHelper::CreateStream( aName, 
StreamMode::STD_READWRITE, m_pTempFile != nullptr /* bFileExists */ );
         }
     }
     else
diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx 
b/sot/source/unoolestorage/xolesimplestorage.cxx
index f8b554cb04bb..a3c95d52334e 100644
--- a/sot/source/unoolestorage/xolesimplestorage.cxx
+++ b/sot/source/unoolestorage/xolesimplestorage.cxx
@@ -397,7 +397,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const 
OUString& aName )
         if ( !pStrg )
             throw lang::WrappedTargetException(); // io::IOException(); // TODO
 
-        SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xTempFile, 
false ); // do not close the original stream
+        std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( xTempFile, false ); // do not close the 
original stream
         if ( !pStream )
             throw uno::RuntimeException();
 
@@ -407,7 +407,7 @@ uno::Any SAL_CALL OLESimpleStorage::getByName( const 
OUString& aName )
 
         DELETEZ( pNewStor );
         DELETEZ( pStrg );
-        DELETEZ( pStream );
+        pStream.reset();
 
         if ( !bSuccess )
             throw uno::RuntimeException();
@@ -572,7 +572,7 @@ void SAL_CALL OLESimpleStorage::dispose()
     }
 
     DELETEZ( m_pStorage );
-    DELETEZ( m_pStream );
+    m_pStream.reset();
 
     m_xStream.clear();
     m_xTempStream.clear();
diff --git a/sot/source/unoolestorage/xolesimplestorage.hxx 
b/sot/source/unoolestorage/xolesimplestorage.hxx
index 1b5216998d19..13ba9d01e5d8 100644
--- a/sot/source/unoolestorage/xolesimplestorage.hxx
+++ b/sot/source/unoolestorage/xolesimplestorage.hxx
@@ -44,7 +44,7 @@ class OLESimpleStorage : public 
cppu::WeakImplHelper<css::embed::XOLESimpleStora
 
     css::uno::Reference< css::io::XStream > m_xStream;
     css::uno::Reference< css::io::XStream > m_xTempStream;
-    SvStream* m_pStream;
+    std::unique_ptr<SvStream> m_pStream;
     BaseStorage* m_pStorage;
 
     ::comphelper::OInterfaceContainerHelper2* m_pListenersContainer; // list 
of listeners
diff --git a/svl/source/fsstor/fsstorage.cxx b/svl/source/fsstor/fsstorage.cxx
index 3d21e23c3b0c..6a28dc07d422 100644
--- a/svl/source/fsstor/fsstorage.cxx
+++ b/svl/source/fsstor/fsstorage.cxx
@@ -369,14 +369,12 @@ uno::Reference< io::XStream > SAL_CALL 
FSStorage::openStreamElement(
             else
             {
                 // TODO: test whether it really works for http and fwp
-                SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( 
aFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ),
+                std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ),
                                                                           
StreamMode::STD_WRITE );
                 if ( pStream )
                 {
                     if ( !pStream->GetError() )
-                        xResult.set( new ::utl::OStreamWrapper( *pStream ) );
-                    else
-                        delete pStream;
+                        xResult.set( new ::utl::OStreamWrapper( 
std::move(pStream) ) );
                 }
             }
 
@@ -1208,18 +1206,16 @@ uno::Reference< embed::XExtendedStorageStream > 
SAL_CALL FSStorage::openStreamEl
             else
             {
                 // TODO: test whether it really works for http and fwp
-                SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( 
aFileURL,
+                std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( aFileURL,
                                                                           
StreamMode::STD_WRITE );
                 if ( pStream )
                 {
                     if ( !pStream->GetError() )
                     {
                         uno::Reference< io::XStream > xStream =
-                            uno::Reference < io::XStream >( new 
::utl::OStreamWrapper( *pStream ) );
+                            uno::Reference < io::XStream >( new 
::utl::OStreamWrapper( std::move(pStream) ) );
                         xResult = static_cast< io::XStream* >( new 
OFSStreamContainer( xStream ) );
                     }
-                    else
-                        delete pStream;
                 }
             }
 
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index 0d83432d15f9..b6ec9ae1576d 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -545,7 +545,7 @@ void EmbeddedObjectRef::SetGraphic( const Graphic& 
rGraphic, const OUString& rMe
     mpImpl->bNeedUpdate = false;
 }
 
-SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) const
+std::unique_ptr<SvStream> EmbeddedObjectRef::GetGraphicStream( bool bUpdate ) 
const
 {
     DBG_ASSERT( bUpdate || mpImpl->pContainer, "Can't retrieve current 
graphic!" );
     uno::Reference < io::XInputStream > xStream;
@@ -557,7 +557,7 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate 
) const
         if ( xStream.is() )
         {
             const sal_Int32 nConstBufferSize = 32000;
-            SvStream *pStream = new SvMemoryStream( 32000, 32000 );
+            std::unique_ptr<SvStream> pStream(new SvMemoryStream( 32000, 32000 
));
             try
             {
                 sal_Int32 nRead=0;
@@ -574,7 +574,6 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate 
) const
             catch (const uno::Exception&)
             {
                 DBG_UNHANDLED_EXCEPTION("svtools.misc", "discarding broken 
embedded object preview");
-                delete pStream;
                 xStream.clear();
             }
         }
@@ -607,7 +606,7 @@ SvStream* EmbeddedObjectRef::GetGraphicStream( bool bUpdate 
) const
                 if (mpImpl->pContainer)
                     
mpImpl->pContainer->InsertGraphicStream(xStream,mpImpl->aPersistName,mpImpl->aMediaType);
 
-                SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( 
xStream );
+                std::unique_ptr<SvStream> pResult = 
::utl::UcbStreamHelper::CreateStream( xStream );
                 if (pResult && bUpdate)
                     mpImpl->bNeedUpdate = false;
 
diff --git a/svtools/source/misc/embedtransfer.cxx 
b/svtools/source/misc/embedtransfer.cxx
index 51c16627e338..29e894c56bd1 100644
--- a/svtools/source/misc/embedtransfer.cxx
+++ b/svtools/source/misc/embedtransfer.cxx
@@ -117,7 +117,7 @@ bool SvEmbedTransferHelper::GetData( const 
css::datatransfer::DataFlavor& rFlavo
                             if ( xStg->isStreamElement( aName ) )
                             {
                                 uno::Reference < io::XStream > xStm = 
xStg->cloneStreamElement( aName );
-                                pStream = utl::UcbStreamHelper::CreateStream( 
xStm );
+                                pStream = utl::UcbStreamHelper::CreateStream( 
xStm ).release();
                                 bDeleteStream = true;
                             }
                             else
diff --git a/svtools/source/misc/templatefoldercache.cxx 
b/svtools/source/misc/templatefoldercache.cxx
index 41141d1ba0c9..6fd4f6944ee7 100644
--- a/svtools/source/misc/templatefoldercache.cxx
+++ b/svtools/source/misc/templatefoldercache.cxx
@@ -702,8 +702,8 @@ namespace svt
         aStorageURL.Append( ".templdir.cache" );
 
         // open the stream
-        m_pCacheStream.reset( UcbStreamHelper::CreateStream( 
aStorageURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ),
-            _bForRead ? StreamMode::READ | StreamMode::NOCREATE : 
StreamMode::WRITE | StreamMode::TRUNC ) );
+        m_pCacheStream = UcbStreamHelper::CreateStream( 
aStorageURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ),
+            _bForRead ? StreamMode::READ | StreamMode::NOCREATE : 
StreamMode::WRITE | StreamMode::TRUNC );
         DBG_ASSERT( m_pCacheStream, "TemplateFolderCacheImpl::openCacheStream: 
could not open/create the cache stream!" );
         if ( m_pCacheStream && m_pCacheStream->GetErrorCode() )
         {
diff --git a/svx/source/xml/xmlgrhlp.cxx b/svx/source/xml/xmlgrhlp.cxx
index 4063179e9082..553522172a27 100644
--- a/svx/source/xml/xmlgrhlp.cxx
+++ b/svx/source/xml/xmlgrhlp.cxx
@@ -111,7 +111,7 @@ GraphicInputStream::GraphicInputStream(GraphicObject const 
& raGraphicObject, co
 
     if (aGraphicObject.GetType() != GraphicType::NONE)
     {
-        SvStream* pStream = 
::utl::UcbStreamHelper::CreateStream(maTempFile.GetURL(), StreamMode::WRITE | 
StreamMode::TRUNC);
+        std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream(maTempFile.GetURL(), StreamMode::WRITE | 
StreamMode::TRUNC);
 
         if (pStream)
         {
@@ -163,10 +163,8 @@ GraphicInputStream::GraphicInputStream(GraphicObject const 
& raGraphicObject, co
             if (bRet)
             {
                 pStream->Seek( 0 );
-                mxStreamWrapper = new ::utl::OInputStreamWrapper(pStream, 
true);
+                mxStreamWrapper = new 
::utl::OInputStreamWrapper(std::move(pStream));
             }
-            else
-                delete pStream;
         }
     }
 }
@@ -250,7 +248,7 @@ SvXMLGraphicOutputStream::SvXMLGraphicOutputStream()
 {
     mpTmp->EnableKillingFile();
 
-    mpOStm.reset( ::utl::UcbStreamHelper::CreateStream( mpTmp->GetURL(), 
StreamMode::WRITE | StreamMode::TRUNC ) );
+    mpOStm = ::utl::UcbStreamHelper::CreateStream( mpTmp->GetURL(), 
StreamMode::WRITE | StreamMode::TRUNC );
 
     if( mpOStm )
         mxStmWrapper = new ::utl::OOutputStreamWrapper( *mpOStm );
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx 
b/sw/qa/extras/inc/swmodeltestbase.hxx
index ea3ce849a623..e0d304beabc8 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -194,11 +194,11 @@ protected:
         xImporter->setTargetDocument(mxComponent);
         uno::Sequence<beans::PropertyValue> aDescriptor(3);
         aDescriptor[0].Name = "InputStream";
-        SvStream* pStream = utl::UcbStreamHelper::CreateStream(
+        std::unique_ptr<SvStream> pStream = utl::UcbStreamHelper::CreateStream(
             m_directories.getURLFromSrc("/sw/qa/extras/") + aFilename,
             StreamMode::STD_READ);
         CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, pStream->GetError());
-        uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+        uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
         aDescriptor[0].Value <<= xStream;
         aDescriptor[1].Name = "InsertMode";
         aDescriptor[1].Value <<= true;
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index 894056d70d94..bc4e289647c4 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -100,8 +100,8 @@ protected:
         uno::Reference<document::XFilter> 
xFilter(m_xSFactory->createInstance("com.sun.star.comp.Writer.WriterFilter"), 
uno::UNO_QUERY_THROW);
         uno::Reference<document::XImporter> xImporter(xFilter, 
uno::UNO_QUERY_THROW);
         xImporter->setTargetDocument(mxComponent);
-        SvStream* pStream = 
utl::UcbStreamHelper::CreateStream(m_directories.getURLFromSrc("/sw/qa/extras/ooxmlexport/data/")
 + rFilename, StreamMode::READ);
-        uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+        std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream(m_directories.getURLFromSrc("/sw/qa/extras/ooxmlexport/data/")
 + rFilename, StreamMode::READ);
+        uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
         uno::Sequence<beans::PropertyValue> 
aDescriptor(comphelper::InitPropertySequence(
         {
             {"InputStream", uno::makeAny(xStream)},
diff --git a/sw/source/core/swg/SwXMLTextBlocks.cxx 
b/sw/source/core/swg/SwXMLTextBlocks.cxx
index 0ce9064e5deb..eed2272a3ad5 100644
--- a/sw/source/core/swg/SwXMLTextBlocks.cxx
+++ b/sw/source/core/swg/SwXMLTextBlocks.cxx
@@ -505,9 +505,8 @@ bool SwXMLTextBlocks::IsFileUCBStorage( const OUString & 
rFileName)
         aName = aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
     }
 
-    SvStream * pStm = ::utl::UcbStreamHelper::CreateStream( aName, 
StreamMode::STD_READ );
-    bool bRet = UCBStorage::IsStorageFile( pStm );
-    delete pStm;
+    std::unique_ptr<SvStream> pStm = ::utl::UcbStreamHelper::CreateStream( 
aName, StreamMode::STD_READ );
+    bool bRet = UCBStorage::IsStorageFile( pStm.get() );
     return bRet;
 }
 
diff --git a/sw/source/filter/ww8/rtfexportfilter.cxx 
b/sw/source/filter/ww8/rtfexportfilter.cxx
index fce00510105c..292e3e3d1e0d 100644
--- a/sw/source/filter/ww8/rtfexportfilter.cxx
+++ b/sw/source/filter/ww8/rtfexportfilter.cxx
@@ -43,8 +43,8 @@ sal_Bool RtfExportFilter::filter(const 
uno::Sequence<beans::PropertyValue>& aDes
     utl::MediaDescriptor aMediaDesc = aDescriptor;
     uno::Reference<io::XStream> xStream = aMediaDesc.getUnpackedValueOrDefault(
         utl::MediaDescriptor::PROP_STREAMFOROUTPUT(), 
uno::Reference<io::XStream>());
-    SvStream* pStream = utl::UcbStreamHelper::CreateStream(xStream, true);
-    m_aWriter.SetStream(pStream);
+    std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream(xStream, true);
+    m_aWriter.SetStream(pStream.get());
 
     // get SwDoc*
     uno::Reference<uno::XInterface> xIfc(m_xSrcDoc, uno::UNO_QUERY);
@@ -83,7 +83,6 @@ sal_Bool RtfExportFilter::filter(const 
uno::Sequence<beans::PropertyValue>& aDes
     // delete the pCurPam
     while (pCurPam->GetNext() != pCurPam.get())
         delete pCurPam->GetNext();
-    delete pStream;
 
     return true;
 }
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 58c4de33f771..cb1af3ce4d68 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3775,7 +3775,7 @@ void WW8Export::RestoreMacroCmds()
     {
         uno::Reference < io::XStream > xSrcStream =
                 xSrcRoot->openStreamElement( SL::aMSMacroCmds, 
embed::ElementModes::READ );
-        SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xSrcStream );
+        std::unique_ptr<SvStream> pStream = 
::utl::UcbStreamHelper::CreateStream( xSrcStream );
 
         if ( pStream && ERRCODE_NONE == pStream->GetError())
         {
@@ -3788,8 +3788,6 @@ void WW8Export::RestoreMacroCmds()
             if (bReadOk)
                 pTableStrm->WriteBytes(pBuffer.get(), pFib->m_lcbCmds);
         }
-
-        delete pStream;
     }
     catch ( const uno::Exception& )
     {
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx 
b/sw/source/filter/ww8/wrtww8gr.cxx
index 3d2624f654de..d48a2e404142 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -159,7 +159,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet,
             uno::Reference< embed::XEmbeddedObject > xObj = 
pOLENd->GetOLEObj().GetOleRef();
             if ( xObj.is() )
             {
-                SvStream* pGraphicStream = nullptr;
+                std::unique_ptr<SvStream> pGraphicStream;
                 comphelper::EmbeddedObjectContainer aCnt( 
m_pDoc->GetDocStorage() );
                 try
                 {
@@ -183,7 +183,6 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet,
                     if( rGF.ImportGraphic( aGr1, OUString(), *pGraphicStream ) 
== ERRCODE_NONE )
                     {
                         Graphic aGr2;
-                        delete pGraphicStream;
                         pGraphicStream =
                                 ::utl::UcbStreamHelper::CreateStream( 
aCnt.GetGraphicStream( pRet->GetObjRef() ) );
                         if( pGraphicStream && rGF.ImportGraphic( aGr2, 
OUString(), *pGraphicStream ) == ERRCODE_NONE )
@@ -193,7 +192,6 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet,
                         }
                     }
                 }
-                delete pGraphicStream;
             }
 
             // always use SdrObject::Free(...) for SdrObjects (!)
diff --git a/sw/source/filter/xml/swxml.cxx b/sw/source/filter/xml/swxml.cxx
index 928df235531b..3d64af5c5c57 100644
--- a/sw/source/filter/xml/swxml.cxx
+++ b/sw/source/filter/xml/swxml.cxx
@@ -855,10 +855,9 @@ ErrCode XMLReader::Read( SwDoc &rDoc, const OUString& 
rBaseURL, SwPaM &rPaM, con
         try
         {
             uno::Reference < io::XStream > xStm = xStorage->openStreamElement( 
"layout-cache", embed::ElementModes::READ );
-            SvStream* pStrm2 = utl::UcbStreamHelper::CreateStream( xStm );
+            std::unique_ptr<SvStream> pStrm2 = 
utl::UcbStreamHelper::CreateStream( xStm );
             if( !pStrm2->GetError() )
                 rDoc.ReadLayoutCache( *pStrm2 );
-            delete pStrm2;
         }
         catch (const uno::Exception&)
         {
diff --git a/sw/source/filter/xml/wrtxml.cxx b/sw/source/filter/xml/wrtxml.cxx
index 4700a5ce86d1..8006286146cf 100644
--- a/sw/source/filter/xml/wrtxml.cxx
+++ b/sw/source/filter/xml/wrtxml.cxx
@@ -372,7 +372,7 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < 
task::XStatusIndicator >& xS
         try
         {
             uno::Reference < io::XStream > xStm = xStg->openStreamElement( 
"layout-cache", embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE 
);
-            SvStream* pStream = utl::UcbStreamHelper::CreateStream( xStm );
+            std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream( xStm );
             if( !pStream->GetError() )
             {
                 uno::Reference < beans::XPropertySet > xSet( xStm, UNO_QUERY );
@@ -381,8 +381,6 @@ ErrCode SwXMLWriter::Write_( const uno::Reference < 
task::XStatusIndicator >& xS
                 xSet->setPropertyValue("MediaType", aAny2 );
                 m_pDoc->WriteLayoutCache( *pStream );
             }
-
-            delete pStream;
         }
         catch ( uno::Exception& )
         {
diff --git a/sw/source/uibase/uno/SwXFilterOptions.cxx 
b/sw/source/uibase/uno/SwXFilterOptions.cxx
index d7163846db00..0c09c570308b 100644
--- a/sw/source/uibase/uno/SwXFilterOptions.cxx
+++ b/sw/source/uibase/uno/SwXFilterOptions.cxx
@@ -81,7 +81,7 @@ sal_Int16 SwXFilterOptions::execute()
 
     std::unique_ptr<SvStream> pInStream;
     if ( xInputStream.is() )
-        pInStream.reset(utl::UcbStreamHelper::CreateStream( xInputStream ));
+        pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
 
     uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
     SwDocShell* pDocShell = nullptr;
diff --git a/unotools/source/streaming/streamwrap.cxx 
b/unotools/source/streaming/streamwrap.cxx
index dec5f38f8bc4..fc68b8df300d 100644
--- a/unotools/source/streaming/streamwrap.cxx
+++ b/unotools/source/streaming/streamwrap.cxx
@@ -43,6 +43,12 @@ OInputStreamWrapper::OInputStreamWrapper( SvStream* pStream, 
bool bOwner )
 {
 }
 
+OInputStreamWrapper::OInputStreamWrapper( std::unique_ptr<SvStream> pStream )
+                 :m_pSvStream( pStream.release() )
+                 ,m_bSvStreamOwner( true )
+{
+}
+
 OInputStreamWrapper::~OInputStreamWrapper()
 {
     if( m_bSvStreamOwner )
@@ -288,6 +294,11 @@ OStreamWrapper::OStreamWrapper(SvStream& _rStream)
     SetStream( &_rStream, false );
 }
 
+OStreamWrapper::OStreamWrapper(std::unique_ptr<SvStream> pStream)
+{
+    SetStream( pStream.release(), true );
+}
+
 css::uno::Reference< css::io::XInputStream > SAL_CALL 
OStreamWrapper::getInputStream(  )
 {
     return this;
diff --git a/unotools/source/ucbhelper/ucbstreamhelper.cxx 
b/unotools/source/ucbhelper/ucbstreamhelper.cxx
index 63260f632b91..7ded3ca9ad47 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/filter/graphicfilter.cxx 
b/vcl/source/filter/graphicfilter.cxx
index fea987a63520..fbf495aec3af 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1297,7 +1297,7 @@ ErrCode GraphicFilter::ImportGraphic(
 struct GraphicImportContext
 {
     /// Pixel data is read from this stream.
-    std::shared_ptr<SvStream> m_pStream;
+    std::unique_ptr<SvStream> m_pStream;
     /// The Graphic the import filter gets.
     std::shared_ptr<Graphic> m_pGraphic;
     /// Write pixel data using this access.
@@ -1342,34 +1342,34 @@ void GraphicImportTask::doImport(GraphicImportContext& 
rContext)
         rContext.m_eLinkType = GfxLinkType::NativeJpg;
 }
 
-void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& 
rGraphics, const std::vector< std::shared_ptr<SvStream> >& rStreams)
+void GraphicFilter::ImportGraphics(std::vector< std::shared_ptr<Graphic> >& 
rGraphics, std::vector< std::unique_ptr<SvStream> > vStreams)
 {
     static bool bThreads = !getenv("VCL_NO_THREAD_IMPORT");
     std::vector<GraphicImportContext> aContexts;
-    aContexts.reserve(rStreams.size());
+    aContexts.reserve(vStreams.size());
     comphelper::ThreadPool& rSharedPool = 
comphelper::ThreadPool::getSharedOptimalPool();
     std::shared_ptr<comphelper::ThreadTaskTag> pTag = 
comphelper::ThreadPool::createThreadTaskTag();
 
-    for (const auto& pStream : rStreams)
+    for (auto& pStream : vStreams)
     {
         aContexts.emplace_back();
         GraphicImportContext& rContext = aContexts.back();
 
         if (pStream)
         {
-            rContext.m_pStream = pStream;
+            rContext.m_pStream = std::move(pStream);
             rContext.m_pGraphic = std::make_shared<Graphic>();
             rContext.m_nStatus = ERRCODE_NONE;
 
             // Detect the format.
             ResetLastError();
-            rContext.m_nStreamBegin = pStream->Tell();
+            rContext.m_nStreamBegin = rContext.m_pStream->Tell();
             sal_uInt16 nFormat = GRFILTER_FORMAT_DONTKNOW;
-            rContext.m_nStatus = ImpTestOrFindFormat(OUString(), *pStream, 
nFormat);
-            pStream->Seek(rContext.m_nStreamBegin);
+            rContext.m_nStatus = ImpTestOrFindFormat(OUString(), 
*rContext.m_pStream, nFormat);
+            rContext.m_pStream->Seek(rContext.m_nStreamBegin);
 
             // Import the graphic.
-            if (rContext.m_nStatus == ERRCODE_NONE && !pStream->GetError())
+            if (rContext.m_nStatus == ERRCODE_NONE && 
!rContext.m_pStream->GetError())
             {
                 OUString aFilterName = pConfig->GetImportFilterName(nFormat);
 
@@ -1377,13 +1377,13 @@ void GraphicFilter::ImportGraphics(std::vector< 
std::shared_ptr<Graphic> >& rGra
                 {
                     rContext.m_nImportFlags = 
GraphicFilterImportFlags::SetLogsizeForJpeg;
 
-                    if (!ImportJPEG( *pStream, *rContext.m_pGraphic, 
rContext.m_nImportFlags | GraphicFilterImportFlags::OnlyCreateBitmap, nullptr))
+                    if (!ImportJPEG( *rContext.m_pStream, 
*rContext.m_pGraphic, rContext.m_nImportFlags | 
GraphicFilterImportFlags::OnlyCreateBitmap, nullptr))
                         rContext.m_nStatus = ERRCODE_GRFILTER_FILTERERROR;
                     else
                     {
                         Bitmap& rBitmap = 
const_cast<Bitmap&>(rContext.m_pGraphic->GetBitmapExRef().GetBitmapRef());
                         rContext.m_pAccess = 
o3tl::make_unique<BitmapScopedWriteAccess>(rBitmap);
-                        pStream->Seek(rContext.m_nStreamBegin);
+                        rContext.m_pStream->Seek(rContext.m_nStreamBegin);
                         if (bThreads)
                             
rSharedPool.pushTask(o3tl::make_unique<GraphicImportTask>(pTag, rContext));
                         else
@@ -2574,7 +2574,7 @@ ErrCode GraphicFilter::LoadGraphic( const OUString 
&rPath, const OUString &rFilt
 
     std::unique_ptr<SvStream> pStream;
     if ( INetProtocol::File != aURL.GetProtocol() )
-        pStream.reset(::utl::UcbStreamHelper::CreateStream( rPath, 
StreamMode::READ ));
+        pStream = ::utl::UcbStreamHelper::CreateStream( rPath, 
StreamMode::READ );
 
     ErrCode nRes = ERRCODE_NONE;
     if ( !pStream )
diff --git a/vcl/source/filter/graphicfilter2.cxx 
b/vcl/source/filter/graphicfilter2.cxx
index d0bf0517cd8c..f9b5ae775c7f 100644
--- a/vcl/source/filter/graphicfilter2.cxx
+++ b/vcl/source/filter/graphicfilter2.cxx
@@ -28,7 +28,7 @@
 #define DATA_SIZE           640
 
 GraphicDescriptor::GraphicDescriptor( const INetURLObject& rPath ) :
-    pFileStm( ::utl::UcbStreamHelper::CreateStream( rPath.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ) ),
+    pFileStm( ::utl::UcbStreamHelper::CreateStream( rPath.GetMainURL( 
INetURLObject::DecodeMechanism::NONE ), StreamMode::READ ).release() ),
     aPathExt( rPath.GetFileExtension().toAsciiLowerCase() ),
     bOwnStream( true )
 {
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index ff59da4a9f0b..467e130c8738 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -1444,7 +1444,7 @@ bool ImpGraphic::ImplSwapOut()
             std::unique_ptr<SvStream> xOStm;
             try
             {
-                xOStm.reset(::utl::UcbStreamHelper::CreateStream( 
aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), 
StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE ));
+                xOStm = ::utl::UcbStreamHelper::CreateStream( 
aTmpURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ), 
StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
             }
             catch( const css::uno::Exception& )
             {
@@ -1571,7 +1571,7 @@ bool ImpGraphic::ImplSwapIn()
             std::unique_ptr<SvStream> xIStm;
             try
             {
-                xIStm.reset(::utl::UcbStreamHelper::CreateStream( aSwapURL, 
StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE ));
+                xIStm = ::utl::UcbStreamHelper::CreateStream( aSwapURL, 
StreamMode::READWRITE | StreamMode::SHARE_DENYWRITE );
             }
             catch( const css::uno::Exception& )
             {
diff --git a/vcl/source/graphic/GraphicLoader.cxx 
b/vcl/source/graphic/GraphicLoader.cxx
index 22151bf9d88a..770cb2158fba 100644
--- a/vcl/source/graphic/GraphicLoader.cxx
+++ b/vcl/source/graphic/GraphicLoader.cxx
@@ -24,8 +24,8 @@ Graphic loadFromURL(OUString const& rURL)
 {
     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)
     {
diff --git a/vcl/source/graphic/UnoGraphicProvider.cxx 
b/vcl/source/graphic/UnoGraphicProvider.cxx
index bf0b0bc8f654..5b28ed3723c5 100644
--- a/vcl/source/graphic/UnoGraphicProvider.cxx
+++ b/vcl/source/graphic/UnoGraphicProvider.cxx
@@ -366,7 +366,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL 
GraphicProvider::queryGraphic( co
 
     if( xIStm.is() )
     {
-        pIStm.reset(::utl::UcbStreamHelper::CreateStream( xIStm ));
+        pIStm = ::utl::UcbStreamHelper::CreateStream( xIStm );
     }
     else if( !aPath.isEmpty() )
     {
@@ -379,7 +379,7 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL 
GraphicProvider::queryGraphic( co
             xRet = implLoadStandardImage( aPath );
 
         if( !xRet.is() )
-            pIStm.reset(::utl::UcbStreamHelper::CreateStream( aPath, 
StreamMode::READ ));
+            pIStm = ::utl::UcbStreamHelper::CreateStream( aPath, 
StreamMode::READ );
     }
     else if( xBtm.is() )
     {
@@ -441,10 +441,10 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > 
SAL_CALL GraphicProvider::que
     SolarMutexGuard aGuard;
 
     // Turn properties into streams.
-    std::vector< std::shared_ptr<SvStream> > aStreams;
+    std::vector< std::unique_ptr<SvStream> > aStreams;
     for (const auto& rMediaProperties : rMediaPropertiesSeq)
     {
-        SvStream* pStream = nullptr;
+        std::unique_ptr<SvStream> pStream;
         uno::Reference<io::XInputStream> xStream;
 
         for (sal_Int32 i = 0; rMediaProperties.getLength(); ++i)
@@ -458,14 +458,13 @@ uno::Sequence< uno::Reference<graphic::XGraphic> > 
SAL_CALL GraphicProvider::que
             }
         }
 
-        aStreams.push_back(std::shared_ptr<SvStream>(pStream));
-
+        aStreams.push_back(std::move(pStream));
     }
 
     // Import: streams to graphics.
     std::vector< std::shared_ptr<Graphic> > aGraphics;
     GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
-    rFilter.ImportGraphics(aGraphics, aStreams);
+    rFilter.ImportGraphics(aGraphics, std::move(aStreams));
 
     // Returning: graphics to UNO objects.
     std::vector< uno::Reference<graphic::XGraphic> > aRet;
@@ -718,7 +717,7 @@ void SAL_CALL GraphicProvider::storeGraphic( const 
uno::Reference< ::graphic::XG
             OUString aURL;
 
             aValue >>= aURL;
-            pOStm.reset(::utl::UcbStreamHelper::CreateStream( aURL, 
StreamMode::WRITE | StreamMode::TRUNC ));
+            pOStm = ::utl::UcbStreamHelper::CreateStream( aURL, 
StreamMode::WRITE | StreamMode::TRUNC );
             aPath = aURL;
         }
         else if (aName == "OutputStream")
@@ -728,7 +727,7 @@ void SAL_CALL GraphicProvider::storeGraphic( const 
uno::Reference< ::graphic::XG
             aValue >>= xOStm;
 
             if( xOStm.is() )
-                pOStm.reset(::utl::UcbStreamHelper::CreateStream( xOStm ));
+                pOStm = ::utl::UcbStreamHelper::CreateStream( xOStm );
         }
     }
 
diff --git a/writerfilter/source/filter/RtfFilter.cxx 
b/writerfilter/source/filter/RtfFilter.cxx
index 8cb92e7f6624..ba6e3faa8d97 100644
--- a/writerfilter/source/filter/RtfFilter.cxx
+++ b/writerfilter/source/filter/RtfFilter.cxx
@@ -123,8 +123,8 @@ sal_Bool RtfFilter::filter(const uno::Sequence< 
beans::PropertyValue >& rDescrip
         {
             OUString aInStr;
             osl::FileBase::getFileURLFromSystemPath(OUString::fromUtf8(pEnv), 
aInStr);
-            SvStream* pStream = utl::UcbStreamHelper::CreateStream(aInStr, 
StreamMode::READ);
-            uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(*pStream));
+            std::unique_ptr<SvStream> pStream = 
utl::UcbStreamHelper::CreateStream(aInStr, StreamMode::READ);
+            uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
             xInputStream.set(xStream, uno::UNO_QUERY);
         }
 
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx 
b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index fca227d9a702..aa4f859aabc3 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -297,7 +297,7 @@ 
RTFDocumentImpl::RTFDocumentImpl(uno::Reference<uno::XComponentContext> const& x
     , m_bAfterCellBeforeRow(false)
 {
     OSL_ASSERT(xInputStream.is());
-    m_pInStream.reset(utl::UcbStreamHelper::CreateStream(xInputStream, true));
+    m_pInStream = utl::UcbStreamHelper::CreateStream(xInputStream, true);
 
     m_xModelFactory.set(m_xDstDoc, uno::UNO_QUERY);
 
diff --git a/writerperfect/source/common/WPXSvInputStream.cxx 
b/writerperfect/source/common/WPXSvInputStream.cxx
index 2dfee8a44799..1c06f1b784bd 100644
--- a/writerperfect/source/common/WPXSvInputStream.cxx
+++ b/writerperfect/source/common/WPXSvInputStream.cxx
@@ -144,7 +144,7 @@ struct OLEStorageImpl
 {
     OLEStorageImpl();
 
-    void initialize(SvStream* pStream);
+    void initialize(std::unique_ptr<SvStream> pStream);
 
     tools::SvRef<SotStorageStream> getStream(const rtl::OUString& rPath);
     tools::SvRef<SotStorageStream> const& getStream(std::size_t nId);
@@ -178,12 +178,12 @@ OLEStorageImpl::OLEStorageImpl()
 {
 }
 
-void OLEStorageImpl::initialize(SvStream* const pStream)
+void OLEStorageImpl::initialize(std::unique_ptr<SvStream> pStream)
 {
     if (!pStream)
         return;
 
-    mxRootStorage.ref = new SotStorage(pStream, true);
+    mxRootStorage.ref = new SotStorage(pStream.release(), true);
 
     traverse(mxRootStorage.ref, "");
 
diff --git a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx 
b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
index 442323deb6ad..338feda0e134 100644
--- a/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
+++ b/xmlsecurity/qa/unit/pdfsigning/pdfsigning.cxx
@@ -324,9 +324,9 @@ void PDFSigningTest::testPDFRemoveAll()
         osl::File::copy(m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"2good.pdf", aOutURL));
     // Load the test document as a storage and read its two signatures.
     DocumentSignatureManager aManager(mxComponentContext, 
DocumentSignatureMode::Content);
-    SvStream* pStream
+    std::unique_ptr<SvStream> pStream
         = utl::UcbStreamHelper::CreateStream(aOutURL, StreamMode::READ | 
StreamMode::WRITE);
-    uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+    uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
     aManager.mxSignatureStream = xStream;
     aManager.read(/*bUseTempStream=*/false);
     std::vector<SignatureInformation>& rInformations = 
aManager.maCurrentSignatureInformations;
@@ -354,9 +354,9 @@ void PDFSigningTest::testTdf107782()
     // Load the test document as a storage and read its signatures.
     DocumentSignatureManager aManager(mxComponentContext, 
DocumentSignatureMode::Content);
     OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + 
"tdf107782.pdf";
-    SvStream* pStream
+    std::unique_ptr<SvStream> pStream
         = utl::UcbStreamHelper::CreateStream(aURL, StreamMode::READ | 
StreamMode::WRITE);
-    uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+    uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
     aManager.mxSignatureStream = xStream;
     aManager.read(/*bUseTempStream=*/false);
     CPPUNIT_ASSERT(aManager.mpPDFSignatureHelper);
@@ -514,9 +514,9 @@ void PDFSigningTest::testUnknownSubFilter()
         = xml::crypto::SEInitializer::create(mxComponentContext);
     uno::Reference<xml::crypto::XXMLSecurityContext> xSecurityContext
         = xSEInitializer->createSecurityContext(OUString());
-    SvStream* pStream = utl::UcbStreamHelper::CreateStream(
+    std::unique_ptr<SvStream> pStream = utl::UcbStreamHelper::CreateStream(
         m_directories.getURLFromSrc(DATA_DIRECTORY) + "cr-comment.pdf", 
StreamMode::STD_READ);
-    uno::Reference<io::XStream> xStream(new utl::OStreamWrapper(*pStream));
+    uno::Reference<io::XStream> xStream(new 
utl::OStreamWrapper(std::move(pStream)));
     DocumentSignatureManager aManager(mxComponentContext, 
DocumentSignatureMode::Content);
     aManager.mxSignatureStream = xStream;
     aManager.read(/*bUseTempStream=*/false);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to