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

Noel Grandin noel.grandin at collabora.co.uk
Thu Jul 13 06:30:56 UTC 2017


 sc/inc/attarray.hxx                |    3 -
 sc/inc/autoform.hxx                |    3 -
 sc/inc/chartarr.hxx                |    2 
 sc/inc/chartpos.hxx                |   10 +--
 sc/inc/chgtrack.hxx                |    7 +-
 sc/inc/dociter.hxx                 |    9 +--
 sc/inc/dpoutput.hxx                |    7 +-
 sc/inc/fillinfo.hxx                |    3 -
 sc/inc/rechead.hxx                 |    8 +-
 sc/inc/table.hxx                   |    4 -
 sc/source/core/data/attarray.cxx   |   32 ++++-------
 sc/source/core/data/bcaslot.cxx    |   12 +---
 sc/source/core/data/dociter.cxx    |   12 +---
 sc/source/core/data/dpoutput.cxx   |    6 --
 sc/source/core/data/fillinfo.cxx   |    5 -
 sc/source/core/data/table1.cxx     |    6 --
 sc/source/core/data/table5.cxx     |    4 -
 sc/source/core/inc/bcaslot.hxx     |    6 +-
 sc/source/core/tool/autoform.cxx   |   13 +---
 sc/source/core/tool/chartarr.cxx   |    9 ---
 sc/source/core/tool/chartpos.cxx   |   10 ---
 sc/source/core/tool/chgtrack.cxx   |    9 +--
 sc/source/core/tool/interpr8.cxx   |   25 ++-------
 sc/source/core/tool/rechead.cxx    |    7 +-
 sc/source/filter/dif/difimp.cxx    |   20 +------
 sc/source/filter/inc/dif.hxx       |    4 +
 sc/source/ui/dbgui/asciiopt.cxx    |  102 +++++++++----------------------------
 sc/source/ui/docshell/pagedata.cxx |   27 +--------
 sc/source/ui/inc/asciiopt.hxx      |   11 +--
 sc/source/ui/inc/pagedata.hxx      |   23 ++++----
 sc/source/ui/inc/prevloc.hxx       |   10 ++-
 sc/source/ui/inc/undoblk.hxx       |   15 +++--
 sc/source/ui/undo/undoblk.cxx      |    7 --
 sc/source/ui/view/gridwin4.cxx     |    4 -
 sc/source/ui/view/output.cxx       |    2 
 sc/source/ui/view/prevloc.cxx      |    8 --
 36 files changed, 164 insertions(+), 281 deletions(-)

New commits:
commit 647e11dc2fcbf0c8f7e39f4260d2b89057267e36
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jul 12 18:58:17 2017 +0200

    loplugin:useuniqueptr in sc
    
    Change-Id: I004e1f0292c8a40515880546574255ab835dbdbe
    Reviewed-on: https://gerrit.libreoffice.org/39875
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/inc/attarray.hxx b/sc/inc/attarray.hxx
index 7504610f6a06..d410e9140a9c 100644
--- a/sc/inc/attarray.hxx
+++ b/sc/inc/attarray.hxx
@@ -90,7 +90,8 @@ private:
 
     SCSIZE          nCount;
     SCSIZE          nLimit;
-    ScAttrEntry*    pData;
+    std::unique_ptr<ScAttrEntry[]>
+                    pData;
 
 friend class ScDocument;                // for FillInfo
 friend class ScDocumentIterator;
diff --git a/sc/inc/autoform.hxx b/sc/inc/autoform.hxx
index d0e8760561d2..8d36511a1c3c 100644
--- a/sc/inc/autoform.hxx
+++ b/sc/inc/autoform.hxx
@@ -51,6 +51,7 @@
 #include "scdllapi.h"
 #include "zforauto.hxx"
 
+#include <array>
 #include <memory>
 #include <map>
 
@@ -261,7 +262,7 @@ private:
     // Writer-specific data
     AutoFormatSwBlob m_swFields;
 
-    ScAutoFormatDataField**     ppDataField;
+    std::array<std::unique_ptr<ScAutoFormatDataField>,16> ppDataField;
 
     SAL_DLLPRIVATE ScAutoFormatDataField&       GetField( sal_uInt16 nIndex );
     SAL_DLLPRIVATE const ScAutoFormatDataField& GetField( sal_uInt16 nIndex ) const;
