sw/inc/pam.hxx | 2 - sw/source/core/crsr/bookmark.cxx | 2 - sw/source/core/crsr/crsrsh.cxx | 2 - sw/source/core/crsr/swcrsr.cxx | 18 ++++++++-------- sw/source/core/crsr/trvltbl.cxx | 4 +-- sw/source/core/doc/DocumentContentOperationsManager.cxx | 14 ++++++------ sw/source/core/doc/DocumentRedlineManager.cxx | 4 +-- sw/source/core/doc/doccomp.cxx | 6 ++--- sw/source/core/doc/docedt.cxx | 4 +-- sw/source/core/doc/docredln.cxx | 2 - sw/source/core/docnode/ndtbl.cxx | 4 +-- sw/source/core/layout/trvlfrm.cxx | 2 - sw/source/core/undo/undel.cxx | 2 - sw/source/core/undo/untbl.cxx | 4 +-- sw/source/core/unocore/unoframe.cxx | 3 +- sw/source/core/unocore/unoobj2.cxx | 4 +-- sw/source/filter/ww8/writerhelper.cxx | 2 - sw/source/filter/ww8/wrtww8.cxx | 2 - sw/source/filter/xml/XMLRedlineImportHelper.cxx | 4 +-- 19 files changed, 43 insertions(+), 42 deletions(-)
New commits: commit fe9bce8049ef8749981ede192559ad71572b94d4 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Fri Sep 16 12:54:21 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Sep 16 18:49:32 2022 +0200 create less SwPosition temporaries because they need to hook themselves into global rings, which results in a lot of unnecessary pointer chasing Change-Id: I27173c5f0d5e2998fdbfbb7781e2cbd1be6d14b4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140065 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index 971090296173..746fa22840c0 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -234,7 +234,7 @@ public: { /** clear the mark position; this helps if mark's SwContentIndex is registered at some node, and that node is then deleted */ - *m_pMark = SwPosition( GetPointNode().GetNodes() ); + m_pMark->Assign( *GetPointNode().GetNodes()[SwNodeOffset(0)] ); m_pMark = m_pPoint; } } diff --git a/sw/source/core/crsr/bookmark.cxx b/sw/source/core/crsr/bookmark.cxx index 5e5ee08b7a22..95b545102bc1 100644 --- a/sw/source/core/crsr/bookmark.cxx +++ b/sw/source/core/crsr/bookmark.cxx @@ -95,7 +95,7 @@ namespace sw::mark if (nFields == 0) { assert(!ret); // one per field - ret = SwPosition(rTextNode, i - 1); + ret.emplace(rTextNode, i - 1); #ifndef DBG_UTIL return *ret; #endif diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index b8c0bef6a0f5..0ec692f47e7d 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -1541,7 +1541,7 @@ static void lcl_CheckHiddenPara( SwPosition& rPos ) } if ( pTextNd ) - rPos = SwPosition( *pTextNd, 0 ); + rPos.Assign( *pTextNd, 0 ); } #if !ENABLE_WASM_STRIP_ACCESSIBILITY diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index cc45eae6fb45..1a50bb2d8dd4 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1304,7 +1304,7 @@ bool SwCursor::GoStartWordWT(sal_Int16 nWordType, SwRootFrame const*const pLayou if (nPtPos < pTextNd->GetText().getLength() && nPtPos >= 0) { - *GetPoint() = SwPosition(*pTextNd, nPtPos); + GetPoint()->Assign(*pTextNd, nPtPos); if( !IsSelOvr() ) bRet = true; } @@ -1334,7 +1334,7 @@ bool SwCursor::GoEndWordWT(sal_Int16 nWordType, SwRootFrame const*const pLayout) if (nPtPos <= pTextNd->GetText().getLength() && nPtPos >= 0 && GetPoint()->GetContentIndex() != nPtPos ) { - *GetPoint() = SwPosition(*pTextNd, nPtPos); + GetPoint()->Assign(*pTextNd, nPtPos); if( !IsSelOvr() ) bRet = true; } @@ -1362,7 +1362,7 @@ bool SwCursor::GoNextWordWT(sal_Int16 nWordType, SwRootFrame const*const pLayout if (nPtPos <= pTextNd->GetText().getLength() && nPtPos >= 0) { - *GetPoint() = SwPosition(*pTextNd, nPtPos); + GetPoint()->Assign(*pTextNd, nPtPos); if( !IsSelOvr() ) bRet = true; } @@ -1397,7 +1397,7 @@ bool SwCursor::GoPrevWordWT(sal_Int16 nWordType, SwRootFrame const*const pLayout if (nPtPos < pTextNd->GetText().getLength() && nPtPos >= 0) { - *GetPoint() = SwPosition(*pTextNd, nPtPos); + GetPoint()->Assign(*pTextNd, nPtPos); if( !IsSelOvr() ) bRet = true; } @@ -1479,11 +1479,11 @@ bool SwCursor::SelectWordWT( SwViewShell const * pViewShell, sal_Int16 nWordType if( aBndry.startPos != aBndry.endPos ) { - *GetPoint() = SwPosition(*pEndNode, nEndIndex); + GetPoint()->Assign(*pEndNode, nEndIndex); if( !IsSelOvr() ) { SetMark(); - *GetMark() = SwPosition(*pStartNode, nStartIndex); + GetMark()->Assign(*pStartNode, nStartIndex); if (sw::mark::IMark* pAnnotationMark = pMarksAccess->getAnnotationMarkFor(*GetPoint())) { // An annotation mark covers the selected word. Check @@ -1607,7 +1607,7 @@ bool SwCursor::GoSentence(SentenceMoveType eMoveType, SwRootFrame const*const pL // character in the text thus <= ...Len if (nPtPos <= pTextNd->GetText().getLength() && nPtPos >= 0) { - *GetPoint() = SwPosition(*pTextNd, nPtPos); + GetPoint()->Assign(*pTextNd, nPtPos); if( !IsSelOvr() ) bRet = true; } @@ -1651,11 +1651,11 @@ void SwCursor::ExpandToSentenceBorders(SwRootFrame const*const pLayout) // character in the text thus <= ...Len if (nStartPos <= pStartNd->GetText().getLength() && nStartPos >= 0) { - *GetMark() = SwPosition(*pStartNd, nStartPos); + GetMark()->Assign(*pStartNd, nStartPos); } if (nEndPos <= pEndNd->GetText().getLength() && nEndPos >= 0) { - *GetPoint() = SwPosition(*pEndNd, nEndPos); + GetPoint()->Assign(*pEndNd, nEndPos); } } diff --git a/sw/source/core/crsr/trvltbl.cxx b/sw/source/core/crsr/trvltbl.cxx index 6c03eca498a6..e212553c5844 100644 --- a/sw/source/core/crsr/trvltbl.cxx +++ b/sw/source/core/crsr/trvltbl.cxx @@ -316,12 +316,12 @@ bool SwCursorShell::SelTableBox() // select the complete box with our shiny new m_pTableCursor // 1. delete mark, and move point to first content node in box m_pTableCursor->DeleteMark(); - *(m_pTableCursor->GetPoint()) = SwPosition( *pStartNode ); + m_pTableCursor->GetPoint()->Assign( *pStartNode ); m_pTableCursor->Move( fnMoveForward, GoInNode ); // 2. set mark, and move point to last content node in box m_pTableCursor->SetMark(); - *(m_pTableCursor->GetPoint()) = SwPosition( *(pStartNode->EndOfSectionNode()) ); + m_pTableCursor->GetPoint()->Assign( *(pStartNode->EndOfSectionNode()) ); m_pTableCursor->Move( fnMoveBackward, GoInNode ); // 3. exchange diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 3e02061455e4..f62616fa8fcb 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -688,13 +688,13 @@ namespace while (iter != Breaks.rend()) { - rStart = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); + rStart.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); if (rStart < rEnd) // check if part is empty { bRet &= (rDocumentContentOperations.*pFunc)(aPam, flags); nOffset = iter->first - rStart.GetNodeIndex(); // deleted fly nodes... } - rEnd = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); + rEnd.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); ++iter; } @@ -3480,7 +3480,7 @@ bool DocumentContentOperationsManager::ReplaceRange( SwPaM& rPam, const OUString { // park aPam somewhere so it does not point to node that is deleted aPam.DeleteMark(); - *aPam.GetPoint() = SwPosition(m_rDoc.GetNodes().GetEndOfContent()); + aPam.GetPoint()->Assign(m_rDoc.GetNodes().GetEndOfContent()); return ReplaceRangeImpl(rPam, rStr, bRegExReplace); // original pam! } @@ -3504,7 +3504,7 @@ bool DocumentContentOperationsManager::ReplaceRange( SwPaM& rPam, const OUString while (iter != Breaks.rend()) { - rStart = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); + rStart.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); if (rStart < rEnd) // check if part is empty { bRet &= (m_rDoc.getIDocumentRedlineAccess().IsRedlineOn()) @@ -3512,7 +3512,7 @@ bool DocumentContentOperationsManager::ReplaceRange( SwPaM& rPam, const OUString : DeleteAndJoinImpl(aPam, SwDeleteFlags::Default); nOffset = iter->first - rStart.GetNodeIndex(); // deleted fly nodes... } - rEnd = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); + rEnd.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); ++iter; } @@ -4825,7 +4825,7 @@ bool DocumentContentOperationsManager::CopyImpl(SwPaM& rPam, SwPosition& rPos, while (iter != Breaks.rend()) { - rStart = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); + rStart.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second + 1); if (rStart < rEnd) // check if part is empty { // pass in copyRange member as rPos; should work ... @@ -4842,7 +4842,7 @@ bool DocumentContentOperationsManager::CopyImpl(SwPaM& rPam, SwPosition& rPos, } bFirst = false; } - rEnd = SwPosition(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); + rEnd.Assign(*rNodes[iter->first - nOffset]->GetTextNode(), iter->second); ++iter; } diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index f90dda9a545f..0e032d4477a6 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1065,9 +1065,9 @@ namespace { m_pCursor->SetMark(); *m_pCursor->GetMark() = *m_rRedline.GetMark(); - *m_rRedline.GetMark() = SwPosition(rDoc.GetNodes().GetEndOfContent()); + m_rRedline.GetMark()->Assign(rDoc.GetNodes().GetEndOfContent()); } - *m_rRedline.GetPoint() = SwPosition(rDoc.GetNodes().GetEndOfContent()); + m_rRedline.GetPoint()->Assign(rDoc.GetNodes().GetEndOfContent()); } ~TemporaryRedlineUpdater() { diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 92f0d2fd1207..9a6746c90a45 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1567,7 +1567,7 @@ void CompareData::ShowDelete( if( *pCorr->GetPoint() == *pTmp->GetPoint() ) { SwNodeIndex aTmpPos( pTmp->GetMark()->GetNode(), -1 ); - *pCorr->GetPoint() = SwPosition( aTmpPos ); + pCorr->GetPoint()->Assign( aTmpPos ); } } } @@ -1682,7 +1682,7 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) SwNodeIndex const prev(pTmp->GetMark()->GetNode(), -1); if (prev.GetNode().IsTextNode()) { - *pTmp->GetMark() = SwPosition( + pTmp->GetMark()->Assign( *prev.GetNode().GetTextNode(), prev.GetNode().GetTextNode()->Len()); } @@ -1725,7 +1725,7 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo ) SwNodeIndex const prev(pTmp->GetMark()->GetNode(), -1); if (prev.GetNode().IsTextNode()) { - *pTmp->GetMark() = SwPosition( + pTmp->GetMark()->Assign( *prev.GetNode().GetTextNode(), prev.GetNode().GetTextNode()->Len()); } diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx index 6a209530b428..56eb5a6065aa 100644 --- a/sw/source/core/doc/docedt.cxx +++ b/sw/source/core/doc/docedt.cxx @@ -475,11 +475,11 @@ bool sw_JoinText( SwPaM& rPam, bool bJoinPrev ) // #i100466# adjust given <rPam>, if it does not belong to the cursors if ( pDelNd == rPam.GetBound().GetContentNode() ) { - rPam.GetBound() = SwPosition( *pTextNd ); + rPam.GetBound().Assign( *pTextNd ); } if( pDelNd == rPam.GetBound( false ).GetContentNode() ) { - rPam.GetBound( false ) = SwPosition( *pTextNd ); + rPam.GetBound( false ).Assign( *pTextNd ); } pTextNd->JoinNext(); } diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 1b0bb83f6c19..958e62ffe6ea 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -517,7 +517,7 @@ std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p do { // We want to be before the table - *pNew->GetPoint() = SwPosition(*pTab); + pNew->GetPoint()->Assign(*pTab); pC = GoPreviousNds( &pNew->GetPoint()->nNode, false ); // here we are. if( pC ) pNew->GetPoint()->nContent.Assign( pC, 0 ); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index fc96ff692bc4..46f1a475fddc 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2011,7 +2011,7 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode const eMode) SwPaM aSavePaM( *pTableNd->EndOfSectionNode() ); if( ! aSavePaM.Move( fnMoveForward, GoInNode ) ) { - *aSavePaM.GetMark() = SwPosition( *pTableNd ); + aSavePaM.GetMark()->Assign( *pTableNd ); aSavePaM.Move( fnMoveBackward, GoInNode ); } { @@ -2061,7 +2061,7 @@ bool SwDoc::DeleteRowCol(const SwSelBoxes& rBoxes, RowColMode const eMode) SwPaM aSavePaM( *pTableNd->EndOfSectionNode() ); if( ! aSavePaM.Move( fnMoveForward, GoInNode ) ) { - *aSavePaM.GetMark() = SwPosition( *pTableNd ); + aSavePaM.GetMark()->Assign( *pTableNd ); aSavePaM.Move( fnMoveBackward, GoInNode ); } { diff --git a/sw/source/core/layout/trvlfrm.cxx b/sw/source/core/layout/trvlfrm.cxx index 702652f54575..ef503f153650 100644 --- a/sw/source/core/layout/trvlfrm.cxx +++ b/sw/source/core/layout/trvlfrm.cxx @@ -240,7 +240,7 @@ bool SwPageFrame::GetModelPositionForViewPoint( SwPosition *pPos, Point &rPoint, else { assert(pCnt->IsNoTextFrame()); - aTextPos = SwPosition( *static_cast<SwNoTextFrame const*>(pCnt)->GetNode() ); + aTextPos.Assign( *static_cast<SwNoTextFrame const*>(pCnt)->GetNode() ); } } } diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 0d62ed72a603..965f2159a354 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -988,7 +988,7 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) } else { - aPos = SwPosition( aCopyIndex ); + aPos.Assign( aCopyIndex ); nMoveIndex = aPos.GetNodeIndex() + m_nReplaceDummy + 1; } SwNodeIndex aMvIdx(rDoc.GetNodes(), nMoveIndex); diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 6e3befe85104..cff290bce21f 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2419,7 +2419,7 @@ void SwUndoTableCpyTable::UndoImpl(::sw::UndoRedoContext & rContext) pUndoRedlineDelete->ContentStart() ); } else - *aPam.GetPoint() = SwPosition( aTmpIdx ); + aPam.GetPoint()->Assign( aTmpIdx ); } else if (pUndoDelete && pUndoDelete->IsDelFullPara()) { @@ -2702,7 +2702,7 @@ std::unique_ptr<SwUndo> SwUndoTableCpyTable::PrepareRedline( SwDoc* pDoc, const } else if( !rJoin ) // If the old part is empty and joined, we are finished { // if it is not joined, we have to delete this empty paragraph - aCellEnd = SwPosition(*rBox.GetSttNd()->EndOfSectionNode(), SwNodeOffset(0)); + aCellEnd.Assign(*rBox.GetSttNd()->EndOfSectionNode()); SwPaM aTmpPam( aDeleteStart, aCellEnd ); pUndo = std::make_unique<SwUndoDelete>(aTmpPam, SwDeleteFlags::Default, true); } diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index fd28f3bd2424..d2383579275a 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2831,7 +2831,8 @@ void SwXFrame::attachToRange(uno::Reference<text::XTextRange> const& xTextRange, // that content aPam.DeleteMark(); aIntPam.DeleteMark(); - *aPam.GetPoint() = *aIntPam.GetPoint() = SwPosition(pDoc->GetNodes()); + aIntPam.GetPoint()->Assign(*pDoc->GetNodes()[SwNodeOffset(0)]); + *aPam.GetPoint() = *aIntPam.GetPoint(); pFormat = pDoc->MakeFlyAndMove( *pCopySource, aFrameSet, nullptr, diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 9faa447cda10..c9a1cfca662e 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -868,11 +868,11 @@ void SwXTextRange::DeleteAndInsert( } } // now there should be a text node at the start and end of it! - *aCursor.GetPoint() = SwPosition(start); + aCursor.GetPoint()->Assign(start); aCursor.Move( fnMoveForward, GoInContent ); assert(aCursor.GetPoint()->GetNode() <= end.GetNode()); aCursor.SetMark(); - *aCursor.GetPoint() = SwPosition(end); + aCursor.GetPoint()->Assign(end); aCursor.Move( fnMoveBackward, GoInContent ); assert(start <= aCursor.GetPoint()->GetNode()); } diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx index fd2241ef236c..ebb9e855f593 100644 --- a/sw/source/filter/ww8/writerhelper.cxx +++ b/sw/source/filter/ww8/writerhelper.cxx @@ -806,7 +806,7 @@ namespace sw // the point node may be deleted in AppendRedline, so park // the PaM somewhere safe aRegion.DeleteMark(); - *aRegion.GetPoint() = SwPosition(mrDoc.GetNodes()); + aRegion.GetPoint()->Assign(*mrDoc.GetNodes()[SwNodeOffset(0)]); mrDoc.getIDocumentRedlineAccess().AppendRedline(pNewRedline, true); mrDoc.getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::NONE | RedlineFlags::ShowInsert | RedlineFlags::ShowDelete ); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 8e9ceb3ece98..1d401de0bbf3 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3397,7 +3397,7 @@ ErrCode MSWordExportBase::ExportDocument( bool bWriteAll ) // ooo103014-1.odt to .doc // park m_pOrigPam as well, as needed for exporting abi9915-1.odt to doc m_pOrigPam->DeleteMark(); - *m_pOrigPam->GetPoint() = SwPosition(m_rDoc.GetNodes().GetEndOfContent()); + m_pOrigPam->GetPoint()->Assign(m_rDoc.GetNodes().GetEndOfContent()); static_cast<SwPaM&>(*m_pCurPam) = *m_pOrigPam; m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags(m_nOrigRedlineFlags); diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx index b9174eb27ebf..e681f2025b6c 100644 --- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx +++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx @@ -717,9 +717,9 @@ void XMLRedlineImportHelper::InsertIntoDocument(RedlineInfo* pRedlineInfo) { SAL_WARN("sw.xml", "Recursive change tracking, removing"); // reuse aPaM to remove it from nodes that will be deleted - *aPaM.GetPoint() = SwPosition(pRedlineInfo->pContentIndex->GetNode()); + aPaM.GetPoint()->Assign(pRedlineInfo->pContentIndex->GetNode()); aPaM.SetMark(); - *aPaM.GetMark() = SwPosition(*pRedlineInfo->pContentIndex->GetNode().EndOfSectionNode()); + aPaM.GetMark()->Assign(*pRedlineInfo->pContentIndex->GetNode().EndOfSectionNode()); pDoc->getIDocumentContentOperations().DeleteRange(aPaM); } else