Kaydet (Commit) 7e4631c5 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SwHTMLParser

Change-Id: Ib6d101ef6640d45d467cc749b9d1b1261a4ac452
Reviewed-on: https://gerrit.libreoffice.org/61108
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 3de097e0
......@@ -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 );
......
......@@ -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();
}
}
......
......@@ -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;
}
}
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment