summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-11 14:26:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-01-13 08:34:03 +0000
commita706bb06d5326e7a997dd1d71f3f947bd0ad28e6 (patch)
tree8ac34dea4e7e4106d3adbccc6a604b611928ffbe /sw
parent8c73acd101c80a4479f25e35278a451dc3c4b22e (diff)
new loplugin: useuniqueptr: sw part 1
Change-Id: I2bc55634e80976951ede768c97fbc4b7c4eda46c Reviewed-on: https://gerrit.libreoffice.org/32963 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/EnhancedPDFExportHelper.hxx2
-rw-r--r--sw/inc/anchoreddrawobject.hxx4
-rw-r--r--sw/inc/calc.hxx2
-rw-r--r--sw/inc/cellfml.hxx2
-rw-r--r--sw/inc/dpage.hxx4
-rw-r--r--sw/inc/expfld.hxx6
-rw-r--r--sw/inc/fmtcntnt.hxx4
-rw-r--r--sw/inc/fmturl.hxx7
-rw-r--r--sw/inc/list.hxx3
-rw-r--r--sw/inc/ndnotxt.hxx2
-rw-r--r--sw/inc/numrule.hxx2
-rw-r--r--sw/inc/redline.hxx6
-rw-r--r--sw/inc/shellio.hxx2
-rw-r--r--sw/source/core/access/accportions.cxx3
-rw-r--r--sw/source/core/access/accportions.hxx2
-rw-r--r--sw/source/core/bastyp/calc.cxx13
-rw-r--r--sw/source/core/crsr/findattr.cxx8
-rw-r--r--sw/source/core/doc/doccomp.cxx17
-rw-r--r--sw/source/core/doc/docfld.cxx13
-rw-r--r--sw/source/core/doc/docredln.cxx18
-rw-r--r--sw/source/core/doc/htmltbl.cxx11
-rw-r--r--sw/source/core/doc/list.cxx1
-rw-r--r--sw/source/core/doc/number.cxx15
-rw-r--r--sw/source/core/docnode/ndnotxt.cxx15
-rw-r--r--sw/source/core/draw/dpage.cxx12
-rw-r--r--sw/source/core/edit/acorrect.cxx8
-rw-r--r--sw/source/core/fields/cellfml.cxx3
-rw-r--r--sw/source/core/fields/fldlst.cxx3
-rw-r--r--sw/source/core/inc/UndoNumbering.hxx6
-rw-r--r--sw/source/core/inc/acorrect.hxx2
-rw-r--r--sw/source/core/inc/objectformatter.hxx3
-rw-r--r--sw/source/core/inc/swblocks.hxx3
-rw-r--r--sw/source/core/inc/swfont.hxx7
-rw-r--r--sw/source/core/inc/txtfly.hxx12
-rw-r--r--sw/source/core/layout/anchoreddrawobject.cxx4
-rw-r--r--sw/source/core/layout/atrfrm.cxx25
-rw-r--r--sw/source/core/layout/layouter.cxx15
-rw-r--r--sw/source/core/layout/objectformatter.cxx1
-rw-r--r--sw/source/core/swg/swblocks.cxx5
-rw-r--r--sw/source/core/text/EnhancedPDFExportHelper.cxx4
-rw-r--r--sw/source/core/text/atrhndl.hxx4
-rw-r--r--sw/source/core/text/atrstck.cxx4
-rw-r--r--sw/source/core/text/frmpaint.cxx10
-rw-r--r--sw/source/core/text/guess.cxx2
-rw-r--r--sw/source/core/text/guess.hxx6
-rw-r--r--sw/source/core/text/inftxt.cxx5
-rw-r--r--sw/source/core/text/inftxt.hxx2
-rw-r--r--sw/source/core/text/pormulti.cxx6
-rw-r--r--sw/source/core/text/pormulti.hxx4
-rw-r--r--sw/source/core/text/redlnitr.cxx5
-rw-r--r--sw/source/core/text/redlnitr.hxx10
-rw-r--r--sw/source/core/text/txtcache.cxx10
-rw-r--r--sw/source/core/text/txtcache.hxx9
-rw-r--r--sw/source/core/text/txtfly.cxx15
-rw-r--r--sw/source/core/txtnode/swfont.cxx19
-rw-r--r--sw/source/core/undo/unnum.cxx3
56 files changed, 166 insertions, 223 deletions
diff --git a/sw/inc/EnhancedPDFExportHelper.hxx b/sw/inc/EnhancedPDFExportHelper.hxx
index c1d3e30654f4..0aab23331921 100644
--- a/sw/inc/EnhancedPDFExportHelper.hxx
+++ b/sw/inc/EnhancedPDFExportHelper.hxx
@@ -196,7 +196,7 @@ class SwEnhancedPDFExportHelper
SwEditShell& mrSh;
OutputDevice& mrOut;
- StringRangeEnumerator* mpRangeEnum;
+ std::unique_ptr<StringRangeEnumerator> mpRangeEnum;
/** The problem is that numbers in StringRangeEnumerator aren't accordant
* to real page numbers if mbSkipEmptyPages is true, because in this case
* empty pages are excluded from a page range and numbers in
diff --git a/sw/inc/anchoreddrawobject.hxx b/sw/inc/anchoreddrawobject.hxx
index 1e6388852c39..38561d79e8a8 100644
--- a/sw/inc/anchoreddrawobject.hxx
+++ b/sw/inc/anchoreddrawobject.hxx
@@ -35,7 +35,7 @@ class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject
bool mbValidPos;
// rectangle, keeping the last object rectangle after the positioning
- Rectangle* mpLastObjRect;
+ std::unique_ptr<Rectangle> mpLastObjRect;
// boolean, indicating that anchored drawing object hasn't been attached
// to a anchor frame yet. Once, it is attached to a anchor frame the
@@ -140,7 +140,7 @@ class SW_DLLPUBLIC SwAnchoredDrawObject : public SwAnchoredObject
// accessors to the object area and its position
virtual const SwRect GetObjRect() const override;
// Return value can be NULL.
- const Rectangle* GetLastObjRect() const { return mpLastObjRect;}
+ const Rectangle* GetLastObjRect() const { return mpLastObjRect.get();}
void SetLastObjRect( const Rectangle& _rNewObjRect );
diff --git a/sw/inc/calc.hxx b/sw/inc/calc.hxx
index 8f54ab3bb385..630c43cb4a15 100644
--- a/sw/inc/calc.hxx
+++ b/sw/inc/calc.hxx
@@ -121,7 +121,7 @@ struct SwHash
SwHash( const OUString& rStr );
virtual ~SwHash();
OUString aStr;
- SwHash *pNext;
+ std::unique_ptr<SwHash> pNext;
};
struct SwCalcExp : public SwHash
diff --git a/sw/inc/cellfml.hxx b/sw/inc/cellfml.hxx
index 85c8787fb40c..3f918bd2384a 100644
--- a/sw/inc/cellfml.hxx
+++ b/sw/inc/cellfml.hxx
@@ -37,7 +37,7 @@ class SwTableCalcPara
sal_uInt16 nStackCnt, nMaxSize;
public:
- SwTableSortBoxes *pBoxStack; ///< stack for recognizing recursion
+ std::unique_ptr<SwTableSortBoxes> pBoxStack; ///< stack for recognizing recursion
SwCalc& rCalc; ///< current Calculator
const SwTable* pTable; ///< current table
diff --git a/sw/inc/dpage.hxx b/sw/inc/dpage.hxx
index 75d63b08a03b..a000e7052426 100644
--- a/sw/inc/dpage.hxx
+++ b/sw/inc/dpage.hxx
@@ -30,8 +30,8 @@ class SwDPage : public FmFormPage, public SdrObjUserCall
{
SwDPage &operator=(const SwDPage&) = delete;
- SdrPageGridFrameList* pGridLst;
- SwDoc* pDoc;
+ std::unique_ptr<SdrPageGridFrameList> pGridLst;
+ SwDoc* pDoc;
public:
explicit SwDPage(SwDrawModel& rNewModel, bool bMasterPage);
diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx
index bee8249837ea..fb970dbde735 100644
--- a/sw/inc/expfld.hxx
+++ b/sw/inc/expfld.hxx
@@ -365,9 +365,9 @@ public:
bool BuildSortLst();
private:
- SwEditShell* pSh;
- SetGetExpFields* pSrtLst;
- std::set<const SwTextField*> aTmpLst;
+ SwEditShell* pSh;
+ std::unique_ptr<SetGetExpFields> pSrtLst;
+ std::set<const SwTextField*> aTmpLst;
};
/// Implementation in tblcalc.cxx.
diff --git a/sw/inc/fmtcntnt.hxx b/sw/inc/fmtcntnt.hxx
index b8aa2b604dfa..62580c78bb31 100644
--- a/sw/inc/fmtcntnt.hxx
+++ b/sw/inc/fmtcntnt.hxx
@@ -29,7 +29,7 @@ class SwStartNode;
/// Content, content of frame (header, footer, fly).
class SW_DLLPUBLIC SwFormatContent: public SfxPoolItem
{
- SwNodeIndex *pStartNode;
+ std::unique_ptr<SwNodeIndex> pStartNode;
SwFormatContent &operator=( const SwFormatContent & ) = delete;
@@ -42,7 +42,7 @@ public:
virtual bool operator==( const SfxPoolItem& ) const override;
virtual SfxPoolItem* Clone( SfxItemPool* pPool = nullptr ) const override;
- const SwNodeIndex *GetContentIdx() const { return pStartNode; }
+ const SwNodeIndex *GetContentIdx() const { return pStartNode.get(); }
void SetNewContentIdx( const SwNodeIndex *pIdx );
void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
diff --git a/sw/inc/fmturl.hxx b/sw/inc/fmturl.hxx
index e6ea18b863a6..b043939b7e5f 100644
--- a/sw/inc/fmturl.hxx
+++ b/sw/inc/fmturl.hxx
@@ -34,7 +34,8 @@ class SW_DLLPUBLIC SwFormatURL: public SfxPoolItem
OUString sTargetFrameName; ///< Target frame for URL.
OUString sURL; ///< Simple URL.
OUString sName; ///< Name of the anchor.
- ImageMap *pMap; ///< ClientSide images.
+ std::unique_ptr<ImageMap>
+ pMap; ///< ClientSide images.
bool bIsServerMap; ///< A ServerSideImageMap with the URL.
@@ -66,8 +67,8 @@ public:
const OUString& GetTargetFrameName()const { return sTargetFrameName; }
const OUString& GetURL() const { return sURL; }
bool IsServerMap() const { return bIsServerMap; }
- const ImageMap *GetMap() const { return pMap; }
- ImageMap *GetMap() { return pMap; }
+ const ImageMap *GetMap() const { return pMap.get(); }
+ ImageMap *GetMap() { return pMap.get(); }
const OUString& GetName() const { return sName; }
void SetName( const OUString& rNm ) { sName = rNm; }
diff --git a/sw/inc/list.hxx b/sw/inc/list.hxx
index 2c3daf7d981a..d3ef07c8ea4c 100644
--- a/sw/inc/list.hxx
+++ b/sw/inc/list.hxx
@@ -21,6 +21,7 @@
#define INCLUDED_SW_INC_LIST_HXX
#include <rtl/ustring.hxx>
+#include <memory>
class SwNumRule;
class SwNodes;
@@ -57,7 +58,7 @@ class SwList
SwList( const SwList& ) = delete;
SwList& operator=( const SwList& ) = delete;
- SwListImpl* mpListImpl;
+ std::unique_ptr<SwListImpl> mpListImpl;
};
#endif // INCLUDED_SW_INC_LIST_HXX
diff --git a/sw/inc/ndnotxt.hxx b/sw/inc/ndnotxt.hxx
index 7ba253e564b5..531e17c32506 100644
--- a/sw/inc/ndnotxt.hxx
+++ b/sw/inc/ndnotxt.hxx
@@ -30,7 +30,7 @@ class SW_DLLPUBLIC SwNoTextNode : public SwContentNode
friend class SwNodes;
friend class SwNoTextFrame;
- tools::PolyPolygon *pContour;
+ std::unique_ptr<tools::PolyPolygon> pContour;
bool bAutomaticContour : 1; // automatic contour polygon, not manipulated
bool bContourMapModeValid : 1; // contour map mode is not the graphics's
// preferred map mode, but either
diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx
index 88b8d5c35b35..028003c9c2ee 100644
--- a/sw/inc/numrule.hxx
+++ b/sw/inc/numrule.hxx
@@ -49,7 +49,7 @@ const sal_Unicode cBulletChar = 0x2022; ///< Character for lists.
class SW_DLLPUBLIC SwNumFormat : public SvxNumberFormat, public SwClient
{
- SwFormatVertOrient* m_pVertOrient;
+ std::unique_ptr<SwFormatVertOrient> m_pVertOrient;
//For i120928,record the cp info of graphic within bullet
sal_Unicode m_cGrfBulletCP;
SAL_DLLPRIVATE void UpdateNumNodes( SwDoc* pDoc );
diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index fe55dd657452..fbe0ccc0ec84 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -51,7 +51,7 @@ public:
class SwRedlineExtraData_FormatColl : public SwRedlineExtraData
{
OUString sFormatNm;
- SfxItemSet* pSet;
+ std::unique_ptr<SfxItemSet> pSet;
sal_uInt16 nPoolId;
public:
SwRedlineExtraData_FormatColl( const OUString& rColl, sal_uInt16 nPoolFormatId,
@@ -88,7 +88,7 @@ public:
*/
class SW_DLLPUBLIC SwRedlineExtraData_FormattingChanges : public SwRedlineExtraData
{
- SfxItemSet* pSet;
+ std::unique_ptr<SfxItemSet> pSet;
SwRedlineExtraData_FormattingChanges( const SwRedlineExtraData_FormattingChanges& rCpy );
@@ -98,7 +98,7 @@ public:
virtual SwRedlineExtraData* CreateNew() const override;
virtual void Reject( SwPaM& rPam ) const override;
virtual bool operator == ( const SwRedlineExtraData& ) const override;
- SfxItemSet* GetItemSet( ) const { return pSet; }
+ SfxItemSet* GetItemSet( ) const { return pSet.get(); }
};
class SW_DLLPUBLIC SwRedlineData
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index ce171924f106..be6b0785486e 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -287,7 +287,7 @@ class SwImpBlocks;
class SW_DLLPUBLIC SwTextBlocks
{
- SwImpBlocks* pImp;
+ std::unique_ptr<SwImpBlocks> pImp;
sal_uLong nErr;
public:
diff --git a/sw/source/core/access/accportions.cxx b/sw/source/core/access/accportions.cxx
index 172a7ca4539d..3f1093fa0024 100644
--- a/sw/source/core/access/accportions.cxx
+++ b/sw/source/core/access/accportions.cxx
@@ -96,7 +96,6 @@ SwAccessiblePortionData::SwAccessiblePortionData(
SwAccessiblePortionData::~SwAccessiblePortionData()
{
- delete m_pSentences;
}
void SwAccessiblePortionData::Text(sal_Int32 nLength, sal_uInt16 nType, sal_Int32 /*nHeight*/, sal_Int32 /*nWidth*/)
@@ -480,7 +479,7 @@ void SwAccessiblePortionData::GetSentenceBoundary(
OSL_ENSURE( g_pBreakIt->GetBreakIter().is(), "No break-iterator." );
if( g_pBreakIt->GetBreakIter().is() )
{
- m_pSentences = new Positions_t();
+ m_pSentences.reset( new Positions_t );
m_pSentences->reserve(10);
// use xBreak->endOfSentence to iterate over all words; store
diff --git a/sw/source/core/access/accportions.hxx b/sw/source/core/access/accportions.hxx
index bd84e2cbf4bd..97248bd0ba46 100644
--- a/sw/source/core/access/accportions.hxx
+++ b/sw/source/core/access/accportions.hxx
@@ -63,7 +63,7 @@ class SwAccessiblePortionData : public SwPortionHandler
typedef std::vector<sal_uInt8> PortionAttrs_t;
PortionAttrs_t m_aPortionAttrs; /// additional portion attributes
- Positions_t* m_pSentences; /// positions of sentence breaks
+ std::unique_ptr<Positions_t> m_pSentences; /// positions of sentence breaks
size_t m_nBeforePortions; /// # of portions before first model character
bool m_bFinished;
diff --git a/sw/source/core/bastyp/calc.cxx b/sw/source/core/bastyp/calc.cxx
index 75941ad6c6a5..8862dd3887ee 100644
--- a/sw/source/core/bastyp/calc.cxx
+++ b/sw/source/core/bastyp/calc.cxx
@@ -197,7 +197,7 @@ SwHash* Find( const OUString& rStr, SwHash* const * ppTable,
if( pPos )
*pPos = static_cast<sal_uInt16>(ii);
- for( SwHash* pEntry = *(ppTable+ii); pEntry; pEntry = pEntry->pNext )
+ for( SwHash* pEntry = *(ppTable+ii); pEntry; pEntry = pEntry->pNext.get() )
{
if( rStr == pEntry->aStr )
{
@@ -357,7 +357,7 @@ SwCalc::SwCalc( SwDoc& rD )
nVal.PutString( rUserOptions.GetToken( aAdrToken[ 11 ] ));
sTmpStr = OUString::createFromAscii(sNTypeTab[25]);
- m_aVarTable[ aHashValue[ 25 ] ]->pNext = new SwCalcExp( sTmpStr, nVal, nullptr );
+ m_aVarTable[ aHashValue[ 25 ] ]->pNext.reset( new SwCalcExp( sTmpStr, nVal, nullptr ) );
} // SwCalc::SwCalc
@@ -448,14 +448,14 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
{
// then check doc
SwHash* const * ppDocTable = m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().GetFieldTypeTable();
- for( SwHash* pEntry = *(ppDocTable+ii); pEntry; pEntry = pEntry->pNext )
+ for( SwHash* pEntry = *(ppDocTable+ii); pEntry; pEntry = pEntry->pNext.get() )
{
if( aStr == pEntry->aStr )
{
// then insert here
pFnd = new SwCalcExp( aStr, SwSbxValue(),
static_cast<SwCalcFieldType*>(pEntry)->pFieldType );
- pFnd->pNext = *(m_aVarTable+ii);
+ pFnd->pNext.reset( *(m_aVarTable+ii) );
*(m_aVarTable+ii) = pFnd;
break;
}
@@ -562,7 +562,7 @@ SwCalcExp* SwCalc::VarLook( const OUString& rStr, bool bIns )
}
SwCalcExp* pNewExp = new SwCalcExp( aStr, SwSbxValue(), nullptr );
- pNewExp->pNext = m_aVarTable[ ii ];
+ pNewExp->pNext.reset( m_aVarTable[ ii ] );
m_aVarTable[ ii ] = pNewExp;
OUString sColumnName( GetColumnName( sTmpName ));
@@ -607,7 +607,7 @@ void SwCalc::VarChange( const OUString& rStr, const SwSbxValue& rValue )
if( !pFnd )
{
pFnd = new SwCalcExp( aStr, SwSbxValue( rValue ), nullptr );
- pFnd->pNext = m_aVarTable[ nPos ];
+ pFnd->pNext.reset( m_aVarTable[ nPos ] );
m_aVarTable[ nPos ] = pFnd;
}
else
@@ -1392,7 +1392,6 @@ SwHash::SwHash(const OUString& rStr)
SwHash::~SwHash()
{
- delete pNext;
}
void DeleteHashTable( SwHash **ppHashTable, sal_uInt16 nCount )
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index fa25c7fb7289..73b577712c86 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -1058,15 +1058,15 @@ struct SwFindParaAttr : public SwFindParas
const SfxItemSet *pSet, *pReplSet;
const SearchOptions2 *pSearchOpt;
SwCursor& m_rCursor;
- utl::TextSearch* pSText;
+ std::unique_ptr<utl::TextSearch> pSText;
SwFindParaAttr( const SfxItemSet& rSet, bool bNoCollection,
const SearchOptions2* pOpt, const SfxItemSet* pRSet,
SwCursor& rCursor )
: bValue( bNoCollection ), pSet( &rSet ), pReplSet( pRSet ),
- pSearchOpt( pOpt ), m_rCursor( rCursor ),pSText( nullptr ) {}
+ pSearchOpt( pOpt ), m_rCursor( rCursor ) {}
- virtual ~SwFindParaAttr() { delete pSText; }
+ virtual ~SwFindParaAttr() {}
virtual int Find( SwPaM* , SwMoveFnCollection const & , const SwPaM*, bool bInReadOnly ) override;
virtual bool IsReplaceMode() const override;
@@ -1117,7 +1117,7 @@ int SwFindParaAttr::Find( SwPaM* pCursor, SwMoveFnCollection const & fnMove, con
aTmp.Locale = SvtSysLocale().GetLanguageTag().getLocale();
- pSText = new utl::TextSearch( aTmp );
+ pSText.reset( new utl::TextSearch( aTmp ) );
}
// TODO: searching for attributes in Outliner text?!
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index ea21991763c2..380e56599348 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -227,7 +227,8 @@ private:
{
CompareData &rData1, &rData2;
const MovedData &rMoved1, &rMoved2;
- long *pMemory, *pFDiag, *pBDiag;
+ std::unique_ptr<long[]> pMemory;
+ long *pFDiag, *pBDiag;
void Compare( sal_uLong nStt1, sal_uLong nEnd1, sal_uLong nStt2, sal_uLong nEnd2 );
sal_uLong CheckDiag( sal_uLong nStt1, sal_uLong nEnd1,
@@ -323,7 +324,7 @@ static CmpOptionsContainer CmpOptions;
class CommonSubseq
{
private:
- int *pData;
+ std::unique_ptr<int[]> pData;
int nSize;
protected:
@@ -332,12 +333,11 @@ protected:
CommonSubseq( ArrayComparator &rComparator, int nMaxSize )
: nSize( nMaxSize ), rCmp( rComparator )
{
- pData = new int[ nSize ];
+ pData.reset( new int[ nSize ] );
}
~CommonSubseq()
{
- delete[] pData;
}
int FindLCS( int *pLcs1, int *pLcs2, int nStt1,
@@ -814,16 +814,15 @@ Compare::CompareSequence::CompareSequence(
: rData1( rD1 ), rData2( rD2 ), rMoved1( rMD1 ), rMoved2( rMD2 )
{
sal_uLong nSize = rMD1.GetCount() + rMD2.GetCount() + 3;
- pMemory = new long[ nSize * 2 ];
- pFDiag = pMemory + ( rMD2.GetCount() + 1 );
- pBDiag = pMemory + ( nSize + rMD2.GetCount() + 1 );
+ pMemory.reset( new long[ nSize * 2 ] );
+ pFDiag = pMemory.get() + ( rMD2.GetCount() + 1 );
+ pBDiag = pMemory.get() + ( nSize + rMD2.GetCount() + 1 );
Compare( 0, rMD1.GetCount(), 0, rMD2.GetCount() );
}
Compare::CompareSequence::~CompareSequence()
{
- delete [] pMemory;
}
void Compare::CompareSequence::Compare( sal_uLong nStt1, sal_uLong nEnd1,
@@ -2325,7 +2324,7 @@ int CommonSubseq::FindLCS( int *pLcs1, int *pLcs2, int nStt1, int nEnd1,
OSL_ASSERT( nLen2 >= 0 );
int **pLcs = new int*[ nLen1 + 1 ];
- pLcs[ 0 ] = pData;
+ pLcs[ 0 ] = pData.get();
for( int i = 1; i < nLen1 + 1; i++ )
pLcs[ i ] = pLcs[ i - 1 ] + nLen2 + 1;
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index 9282e0100080..7dc05e7b4ca8 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -328,7 +328,7 @@ HashStr::HashStr( const OUString& rName, const OUString& rText,
HashStr* pNxt )
: SwHash( rName ), aSetStr( rText )
{
- pNext = pNxt;
+ pNext.reset( pNxt );
}
/// Look up the Name, if it is present, return its String, otherwise return an empty String
@@ -1103,7 +1103,7 @@ void SwDocUpdateField::InsertFieldType( const SwFieldType& rType )
if( !pFnd )
{
SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
- pNew->pNext = aFieldTypeTable[ n ];
+ pNew->pNext.reset( aFieldTypeTable[ n ] );
aFieldTypeTable[ n ] = pNew;
}
}
@@ -1133,15 +1133,14 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
if( pFnd )
{
if( aFieldTypeTable[ n ] == pFnd )
- aFieldTypeTable[ n ] = static_cast<SwCalcFieldType*>(pFnd->pNext);
+ aFieldTypeTable[ n ] = static_cast<SwCalcFieldType*>(pFnd->pNext.release());
else
{
SwHash* pPrev = aFieldTypeTable[ n ];
- while( pPrev->pNext != pFnd )
- pPrev = pPrev->pNext;
- pPrev->pNext = pFnd->pNext;
+ while( pPrev->pNext.get() != pFnd )
+ pPrev = pPrev->pNext.get();
+ pPrev->pNext.reset( pFnd->pNext.release() );
}
- pFnd->pNext = nullptr;
delete pFnd;
}
}
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index fe20071a3441..95725bc8351f 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -653,17 +653,16 @@ SwRedlineExtraData_FormatColl::SwRedlineExtraData_FormatColl( const OUString& rC
: sFormatNm(rColl), pSet(nullptr), nPoolId(nPoolFormatId)
{
if( pItemSet && pItemSet->Count() )
- pSet = new SfxItemSet( *pItemSet );
+ pSet.reset( new SfxItemSet( *pItemSet ) );
}
SwRedlineExtraData_FormatColl::~SwRedlineExtraData_FormatColl()
{
- delete pSet;
}
SwRedlineExtraData* SwRedlineExtraData_FormatColl::CreateNew() const
{
- return new SwRedlineExtraData_FormatColl( sFormatNm, nPoolId, pSet );
+ return new SwRedlineExtraData_FormatColl( sFormatNm, nPoolId, pSet.get() );
}
void SwRedlineExtraData_FormatColl::Reject( SwPaM& rPam ) const
@@ -713,11 +712,10 @@ bool SwRedlineExtraData_FormatColl::operator == ( const SwRedlineExtraData& r) c
void SwRedlineExtraData_FormatColl::SetItemSet( const SfxItemSet& rSet )
{
- delete pSet;
if( rSet.Count() )
- pSet = new SfxItemSet( rSet );
+ pSet.reset( new SfxItemSet( rSet ) );
else
- pSet = nullptr;
+ pSet.reset();
}
SwRedlineExtraData_Format::SwRedlineExtraData_Format( const SfxItemSet& rSet )
@@ -784,10 +782,9 @@ bool SwRedlineExtraData_Format::operator == ( const SwRedlineExtraData& rCmp ) c
}
SwRedlineExtraData_FormattingChanges::SwRedlineExtraData_FormattingChanges( const SfxItemSet* pItemSet )
- : pSet(nullptr)
{
if( pItemSet && pItemSet->Count() )
- pSet = new SfxItemSet( *pItemSet );
+ pSet.reset( new SfxItemSet( *pItemSet ) );
}
SwRedlineExtraData_FormattingChanges::SwRedlineExtraData_FormattingChanges( const SwRedlineExtraData_FormattingChanges& rCpy )
@@ -796,17 +793,16 @@ SwRedlineExtraData_FormattingChanges::SwRedlineExtraData_FormattingChanges( cons
// Checking pointer pSet before accessing it for Count
if( rCpy.pSet && rCpy.pSet->Count() )
{
- pSet = new SfxItemSet( *(rCpy.pSet) );
+ pSet.reset( new SfxItemSet( *(rCpy.pSet) ) );
}
else
{
- pSet = nullptr;
+ pSet.reset();
}
}
SwRedlineExtraData_FormattingChanges::~SwRedlineExtraData_FormattingChanges()
{
- delete pSet;
}
SwRedlineExtraData* SwRedlineExtraData_FormattingChanges::CreateNew() const
diff --git a/sw/source/core/doc/htmltbl.cxx b/sw/source/core/doc/htmltbl.cxx
index ace49e99aedf..ec89c261ce3a 100644
--- a/sw/source/core/doc/htmltbl.cxx
+++ b/sw/source/core/doc/htmltbl.cxx
@@ -56,7 +56,7 @@ class SwHTMLTableLayoutConstraints
sal_uInt16 nCol; // start column
sal_uInt16 nColSpan; // the column's COLSPAN
- SwHTMLTableLayoutConstraints *pNext; // the next constraint
+ std::unique_ptr<SwHTMLTableLayoutConstraints> pNext; // the next constraint
sal_uLong nMinNoAlign, nMaxNoAlign; // provisional result of AL-Pass 1
@@ -69,7 +69,7 @@ public:
sal_uLong GetMaxNoAlign() const { return nMaxNoAlign; }
SwHTMLTableLayoutConstraints *InsertNext( SwHTMLTableLayoutConstraints *pNxt );
- SwHTMLTableLayoutConstraints* GetNext() const { return pNext; }
+ SwHTMLTableLayoutConstraints* GetNext() const { return pNext.get(); }
sal_uInt16 GetColSpan() const { return nColSpan; }
sal_uInt16 GetColumn() const { return nCol; }
@@ -131,7 +131,6 @@ SwHTMLTableLayoutConstraints::SwHTMLTableLayoutConstraints(
SwHTMLTableLayoutConstraints::~SwHTMLTableLayoutConstraints()
{
- delete pNext;
}
SwHTMLTableLayoutConstraints *SwHTMLTableLayoutConstraints::InsertNext(
@@ -150,13 +149,13 @@ SwHTMLTableLayoutConstraints *SwHTMLTableLayoutConstraints::InsertNext(
if( pPrev )
{
- pNxt->pNext = pPrev->GetNext();
- pPrev->pNext = pNxt;
+ pNxt->pNext.reset( pPrev->pNext.release() );
+ pPrev->pNext.reset( pNxt );
pConstr = this;
}
else
{
- pNxt->pNext = this;
+ pNxt->pNext.reset( this );
pConstr = pNxt;
}
diff --git a/sw/source/core/doc/list.cxx b/sw/source/core/doc/list.cxx
index 2e3f9bbc3971..753965a799ce 100644
--- a/sw/source/core/doc/list.cxx
+++ b/sw/source/core/doc/list.cxx
@@ -218,7 +218,6 @@ SwList::SwList( const OUString& sListId,
SwList::~SwList()
{
- delete mpListImpl;
}
const OUString SwList::GetListId() const
diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx
index 441461f3ea2a..5db16bb9df50 100644
--- a/sw/source/core/doc/number.cxx
+++ b/sw/source/core/doc/number.cxx
@@ -222,7 +222,6 @@ SwNumFormat::SwNumFormat(const SvxNumberFormat& rNumFormat, SwDoc* pDoc)
SwNumFormat::~SwNumFormat()
{
- delete m_pVertOrient;
}
// #i22362#
@@ -351,7 +350,7 @@ const SwFormatVertOrient* SwNumFormat::GetGraphicOrientation() const
else
{
m_pVertOrient->SetVertOrient(eOrient);
- return m_pVertOrient;
+ return m_pVertOrient.get();
}
}
@@ -1071,7 +1070,6 @@ namespace numfunc
}
SwDefBulletConfig();
- virtual ~SwDefBulletConfig() override;
private:
/** sets internal default bullet configuration data to default values */
@@ -1099,7 +1097,7 @@ namespace numfunc
sal_Unicode mnLevelChars[MAXLEVEL];
// default bullet list font instance
- vcl::Font* mpFont;
+ std::unique_ptr<vcl::Font> mpFont;
};
namespace
@@ -1130,11 +1128,6 @@ namespace numfunc
EnableNotification( GetPropNames() );
}
- SwDefBulletConfig::~SwDefBulletConfig()
- {
- delete mpFont;
- }
-
void SwDefBulletConfig::SetToDefault()
{
msFontname = "OpenSymbol";
@@ -1235,9 +1228,7 @@ namespace numfunc
void SwDefBulletConfig::InitFont()
{
- delete mpFont;
-
- mpFont = new vcl::Font( msFontname, OUString(), Size( 0, 14 ) );
+ mpFont.reset( new vcl::Font( msFontname, OUString(), Size( 0, 14 ) ) );
mpFont->SetWeight( meFontWeight );
mpFont->SetItalic( meFontItalic );
mpFont->SetCharSet( RTL_TEXTENCODING_SYMBOL );
diff --git a/sw/source/core/docnode/ndnotxt.cxx b/sw/source/core/docnode/ndnotxt.cxx
index 8b2bbdec970d..3c3938857945 100644
--- a/sw/source/core/docnode/ndnotxt.cxx
+++ b/sw/source/core/docnode/ndnotxt.cxx
@@ -53,7 +53,6 @@ SwNoTextNode::SwNoTextNode( const SwNodeIndex & rWhere,
SwNoTextNode::~SwNoTextNode()
{
- delete pContour;
}
/// Creates an AttrSet for all derivations with ranges for frame-
@@ -88,11 +87,10 @@ bool SwNoTextNode::SavePersistentData()
void SwNoTextNode::SetContour( const tools::PolyPolygon *pPoly, bool bAutomatic )
{
- delete pContour;
if ( pPoly )
- pContour = new tools::PolyPolygon( *pPoly );
+ pContour.reset( new tools::PolyPolygon( *pPoly ) );
else
- pContour = nullptr;
+ pContour.reset();
bAutomaticContour = bAutomatic;
bContourMapModeValid = true;
bPixelContour = false;
@@ -101,7 +99,7 @@ void SwNoTextNode::SetContour( const tools::PolyPolygon *pPoly, bool bAutomatic
void SwNoTextNode::CreateContour()
{
OSL_ENSURE( !pContour, "Contour available." );
- pContour = new tools::PolyPolygon(SvxContourDlg::CreateAutoContour(GetGraphic()));
+ pContour.reset( new tools::PolyPolygon(SvxContourDlg::CreateAutoContour(GetGraphic())) );
bAutomaticContour = true;
bContourMapModeValid = true;
bPixelContour = false;
@@ -175,7 +173,7 @@ const tools::PolyPolygon *SwNoTextNode::HasContour() const
const_cast<SwNoTextNode *>(this)->bPixelContour = false;
}
- return pContour;
+ return pContour.get();
}
void SwNoTextNode::GetContour( tools::PolyPolygon &rPoly ) const
@@ -186,11 +184,10 @@ void SwNoTextNode::GetContour( tools::PolyPolygon &rPoly ) const
void SwNoTextNode::SetContourAPI( const tools::PolyPolygon *pPoly )
{
- delete pContour;
if ( pPoly )
- pContour = new tools::PolyPolygon( *pPoly );
+ pContour.reset( new tools::PolyPolygon( *pPoly ) );
else
- pContour = nullptr;
+ pContour.reset();
bContourMapModeValid = false;
}
diff --git a/sw/source/core/draw/dpage.cxx b/sw/source/core/draw/dpage.cxx
index bea0588ea495..8163b2606a31 100644
--- a/sw/source/core/draw/dpage.cxx
+++ b/sw/source/core/draw/dpage.cxx
@@ -58,12 +58,11 @@ SwDPage::SwDPage(SwDrawModel& rNewModel, bool bMasterPage) :
SwDPage::SwDPage(const SwDPage& rSrcPage) :
FmFormPage( rSrcPage ),
- pGridLst( nullptr ),
pDoc( nullptr )
{
if ( rSrcPage.pGridLst )
{
- pGridLst = new SdrPageGridFrameList;
+ pGridLst.reset( new SdrPageGridFrameList );
for ( sal_uInt16 i = 0; i != rSrcPage.pGridLst->GetCount(); ++i )
pGridLst->Insert( ( *rSrcPage.pGridLst )[ i ] );
}
@@ -71,7 +70,6 @@ SwDPage::SwDPage(const SwDPage& rSrcPage) :
SwDPage::~SwDPage()
{
- delete pGridLst;
}
void SwDPage::lateInit(const SwDPage& rPage, SwDrawModel* const pNewModel)
@@ -142,7 +140,7 @@ const SdrPageGridFrameList* SwDPage::GetGridFrameList(
if ( pGridLst )
const_cast<SwDPage*>(this)->pGridLst->Clear();
else
- const_cast<SwDPage*>(this)->pGridLst = new SdrPageGridFrameList;
+ const_cast<SwDPage*>(this)->pGridLst.reset( new SdrPageGridFrameList );
if ( pRect )
{
@@ -151,7 +149,7 @@ const SdrPageGridFrameList* SwDPage::GetGridFrameList(
const SwFrame *pPg = pSh->GetLayout()->Lower();
do
{ if ( pPg->Frame().IsOver( aRect ) )
- ::InsertGridFrame( const_cast<SwDPage*>(this)->pGridLst, pPg );
+ ::InsertGridFrame( const_cast<SwDPage*>(this)->pGridLst.get(), pPg );
pPg = pPg->GetNext();
} while ( pPg );
}
@@ -161,12 +159,12 @@ const SdrPageGridFrameList* SwDPage::GetGridFrameList(
const SwFrame *pPg = pSh->Imp()->GetFirstVisPage(pSh->GetOut());
if ( pPg )
do
- { ::InsertGridFrame( const_cast<SwDPage*>(this)->pGridLst, pPg );
+ { ::InsertGridFrame( const_cast<SwDPage*>(this)->pGridLst.get(), pPg );
pPg = pPg->GetNext();
} while ( pPg && pPg->Frame().IsOver( pSh->VisArea() ) );
}
}
- return pGridLst;
+ return pGridLst.get();
}
bool SwDPage::RequestHelp( vcl::Window* pWindow, SdrView* pView,
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index afc4d1832b45..ce1004df364c 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -455,7 +455,6 @@ bool SwAutoCorrExceptWord::CheckDelChar( const SwPosition& rPos )
SwDontExpandItem::~SwDontExpandItem()
{
- delete pDontExpItems;
}
void SwDontExpandItem::SaveDontExpandItems( const SwPosition& rPos )
@@ -463,14 +462,13 @@ void SwDontExpandItem::SaveDontExpandItems( const SwPosition& rPos )
const SwTextNode* pTextNd = rPos.nNode.GetNode().GetTextNode();
if( pTextNd )
{
- pDontExpItems = new SfxItemSet( const_cast<SwDoc*>(pTextNd->GetDoc())->GetAttrPool(),
- aCharFormatSetRange );
+ pDontExpItems.reset( new SfxItemSet( const_cast<SwDoc*>(pTextNd->GetDoc())->GetAttrPool(),
+ aCharFormatSetRange ) );
const sal_Int32 n = rPos.nContent.GetIndex();
if( !pTextNd->GetAttr( *pDontExpItems, n, n,
n != pTextNd->GetText().getLength() ))
{
- delete pDontExpItems;
- pDontExpItems = nullptr;
+ pDontExpItems.reset();
}
}
}
diff --git a/sw/source/core/fields/cellfml.cxx b/sw/source/core/fields/cellfml.cxx
index cb8da529f2dd..1d55ab872fd4 100644
--- a/sw/source/core/fields/cellfml.cxx
+++ b/sw/source/core/fields/cellfml.cxx
@@ -252,14 +252,13 @@ double SwTableBox::GetValue( SwTableCalcPara& rCalcPara ) const
SwTableCalcPara::SwTableCalcPara( SwCalc& rCalculator, const SwTable& rTable )
: pLastTableBox( nullptr ), nStackCnt( 0 ), nMaxSize( cMAXSTACKSIZE ),
+ pBoxStack( new SwTableSortBoxes ),
rCalc( rCalculator ), pTable( &rTable )
{
- pBoxStack = new SwTableSortBoxes;
}
SwTableCalcPara::~SwTableCalcPara()
{
- delete pBoxStack;
}
bool SwTableCalcPara::CalcWithStackOverflow()
diff --git a/sw/source/core/fields/fldlst.cxx b/sw/source/core/fields/fldlst.cxx
index e075d3db0f13..04e0f601d2a2 100644
--- a/sw/source/core/fields/fldlst.cxx
+++ b/sw/source/core/fields/fldlst.cxx
@@ -36,7 +36,7 @@ SwInputFieldList::SwInputFieldList( SwEditShell* pShell, bool bBuildTmpLst )
: pSh(pShell)
{
// create sorted list of all input fields
- pSrtLst = new SetGetExpFields();
+ pSrtLst.reset( new SetGetExpFields );
const SwFieldTypes& rFieldTypes = *pSh->GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
const size_t nSize = rFieldTypes.size();
@@ -80,7 +80,6 @@ SwInputFieldList::SwInputFieldList( SwEditShell* pShell, bool bBuildTmpLst )
SwInputFieldList::~SwInputFieldList()
{
- delete pSrtLst;
}
size_t SwInputFieldList::Count() const
diff --git a/sw/source/core/inc/UndoNumbering.hxx b/sw/source/core/inc/UndoNumbering.hxx
index f3ce48bf6d30..7d2c6f9b84a8 100644
--- a/sw/source/core/inc/UndoNumbering.hxx
+++ b/sw/source/core/inc/UndoNumbering.hxx
@@ -64,8 +64,8 @@ class SwUndoDelNum : public SwUndo, private SwUndRng
int level;
inline NodeLevel(sal_uLong idx, int lvl) : index(idx), level(lvl) {};
};
- std::vector<NodeLevel> aNodes;
- SwHistory* pHistory;
+ std::vector<NodeLevel> aNodes;
+ std::unique_ptr<SwHistory> pHistory;
public:
SwUndoDelNum( const SwPaM& rPam );
@@ -77,7 +77,7 @@ public:
virtual void RepeatImpl( ::sw::RepeatContext & ) override;
void AddNode( const SwTextNode& rNd );
- SwHistory* GetHistory() { return pHistory; }
+ SwHistory* GetHistory() { return pHistory.get(); }
};
class SwUndoMoveNum : public SwUndo, private SwUndRng
diff --git a/sw/source/core/inc/acorrect.hxx b/sw/source/core/inc/acorrect.hxx
index afbb1fdf8137..104b3653351d 100644
--- a/sw/source/core/inc/acorrect.hxx
+++ b/sw/source/core/inc/acorrect.hxx
@@ -31,7 +31,7 @@ class SfxItemSet;
class SwDontExpandItem
{
- SfxItemSet* pDontExpItems;
+ std::unique_ptr<SfxItemSet> pDontExpItems;
public:
SwDontExpandItem() :
diff --git a/sw/source/core/inc/objectformatter.hxx b/sw/source/core/inc/objectformatter.hxx
index e010ee21821c..ddeb9d189074 100644
--- a/sw/source/core/inc/objectformatter.hxx
+++ b/sw/source/core/inc/objectformatter.hxx
@@ -20,6 +20,7 @@
#define INCLUDED_SW_SOURCE_CORE_INC_OBJECTFORMATTER_HXX
#include <sal/types.h>
+#include <memory>
class SwFrame;
// #i26945#
@@ -50,7 +51,7 @@ class SwObjectFormatter
// data structure to collect page number of object's 'anchor'
// #i26945#
- SwPageNumAndTypeOfAnchors* mpPgNumAndTypeOfAnchors;
+ std::unique_ptr<SwPageNumAndTypeOfAnchors> mpPgNumAndTypeOfAnchors;
/** helper method for method <FormatObj_(..)> - performs the intrinsic
format of the layout of the given layout frame and all its lower
diff --git a/sw/source/core/inc/swblocks.hxx b/sw/source/core/inc/swblocks.hxx
index 2c0dc88d5386..4899e353a6c9 100644
--- a/sw/source/core/inc/swblocks.hxx
+++ b/sw/source/core/inc/swblocks.hxx
@@ -67,7 +67,6 @@ protected:
bool bInfoChanged : 1; // Whether any info of TextBlock changed
explicit SwImpBlocks( const OUString& );
- virtual ~SwImpBlocks();
enum class FileType {
NoFile, // Not present
@@ -86,6 +85,8 @@ protected:
void Touch();
public:
+ virtual ~SwImpBlocks();
+
static sal_uInt16 Hash( const OUString& ); /// Hashcode for Block names
sal_uInt16 GetCount() const; /// Get count of Text Blocks
sal_uInt16 GetIndex( const OUString& ) const; /// Index for shortnames
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index fd41e411aca9..caef07ddc31d 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -132,7 +132,8 @@ class SW_DLLPUBLIC SwFont
// CTL == Complex text layout ( Hebrew, Arabic )
o3tl::enumarray<SwFontScript, SwSubFont> m_aSub; // Latin-, CJK- and CTL-font
- Color* m_pBackColor; // background color (i.e. at character styles)
+ std::unique_ptr<Color>
+ m_pBackColor; // background color (i.e. at character styles)
Color m_aHighlightColor; // highlight color
Color m_aUnderColor; // color of the underlining
Color m_aOverColor; // color of the overlining
@@ -189,7 +190,7 @@ public:
void GoMagic( SwViewShell *pSh, SwFontScript nWhich );
// set background color
void SetBackColor( Color* pNewColor );
- inline const Color* GetBackColor() const{ return m_pBackColor; }
+ inline const Color* GetBackColor() const{ return m_pBackColor.get(); }
void SetHighlightColor( const Color& aNewColor );
const Color& GetHighlightColor() const { return m_aHighlightColor; }
@@ -962,7 +963,7 @@ class SwUnderlineFont
{
Point m_aPos;
sal_Int32 m_nEnd;
- SwFont* m_pFont;
+ std::unique_ptr<SwFont> m_pFont;
public:
// sets the font which should paint the common baseline,
diff --git a/sw/source/core/inc/txtfly.hxx b/sw/source/core/inc/txtfly.hxx
index 5c22fefdf191..7844d8c53cc2 100644
--- a/sw/source/core/inc/txtfly.hxx
+++ b/sw/source/core/inc/txtfly.hxx
@@ -116,11 +116,11 @@ public:
*/
class SwTextFly
{
- const SwPageFrame * pPage;
- const SwAnchoredObject * mpCurrAnchoredObj;
- const SwTextFrame * pCurrFrame;
- const SwContentFrame * pMaster;
- SwAnchoredObjList * mpAnchoredObjList;
+ const SwPageFrame * pPage;
+ const SwAnchoredObject * mpCurrAnchoredObj;
+ const SwTextFrame * pCurrFrame;
+ const SwContentFrame * pMaster;
+ std::unique_ptr<SwAnchoredObjList> mpAnchoredObjList;
long nMinBottom;
long nNextTop; /// Stores the upper edge of the "next" frame
@@ -299,7 +299,7 @@ public:
inline SwAnchoredObjList* SwTextFly::GetAnchoredObjList() const
{
return mpAnchoredObjList
- ? mpAnchoredObjList
+ ? mpAnchoredObjList.get()
: const_cast<SwTextFly*>(this)->InitAnchoredObjList();
}
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 1c95425fdf2a..0b11e228cbcd 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -210,8 +210,6 @@ SwAnchoredDrawObject::SwAnchoredDrawObject() :
SwAnchoredDrawObject::~SwAnchoredDrawObject()
{
- // #i34748#
- delete mpLastObjRect;
}
// --> #i62875#
@@ -728,7 +726,7 @@ void SwAnchoredDrawObject::SetLastObjRect( const Rectangle& _rNewLastRect )
{
if ( !mpLastObjRect )
{
- mpLastObjRect = new Rectangle;
+ mpLastObjRect.reset( new Rectangle );
}
*(mpLastObjRect) = _rNewLastRect;
}
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 6ca6ef19c343..566f785f2f95 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -530,25 +530,23 @@ SfxPoolItem* SwFormatFooter::Clone( SfxItemPool* ) const
SwFormatContent::SwFormatContent( const SwFormatContent &rCpy )
: SfxPoolItem( RES_CNTNT )
{
- pStartNode = rCpy.GetContentIdx() ?
- new SwNodeIndex( *rCpy.GetContentIdx() ) : nullptr;
+ pStartNode.reset( rCpy.GetContentIdx() ?
+ new SwNodeIndex( *rCpy.GetContentIdx() ) : nullptr);
}
SwFormatContent::SwFormatContent( const SwStartNode *pStartNd )
: SfxPoolItem( RES_CNTNT )
{
- pStartNode = pStartNd ? new SwNodeIndex( *pStartNd ) : nullptr;
+ pStartNode.reset( pStartNd ? new SwNodeIndex( *pStartNd ) : nullptr);
}
- SwFormatContent::~SwFormatContent()
+SwFormatContent::~SwFormatContent()
{
- delete pStartNode;
}
void SwFormatContent::SetNewContentIdx( const SwNodeIndex *pIdx )
{
- delete pStartNode;
- pStartNode = pIdx ? new SwNodeIndex( *pIdx ) : nullptr;
+ pStartNode.reset( pIdx ? new SwNodeIndex( *pIdx ) : nullptr );
}
bool SwFormatContent::operator==( const SfxPoolItem& rAttr ) const
@@ -1751,12 +1749,12 @@ SwFormatURL::SwFormatURL( const SwFormatURL &rURL) :
sName( rURL.GetName() ),
bIsServerMap( rURL.IsServerMap() )
{
- pMap = rURL.GetMap() ? new ImageMap( *rURL.GetMap() ) : nullptr;
+ if (rURL.GetMap())
+ pMap.reset( new ImageMap( *rURL.GetMap() ) );
}
SwFormatURL::~SwFormatURL()
{
- delete pMap;
}
bool SwFormatURL::operator==( const SfxPoolItem &rAttr ) const
@@ -1772,7 +1770,7 @@ bool SwFormatURL::operator==( const SfxPoolItem &rAttr ) const
if ( pMap && rCmp.GetMap() )
bRet = *pMap == *rCmp.GetMap();
else
- bRet = pMap == rCmp.GetMap();
+ bRet = pMap.get() == rCmp.GetMap();
}
return bRet;
}
@@ -1790,8 +1788,7 @@ void SwFormatURL::SetURL(const OUString &rURL, bool bServerMap)
void SwFormatURL::SetMap( const ImageMap *pM )
{
- delete pMap;
- pMap = pM ? new ImageMap( *pM ) : nullptr;
+ pMap.reset( pM ? new ImageMap( *pM ) : nullptr);
}
bool SwFormatURL::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
@@ -1868,11 +1865,11 @@ bool SwFormatURL::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
uno::Reference<container::XIndexContainer> xCont;
if(!rVal.hasValue())
- DELETEZ(pMap);
+ pMap.reset();
else if(rVal >>= xCont)
{
if(!pMap)
- pMap = new ImageMap;
+ pMap.reset(new ImageMap);
bRet = SvUnoImageMap_fillImageMap( xCont, *pMap );
}
else
diff --git a/sw/source/core/layout/layouter.cxx b/sw/source/core/layout/layouter.cxx
index 638d0e76056c..8e455c5894ab 100644
--- a/sw/source/core/layout/layouter.cxx
+++ b/sw/source/core/layout/layouter.cxx
@@ -45,13 +45,13 @@ public:
class SwEndnoter
{
- SwLayouter* pMaster;
- SwSectionFrame* pSect;
- SwFootnoteFrames* pEndArr;
+ SwLayouter* pMaster;
+ SwSectionFrame* pSect;
+ std::unique_ptr<SwFootnoteFrames> pEndArr;
public:
explicit SwEndnoter( SwLayouter* pLay )
- : pMaster( pLay ), pSect( nullptr ), pEndArr( nullptr ) {}
- ~SwEndnoter() { delete pEndArr; }
+ : pMaster( pLay ), pSect( nullptr ) {}
+ ~SwEndnoter() {}
void CollectEndnotes( SwSectionFrame* pSct );
void CollectEndnote( SwFootnoteFrame* pFootnote );
const SwSectionFrame* GetSect() const { return pSect; }
@@ -114,7 +114,7 @@ void SwEndnoter::CollectEndnote( SwFootnoteFrame* pFootnote )
}
}
if( !pEndArr )
- pEndArr = new SwFootnoteFrames; // deleted from the SwLayouter
+ pEndArr.reset( new SwFootnoteFrames ); // deleted from the SwLayouter
pEndArr->push_back( pFootnote );
}
@@ -133,8 +133,7 @@ void SwEndnoter::InsertEndnotes()
SwFootnoteBossFrame *pBoss = pRef ? pRef->FindFootnoteBossFrame()
: static_cast<SwFootnoteBossFrame*>(pSect->Lower());
pBoss->MoveFootnotes_( *pEndArr );
- delete pEndArr;
- pEndArr = nullptr;
+ pEndArr.reset();
pSect = nullptr;
}
diff --git a/sw/source/core/layout/objectformatter.cxx b/sw/source/core/layout/objectformatter.cxx
index a59c83495b1e..ff5ff9c4b979 100644
--- a/sw/source/core/layout/objectformatter.cxx
+++ b/sw/source/core/layout/objectformatter.cxx
@@ -145,7 +145,6 @@ SwObjectFormatter::SwObjectFormatter( const SwPageFrame& _rPageFrame,
SwObjectFormatter::~SwObjectFormatter()
{
- delete mpPgNumAndTypeOfAnchors;
}
SwObjectFormatter* SwObjectFormatter::CreateObjFormatter(
diff --git a/sw/source/core/swg/swblocks.cxx b/sw/source/core/swg/swblocks.cxx
index 99f0751a41cb..c84b29ee2bdd 100644
--- a/sw/source/core/swg/swblocks.cxx
+++ b/sw/source/core/swg/swblocks.cxx
@@ -239,8 +239,8 @@ SwTextBlocks::SwTextBlocks( const OUString& rFile )
const OUString sFileName = aObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
switch( SwImpBlocks::GetFileType( rFile ) )
{
- case SwImpBlocks::FileType::XML: pImp = new SwXMLTextBlocks( sFileName ); break;
- case SwImpBlocks::FileType::NoFile: pImp = new SwXMLTextBlocks( sFileName ); break;
+ case SwImpBlocks::FileType::XML: pImp.reset( new SwXMLTextBlocks( sFileName ) ); break;
+ case SwImpBlocks::FileType::NoFile: pImp.reset( new SwXMLTextBlocks( sFileName ) ); break;
default: break;
}
if( !pImp )
@@ -249,7 +249,6 @@ SwTextBlocks::SwTextBlocks( const OUString& rFile )
SwTextBlocks::~SwTextBlocks()
{
- delete pImp;
}
OUString SwTextBlocks::GetName()
diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx
index 6a4c102e1efe..dde3c458e79f 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -1455,13 +1455,12 @@ SwEnhancedPDFExportHelper::SwEnhancedPDFExportHelper( SwEditShell& rSh,
const SwPrintData& rPrintData )
: mrSh( rSh ),
mrOut( rOut ),
- mpRangeEnum( nullptr ),
mbSkipEmptyPages( bSkipEmptyPages ),
mbEditEngineOnly( bEditEngineOnly ),
mrPrintData( rPrintData )
{
if ( !rPageRange.isEmpty() )
- mpRangeEnum = new StringRangeEnumerator( rPageRange, 0, mrSh.GetPageCount()-1 );
+ mpRangeEnum.reset( new StringRangeEnumerator( rPageRange, 0, mrSh.GetPageCount()-1 ) );
if ( mbSkipEmptyPages )
{
@@ -1505,7 +1504,6 @@ SwEnhancedPDFExportHelper::SwEnhancedPDFExportHelper( SwEditShell& rSh,
SwEnhancedPDFExportHelper::~SwEnhancedPDFExportHelper()
{
- delete mpRangeEnum;
}
Rectangle SwEnhancedPDFExportHelper::SwRectToPDFRect(const SwPageFrame* pCurrPage,
diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx
index 0b7caf18710f..d9dc3c95bed4 100644
--- a/sw/source/core/text/atrhndl.hxx
+++ b/sw/source/core/text/atrhndl.hxx
@@ -85,7 +85,7 @@ private:
// This is the base font for the paragraph. It is stored in order to have
// a template, if we have to restart the attribute evaluation
- SwFont* pFnt;
+ std::unique_ptr<SwFont> pFnt;
bool bVertLayout;
@@ -145,7 +145,7 @@ inline void SwAttrHandler::ResetFont( SwFont& rFnt ) const
inline const SwFont* SwAttrHandler::GetFont() const
{
- return pFnt;
+ return pFnt.get();
};
#endif
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index 418556f309a6..6951d02d2e05 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -353,7 +353,6 @@ SwAttrHandler::SwAttrHandler()
SwAttrHandler::~SwAttrHandler()
{
- delete pFnt;
}
void SwAttrHandler::Init( const SwAttrSet& rAttrSet,
@@ -404,8 +403,7 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, const SwAttrSet* pAS,
// It is possible, that Init is called more than once, e.g., in a
// SwTextFrame::FormatOnceMore situation.
- delete pFnt;
- pFnt = new SwFont( rFnt );
+ pFnt.reset( new SwFont( rFnt ) );
}
void SwAttrHandler::Reset( )
diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx
index 7f6efc6822cc..1e6027e6ca48 100644
--- a/sw/source/core/text/frmpaint.cxx
+++ b/sw/source/core/text/frmpaint.cxx
@@ -62,7 +62,7 @@ class SwExtraPainter
SwRect aRect;
const SwTextFrame* pTextFrame;
SwViewShell *pSh;
- SwFont* pFnt;
+ std::unique_ptr<SwFont> pFnt;
const SwLineNumberInfo &rLineInf;
SwTwips nX;
SwTwips nRedX;
@@ -79,8 +79,8 @@ public:
SwExtraPainter( const SwTextFrame *pFrame, SwViewShell *pVwSh,
const SwLineNumberInfo &rLnInf, const SwRect &rRct,
sal_Int16 eHor, bool bLnNm );
- ~SwExtraPainter() { delete pFnt; }
- inline SwFont* GetFont() const { return pFnt; }
+ ~SwExtraPainter() {}
+ inline SwFont* GetFont() const { return pFnt.get(); }
inline void IncLineNr() { ++nLineNr; }
inline bool HasNumber() { return !( nLineNr % rLineInf.GetCountBy() ); }
inline bool HasDivider() { if( !nDivider ) return false;
@@ -128,7 +128,7 @@ SwExtraPainter::SwExtraPainter( const SwTextFrame *pFrame, SwViewShell *pVwSh,
nX = pFrame->Frame().Left();
SwCharFormat* pFormat = rLineInf.GetCharFormat( const_cast<IDocumentStylePoolAccess&>(pFrame->GetNode()->getIDocumentStylePoolAccess()) );
OSL_ENSURE( pFormat, "PaintExtraData without CharFormat" );
- pFnt = new SwFont( &pFormat->GetAttrSet(), pFrame->GetTextNode()->getIDocumentSettingAccess() );
+ pFnt.reset( new SwFont( &pFormat->GetAttrSet(), pFrame->GetTextNode()->getIDocumentSettingAccess() ) );
pFnt->Invalidate();
pFnt->ChgPhysFnt( pSh, *pSh->GetOut() );
pFnt->SetVertical( 0, pFrame->IsVertical() );
@@ -200,7 +200,7 @@ void SwExtraPainter::PaintExtra( SwTwips nY, long nAsc, long nMax, bool bRed )
aDrawInf.SetLeft( 0 );
aDrawInf.SetRight( LONG_MAX );
aDrawInf.SetFrame( pTextFrame );
- aDrawInf.SetFont( pFnt );
+ aDrawInf.SetFont( pFnt.get() );
aDrawInf.SetSnapToGrid( false );
aDrawInf.SetIgnoreFrameRTL( true );
diff --git a/sw/source/core/text/guess.cxx b/sw/source/core/text/guess.cxx
index e347013a4c9b..a13ed2466d08 100644
--- a/sw/source/core/text/guess.cxx
+++ b/sw/source/core/text/guess.cxx
@@ -475,7 +475,7 @@ bool SwTextGuess::Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
SwPosSize aTmpSize = rInf.GetTextSize( &rSI, nCutPos, nHangingLen );
aTmpSize.Width(aTmpSize.Width() + nLeftRightBorderSpace);
OSL_ENSURE( !pHanging, "A hanging portion is hanging around" );
- pHanging = new SwHangingPortion( aTmpSize );
+ pHanging.reset( new SwHangingPortion( aTmpSize ) );
pHanging->SetLen( nHangingLen );
nPorLen = nCutPos - rInf.GetIdx();
}
diff --git a/sw/source/core/text/guess.hxx b/sw/source/core/text/guess.hxx
index e8023c26ed47..75bc91543f71 100644
--- a/sw/source/core/text/guess.hxx
+++ b/sw/source/core/text/guess.hxx
@@ -29,7 +29,7 @@ class SwTextFormatInfo;
class SwTextGuess
{
css::uno::Reference< css::linguistic2::XHyphenatedWord > xHyphWord;
- SwHangingPortion *pHanging; // for hanging punctuation
+ std::unique_ptr<SwHangingPortion> pHanging; // for hanging punctuation
sal_Int32 nCutPos; // this character doesn't fit
sal_Int32 nBreakStart; // start index of word containing line break
sal_Int32 nBreakPos; // start index of break position
@@ -40,14 +40,14 @@ public:
inline SwTextGuess(): pHanging( nullptr ), nCutPos(0), nBreakStart(0),
nBreakPos(0), nFieldDiff(0), nBreakWidth(0)
{ }
- ~SwTextGuess() { delete pHanging; }
+ ~SwTextGuess() {}
// true, if current portion still fits to current line
bool Guess( const SwTextPortion& rPor, SwTextFormatInfo &rInf,
const sal_uInt16 nHeight );
bool AlternativeSpelling( const SwTextFormatInfo &rInf, const sal_Int32 nPos );
- inline SwHangingPortion* GetHangingPortion() const { return pHanging; }
+ inline SwHangingPortion* GetHangingPortion() const { return pHanging.get(); }
inline void ClearHangingPortion() { pHanging = nullptr; }
inline sal_uInt16 BreakWidth() const { return nBreakWidth; }
inline sal_Int32 CutPos() const { return nCutPos; }
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index 855d4d4cd096..b4709f2461d3 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -98,13 +98,12 @@ SwLineInfo::SwLineInfo()
SwLineInfo::~SwLineInfo()
{
- delete pRuler;
}
+
void SwLineInfo::CtorInitLineInfo( const SwAttrSet& rAttrSet,
const SwTextNode& rTextNode )
{
- delete pRuler;
- pRuler = new SvxTabStopItem( rAttrSet.GetTabStops() );
+ pRuler.reset( new SvxTabStopItem( rAttrSet.GetTabStops() ) );
if ( rTextNode.GetListTabStopPosition( nListTabStopPosition ) )
{
bListTabStopIncluded = true;
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index 0be4a14e488f..7170e20563c1 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -73,7 +73,7 @@ class SwLineInfo
{
friend class SwTextIter;
- SvxTabStopItem* pRuler;
+ std::unique_ptr<SvxTabStopItem> pRuler;
const SvxLineSpacingItem *pSpace;
SvxParaVertAlignItem::Align nVertAlign;
sal_uInt16 nDefTabStop;
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index a96e94ea5dd3..39bdf05d6163 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -305,8 +305,7 @@ SwDoubleLinePortion::SwDoubleLinePortion(const SwMultiCreator& rCreate, sal_Int3
if( !pBracket->cPre && !pBracket->cPost )
{
- delete pBracket;
- pBracket = nullptr;
+ pBracket.reset();
}
// double line portions have the same direction as the frame directions
@@ -359,7 +358,7 @@ void SwDoubleLinePortion::SetBrackets( const SwDoubleLinePortion& rDouble )
{
if( rDouble.pBracket )
{
- pBracket = new SwBracket;
+ pBracket.reset( new SwBracket );
pBracket->cPre = rDouble.pBracket->cPre;
pBracket->cPost = rDouble.pBracket->cPost;
pBracket->nPreScript = rDouble.pBracket->nPreScript;
@@ -526,7 +525,6 @@ void SwDoubleLinePortion::ResetSpaceAdd( SwLineLayout* pCurr )
SwDoubleLinePortion::~SwDoubleLinePortion()
{
- delete pBracket;
}
// constructs a ruby portion, i.e. an additional text is displayed
diff --git a/sw/source/core/text/pormulti.hxx b/sw/source/core/text/pormulti.hxx
index 21242978e0b0..ea2903775a2e 100644
--- a/sw/source/core/text/pormulti.hxx
+++ b/sw/source/core/text/pormulti.hxx
@@ -146,7 +146,7 @@ public:
class SwDoubleLinePortion : public SwMultiPortion
{
- SwBracket* pBracket; // Surrounding brackets
+ std::unique_ptr<SwBracket> pBracket; // Surrounding brackets
SwTwips nLineDiff; // Difference of the width of the both lines
sal_Int32 nBlank1; // Number of blanks in the first line
sal_Int32 nBlank2; // Number of blanks in the second line
@@ -155,7 +155,7 @@ public:
SwDoubleLinePortion( const SwMultiCreator& rCreate, sal_Int32 nEnd );
virtual ~SwDoubleLinePortion() override;
- inline SwBracket* GetBrackets() const { return pBracket; }
+ inline SwBracket* GetBrackets() const { return pBracket.get(); }
void SetBrackets( const SwDoubleLinePortion& rDouble );
void PaintBracket( SwTextPaintInfo& rInf, long nSpaceAdd, bool bOpen ) const;
void FormatBrackets( SwTextFormatInfo &rInf, SwTwips& nMaxWidth );
diff --git a/sw/source/core/text/redlnitr.cxx b/sw/source/core/text/redlnitr.cxx
index 874614d72d69..49c4a5e69700 100644
--- a/sw/source/core/text/redlnitr.cxx
+++ b/sw/source/core/text/redlnitr.cxx
@@ -433,7 +433,7 @@ short SwExtend::Enter(SwFont& rFnt, sal_Int32 nNew)
nPos = nNew;
if( Inside() )
{
- pFnt = new SwFont( rFnt );
+ pFnt.reset( new SwFont( rFnt ) );
ActualizeFont( rFnt, rArr[ nPos - nStart ] );
return 1;
}
@@ -457,8 +457,7 @@ bool SwExtend::Leave_(SwFont& rFnt, sal_Int32 nNew)
else
{
rFnt = *pFnt;
- delete pFnt;
- pFnt = nullptr;
+ pFnt.reset();
return true;
}
return false;
diff --git a/sw/source/core/text/redlnitr.hxx b/sw/source/core/text/redlnitr.hxx
index 31c3cc69c7b3..bb4cc708eede 100644
--- a/sw/source/core/text/redlnitr.hxx
+++ b/sw/source/core/text/redlnitr.hxx
@@ -33,7 +33,7 @@ class SwAttrHandler;
class SwExtend
{
- SwFont *pFnt;
+ std::unique_ptr<SwFont> pFnt;
const std::vector<ExtTextInputAttr> &rArr;
sal_Int32 nStart;
sal_Int32 nPos;
@@ -42,16 +42,16 @@ class SwExtend
bool Inside() const { return ( nPos >= nStart && nPos < nEnd ); }
static void ActualizeFont( SwFont &rFnt, ExtTextInputAttr nAttr );
public:
- SwExtend( const std::vector<ExtTextInputAttr> &rA, sal_Int32 nSt ) : pFnt(nullptr), rArr( rA ),
+ SwExtend( const std::vector<ExtTextInputAttr> &rA, sal_Int32 nSt ) : rArr( rA ),
nStart( nSt ), nPos( COMPLETE_STRING ), nEnd( nStart + rA.size() ) {}
- ~SwExtend() { delete pFnt; }
+ ~SwExtend() {}
bool IsOn() const { return pFnt != nullptr; }
- void Reset() { if( pFnt ) { delete pFnt; pFnt = nullptr; } nPos = COMPLETE_STRING; }
+ void Reset() { pFnt.reset(); nPos = COMPLETE_STRING; }
bool Leave( SwFont& rFnt, sal_Int32 nNew )
{ return pFnt && Leave_( rFnt, nNew ); }
short Enter( SwFont& rFnt, sal_Int32 nNew );
sal_Int32 Next( sal_Int32 nNext );
- SwFont* GetFont() { return pFnt; }
+ SwFont* GetFont() { return pFnt.get(); }
void UpdateFont( SwFont &rFnt ) { ActualizeFont( rFnt, rArr[ nPos - nStart ] ); }
};
diff --git a/sw/source/core/text/txtcache.cxx b/sw/source/core/text/txtcache.cxx
index 4cc22f241f64..c120041bcfff 100644
--- a/sw/source/core/text/txtcache.cxx
+++ b/sw/source/core/text/txtcache.cxx
@@ -29,7 +29,6 @@ SwTextLine::SwTextLine( SwTextFrame *pFrame, SwParaPortion *pNew ) :
SwTextLine::~SwTextLine()
{
- delete pLine;
}
SwCacheObj *SwTextLineAccess::NewObj()
@@ -48,7 +47,7 @@ SwParaPortion *SwTextLineAccess::GetPara()
const_cast<SwTextFrame *>(static_cast<SwTextFrame const *>(m_pOwner))->SetCacheIdx( pRet->GetCachePos() );
}
if ( !pRet->GetPara() )
- pRet->SetPara( new SwParaPortion );
+ pRet->SetPara( new SwParaPortion, true/*bDelete*/ );
return pRet->GetPara();
}
@@ -100,8 +99,7 @@ void SwTextFrame::ClearPara()
Get( this, GetCacheIdx(), false ));
if ( pTextLine )
{
- delete pTextLine->GetPara();
- pTextLine->SetPara( nullptr );
+ pTextLine->SetPara( nullptr, true/*bDelete*/ );
}
else
mnCacheIndex = USHRT_MAX;
@@ -117,9 +115,7 @@ void SwTextFrame::SetPara( SwParaPortion *pNew, bool bDelete )
Get( this, GetCacheIdx(), false ));
if ( pTextLine )
{
- if( bDelete )
- delete pTextLine->GetPara();
- pTextLine->SetPara( pNew );
+ pTextLine->SetPara( pNew, bDelete );
}
else
{
diff --git a/sw/source/core/text/txtcache.hxx b/sw/source/core/text/txtcache.hxx
index 5ee5126cc529..2acc3de89ed9 100644
--- a/sw/source/core/text/txtcache.hxx
+++ b/sw/source/core/text/txtcache.hxx
@@ -22,13 +22,14 @@
#include <sal/types.h>
#include <tools/mempool.hxx>
#include "swcache.hxx"
+#include <memory>
class SwParaPortion;
class SwTextFrame;
class SwTextLine : public SwCacheObj
{
- SwParaPortion *pLine;
+ std::unique_ptr<SwParaPortion> pLine;
public:
DECL_FIXEDMEMPOOL_NEWDEL(SwTextLine)
@@ -36,10 +37,10 @@ public:
SwTextLine( SwTextFrame *pFrame, SwParaPortion *pNew = nullptr );
virtual ~SwTextLine() override;
- inline SwParaPortion *GetPara() { return pLine; }
- inline const SwParaPortion *GetPara() const { return pLine; }
+ inline SwParaPortion *GetPara() { return pLine.get(); }
+ inline const SwParaPortion *GetPara() const { return pLine.get(); }
- inline void SetPara( SwParaPortion *pNew ) { pLine = pNew; }
+ inline void SetPara( SwParaPortion *pNew, bool bDelete ) { if (!bDelete) pLine.release(); pLine.reset( pNew ); }
};
class SwTextLineAccess : public SwCacheAccess
diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx
index 309e3e3be8a6..9abedf1d7a28 100644
--- a/sw/source/core/text/txtfly.cxx
+++ b/sw/source/core/text/txtfly.cxx
@@ -340,11 +340,7 @@ SwTextFly::SwTextFly( const SwTextFly& rTextFly )
pMaster = rTextFly.pMaster;
if( rTextFly.mpAnchoredObjList )
{
- mpAnchoredObjList = new SwAnchoredObjList( *(rTextFly.mpAnchoredObjList) );
- }
- else
- {
- mpAnchoredObjList = nullptr;
+ mpAnchoredObjList.reset( new SwAnchoredObjList( *(rTextFly.mpAnchoredObjList) ) );
}
bOn = rTextFly.bOn;
@@ -359,7 +355,6 @@ SwTextFly::SwTextFly( const SwTextFly& rTextFly )
SwTextFly::~SwTextFly()
{
- delete mpAnchoredObjList;
}
void SwTextFly::CtorInitTextFly( const SwTextFrame *pFrame )
@@ -373,8 +368,6 @@ void SwTextFly::CtorInitTextFly( const SwTextFrame *pFrame )
mpCurrAnchoredObj = pTmp;
pCurrFrame = pFrame;
pMaster = pCurrFrame->IsFollow() ? nullptr : pCurrFrame;
- // #i68520#
- mpAnchoredObjList = nullptr;
// If we're not overlapped by a frame or if a FlyCollection does not exist
// at all, we switch off forever.
// It could be, however, that a line is added while formatting, that
@@ -858,7 +851,7 @@ SwAnchoredObjList* SwTextFly::InitAnchoredObjList()
if( nCount && bWrapAllowed )
{
// #i68520#
- mpAnchoredObjList = new SwAnchoredObjList();
+ mpAnchoredObjList.reset(new SwAnchoredObjList );
// #i28701# - consider complete frame area for new
// text wrapping
@@ -960,11 +953,11 @@ SwAnchoredObjList* SwTextFly::InitAnchoredObjList()
else
{
// #i68520#
- mpAnchoredObjList = new SwAnchoredObjList();
+ mpAnchoredObjList.reset( new SwAnchoredObjList );
}
// #i68520#
- return mpAnchoredObjList;
+ return mpAnchoredObjList.get();
}
SwTwips SwTextFly::CalcMinBottom() const
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index 89d444e4ede8..5644ee3e5067 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -69,8 +69,7 @@ using namespace ::com::sun::star;
// Hintergrundbrush setzen, z.B. bei Zeichenvorlagen
void SwFont::SetBackColor( Color* pNewColor )
{
- delete m_pBackColor;
- m_pBackColor = pNewColor;
+ m_pBackColor.reset( pNewColor );
m_bFontChg = true;
m_aSub[SwFontScript::Latin].m_pMagic = m_aSub[SwFontScript::CJK].m_pMagic = m_aSub[SwFontScript::CTL].m_pMagic = nullptr;
}
@@ -481,8 +480,7 @@ sal_uInt16 SwSubFont::CalcEscAscent( const sal_uInt16 nOldAscent ) const
void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
const IDocumentSettingAccess *pIDocumentSettingAccess )
{
- delete m_pBackColor;
- m_pBackColor = nullptr;
+ m_pBackColor.reset();
if( pAttrSet )
{
@@ -661,7 +659,7 @@ void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
SetVertical( static_cast<const SvxCharRotateItem*>(pItem)->GetValue() );
if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
true, &pItem ))
- m_pBackColor = new Color( static_cast<const SvxBrushItem*>(pItem)->GetColor() );
+ m_pBackColor.reset( new Color( static_cast<const SvxBrushItem*>(pItem)->GetColor() ) );
if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
true, &pItem ))
SetHighlightColor(static_cast<const SvxBrushItem*>(pItem)->GetColor());
@@ -706,7 +704,7 @@ SwFont::SwFont( const SwFont &rFont )
: m_aSub(rFont.m_aSub)
{
m_nActual = rFont.m_nActual;
- m_pBackColor = rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr;
+ m_pBackColor.reset( rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr );
m_aHighlightColor = rFont.m_aHighlightColor;
m_aTopBorder = rFont.m_aTopBorder;
m_aBottomBorder = rFont.m_aBottomBorder;
@@ -837,9 +835,7 @@ SwFont::SwFont( const SwAttrSet* pAttrSet,
const SfxPoolItem* pItem;
if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
true, &pItem ))
- m_pBackColor = new Color( static_cast<const SvxBrushItem*>(pItem)->GetColor() );
- else
- m_pBackColor = nullptr;
+ m_pBackColor.reset( new Color( static_cast<const SvxBrushItem*>(pItem)->GetColor() ) );
if( SfxItemState::SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
true, &pItem ))
SetHighlightColor(static_cast<const SvxBrushItem*>(pItem)->GetColor());
@@ -900,7 +896,6 @@ SwFont::SwFont( const SwAttrSet* pAttrSet,
SwFont::~SwFont()
{
- delete m_pBackColor;
}
SwSubFont& SwSubFont::operator=( const SwSubFont &rFont )
@@ -922,8 +917,7 @@ SwFont& SwFont::operator=( const SwFont &rFont )
m_aSub[SwFontScript::CJK] = rFont.m_aSub[SwFontScript::CJK];
m_aSub[SwFontScript::CTL] = rFont.m_aSub[SwFontScript::CTL];
m_nActual = rFont.m_nActual;
- delete m_pBackColor;
- m_pBackColor = rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr;
+ m_pBackColor.reset( rFont.m_pBackColor ? new Color( *rFont.m_pBackColor ) : nullptr );
m_aHighlightColor = rFont.m_aHighlightColor;
m_aTopBorder = rFont.m_aTopBorder;
m_aBottomBorder = rFont.m_aBottomBorder;
@@ -1508,7 +1502,6 @@ SwUnderlineFont::SwUnderlineFont( SwFont& rFnt, sal_Int32 nEnd, const Point& rPo
SwUnderlineFont::~SwUnderlineFont()
{
- delete m_pFont;
}
/// Helper for filters to find true lineheight of a font
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index 7a69b29d35b8..6717a1e2df92 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -166,12 +166,11 @@ SwUndoDelNum::SwUndoDelNum( const SwPaM& rPam )
: SwUndo( UNDO_DELNUM, rPam.GetDoc() ), SwUndRng( rPam )
{
aNodes.reserve( nEndNode - nSttNode > 255 ? 255 : nEndNode - nSttNode );
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
}
SwUndoDelNum::~SwUndoDelNum()
{
- delete pHistory;
}
void SwUndoDelNum::UndoImpl(::sw::UndoRedoContext & rContext)