sw/source/filter/html/htmlflywriter.cxx | 35 ++++++++++++-------------------- sw/source/filter/html/htmlforw.cxx | 25 ++++++++++------------ sw/source/filter/html/wrthtml.cxx | 6 ++--- sw/source/filter/html/wrthtml.hxx | 2 - 4 files changed, 29 insertions(+), 39 deletions(-)
New commits: commit eaf0b96ec2acdea2376413ef3a93c4c17889e23c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 25 10:33:21 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Aug 25 11:35:38 2022 +0200 no need to allocate SwHTMLPosFlyFrames separately Change-Id: Ib3b23445d204058576b6e07806e3a4bfe45e5a74 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138800 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx index 425cce1d5095..47a63043fb75 100644 --- a/sw/source/filter/html/htmlflywriter.cxx +++ b/sw/source/filter/html/htmlflywriter.cxx @@ -244,15 +244,12 @@ sal_uInt16 SwHTMLWriter::GuessFrameType( const SwFrameFormat& rFrameFormat, // empty frame? Only if no frame is // anchored to the text or start node. bEmpty = true; - if( m_pHTMLPosFlyFrames ) + for( auto & pHTMLPosFlyFrame : m_aHTMLPosFlyFrames ) { - for( auto & pHTMLPosFlyFrame : *m_pHTMLPosFlyFrames ) - { - SwNodeOffset nIdx = pHTMLPosFlyFrame->GetNdIndex().GetIndex(); - bEmpty = (nIdx != nStt) && (nIdx != nStt-1); - if( !bEmpty || nIdx > nStt ) - break; - } + SwNodeOffset nIdx = pHTMLPosFlyFrame->GetNdIndex().GetIndex(); + bEmpty = (nIdx != nStt) && (nIdx != nStt-1); + if( !bEmpty || nIdx > nStt ) + break; } } if( bEmpty ) @@ -345,10 +342,7 @@ void SwHTMLWriter::CollectFlyFrames() break; } - if( !m_pHTMLPosFlyFrames ) - m_pHTMLPosFlyFrames.reset(new SwHTMLPosFlyFrames); - - m_pHTMLPosFlyFrames->insert( std::make_unique<SwHTMLPosFlyFrame>(rItem, pSdrObj, nMode) ); + m_aHTMLPosFlyFrames.insert( std::make_unique<SwHTMLPosFlyFrame>(rItem, pSdrObj, nMode) ); } } @@ -359,20 +353,20 @@ bool SwHTMLWriter::OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx, Html // OutFlyFrame can be called recursively. Thus, sometimes it is // necessary to start over after a Fly was returned. bool bRestart = true; - while( m_pHTMLPosFlyFrames && bRestart ) + while( !m_aHTMLPosFlyFrames.empty() && bRestart ) { bFlysLeft = bRestart = false; // search for the beginning of the FlyFrames size_t i {0}; - for( ; i < m_pHTMLPosFlyFrames->size() && - (*m_pHTMLPosFlyFrames)[i]->GetNdIndex().GetIndex() < nNdIdx; i++ ) + for( ; i < m_aHTMLPosFlyFrames.size() && + m_aHTMLPosFlyFrames[i]->GetNdIndex().GetIndex() < nNdIdx; i++ ) ; - for( ; !bRestart && i < m_pHTMLPosFlyFrames->size() && - (*m_pHTMLPosFlyFrames)[i]->GetNdIndex().GetIndex() == nNdIdx; i++ ) + for( ; !bRestart && i < m_aHTMLPosFlyFrames.size() && + m_aHTMLPosFlyFrames[i]->GetNdIndex().GetIndex() == nNdIdx; i++ ) { - SwHTMLPosFlyFrame *pPosFly = (*m_pHTMLPosFlyFrames)[i].get(); + SwHTMLPosFlyFrame *pPosFly = m_aHTMLPosFlyFrames[i].get(); if( ( HtmlPosition::Any == nPos || pPosFly->GetOutPos() == nPos ) && pPosFly->GetContentIndex() == nContentIdx ) @@ -380,11 +374,10 @@ bool SwHTMLWriter::OutFlyFrame( SwNodeOffset nNdIdx, sal_Int32 nContentIdx, Html // It is important to remove it first, because additional // elements or the whole array could be deleted on // deeper recursion levels. - std::unique_ptr<SwHTMLPosFlyFrame> flyHolder = m_pHTMLPosFlyFrames->erase_extract(i); + std::unique_ptr<SwHTMLPosFlyFrame> flyHolder = m_aHTMLPosFlyFrames.erase_extract(i); i--; - if( m_pHTMLPosFlyFrames->empty() ) + if( m_aHTMLPosFlyFrames.empty() ) { - m_pHTMLPosFlyFrames.reset(); bRestart = true; // not really, only exit the loop } diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx index 51d2a62198a5..838130f8f487 100644 --- a/sw/source/filter/html/htmlforw.cxx +++ b/sw/source/filter/html/htmlforw.cxx @@ -1302,23 +1302,20 @@ void SwHTMLWriter::GetControls() // With that array it's possible to find out where form::Forms must be // opened and closed. - if( m_pHTMLPosFlyFrames ) + // collect the paragraph-bound controls + for( size_t i=0; i<m_aHTMLPosFlyFrames.size(); i++ ) { - // collect the paragraph-bound controls - for( size_t i=0; i<m_pHTMLPosFlyFrames->size(); i++ ) - { - const SwHTMLPosFlyFrame* pPosFlyFrame = (*m_pHTMLPosFlyFrames)[ i ].get(); - if( HtmlOut::Control != pPosFlyFrame->GetOutFn() ) - continue; + const SwHTMLPosFlyFrame* pPosFlyFrame = m_aHTMLPosFlyFrames[ i ].get(); + if( HtmlOut::Control != pPosFlyFrame->GetOutFn() ) + continue; - const SdrObject *pSdrObj = pPosFlyFrame->GetSdrObject(); - OSL_ENSURE( pSdrObj, "Where is the SdrObject?" ); - if( !pSdrObj ) - continue; + const SdrObject *pSdrObj = pPosFlyFrame->GetSdrObject(); + OSL_ENSURE( pSdrObj, "Where is the SdrObject?" ); + if( !pSdrObj ) + continue; - AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), - pPosFlyFrame->GetNdIndex().GetIndex() ); - } + AddControl( m_aHTMLControls, dynamic_cast<const SdrUnoObj&>(*pSdrObj), + pPosFlyFrame->GetNdIndex().GetIndex() ); } // and now the ones in a character-bound frame diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index 8ca66e05215d..002f0191bd30 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -527,7 +527,7 @@ ErrCode SwHTMLWriter::WriteStream() // create table of the floating frames, but only when the whole // document is saved - m_pHTMLPosFlyFrames = nullptr; + m_aHTMLPosFlyFrames.clear(); CollectFlyFrames(); m_nLastParaToken = HtmlTokenId::NONE; GetControls(); @@ -589,8 +589,8 @@ ErrCode SwHTMLWriter::WriteStream() HTMLOutFuncs::Out_AsciiTag(Strm(), OStringConcatenation(GetNamespace() + OOO_STRING_SVTOOLS_HTML_division), false); // delete the table with floating frames - OSL_ENSURE( !m_pHTMLPosFlyFrames, "Were not all frames output?" ); - m_pHTMLPosFlyFrames.reset(); + OSL_ENSURE( m_aHTMLPosFlyFrames.empty(), "Were not all frames output?" ); + m_aHTMLPosFlyFrames.clear(); m_aHTMLControls.clear(); diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx index 44fc97572342..bbec1a1b424a 100644 --- a/sw/source/filter/html/wrthtml.hxx +++ b/sw/source/filter/html/wrthtml.hxx @@ -271,7 +271,7 @@ enum class Css1Background class SW_DLLPUBLIC SwHTMLWriter : public Writer { - std::unique_ptr<SwHTMLPosFlyFrames> m_pHTMLPosFlyFrames; + SwHTMLPosFlyFrames m_aHTMLPosFlyFrames; std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;// current numbering std::unique_ptr<SwHTMLNumRuleInfo> m_pNextNumRuleInfo; sal_uInt32 m_nHTMLMode; // description of export configuration