diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-09-27 08:44:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-01 08:16:02 +0200 |
commit | 7e4631c544146a9b5a4087aab992aedfed6e8c03 (patch) | |
tree | 046ec01e494fd649cc051db5981974e097ca2c1d /sw | |
parent | 3de097e028d1079b0f48f43fab843fe53d39ec5d (diff) |
loplugin:useuniqueptr in SwHTMLParser
Change-Id: Ib6d101ef6640d45d467cc749b9d1b1261a4ac452
Reviewed-on: https://gerrit.libreoffice.org/61108
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/html/htmlsect.cxx | 18 | ||||
-rw-r--r-- | sw/source/filter/html/htmltab.cxx | 20 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.cxx | 9 | ||||
-rw-r--r-- | sw/source/filter/html/swhtml.hxx | 6 |
4 files changed, 24 insertions, 29 deletions
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx index 606b754d630e..b084a27d41c7 100644 --- a/sw/source/filter/html/htmlsect.cxx +++ b/sw/source/filter/html/htmlsect.cxx @@ -261,8 +261,8 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken ) bAppended = true; } } - HTMLAttrs *pPostIts = bAppended ? nullptr : new HTMLAttrs; - SetAttr( true, true, pPostIts ); + std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts(bAppended ? nullptr : new std::deque<std::unique_ptr<HTMLAttr>>); + SetAttr( true, true, pPostIts.get() ); // make name of section unique const OUString aName( m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : nullptr ) ); @@ -357,9 +357,8 @@ void SwHTMLParser::NewDivision( HtmlTokenId nToken ) if( pPostIts ) { // move still existing PostIts in the first paragraph of the table - InsertAttrs( *pPostIts ); - delete pPostIts; - pPostIts = nullptr; + InsertAttrs( std::move(*pPostIts) ); + pPostIts.reset(); } xCntxt->SetSpansSection( true ); @@ -684,8 +683,8 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss ) bAppended = true; } } - HTMLAttrs *pPostIts = bAppended ? nullptr : new HTMLAttrs; - SetAttr( true, true, pPostIts ); + std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts(bAppended ? nullptr : new std::deque<std::unique_ptr<HTMLAttr>>); + SetAttr( true, true, pPostIts.get() ); // Make section name unique. OUString aName( m_xDoc->GetUniqueSectionName( !aId.isEmpty() ? &aId : nullptr ) ); @@ -744,9 +743,8 @@ void SwHTMLParser::NewMultiCol( sal_uInt16 columnsFromCss ) if( pPostIts ) { // Move pending PostIts into the section. - InsertAttrs( *pPostIts ); - delete pPostIts; - pPostIts = nullptr; + InsertAttrs( std::move(*pPostIts) ); + pPostIts.reset(); } xCntxt->SetSpansSection( true ); diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index cea48ce2645c..6dd841891b19 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -3372,7 +3372,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, m_nContextStAttrMin ) ); // end all open attributes and open them again behind the table - HTMLAttrs *pPostIts = nullptr; + std::unique_ptr<std::deque<std::unique_ptr<HTMLAttr>>> pPostIts; if( !bForceFrame && (bTopTable || pCurTable->HasParentSection()) ) { SplitAttrTab(pTCntxt->xAttrTab, bTopTable); @@ -3384,16 +3384,16 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, if( (bTopTable && !bAppended) || (!bTopTable && !bParentLFStripped && !m_pPam->GetPoint()->nContent.GetIndex()) ) - pPostIts = new HTMLAttrs; - SetAttr( bTopTable, bTopTable, pPostIts ); + pPostIts.reset(new std::deque<std::unique_ptr<HTMLAttr>>); + SetAttr( bTopTable, bTopTable, pPostIts.get() ); } else { SaveAttrTab(pTCntxt->xAttrTab); if( bTopTable && !bAppended ) { - pPostIts = new HTMLAttrs; - SetAttr( true, true, pPostIts ); + pPostIts.reset(new std::deque<std::unique_ptr<HTMLAttr>>); + SetAttr( true, true, pPostIts.get() ); } } m_bNoParSpace = false; @@ -3523,9 +3523,8 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, if( !bAppended && pPostIts ) { // set still-existing PostIts to the first paragraph of the table - InsertAttrs( *pPostIts ); - delete pPostIts; - pPostIts = nullptr; + InsertAttrs( std::move(*pPostIts) ); + pPostIts.reset(); } pTCntxt->SetTableNode( const_cast<SwTableNode *>(pNd->FindTableNode()) ); @@ -3553,9 +3552,8 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, if( pPostIts ) { // move still existing PostIts to the end of the current paragraph - InsertAttrs( *pPostIts ); - delete pPostIts; - pPostIts = nullptr; + InsertAttrs( std::move(*pPostIts) ); + pPostIts.reset(); } } diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index d3c513530216..5bd52b7b06f8 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -2683,7 +2683,7 @@ SwViewShell *SwHTMLParser::CheckActionViewShell() } void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, - HTMLAttrs *pPostIts ) + std::deque<std::unique_ptr<HTMLAttr>> *pPostIts ) { std::unique_ptr<SwPaM> pAttrPam( new SwPaM( *m_pPam->GetPoint() ) ); const SwNodeIndex& rEndIdx = m_pPam->GetPoint()->nNode; @@ -2882,7 +2882,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable, if( pPostIts && (SwFieldIds::Postit == nFieldWhich || SwFieldIds::Script == nFieldWhich) ) { - pPostIts->push_front( pAttr ); + pPostIts->emplace_front( pAttr ); } else { @@ -3422,14 +3422,13 @@ void SwHTMLParser::InsertAttr( const SfxPoolItem& rItem, bool bInsAtStart ) m_aSetAttrTab.push_back( pTmp ); } -void SwHTMLParser::InsertAttrs( HTMLAttrs& rAttrs ) +void SwHTMLParser::InsertAttrs( std::deque<std::unique_ptr<HTMLAttr>> rAttrs ) { while( !rAttrs.empty() ) { - HTMLAttr *pAttr = rAttrs.front(); + std::unique_ptr<HTMLAttr> pAttr = std::move(rAttrs.front()); InsertAttr( pAttr->GetItem(), false ); rAttrs.pop_front(); - delete pAttr; } } diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx index fffff878e01b..bcd620b84562 100644 --- a/sw/source/filter/html/swhtml.hxx +++ b/sw/source/filter/html/swhtml.hxx @@ -483,9 +483,9 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient DECL_LINK( AsyncCallback, void*, void ); // set attribute on document - void SetAttr_( bool bChkEnd, bool bBeforeTable, HTMLAttrs *pPostIts ); + void SetAttr_( bool bChkEnd, bool bBeforeTable, std::deque<std::unique_ptr<HTMLAttr>> *pPostIts ); void SetAttr( bool bChkEnd = true, bool bBeforeTable = false, - HTMLAttrs *pPostIts = nullptr ) + std::deque<std::unique_ptr<HTMLAttr>> *pPostIts = nullptr ) { if( !m_aSetAttrTab.empty() || !m_aMoveFlyFrames.empty() ) SetAttr_( bChkEnd, bBeforeTable, pPostIts ); @@ -510,7 +510,7 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient void SplitAttrTab(std::shared_ptr<HTMLAttrTable> const & rNewAttrTab, bool bMoveEndBack); void RestoreAttrTab(std::shared_ptr<HTMLAttrTable> const & rNewAttrTab); void InsertAttr( const SfxPoolItem& rItem, bool bInsAtStart ); - void InsertAttrs( HTMLAttrs& rAttrs ); + void InsertAttrs( std::deque<std::unique_ptr<HTMLAttr>> rAttrs ); bool DoPositioning( SfxItemSet &rItemSet, SvxCSS1PropertyInfo &rPropInfo, |