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

Noel Grandin noel.grandin at collabora.co.uk
Fri Jan 13 08:34:24 UTC 2017


 sw/inc/EnhancedPDFExportHelper.hxx              |    2 -
 sw/inc/anchoreddrawobject.hxx                   |    4 +--
 sw/inc/calc.hxx                                 |    2 -
 sw/inc/cellfml.hxx                              |    2 -
 sw/inc/dpage.hxx                                |    4 +--
 sw/inc/expfld.hxx                               |    6 ++---
 sw/inc/fmtcntnt.hxx                             |    4 +--
 sw/inc/fmturl.hxx                               |    7 +++---
 sw/inc/list.hxx                                 |    3 +-
 sw/inc/ndnotxt.hxx                              |    2 -
 sw/inc/numrule.hxx                              |    2 -
 sw/inc/redline.hxx                              |    6 ++---
 sw/inc/shellio.hxx                              |    2 -
 sw/source/core/access/accportions.cxx           |    3 --
 sw/source/core/access/accportions.hxx           |    2 -
 sw/source/core/bastyp/calc.cxx                  |   13 +++++-------
 sw/source/core/crsr/findattr.cxx                |    8 +++----
 sw/source/core/doc/doccomp.cxx                  |   17 +++++++---------
 sw/source/core/doc/docfld.cxx                   |   13 +++++-------
 sw/source/core/doc/docredln.cxx                 |   18 ++++++-----------
 sw/source/core/doc/htmltbl.cxx                  |   11 ++++------
 sw/source/core/doc/list.cxx                     |    1 
 sw/source/core/doc/number.cxx                   |   15 ++------------
 sw/source/core/docnode/ndnotxt.cxx              |   15 +++++---------
 sw/source/core/draw/dpage.cxx                   |   12 ++++-------
 sw/source/core/edit/acorrect.cxx                |    8 ++-----
 sw/source/core/fields/cellfml.cxx               |    3 --
 sw/source/core/fields/fldlst.cxx                |    3 --
 sw/source/core/inc/UndoNumbering.hxx            |    6 ++---
 sw/source/core/inc/acorrect.hxx                 |    2 -
 sw/source/core/inc/objectformatter.hxx          |    3 +-
 sw/source/core/inc/swblocks.hxx                 |    3 +-
 sw/source/core/inc/swfont.hxx                   |    7 +++---
 sw/source/core/inc/txtfly.hxx                   |   12 +++++------
 sw/source/core/layout/anchoreddrawobject.cxx    |    4 ---
 sw/source/core/layout/atrfrm.cxx                |   25 ++++++++++--------------
 sw/source/core/layout/layouter.cxx              |   15 ++++++--------
 sw/source/core/layout/objectformatter.cxx       |    1 
 sw/source/core/swg/swblocks.cxx                 |    5 +---
 sw/source/core/text/EnhancedPDFExportHelper.cxx |    4 ---
 sw/source/core/text/atrhndl.hxx                 |    4 +--
 sw/source/core/text/atrstck.cxx                 |    4 ---
 sw/source/core/text/frmpaint.cxx                |   10 ++++-----
 sw/source/core/text/guess.cxx                   |    2 -
 sw/source/core/text/guess.hxx                   |    6 ++---
 sw/source/core/text/inftxt.cxx                  |    5 +---
 sw/source/core/text/inftxt.hxx                  |    2 -
 sw/source/core/text/pormulti.cxx                |    6 +----
 sw/source/core/text/pormulti.hxx                |    4 +--
 sw/source/core/text/redlnitr.cxx                |    5 +---
 sw/source/core/text/redlnitr.hxx                |   10 ++++-----
 sw/source/core/text/txtcache.cxx                |   10 ++-------
 sw/source/core/text/txtcache.hxx                |    9 ++++----
 sw/source/core/text/txtfly.cxx                  |   15 +++-----------
 sw/source/core/txtnode/swfont.cxx               |   19 +++++-------------
 sw/source/core/undo/unnum.cxx                   |    3 --
 56 files changed, 166 insertions(+), 223 deletions(-)

New commits:
commit a706bb06d5326e7a997dd1d71f3f947bd0ad28e6
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Wed Jan 11 14:26:47 2017 +0200

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

diff --git a/sw/inc/EnhancedPDFExportHelper.hxx b/sw/inc/EnhancedPDFExportHelper.hxx
index c1d3e30..0aab233 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 1e63888..38561d7 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 8f54ab3..630c43c 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 85c8787..3f918bd 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 75d63b0..a000e70 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 bee8249..fb970db 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 b8aa2b6..62580c7 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 e6ea18b..b043939 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 2c3daf7..d3ef07c 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 7ba253e..531e17c 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 88b8d5c..028003c 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 fe55dd6..fbe0ccc 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 ce17192..be6b078 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 172a7ca..3f1093f 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 bd84e2c..97248bd 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 75941ad..8862dd3 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 fa25c7f..73b5777 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 ea21991..380e565 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 9282e01..7dc05e7 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 fe20071..95725bc 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 ace49e9..ec89c26 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 2e3f9bb..753965a 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 441461f..5db16bb 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 8b2bbde..3c39388 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 bea0588..8163b26 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 afc4d18..ce1004d 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 cb8da52..1d55ab8 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 e075d3d..04e0f60 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 f3ce48b..7d2c6f9 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 afbb1fd..104b365 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 e010ee2..ddeb9d1 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 2c0dc88..4899e35 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 fd41e41..caef07d 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 5c22fef..7844d8c 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 1c95425..0b11e22 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 6ca6ef1..566f785 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 638d0e7..8e455c5 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 a59c834..ff5ff9c 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 99f0751..c84b29e 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 6a4c102..dde3c45 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 0b7caf1..d9dc3c9 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 418556f..6951d02 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 7f6efc6..1e6027e 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 e347013..a13ed24 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 e8023c2..75bc915 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 855d4d4..b4709f2 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 0be4a14..7170e20 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 a96e94e..39bdf05 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 2124297..ea29037 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 874614d..49c4a5e 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 31c3cc6..bb4cc70 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> ⇒
     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 4cc22f2..c120041 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 5ee5126..2acc3de 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 309e3e3..9abedf1 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 89d444e..5644ee3 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 7a69b29..6717a1e 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)


More information about the Libreoffice-commits mailing list