[Libreoffice-commits] core.git: sc/inc sc/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Jan 13 11:39:43 UTC 2017


 sc/inc/addincol.hxx                 |    5 +++--
 sc/inc/appoptio.hxx                 |    7 ++++---
 sc/inc/attrib.hxx                   |    2 +-
 sc/inc/chartpos.hxx                 |   15 ++++-----------
 sc/inc/chgviset.hxx                 |    3 ++-
 sc/inc/dociter.hxx                  |    9 ++++++---
 sc/inc/dpgroup.hxx                  |    3 ++-
 sc/inc/dpresfilter.hxx              |    2 +-
 sc/inc/dpsave.hxx                   |    4 ++--
 sc/inc/dptabres.hxx                 |   15 ++++++++-------
 sc/inc/dptabsrc.hxx                 |    3 ++-
 sc/inc/editutil.hxx                 |    2 +-
 sc/inc/markarr.hxx                  |    7 ++++---
 sc/inc/paramisc.hxx                 |    8 ++++----
 sc/inc/patattr.hxx                  |    7 ++++---
 sc/inc/prnsave.hxx                  |    5 +++--
 sc/inc/rangenam.hxx                 |    7 ++++---
 sc/source/core/data/attrib.cxx      |   11 +++--------
 sc/source/core/data/dociter.cxx     |   26 +++++++++-----------------
 sc/source/core/data/dpgroup.cxx     |    3 +--
 sc/source/core/data/dpresfilter.cxx |    8 +++-----
 sc/source/core/data/dpsave.cxx      |   14 +++++---------
 sc/source/core/data/dptabres.cxx    |   10 ++++------
 sc/source/core/data/dptabsrc.cxx    |    8 +++-----
 sc/source/core/data/global2.cxx     |    7 ++-----
 sc/source/core/data/markarr.cxx     |   27 ++++++++++-----------------
 sc/source/core/data/patattr.cxx     |   17 +++++++----------
 sc/source/core/inc/addinlis.hxx     |    2 +-
 sc/source/core/tool/addincol.cxx    |   11 +++--------
 sc/source/core/tool/addinlis.cxx    |    7 +++----
 sc/source/core/tool/appoptio.cxx    |   12 ++++--------
 sc/source/core/tool/callform.cxx    |    6 +++---
 sc/source/core/tool/chartpos.cxx    |   16 ++++++++++------
 sc/source/core/tool/chgviset.cxx    |    9 ++-------
 sc/source/core/tool/editutil.cxx    |    5 ++---
 sc/source/core/tool/prnsave.cxx     |    5 +----
 sc/source/core/tool/rangenam.cxx    |    9 +++------
 37 files changed, 134 insertions(+), 183 deletions(-)

New commits:
commit 414ede0435645a2ebf8f1476435b6ec3bb248f33
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 11 14:05:10 2017 +0200

    new loplugin: useuniqueptr: sc part 1
    
    Change-Id: Ic96fd3b56b2063df0882168a7d02725d3c50515f
    Reviewed-on: https://gerrit.libreoffice.org/32961
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 49d30b6..7915015 100644
--- a/sc/inc/addincol.hxx
+++ b/sc/inc/addincol.hxx
@@ -88,7 +88,8 @@ private:
     css::uno::Reference< css::reflection::XIdlMethod> xFunction;
     css::uno::Any       aObject;
     long                nArgCount;
-    ScAddInArgDesc*     pArgDescs;
+    std::unique_ptr<ScAddInArgDesc[]>
+                        pArgDescs;
     long                nCallerPos;
     sal_uInt16          nCategory;
     OString             sHelpId;
@@ -113,7 +114,7 @@ public:
                                                         { return xFunction; }
     const css::uno::Any& GetObject() const   { return aObject; }
     long                    GetArgumentCount() const    { return nArgCount; }
-    const ScAddInArgDesc*   GetArguments() const        { return pArgDescs; }
+    const ScAddInArgDesc*   GetArguments() const        { return pArgDescs.get(); }
     long                    GetCallerPos() const        { return nCallerPos; }
     const OUString&         GetDescription() const      { return aDescription; }
     sal_uInt16              GetCategory() const         { return nCategory; }
diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 5bc668a..d3d6f5b 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -45,8 +45,8 @@ public:
     SvxZoomType GetZoomType() const             { return eZoomType;     }
     void        SetSynchronizeZoom( bool bNew ) { bSynchronizeZoom = bNew; }
     bool        GetSynchronizeZoom() const      { return bSynchronizeZoom; }
-    sal_uInt16      GetLRUFuncListCount() const     { return nLRUFuncCount; }
-    sal_uInt16*     GetLRUFuncList() const          { return pLRUList;      }
+    sal_uInt16  GetLRUFuncListCount() const     { return nLRUFuncCount; }
+    sal_uInt16* GetLRUFuncList() const          { return pLRUList.get();      }
     void        SetLRUFuncList( const sal_uInt16* pList,
                                 const sal_uInt16  nCount );
     void        SetStatusFunc( sal_uInt32 nNew )    { nStatusFunc = nNew;   }
@@ -83,7 +83,8 @@ public:
 private:
     FieldUnit       eMetric;
     sal_uInt16      nLRUFuncCount;
-    sal_uInt16*     pLRUList;
+    std::unique_ptr<sal_uInt16[]>
+                    pLRUList;
     SvxZoomType     eZoomType;
     sal_uInt16      nZoom;
     bool            bSynchronizeZoom;
diff --git a/sc/inc/attrib.hxx b/sc/inc/attrib.hxx
index 3b71b8c..83235ac 100644
--- a/sc/inc/attrib.hxx
+++ b/sc/inc/attrib.hxx
@@ -214,7 +214,7 @@ public:
 
 public:
     sal_uInt16  nCount;
-    SCTAB*  pTabArr;
+    std::unique_ptr<SCTAB[]>  pTabArr;
 };
 
 inline ScTableListItem::ScTableListItem( const sal_uInt16 nWhichP )
diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx
index 18c40ae..664cbc9 100644
--- a/sc/inc/chartpos.hxx
+++ b/sc/inc/chartpos.hxx
@@ -46,12 +46,13 @@ class ScChartPositionMap
                                     SCROW nRowAdd,      // header rows
                                     ColumnMap& rCols        // table with col tables with address*
                                     );
-                                ~ScChartPositionMap();  //! deletes all ScAddress*
 
                                 ScChartPositionMap( const ScChartPositionMap& ) = delete;
             ScChartPositionMap& operator=( const ScChartPositionMap& ) = delete;
 
 public:
+                                ~ScChartPositionMap();  //! deletes all ScAddress*
+
             SCCOL               GetColCount() const { return nColCount; }
             SCROW               GetRowCount() const { return nRowCount; }
 
