summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-11 14:05:10 +0200
committerAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-11-28 00:12:50 -0500
commiteb0e8093c325f895f735626ac1326b5e7a1d88b2 (patch)
treec5bee2fb011fa0cc7394d37659330c4ee286153b /sc
parente525637657bd905a37a16cb530a47aad3042d4b5 (diff)
new loplugin: useuniqueptr: sc part 1
Change-Id: Ic96fd3b56b2063df0882168a7d02725d3c50515f Reviewed-on: https://gerrit.libreoffice.org/32961 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 414ede0435645a2ebf8f1476435b6ec3bb248f33)
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/addincol.hxx5
-rw-r--r--sc/inc/appoptio.hxx7
-rw-r--r--sc/inc/attrib.hxx2
-rw-r--r--sc/inc/chartpos.hxx15
-rw-r--r--sc/inc/chgviset.hxx3
-rw-r--r--sc/inc/dociter.hxx9
-rw-r--r--sc/inc/dpgroup.hxx3
-rw-r--r--sc/inc/dpresfilter.hxx2
-rw-r--r--sc/inc/dpsave.hxx4
-rw-r--r--sc/inc/dptabres.hxx15
-rw-r--r--sc/inc/dptabsrc.hxx3
-rw-r--r--sc/inc/editutil.hxx2
-rw-r--r--sc/inc/paramisc.hxx8
-rw-r--r--sc/inc/patattr.hxx7
-rw-r--r--sc/inc/prnsave.hxx5
-rw-r--r--sc/inc/rangenam.hxx7
-rw-r--r--sc/source/core/data/attrib.cxx11
-rw-r--r--sc/source/core/data/dociter.cxx26
-rw-r--r--sc/source/core/data/dpgroup.cxx3
-rw-r--r--sc/source/core/data/dpresfilter.cxx8
-rw-r--r--sc/source/core/data/dpsave.cxx14
-rw-r--r--sc/source/core/data/dptabres.cxx10
-rw-r--r--sc/source/core/data/dptabsrc.cxx8
-rw-r--r--sc/source/core/data/global2.cxx7
-rw-r--r--sc/source/core/data/patattr.cxx17
-rw-r--r--sc/source/core/inc/addinlis.hxx2
-rw-r--r--sc/source/core/tool/addincol.cxx11
-rw-r--r--sc/source/core/tool/addinlis.cxx7
-rw-r--r--sc/source/core/tool/appoptio.cxx12
-rw-r--r--sc/source/core/tool/callform.cxx6
-rw-r--r--sc/source/core/tool/chartpos.cxx16
-rw-r--r--sc/source/core/tool/chgviset.cxx9
-rw-r--r--sc/source/core/tool/editutil.cxx5
-rw-r--r--sc/source/core/tool/prnsave.cxx5
-rw-r--r--sc/source/core/tool/rangenam.cxx9
35 files changed, 120 insertions, 163 deletions
diff --git a/sc/inc/addincol.hxx b/sc/inc/addincol.hxx
index 49d30b6a7b7a..79150156f969 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 5bc668a24629..d3d6f5ba61eb 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 3b71b8c79aa4..83235acd0e6f 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 18c40aee8e53..664cbc966c08 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 ee61570f4248..68e144d9059d 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 f3142781a61c..04d04b60e29f 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 e45f3f45eda9..1eddcf931e34 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 82c2862229df..0ab75d433b88 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 663bcb2d724d..8338e0ef4862 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 65dbf5dbb4d1..7b6e7d1d5aaa 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 48c0714e915a..26e949a813b7 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 e71976eb2b51..00f0029d3eba 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/paramisc.hxx b/sc/inc/paramisc.hxx
index 0a21a1db83a6..5853051a4abd 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 3f75827a75c8..05bfc926c6ac 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 9bdbc28ecfd0..463a424451ad 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 a1924de86a26..19c288b8ac87 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 9da829353099..65a8b589686c 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 8bbb121de8fe..b02004948ac9 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 cf3cfbf407e8..813fe5e312d2 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -481,12 +481,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 d119f09138a8..163782a94157 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 54f98850c2de..d93a754c71bf 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 c20c2a94160d..b62c88b4af8d 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 8285aa11b187..5498b7e55385 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 b4b189b60de7..d19535b8c773 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/patattr.cxx b/sc/source/core/data/patattr.cxx
index 23e451d60521..133b9809eb33 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 9f1c36db9770..5f451f518f51 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 15c4e92bfb27..3eaa8155e01b 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 73e73a6367f6..403fb9185c50 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 b1d6e94b6546..9b7a958c2167 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 d79e98f2902e..06884c56b6af 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 cd891b5616e6..fa95a3553acb 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 938c26591e62..a9016d1ed16b 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 0922d00741dd..fa0f99d22329 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 911b411846a7..7cc5359713bc 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 eae117c08434..d7fba04de639 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();
}