[Libreoffice-commits] core.git: compilerplugins/clang include/tools include/unotools stoc/source tools/source unotools/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Jan 11 11:48:07 UTC 2018


 compilerplugins/clang/useuniqueptr.cxx |    5 +
 include/tools/inetstrm.hxx             |    6 -
 include/tools/multisel.hxx             |    7 -
 include/tools/stream.hxx               |    7 +
 include/unotools/intlwrapper.hxx       |   13 +-
 include/unotools/tempfile.hxx          |    4 
 stoc/source/corereflection/base.hxx    |    2 
 stoc/source/corereflection/criface.cxx |   45 +++------
 tools/source/inet/inetstrm.cxx         |   10 --
 tools/source/memtools/multisel.cxx     |  150 +++++++++++++--------------------
 tools/source/stream/stream.cxx         |   40 ++++----
 tools/source/stream/strmunx.cxx        |    6 -
 tools/source/stream/strmwnt.cxx        |    5 -
 unotools/source/i18n/intlwrapper.cxx   |    9 -
 unotools/source/misc/syslocale.cxx     |   17 +--
 unotools/source/ucbhelper/tempfile.cxx |   17 +--
 16 files changed, 150 insertions(+), 193 deletions(-)

New commits:
commit e57a036939e27ecd173ace691689e26a6a33df8e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 10 12:30:15 2018 +0200

    loplugin:useuniqueptr in tools,stoc,unotools
    
    Change-Id: Ia72b65577143623cedc7a40bc34f7fb897add097
    Reviewed-on: https://gerrit.libreoffice.org/47726
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index 0c0e25d2ebee..7524f7662e3c 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -112,6 +112,11 @@ void UseUniquePtr::CheckForUnconditionalDelete(const CXXDestructorDecl* destruct
         // @TODO it's sharing pointers with another class
         if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sc/inc/formulacell.hxx"))
             continue;
+        // some weird stuff going on here around struct Entity
+        if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/sax/"))
+            continue;
+        if (loplugin::hasPathnamePrefix(aFileName, SRCDIR "/include/sax/"))
+            continue;
 
         report(
             DiagnosticsEngine::Warning,
diff --git a/include/tools/inetstrm.hxx b/include/tools/inetstrm.hxx
index f3e7ae325c90..765474ef8248 100644
--- a/include/tools/inetstrm.hxx
+++ b/include/tools/inetstrm.hxx
@@ -23,6 +23,7 @@
 #include <tools/stream.hxx>
 #include <sal/types.h>
 #include <vector>
+#include <memory>
 
 class INetMIMEMessage;
 class SvStream;
@@ -36,7 +37,8 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
     sal_Char       *pRead;
     sal_Char       *pWrite;
 
-    SvStream       *pMsgStrm;
+    std::unique_ptr<SvStream>
+                    pMsgStrm;
     SvMemoryStream  maMsgBuffer;
     sal_Char       *pMsgRead;
     sal_Char       *pMsgWrite;
@@ -44,7 +46,7 @@ class TOOLS_DLLPUBLIC INetMIMEMessageStream
     bool done;
 
     sal_uInt32             nChildIndex;
-    INetMIMEMessageStream *pChildStrm;
+    std::unique_ptr<INetMIMEMessageStream> pChildStrm;
 
     INetMIMEMessageStream (const INetMIMEMessageStream& rStrm) = delete;
     INetMIMEMessageStream& operator= (const INetMIMEMessageStream& rStrm) = delete;
diff --git a/include/tools/multisel.hxx b/include/tools/multisel.hxx
index 854be3768afb..c26eccf221c6 100644
--- a/include/tools/multisel.hxx
+++ b/include/tools/multisel.hxx
@@ -26,14 +26,13 @@
 #include <vector>
 #include <set>
 
-typedef ::std::vector< Range* > ImpSelList;
-
 #define SFX_ENDOFSELECTION      SAL_MAX_INT32
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC MultiSelection
 {
 private:
-    ImpSelList      aSels;      // array of SV-selections
+    std::vector< Range >
+                    aSels;      // array of SV-selections
     Range           aTotRange;  // total range of indexes
     sal_Int32       nCurSubSel; // index in aSels of current selected index
     sal_Int32       nCurIndex;  // current selected entry
@@ -72,7 +71,7 @@ public:
     sal_Int32       NextSelected();
 
     sal_Int32       GetRangeCount() const { return aSels.size(); }
-    const Range&    GetRange( sal_Int32 nRange ) const { return *aSels[nRange]; }
+    const Range&    GetRange( sal_Int32 nRange ) const { return aSels[nRange]; }
 };
 
 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC StringRangeEnumerator
diff --git a/include/tools/stream.hxx b/include/tools/stream.hxx
index 640dca026598..cb211ddba607 100644
--- a/include/tools/stream.hxx
+++ b/include/tools/stream.hxx
@@ -26,6 +26,7 @@
 #include <vcl/errcode.hxx>
 #include <rtl/string.hxx>
 #include <o3tl/typed_flags_set.hxx>
+#include <memory>
 
 class StreamData;
 
@@ -143,7 +144,8 @@ private:
     sal_uInt64      m_nActPos;
 
     // buffer management
-    sal_uInt8*      m_pRWBuf;     ///< Points to read/write buffer
+    std::unique_ptr<sal_uInt8>
+                    m_pRWBuf;     ///< Points to read/write buffer
     sal_uInt8*      m_pBufPos;    ///< m_pRWBuf + m_nBufActualPos
     sal_uInt16      m_nBufSize;   ///< Allocated size of buffer
     sal_uInt16      m_nBufActualLen; ///< Length of used segment of puffer
@@ -582,7 +584,8 @@ TOOLS_DLLPUBLIC bool checkSeek(SvStream &rSt, sal_uInt64 nOffset) SAL_WARN_UNUSE
 class TOOLS_DLLPUBLIC SvFileStream : public SvStream
 {
 private:
-    StreamData*     pInstanceData;
+    std::unique_ptr<StreamData>
+                    pInstanceData;
     OUString        aFilename;
 #if defined(_WIN32)
     sal_uInt16      nLockCounter;
diff --git a/include/unotools/intlwrapper.hxx b/include/unotools/intlwrapper.hxx
index 8877a05dbd61..ffcb3313b349 100644
--- a/include/unotools/intlwrapper.hxx
+++ b/include/unotools/intlwrapper.hxx
@@ -27,6 +27,7 @@
 #include <unotools/collatorwrapper.hxx>
 #include <i18nlangtag/lang.h>
 #include <i18nlangtag/languagetag.hxx>
+#include <memory>
 
 /**
     A wrapper of I18N wrappers. Using this is more expensive than using some
@@ -50,9 +51,9 @@ private:
     LanguageTag         maLanguageTag;
     css::uno::Reference< css::uno::XComponentContext > m_xContext;
 
-    LocaleDataWrapper*  pLocaleData;
-    CollatorWrapper*    pCollator;
-    CollatorWrapper*    pCaseCollator;
+    std::unique_ptr<LocaleDataWrapper>  pLocaleData;
+    std::unique_ptr<CollatorWrapper>    pCollator;
+    std::unique_ptr<CollatorWrapper>    pCaseCollator;
 
     void                ImplNewLocaleData() const;
     void                ImplNewCollator( bool bCaseSensitive ) const;
@@ -65,21 +66,21 @@ public:
                                     {
                                         if ( !pLocaleData )
                                             ImplNewLocaleData();
-                                        return pLocaleData;
+                                        return pLocaleData.get();
                                     }
     /// case insensitive collator, simple IGNORE_CASE
     const CollatorWrapper*      getCollator() const
                                     {
                                         if ( !pCollator )
                                             ImplNewCollator( false );
-                                        return pCollator;
+                                        return pCollator.get();
                                     }
     /// case sensitive collator
     const CollatorWrapper*      getCaseCollator() const
                                     {
                                         if ( !pCaseCollator )
                                             ImplNewCollator( true );
-                                        return pCaseCollator;
+                                        return pCaseCollator.get();
                                     }
 };
 
diff --git a/include/unotools/tempfile.hxx b/include/unotools/tempfile.hxx
index 791b51573f29..a70f7d277fbf 100644
--- a/include/unotools/tempfile.hxx
+++ b/include/unotools/tempfile.hxx
@@ -22,6 +22,7 @@
 
 #include <unotools/unotoolsdllapi.h>
 #include <tools/stream.hxx>
+#include <memory>
 
 namespace utl
 {
@@ -45,7 +46,8 @@ namespace utl
 class UNOTOOLS_DLLPUBLIC TempFile
 {
     OUString    aName;
-    SvStream*   pStream;
+    std::unique_ptr<SvStream>
+                pStream;
     bool        bIsDirectory;
     bool        bKillingFileEnabled;
 
diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx
index fe15a10a75ac..4c05b91078c9 100644
--- a/stoc/source/corereflection/base.hxx
+++ b/stoc/source/corereflection/base.hxx
@@ -197,7 +197,7 @@ class InterfaceIdlClassImpl
 
     css::uno::Sequence< css::uno::Reference< css::reflection::XIdlClass > >      _xSuperClasses;
 
-    MemberInit *                            _pSortedMemberInit; // first methods, then attributes
+    std::unique_ptr<MemberInit[]>           _pSortedMemberInit; // first methods, then attributes
     OUString2Field                          _aName2Field;
     OUString2Method                         _aName2Method;
     sal_Int32                               _nMethods;
diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx
index 91177f626246..fddaff0b4b6a 100644
--- a/stoc/source/corereflection/criface.cxx
+++ b/stoc/source/corereflection/criface.cxx
@@ -327,9 +327,9 @@ class IdlInterfaceMethodImpl
     : public IdlMemberImpl
     , public XIdlMethod
 {
-    Sequence< Reference< XIdlClass > > * _pExceptionTypes;
-    Sequence< Reference< XIdlClass > > * _pParamTypes;
-    Sequence< ParamInfo > *              _pParamInfos;
+    std::unique_ptr<Sequence< Reference< XIdlClass > >> _pExceptionTypes;
+    std::unique_ptr<Sequence< Reference< XIdlClass > >> _pParamTypes;
+    std::unique_ptr<Sequence< ParamInfo >>              _pParamInfos;
 
 public:
     typelib_InterfaceMethodTypeDescription * getMethodTypeDescr() const
@@ -338,11 +338,7 @@ public:
     IdlInterfaceMethodImpl( IdlReflectionServiceImpl * pReflection, const OUString & rName,
                             typelib_TypeDescription * pTypeDescr, typelib_TypeDescription * pDeclTypeDescr )
         : IdlMemberImpl( pReflection, rName, pTypeDescr, pDeclTypeDescr )
-        , _pExceptionTypes( nullptr )
-        , _pParamTypes( nullptr )
-        , _pParamInfos( nullptr )
         {}
-    virtual ~IdlInterfaceMethodImpl() override;
 
     // XInterface
     virtual Any SAL_CALL queryInterface( const Type & rType ) override;
@@ -365,13 +361,6 @@ public:
     virtual Any SAL_CALL invoke( const Any & rObj, Sequence< Any > & rArgs ) override;
 };
 
-IdlInterfaceMethodImpl::~IdlInterfaceMethodImpl()
-{
-    delete _pParamInfos;
-    delete _pParamTypes;
-    delete _pExceptionTypes;
-}
-
 // XInterface
 
 Any IdlInterfaceMethodImpl::queryInterface( const Type & rType )
@@ -452,8 +441,8 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
         if (! _pExceptionTypes)
         {
             sal_Int32 nExc = getMethodTypeDescr()->nExceptions;
-            Sequence< Reference< XIdlClass > > * pTempExceptionTypes =
-                new Sequence< Reference< XIdlClass > >( nExc );
+            std::unique_ptr<Sequence< Reference< XIdlClass > >> pTempExceptionTypes(
+                new Sequence< Reference< XIdlClass > >( nExc ));
             Reference< XIdlClass > * pExceptionTypes = pTempExceptionTypes->getArray();
 
             typelib_TypeDescriptionReference ** ppExc =
@@ -463,7 +452,7 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getExceptionTypes()
             while (nExc--)
                 pExceptionTypes[nExc] = pRefl->forType( ppExc[nExc] );
 
-            _pExceptionTypes = pTempExceptionTypes;
+            _pExceptionTypes = std::move(pTempExceptionTypes);
         }
     }
     return *_pExceptionTypes;
@@ -477,8 +466,8 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
         if (! _pParamTypes)
         {
             sal_Int32 nParams = getMethodTypeDescr()->nParams;
-            Sequence< Reference< XIdlClass > > * pTempParamTypes =
-                new Sequence< Reference< XIdlClass > >( nParams );
+            std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
+                new Sequence< Reference< XIdlClass > >( nParams ));
             Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
 
             typelib_MethodParameter * pTypelibParams =
@@ -488,7 +477,7 @@ Sequence< Reference< XIdlClass > > IdlInterfaceMethodImpl::getParameterTypes()
             while (nParams--)
                 pParamTypes[nParams] = pRefl->forType( pTypelibParams[nParams].pTypeRef );
 
-            _pParamTypes = pTempParamTypes;
+            _pParamTypes = std::move(pTempParamTypes);
         }
     }
     return *_pParamTypes;
@@ -502,7 +491,7 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
         if (! _pParamInfos)
         {
             sal_Int32 nParams = getMethodTypeDescr()->nParams;
-            Sequence< ParamInfo > * pTempParamInfos = new Sequence< ParamInfo >( nParams );
+            std::unique_ptr<Sequence< ParamInfo > > pTempParamInfos( new Sequence< ParamInfo >( nParams ) );
             ParamInfo * pParamInfos = pTempParamInfos->getArray();
 
             typelib_MethodParameter * pTypelibParams =
@@ -526,8 +515,8 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
             }
             else // make also param types sequence if not already initialized
             {
-                Sequence< Reference< XIdlClass > > * pTempParamTypes =
-                    new Sequence< Reference< XIdlClass > >( nParams );
+                std::unique_ptr<Sequence< Reference< XIdlClass > > > pTempParamTypes(
+                    new Sequence< Reference< XIdlClass > >( nParams ));
                 Reference< XIdlClass > * pParamTypes = pTempParamTypes->getArray();
 
                 IdlReflectionServiceImpl * pRefl = getReflection();
@@ -544,10 +533,10 @@ Sequence< ParamInfo > IdlInterfaceMethodImpl::getParameterInfos()
                     rInfo.aType = pParamTypes[nParams] = pRefl->forType( rParam.pTypeRef );
                 }
 
-                _pParamTypes = pTempParamTypes;
+                _pParamTypes = std::move(pTempParamTypes);
             }
 
-            _pParamInfos = pTempParamInfos;
+            _pParamInfos = std::move(pTempParamInfos);
         }
     }
     return *_pParamInfos;
@@ -759,8 +748,6 @@ InterfaceIdlClassImpl::~InterfaceIdlClassImpl()
 {
     for ( sal_Int32 nPos = _nMethods + _nAttributes; nPos--; )
         typelib_typedescription_release( _pSortedMemberInit[nPos].second );
-
-    delete [] _pSortedMemberInit;
 }
 
 
@@ -782,7 +769,7 @@ Sequence< Reference< XIdlClass > > InterfaceIdlClassImpl::getSuperclasses()
 void InterfaceIdlClassImpl::initMembers()
 {
     sal_Int32 nAll = getTypeDescr()->nAllMembers;
-    MemberInit * pSortedMemberInit = new MemberInit[nAll];
+    std::unique_ptr<MemberInit[]> pSortedMemberInit(new MemberInit[nAll]);
     typelib_TypeDescriptionReference ** ppAllMembers = getTypeDescr()->ppAllMembers;
 
     for ( sal_Int32 nPos = 0; nPos < nAll; ++nPos )
@@ -808,7 +795,7 @@ void InterfaceIdlClassImpl::initMembers()
         pSortedMemberInit[nIndex].second = pTD;
     }
 
-    _pSortedMemberInit = pSortedMemberInit;
+    _pSortedMemberInit = std::move(pSortedMemberInit);
 }
 
 sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & xType )
diff --git a/tools/source/inet/inetstrm.cxx b/tools/source/inet/inetstrm.cxx
index 7949b5f94108..4c3015bf6cd0 100644
--- a/tools/source/inet/inetstrm.cxx
+++ b/tools/source/inet/inetstrm.cxx
@@ -79,7 +79,7 @@ int INetMIMEMessageStream::GetBodyLine(sal_Char* pData, sal_uInt32 nSize)
     if (pSourceMsg->GetDocumentLB())
     {
         if (pMsgStrm == nullptr)
-            pMsgStrm = new SvStream (pSourceMsg->GetDocumentLB());
+            pMsgStrm.reset(new SvStream (pSourceMsg->GetDocumentLB()));
 
         sal_uInt32 nRead = pMsgStrm->ReadBytes(pWBuf, (pWEnd - pWBuf));
         pWBuf += nRead;
@@ -156,7 +156,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uInt32 nSize)
                         nChildIndex++;
 
                         // Create child stream.
-                        pChildStrm = new INetMIMEMessageStream(pChild, false);
+                        pChildStrm.reset(new INetMIMEMessageStream(pChild, false));
 
                         if (pSourceMsg->IsMultipart())
                         {
@@ -200,8 +200,7 @@ int INetMIMEMessageStream::GetMsgLine(sal_Char* pData, sal_uInt32 nSize)
                     else
                     {
                         // Cleanup exhausted child stream.
-                        delete pChildStrm;
-                        pChildStrm = nullptr;
+                        pChildStrm.reset();
                     }
                 }
             }
@@ -248,8 +247,7 @@ INetMIMEMessageStream::INetMIMEMessageStream(
 
 INetMIMEMessageStream::~INetMIMEMessageStream()
 {
-    delete pChildStrm;
-    delete pMsgStrm;
+    pChildStrm.reset();
 }
 
 int INetMIMEMessageStream::Read(sal_Char* pData, sal_uInt32 nSize)
diff --git a/tools/source/memtools/multisel.cxx b/tools/source/memtools/multisel.cxx
index d53ce8004e9c..b1dd66680ae6 100644
--- a/tools/source/memtools/multisel.cxx
+++ b/tools/source/memtools/multisel.cxx
@@ -26,10 +26,6 @@ void MultiSelection::ImplClear()
 {
     // no selected indexes
     nSelCount = 0;
-
-    for (Range* pSel : aSels) {
-        delete pSel;
-    }
     aSels.clear();
 }
 
@@ -38,7 +34,7 @@ sal_Int32 MultiSelection::ImplFindSubSelection( sal_Int32 nIndex ) const
     // iterate through the sub selections
     sal_Int32 n = 0;
     for ( ;
-          n < sal_Int32(aSels.size()) && nIndex > aSels[ n ]->Max();
+          n < sal_Int32(aSels.size()) && nIndex > aSels[ n ].Max();
           ++n ) {} /* empty loop */
     return n;
 }
@@ -50,14 +46,11 @@ void MultiSelection::ImplMergeSubSelections( sal_Int32 nPos1, sal_Int32 nPos2 )
         return;
 
     // did the sub selections touch each other?
-    if ( (aSels[ nPos1 ]->Max() + 1) == aSels[ nPos2 ]->Min() )
+    if ( (aSels[ nPos1 ].Max() + 1) == aSels[ nPos2 ].Min() )
     {
         // merge them
-        aSels[ nPos1 ]->Max() = aSels[ nPos2 ]->Max();
-        ImpSelList::iterator it = aSels.begin();
-        ::std::advance( it, nPos2 );
-        delete *it;
-        aSels.erase( it );
+        aSels[ nPos1 ].Max() = aSels[ nPos2 ].Max();
+        aSels.erase( aSels.begin() + nPos2 );
     }
 }
 
@@ -95,8 +88,8 @@ MultiSelection::MultiSelection( const MultiSelection& rOrig ) :
     }
 
     // copy the sub selections
