filter/source/graphicfilter/icgm/chart.cxx | 28 +++++----------------------- filter/source/graphicfilter/icgm/chart.hxx | 5 ++--- filter/source/graphicfilter/icgm/class7.cxx | 4 ++-- sw/source/filter/inc/msfilter.hxx | 8 ++++---- sw/source/filter/ww8/writerhelper.cxx | 12 ++++++------ sw/source/filter/ww8/ww8par.cxx | 3 +-- sw/source/filter/ww8/ww8par.hxx | 10 +++++----- 7 files changed, 25 insertions(+), 45 deletions(-)
New commits: commit 45c2eb2eced00c51198ea2e4e09a8c06d0a81305 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Aug 14 17:17:00 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 15 08:42:12 2018 +0200 loplugin:useuniqueptr in RedlineStack Change-Id: I8e4f3599d30f94cfaa418f0adb35cf9fba97ff53 Reviewed-on: https://gerrit.libreoffice.org/59032 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx index 9cd6dec4455f..4babe2e56c95 100644 --- a/sw/source/filter/inc/msfilter.hxx +++ b/sw/source/filter/inc/msfilter.hxx @@ -292,7 +292,7 @@ namespace sw class RedlineStack { private: - std::vector<SwFltStackEntry *> maStack; + std::vector<std::unique_ptr<SwFltStackEntry>> maStack; SwDoc &mrDoc; RedlineStack(RedlineStack const&) = delete; @@ -315,7 +315,7 @@ namespace sw SwDoc &mrDoc; public: explicit SetInDocAndDelete(SwDoc &rDoc) : mrDoc(rDoc) {} - void operator()(SwFltStackEntry *pEntry); + void operator()(std::unique_ptr<SwFltStackEntry> & pEntry); private: SetInDocAndDelete& operator=(const SetInDocAndDelete&) = delete; }; @@ -326,7 +326,7 @@ namespace sw const SwPosition &mrPos; public: explicit SetEndIfOpen(const SwPosition &rPos) : mrPos(rPos) {} - void operator()(SwFltStackEntry *pEntry) const + void operator()(std::unique_ptr<SwFltStackEntry> & pEntry) const { if (pEntry->bOpen) pEntry->SetEndPos(mrPos); @@ -338,7 +338,7 @@ namespace sw class CompareRedlines { public: - bool operator()(const SwFltStackEntry *pOneE, const SwFltStackEntry *pTwoE) + bool operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, const std::unique_ptr<SwFltStackEntry> & pTwoE) const; }; diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index 9e94dd9a3e17..03821f0b1696 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -682,7 +682,7 @@ namespace sw void RedlineStack::open(const SwPosition& rPos, const SfxPoolItem& rAttr) { OSL_ENSURE(rAttr.Which() == RES_FLTR_REDLINE, "not a redline"); - maStack.push_back(new SwFltStackEntry(rPos,rAttr.Clone())); + maStack.emplace_back(new SwFltStackEntry(rPos,rAttr.Clone())); } class SameOpenRedlineType @@ -691,7 +691,7 @@ namespace sw RedlineType_t meType; public: explicit SameOpenRedlineType(RedlineType_t eType) : meType(eType) {} - bool operator()(const SwFltStackEntry *pEntry) const + bool operator()(const std::unique_ptr<SwFltStackEntry> & pEntry) const { const SwFltRedline *pTest = static_cast<const SwFltRedline *> (pEntry->pAttr.get()); @@ -771,7 +771,7 @@ namespace sw } } - void SetInDocAndDelete::operator()(SwFltStackEntry *pEntry) + void SetInDocAndDelete::operator()(std::unique_ptr<SwFltStackEntry>& pEntry) { SwPaM aRegion(pEntry->m_aMkPos.m_nNode); if ( @@ -805,11 +805,11 @@ namespace sw mrDoc.getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::NONE | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete ); } - delete pEntry; + pEntry.reset(); } - bool CompareRedlines::operator()(const SwFltStackEntry *pOneE, - const SwFltStackEntry *pTwoE) const + bool CompareRedlines::operator()(const std::unique_ptr<SwFltStackEntry> & pOneE, + const std::unique_ptr<SwFltStackEntry> & pTwoE) const { const SwFltRedline *pOne= static_cast<const SwFltRedline*> (pOneE->pAttr.get()); diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index 648752df60fc..c6f7248de8d3 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4281,13 +4281,12 @@ SwWW8ImplReader::~SwWW8ImplReader() { } -void SwWW8ImplReader::DeleteStack(SwFltControlStack* pStck) +void SwWW8ImplReader::DeleteStack(std::unique_ptr<SwFltControlStack> pStck) { if( pStck ) { pStck->SetAttr( *m_pPaM->GetPoint(), 0, false); pStck->SetAttr( *m_pPaM->GetPoint(), 0, false); - delete pStck; } else { diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 2e1baeac0778..ccab8afb730a 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1395,19 +1395,19 @@ private: void CopyPageDescHdFt( const SwPageDesc* pOrgPageDesc, SwPageDesc* pNewPageDesc, sal_uInt8 nCode ); - void DeleteStack(SwFltControlStack* prStck); + void DeleteStack(std::unique_ptr<SwFltControlStack> prStck); void DeleteCtrlStack() { - DeleteStack(m_xCtrlStck.release()); + DeleteStack(std::move(m_xCtrlStck)); } void DeleteRefStacks() { - DeleteStack(m_xReffedStck.release()); - DeleteStack(m_xReffingStck.release()); + DeleteStack(std::move(m_xReffedStck)); + DeleteStack(std::move(m_xReffingStck)); } void DeleteAnchorStack() { - DeleteStack(m_xAnchorStck.release()); + DeleteStack(std::move(m_xAnchorStck)); } void emulateMSWordAddTextToParagraph(const OUString& rAddString); void simpleAddTextToParagraph(const OUString& rAddString); commit 92f9fcc99d103a572d42b00a0227e3d8d8303be6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Aug 14 10:10:25 2018 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Aug 15 08:42:01 2018 +0200 loplugin:useuniqueptr in CGMChart Change-Id: I55e11d158c50a76b0fad1da0e1adc3712990aa8f Reviewed-on: https://gerrit.libreoffice.org/59028 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/filter/source/graphicfilter/icgm/chart.cxx b/filter/source/graphicfilter/icgm/chart.cxx index eaefef22195e..afd39f69e556 100644 --- a/filter/source/graphicfilter/icgm/chart.cxx +++ b/filter/source/graphicfilter/icgm/chart.cxx @@ -33,34 +33,16 @@ CGMChart::CGMChart() CGMChart::~CGMChart() { // delete the whole textentry structure - - while( !maTextEntryList.empty() ) - { - DeleteTextEntry( maTextEntryList[ 0 ] ); - } -} - -void CGMChart::DeleteTextEntry( TextEntry* pTextEntry ) -{ - if ( pTextEntry ) + for (auto & pTextEntry : maTextEntryList) { - delete pTextEntry->pText; - ::std::vector< TextEntry* >::iterator it; - for ( it = maTextEntryList.begin(); it != maTextEntryList.end(); ++it ) - { - if ( *it == pTextEntry ) - { - maTextEntryList.erase( it ); - break; - } - } - delete pTextEntry; + if ( pTextEntry ) + delete pTextEntry->pText; } } -void CGMChart::InsertTextEntry( TextEntry* pTextEntry ) +void CGMChart::InsertTextEntry( std::unique_ptr<TextEntry> pTextEntry ) { - maTextEntryList.push_back( pTextEntry ); + maTextEntryList.push_back( std::move(pTextEntry) ); } void CGMChart::ResetAnnotation() diff --git a/filter/source/graphicfilter/icgm/chart.hxx b/filter/source/graphicfilter/icgm/chart.hxx index 445d558978d3..837015614696 100644 --- a/filter/source/graphicfilter/icgm/chart.hxx +++ b/filter/source/graphicfilter/icgm/chart.hxx @@ -64,15 +64,14 @@ class CGMChart final friend class CGMImpressOutAct; sal_Int8 mnCurrentFileType; - ::std::vector< TextEntry* > maTextEntryList; + ::std::vector< std::unique_ptr<TextEntry> > maTextEntryList; DataNode mDataNode[ 7 ]; public: CGMChart(); ~CGMChart(); - void DeleteTextEntry( TextEntry* ); - void InsertTextEntry( TextEntry* ); + void InsertTextEntry( std::unique_ptr<TextEntry> ); void ResetAnnotation(); bool IsAnnotation(); diff --git a/filter/source/graphicfilter/icgm/class7.cxx b/filter/source/graphicfilter/icgm/class7.cxx index 54cebd4bdf2b..c85e5284e026 100644 --- a/filter/source/graphicfilter/icgm/class7.cxx +++ b/filter/source/graphicfilter/icgm/class7.cxx @@ -117,7 +117,7 @@ void CGM::ImplDoClass7() if (mpEndValidSource - pAppData < 9) throw css::uno::Exception("attempt to read past end of input", nullptr); - TextEntry* pTextEntry = new TextEntry; + std::unique_ptr<TextEntry> pTextEntry(new TextEntry); pTextEntry->nTypeOfText = *reinterpret_cast<sal_uInt16*>( pAppData ); pTextEntry->nRowOrLineNum = *reinterpret_cast<sal_uInt16*>( pAppData + 2 ); pTextEntry->nColumnNum = *reinterpret_cast<sal_uInt16*>( pAppData + 4 ); @@ -132,7 +132,7 @@ void CGM::ImplDoClass7() memcpy( pTextEntry->pText, pAppData, nLen ); pAppData += nLen; - mpChart->InsertTextEntry( pTextEntry ); + mpChart->InsertTextEntry( std::move(pTextEntry) ); } break; case 0x321 : /*AppData - IOC_TABS */break; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits