diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-11 14:19:47 +0200 |
---|---|---|
committer | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2017-11-28 00:12:48 -0500 |
commit | 051b2fbdad2a4b18f6d4b30134438e11fb9bec64 (patch) | |
tree | 676ceceb365455c0144a4ce93fa563e0d895d82d /sw | |
parent | fb68934e81bebdf1580d0fad25fad8912eaf3450 (diff) |
new loplugin useuniqueptr
Change-Id: Ic7a8b32887c968d86568e4cfad7ddd1f4da7c73f
Reviewed-on: https://gerrit.libreoffice.org/33339
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
(cherry picked from commit 98e4013c22c4ce63090a575e698cc2af82925e6b)
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 3 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.cxx | 14 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8scan.hxx | 9 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8toolbar.cxx | 6 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8toolbar.hxx | 5 | ||||
-rw-r--r-- | sw/source/ui/index/swuiidxmrk.cxx | 4 | ||||
-rw-r--r-- | sw/source/uibase/inc/swuiidxmrk.hxx | 4 |
9 files changed, 28 insertions, 35 deletions
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 12b0b225c4d2..94a7de406b91 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -1923,7 +1923,6 @@ WW8_WrPlcSubDoc::WW8_WrPlcSubDoc() WW8_WrPlcSubDoc::~WW8_WrPlcSubDoc() { - delete pTextPos; } void WW8_WrPlcFootnoteEdn::Append( WW8_CP nCp, const SwFormatFootnote& rFootnote ) @@ -2006,7 +2005,7 @@ bool WW8_WrPlcSubDoc::WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp, return false; sal_uLong nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() ); - pTextPos = new WW8_WrPlc0( nCpStart ); + pTextPos.reset( new WW8_WrPlc0( nCpStart ) ); sal_uInt16 i; switch ( nTTyp ) diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 9a7bf2a85fa5..e0071f84013c 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -814,12 +814,11 @@ WW8_WrPlc1::WW8_WrPlc1( sal_uInt16 nStructSz ) : nStructSiz( nStructSz ) { nDataLen = 16 * nStructSz; - pData = new sal_uInt8[ nDataLen ]; + pData.reset( new sal_uInt8[ nDataLen ] ); } WW8_WrPlc1::~WW8_WrPlc1() { - delete[] pData; } WW8_CP WW8_WrPlc1::Prev() const @@ -836,12 +835,11 @@ void WW8_WrPlc1::Append( WW8_CP nCp, const void* pNewData ) if( nDataLen < nInsPos + nStructSiz ) { sal_uInt8* pNew = new sal_uInt8[ 2 * nDataLen ]; - memcpy( pNew, pData, nDataLen ); - delete[] pData; - pData = pNew; + memcpy( pNew, pData.get(), nDataLen ); + pData.reset(pNew); nDataLen *= 2; } - memcpy( pData + nInsPos, pNewData, nStructSiz ); + memcpy( pData.get() + nInsPos, pNewData, nStructSiz ); } void WW8_WrPlc1::Finish( sal_uLong nLastCp, sal_uLong nSttCp ) @@ -861,7 +859,7 @@ void WW8_WrPlc1::Write( SvStream& rStrm ) for( i = 0; i < aPos.size(); ++i ) SwWW8Writer::WriteLong( rStrm, aPos[i] ); if( i ) - rStrm.WriteBytes(pData, (i-1) * nStructSiz); + rStrm.WriteBytes(pData.get(), (i-1) * nStructSiz); } // Class WW8_WrPlcField for fields diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index 41e673c8f65b..1382cef1b5b0 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1165,8 +1165,8 @@ private: protected: std::vector<WW8_CP> aCps; std::vector<const void*> aContent; // PTRARR of SwFormatFootnote/PostIts/.. - std::vector<const SwFrameFormat*> aSpareFormats; //a backup for aContent: if there's no SdrObject, stores the fmt directly here - WW8_WrPlc0* pTextPos; // positions of the individual texts + std::vector<const SwFrameFormat*> aSpareFormats; // a backup for aContent: if there's no SdrObject, stores the fmt directly here + std::unique_ptr<WW8_WrPlc0> pTextPos; // positions of the individual texts WW8_WrPlcSubDoc(); virtual ~WW8_WrPlcSubDoc(); @@ -1277,7 +1277,7 @@ class WW8_WrPlc1 { private: std::vector<WW8_CP> aPos; - sal_uInt8* pData; // content ( structures ) + std::unique_ptr<sal_uInt8[]> pData; // content ( structures ) sal_uLong nDataLen; sal_uInt16 nStructSiz; diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx index ec3dc11da85c..4f084c923cb5 100644 --- a/sw/source/filter/ww8/ww8scan.cxx +++ b/sw/source/filter/ww8/ww8scan.cxx @@ -1138,14 +1138,12 @@ WW8PLCFx_PCD::WW8PLCFx_PCD(const WW8Fib& rFib, WW8PLCFpcd* pPLCFpcd, : WW8PLCFx(rFib, false), nClipStart(-1) { // construct own iterator - pPcdI = new WW8PLCFpcd_Iter(*pPLCFpcd, nStartCp); + pPcdI.reset( new WW8PLCFpcd_Iter(*pPLCFpcd, nStartCp) ); bVer67= bVer67P; } WW8PLCFx_PCD::~WW8PLCFx_PCD() { - // pPcd-Dtor which in called from WW8ScannerBase - delete pPcdI; } sal_uLong WW8PLCFx_PCD::GetIMax() const @@ -3110,8 +3108,8 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt, { ResetAttrStartEnd(); - pPcd = rSBase.m_pPiecePLCF ? new WW8PLCFx_PCD(GetFIB(), - rBase.m_pPiecePLCF, 0, IsSevenMinus(GetFIBVersion())) : nullptr; + if (rSBase.m_pPiecePLCF) + pPcd.reset( new WW8PLCFx_PCD(GetFIB(), rBase.m_pPiecePLCF, 0, IsSevenMinus(GetFIBVersion())) ); /* Make a copy of the piece attributes for so that the calls to HasSprm on a @@ -3122,7 +3120,7 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt, if (pPcd) { pPCDAttrs = rSBase.m_pPLCFx_PCDAttrs ? new WW8PLCFx_PCDAttrs( - *rSBase.m_pWw8Fib, pPcd, &rSBase) : nullptr; + *rSBase.m_pWw8Fib, pPcd.get(), &rSBase) : nullptr; } pPieceIter = rSBase.m_pPieceIter; @@ -3130,7 +3128,6 @@ WW8PLCFx_Cp_FKP::WW8PLCFx_Cp_FKP( SvStream* pSt, SvStream* pTableSt, WW8PLCFx_Cp_FKP::~WW8PLCFx_Cp_FKP() { - delete pPcd; } void WW8PLCFx_Cp_FKP::ResetAttrStartEnd() @@ -3692,12 +3689,11 @@ WW8PLCFx_FLD::WW8PLCFx_FLD( SvStream* pSt, const WW8Fib& rMyFib, short nType) } if( nLen ) - pPLCF = new WW8PLCFspecial( pSt, nFc, nLen, 2 ); + pPLCF.reset( new WW8PLCFspecial( pSt, nFc, nLen, 2 ) ); } WW8PLCFx_FLD::~WW8PLCFx_FLD() { - delete pPLCF; } sal_uInt32 WW8PLCFx_FLD::GetIdx() const diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx index 3587a9fabdf5..ff2fc7a7e07b 100644 --- a/sw/source/filter/ww8/ww8scan.hxx +++ b/sw/source/filter/ww8/ww8scan.hxx @@ -27,6 +27,7 @@ #include <cassert> #include <cstddef> #include <list> +#include <memory> #include <stack> #include <unordered_map> #include <vector> @@ -452,7 +453,7 @@ public: class WW8PLCFx_PCD : public WW8PLCFx // iterator for Piece table { private: - WW8PLCFpcd_Iter* pPcdI; + std::unique_ptr<WW8PLCFpcd_Iter> pPcdI; bool bVer67; WW8_CP nClipStart; @@ -474,7 +475,7 @@ public: WW8_FC AktPieceStartCp2Fc( WW8_CP nCp ); static void AktPieceFc2Cp(WW8_CP& rStartPos, WW8_CP& rEndPos, const WW8ScannerBase *pSBase); - WW8PLCFpcd_Iter* GetPLCFIter() { return pPcdI; } + WW8PLCFpcd_Iter* GetPLCFIter() { return pPcdI.get(); } void SetClipStart(WW8_CP nIn) { nClipStart = nIn; } WW8_CP GetClipStart() { return nClipStart; } @@ -618,7 +619,7 @@ class WW8PLCFx_Cp_FKP : public WW8PLCFx_Fc_FKP { private: const WW8ScannerBase& rSBase; - WW8PLCFx_PCD* pPcd; + std::unique_ptr<WW8PLCFx_PCD> pPcd; WW8PLCFpcd_Iter *pPieceIter; WW8_CP nAttrStart, nAttrEnd; bool bLineEnd : 1; @@ -709,7 +710,7 @@ public: class WW8PLCFx_FLD : public WW8PLCFx { private: - WW8PLCFspecial* pPLCF; + std::unique_ptr<WW8PLCFspecial> pPLCF; const WW8Fib& rFib; WW8PLCFx_FLD(const WW8PLCFx_FLD&) = delete; WW8PLCFx_FLD& operator=(const WW8PLCFx_FLD &) = delete; diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx index 15c0abb63c94..0b6ddcd8ebb6 100644 --- a/sw/source/filter/ww8/ww8toolbar.cxx +++ b/sw/source/filter/ww8/ww8toolbar.cxx @@ -1102,7 +1102,6 @@ TcgSttbfCore::TcgSttbfCore() : fExtend( 0 ) TcgSttbfCore::~TcgSttbfCore() { - delete[] dataItems; } bool TcgSttbfCore::Read( SvStream& rS ) @@ -1114,7 +1113,7 @@ bool TcgSttbfCore::Read( SvStream& rS ) { if (cData > rS.remainingSize() / 4) //definitely an invalid record return false; - dataItems = new SBBItem[ cData ]; + dataItems.reset( new SBBItem[ cData ] ); for ( sal_Int32 index = 0; index < cData; ++index ) { rS.ReadUInt16( dataItems[ index ].cchData ); @@ -1150,7 +1149,6 @@ MacroNames::MacroNames() : MacroNames::~MacroNames() { - delete[] rgNames; } bool MacroNames::Read( SvStream &rS) @@ -1165,7 +1163,7 @@ bool MacroNames::Read( SvStream &rS) size_t nMaxAvailableRecords = rS.remainingSize()/sizeof(sal_uInt16); if (iMac > nMaxAvailableRecords) return false; - rgNames = new MacroName[ iMac ]; + rgNames.reset( new MacroName[ iMac ] ); for ( sal_Int32 index = 0; index < iMac; ++index ) { if ( !rgNames[ index ].Read( rS ) ) diff --git a/sw/source/filter/ww8/ww8toolbar.hxx b/sw/source/filter/ww8/ww8toolbar.hxx index c5079f4eb617..01f3e8fc6aa2 100644 --- a/sw/source/filter/ww8/ww8toolbar.hxx +++ b/sw/source/filter/ww8/ww8toolbar.hxx @@ -11,6 +11,7 @@ #include <com/sun/star/container/XIndexContainer.hpp> #include <filter/msfilter/mstoolbar.hxx> +#include <memory> class Xst : public TBBase { @@ -294,7 +295,7 @@ class TcgSttbfCore : public TBBase sal_uInt16 fExtend; sal_uInt16 cData; sal_uInt16 cbExtra; - SBBItem* dataItems; + std::unique_ptr<SBBItem[]> dataItems; TcgSttbfCore(const TcgSttbfCore&) = delete; TcgSttbfCore& operator = ( const TcgSttbfCore&) = delete; @@ -358,7 +359,7 @@ public: class MacroNames : public Tcg255SubStruct { sal_uInt16 iMac; //An unsigned integer that specifies the number of MacroName structures in rgNames. - MacroName* rgNames; + std::unique_ptr<MacroName[]> rgNames; MacroNames(const MacroNames&) = delete; MacroNames& operator = ( const MacroNames&) = delete; diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index e8d4ef2b492c..9f02e3f4411c 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -949,14 +949,12 @@ IMPL_LINK( SwIndexMarkPane, KeyDCBModifyHdl, Edit&, rEdit, void ) SwIndexMarkPane::~SwIndexMarkPane() { - delete pTOXMgr; } void SwIndexMarkPane::ReInitDlg(SwWrtShell& rWrtShell, SwTOXMark* pCurTOXMark) { pSh = &rWrtShell; - delete pTOXMgr; - pTOXMgr = new SwTOXMgr(pSh); + pTOXMgr.reset( new SwTOXMgr(pSh) ); if(pCurTOXMark) { for(sal_uInt16 i = 0; i < pTOXMgr->GetTOXMarkCount(); i++) diff --git a/sw/source/uibase/inc/swuiidxmrk.hxx b/sw/source/uibase/inc/swuiidxmrk.hxx index 609e2d1b8c14..2ae2ab4f4a0e 100644 --- a/sw/source/uibase/inc/swuiidxmrk.hxx +++ b/sw/source/uibase/inc/swuiidxmrk.hxx @@ -35,6 +35,7 @@ #include <sfx2/childwin.hxx> #include "toxe.hxx" #include <com/sun/star/i18n/XExtendedIndexEntrySupplier.hpp> +#include <memory> class SwWrtShell; class SwTOXMgr; @@ -99,7 +100,8 @@ class SwIndexMarkPane css::uno::Reference< css::i18n::XExtendedIndexEntrySupplier > xExtendedIndexEntrySupplier; - SwTOXMgr* pTOXMgr; + std::unique_ptr<SwTOXMgr> + pTOXMgr; SwWrtShell* pSh; void Apply(); |