-    for (const Range* pSel : rOrig.aSels)
-        aSels.push_back( new Range( *pSel ) );
+    for (const Range & rSel : rOrig.aSels)
+        aSels.push_back( rSel );
 }
 
 MultiSelection::MultiSelection( const Range& rRange ):
@@ -110,9 +103,6 @@ MultiSelection::MultiSelection( const Range& rRange ):
 
 MultiSelection::~MultiSelection()
 {
-    for (Range* pSel : aSels)
-        delete pSel;
-    aSels.clear();
 }
 
 MultiSelection& MultiSelection::operator= ( const MultiSelection& rOrig )
@@ -127,8 +117,8 @@ MultiSelection& MultiSelection::operator= ( const MultiSelection& rOrig )
 
     // clear the old and copy the sub selections
     ImplClear();
-    for (const Range* pSel : rOrig.aSels)
-        aSels.push_back( new Range( *pSel ) );
+    for (const Range& rSel : rOrig.aSels)
+        aSels.push_back( rSel );
     nSelCount = rOrig.nSelCount;
 
     return *this;
@@ -139,7 +129,7 @@ void MultiSelection::SelectAll( bool bSelect )
     ImplClear();
     if ( bSelect )
     {
-        aSels.push_back( new Range(aTotRange) );
+        aSels.push_back( aTotRange );
         nSelCount = aTotRange.Len();
     }
 }