diff --git a/sc/inc/chartarr.hxx b/sc/inc/chartarr.hxx
index 6165290ee5b2..57feca6d91a1 100644
--- a/sc/inc/chartarr.hxx
+++ b/sc/inc/chartarr.hxx
@@ -36,7 +36,7 @@ class ScMemChart
 {
     SCROW nRowCnt;
     SCCOL nColCnt;
-    double* pData;
+    std::unique_ptr<double[]> pData;
     OUString* pColText;
     OUString* pRowText;
 
diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx
index ac53d74a0cbf..8666919df0fa 100644
--- a/sc/inc/chartpos.hxx
+++ b/sc/inc/chartpos.hxx
@@ -20,8 +20,8 @@
 #ifndef INCLUDED_SC_INC_CHARTPOS_HXX
 #define INCLUDED_SC_INC_CHARTPOS_HXX
 
-#include <memory>
 #include "rangelst.hxx"
+#include <memory>
 #include <map>
 
 class ScAddress;
@@ -35,10 +35,10 @@ class ScChartPositionMap
 {
     friend class ScChartPositioner;
 
-            ScAddress**         ppData;
-            ScAddress**         ppColHeader;
-            ScAddress**         ppRowHeader;
-            sal_uLong               nCount;
+            std::unique_ptr<ScAddress*[]> ppData;
+            std::unique_ptr<ScAddress*[]> ppColHeader;
+            std::unique_ptr<ScAddress*[]> ppRowHeader;
+            sal_uLong           nCount;
             SCCOL               nColCount;
             SCROW               nRowCount;
 
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 9484db26e94d..b389029fb9bf 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -22,6 +22,7 @@
 
 #include <deque>
 #include <map>
+#include <memory>
 #include <set>
 #include <stack>
 
@@ -876,14 +877,14 @@ class ScChangeTrack : public utl::ConfigurationListener
     ScChangeAction*     pFirst;
     ScChangeAction*     pLast;
     ScChangeActionContent*  pFirstGeneratedDelContent;
-    ScChangeActionContent** ppContentSlots;
+    std::unique_ptr<ScChangeActionContent*[]> ppContentSlots;
     ScChangeActionMove*     pLastCutMove;
     ScChangeActionLinkEntry*    pLinkInsertCol;
     ScChangeActionLinkEntry*    pLinkInsertRow;
     ScChangeActionLinkEntry*    pLinkInsertTab;
     ScChangeActionLinkEntry*    pLinkMove;
     ScChangeTrackMsgInfo*   pBlockModifyMsg;
-    ScDocument*         pDoc;
+    ScDocument*             pDoc;
     sal_uLong               nActionMax;
     sal_uLong               nGeneratedMin;
     sal_uLong               nMarkLastSaved;
@@ -1003,7 +1004,7 @@ public:
     sal_uLong GetLastSavedActionNumber() const;
     void SetLastSavedActionNumber(sal_uLong nNew);
     ScChangeAction* GetLastSaved() const;
-    ScChangeActionContent** GetContentSlots() const { return ppContentSlots; }
+    ScChangeActionContent** GetContentSlots() const { return ppContentSlots.get(); }
 
     const ScRange&      GetInDeleteRange() const
                             { return aInDeleteRange; }
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index 25c09d6599c1..0cfda4c72440 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -480,10 +480,11 @@ private:
     SCCOL                   nEndCol;
     SCROW                   nEndRow;
 
-    SCROW*                  pNextEnd;
-    SCCOL*                  pHorizEnd;
-    SCSIZE*                 pIndices;
-    const ScPatternAttr**   ppPatterns;
+    std::unique_ptr<SCROW[]>  pNextEnd;
+    std::unique_ptr<SCCOL[]>  pHorizEnd;
+    std::unique_ptr<SCSIZE[]> pIndices;
+    std::unique_ptr<const ScPatternAttr*[]>
+                              ppPatterns;
     SCCOL                   nCol;
     SCROW                   nRow;
     bool                    bRowEmpty;
diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index cf9e25dab7e6..defab43b4b87 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -32,6 +32,7 @@
 #include "dpfilteredcache.hxx"
 #include "dptypes.hxx"
 
+#include <memory>
 #include <vector>
 
 namespace com { namespace sun { namespace star { namespace sheet {
@@ -56,8 +57,10 @@ private:
     OUString                aDataDescription;
 
     // Number format related parameters
-    sal_uInt32*             pColNumFmt;
-    sal_uInt32*             pRowNumFmt;
+    std::unique_ptr<sal_uInt32[]>
+                            pColNumFmt;
+    std::unique_ptr<sal_uInt32[]>
+                            pRowNumFmt;
     long                    nColFmtCount;
     long                    nRowFmtCount;
     sal_uInt32              nSingleNumFmt;
diff --git a/sc/inc/fillinfo.hxx b/sc/inc/fillinfo.hxx
index d8a9a0430d33..53de02b0eca5 100644
--- a/sc/inc/fillinfo.hxx
+++ b/sc/inc/fillinfo.hxx
@@ -191,7 +191,8 @@ struct RowInfo
 struct ScTableInfo
 {
     svx::frame::Array   maArray;
-    RowInfo*            mpRowInfo;
+    std::unique_ptr<RowInfo[]>
+                        mpRowInfo;
     SCSIZE              mnArrCount;
     SCSIZE              mnArrCapacity;
     bool                mbPageMode;
diff --git a/sc/inc/rechead.hxx b/sc/inc/rechead.hxx
index 9d2ac1291353..950620276fae 100644
--- a/sc/inc/rechead.hxx
+++ b/sc/inc/rechead.hxx
@@ -21,6 +21,7 @@
 #define INCLUDED_SC_INC_RECHEAD_HXX
 
 #include <tools/stream.hxx>
+#include <memory>
 
 //      ID's for files:
 
@@ -49,9 +50,10 @@ class SvStream;
 class ScMultipleReadHeader
 {
 private:
-    SvStream&       rStream;
-    sal_uInt8*          pBuf;
-    SvMemoryStream* pMemStream;
+    SvStream&           rStream;
+    std::unique_ptr<sal_uInt8[]>
+                        pBuf;
+    SvMemoryStream*     pMemStream;
     sal_uLong           nEndPos;
     sal_uLong           nEntryEnd;
     sal_uLong           nTotalEnd;
diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 38b958478824..e34ed5fd2d77 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -145,10 +145,10 @@ private:
 
     std::unique_ptr<ScTableProtection> pTabProtection;
 
-    sal_uInt16*         pColWidth;
+    std::unique_ptr<sal_uInt16[]>            pColWidth;
     std::unique_ptr<ScFlatUInt16RowSegments> mpRowHeights;
 
-    CRFlags*            pColFlags;
+    std::unique_ptr<CRFlags[]>               pColFlags;
     ScBitMaskCompressedArray< SCROW, CRFlags>*     pRowFlags;
     std::unique_ptr<ScFlatBoolColSegments>  mpHiddenCols;
     std::unique_ptr<ScFlatBoolRowSegments>  mpHiddenRows;
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx
index 5214180f0d80..287ece9fcdba 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -67,7 +67,7 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr
             bool bNumFormatChanged;
             ScAddress aAdrStart( nCol, 0, nTab );
             ScAddress aAdrEnd( nCol, 0, nTab );
-            pData = new ScAttrEntry[nCount];
+            pData.reset( new ScAttrEntry[nCount] );
             for ( size_t nIdx = 0; nIdx < nCount; ++nIdx )
             {
                 pData[nIdx].nRow = pDefaultColAttrArray->pData[nIdx].nRow;
@@ -95,8 +95,6 @@ ScAttrArray::~ScAttrArray()
     ScDocumentPool* pDocPool = pDocument->GetPool();
     for (SCSIZE i=0; i<nCount; i++)
         pDocPool->Remove(*pData[i].pPattern);
-
-    delete[] pData;
 }
 
 #if DEBUG_SC_TESTATTRARRAY
@@ -126,7 +124,7 @@ void ScAttrArray::SetDefaultIfNotInit( SCSIZE nNeeded )
         return;
 
     SCSIZE nNewLimit = ( SC_ATTRARRAY_DELTA > nNeeded ) ? SC_ATTRARRAY_DELTA : nNeeded;
-    pData = new ScAttrEntry[nNewLimit];
+    pData.reset( new ScAttrEntry[nNewLimit] );
     pData[0].nRow = MAXROW;
     pData[0].pPattern = pDocument->GetDefPattern(); // no put
     nCount = 1;
@@ -156,13 +154,13 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern )
         }
         pDocPool->Remove(*pOldPattern);
     }
-    delete[] pData;
+    pData.reset();
 
     if (pDocument->IsStreamValid(nTab))
         pDocument->SetStreamValid(nTab, false);
 
     nCount = nLimit = 1;
-    pData = new ScAttrEntry[1];
+    pData.reset( new ScAttrEntry[1] );
     const ScPatternAttr* pNewPattern = static_cast<const ScPatternAttr*>( &pDocPool->Put(*pPattern) );
     pData[0].nRow = MAXROW;
     pData[0].pPattern = pNewPattern;
@@ -425,7 +423,7 @@ bool ScAttrArray::Reserve( SCSIZE nReserve )
         {
             nLimit = nReserve;
             nCount = 1;
-            pData = pNewData;
+            pData.reset( pNewData );
             pData[0].nRow = MAXROW;
             pData[0].pPattern = pDocument->GetDefPattern(); // no put
             return true;
@@ -438,9 +436,8 @@ bool ScAttrArray::Reserve( SCSIZE nReserve )
         if( ScAttrEntry* pNewData = new (std::nothrow) ScAttrEntry[nReserve] )
         {
             nLimit = nReserve;
-            memcpy( pNewData, pData, nCount*sizeof(ScAttrEntry) );
-            delete[] pData;
-            pData = pNewData;
+            memcpy( pNewData, pData.get(), nCount*sizeof(ScAttrEntry) );
+            pData.reset( pNewData );
             return true;
         }
         else
@@ -470,9 +467,8 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern
                 if ( nLimit < nNeeded )
                     nLimit = nNeeded;
                 ScAttrEntry* pNewData = new ScAttrEntry[nLimit];
-                memcpy( pNewData, pData, nCount*sizeof(ScAttrEntry) );
-                delete[] pData;
-                pData = pNewData;
+                memcpy( pNewData, pData.get(), nCount*sizeof(ScAttrEntry) );
+                pData.reset( pNewData );
             }
 
             ScAddress       aAdrStart( nCol, 0, nTab );
@@ -590,7 +586,7 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern
                 }
                 if ( ni < nj )
                 {   // remove entries
-                    memmove( pData + ni, pData + nj, (nCount - nj) * sizeof(ScAttrEntry) );
+                    memmove( pData.get() + ni, pData.get() + nj, (nCount - nj) * sizeof(ScAttrEntry) );
                     nCount -= nj - ni;
                 }
             }
@@ -600,11 +596,11 @@ void ScAttrArray::SetPatternArea(SCROW nStartRow, SCROW nEndRow, const ScPattern
                 if ( nInsert <= nCount )
                 {
                     if ( !bSplit )
-                        memmove( pData + nInsert + 1, pData + nInsert,
+                        memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
                             (nCount - nInsert) * sizeof(ScAttrEntry) );
                     else
                     {
-                        memmove( pData + nInsert + 2, pData + nInsert,
+                        memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
                             (nCount - nInsert) * sizeof(ScAttrEntry) );
                         pData[nInsert+1] = pData[nInsert-1];
                         nCount++;
@@ -941,9 +937,7 @@ void ScAttrArray::SetAttrEntries(ScAttrEntry* pNewData, SCSIZE nSize)
     for (SCSIZE i=0; i<nCount; i++)
         pDocPool->Remove(*pData[i].pPattern);
 
-    delete[] pData;
-
-    pData = pNewData;
+    pData.reset( pNewData );
     nCount = nLimit = nSize;
 }
 
diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx
index 389d26217963..a55fbcb5b533 100644
--- a/sc/source/core/data/bcaslot.cxx
+++ b/sc/source/core/data/bcaslot.cxx
@@ -637,18 +637,14 @@ void ScBroadcastAreaSlot::FinallyEraseAreas()
 
 ScBroadcastAreaSlotMachine::TableSlots::TableSlots()
 {
-    ppSlots = new ScBroadcastAreaSlot* [ nBcaSlots ];
-    memset( ppSlots, 0 , sizeof( ScBroadcastAreaSlot* ) * nBcaSlots );
+    ppSlots.reset( new ScBroadcastAreaSlot* [ nBcaSlots ] );
+    memset( ppSlots.get(), 0 , sizeof( ScBroadcastAreaSlot* ) * nBcaSlots );
 }
 
 ScBroadcastAreaSlotMachine::TableSlots::~TableSlots()
 {
-    for ( ScBroadcastAreaSlot** pp = ppSlots + nBcaSlots; --pp >= ppSlots; /* nothing */ )
-    {
-        if (*pp)
-            delete *pp;
-    }
-    delete [] ppSlots;
+    for ( ScBroadcastAreaSlot** pp = ppSlots.get() + nBcaSlots; --pp >= ppSlots.get(); /* nothing */ )
+        delete *pp;
 }
 
 ScBroadcastAreaSlotMachine::ScBroadcastAreaSlotMachine(
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 1d0d89efd2e5..016630f1c061 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -2258,20 +2258,16 @@ ScHorizontalAttrIterator::ScHorizontalAttrIterator( ScDocument* pDocument, SCTAB
     nCol = nStartCol;
     bRowEmpty = false;
 
-    pIndices    = new SCSIZE[nEndCol-nStartCol+1];
-    pNextEnd    = new SCROW[nEndCol-nStartCol+1];
-    pHorizEnd   = new SCCOL[nEndCol-nStartCol+1];
-    ppPatterns  = new const ScPatternAttr*[nEndCol-nStartCol+1];
+    pIndices.reset( new SCSIZE[nEndCol-nStartCol+1] );
+    pNextEnd.reset( new SCROW[nEndCol-nStartCol+1] );
+    pHorizEnd.reset( new SCCOL[nEndCol-nStartCol+1] );
+    ppPatterns.reset( new const ScPatternAttr*[nEndCol-nStartCol+1] );
 
     InitForNextRow(true);
 }
 
 ScHorizontalAttrIterator::~ScHorizontalAttrIterator()
 {
-    delete[] ppPatterns;
-    delete[] pHorizEnd;
-    delete[] pNextEnd;
-    delete[] pIndices;
 }
 
 void ScHorizontalAttrIterator::InitForNextRow(bool bInitialization)
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 5bd2c12b0551..366538a354a4 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -327,7 +327,7 @@ void lcl_SetFrame( ScDocument* pDoc, SCTAB nTab,
     pDoc->ApplyFrameAreaTab(ScRange(nCol1, nRow1, nTab, nCol2, nRow2, nTab), aBox, aBoxInfo);
 }
 
-void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
+void lcl_FillNumberFormats( std::unique_ptr<sal_uInt32[]>& rFormats, long& rCount,
                             const uno::Reference<sheet::XDataPilotMemberResults>& xLevRes,
                             const uno::Reference<container::XIndexAccess>& xDims )
 {
@@ -407,7 +407,7 @@ void lcl_FillNumberFormats( sal_uInt32*& rFormats, long& rCount,
         }
     }
 
-    rFormats = pNumFmt;
+    rFormats.reset( pNumFmt );
     rCount = nSize;
 }
 
@@ -693,8 +693,6 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
 
 ScDPOutput::~ScDPOutput()
 {
-    delete[] pColNumFmt;
-    delete[] pRowNumFmt;
 }
 
 void ScDPOutput::SetPosition( const ScAddress& rPos )
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 083051d52245..e5aadd52ac4f 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -364,7 +364,7 @@ void ScDocument::FillInfo(
     ScDocumentPool* pPool = xPoolHelper->GetDocPool();
     ScStyleSheetPool* pStlPool = xPoolHelper->GetStylePool();
 
-    RowInfo* pRowInfo = rTabInfo.mpRowInfo;
+    RowInfo* pRowInfo = rTabInfo.mpRowInfo.get();
 
     const SvxBrushItem* pDefBackground =
             static_cast<const SvxBrushItem*>( &pPool->GetDefaultItem( ATTR_BACKGROUND ) );
@@ -1097,14 +1097,13 @@ ScTableInfo::ScTableInfo(const SCSIZE capacity)
     , mnArrCapacity(capacity)
     , mbPageMode(false)
 {
-    memset(mpRowInfo, 0, mnArrCapacity * sizeof(RowInfo));
+    memset(mpRowInfo.get(), 0, mnArrCapacity * sizeof(RowInfo));
 }
 
 ScTableInfo::~ScTableInfo()
 {
     for( SCSIZE nIdx = 0; nIdx < mnArrCapacity; ++nIdx )
         delete [] mpRowInfo[ nIdx ].pCellInfo;
-    delete [] mpRowInfo;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 44ab75965008..1652c97c12b4 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -291,8 +291,8 @@ ScTable::ScTable( ScDocument* pDoc, SCTAB nNewTab, const OUString& rNewName,
 
     if (bColInfo)
     {
-        pColWidth  = new sal_uInt16[ MAXCOL+1 ];
-        pColFlags  = new CRFlags[ MAXCOL+1 ];
+        pColWidth.reset( new sal_uInt16[ MAXCOL+1 ] );
+        pColFlags.reset( new CRFlags[ MAXCOL+1 ] );
 
         for (SCCOL i=0; i<=MAXCOL; i++)
         {
@@ -347,8 +347,6 @@ ScTable::~ScTable() COVERITY_NOEXCEPT_FALSE
             pDrawLayer->ScRemovePage( nTab );
     }
 
-    delete[] pColWidth;
-    delete[] pColFlags;
     delete pRowFlags;
     delete pSheetEvents;
     delete pOutlineTable;
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index c7a3b7938b68..dc59989d1644 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -1026,8 +1026,8 @@ void ScTable::SyncColRowFlags()
     }
 
     // Hidden flags.
-    lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, pColFlags, pRowFlags, CRFlags::Hidden);
-    lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, pColFlags, pRowFlags, CRFlags::Filtered);
+    lcl_syncFlags(*mpHiddenCols, *mpHiddenRows, pColFlags.get(), pRowFlags, CRFlags::Hidden);
+    lcl_syncFlags(*mpFilteredCols, *mpFilteredRows, pColFlags.get(), pRowFlags, CRFlags::Filtered);
 }
 
 void ScTable::SetPageSize( const Size& rSize )
diff --git a/sc/source/core/inc/bcaslot.hxx b/sc/source/core/inc/bcaslot.hxx
index ce5f33384124..af2fdaf540b0 100644
--- a/sc/source/core/inc/bcaslot.hxx
+++ b/sc/source/core/inc/bcaslot.hxx
@@ -265,17 +265,17 @@ private:
     public:
                                         TableSlots();
                                         ~TableSlots();
-        ScBroadcastAreaSlot**    getSlots() { return ppSlots; }
+        ScBroadcastAreaSlot**    getSlots() { return ppSlots.get(); }
 
         /**
             Obtain slot pointer, no check on validity! It is assumed that
             all calls are made with the results of ComputeSlotOffset(),
             ComputeAreaPoints() and ComputeNextSlot()
           */
-        ScBroadcastAreaSlot*     getAreaSlot( SCSIZE nOff ) { return *(ppSlots + nOff); }
+        ScBroadcastAreaSlot*     getAreaSlot( SCSIZE nOff ) { return ppSlots[nOff]; }
 
     private:
-        ScBroadcastAreaSlot**   ppSlots;
+        std::unique_ptr<ScBroadcastAreaSlot*[]>   ppSlots;
 
         TableSlots( const TableSlots& ) = delete;
         TableSlots& operator=( const TableSlots& ) = delete;
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 40b6a836adfa..eb4fe52f3ebc 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -440,9 +440,8 @@ ScAutoFormatData::ScAutoFormatData()
     bIncludeBackground =
     bIncludeWidthHeight = true;
 
-    ppDataField = new ScAutoFormatDataField*[ 16 ];
     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
-        ppDataField[ nIndex ] = new ScAutoFormatDataField;
+        ppDataField[ nIndex ].reset( new ScAutoFormatDataField );
 }
 
 ScAutoFormatData::ScAutoFormatData( const ScAutoFormatData& rData ) :
@@ -455,29 +454,25 @@ ScAutoFormatData::ScAutoFormatData( const ScAutoFormatData& rData ) :
         bIncludeValueFormat( rData.bIncludeValueFormat ),
         bIncludeWidthHeight( rData.bIncludeWidthHeight )
 {
-    ppDataField = new ScAutoFormatDataField*[ 16 ];
     for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
-        ppDataField[ nIndex ] = new ScAutoFormatDataField( rData.GetField( nIndex ) );
+        ppDataField[ nIndex ].reset( new ScAutoFormatDataField( rData.GetField( nIndex ) ) );
 }
 
 ScAutoFormatData::~ScAutoFormatData()
 {
-    for( sal_uInt16 nIndex = 0; nIndex < 16; ++nIndex )
-        delete ppDataField[ nIndex ];
-    delete[] ppDataField;
 }
 
 ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex )
 {
     OSL_ENSURE( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
-    OSL_ENSURE( ppDataField && ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
+    OSL_ENSURE( ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
     return *ppDataField[ nIndex ];
 }
 
 const ScAutoFormatDataField& ScAutoFormatData::GetField( sal_uInt16 nIndex ) const
 {
     OSL_ENSURE( nIndex < 16, "ScAutoFormatData::GetField - illegal index" );
-    OSL_ENSURE( ppDataField && ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
+    OSL_ENSURE( ppDataField[ nIndex ], "ScAutoFormatData::GetField - no data" );
     return *ppDataField[ nIndex ];
 }
 
diff --git a/sc/source/core/tool/chartarr.cxx b/sc/source/core/tool/chartarr.cxx
index 06463aef0709..ef89cbeb0710 100644
--- a/sc/source/core/tool/chartarr.cxx
+++ b/sc/source/core/tool/chartarr.cxx
@@ -43,13 +43,9 @@ ScMemChart::ScMemChart(SCCOL nCols, SCROW nRows)
 {
     nRowCnt = nRows;
     nColCnt = nCols;
-    pData   = new double[nColCnt * nRowCnt];
+    pData.reset( new double[nColCnt * nRowCnt] );
 
-    double *pFill = pData;
-
-    for (SCCOL i = 0; i < nColCnt; i++)
-        for (SCROW j = 0; j < nRowCnt; j++)
-            *(pFill ++) = 0.0;
+    memset( pData.get(), 0.0, nColCnt * nRowCnt );
 
     pColText = new OUString[nColCnt];
     pRowText = new OUString[nRowCnt];
@@ -59,7 +55,6 @@ ScMemChart::~ScMemChart()
 {
     delete[] pRowText;
     delete[] pColText;
-    delete[] pData;
 }
 
 ScChartArray::ScChartArray( ScDocument* pDoc, SCTAB nTab,
diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx
index 5ab46a12e6a2..b441563237d5 100644
--- a/sc/source/core/tool/chartpos.cxx
+++ b/sc/source/core/tool/chartpos.cxx
@@ -567,20 +567,14 @@ ScChartPositionMap::~ScChartPositionMap()
     {
         delete ppData[nIndex];
     }
-    delete [] ppData;
-
-    SCCOL j;
-    for ( j=0; j < nColCount; j++ )
+    for ( SCCOL j=0; j < nColCount; j++ )
     {
         delete ppColHeader[j];
     }
-    delete [] ppColHeader;
-    SCROW i;
-    for ( i=0; i < nRowCount; i++ )
+    for ( SCROW i=0; i < nRowCount; i++ )
     {
         delete ppRowHeader[i];
     }
-    delete [] ppRowHeader;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/chgtrack.cxx b/sc/source/core/tool/chgtrack.cxx
index 5d567b5bd464..5e208027f0ef 100644
--- a/sc/source/core/tool/chgtrack.cxx
+++ b/sc/source/core/tool/chgtrack.cxx
@@ -2076,8 +2076,8 @@ ScChangeTrack::ScChangeTrack( ScDocument* pDocP ) :
     Init();
     SC_MOD()->GetUserOptions().AddListener(this);
 
-    ppContentSlots = new ScChangeActionContent* [ nContentSlots ];
-    memset( ppContentSlots, 0, nContentSlots * sizeof( ScChangeActionContent* ) );
+    ppContentSlots.reset( new ScChangeActionContent* [ nContentSlots ] );
+    memset( ppContentSlots.get(), 0, nContentSlots * sizeof( ScChangeActionContent* ) );
 }
 
 ScChangeTrack::ScChangeTrack( ScDocument* pDocP, const std::set<OUString>& aTempUserCollection) :
@@ -2087,15 +2087,14 @@ ScChangeTrack::ScChangeTrack( ScDocument* pDocP, const std::set<OUString>& aTemp
 {
     Init();
     SC_MOD()->GetUserOptions().AddListener(this);
-    ppContentSlots = new ScChangeActionContent* [ nContentSlots ];
-    memset( ppContentSlots, 0, nContentSlots * sizeof( ScChangeActionContent* ) );
+    ppContentSlots.reset( new ScChangeActionContent* [ nContentSlots ] );
+    memset( ppContentSlots.get(), 0, nContentSlots * sizeof( ScChangeActionContent* ) );
 }
 
 ScChangeTrack::~ScChangeTrack()
 {
     SC_MOD()->GetUserOptions().RemoveListener(this);
     DtorClear();
-    delete [] ppContentSlots;
 }
 
 void ScChangeTrack::Init()
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx
index cadcc34df828..b661a220ec27 100644
--- a/sc/source/core/tool/interpr8.cxx
+++ b/sc/source/core/tool/interpr8.cxx
@@ -74,10 +74,10 @@ class ScETSForecastCalculation
 private:
     SvNumberFormatter* mpFormatter;
     std::vector< DataPoint > maRange;   // data (X, Y)
-    double* mpBase;                     // calculated base value array
-    double* mpTrend;                    // calculated trend factor array
-    double* mpPerIdx;                   // calculated periodical deviation array, not used with eds
-    double* mpForecast;                 // forecasted value array
+    std::unique_ptr<double[]> mpBase;                     // calculated base value array
+    std::unique_ptr<double[]> mpTrend;                    // calculated trend factor array
+    std::unique_ptr<double[]> mpPerIdx;                   // calculated periodical deviation array, not used with eds
+    std::unique_ptr<double[]> mpForecast;                 // forecasted value array
     SCSIZE mnSmplInPrd;                 // samples per period
     double mfStepSize;                  // increment of X in maRange
     double mfAlpha, mfBeta, mfGamma;    // constants to minimise the RMSE in the ES-equations
@@ -115,7 +115,6 @@ private:
 
 public:
     ScETSForecastCalculation( SCSIZE nSize, SvNumberFormatter* pFormatter );
-    ~ScETSForecastCalculation();
 
     bool PreprocessDataRange( const ScMatrixRef& rMatX, const ScMatrixRef& rMatY, int& rSmplInPrd,
                               bool bDataCompletion, int nAggregation, const ScMatrixRef& rTMat,
@@ -154,14 +153,6 @@ ScETSForecastCalculation::ScETSForecastCalculation( SCSIZE nSize, SvNumberFormat
     maRange.reserve( mnCount );
 }
 
-ScETSForecastCalculation::~ScETSForecastCalculation()
-{
-    delete[] mpBase;
-    delete[] mpTrend;
-    delete[] mpPerIdx;
-    delete[] mpForecast;
-}
-
 bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, const ScMatrixRef& rMatY, int& rSmplInPrd,
                                                     bool bDataCompletion, int nAggregation, const ScMatrixRef& rTMat,
                                                     ScETSType eETSType )
@@ -393,11 +384,11 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co
 bool ScETSForecastCalculation::initData( )
 {
     // give various vectors size and initial value
-    mpBase     = new double[ mnCount ];
-    mpTrend    = new double[ mnCount ];
+    mpBase.reset( new double[ mnCount ] );
+    mpTrend.reset( new double[ mnCount ] );
     if ( !bEDS )
-        mpPerIdx   = new double[ mnCount ];
-    mpForecast = new double[ mnCount ];
+        mpPerIdx.reset( new double[ mnCount ] );
+    mpForecast.reset( new double[ mnCount ] );
     mpForecast[ 0 ] = maRange[ 0 ].Y;
 
     if ( prefillTrendData() )
diff --git a/sc/source/core/tool/rechead.cxx b/sc/source/core/tool/rechead.cxx
index 15c947d84a86..7ce4fcbff686 100644
--- a/sc/source/core/tool/rechead.cxx
+++ b/sc/source/core/tool/rechead.cxx
@@ -48,9 +48,9 @@ ScMultipleReadHeader::ScMultipleReadHeader(SvStream& rNewStream) :
     {
         sal_uInt32 nSizeTableLen;
         rStream.ReadUInt32( nSizeTableLen );
-        pBuf = new sal_uInt8[nSizeTableLen];
-        rStream.ReadBytes( pBuf, nSizeTableLen );
-        pMemStream = new SvMemoryStream( pBuf, nSizeTableLen, StreamMode::READ );
+        pBuf.reset( new sal_uInt8[nSizeTableLen] );
+        rStream.ReadBytes( pBuf.get(), nSizeTableLen );
+        pMemStream = new SvMemoryStream( pBuf.get(), nSizeTableLen, StreamMode::READ );
     }
 
     nEndPos = rStream.Tell();
@@ -66,7 +66,6 @@ ScMultipleReadHeader::~ScMultipleReadHeader()
             rStream.SetError( SCWARN_IMPORT_INFOLOST );
     }
     delete pMemStream;
-    delete[] pBuf;
 
     rStream.Seek(nEndPos);
 }
diff --git a/sc/source/filter/dif/difimp.cxx b/sc/source/filter/dif/difimp.cxx
index 5df754cc6f94..2603e06bf4ae 100644
--- a/sc/source/filter/dif/difimp.cxx
+++ b/sc/source/filter/dif/difimp.cxx
@@ -668,38 +668,28 @@ void DifColumn::Apply( ScDocument& rDoc, const SCCOL nCol, const SCTAB nTab )
 
 DifAttrCache::DifAttrCache()
 {
-    ppCols = new DifColumn *[ MAXCOL + 1 ];
-    for( SCCOL nCnt = 0 ; nCnt <= MAXCOL ; nCnt++ )
-        ppCols[ nCnt ] = nullptr;
 }
 
 DifAttrCache::~DifAttrCache()
 {
-    for( SCCOL nCnt = 0 ; nCnt <= MAXCOL ; nCnt++ )
-    {
-        if( ppCols[ nCnt ] )
-            delete ppCols[ nCnt ];
-    }
-
-    delete[] ppCols;
 }
 
 void DifAttrCache::SetNumFormat( const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat )
 {
     OSL_ENSURE( ValidCol(nCol), "-DifAttrCache::SetNumFormat(): Col too big!" );
 
-    if( !ppCols[ nCol ] )
-        ppCols[ nCol ] = new DifColumn;
+    if( !mvCols[ nCol ] )
+        mvCols[ nCol ].reset( new DifColumn );
 
-    ppCols[ nCol ]->SetNumFormat( nRow, nNumFormat );
+    mvCols[ nCol ]->SetNumFormat( nRow, nNumFormat );
 }
 
 void DifAttrCache::Apply( ScDocument& rDoc, SCTAB nTab )
 {
     for( SCCOL nCol = 0 ; nCol <= MAXCOL ; nCol++ )
     {
-        if( ppCols[ nCol ] )
-            ppCols[ nCol ]->Apply( rDoc, nCol, nTab );
+        if( mvCols[ nCol ] )
+            mvCols[ nCol ]->Apply( rDoc, nCol, nTab );
     }
 }
 
diff --git a/sc/source/filter/inc/dif.hxx b/sc/source/filter/inc/dif.hxx
index 082915570da9..cca74ecd6aa4 100644
--- a/sc/source/filter/inc/dif.hxx
+++ b/sc/source/filter/inc/dif.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_SC_SOURCE_FILTER_INC_DIF_HXX
 #define INCLUDED_SC_SOURCE_FILTER_INC_DIF_HXX
 
+#include <array>
+#include <memory>
 #include <vector>
 
 #include <rtl/ustring.hxx>
@@ -162,7 +164,7 @@ public:
 
 private:
 
-    DifColumn**         ppCols;
+    std::array<std::unique_ptr<DifColumn>,MAXCOL + 1> mvCols;
 };
 
 #endif
diff --git a/sc/source/ui/dbgui/asciiopt.cxx b/sc/source/ui/dbgui/asciiopt.cxx
index acccdfb55bb3..b104af3b7979 100644
--- a/sc/source/ui/dbgui/asciiopt.cxx
+++ b/sc/source/ui/dbgui/asciiopt.cxx
@@ -36,10 +36,7 @@ ScAsciiOptions::ScAsciiOptions() :
     eCharSet        ( osl_getThreadTextEncoding() ),
     eLang           ( LANGUAGE_SYSTEM ),
     bCharSetSystem  ( false ),
-    nStartRow       ( 1 ),
-    nInfoCount      ( 0 ),
-    pColStart       ( nullptr ),
-    pColFormat      ( nullptr )
+    nStartRow       ( 1 )
 {
 }
 
@@ -54,78 +51,41 @@ ScAsciiOptions::ScAsciiOptions(const ScAsciiOptions& rOpt) :
     eLang           ( rOpt.eLang ),
     bCharSetSystem  ( rOpt.bCharSetSystem ),
     nStartRow       ( rOpt.nStartRow ),
-    nInfoCount      ( rOpt.nInfoCount )
+    mvColStart      ( rOpt.mvColStart ),
+    mvColFormat     ( rOpt.mvColFormat )
 {
-    if (nInfoCount)
-    {
-        pColStart = new sal_Int32[nInfoCount];
-        pColFormat = new sal_uInt8[nInfoCount];
-        for (sal_uInt16 i=0; i<nInfoCount; i++)
-        {
-            pColStart[i] = rOpt.pColStart[i];
-            pColFormat[i] = rOpt.pColFormat[i];
-        }
-    }
-    else
-    {
-        pColStart = nullptr;
-        pColFormat = nullptr;
-    }
 }
 
 ScAsciiOptions::~ScAsciiOptions()
 {
-    delete[] pColStart;
-    delete[] pColFormat;
 }
 
 void ScAsciiOptions::SetColInfo( sal_uInt16 nCount, const sal_Int32* pStart, const sal_uInt8* pFormat )
 {
-    delete[] pColStart;
-    delete[] pColFormat;
-
-    nInfoCount = nCount;
-
-    if (nInfoCount)
+    mvColStart.resize(nCount);
+    mvColFormat.resize(nCount);
+    for (sal_uInt16 i=0; i<nCount; i++)
     {
-        pColStart = new sal_Int32[nInfoCount];
-        pColFormat = new sal_uInt8[nInfoCount];
-        for (sal_uInt16 i=0; i<nInfoCount; i++)
-        {
-            pColStart[i] = pStart[i];
-            pColFormat[i] = pFormat[i];
-        }
-    }
-    else
-    {
-        pColStart = nullptr;
-        pColFormat = nullptr;
+        mvColStart[i] = pStart[i];
+        mvColFormat[i] = pFormat[i];
     }
 }
 
 void ScAsciiOptions::SetColumnInfo( const ScCsvExpDataVec& rDataVec )
 {
-    delete[] pColStart;
-    pColStart = nullptr;
-    delete[] pColFormat;
-    pColFormat = nullptr;
-
-    nInfoCount = static_cast< sal_uInt16 >( rDataVec.size() );
-    if( nInfoCount )
+    sal_uInt16 nInfoCount = static_cast< sal_uInt16 >( rDataVec.size() );
+    mvColStart.resize(nInfoCount);
+    mvColFormat.resize(nInfoCount);
+    for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx )
     {
-        pColStart = new sal_Int32[ nInfoCount ];
-        pColFormat = new sal_uInt8[ nInfoCount ];
-        for( sal_uInt16 nIx = 0; nIx < nInfoCount; ++nIx )
-        {
-            pColStart[ nIx ] = rDataVec[ nIx ].mnIndex;
-            pColFormat[ nIx ] = rDataVec[ nIx ].mnType;
-        }
+        mvColStart[ nIx ] = rDataVec[ nIx ].mnIndex;
+        mvColFormat[ nIx ] = rDataVec[ nIx ].mnType;
     }
 }
 
 ScAsciiOptions& ScAsciiOptions::operator=( const ScAsciiOptions& rCpy )
 {
-    SetColInfo( rCpy.nInfoCount, rCpy.pColStart, rCpy.pColFormat );
+    SetColInfo( rCpy.mvColStart.size(), rCpy.mvColStart.data(), rCpy.mvColFormat.data() );
 
     bFixedLen       = rCpy.bFixedLen;
     aFieldSeps      = rCpy.aFieldSeps;
@@ -203,27 +163,16 @@ void ScAsciiOptions::ReadFromString( const OUString& rString )
     // Token 4: Column info.
     if ( nPos >= 0 )
     {
-        delete[] pColStart;
-        delete[] pColFormat;
-
         const OUString aToken = rString.getToken(0, ',', nPos);
         sal_Int32 nSub = comphelper::string::getTokenCount(aToken, '/');
-        nInfoCount = nSub / 2;
-        if (nInfoCount)
-        {
-            pColStart = new sal_Int32[nInfoCount];
-            pColFormat = new sal_uInt8[nInfoCount];
-            sal_Int32 nP = 0;
-            for (sal_Int32 nInfo=0; nInfo<nInfoCount; ++nInfo)
-            {
-                pColStart[nInfo]  = aToken.getToken(0, '/', nP).toInt32();
-                pColFormat[nInfo] = static_cast<sal_uInt8>(aToken.getToken(0, '/', nP).toInt32());
-            }
-        }
-        else
+        sal_Int32 nInfoCount = nSub / 2;
+        mvColStart.resize(nInfoCount);
+        mvColFormat.resize(nInfoCount);
+        sal_Int32 nP = 0;
+        for (sal_Int32 nInfo=0; nInfo<nInfoCount; ++nInfo)
         {
-            pColStart = nullptr;
-            pColFormat = nullptr;
+            mvColStart[nInfo]  = aToken.getToken(0, '/', nP).toInt32();
+            mvColFormat[nInfo] = static_cast<sal_uInt8>(aToken.getToken(0, '/', nP).toInt32());
         }
     }
 
@@ -289,14 +238,13 @@ OUString ScAsciiOptions::WriteToString() const
     aOutStr += "," + OUString::number(nStartRow) + ",";
 
     // Column info.
-    OSL_ENSURE( !nInfoCount || (pColStart && pColFormat), "NULL pointer in ScAsciiOptions column info" );
-    for (sal_uInt16 nInfo=0; nInfo<nInfoCount; nInfo++)
+    for (size_t nInfo=0; nInfo<mvColStart.size(); nInfo++)
     {
         if (nInfo)
             aOutStr += "/";
-        aOutStr += OUString::number(pColStart[nInfo]) +
+        aOutStr += OUString::number(mvColStart[nInfo]) +
                    "/" +
-                   OUString::number(pColFormat[nInfo]);
+                   OUString::number(mvColFormat[nInfo]);
     }
 
     // #i112025# the options string is used in macros and linked sheets,
diff --git a/sc/source/ui/docshell/pagedata.cxx b/sc/source/ui/docshell/pagedata.cxx
index 143c1e50119f..94ce9277776c 100644
--- a/sc/source/ui/docshell/pagedata.cxx
+++ b/sc/source/ui/docshell/pagedata.cxx
@@ -25,43 +25,24 @@
 
 ScPrintRangeData::ScPrintRangeData()
 {
-    nPagesX = nPagesY = 0;
-    pPageEndX = nullptr;
-    pPageEndY = nullptr;
     bTopDown = bAutomatic = true;
     nFirstPage = 1;
 }
 
 ScPrintRangeData::~ScPrintRangeData()
 {
-    delete[] pPageEndX;
-    delete[] pPageEndY;
 }
 
 void ScPrintRangeData::SetPagesX( size_t nCount, const SCCOL* pData )
 {
-    delete[] pPageEndX;
-    if ( nCount )
-    {
-        pPageEndX = new SCCOL[nCount];
-        memcpy( pPageEndX, pData, nCount * sizeof(SCCOL) );
-    }
-    else
-        pPageEndX = nullptr;
-    nPagesX = nCount;
+    mvPageEndX.resize( nCount );
+    memcpy( mvPageEndX.data(), pData, nCount * sizeof(SCCOL) );
 }
 
 void ScPrintRangeData::SetPagesY( size_t nCount, const SCROW* pData )
 {
-    delete[] pPageEndY;
-    if ( nCount )
-    {
-        pPageEndY = new SCROW[nCount];
-        memcpy( pPageEndY, pData, nCount * sizeof(SCROW) );
-    }
-    else
-        pPageEndY = nullptr;
-    nPagesY = nCount;
+    mvPageEndY.resize(nCount);
+    memcpy( mvPageEndY.data(), pData, nCount * sizeof(SCROW) );
 }
 
 ScPageBreakData::ScPageBreakData(size_t nMax)
diff --git a/sc/source/ui/inc/asciiopt.hxx b/sc/source/ui/inc/asciiopt.hxx
index 551b5f277990..61308a9fe7d2 100644
--- a/sc/source/ui/inc/asciiopt.hxx
+++ b/sc/source/ui/inc/asciiopt.hxx
@@ -38,9 +38,8 @@ private:
     LanguageType eLang;
     bool        bCharSetSystem;
     long        nStartRow;
-    sal_uInt16      nInfoCount;
-    sal_Int32* pColStart;  //! TODO replace with vector
-    sal_uInt8*       pColFormat; //! TODO replace with vector
+    std::vector<sal_Int32> mvColStart;
+    std::vector<sal_uInt8> mvColFormat;
 
 public:
                     ScAsciiOptions();
@@ -61,9 +60,9 @@ public:
     bool                IsDetectSpecialNumber() const { return bDetectSpecialNumber; }
     sal_Unicode         GetTextSep() const      { return cTextSep; }
     bool                IsFixedLen() const      { return bFixedLen; }
-    sal_uInt16          GetInfoCount() const    { return nInfoCount; }
-    const sal_Int32*    GetColStart() const     { return pColStart; }
-    const sal_uInt8*    GetColFormat() const    { return pColFormat; }
+    sal_uInt16          GetInfoCount() const    { return mvColStart.size(); }
+    const sal_Int32*    GetColStart() const     { return mvColStart.data(); }
+    const sal_uInt8*    GetColFormat() const    { return mvColFormat.data(); }
     long                GetStartRow() const     { return nStartRow; }
     LanguageType        GetLanguage() const     { return eLang; }
 
diff --git a/sc/source/ui/inc/pagedata.hxx b/sc/source/ui/inc/pagedata.hxx
index 7dce22202e32..ffca7fe86cd2 100644
--- a/sc/source/ui/inc/pagedata.hxx
+++ b/sc/source/ui/inc/pagedata.hxx
@@ -20,25 +20,26 @@
 #ifndef INCLUDED_SC_SOURCE_UI_INC_PAGEDATA_HXX
 #define INCLUDED_SC_SOURCE_UI_INC_PAGEDATA_HXX
 
-#include <memory>
 #include "global.hxx"
 #include "address.hxx"
+#include <memory>
+#include <vector>
 
 class ScPrintRangeData
 {
 private:
     ScRange     aPrintRange;
-    size_t      nPagesX;
-    SCCOL*      pPageEndX;
-    size_t      nPagesY;
-    SCROW*      pPageEndY;
+    std::vector<SCCOL>
+                mvPageEndX;
+    std::vector<SCROW>
+                mvPageEndY;
     long        nFirstPage;
     bool        bTopDown;
     bool        bAutomatic;
 
 public:
-                ScPrintRangeData();
-                ~ScPrintRangeData();
+                    ScPrintRangeData();
+                    ~ScPrintRangeData();
 
     void            SetPrintRange( const ScRange& rNew )    { aPrintRange = rNew; }
     const ScRange&  GetPrintRange() const                   { return aPrintRange; }
@@ -46,10 +47,10 @@ public:
     void            SetPagesX( size_t nCount, const SCCOL* pEnd );
     void            SetPagesY( size_t nCount, const SCROW* pEnd );
 
-    size_t          GetPagesX() const       { return nPagesX;   }
-    const SCCOL*    GetPageEndX() const     { return pPageEndX; }
-    size_t          GetPagesY() const       { return nPagesY;   }
-    const SCROW*    GetPageEndY() const     { return pPageEndY; }
+    size_t          GetPagesX() const       { return mvPageEndX.size();   }
+    const SCCOL*    GetPageEndX() const     { return mvPageEndX.data(); }
+    size_t          GetPagesY() const       { return mvPageEndY.size();   }
+    const SCROW*    GetPageEndY() const     { return mvPageEndY.data(); }
 
     void            SetFirstPage( long nNew )   { nFirstPage = nNew; }
     long            GetFirstPage() const        { return nFirstPage; }
diff --git a/sc/source/ui/inc/prevloc.hxx b/sc/source/ui/inc/prevloc.hxx
index 419deb6e003c..a6ffc80489c8 100644
--- a/sc/source/ui/inc/prevloc.hxx
+++ b/sc/source/ui/inc/prevloc.hxx
@@ -65,8 +65,10 @@ class ScPreviewTableInfo
     SCTAB                   nTab;
     SCCOL                   nCols;
     SCROW                   nRows;
-    ScPreviewColRowInfo*    pColInfo;
-    ScPreviewColRowInfo*    pRowInfo;
+    std::unique_ptr<ScPreviewColRowInfo[]>
+                            pColInfo;
+    std::unique_ptr<ScPreviewColRowInfo[]>
+                            pRowInfo;
 
 public:
             ScPreviewTableInfo();
@@ -75,8 +77,8 @@ public:
     SCTAB                       GetTab() const      { return nTab; }
     SCCOL                       GetCols() const     { return nCols; }
     SCROW                       GetRows() const     { return nRows; }
-    const ScPreviewColRowInfo*  GetColInfo() const  { return pColInfo; }
-    const ScPreviewColRowInfo*  GetRowInfo() const  { return pRowInfo; }
+    const ScPreviewColRowInfo*  GetColInfo() const  { return pColInfo.get(); }
+    const ScPreviewColRowInfo*  GetRowInfo() const  { return pRowInfo.get(); }
 
     void    SetTab( SCTAB nNewTab );
     void    SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo );
diff --git a/sc/source/ui/inc/undoblk.hxx b/sc/source/ui/inc/undoblk.hxx
index 1dd470ff264f..9b89e55a2fde 100644
--- a/sc/source/ui/inc/undoblk.hxx
+++ b/sc/source/ui/inc/undoblk.hxx
@@ -60,12 +60,15 @@ public:
 private:
     ScRange         aEffRange;
     SCTAB           nCount;
-    SCTAB*          pTabs;
-    SCTAB*          pScenarios;
+    std::unique_ptr<SCTAB[]>
+                    pTabs;
+    std::unique_ptr<SCTAB[]>
+                    pScenarios;
     sal_uLong       nEndChangeAction;
     InsCellCmd      eCmd;
     bool            bPartOfPaste;
-    SfxUndoAction*  pPasteUndo;
+    std::unique_ptr<SfxUndoAction>
+                    pPasteUndo;
 
     void            DoChange ( const bool bUndo );
     void            SetChangeTrack();
@@ -89,8 +92,10 @@ public:
 private:
     ScRange         aEffRange;
     SCTAB           nCount;
-    SCTAB*          pTabs;
-    SCTAB*          pScenarios;
+    std::unique_ptr<SCTAB[]>
+                    pTabs;
+    std::unique_ptr<SCTAB[]>
+                    pScenarios;
     sal_uLong       nStartChangeAction;
     sal_uLong       nEndChangeAction;
     DelCellCmd      eCmd;
diff --git a/sc/source/ui/undo/undoblk.cxx b/sc/source/ui/undo/undoblk.cxx
index 5d4444dd06b3..4696623ead07 100644
--- a/sc/source/ui/undo/undoblk.cxx
+++ b/sc/source/ui/undo/undoblk.cxx
@@ -96,9 +96,6 @@ ScUndoInsertCells::ScUndoInsertCells( ScDocShell* pNewDocShell,
 
 ScUndoInsertCells::~ScUndoInsertCells()
 {
-    delete pPasteUndo;
-    delete []pTabs;
-    delete []pScenarios;
 }
 
 OUString ScUndoInsertCells::GetComment() const
@@ -121,7 +118,7 @@ bool ScUndoInsertCells::Merge( SfxUndoAction* pNextAction )
             //  Store paste action if this is part of paste with inserting cells.
             //  A list action isn't used because Repeat wouldn't work (insert wrong cells).
 
-            pPasteUndo = pWrappedAction;
+            pPasteUndo.reset( pWrappedAction );
             pWrapper->ForgetWrappedUndo();      // pWrapper is deleted by UndoManager
             return true;
         }
@@ -352,8 +349,6 @@ ScUndoDeleteCells::ScUndoDeleteCells( ScDocShell* pNewDocShell,
 
 ScUndoDeleteCells::~ScUndoDeleteCells()
 {
-    delete []pTabs;
-    delete []pScenarios;
 }
 
 OUString ScUndoDeleteCells::GetComment() const
diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 5fea40a60d51..68a1ec5fb461 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -1532,8 +1532,8 @@ void ScGridWindow::DrawButtons(SCCOL nX1, SCCOL nX2, const ScTableInfo& rTabInfo
     ScDBData*       pDBData = nullptr;
     std::unique_ptr<ScQueryParam> pQueryParam;
 
-    RowInfo*        pRowInfo = rTabInfo.mpRowInfo;
-    sal_uInt16          nArrCount = rTabInfo.mnArrCount;
+    RowInfo*        pRowInfo = rTabInfo.mpRowInfo.get();
+    sal_uInt16      nArrCount = rTabInfo.mnArrCount;
 
     bool bLayoutRTL = pDoc->IsLayoutRTL( nTab );
 
diff --git a/sc/source/ui/view/output.cxx b/sc/source/ui/view/output.cxx
index 8c656ca45bb7..900d880ccee7 100644
--- a/sc/source/ui/view/output.cxx
+++ b/sc/source/ui/view/output.cxx
@@ -150,7 +150,7 @@ ScOutputData::ScOutputData( OutputDevice* pNewDev, ScOutputType eNewType,
     mpRefDevice( pNewDev ),      // default is output device
     pFmtDevice( pNewDev ),      // default is output device
     mrTabInfo( rTabInfo ),
-    pRowInfo( rTabInfo.mpRowInfo ),
+    pRowInfo( rTabInfo.mpRowInfo.get() ),
     nArrCount( rTabInfo.mnArrCount ),
     mpDoc( pNewDoc ),
     nTab( nNewTab ),
diff --git a/sc/source/ui/view/prevloc.cxx b/sc/source/ui/view/prevloc.cxx
index 4c9f6ed18450..f929a4e24e58 100644
--- a/sc/source/ui/view/prevloc.cxx
+++ b/sc/source/ui/view/prevloc.cxx
@@ -67,8 +67,6 @@ ScPreviewTableInfo::ScPreviewTableInfo() :
 
 ScPreviewTableInfo::~ScPreviewTableInfo()
 {
-    delete[] pColInfo;
-    delete[] pRowInfo;
 }
 
 void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
@@ -78,15 +76,13 @@ void ScPreviewTableInfo::SetTab( SCTAB nNewTab )
 
 void ScPreviewTableInfo::SetColInfo( SCCOL nCount, ScPreviewColRowInfo* pNewInfo )
 {
-    delete[] pColInfo;
-    pColInfo = pNewInfo;
+    pColInfo.reset(pNewInfo);
     nCols = nCount;
 }
 
 void ScPreviewTableInfo::SetRowInfo( SCROW nCount, ScPreviewColRowInfo* pNewInfo )
 {
-    delete[] pRowInfo;
-    pRowInfo = pNewInfo;
+    pRowInfo.reset(pNewInfo);
     nRows = nCount;
 }
 


More information about the Libreoffice-commits mailing list