sw/source/filter/ww8/ww8par.cxx | 10 +++++----- sw/source/filter/ww8/ww8par.hxx | 2 +- sw/source/filter/ww8/ww8par2.cxx | 12 ++++++------ sw/source/filter/ww8/ww8par6.cxx | 20 ++++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-)
New commits: commit 57ae68004899076303666da3ed7b2ee8a1e5ae94 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Sun Aug 7 18:04:58 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sun Aug 7 20:35:40 2022 +0200 no need to allocate these SwPosition separately It is a small object, and in these places is already contained inside a heap object. Change-Id: I63eee5390e4ab1d1a66197a100e3876f96f95944 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137928 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index f56e4600f29c..a22469ba2994 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -2074,15 +2074,15 @@ void WW8ReaderSave::Restore( SwWW8ImplReader* pRdr ) pRdr->m_xRedlineStack->closeall(*pRdr->m_pPaM->GetPoint()); - // ofz#37322 drop m_pLastAnchorPos during RedlineStack dtor and restore it afterwards to the same + // ofz#37322 drop m_oLastAnchorPos during RedlineStack dtor and restore it afterwards to the same // place, or somewhere close if that place got destroyed - std::shared_ptr<SwUnoCursor> xLastAnchorCursor(pRdr->m_pLastAnchorPos ? pRdr->m_rDoc.CreateUnoCursor(*pRdr->m_pLastAnchorPos) : nullptr); - pRdr->m_pLastAnchorPos.reset(); + std::shared_ptr<SwUnoCursor> xLastAnchorCursor(pRdr->m_oLastAnchorPos ? pRdr->m_rDoc.CreateUnoCursor(*pRdr->m_oLastAnchorPos) : nullptr); + pRdr->m_oLastAnchorPos.reset(); pRdr->m_xRedlineStack = std::move(mxOldRedlines); if (xLastAnchorCursor) - pRdr->m_pLastAnchorPos.reset(new SwPosition(*xLastAnchorCursor->GetPoint())); + pRdr->m_oLastAnchorPos.emplace(*xLastAnchorCursor->GetPoint()); pRdr->DeleteAnchorStack(); pRdr->m_xAnchorStck = std::move(mxOldAnchorStck); @@ -5385,7 +5385,7 @@ ErrCode SwWW8ImplReader::CoreLoad(WW8Glossary const *pGloss) DeleteCtrlStack(); DeleteAnchorStack(); DeleteRefStacks(); - m_pLastAnchorPos.reset();//ensure this is deleted before UpdatePageDescs + m_oLastAnchorPos.reset();//ensure this is deleted before UpdatePageDescs // ofz#10994 remove any trailing fly paras before processing redlines m_xWFlyPara.reset(); // ofz#12660 remove any trailing fly paras before deleting extra paras diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx index 383c4e34c24f..fcd46da1cde4 100644 --- a/sw/source/filter/ww8/ww8par.hxx +++ b/sw/source/filter/ww8/ww8par.hxx @@ -1403,7 +1403,7 @@ private: // used for some dropcap tweaking std::unique_ptr<TextNodeListener> m_xPreviousNode; - std::unique_ptr< SwPosition > m_pLastAnchorPos; + std::optional< SwPosition > m_oLastAnchorPos; bool m_bCareFirstParaEndInToc; bool m_bCareLastParaEndInToc; diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx index e140e6c471ac..e7321122d0a9 100644 --- a/sw/source/filter/ww8/ww8par2.cxx +++ b/sw/source/filter/ww8/ww8par2.cxx @@ -199,12 +199,12 @@ sal_uInt16 SwWW8ImplReader::End_Footnote() sChar += OUStringChar(pText->GetText()[--nPos]); m_pPaM->SetMark(); --m_pPaM->GetMark()->nContent; - std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_pLastAnchorPos ? m_rDoc.CreateUnoCursor(*m_pLastAnchorPos) : nullptr); - m_pLastAnchorPos.reset(); + std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_oLastAnchorPos ? m_rDoc.CreateUnoCursor(*m_oLastAnchorPos) : nullptr); + m_oLastAnchorPos.reset(); m_rDoc.getIDocumentContentOperations().DeleteRange( *m_pPaM ); m_pPaM->DeleteMark(); if (xLastAnchorCursor) - m_pLastAnchorPos.reset(new SwPosition(*xLastAnchorCursor->GetPoint())); + m_oLastAnchorPos.emplace(*xLastAnchorCursor->GetPoint()); SwFormatFootnote aFootnote(rDesc.meType == MAN_EDN); pFN = static_cast<SwTextFootnote*>(pText->InsertItem(aFootnote, nPos, nPos)); } @@ -2760,15 +2760,15 @@ void WW8TabDesc::FinishSwTable() // ofz#38011 drop m_pLastAnchorPos during RedlineStack dtor and restore it afterwards to the same // place, or somewhere close if that place got destroyed - std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_pIo->m_pLastAnchorPos ? m_pIo->m_rDoc.CreateUnoCursor(*m_pIo->m_pLastAnchorPos) : nullptr); - m_pIo->m_pLastAnchorPos.reset(); + std::shared_ptr<SwUnoCursor> xLastAnchorCursor(m_pIo->m_oLastAnchorPos ? m_pIo->m_rDoc.CreateUnoCursor(*m_pIo->m_oLastAnchorPos) : nullptr); + m_pIo->m_oLastAnchorPos.reset(); SwTableNode* pTableNode = m_pTable->GetTableNode(); SwDeleteListener aListener(*pTableNode); m_pIo->m_xRedlineStack = std::move(mxOldRedlineStack); if (xLastAnchorCursor) - m_pIo->m_pLastAnchorPos.reset(new SwPosition(*xLastAnchorCursor->GetPoint())); + m_pIo->m_oLastAnchorPos.emplace(*xLastAnchorCursor->GetPoint()); WW8DupProperties aDup(m_pIo->m_rDoc,m_pIo->m_xCtrlStck.get()); m_pIo->m_xCtrlStck->SetAttr( *m_pIo->m_pPaM->GetPoint(), 0, false); diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx index 29006f5fbcc3..dd938500950f 100644 --- a/sw/source/filter/ww8/ww8par6.cxx +++ b/sw/source/filter/ww8/ww8par6.cxx @@ -870,10 +870,10 @@ void wwSectionManager::CreateSep(const tools::Long nTextPos) if (!pSep) return; - if (!maSegments.empty() && mrReader.m_pLastAnchorPos && *mrReader.m_pLastAnchorPos == *mrReader.m_pPaM->GetPoint()) + if (!maSegments.empty() && mrReader.m_oLastAnchorPos && *mrReader.m_oLastAnchorPos == *mrReader.m_pPaM->GetPoint()) { bool insert = true; - SwPaM pam( *mrReader.m_pLastAnchorPos ); + SwPaM pam( *mrReader.m_oLastAnchorPos ); if( pam.Move(fnMoveBackward, GoInNode)) if( SwTextNode* txtNode = pam.GetPoint()->GetNode().GetTextNode()) if( txtNode->Len() == 0 ) @@ -1962,7 +1962,7 @@ bTogglePos(false) //#i53725# - absolute positioned objects have to be // anchored at-paragraph to assure its correct anchor position. - rIo.m_pLastAnchorPos.reset( new SwPosition(*rPaM.GetPoint())); + rIo.m_oLastAnchorPos.emplace(*rPaM.GetPoint()); switch (nYBind) { @@ -2561,11 +2561,11 @@ bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr) if (bStealAttr) m_xCtrlStck->StealAttr(rPam.GetPoint()->nNode); - if (m_pLastAnchorPos || m_xPreviousNode || (m_xSFlyPara && m_xSFlyPara->xMainTextPos)) + if (m_oLastAnchorPos || m_xPreviousNode || (m_xSFlyPara && m_xSFlyPara->xMainTextPos)) { SwNodeIndex aToBeJoined(aPref, 1); - if (m_pLastAnchorPos) + if (m_oLastAnchorPos) { //If the last anchor pos is here, then clear the anchor pos. //This "last anchor pos" is only used for fixing up the @@ -2574,9 +2574,9 @@ bool SwWW8ImplReader::JoinNode(SwPaM &rPam, bool bStealAttr) //cannot be a page break at this point so we can //safely reset m_pLastAnchorPos to avoid any dangling //SwContentIndex's pointing into the deleted paragraph - SwNodeIndex aLastAnchorPos(m_pLastAnchorPos->nNode); + SwNodeIndex aLastAnchorPos(m_oLastAnchorPos->nNode); if (aLastAnchorPos == aToBeJoined) - m_pLastAnchorPos.reset(); + m_oLastAnchorPos.reset(); } if (m_xPreviousNode) @@ -2687,7 +2687,7 @@ void SwWW8ImplReader::StopApo() if (rBrush.GetColor() != COL_AUTO) aBg = rBrush.GetColor(); - if (m_pLastAnchorPos) + if (m_oLastAnchorPos) { //If the last anchor pos is here, then clear the anchor pos. //This "last anchor pos" is only used for fixing up the @@ -2696,10 +2696,10 @@ void SwWW8ImplReader::StopApo() //cannot be a page break at this point so we can //safely reset m_pLastAnchorPos to avoid any dangling //SwContentIndex's pointing into the deleted paragraph - SwNodeIndex aLastAnchorPos(m_pLastAnchorPos->nNode); + SwNodeIndex aLastAnchorPos(m_oLastAnchorPos->nNode); SwNodeIndex aToBeJoined(aPref, 1); if (aLastAnchorPos == aToBeJoined) - m_pLastAnchorPos.reset(); + m_oLastAnchorPos.reset(); } //Get rid of extra empty paragraph