@@ -158,7 +148,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
     if ( bSelect )
     {
         // is it included in the found sub selection?
-        if ( nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ]->IsInside( nIndex ) )
+        if ( nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ].IsInside( nIndex ) )
             // already selected, nothing to do
             return false;
 
@@ -167,29 +157,27 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
 
         // is it at the end of the previous sub selection
         if ( nSubSelPos > 0 &&
-             aSels[ nSubSelPos-1 ]->Max() == (nIndex-1) )
+             aSels[ nSubSelPos-1 ].Max() == (nIndex-1) )
         {
             // expand the previous sub selection
-            aSels[ nSubSelPos-1 ]->Max() = nIndex;
+            aSels[ nSubSelPos-1 ].Max() = nIndex;
 
             // try to merge the previous sub selection
             ImplMergeSubSelections( nSubSelPos-1, nSubSelPos );
         }
         // is it at the beginning of the found sub selection
         else if (  nSubSelPos < sal_Int32(aSels.size())
-                && aSels[ nSubSelPos ]->Min() == (nIndex+1)
+                && aSels[ nSubSelPos ].Min() == (nIndex+1)
         )
             // expand the found sub selection
-            aSels[ nSubSelPos ]->Min() = nIndex;
+            aSels[ nSubSelPos ].Min() = nIndex;
         else
         {
             // create a new sub selection
             if ( nSubSelPos < sal_Int32(aSels.size()) ) {
-                ImpSelList::iterator it = aSels.begin();
-                ::std::advance( it, nSubSelPos );
-                aSels.insert( it, new Range( nIndex, nIndex ) );
+                aSels.insert( aSels.begin() + nSubSelPos, Range( nIndex, nIndex ) );
             } else {
-                aSels.push_back( new Range( nIndex, nIndex ) );
+                aSels.push_back( Range( nIndex, nIndex ) );
             }
             if ( bCurValid && nCurSubSel >= nSubSelPos )
                 ++nCurSubSel;
@@ -199,7 +187,7 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
     {
         // is it excluded from the found sub selection?
         if (  nSubSelPos >= sal_Int32(aSels.size())
-           || !aSels[ nSubSelPos ]->IsInside( nIndex )
+           || !aSels[ nSubSelPos ].IsInside( nIndex )
         ) {
             // not selected, nothing to do
             return false;
@@ -209,34 +197,29 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
         --nSelCount;
 
         // is it the only index in the found sub selection?
-        if ( aSels[ nSubSelPos ]->Len() == 1 )
+        if ( aSels[ nSubSelPos ].Len() == 1 )
         {
             // remove the complete sub selection
-            ImpSelList::iterator it = aSels.begin();
-            ::std::advance( it, nSubSelPos );
-            delete *it;
-            aSels.erase( it );
+            aSels.erase( aSels.begin() + nSubSelPos );
             return true;
         }
 
         // is it at the beginning of the found sub selection?
-        if ( aSels[ nSubSelPos ]->Min() == nIndex )
-            ++aSels[ nSubSelPos ]->Min();
+        if ( aSels[ nSubSelPos ].Min() == nIndex )
+            ++aSels[ nSubSelPos ].Min();
         // is it at the end of the found sub selection?
-        else if ( aSels[ nSubSelPos ]->Max() == nIndex )
-            --aSels[ nSubSelPos ]->Max();
+        else if ( aSels[ nSubSelPos ].Max() == nIndex )
+            --aSels[ nSubSelPos ].Max();
         // it is in the middle of the found sub selection?
         else
         {
             // split the sub selection
             if ( nSubSelPos < sal_Int32(aSels.size()) ) {
-                ImpSelList::iterator it = aSels.begin();
-                ::std::advance( it, nSubSelPos );
-                aSels.insert( it, new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+                aSels.insert( aSels.begin() + nSubSelPos, Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
             } else {
-                aSels.push_back( new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+                aSels.push_back( Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
             }
-            aSels[ nSubSelPos+1 ]->Min() = nIndex + 1;
+            aSels[ nSubSelPos+1 ].Min() = nIndex + 1;
         }
     }
 
@@ -245,7 +228,6 @@ bool MultiSelection::Select( sal_Int32 nIndex, bool bSelect )
 
 void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
 {
-    Range* pRange;
     sal_Int32 nOld;
 
     sal_Int32 nTmpMin = rIndexRange.Min();
@@ -261,7 +243,7 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
         ImplClear();
         if ( bSelect )
         {
-            aSels.push_back( new Range(rIndexRange) );
+            aSels.push_back( rIndexRange );
             nSelCount = rIndexRange.Len();
         }
         return;
@@ -274,15 +256,14 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
             // extend first range?
             if( nCurMin > (nTmpMax+1)  )
             {
-                pRange = new Range( rIndexRange );
-                aSels.insert( aSels.begin() , pRange );
-                nSelCount += pRange->Len();
+                aSels.insert( aSels.begin(), rIndexRange );
+                nSelCount += rIndexRange.Len();
             }
             else
             {
-                pRange = aSels.front();
-                nOld = pRange->Min();
-                pRange->Min() = nTmpMin;
+                auto & rRange = aSels.front();
+                nOld = rRange.Min();
+                rRange.Min() = nTmpMin;
                 nSelCount += ( nOld - nTmpMin );
             }
             bCurValid = false;
@@ -297,15 +278,14 @@ void MultiSelection::Select( const Range& rIndexRange, bool bSelect )
             // extend last range?
             if( nTmpMin > (nCurMax+1) )
             {
-                pRange = new Range( rIndexRange );
-                aSels.push_back( pRange );
-                nSelCount += pRange->Len();
+                aSels.push_back( rIndexRange );
+                nSelCount += rIndexRange.Len();
             }
             else
             {
-                pRange = aSels.back();
-                nOld = pRange->Max();
-                pRange->Max() = nTmpMax;
+                auto & rRange = aSels.back();
+                nOld = rRange.Max();
+                rRange.Max() = nTmpMax;
                 nSelCount += ( nTmpMax - nOld );
             }
             bCurValid = false;
@@ -326,7 +306,7 @@ bool MultiSelection::IsSelected( sal_Int32 nIndex ) const
     // find the virtual target position
     sal_Int32 nSubSelPos = ImplFindSubSelection( nIndex );
 
-    return nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ]->IsInside(nIndex);
+    return nSubSelPos < sal_Int32(aSels.size()) && aSels[ nSubSelPos ].IsInside(nIndex);
 }
 
 void MultiSelection::Insert( sal_Int32 nIndex, sal_Int32 nCount )
@@ -337,25 +317,23 @@ void MultiSelection::Insert( sal_Int32 nIndex, sal_Int32 nCount )
     // did we need to shift the sub selections?
     if ( nSubSelPos < sal_Int32(aSels.size()) )
     {   // did we insert an unselected into an existing sub selection?
-        if (  aSels[ nSubSelPos ]->Min() != nIndex
-           && aSels[ nSubSelPos ]->IsInside(nIndex)
+        if (  aSels[ nSubSelPos ].Min() != nIndex
+           && aSels[ nSubSelPos ].IsInside(nIndex)
         ) { // split the sub selection
             if ( nSubSelPos < sal_Int32(aSels.size()) ) {
-                ImpSelList::iterator it = aSels.begin();
-                ::std::advance( it, nSubSelPos );
-                aSels.insert( it, new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+                aSels.insert( aSels.begin() + nSubSelPos, Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
             } else {
-                aSels.push_back( new Range( aSels[ nSubSelPos ]->Min(), nIndex-1 ) );
+                aSels.push_back( Range( aSels[ nSubSelPos ].Min(), nIndex-1 ) );
             }
             ++nSubSelPos;
-            aSels[ nSubSelPos ]->Min() = nIndex;
+            aSels[ nSubSelPos ].Min() = nIndex;
         }
 
         // shift the sub selections behind the inserting position
         for ( sal_Int32 nPos = nSubSelPos; nPos < sal_Int32(aSels.size()); ++nPos )
         {
-            aSels[ nPos ]->Min() += nCount;
-            aSels[ nPos ]->Max() += nCount;
+            aSels[ nPos ].Min() += nCount;
+            aSels[ nPos ].Max() += nCount;
         }
     }
 
@@ -370,18 +348,15 @@ void MultiSelection::Remove( sal_Int32 nIndex )
 
     // did we remove from an existing sub selection?
     if (  nSubSelPos < sal_Int32(aSels.size())
-       && aSels[ nSubSelPos ]->IsInside(nIndex)
+       && aSels[ nSubSelPos ].IsInside(nIndex)
     ) {
         // does this sub selection only contain the index to be deleted
-        if ( aSels[ nSubSelPos ]->Len() == 1 ) {
+        if ( aSels[ nSubSelPos ].Len() == 1 ) {
             // completely remove the sub selection
-            ImpSelList::iterator it = aSels.begin();
-            ::std::advance( it, nSubSelPos );
-            delete *it;
-            aSels.erase( it );
+            aSels.erase( aSels.begin() + nSubSelPos );
         } else {
             // shorten this sub selection
-            --( aSels[ nSubSelPos++ ]->Max() );
+            --( aSels[ nSubSelPos++ ].Max() );
         }
 
         // adjust the selected counter
@@ -391,8 +366,8 @@ void MultiSelection::Remove( sal_Int32 nIndex )
     // shift the sub selections behind the removed index
     for ( sal_Int32 nPos = nSubSelPos; nPos < sal_Int32(aSels.size()); ++nPos )
     {
-        --( aSels[ nPos ]->Min() );
-        --( aSels[ nPos ]->Max() );
+        --( aSels[ nPos ].Min() );
+        --( aSels[ nPos ].Max() );
     }
 
     bCurValid = false;
@@ -405,9 +380,9 @@ sal_Int32 MultiSelection::ImplFwdUnselected()
         return SFX_ENDOFSELECTION;
 
     if (  ( nCurSubSel < sal_Int32(aSels.size()) )
-       && ( aSels[ nCurSubSel ]->Min() <= nCurIndex )
+       && ( aSels[ nCurSubSel ].Min() <= nCurIndex )
     )
-        nCurIndex = aSels[ nCurSubSel++ ]->Max() + 1;
+        nCurIndex = aSels[ nCurSubSel++ ].Max() + 1;
 
     if ( nCurIndex <= aTotRange.Max() )
         return nCurIndex;
@@ -421,7 +396,7 @@ sal_Int32 MultiSelection::FirstSelected()
 
     bCurValid = !aSels.empty();
     if ( bCurValid )
-        return nCurIndex = aSels[ 0 ]->Min();
+        return nCurIndex = aSels[ 0 ].Min();
 
     return SFX_ENDOFSELECTION;
 }
@@ -432,7 +407,7 @@ sal_Int32 MultiSelection::LastSelected()
     bCurValid = !aSels.empty();
 
     if ( bCurValid )
-        return nCurIndex = aSels[ nCurSubSel ]->Max();
+        return nCurIndex = aSels[ nCurSubSel ].Max();
 
     return SFX_ENDOFSELECTION;
 }
@@ -443,12 +418,12 @@ sal_Int32 MultiSelection::NextSelected()
         return SFX_ENDOFSELECTION;
 
     // is the next index in the current sub selection too?
-    if ( nCurIndex < aSels[ nCurSubSel ]->Max() )
+    if ( nCurIndex < aSels[ nCurSubSel ].Max() )
         return ++nCurIndex;
 
     // are there further sub selections?
     if ( ++nCurSubSel < sal_Int32(aSels.size()) )
-        return nCurIndex = aSels[ nCurSubSel ]->Min();
+        return nCurIndex = aSels[ nCurSubSel ].Min();
 
     // we are at the end!
     return SFX_ENDOFSELECTION;
@@ -459,7 +434,7 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
     aTotRange = rTotRange;
 
     // adjust lower boundary
-    Range* pRange = aSels.empty() ? nullptr : aSels.front();
+    Range* pRange = aSels.empty() ? nullptr : &aSels.front();
     while( pRange )
     {
         if( pRange->Max() < aTotRange.Min() )
@@ -475,17 +450,16 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
         else
             break;
 
-        pRange = aSels.empty() ? nullptr : aSels.front();
+        pRange = aSels.empty() ? nullptr : &aSels.front();
     }
 
     // adjust upper boundary
     sal_Int32 nCount = aSels.size();
     while( nCount )
     {
-        pRange = aSels[ nCount - 1 ];
+        pRange = &aSels[ nCount - 1 ];
         if( pRange->Min() > aTotRange.Max() )
         {
-            delete pRange;
             aSels.pop_back();
         }
         else if( pRange->Max() > aTotRange.Max() )
@@ -501,8 +475,8 @@ void MultiSelection::SetTotalRange( const Range& rTotRange )
 
     // re-calculate selection count
     nSelCount = 0;
-    for (Range* pSel : aSels)
-        nSelCount += pSel->Len();
+    for (Range const & rSel : aSels)
+        nSelCount += rSel.Len();
 
     bCurValid = false;
     nCurIndex = 0;
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index 516cfd18a51a..c7d1e3f8414a 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -368,8 +368,6 @@ SvStream::~SvStream()
 {
     if (m_xLockBytes.is())
         Flush();
-
-    delete[] m_pRWBuf;
 }
 
 void SvStream::ClearError()
@@ -407,7 +405,7 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
 
     if (m_nBufSize)
     {
-        delete[] m_pRWBuf;
+        m_pRWBuf.reset();
         m_nBufFilePos += m_nBufActualPos;
     }
 
@@ -416,9 +414,9 @@ void SvStream::SetBufferSize( sal_uInt16 nBufferSize )
     m_nBufActualPos = 0;
     m_nBufSize      = nBufferSize;
     if (m_nBufSize)
-        m_pRWBuf = new sal_uInt8[ m_nBufSize ];
+        m_pRWBuf.reset(new sal_uInt8[ m_nBufSize ]);
     m_isConsistent  = true;
-    m_pBufPos       = m_pRWBuf;
+    m_pBufPos       = m_pRWBuf.get();
     m_isIoRead = m_isIoWrite = false;
     if( !bDontSeek )
         SeekPos( nActualFilePos );
@@ -429,7 +427,7 @@ void SvStream::ClearBuffer()
     m_nBufActualLen = 0;
     m_nBufActualPos = 0;
     m_nBufFilePos   = 0;
-    m_pBufPos       = m_pRWBuf;
+    m_pBufPos       = m_pRWBuf.get();
     m_isDirty       = false;
     m_isConsistent  = true;
     m_isIoRead = m_isIoWrite = false;
@@ -809,7 +807,7 @@ sal_uInt64 SvStream::SeekRel(sal_Int64 const nPos)
             nActualPos -= nAbsPos;
     }
 
-    m_pBufPos = m_pRWBuf + nActualPos;
+    m_pBufPos = m_pRWBuf.get() + nActualPos;
     return Seek( nActualPos );
 }
 
@@ -1225,8 +1223,8 @@ void SvStream::FlushBuffer(bool isConsistent)
     {
         SeekPos(m_nBufFilePos);
         if (m_nCryptMask)
-            CryptAndWriteBuffer(m_pRWBuf, m_nBufActualLen);
-        else if (PutData(m_pRWBuf, m_nBufActualLen) != m_nBufActualLen)
+            CryptAndWriteBuffer(m_pRWBuf.get(), m_nBufActualLen);
+        else if (PutData(m_pRWBuf.get(), m_nBufActualLen) != m_nBufActualLen)
             SetError(SVSTREAM_WRITE_ERROR);
         m_isDirty = false;
     }
@@ -1273,7 +1271,7 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
 
                 SeekPos(m_nBufFilePos + m_nBufActualPos);
                 m_nBufActualLen = 0;
-                m_pBufPos     = m_pRWBuf;
+                m_pBufPos     = m_pRWBuf.get();
                 nCount = GetData( pData, nCount );
                 if (m_nCryptMask)
                     EncryptBuffer(pData, nCount);
@@ -1289,17 +1287,17 @@ std::size_t SvStream::ReadBytes( void* pData, std::size_t nCount )
                 SeekPos(m_nBufFilePos);
 
                 // TODO: Typecast before GetData, sal_uInt16 nCountTmp
-                std::size_t nCountTmp = GetData( m_pRWBuf, m_nBufSize );
+                std::size_t nCountTmp = GetData( m_pRWBuf.get(), m_nBufSize );
                 if (m_nCryptMask)
-                    EncryptBuffer(m_pRWBuf, nCountTmp);
+                    EncryptBuffer(m_pRWBuf.get(), nCountTmp);
                 m_nBufActualLen = (sal_uInt16)nCountTmp;
                 if( nCount > nCountTmp )
                 {
                     nCount = nCountTmp;  // trim count back, EOF see below
                 }
-                memcpy( pData, m_pRWBuf, (size_t)nCount );
+                memcpy( pData, m_pRWBuf.get(), (size_t)nCount );
                 m_nBufActualPos = (sal_uInt16)nCount;
-                m_pBufPos = m_pRWBuf + nCount;
+                m_pBufPos = m_pRWBuf.get() + nCount;
             }
         }
     }
@@ -1359,7 +1357,7 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
             m_nBufFilePos += m_nBufActualPos;
             m_nBufActualLen = 0;
             m_nBufActualPos = 0;
-            m_pBufPos     = m_pRWBuf;
+            m_pBufPos     = m_pRWBuf.get();
             SeekPos(m_nBufFilePos);
             if (m_nCryptMask)
                 nCount = CryptAndWriteBuffer( pData, nCount );
@@ -1370,12 +1368,12 @@ std::size_t SvStream::WriteBytes( const void* pData, std::size_t nCount )
         else
         {
             // Copy block to buffer
-            memcpy( m_pRWBuf, pData, (size_t)nCount );
+            memcpy( m_pRWBuf.get(), pData, (size_t)nCount );
 
             // Mind the order!
             m_nBufFilePos += m_nBufActualPos;
             m_nBufActualPos = (sal_uInt16)nCount;
-            m_pBufPos = m_pRWBuf + nCount;
+            m_pBufPos = m_pRWBuf.get() + nCount;
             m_nBufActualLen = (sal_uInt16)nCount;
             m_isDirty = true;
         }
@@ -1399,7 +1397,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
     if (nFilePos >= m_nBufFilePos && nFilePos <= (m_nBufFilePos + m_nBufActualLen))
     {
         m_nBufActualPos = (sal_uInt16)(nFilePos - m_nBufFilePos);
-        m_pBufPos = m_pRWBuf + m_nBufActualPos;
+        m_pBufPos = m_pRWBuf.get() + m_nBufActualPos;
         // Update m_nBufFree to avoid crash upon PutBack
         m_nBufFree = m_nBufActualLen - m_nBufActualPos;
     }
@@ -1408,7 +1406,7 @@ sal_uInt64 SvStream::Seek(sal_uInt64 const nFilePos)
         FlushBuffer(m_isConsistent);
         m_nBufActualLen = 0;
         m_nBufActualPos = 0;
-        m_pBufPos     = m_pRWBuf;
+        m_pBufPos     = m_pRWBuf.get();
         m_nBufFilePos = SeekPos( nFilePos );
     }
     return m_nBufFilePos + m_nBufActualPos;
@@ -1443,11 +1441,11 @@ void SvStream::RefreshBuffer()
 {
     FlushBuffer(m_isConsistent);
     SeekPos(m_nBufFilePos);
-    m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf, m_nBufSize );
+    m_nBufActualLen = (sal_uInt16)GetData( m_pRWBuf.get(), m_nBufSize );
     if (m_nBufActualLen && m_nError == ERRCODE_IO_PENDING)
         m_nError = ERRCODE_NONE;
     if (m_nCryptMask)
-        EncryptBuffer(m_pRWBuf, (std::size_t)m_nBufActualLen);
+        EncryptBuffer(m_pRWBuf.get(), (std::size_t)m_nBufActualLen);
     m_isConsistent = true;
     m_isIoRead = m_isIoWrite = false;
 }
diff --git a/tools/source/stream/strmunx.cxx b/tools/source/stream/strmunx.cxx
index d3f79e6c3712..d06544e72031 100644
--- a/tools/source/stream/strmunx.cxx
+++ b/tools/source/stream/strmunx.cxx
@@ -273,7 +273,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nOpenMode )
 {
     bIsOpen             = false;
     m_isWritable        = false;
-    pInstanceData       = new StreamData;
+    pInstanceData.reset(new StreamData);
 
     SetBufferSize( 1024 );
     // convert URL to SystemPath, if necessary
@@ -290,15 +290,13 @@ SvFileStream::SvFileStream()
 {
     bIsOpen             = false;
     m_isWritable        = false;
-    pInstanceData       = new StreamData;
+    pInstanceData.reset(new StreamData);
     SetBufferSize( 1024 );
 }
 
 SvFileStream::~SvFileStream()
 {
     Close();
-
-    delete pInstanceData;
 }
 
 std::size_t SvFileStream::GetData( void* pData, std::size_t nSize )
diff --git a/tools/source/stream/strmwnt.cxx b/tools/source/stream/strmwnt.cxx
index 8a626ecc7c76..3b890fbfef1b 100644
--- a/tools/source/stream/strmwnt.cxx
+++ b/tools/source/stream/strmwnt.cxx
@@ -109,7 +109,7 @@ SvFileStream::SvFileStream( const OUString& rFileName, StreamMode nMode )
     bIsOpen             = false;
     nLockCounter        = 0;
     m_isWritable        = false;
-    pInstanceData       = new StreamData;
+    pInstanceData.reset( new StreamData );
 
     SetBufferSize( 8192 );
     // convert URL to SystemPath, if necessary
@@ -125,7 +125,7 @@ SvFileStream::SvFileStream()
     bIsOpen             = false;
     nLockCounter        = 0;
     m_isWritable        = false;
-    pInstanceData       = new StreamData;
+    pInstanceData.reset( new StreamData );
 
     SetBufferSize( 8192 );
 }
@@ -133,7 +133,6 @@ SvFileStream::SvFileStream()
 SvFileStream::~SvFileStream()
 {
     Close();
-    delete pInstanceData;
 }
 
 /// Does not check for EOF, makes isEof callable
diff --git a/unotools/source/i18n/intlwrapper.cxx b/unotools/source/i18n/intlwrapper.cxx
index 63e47c71aed4..901f74394334 100644
--- a/unotools/source/i18n/intlwrapper.cxx
+++ b/unotools/source/i18n/intlwrapper.cxx
@@ -35,14 +35,11 @@ IntlWrapper::IntlWrapper(
 
 IntlWrapper::~IntlWrapper()
 {
-    delete pLocaleData;
-    delete pCollator;
-    delete pCaseCollator;
 }
 
 void IntlWrapper::ImplNewLocaleData() const
 {
-    const_cast<IntlWrapper*>(this)->pLocaleData = new LocaleDataWrapper( m_xContext, maLanguageTag );
+    const_cast<IntlWrapper*>(this)->pLocaleData.reset( new LocaleDataWrapper( m_xContext, maLanguageTag ) );
 }
 
 void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const
@@ -51,13 +48,13 @@ void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const
     if ( bCaseSensitive )
     {
         p->loadDefaultCollator( maLanguageTag.getLocale(), 0 );
-        const_cast<IntlWrapper*>(this)->pCaseCollator = p;
+        const_cast<IntlWrapper*>(this)->pCaseCollator.reset(p);
     }
     else
     {
         p->loadDefaultCollator( maLanguageTag.getLocale(),
                 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
-        const_cast<IntlWrapper*>(this)->pCollator = p;
+        const_cast<IntlWrapper*>(this)->pCollator.reset(p);
     }
 }
 
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index 951ac9e3b4aa..017ec3b9c52c 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -32,6 +32,7 @@
 #include <osl/nlsupport.h>
 
 #include <vector>
+#include <memory>
 
 using namespace osl;
 using namespace com::sun::star;
@@ -45,9 +46,9 @@ std::weak_ptr<SvtSysLocale_Impl> g_pSysLocale;
 class SvtSysLocale_Impl : public utl::ConfigurationListener
 {
 public:
-        SvtSysLocaleOptions     aSysLocaleOptions;
-        LocaleDataWrapper*      pLocaleData;
-        CharClass*              pCharClass;
+        SvtSysLocaleOptions                    aSysLocaleOptions;
+        std::unique_ptr<LocaleDataWrapper>      pLocaleData;
+        std::unique_ptr<CharClass>              pCharClass;
 
                                 SvtSysLocale_Impl();
     virtual                     ~SvtSysLocale_Impl() override;
@@ -61,7 +62,7 @@ private:
 
 SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(nullptr)
 {
-    pLocaleData = new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() );
+    pLocaleData.reset(new LocaleDataWrapper( aSysLocaleOptions.GetRealLanguageTag() ));
     setDateAcceptancePatternsConfig();
 
     // listen for further changes
@@ -71,15 +72,13 @@ SvtSysLocale_Impl::SvtSysLocale_Impl() : pCharClass(nullptr)
 SvtSysLocale_Impl::~SvtSysLocale_Impl()
 {
     aSysLocaleOptions.RemoveListener( this );
-    delete pCharClass;
-    delete pLocaleData;
 }
 
 CharClass* SvtSysLocale_Impl::GetCharClass()
 {
     if ( !pCharClass )
-        pCharClass = new CharClass( aSysLocaleOptions.GetRealLanguageTag() );
-    return pCharClass;
+        pCharClass.reset(new CharClass( aSysLocaleOptions.GetRealLanguageTag() ));
+    return pCharClass.get();
 }
 
 void SvtSysLocale_Impl::ConfigurationChanged( utl::ConfigurationBroadcaster*, ConfigurationHints nHint )
@@ -151,7 +150,7 @@ const LocaleDataWrapper& SvtSysLocale::GetLocaleData() const
 
 const LocaleDataWrapper* SvtSysLocale::GetLocaleDataPtr() const
 {
-    return pImpl->pLocaleData;
+    return pImpl->pLocaleData.get();
 }
 
 const CharClass& SvtSysLocale::GetCharClass() const
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index 47afc2ed82ce..9d4c717ed3ae 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -373,16 +373,15 @@ TempFile::TempFile( const OUString& rLeadingChars, bool _bStartWithZero,
 }
 
 TempFile::TempFile(TempFile && other):
-    aName(std::move(other.aName)), pStream(other.pStream), bIsDirectory(other.bIsDirectory),
+    aName(std::move(other.aName)), pStream(std::move(other.pStream)), bIsDirectory(other.bIsDirectory),
     bKillingFileEnabled(other.bKillingFileEnabled)
 {
-    other.pStream = nullptr;
     other.bKillingFileEnabled = false;
 }
 
 TempFile::~TempFile()
 {
-    delete pStream;
+    pStream.reset();
     if ( bKillingFileEnabled )
     {
         if ( bIsDirectory )
@@ -420,21 +419,17 @@ SvStream* TempFile::GetStream( StreamMode eMode )
     if (!pStream)
     {
         if (!aName.isEmpty())
-            pStream = new SvFileStream(aName, eMode);
+            pStream.reset(new SvFileStream(aName, eMode));
         else
-            pStream = new SvMemoryStream(nullptr, 0, eMode);
+            pStream.reset(new SvMemoryStream(nullptr, 0, eMode));
     }
 
-    return pStream;
+    return pStream.get();
 }
 
 void TempFile::CloseStream()
 {
-    if ( pStream )
-    {
-        delete pStream;
-        pStream = nullptr;
-    }
+    pStream.reset();
 }
 
 OUString TempFile::SetTempNameBaseDirectory( const OUString &rBaseName )


More information about the Libreoffice-commits mailing list