@@ -103,7 +104,7 @@ class ScChartPositioner final             // only parameter struct
 {
     ScRangeListRef  aRangeListRef;
     ScDocument* pDocument;
-    ScChartPositionMap* pPositionMap;
+    std::unique_ptr<ScChartPositionMap> pPositionMap;
     ScChartGlue eGlue;
     SCCOL       nStartCol;
     SCROW       nStartRow;
@@ -132,15 +133,7 @@ public:
     bool    HasColHeaders() const            { return bColHeaders; }
     bool    HasRowHeaders() const            { return bRowHeaders; }
 
-    void                    InvalidateGlue()
-                                {
-                                    eGlue = SC_CHARTGLUE_NA;
-                                    if ( pPositionMap )
-                                    {
-                                        delete pPositionMap;
-                                        pPositionMap = nullptr;
-                                    }
-                                }
+    void                        InvalidateGlue();
     const ScChartPositionMap*   GetPositionMap();
 };
 
diff --git a/sc/inc/chgviset.hxx b/sc/inc/chgviset.hxx
index ee61570..68e144d 100644
--- a/sc/inc/chgviset.hxx
+++ b/sc/inc/chgviset.hxx
@@ -34,7 +34,8 @@ class SC_DLLPUBLIC ScChangeViewSettings
 {
 private:
 
-    utl::TextSearch*    pCommentSearcher;
+    std::unique_ptr<utl::TextSearch>
+                        pCommentSearcher;
     DateTime            aFirstDateTime;
     DateTime            aLastDateTime;
     OUString            aAuthorToShow;
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index f314278..04d04b6 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -370,7 +370,8 @@ private:
     SCROW           nStartRow;
     SCROW           nEndRow;
     SCCOL           nCol;
-    ScAttrIterator* pColIter;
+    std::unique_ptr<ScAttrIterator>
+                    pColIter;
 
 public:
                     ScDocAttrIterator(ScDocument* pDocument, SCTAB nTable,
@@ -391,7 +392,8 @@ private:
     SCROW           nEndRow;
     SCCOL           nIterStartCol;
     SCCOL           nIterEndCol;
-    ScAttrIterator* pColIter;
+    std::unique_ptr<ScAttrIterator>
+                    pColIter;
 
 public:
                     ScAttrRectIterator(ScDocument* pDocument, SCTAB nTable,
@@ -450,7 +452,8 @@ class ScHorizontalValueIterator
 private:
     ScDocument               *pDoc;
     const ScAttrArray        *pAttrArray;
-    ScHorizontalCellIterator *pCellIter;
+    std::unique_ptr<ScHorizontalCellIterator>
+                              pCellIter;
     sal_uLong                 nNumFormat;     // for CalcAsShown
     SCTAB                     nEndTab;
     SCCOL                     nCurCol;
diff --git a/sc/inc/dpgroup.hxx b/sc/inc/dpgroup.hxx
index e45f3f4..1eddcf9 100644
--- a/sc/inc/dpgroup.hxx
+++ b/sc/inc/dpgroup.hxx
@@ -124,7 +124,8 @@ class ScDPGroupTableData : public ScDPTableData
     std::shared_ptr<ScDPTableData> pSourceData;
     long                    nSourceCount;
     ScDPGroupDimensionVec   aGroups;
-    ScDPNumGroupDimension*  pNumGroups;     // array[nSourceCount]
+    std::unique_ptr<ScDPNumGroupDimension[]>
+                            pNumGroups;     // array[nSourceCount]
     ScDocument*             pDoc;
     StringHashSet           aGroupNames;
 
diff --git a/sc/inc/dpresfilter.hxx b/sc/inc/dpresfilter.hxx
index 82c2862..0ab75d4 100644
--- a/sc/inc/dpresfilter.hxx
+++ b/sc/inc/dpresfilter.hxx
@@ -99,7 +99,7 @@ private:
     LeafValuesType maLeafValues;
 
     OUString maPrimaryDimName;
-    MemberNode* mpRoot;
+    std::unique_ptr<MemberNode> mpRoot;
 
 public:
 
diff --git a/sc/inc/dpsave.hxx b/sc/inc/dpsave.hxx
index 663bcb2..8338e0e 100644
--- a/sc/inc/dpsave.hxx
+++ b/sc/inc/dpsave.hxx
@@ -241,7 +241,7 @@ public:
 private:
     DimsType m_DimList;
     DupNameCountType maDupNameCounts; /// keep track of number of duplicates in each name.
-    ScDPDimensionSaveData* pDimensionData; // settings that create new dimensions
+    std::unique_ptr<ScDPDimensionSaveData> pDimensionData; // settings that create new dimensions
     sal_uInt16 nColumnGrandMode;
     sal_uInt16 nRowGrandMode;
     sal_uInt16 nIgnoreEmptyMode;
@@ -347,7 +347,7 @@ public:
     bool IsEmpty() const;
 
     const ScDPDimensionSaveData* GetExistingDimensionData() const
-        { return pDimensionData; }
+        { return pDimensionData.get(); }
 
     void RemoveAllGroupDimensions( const OUString& rSrcDimName, std::vector<OUString>* pDeletedNames = nullptr );
 
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 65dbf5d..7b6e7d1 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -159,12 +159,12 @@ private:
     double          fVal;
     double          fAux;
     long            nCount;
-    ScDPAggData*    pChild;
+    std::unique_ptr<ScDPAggData> pChild;
     std::vector<double> mSortedValues;
 
 public:
             ScDPAggData() : fVal(0.0), fAux(0.0), nCount(SC_DPAGG_EMPTY), pChild(nullptr) {}
-            ~ScDPAggData() { delete pChild; }
+            ~ScDPAggData() {}
 
     void    Update( const ScDPValue& rNext, ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
     void    Calculate( ScSubTotalFunc eFunc, const ScDPSubTotalState& rSubState );
@@ -183,7 +183,7 @@ public:
 
     void    Reset();        // also deletes children
 
-    const ScDPAggData*  GetExistingChild() const    { return pChild; }
+    const ScDPAggData*  GetExistingChild() const    { return pChild.get(); }
     ScDPAggData*        GetChild();
 
 #if DUMP_PIVOT_TABLE
@@ -437,8 +437,9 @@ class ScDPDataMember
 private:
     const ScDPResultData*       pResultData;
     const ScDPResultMember*     pResultMember;          //! Ref?
-    ScDPDataDimension*      pChildDimension;
-    ScDPAggData             aAggregate;
+    std::unique_ptr<ScDPDataDimension>
+                                pChildDimension;
+    ScDPAggData                 aAggregate;
 
     void                UpdateValues( const ::std::vector<ScDPValue>& aValues, const ScDPSubTotalState& rSubState );
 
@@ -486,8 +487,8 @@ public:
 #endif
 
                         //! this will be removed!
-    const ScDPDataDimension*    GetChildDimension() const   { return pChildDimension; }
-    ScDPDataDimension*          GetChildDimension()         { return pChildDimension; }
+    const ScDPDataDimension*    GetChildDimension() const   { return pChildDimension.get(); }
+    ScDPDataDimension*          GetChildDimension()         { return pChildDimension.get(); }
 };
 
 typedef std::vector<ScDPDataMember*> ScDPDataMembers;
diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx
index 48c0714..26e949a 100644
--- a/sc/inc/dptabsrc.hxx
+++ b/sc/inc/dptabsrc.hxx
@@ -315,7 +315,8 @@ class ScDPDimension : public cppu::WeakImplHelper<
                         aReferenceValue;    // settings for "show data as" / "displayed value"
     bool                bHasSelectedPage;
     OUString            aSelectedPage;
-    ScDPItemData*       pSelectedData;      // internal, temporary, created from aSelectedPage
+    std::unique_ptr<ScDPItemData>
+                        pSelectedData;      // internal, temporary, created from aSelectedPage
     bool                mbHasHiddenMember;
 
 public:
diff --git a/sc/inc/editutil.hxx b/sc/inc/editutil.hxx
index e71976e..00f0029 100644
--- a/sc/inc/editutil.hxx
+++ b/sc/inc/editutil.hxx
@@ -88,7 +88,7 @@ public:
 class ScEditAttrTester
 {
     ScEditEngineDefaulter* pEngine;
-    SfxItemSet* pEditAttrs;
+    std::unique_ptr<SfxItemSet> pEditAttrs;
     bool        bNeedsObject;
     bool        bNeedsCellAttr;
 
diff --git a/sc/inc/markarr.hxx b/sc/inc/markarr.hxx
index 0fd826c..a88dd76 100644
--- a/sc/inc/markarr.hxx
+++ b/sc/inc/markarr.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_INC_MARKARR_HXX
 
 #include "address.hxx"
+#include <memory>
 
 #define SC_MARKARRAY_DELTA    4
 
@@ -32,9 +33,9 @@ struct ScMarkEntry
 
 class ScMarkArray
 {
-    SCSIZE          nCount;
-    SCSIZE          nLimit;
-    ScMarkEntry*    pData;
+    SCSIZE                            nCount;
+    SCSIZE                            nLimit;
+    std::unique_ptr<ScMarkEntry[]>    pData;
 
 friend class ScMarkArrayIter;
 friend class ScDocument;                // for FillInfo
diff --git a/sc/inc/paramisc.hxx b/sc/inc/paramisc.hxx
index 0a21a1d..5853051 100644
--- a/sc/inc/paramisc.hxx
+++ b/sc/inc/paramisc.hxx
@@ -25,9 +25,9 @@
 
 struct ScSolveParam
 {
-    ScAddress   aRefFormulaCell;
-    ScAddress   aRefVariableCell;
-    OUString*   pStrTargetVal;
+    ScAddress                   aRefFormulaCell;
+    ScAddress                   aRefVariableCell;
+    std::unique_ptr<OUString>   pStrTargetVal;
 
     ScSolveParam();
     ScSolveParam( const ScSolveParam& r );
@@ -36,7 +36,7 @@ struct ScSolveParam
                   const OUString& rTargetValStr );
     ~ScSolveParam();
 
-    ScSolveParam&   operator=   ( const ScSolveParam& r );
+    ScSolveParam&  operator=   ( const ScSolveParam& r );
     bool           operator==  ( const ScSolveParam& r ) const;
 };
 
diff --git a/sc/inc/patattr.hxx b/sc/inc/patattr.hxx
index 3f75827..05bfc92 100644
--- a/sc/inc/patattr.hxx
+++ b/sc/inc/patattr.hxx
@@ -27,6 +27,7 @@
 #include <editeng/svxenum.hxx>
 #include "scdllapi.h"
 #include "fonthelper.hxx"
+#include <memory>
 
 namespace vcl { class Font; }
 class OutputDevice;
@@ -51,9 +52,9 @@ enum ScAutoFontColorMode
 
 class SC_DLLPUBLIC ScPatternAttr: public SfxSetItem
 {
-    OUString*       pName;
-    ScStyleSheet*   pStyle;
-    sal_uInt64      mnKey;
+    std::unique_ptr<OUString>  pName;
+    ScStyleSheet*              pStyle;
+    sal_uInt64                 mnKey;
 public:
                             ScPatternAttr(SfxItemSet* pItemSet, const OUString& rStyleName);
                             ScPatternAttr(SfxItemSet* pItemSet);
diff --git a/sc/inc/prnsave.hxx b/sc/inc/prnsave.hxx
index 9bdbc28..463a424 100644
--- a/sc/inc/prnsave.hxx
+++ b/sc/inc/prnsave.hxx
@@ -22,6 +22,7 @@
 
 #include "address.hxx"
 #include <vector>
+#include <memory>
 
 class ScRange;
 
@@ -51,8 +52,8 @@ public:
 
 class ScPrintRangeSaver
 {
-    SCTAB               nTabCount;
-    ScPrintSaverTab*    pData;      ///< Array
+    SCTAB                               nTabCount;
+    std::unique_ptr<ScPrintSaverTab[]>  pData;
 
 public:
             ScPrintRangeSaver( SCTAB nCount );
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index a1924de..19c288b 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -63,7 +63,8 @@ private:
     OUString        aName;
     OUString        aUpperName; // #i62977# for faster searching (aName is never modified after ctor)
     OUString        maNewName;  ///< used for formulas after changing names in the dialog
-    ScTokenArray*   pCode;
+    std::unique_ptr<ScTokenArray>
+                    pCode;
     ScAddress       aPos;
     Type            eType;
     ScDocument*     pDoc;
@@ -116,9 +117,9 @@ public:
     sal_uInt16      GetIndex() const                { return nIndex; }
     /// Does not change the name, but sets maNewName for formula update after dialog.
     void            SetNewName( const OUString& rNewName )  { maNewName = rNewName; }
-    ScTokenArray*   GetCode()                       { return pCode; }
+    ScTokenArray*   GetCode()                       { return pCode.get(); }
     SC_DLLPUBLIC void   SetCode( ScTokenArray& );
-    const ScTokenArray* GetCode() const             { return pCode; }
+    const ScTokenArray* GetCode() const             { return pCode.get(); }
     SC_DLLPUBLIC FormulaError GetErrCode() const;
     bool            HasReferences() const;
     void            AddType( Type nType );
diff --git a/sc/source/core/data/attrib.cxx b/sc/source/core/data/attrib.cxx
index 9da8293..65a8b58 100644
--- a/sc/source/core/data/attrib.cxx
+++ b/sc/source/core/data/attrib.cxx
@@ -440,32 +440,27 @@ ScTableListItem::ScTableListItem( const ScTableListItem& rCpy )
 {
     if ( nCount > 0 )
     {
-        pTabArr = new SCTAB [nCount];
+        pTabArr.reset( new SCTAB [nCount] );
 
         for ( sal_uInt16 i=0; i<nCount; i++ )
             pTabArr[i] = rCpy.pTabArr[i];
     }
-    else
-        pTabArr = nullptr;
 }
 
 ScTableListItem::~ScTableListItem()
 {
-    delete [] pTabArr;
 }
 
 ScTableListItem& ScTableListItem::operator=( const ScTableListItem& rCpy )
 {
-    delete [] pTabArr;
-
     if ( rCpy.nCount > 0 )
     {
-        pTabArr = new SCTAB [rCpy.nCount];
+        pTabArr.reset( new SCTAB [rCpy.nCount] );
         for ( sal_uInt16 i=0; i<rCpy.nCount; i++ )
             pTabArr[i] = rCpy.pTabArr[i];
     }
     else
-        pTabArr = nullptr;
+        pTabArr.reset();
 
     nCount = rCpy.nCount;
 
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 6f3467f..f773937 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2190,13 +2190,12 @@ ScHorizontalValueIterator::ScHorizontalValueIterator( ScDocument* pDocument,
     pAttrArray = nullptr;
     nAttrEndRow = 0;
 
-    pCellIter = new ScHorizontalCellIterator( pDoc, nStartTab, nStartCol,
-            nStartRow, nEndCol, nEndRow );
+    pCellIter.reset( new ScHorizontalCellIterator( pDoc, nStartTab, nStartCol,
+            nStartRow, nEndCol, nEndRow ) );
 }
 
 ScHorizontalValueIterator::~ScHorizontalValueIterator()
 {
-    delete pCellIter;
 }
 
 bool ScHorizontalValueIterator::GetNext( double& rValue, FormulaError& rErr )
@@ -2518,14 +2517,11 @@ ScDocAttrIterator::ScDocAttrIterator(ScDocument* pDocument, SCTAB nTable,
     nCol( nCol1 )
 {
     if ( ValidTab(nTab) && nTab < pDoc->GetTableCount() && pDoc->maTabs[nTab] )
-        pColIter = pDoc->maTabs[nTab]->aCol[nCol].CreateAttrIterator( nStartRow, nEndRow );
-    else
-        pColIter = nullptr;
+        pColIter.reset( pDoc->maTabs[nTab]->aCol[nCol].CreateAttrIterator( nStartRow, nEndRow ) );
 }
 
 ScDocAttrIterator::~ScDocAttrIterator()
 {
-    delete pColIter;
 }
 
 const ScPatternAttr* ScDocAttrIterator::GetNext( SCCOL& rCol, SCROW& rRow1, SCROW& rRow2 )
@@ -2539,12 +2535,11 @@ const ScPatternAttr* ScDocAttrIterator::GetNext( SCCOL& rCol, SCROW& rRow1, SCRO
             return pPattern;
         }
 
-        delete pColIter;
         ++nCol;
         if ( nCol <= nEndCol )
-            pColIter = pDoc->maTabs[nTab]->aCol[nCol].CreateAttrIterator( nStartRow, nEndRow );
+            pColIter.reset( pDoc->maTabs[nTab]->aCol[nCol].CreateAttrIterator( nStartRow, nEndRow ) );
         else
-            pColIter = nullptr;
+            pColIter.reset();
     }
     return nullptr;  // Nothing anymore
 }
@@ -2649,7 +2644,7 @@ ScAttrRectIterator::ScAttrRectIterator(ScDocument* pDocument, SCTAB nTable,
 {
     if ( ValidTab(nTab) && nTab < pDoc->GetTableCount() && pDoc->maTabs[nTab] )
     {
-        pColIter = pDoc->maTabs[nTab]->aCol[nIterStartCol].CreateAttrIterator( nStartRow, nEndRow );
+        pColIter.reset( pDoc->maTabs[nTab]->aCol[nIterStartCol].CreateAttrIterator( nStartRow, nEndRow ) );
         while ( nIterEndCol < nEndCol &&
                 pDoc->maTabs[nTab]->aCol[nIterEndCol].IsAllAttrEqual(
                     pDoc->maTabs[nTab]->aCol[nIterEndCol+1], nStartRow, nEndRow ) )
@@ -2661,7 +2656,6 @@ ScAttrRectIterator::ScAttrRectIterator(ScDocument* pDocument, SCTAB nTable,
 
 ScAttrRectIterator::~ScAttrRectIterator()
 {
-    delete pColIter;
 }
 
 void ScAttrRectIterator::DataChanged()
@@ -2669,8 +2663,7 @@ void ScAttrRectIterator::DataChanged()
     if (pColIter)
     {
         SCROW nNextRow = pColIter->GetNextRow();
-        delete pColIter;
-        pColIter = pDoc->maTabs[nTab]->aCol[nIterStartCol].CreateAttrIterator( nNextRow, nEndRow );
+        pColIter.reset( pDoc->maTabs[nTab]->aCol[nIterStartCol].CreateAttrIterator( nNextRow, nEndRow ) );
     }
 }
 
@@ -2687,19 +2680,18 @@ const ScPatternAttr* ScAttrRectIterator::GetNext( SCCOL& rCol1, SCCOL& rCol2,
             return pPattern;
         }
 
-        delete pColIter;
         nIterStartCol = nIterEndCol+1;
         if ( nIterStartCol <= nEndCol )
         {
             nIterEndCol = nIterStartCol;
-            pColIter = pDoc->maTabs[nTab]->aCol[nIterStartCol].CreateAttrIterator( nStartRow, nEndRow );
+            pColIter.reset( pDoc->maTabs[nTab]->aCol[nIterStartCol].CreateAttrIterator( nStartRow, nEndRow ) );
             while ( nIterEndCol < nEndCol &&
                     pDoc->maTabs[nTab]->aCol[nIterEndCol].IsAllAttrEqual(
                         pDoc->maTabs[nTab]->aCol[nIterEndCol+1], nStartRow, nEndRow ) )
                 ++nIterEndCol;
         }
         else
-            pColIter = nullptr;
+            pColIter.reset();
     }
     return nullptr; // Nothing anymore
 }
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index c417218..d0d75bc 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -480,12 +480,11 @@ ScDPGroupTableData::ScDPGroupTableData( const shared_ptr<ScDPTableData>& pSource
 
     CreateCacheTable();
     nSourceCount = pSource->GetColumnCount();               // real columns, excluding data layout
-    pNumGroups = new ScDPNumGroupDimension[nSourceCount];
+    pNumGroups.reset( new ScDPNumGroupDimension[nSourceCount] );
 }
 
 ScDPGroupTableData::~ScDPGroupTableData()
 {
-    delete[] pNumGroups;
 }
 
 void ScDPGroupTableData::AddGroupDimension( const ScDPGroupDimension& rGroup )
diff --git a/sc/source/core/data/dpresfilter.cxx b/sc/source/core/data/dpresfilter.cxx
index d119f09..163782a 100644
--- a/sc/source/core/data/dpresfilter.cxx
+++ b/sc/source/core/data/dpresfilter.cxx
@@ -85,7 +85,6 @@ void ScDPResultTree::MemberNode::dump(int nLevel) const
 ScDPResultTree::ScDPResultTree() : mpRoot(new MemberNode) {}
 ScDPResultTree::~ScDPResultTree()
 {
-    delete mpRoot;
 }
 
 void ScDPResultTree::add(
@@ -95,7 +94,7 @@ void ScDPResultTree::add(
 
     const OUString* pDimName = nullptr;
     const OUString* pMemName = nullptr;
-    MemberNode* pMemNode = mpRoot;
+    MemberNode* pMemNode = mpRoot.get();
 
     std::vector<ScDPResultFilter>::const_iterator itFilter = rFilters.begin(), itFilterEnd = rFilters.end();
     for (; itFilter != itFilterEnd; ++itFilter)
@@ -203,8 +202,7 @@ bool ScDPResultTree::empty() const
 void ScDPResultTree::clear()
 {
     maPrimaryDimName = EMPTY_OUSTRING;
-    delete mpRoot;
-    mpRoot = new MemberNode;
+    mpRoot.reset( new MemberNode );
 }
 
 const ScDPResultTree::ValuesType* ScDPResultTree::getResults(
@@ -212,7 +210,7 @@ const ScDPResultTree::ValuesType* ScDPResultTree::getResults(
 {
     const sheet::DataPilotFieldFilter* p = rFilters.getConstArray();
     const sheet::DataPilotFieldFilter* pEnd = p + static_cast<size_t>(rFilters.getLength());
-    const MemberNode* pMember = mpRoot;
+    const MemberNode* pMember = mpRoot.get();
     for (; p != pEnd; ++p)
     {
         DimensionsType::const_iterator itDim = pMember->maChildDimensions.find(
diff --git a/sc/source/core/data/dpsave.cxx b/sc/source/core/data/dpsave.cxx
index f1b7e8b..2e7102d 100644
--- a/sc/source/core/data/dpsave.cxx
+++ b/sc/source/core/data/dpsave.cxx
@@ -814,9 +814,7 @@ ScDPSaveData::ScDPSaveData(const ScDPSaveData& r) :
     mpDimOrder(nullptr)
 {
     if ( r.pDimensionData )
-        pDimensionData = new ScDPDimensionSaveData( *r.pDimensionData );
-    else
-        pDimensionData = nullptr;
+        pDimensionData.reset( new ScDPDimensionSaveData( *r.pDimensionData ) );
 
     for (auto const& it : r.m_DimList)
     {
@@ -870,7 +868,6 @@ bool ScDPSaveData::operator== ( const ScDPSaveData& r ) const
 
 ScDPSaveData::~ScDPSaveData()
 {
-    delete pDimensionData;
 }
 
 void ScDPSaveData::SetGrandTotalName(const OUString& rName)
@@ -1315,17 +1312,16 @@ void ScDPSaveData::RemoveAllGroupDimensions( const OUString& rSrcDimName, std::v
 ScDPDimensionSaveData* ScDPSaveData::GetDimensionData()
 {
     if (!pDimensionData)
-        pDimensionData = new ScDPDimensionSaveData;
-    return pDimensionData;
+        pDimensionData.reset( new ScDPDimensionSaveData );
+    return pDimensionData.get();
 }
 
 void ScDPSaveData::SetDimensionData( const ScDPDimensionSaveData* pNew )
 {
-    delete pDimensionData;
     if ( pNew )
-        pDimensionData = new ScDPDimensionSaveData( *pNew );
+        pDimensionData.reset( new ScDPDimensionSaveData( *pNew ) );
     else
-        pDimensionData = nullptr;
+        pDimensionData.reset();
 }
 
 void ScDPSaveData::BuildAllDimensionMembers(ScDPTableData* pData)
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index c20c2a9..b62c88b 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -655,8 +655,8 @@ void ScDPAggData::SetAuxiliary( double fNew )
 ScDPAggData* ScDPAggData::GetChild()
 {
     if (!pChild)
-        pChild = new ScDPAggData;
-    return pChild;
+        pChild.reset( new ScDPAggData );
+    return pChild.get();
 }
 
 void ScDPAggData::Reset()
@@ -664,8 +664,7 @@ void ScDPAggData::Reset()
     fVal = 0.0;
     fAux = 0.0;
     nCount = SC_DPAGG_EMPTY;
-    delete pChild;
-    pChild = nullptr;
+    pChild.reset();
 }
 
 #if DUMP_PIVOT_TABLE
@@ -1845,7 +1844,6 @@ ScDPDataMember::ScDPDataMember( const ScDPResultData* pData, const ScDPResultMem
 
 ScDPDataMember::~ScDPDataMember()
 {
-    delete pChildDimension;
 }
 
 OUString ScDPDataMember::GetName() const
@@ -1883,7 +1881,7 @@ bool ScDPDataMember::HasHiddenDetails() const
 void ScDPDataMember::InitFrom( const ScDPResultDimension* pDim )
 {
     if ( !pChildDimension )
-        pChildDimension = new ScDPDataDimension(pResultData);
+        pChildDimension.reset( new ScDPDataDimension(pResultData) );
     pChildDimension->InitFrom(pDim);
 }
 
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index dd69c79..f741943 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -1340,8 +1340,6 @@ ScDPDimension::ScDPDimension( ScDPSource* pSrc, long nD ) :
 ScDPDimension::~ScDPDimension()
 {
     //TODO: release pSource
-
-    delete pSelectedData;
 }
 
 ScDPHierarchies* ScDPDimension::GetHierarchiesObject()
@@ -1442,13 +1440,13 @@ const ScDPItemData& ScDPDimension::GetSelectedData()
                 ScDPMember* pMember = pMembers->getByIndex(i);
                 if (aSelectedPage.equals(pMember->GetNameStr( false)))
                 {
-                    pSelectedData = new ScDPItemData(pMember->FillItemData());
+                    pSelectedData.reset( new ScDPItemData(pMember->FillItemData()) );
                 }
             }
         }
 
         if ( !pSelectedData )
-            pSelectedData = new ScDPItemData(aSelectedPage);      // default - name only
+            pSelectedData.reset( new ScDPItemData(aSelectedPage) );      // default - name only
     }
 
     return *pSelectedData;
@@ -1543,7 +1541,7 @@ void SAL_CALL ScDPDimension::setPropertyValue( const OUString& aPropertyName, co
             OSL_FAIL("Filter property is not a single string");
             throw lang::IllegalArgumentException();
         }
-        DELETEZ( pSelectedData );       // invalid after changing aSelectedPage
+        pSelectedData.reset();       // invalid after changing aSelectedPage
     }
     else if (aPropertyName == SC_UNO_DP_LAYOUTNAME)
     {
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 59af5df..b796c60 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -231,18 +231,15 @@ ScSolveParam::ScSolveParam( const ScAddress& rFormulaCell,
 
 ScSolveParam::~ScSolveParam()
 {
-    delete pStrTargetVal;
 }
 
 ScSolveParam& ScSolveParam::operator=( const ScSolveParam& r )
 {
-    delete pStrTargetVal;
-
     aRefFormulaCell  = r.aRefFormulaCell;
     aRefVariableCell = r.aRefVariableCell;
-    pStrTargetVal    = r.pStrTargetVal
+    pStrTargetVal.reset( r.pStrTargetVal
                             ? new OUString(*r.pStrTargetVal)
-                            : nullptr;
+                            : nullptr);
     return *this;
 }
 
diff --git a/sc/source/core/data/markarr.cxx b/sc/source/core/data/markarr.cxx
index dc65138..fb4cef0 100644
--- a/sc/source/core/data/markarr.cxx
+++ b/sc/source/core/data/markarr.cxx
@@ -35,16 +35,14 @@ ScMarkArray::ScMarkArray() :
 ScMarkArray::ScMarkArray( ScMarkArray&& rArray ) :
     nCount( rArray.nCount ),
     nLimit( rArray.nLimit ),
-    pData( rArray.pData )
+    pData( rArray.pData.release() )
 {
     rArray.nCount = 0;
     rArray.nLimit = 0;
-    rArray.pData = nullptr;
 }
 
 ScMarkArray::~ScMarkArray()
 {
-    delete[] pData;
 }
 
 void ScMarkArray::Reset( bool bMarked, SCSIZE nNeeded )
@@ -52,12 +50,10 @@ void ScMarkArray::Reset( bool bMarked, SCSIZE nNeeded )
     // always create pData here
     // (or have separate method to ensure pData)
 
-    delete[] pData;
-
     assert(nNeeded);
     nLimit = nNeeded;
     nCount = 1;
-    pData = new ScMarkEntry[nNeeded];
+    pData.reset( new ScMarkEntry[nNeeded] );
     pData[0].nRow = MAXROW;
     pData[0].bMarked = bMarked;
 }
@@ -129,9 +125,8 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked )
                     if ( nLimit < nNeeded )
                         nLimit = nNeeded;
                     ScMarkEntry* pNewData = new ScMarkEntry[nLimit];
-                    memcpy( pNewData, pData, nCount*sizeof(ScMarkEntry) );
-                    delete[] pData;
-                    pData = pNewData;
+                    memcpy( pNewData, pData.get(), nCount*sizeof(ScMarkEntry) );
+                    pData.reset( pNewData );
                 }
             }
 
@@ -207,7 +202,7 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked )
                 }
                 if ( ni < nj )
                 {   // remove entries
-                    memmove( pData + ni, pData + nj, (nCount - nj) * sizeof(ScMarkEntry) );
+                    memmove( pData.get() + ni, pData.get() + nj, (nCount - nj) * sizeof(ScMarkEntry) );
                     nCount -= nj - ni;
                 }
             }
@@ -217,11 +212,11 @@ void ScMarkArray::SetMarkArea( SCROW nStartRow, SCROW nEndRow, bool bMarked )
                 if ( nInsert <= nCount )
                 {
                     if ( !bSplit )
-                        memmove( pData + nInsert + 1, pData + nInsert,
+                        memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
                             (nCount - nInsert) * sizeof(ScMarkEntry) );
                     else
                     {
-                        memmove( pData + nInsert + 2, pData + nInsert,
+                        memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
                             (nCount - nInsert) * sizeof(ScMarkEntry) );
                         pData[nInsert+1] = pData[nInsert-1];
                         nCount++;
@@ -306,15 +301,13 @@ bool ScMarkArray::HasEqualRowsMarked( const ScMarkArray& rOther ) const
 
 void ScMarkArray::CopyMarksTo( ScMarkArray& rDestMarkArray ) const
 {
-    delete[] rDestMarkArray.pData;
-
     if (pData)
     {
-        rDestMarkArray.pData = new ScMarkEntry[nCount];
-        memcpy( rDestMarkArray.pData, pData, nCount * sizeof(ScMarkEntry) );
+        rDestMarkArray.pData.reset( new ScMarkEntry[nCount] );
+        memcpy( rDestMarkArray.pData.get(), pData.get(), nCount * sizeof(ScMarkEntry) );
     }
     else
-        rDestMarkArray.pData = nullptr;
+        rDestMarkArray.pData.reset();
 
     rDestMarkArray.nCount = rDestMarkArray.nLimit = nCount;
 }
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 23e451d..133b980 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -95,14 +95,11 @@ ScPatternAttr::ScPatternAttr( const ScPatternAttr& rPatternAttr )
         mnKey(rPatternAttr.mnKey)
 {
     if (rPatternAttr.pName)
-        pName = new OUString(*rPatternAttr.pName);
-    else
-        pName = nullptr;
+        pName.reset( new OUString(*rPatternAttr.pName) );
 }
 
 ScPatternAttr::~ScPatternAttr()
 {
-    delete pName;
 }
 
 SfxPoolItem* ScPatternAttr::Clone( SfxItemPool *pPool ) const
@@ -110,7 +107,7 @@ SfxPoolItem* ScPatternAttr::Clone( SfxItemPool *pPool ) const
     ScPatternAttr* pPattern = new ScPatternAttr( GetItemSet().Clone(true, pPool) );
 
     pPattern->pStyle = pStyle;
-    pPattern->pName  = pName ? new OUString(*pName) : nullptr;
+    pPattern->pName.reset( pName ? new OUString(*pName) : nullptr );
 
     return pPattern;
 }
@@ -166,7 +163,7 @@ SfxPoolItem* ScPatternAttr::Create( SvStream& rStream, sal_uInt16 /* nVersion */
 
     ScPatternAttr* pPattern = new ScPatternAttr( pNewSet );
 
-    pPattern->pName = pStr;
+    pPattern->pName.reset( pStr );
 
     return pPattern;
 }
@@ -1213,7 +1210,7 @@ bool ScPatternAttr::IsVisibleEqual( const ScPatternAttr& rOther ) const
 
 const OUString* ScPatternAttr::GetStyleName() const
 {
-    return pName ? pName : ( pStyle ? &pStyle->GetName() : nullptr );
+    return pName ? pName.get() : ( pStyle ? &pStyle->GetName() : nullptr );
 }
 
 void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle, bool bClearDirectFormat )
@@ -1233,7 +1230,7 @@ void ScPatternAttr::SetStyleSheet( ScStyleSheet* pNewStyle, bool bClearDirectFor
         }
         rPatternSet.SetParent(&pNewStyle->GetItemSet());
         pStyle = pNewStyle;
-        DELETEZ( pName );
+        pName.reset();
     }
     else
     {
@@ -1261,7 +1258,7 @@ void ScPatternAttr::UpdateStyleSheet(ScDocument* pDoc)
         if (pStyle)
         {
             GetItemSet().SetParent(&pStyle->GetItemSet());
-            DELETEZ( pName );
+            pName.reset();
         }
     }
     else
@@ -1277,7 +1274,7 @@ void ScPatternAttr::StyleToName()
         if ( pName )
             *pName = pStyle->GetName();
         else
-            pName = new OUString( pStyle->GetName() );
+            pName.reset( new OUString( pStyle->GetName() ) );
 
         pStyle = nullptr;
         GetItemSet().SetParent( nullptr );
diff --git a/sc/source/core/inc/addinlis.hxx b/sc/source/core/inc/addinlis.hxx
index 9f1c36d..5f451f5 100644
--- a/sc/source/core/inc/addinlis.hxx
+++ b/sc/source/core/inc/addinlis.hxx
@@ -37,7 +37,7 @@ class ScAddInListener : public cppu::WeakImplHelper<
 private:
     css::uno::Reference<css::sheet::XVolatileResult> xVolRes;
     css::uno::Any aResult;
-    ScAddInDocs* pDocs; // documents where this is used
+    std::unique_ptr<ScAddInDocs> pDocs; // documents where this is used
 
     static ::std::list<ScAddInListener*> aAllListeners;
 
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 15c4e92..3eaa815 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -80,12 +80,10 @@ ScUnoAddInFuncData::ScUnoAddInFuncData( const OUString& rNam, const OUString& rL
 {
     if ( nArgCount )
     {
-        pArgDescs = new ScAddInArgDesc[nArgCount];
+        pArgDescs.reset( new ScAddInArgDesc[nArgCount] );
         for (long i=0; i<nArgCount; i++)
             pArgDescs[i] = pAD[i];
     }
-    else
-        pArgDescs = nullptr;
 
     aUpperName = ScGlobal::pCharClass->uppercase(aUpperName);
     aUpperLocal = ScGlobal::pCharClass->uppercase(aUpperLocal);
@@ -93,7 +91,6 @@ ScUnoAddInFuncData::ScUnoAddInFuncData( const OUString& rNam, const OUString& rL
 
 ScUnoAddInFuncData::~ScUnoAddInFuncData()
 {
-    delete[] pArgDescs;
 }
 
 const ::std::vector<ScUnoAddInFuncData::LocalizedName>& ScUnoAddInFuncData::GetCompNames() const
@@ -204,17 +201,15 @@ void ScUnoAddInFuncData::SetFunction( const uno::Reference< reflection::XIdlMeth
 
 void ScUnoAddInFuncData::SetArguments( long nNewCount, const ScAddInArgDesc* pNewDescs )
 {
-    delete[] pArgDescs;
-
     nArgCount = nNewCount;
     if ( nArgCount )
     {
-        pArgDescs = new ScAddInArgDesc[nArgCount];
+        pArgDescs.reset( new ScAddInArgDesc[nArgCount] );
         for (long i=0; i<nArgCount; i++)
             pArgDescs[i] = pNewDescs[i];
     }
     else
-        pArgDescs = nullptr;
+        pArgDescs.reset();
 }
 
 void ScUnoAddInFuncData::SetCallerPos( long nNewPos )
diff --git a/sc/source/core/tool/addinlis.cxx b/sc/source/core/tool/addinlis.cxx
index 95ebc60..29985bf 100644
--- a/sc/source/core/tool/addinlis.cxx
+++ b/sc/source/core/tool/addinlis.cxx
@@ -47,15 +47,14 @@ ScAddInListener* ScAddInListener::CreateListener(
 }
 
 ScAddInListener::ScAddInListener( uno::Reference<sheet::XVolatileResult> const & xVR, ScDocument* pDoc ) :
-    xVolRes( xVR )
+    xVolRes( xVR ),
+    pDocs( new ScAddInDocs )
 {
-    pDocs = new ScAddInDocs();
     pDocs->insert( pDoc );
 }
 
 ScAddInListener::~ScAddInListener()
 {
-    delete pDocs;
 }
 
 ScAddInListener* ScAddInListener::Get( const uno::Reference<sheet::XVolatileResult>& xVR )
@@ -80,7 +79,7 @@ void ScAddInListener::RemoveDocument( ScDocument* pDocumentP )
     ::std::list<ScAddInListener*>::iterator iter = aAllListeners.begin();
     while(iter != aAllListeners.end())
     {
-        ScAddInDocs* p = (*iter)->pDocs;
+        ScAddInDocs* p = (*iter)->pDocs.get();
         ScAddInDocs::iterator iter2 = p->find( pDocumentP );
         if( iter2 != p->end() )
         {
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index b1d6e94..9b7a958 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -49,7 +49,6 @@ ScAppOptions::ScAppOptions( const ScAppOptions& rCpy ) : pLRUList( nullptr )
 
 ScAppOptions::~ScAppOptions()
 {
-    delete [] pLRUList;
 }
 
 void ScAppOptions::SetDefaults()
@@ -66,8 +65,7 @@ void ScAppOptions::SetDefaults()
     bAutoComplete   = true;
     bDetectiveAuto  = true;
 
-    delete [] pLRUList;
-    pLRUList = new sal_uInt16[5];               // sinnvoll vorbelegen
+    pLRUList.reset( new sal_uInt16[5] );               // sinnvoll vorbelegen
     pLRUList[0] = SC_OPCODE_SUM;
     pLRUList[1] = SC_OPCODE_AVERAGE;
     pLRUList[2] = SC_OPCODE_MIN;
@@ -95,7 +93,7 @@ ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
     eZoomType       = rCpy.eZoomType;
     bSynchronizeZoom = rCpy.bSynchronizeZoom;
     nZoom           = rCpy.nZoom;
-    SetLRUFuncList( rCpy.pLRUList, rCpy.nLRUFuncCount );
+    SetLRUFuncList( rCpy.pLRUList.get(), rCpy.nLRUFuncCount );
     nStatusFunc     = rCpy.nStatusFunc;
     bAutoComplete   = rCpy.bAutoComplete;
     bDetectiveAuto  = rCpy.bDetectiveAuto;
@@ -113,19 +111,17 @@ ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
 
 void ScAppOptions::SetLRUFuncList( const sal_uInt16* pList, const sal_uInt16 nCount )
 {
-    delete [] pLRUList;
-
     nLRUFuncCount = nCount;
 
     if ( nLRUFuncCount > 0 )
     {
-        pLRUList = new sal_uInt16[nLRUFuncCount];
+        pLRUList.reset( new sal_uInt16[nLRUFuncCount] );
 
         for ( sal_uInt16 i=0; i<nLRUFuncCount; i++ )
             pLRUList[i] = pList[i];
     }
     else
-        pLRUList = nullptr;
+        pLRUList.reset();
 }
 
 //  Config Item containing app options
diff --git a/sc/source/core/tool/callform.cxx b/sc/source/core/tool/callform.cxx
index d79e98f..06884c5 100644
--- a/sc/source/core/tool/callform.cxx
+++ b/sc/source/core/tool/callform.cxx
@@ -80,16 +80,16 @@ class ModuleData
 {
 friend class ModuleCollection;
     OUString aName;
-    osl::Module* pInstance;
+    std::unique_ptr<osl::Module> pInstance;
 public:
     ModuleData(const ModuleData&) = delete;
     const ModuleData& operator=(const ModuleData&) = delete;
 
     ModuleData(const OUString& rStr, osl::Module* pInst) : aName(rStr), pInstance(pInst) {}
-    ~ModuleData() { delete pInstance; }
+    ~ModuleData() {}
 
     const OUString& GetName() const { return aName; }
-    osl::Module*    GetInstance() const { return pInstance; }
+    osl::Module*    GetInstance() const { return pInstance.get(); }
 };
 
 LegacyFuncData::LegacyFuncData(const ModuleData*pModule,
diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx
index cd891b5..fa95a35 100644
--- a/sc/source/core/tool/chartpos.cxx
+++ b/sc/source/core/tool/chartpos.cxx
@@ -86,7 +86,6 @@ ScChartPositioner::ScChartPositioner( const ScChartPositioner& rPositioner ) :
 
 ScChartPositioner::~ScChartPositioner()
 {
-    delete pPositionMap;
 }
 
 void ScChartPositioner::SetRangeList( const ScRange& rRange )
@@ -331,15 +330,14 @@ void ScChartPositioner::CheckColRowHeaders()
 const ScChartPositionMap* ScChartPositioner::GetPositionMap()
 {
     CreatePositionMap();
-    return pPositionMap;
+    return pPositionMap.get();
 }
 
 void ScChartPositioner::CreatePositionMap()
 {
     if ( eGlue == SC_CHARTGLUE_NA && pPositionMap )
     {
-        delete pPositionMap;
-        pPositionMap = nullptr;
+        pPositionMap.reset();
     }
 
     if ( pPositionMap )
@@ -458,8 +456,8 @@ void ScChartPositioner::CreatePositionMap()
         }
     }
 
-    pPositionMap = new ScChartPositionMap( static_cast<SCCOL>(nColCount), static_cast<SCROW>(nRowCount),
-        static_cast<SCCOL>(nColAdd), static_cast<SCROW>(nRowAdd), *pCols );
+    pPositionMap.reset( new ScChartPositionMap( static_cast<SCCOL>(nColCount), static_cast<SCROW>(nRowCount),
+        static_cast<SCCOL>(nColAdd), static_cast<SCROW>(nRowAdd), *pCols ) );
 
     //  cleanup
     for (ColumnMap::const_iterator it = pCols->begin(); it != pCols->end(); ++it )
@@ -469,6 +467,12 @@ void ScChartPositioner::CreatePositionMap()
     delete pCols;
 }
 
+void ScChartPositioner::InvalidateGlue()
+{
+    eGlue = SC_CHARTGLUE_NA;
+    pPositionMap.reset();
+}
+
 ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows,
             SCCOL nColAdd, SCROW nRowAdd, ColumnMap& rCols ) :
         ppData( new ScAddress* [ nChartCols * nChartRows ] ),
diff --git a/sc/source/core/tool/chgviset.cxx b/sc/source/core/tool/chgviset.cxx
index 938c265..a9016d1 100644
--- a/sc/source/core/tool/chgviset.cxx
+++ b/sc/source/core/tool/chgviset.cxx
@@ -26,7 +26,6 @@
 
 ScChangeViewSettings::~ScChangeViewSettings()
 {
-    delete pCommentSearcher;
 }
 
 ScChangeViewSettings::ScChangeViewSettings( const ScChangeViewSettings& r ):
@@ -96,18 +95,14 @@ bool ScChangeViewSettings::IsValidComment(const OUString* pCommentStr) const
 void ScChangeViewSettings::SetTheComment(const OUString& rString)
 {
     aComment = rString;
-    if(pCommentSearcher)
-    {
-        delete pCommentSearcher;
-        pCommentSearcher=nullptr;
-    }
+    pCommentSearcher.reset();
 
     if(!rString.isEmpty())
     {
         utl::SearchParam aSearchParam( rString,
             utl::SearchParam::SRCH_REGEXP,false );
 
-        pCommentSearcher = new utl::TextSearch( aSearchParam, *ScGlobal::pCharClass );
+        pCommentSearcher.reset( new utl::TextSearch( aSearchParam, *ScGlobal::pCharClass ) );
     }
 }
 
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 0922d00..fa0f99d 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -381,8 +381,8 @@ ScEditAttrTester::ScEditAttrTester( ScEditEngineDefaulter* pEng ) :
     else
     {
         const SfxPoolItem* pItem = nullptr;
-        pEditAttrs = new SfxItemSet( pEngine->GetAttribs(
-                                        ESelection(0,0,0,pEngine->GetTextLen(0)), EditEngineAttribs_OnlyHard ) );
+        pEditAttrs.reset( new SfxItemSet( pEngine->GetAttribs(
+                                        ESelection(0,0,0,pEngine->GetTextLen(0)), EditEngineAttribs_OnlyHard ) ) );
         const SfxItemSet& rEditDefaults = pEngine->GetDefaults();
 
         for (sal_uInt16 nId = EE_CHAR_START; nId <= EE_CHAR_END && !bNeedsObject; nId++)
@@ -427,7 +427,6 @@ ScEditAttrTester::ScEditAttrTester( ScEditEngineDefaulter* pEng ) :
 
 ScEditAttrTester::~ScEditAttrTester()
 {
-    delete pEditAttrs;
 }
 
 ScEnginePoolHelper::ScEnginePoolHelper( SfxItemPool* pEnginePoolP,
diff --git a/sc/source/core/tool/prnsave.cxx b/sc/source/core/tool/prnsave.cxx
index 911b411..7cc5359 100644
--- a/sc/source/core/tool/prnsave.cxx
+++ b/sc/source/core/tool/prnsave.cxx
@@ -72,14 +72,11 @@ ScPrintRangeSaver::ScPrintRangeSaver( SCTAB nCount ) :
     nTabCount( nCount )
 {
     if (nCount > 0)
-        pData = new ScPrintSaverTab[nCount];
-    else
-        pData = nullptr;
+        pData.reset( new ScPrintSaverTab[nCount] );
 }
 
 ScPrintRangeSaver::~ScPrintRangeSaver()
 {
-    delete[] pData;
 }
 
 ScPrintSaverTab& ScPrintRangeSaver::GetTabData(SCTAB nTab)
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index eae117c0..d7fba04 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -73,7 +73,7 @@ ScRangeData::ScRangeData( ScDocument* pDok,
         // Copy ctor default-constructs pCode if it was NULL, so it's initialized here, too,
         // to ensure same behavior if unnecessary copying is left out.
 
-        pCode = new ScTokenArray();
+        pCode.reset( new ScTokenArray );
         pCode->SetFromRangeName(true);
     }
 }
@@ -144,7 +144,6 @@ ScRangeData::ScRangeData(const ScRangeData& rScRangeData, ScDocument* pDocument,
 
 ScRangeData::~ScRangeData()
 {
-    delete pCode;
 }
 
 void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError )
@@ -162,8 +161,7 @@ void ScRangeData::CompileRangeData( const OUString& rSymbol, bool bSetError )
     if (bSetError)
         aComp.SetExtendedErrorDetection( ScCompiler::EXTENDED_ERROR_DETECTION_NAME_NO_BREAK);
     ScTokenArray* pNewCode = aComp.CompileString( rSymbol );
-    std::unique_ptr<ScTokenArray> pOldCode( pCode);     // old pCode will be deleted
-    pCode = pNewCode;
+    pCode.reset(pNewCode);
     pCode->SetFromRangeName(true);
     if( pCode->GetCodeError() == FormulaError::NONE )
     {
@@ -626,8 +624,7 @@ void ScRangeData::ValidateTabRefs()
 
 void ScRangeData::SetCode( ScTokenArray& rArr )
 {
-    std::unique_ptr<ScTokenArray> pOldCode( pCode); // old pCode will be deleted
-    pCode = new ScTokenArray( rArr );
+    pCode.reset(new ScTokenArray( rArr ));
     pCode->SetFromRangeName(true);
     InitCode();
 }


More information about the Libreoffice-commits mailing list