sw/source/filter/ww8/ww8par.hxx | 2 +- sw/source/filter/ww8/ww8par3.cxx | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-)
New commits: commit c751fd0ebd6724fe2b8ee9f308841cabbb002391 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 16 11:44:52 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 17 08:23:36 2018 +0200 loplugin:useuniqueptr in WW8ListManager Change-Id: Ibd6486889797a4e660c63377a1fd3d577747aec0 Reviewed-on: https://gerrit.libreoffice.org/59229 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index ccab8afb730a..64c49ba6c5a1 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -162,7 +162,7 @@ private: SwDoc& rDoc; const WW8Fib& rFib; SvStream& rSt; - std::vector<WW8LSTInfo* > maLSTInfos; + std::vector<std::unique_ptr<WW8LSTInfo>> maLSTInfos; std::vector<std::unique_ptr<WW8LFOInfo>> m_LFOInfos;// D. from PLF LFO, sorted exactly like in the WW8 Stream sal_uInt16 nUniqueList; // current number for creating unique list names SprmResult GrpprlHasSprm(sal_uInt16 nId, sal_uInt8& rSprms, sal_uInt8 nLen); diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx index 9d77bb574592..bda1388f5034 100644 --- a/sw/source/filter/ww8/ww8par3.cxx +++ b/sw/source/filter/ww8/ww8par3.cxx @@ -451,18 +451,18 @@ private: sal_uInt32 mnIdLst; public: explicit ListWithId(sal_uInt32 nIdLst) : mnIdLst(nIdLst) {} - bool operator() (const WW8LSTInfo *pEntry) const + bool operator() (const std::unique_ptr<WW8LSTInfo>& pEntry) const { return (pEntry->nIdLst == mnIdLst); } }; // Access via List-Id of LST Entry WW8LSTInfo* WW8ListManager::GetLSTByListId( sal_uInt32 nIdLst ) const { - std::vector<WW8LSTInfo *>::const_iterator aResult = + auto aResult = std::find_if(maLSTInfos.begin(),maLSTInfos.end(),ListWithId(nIdLst)); if (aResult == maLSTInfos.end()) return nullptr; - return *aResult; + return aResult->get(); } static void lcl_CopyGreaterEight(OUString &rDest, OUString const &rSrc, @@ -1216,7 +1216,7 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_) aLST.bSimpleList || (aBits1 & 0x10)); WW8LSTInfo* pLSTInfo = new WW8LSTInfo(pMyNumRule, aLST); - maLSTInfos.push_back(pLSTInfo); + maLSTInfos.emplace_back(pLSTInfo); nRemainingPlcfLst -= cbLSTF; } @@ -1228,7 +1228,7 @@ WW8ListManager::WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_) { WW8aISet aItemSet; // Character attributes from GrpprlChpx - WW8LSTInfo* pListInfo = maLSTInfos[nList]; + WW8LSTInfo* pListInfo = maLSTInfos[nList].get(); if( !pListInfo || !pListInfo->pNumRule ) break; SwNumRule& rMyNumRule = *pListInfo->pNumRule; @@ -1474,15 +1474,14 @@ WW8ListManager::~WW8ListManager() COVERITY_NOEXCEPT_FALSE named lists remain in document unused automatic lists are removed from document (DelNumRule) */ - for(std::vector<WW8LSTInfo *>::iterator aIter = maLSTInfos.begin(); - aIter != maLSTInfos.end(); ++aIter) + for(auto & rpInfo : maLSTInfos) { - if ((*aIter)->pNumRule && !(*aIter)->bUsedInDoc && - (*aIter)->pNumRule->IsAutoRule()) + if (rpInfo->pNumRule && !rpInfo->bUsedInDoc && + rpInfo->pNumRule->IsAutoRule()) { - rDoc.DelNumRule((*aIter)->pNumRule->GetName()); + rDoc.DelNumRule(rpInfo->pNumRule->GetName()); } - delete *aIter; + rpInfo.reset(); } for (auto aIter = m_LFOInfos.rbegin(); aIter != m_LFOInfos.rend(); ++aIter) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits