sw/inc/ndarr.hxx | 2 sw/inc/pam.hxx | 4 - sw/source/core/crsr/crsrsh.cxx | 11 +-- sw/source/core/crsr/pam.cxx | 8 +- sw/source/core/crsr/swcrsr.cxx | 12 +-- sw/source/core/doc/CntntIdxStore.cxx | 6 - sw/source/core/doc/DocumentContentOperationsManager.cxx | 49 ++++------------ sw/source/core/doc/DocumentRedlineManager.cxx | 4 - sw/source/core/doc/docbm.cxx | 26 ++++---- sw/source/core/doc/doccomp.cxx | 4 - sw/source/core/doc/docfld.cxx | 3 sw/source/core/doc/docnum.cxx | 14 +--- sw/source/core/doc/docredln.cxx | 8 -- sw/source/core/doc/doctxm.cxx | 5 - sw/source/core/docnode/ndtbl.cxx | 19 ++---- sw/source/core/docnode/nodes.cxx | 34 +++++++++++ sw/source/core/edit/eddel.cxx | 3 sw/source/core/edit/edglbldc.cxx | 6 - sw/source/core/fields/expfld.cxx | 5 - sw/source/core/frmedt/fetab.cxx | 3 sw/source/core/undo/unattr.cxx | 9 -- sw/source/core/undo/unins.cxx | 10 --- sw/source/core/undo/unredln.cxx | 6 - sw/source/core/undo/unspnd.cxx | 7 -- sw/source/core/undo/untbl.cxx | 6 - sw/source/core/unocore/unoframe.cxx | 5 - sw/source/core/unocore/unoobj.cxx | 15 +--- sw/source/core/unocore/unoobj2.cxx | 7 -- sw/source/core/unocore/unoredline.cxx | 10 --- sw/source/core/unocore/unotext.cxx | 14 ---- sw/source/filter/ascii/parasc.cxx | 5 - sw/source/filter/html/htmltab.cxx | 5 - sw/source/uibase/docvw/AnnotationWin2.cxx | 6 - sw/source/uibase/docvw/edtwin.cxx | 12 +-- 34 files changed, 146 insertions(+), 197 deletions(-)
New commits: commit e95bb3c1074bca7460977fe962a1042a2aef415d Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 4 16:13:20 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 5 09:18:19 2022 +0200 introduce SwNodes::GoNext(SwPosition*) and similar GoPrevious as part of the process of hiding the internals of SwPosition These are still the easy ones, i.e. no functional change intended Change-Id: Ic1128d9e31fb87c015e1e9e66f5c365b3c2ebdca Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137803 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/inc/ndarr.hxx b/sw/inc/ndarr.hxx index 87c78c5172b1..0bf1f69f63fd 100644 --- a/sw/inc/ndarr.hxx +++ b/sw/inc/ndarr.hxx @@ -183,7 +183,9 @@ public: static void GoEndOfSection(SwNodeIndex *); SwContentNode* GoNext(SwNodeIndex *) const; + SwContentNode* GoNext(SwPosition *) const; static SwContentNode* GoPrevious(SwNodeIndex *); + static SwContentNode* GoPrevious(SwPosition *); /** Go to next content-node that is not protected or hidden (Both set FALSE ==> GoNext/GoPrevious!!!). */ diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx index 8097ca0823b1..13779e0b6999 100644 --- a/sw/source/core/crsr/crsrsh.cxx +++ b/sw/source/core/crsr/crsrsh.cxx @@ -594,12 +594,13 @@ void SwCursorShell::ExtendedSelectAll(bool bFootnotes) { SwNodes& rNodes = GetDoc()->GetNodes(); SwPosition* pPos = m_pCurrentCursor->GetPoint(); - pPos->nNode = bFootnotes ? rNodes.GetEndOfPostIts() : rNodes.GetEndOfAutotext(); - pPos->nContent.Assign( rNodes.GoNext( &pPos->nNode ), 0 ); + pPos->Assign( bFootnotes ? rNodes.GetEndOfPostIts() : rNodes.GetEndOfAutotext() ); + rNodes.GoNext( pPos ); pPos = m_pCurrentCursor->GetMark(); - pPos->nNode = rNodes.GetEndOfContent(); - SwContentNode* pCNd = SwNodes::GoPrevious( &pPos->nNode ); - pPos->nContent.Assign( pCNd, pCNd ? pCNd->Len() : 0 ); + pPos->Assign(rNodes.GetEndOfContent()); + SwContentNode* pCNd = SwNodes::GoPrevious( pPos ); + if (pCNd) + pPos->AssignEndIndex(*pCNd); } bool SwCursorShell::ExtendedSelectedAll() diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 5d962d9e2e3e..a0004bf47650 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -1114,29 +1114,29 @@ void SwCursor::FillFindPos( SwDocPositions ePos, SwPosition& rPos ) const { case SwDocPositions::Start: rPos.nNode = *rNds.GetEndOfContent().StartOfSectionNode(); - pCNd = rNds.GoNext( &rPos.nNode ); + pCNd = rNds.GoNext( &rPos ); break; case SwDocPositions::End: rPos.nNode = rNds.GetEndOfContent(); - pCNd = SwNodes::GoPrevious( &rPos.nNode ); + pCNd = SwNodes::GoPrevious( &rPos ); bIsStart = false; break; case SwDocPositions::OtherStart: rPos.nNode = *rNds[ SwNodeOffset(0) ]; - pCNd = rNds.GoNext( &rPos.nNode ); + pCNd = rNds.GoNext( &rPos ); break; case SwDocPositions::OtherEnd: rPos.nNode = *rNds.GetEndOfContent().StartOfSectionNode(); - pCNd = SwNodes::GoPrevious( &rPos.nNode ); + pCNd = SwNodes::GoPrevious( &rPos ); bIsStart = false; break; default: rPos = *GetPoint(); } - if( pCNd ) + if( pCNd && !bIsStart ) { - rPos.nContent.Assign( pCNd, bIsStart ? 0 : pCNd->Len() ); + rPos.AssignEndIndex( *pCNd ); } } diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index 9fa6df2f86c0..409f053ddc99 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -2217,8 +2217,7 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam ) SwPosition aTmpPos( *aDelPam.GetPoint() ); if( bGoNext ) { - pTmpNode = m_rDoc.GetNodes().GoNext( &aTmpPos.nNode ); - aTmpPos.nContent.Assign( pTmpNode, 0 ); + m_rDoc.GetNodes().GoNext( &aTmpPos ); } ::PaMCorrAbs( aDelPam, aTmpPos ); } diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 215c728e65a2..616292668a77 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1929,19 +1929,20 @@ void DelBookmarks( bool bStt = true; SwContentNode* pCNd = pRStt->GetNode().GetContentNode(); if( !pCNd ) - pCNd = rDoc.GetNodes().GoNext( &pRStt->nNode ); + pCNd = rDoc.GetNodes().GoNext( pRStt ); if (!pCNd) { bStt = false; - pRStt->nNode = rStt; - pCNd = SwNodes::GoPrevious( &pRStt->nNode ); + pRStt->Assign(rStt); + pCNd = SwNodes::GoPrevious( pRStt ); if( !pCNd ) { - pRStt->nNode = pREnd->nNode; + *pRStt = *pREnd; pCNd = pRStt->GetNode().GetContentNode(); } } - pRStt->nContent.Assign( pCNd, bStt ? 0 : pCNd->Len() ); + if (pCNd && !bStt) + pRStt->AssignEndIndex( *pCNd ); } } if( lcl_Greater( *pREnd, rStt, pSttIdx ) && lcl_Lower( *pREnd, rEnd, pEndIdx )) @@ -1954,19 +1955,20 @@ void DelBookmarks( bool bStt = false; SwContentNode* pCNd = pREnd->GetNode().GetContentNode(); if( !pCNd ) - pCNd = SwNodes::GoPrevious( &pREnd->nNode ); + pCNd = SwNodes::GoPrevious( pREnd ); if( !pCNd ) { bStt = true; - pREnd->nNode = rEnd; - pCNd = rDoc.GetNodes().GoNext( &pREnd->nNode ); + pREnd->Assign(rEnd); + pCNd = rDoc.GetNodes().GoNext( pREnd ); if( !pCNd ) { - pREnd->nNode = pRStt->nNode; + *pREnd = *pRStt; pCNd = pREnd->GetNode().GetContentNode(); } } - pREnd->nContent.Assign( pCNd, bStt ? 0 : pCNd->Len() ); + if (pCNd && !bStt) + pREnd->AssignEndIndex( *pCNd ); } } } diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index c0d3efa66d35..4aa9c9078084 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -2214,8 +2214,9 @@ bool SwDoc::MoveParagraphImpl(SwPaM& rPam, SwNodeOffset const nOffset, { // We need to remove the last empty Node again aIdx = aInsPos.nNode; - SwContentNode* pCNd = SwNodes::GoPrevious( &aInsPos.nNode ); - aInsPos.nContent.Assign( pCNd, pCNd ? pCNd->Len() : 0 ); + SwContentNode* pCNd = SwNodes::GoPrevious( &aInsPos ); + if (pCNd) + aInsPos.AssignEndIndex( *pCNd ); // All, that are in the to-be-deleted Node, need to be // moved to the next Node diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index e29ed4d1f8e0..cead2ecf1cba 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -487,11 +487,9 @@ std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p if( !aNewStt.GetNode().IsContentNode() ) { - pC = rNds.GoNext( &aNewStt.nNode ); - if( pC ) - aNewStt.nContent.Assign( pC, 0 ); - else - aNewStt.nNode = rNds.GetEndOfContent(); + pC = rNds.GoNext( &aNewStt ); + if( !pC ) + aNewStt.Assign(rNds.GetEndOfContent()); } SwRangeRedline* pNew = nullptr; diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx index b98419b81857..232e9b31cc27 100644 --- a/sw/source/core/doc/doctxm.cxx +++ b/sw/source/core/doc/doctxm.cxx @@ -838,9 +838,8 @@ bool SwTOXBaseSection::SetPosAtStartEnd( SwPosition& rPos ) const const SwSectionNode* pSectNd = GetFormat()->GetSectionNode(); if( pSectNd ) { - rPos.nNode = *pSectNd; - SwContentNode* pCNd = pSectNd->GetDoc().GetNodes().GoNext( &rPos.nNode ); - rPos.nContent.Assign( pCNd, 0 ); + rPos.Assign(*pSectNd); + pSectNd->GetDoc().GetNodes().GoNext( &rPos ); bRet = true; } return bRet; diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 961bdeaadcdf..66eb96484281 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -869,9 +869,8 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, { SwPaM& rTmp = const_cast<SwPaM&>(rRange); // Point always at the Start rTmp.DeleteMark(); - rTmp.GetPoint()->nNode = *pTableNd; - SwContentNode* pCNd = GetNodes().GoNext( &rTmp.GetPoint()->nNode ); - rTmp.GetPoint()->nContent.Assign( pCNd, 0 ); + rTmp.GetPoint()->Assign( *pTableNd ); + GetNodes().GoNext( rTmp.GetPoint() ); } if( pUndo ) @@ -4420,8 +4419,8 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes, if( bCorrPos ) { - rInsPos.nNode = *pSttNd; - rInsPos.nContent.Assign( GetNodes().GoNext( &rInsPos.nNode ), 0 ); + rInsPos.Assign( *pSttNd ); + GetNodes().GoNext( &rInsPos ); } getIDocumentRedlineAccess().SetRedlineFlags( eOld ); } diff --git a/sw/source/core/docnode/nodes.cxx b/sw/source/core/docnode/nodes.cxx index 2c0511ea9298..474aa2fd12c0 100644 --- a/sw/source/core/docnode/nodes.cxx +++ b/sw/source/core/docnode/nodes.cxx @@ -1314,6 +1314,23 @@ SwContentNode* SwNodes::GoNext(SwNodeIndex *pIdx) const return static_cast<SwContentNode*>(pNd); } +SwContentNode* SwNodes::GoNext(SwPosition *pIdx) const +{ + if( pIdx->GetNodeIndex() >= Count() - 1 ) + return nullptr; + + SwNodeIndex aTmp(pIdx->GetNode(), +1); + SwNode* pNd = nullptr; + while( aTmp < Count()-1 && !( pNd = &aTmp.GetNode())->IsContentNode() ) + ++aTmp; + + if( aTmp == Count()-1 ) + pNd = nullptr; + else + pIdx->Assign(aTmp); + return static_cast<SwContentNode*>(pNd); +} + SwContentNode* SwNodes::GoPrevious(SwNodeIndex *pIdx) { if( !pIdx->GetIndex() ) @@ -1331,6 +1348,23 @@ SwContentNode* SwNodes::GoPrevious(SwNodeIndex *pIdx) return static_cast<SwContentNode*>(pNd); } +SwContentNode* SwNodes::GoPrevious(SwPosition *pIdx) +{ + if( !pIdx->GetNodeIndex() ) + return nullptr; + + SwNodeIndex aTmp( pIdx->GetNode(), -1 ); + SwNode* pNd = nullptr; + while( aTmp.GetIndex() && !( pNd = &aTmp.GetNode())->IsContentNode() ) + --aTmp; + + if( !aTmp.GetIndex() ) + pNd = nullptr; + else + pIdx->Assign(aTmp); + return static_cast<SwContentNode*>(pNd); +} + /** Delete a number of nodes * * @param rStart starting position in this nodes array diff --git a/sw/source/core/edit/edglbldc.cxx b/sw/source/core/edit/edglbldc.cxx index be63713ec436..93a77ddf5edb 100644 --- a/sw/source/core/edit/edglbldc.cxx +++ b/sw/source/core/edit/edglbldc.cxx @@ -343,14 +343,12 @@ void SwEditShell::GotoGlobalDocContent( const SwGlblDocContent& rPos ) ClearMark(); SwPosition& rCursorPos = *pCursor->GetPoint(); - rCursorPos.nNode = rPos.GetDocPos(); + rCursorPos.Assign(rPos.GetDocPos()); SwDoc* pMyDoc = GetDoc(); SwContentNode * pCNd = rCursorPos.GetNode().GetContentNode(); if( !pCNd ) - pCNd = pMyDoc->GetNodes().GoNext( &rCursorPos.nNode ); - - rCursorPos.nContent.Assign( pCNd, 0 ); + pCNd = pMyDoc->GetNodes().GoNext( &rCursorPos ); EndCursorMove(); } diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx index 728489a20217..1f58ff7bc194 100644 --- a/sw/source/core/fields/expfld.cxx +++ b/sw/source/core/fields/expfld.cxx @@ -139,13 +139,12 @@ static SwTextNode* GetFirstTextNode( const SwDoc& rDoc, SwPosition& rPos, if ( !pCFrame ) { const SwNodes& rNodes = rDoc.GetNodes(); - rPos.nNode = *rNodes.GetEndOfContent().StartOfSectionNode(); + rPos.Assign( *rNodes.GetEndOfContent().StartOfSectionNode() ); SwContentNode* pCNd; - while( nullptr != (pCNd = rNodes.GoNext( &rPos.nNode ) ) && + while( nullptr != (pCNd = rNodes.GoNext( &rPos ) ) && nullptr == ( pTextNode = pCNd->GetTextNode() ) ) ; OSL_ENSURE( pTextNode, "Where is the 1. TextNode?" ); - rPos.nContent.Assign( pTextNode, 0 ); } else if ( !pCFrame->isFrameAreaDefinitionValid() ) { diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 7229f9bd4fe8..666a6e7e3a8c 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -3294,15 +3294,12 @@ uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor() SwPaM aPam(rNode); aPam.Move(fnMoveForward, GoInNode); SwTableNode* pTableNode = aPam.GetNode().FindTableNode(); - SwContentNode* pCont = nullptr; while( pTableNode ) { aPam.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); + SwContentNode* pCont = GetDoc()->GetNodes().GoNext(aPam.GetPoint()); pTableNode = pCont->FindTableNode(); } - if(pCont) - aPam.GetPoint()->nContent.Assign(pCont, 0); const SwStartNode* pNewStartNode = aPam.GetNode().FindSttNodeByType(SwFlyStartNode); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 60a560b8b042..3f0d1708984e 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -990,17 +990,12 @@ SwXTextCursor::gotoStart(sal_Bool Expand) rUnoCursor.Move( fnMoveBackward, GoInDoc ); //check, that the cursor is not in a table SwTableNode * pTableNode = rUnoCursor.GetNode().FindTableNode(); - SwContentNode * pCNode = nullptr; while (pTableNode) { rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + SwContentNode* pCNode = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); pTableNode = pCNode ? pCNode->FindTableNode() : nullptr; } - if (pCNode) - { - rUnoCursor.GetPoint()->nContent.Assign(pCNode, 0); - } SwStartNode const*const pTmp = rUnoCursor.GetNode().StartOfSectionNode(); if (pTmp->IsSectionNode()) @@ -1009,7 +1004,7 @@ SwXTextCursor::gotoStart(sal_Bool Expand) static_cast<SwSectionNode const*>(pTmp); if (pSectionStartNode->GetSection().IsHiddenFlag()) { - pCNode = GetDoc()->GetNodes().GoNextSection( + SwContentNode* pCNode = GetDoc()->GetNodes().GoNextSection( &rUnoCursor.GetPoint()->nNode, true, false); if (pCNode) { diff --git a/sw/source/core/unocore/unoredline.cxx b/sw/source/core/unocore/unoredline.cxx index 197a5542b072..10da49719cd6 100644 --- a/sw/source/core/unocore/unoredline.cxx +++ b/sw/source/core/unocore/unoredline.cxx @@ -106,16 +106,13 @@ uno::Reference<text::XTextCursor> SwXRedlineText::createTextCursor() // skip all tables at the beginning SwTableNode* pTableNode = rUnoCursor.GetNode().FindTableNode(); - SwContentNode* pContentNode = nullptr; bool bTable = pTableNode != nullptr; while( pTableNode != nullptr ) { rUnoCursor.GetPoint()->nNode = *(pTableNode->EndOfSectionNode()); - pContentNode = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + SwContentNode* pContentNode = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); pTableNode = pContentNode->FindTableNode(); } - if( pContentNode != nullptr ) - rUnoCursor.GetPoint()->nContent.Assign( pContentNode, 0 ); if( bTable && rUnoCursor.GetNode().FindSttNodeByType( SwNormalStartNode ) != GetStartNode() ) { @@ -543,15 +540,12 @@ uno::Reference< text::XTextCursor > SwXRedline::createTextCursor() // is here a table? SwTableNode* pTableNode = rUnoCursor.GetNode().FindTableNode(); - SwContentNode* pCont = nullptr; while( pTableNode ) { rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + SwContentNode* pCont = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); pTableNode = pCont->FindTableNode(); } - if(pCont) - rUnoCursor.GetPoint()->nContent.Assign(pCont, 0); return static_cast<text::XWordCursor*>(pXCursor.get()); } diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx index 2cb69face648..d5e2cac57e35 100644 --- a/sw/source/core/unocore/unotext.cxx +++ b/sw/source/core/unocore/unotext.cxx @@ -2504,17 +2504,12 @@ rtl::Reference<SwXTextCursor> SwXBodyText::CreateTextCursor(const bool bIgnoreTa if (!bIgnoreTables) { SwTableNode * pTableNode = aPam.GetNode().FindTableNode(); - SwContentNode * pCont = nullptr; while (pTableNode) { aPam.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); + SwContentNode* pCont = GetDoc()->GetNodes().GoNext(aPam.GetPoint()); pTableNode = pCont->FindTableNode(); } - if (pCont) - { - aPam.GetPoint()->nContent.Assign(pCont, 0); - } } return new SwXTextCursor(*GetDoc(), this, CursorType::Body, *aPam.GetPoint()); } @@ -2764,17 +2759,12 @@ uno::Reference<text::XTextCursor> SwXHeadFootText::CreateTextCursor(const bool b { // is there a table here? SwTableNode* pTableNode = rUnoCursor.GetNode().FindTableNode(); - SwContentNode* pCont = nullptr; while (pTableNode) { rUnoCursor.GetPoint()->nNode = *pTableNode->EndOfSectionNode(); - pCont = GetDoc()->GetNodes().GoNext(&rUnoCursor.GetPoint()->nNode); + SwContentNode* pCont = GetDoc()->GetNodes().GoNext(rUnoCursor.GetPoint()); pTableNode = pCont->FindTableNode(); } - if (pCont) - { - rUnoCursor.GetPoint()->nContent.Assign(pCont, 0); - } } SwStartNode const*const pNewStartNode = rUnoCursor.GetNode().FindSttNodeByType( (m_pImpl->m_bIsHeader) ? SwHeaderStartNode : SwFooterStartNode); diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx index 6db247527c31..b779ec4e53ab 100644 --- a/sw/source/filter/html/htmltab.cxx +++ b/sw/source/filter/html/htmltab.cxx @@ -3457,10 +3457,7 @@ void SwHTMLParser::BuildTableCell( HTMLTable *pCurTable, bool bReadOptions, pTCntxt->SetFrameFormat( pFrameFormat ); const SwFormatContent& rFlyContent = pFrameFormat->GetContent(); m_pPam->GetPoint()->nNode = *rFlyContent.GetContentIdx(); - SwContentNode *pCNd = - m_xDoc->GetNodes().GoNext( &(m_pPam->GetPoint()->nNode) ); - m_pPam->GetPoint()->nContent.Assign( pCNd, 0 ); - + m_xDoc->GetNodes().GoNext( m_pPam->GetPoint() ); } // create a SwTable with a box and set the PaM to the content of commit 8dd67096d9472aaf46c9db59921b65d92f8c3827 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Thu Aug 4 14:47:53 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Aug 5 09:17:55 2022 +0200 use more SwPosition::Assign as part of the process of hiding the internals of SwPosition these are still the easy ones, i.e. no functional change intended Change-Id: Ibb2adf17de47bab5374730b508d9c020991a945e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137802 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 f9cb439d0407..60675cd2aa33 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -86,8 +86,8 @@ struct SAL_WARN_UNUSED SW_DLLPUBLIC SwPosition void Assign( const SwNode& rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset = 0 ); void Assign( SwNodeOffset nNodeOffset, sal_Int32 nContentOffset = 0 ); void Assign( const SwContentNode& rNode, sal_Int32 nContentOffset = 0 ); - void Assign( const SwNode& rNd ); - void Assign( const SwNodeIndex& rNdIdx ); + void Assign( const SwNode& rNd, sal_Int32 nContentOffset = 0 ); + void Assign( const SwNodeIndex& rNdIdx, sal_Int32 nContentOffset = 0 ); /// Set nNode to rNd, and nContent to the beginning of rNd void AssignStartIndex( const SwContentNode& rNd ); /// Set nNode to rNd, and nContent to the end of rNd diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index d2bec56c9f98..c23dd899eeae 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -224,15 +224,15 @@ void SwPosition::Assign( const SwContentNode& rNode, sal_Int32 nContentOffset ) nNode = rNode; nContent.Assign(&rNode, nContentOffset); } -void SwPosition::Assign( const SwNode& rNd ) +void SwPosition::Assign( const SwNode& rNd, sal_Int32 nContentOffset ) { nNode.Assign(rNd); - nContent.Assign(rNd.GetContentNode(), 0); + nContent.Assign(rNd.GetContentNode(), nContentOffset); } -void SwPosition::Assign( const SwNodeIndex& rNdIdx ) +void SwPosition::Assign( const SwNodeIndex& rNdIdx, sal_Int32 nContentOffset ) { nNode = rNdIdx; - nContent.Assign(nNode.GetNode().GetContentNode(), 0); + nContent.Assign(nNode.GetNode().GetContentNode(), nContentOffset); } void SwPosition::Adjust( SwNodeOffset nDelta ) { diff --git a/sw/source/core/doc/CntntIdxStore.cxx b/sw/source/core/doc/CntntIdxStore.cxx index a7795a6fdfb5..3c89c2384a17 100644 --- a/sw/source/core/doc/CntntIdxStore.cxx +++ b/sw/source/core/doc/CntntIdxStore.cxx @@ -108,15 +108,15 @@ namespace : m_pNewContentNode(pNewContentNode), m_nLen(nLen), m_nCorrLen(nCorrLen) {}; void operator()(SwPosition& rPos, sal_Int32 nContent) const { - rPos.nNode = *m_pNewContentNode; if( nContent < m_nCorrLen ) { - rPos.nContent.Assign(m_pNewContentNode, std::min( nContent, static_cast<sal_Int32>(m_nLen) ) ); + nContent = std::min( nContent, static_cast<sal_Int32>(m_nLen) ); } else { - rPos.nContent -= m_nCorrLen; + nContent -= m_nCorrLen; } + rPos.Assign( *m_pNewContentNode, nContent ); }; }; struct ContentIdxStoreImpl : sw::mark::ContentIdxStore diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx index a5c2941979cc..9fa6df2f86c0 100644 --- a/sw/source/core/doc/DocumentContentOperationsManager.cxx +++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx @@ -770,23 +770,21 @@ namespace void SetPos( SwNodeOffset nInsPos ) { - pRedl->GetPoint()->nNode = nInsPos + nStt; - pRedl->GetPoint()->nContent.Assign( pRedl->GetContentNode(), nSttCnt ); + pRedl->GetPoint()->Assign( nInsPos + nStt, nSttCnt ); if( pRedl->HasMark() ) { - pRedl->GetMark()->nNode = nInsPos + nEnd; - pRedl->GetMark()->nContent.Assign( pRedl->GetContentNode(false), nEndCnt ); + pRedl->GetMark()->Assign( nInsPos + nEnd, nEndCnt ); } } void SetPos( const SwPosition& aPos ) { - pRedl->GetPoint()->nNode = aPos.GetNodeIndex() + nStt; - pRedl->GetPoint()->nContent.Assign( pRedl->GetContentNode(), nSttCnt + ( nStt == SwNodeOffset(0) ? aPos.GetContentIndex() : 0 ) ); + pRedl->GetPoint()->Assign( aPos.GetNodeIndex() + nStt, + nSttCnt + ( nStt == SwNodeOffset(0) ? aPos.GetContentIndex() : 0 ) ); if( pRedl->HasMark() ) { - pRedl->GetMark()->nNode = aPos.GetNodeIndex() + nEnd; - pRedl->GetMark()->nContent.Assign( pRedl->GetContentNode(false), nEndCnt + ( nEnd == SwNodeOffset(0) ? aPos.GetContentIndex() : 0 ) ); + pRedl->GetMark()->Assign( aPos.GetNodeIndex() + nEnd, + nEndCnt + ( nEnd == SwNodeOffset(0) ? aPos.GetContentIndex() : 0 ) ); } } }; @@ -900,23 +898,17 @@ namespace // The copy is moved too. SwRangeRedline* pNewRedl = new SwRangeRedline( *pTmp ); SwPosition* pTmpPos = pNewRedl->Start(); - pTmpPos->nNode = rRg.aStart; - pTmpPos->nContent.Assign( - pTmpPos->GetNode().GetContentNode(), 0 ); + pTmpPos->Assign(rRg.aStart); rArr.emplace_back(pNewRedl, rRg.aStart); pTmpPos = pTmp->End(); - pTmpPos->nNode = rRg.aEnd; - pTmpPos->nContent.Assign( - pTmpPos->GetNode().GetContentNode(), 0 ); + pTmpPos->Assign(rRg.aEnd); } else if( pREnd->nNode == rRg.aStart ) { SwPosition* pTmpPos = pTmp->End(); - pTmpPos->nNode = rRg.aEnd; - pTmpPos->nContent.Assign( - pTmpPos->GetNode().GetContentNode(), 0 ); + pTmpPos->Assign(rRg.aEnd); } } else if( pRStt->nNode < rRg.aEnd ) @@ -933,16 +925,12 @@ namespace // split SwRangeRedline* pNewRedl = new SwRangeRedline( *pTmp ); SwPosition* pTmpPos = pNewRedl->End(); - pTmpPos->nNode = rRg.aEnd; - pTmpPos->nContent.Assign( - pTmpPos->GetNode().GetContentNode(), 0 ); + pTmpPos->Assign(rRg.aEnd); rArr.emplace_back( pNewRedl, rRg.aStart ); pTmpPos = pTmp->Start(); - pTmpPos->nNode = rRg.aEnd; - pTmpPos->nContent.Assign( - pTmpPos->GetNode().GetContentNode(), 0 ); + pTmpPos->Assign(rRg.aEnd); rDoc.getIDocumentRedlineAccess().AppendRedline( pTmp, true ); } } @@ -4566,9 +4554,7 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt SplitNode( *aDelPam.GetPoint(), false ); ++aMkNd; - aDelPam.GetMark()->nNode = aMkNd; - aDelPam.GetMark()->nContent.Assign( - aMkNd.GetNode().GetContentNode(), nMkCnt ); + aDelPam.GetMark()->Assign( aMkNd, nMkCnt ); bFirst = false; } else @@ -4583,9 +4569,7 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt aTmpRange.SetMark(); ++aPtNd; - aDelPam.GetPoint()->nNode = aPtNd; - aDelPam.GetPoint()->nContent.Assign( aPtNd.GetNode().GetContentNode(), - nPtCnt); + aDelPam.GetPoint()->Assign(aPtNd, nPtCnt); *aTmpRange.GetMark() = *aDelPam.GetPoint(); m_rDoc.RstTextAttrs( aTmpRange ); @@ -4700,9 +4684,7 @@ bool DocumentContentOperationsManager::ReplaceRangeImpl( SwPaM& rPam, const OUSt *rPam.GetPoint() = *aDelPam.GetMark(); ++aPtNd; - rPam.GetMark()->nNode = aPtNd; - rPam.GetMark()->nContent.Assign( aPtNd.GetNode().GetContentNode(), - nPtCnt ); + rPam.GetMark()->Assign( aPtNd, nPtCnt ); if (bJoinText) { diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index 490b2bc00953..303b7d01dc8b 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -1759,9 +1759,7 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall if( (pStt->nContent == 0) && pEnd->GetNode().IsEndNode() ) { - pEnd->nNode--; - pEnd->nContent.Assign( - pEnd->GetNode().GetTextNode(), 0); + pEnd->Adjust(SwNodeOffset(-1)); m_rDoc.getIDocumentContentOperations().DelFullPara( *pNewRedl ); } else diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx index 4102c97aa25c..215c728e65a2 100644 --- a/sw/source/core/doc/docbm.cxx +++ b/sw/source/core/doc/docbm.cxx @@ -1458,13 +1458,13 @@ namespace sw::mark // Remove the old fieldmark and create a new one with the new type if (rNewType == ODF_FORMDROPDOWN || rNewType == ODF_FORMCHECKBOX) { - SwPosition aNewPos (aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent); + SwPosition aNewPos (*aPaM.GetPoint()); deleteFieldmarkAt(aNewPos); return makeNoTextFieldBookmark(aPaM, sName, rNewType); } else if(rNewType == ODF_FORMDATE) { - SwPosition aPos (aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent); + SwPosition aPos (*aPaM.GetPoint()); SwPaM aNewPaM(pFieldmark->GetMarkStart(), pFieldmark->GetMarkEnd()); deleteFieldmarkAt(aPos); // HACK: hard-code the separator position here at the start because diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx index 1d236a6aba7d..e526f6c5946b 100644 --- a/sw/source/core/doc/doccomp.cxx +++ b/sw/source/core/doc/doccomp.cxx @@ -1959,9 +1959,7 @@ sal_uInt16 SaveMergeRedline::InsertRedline(SwPaM* pLastDestRedline) pDestRedl->SetMark(); ++aSaveNd; - pDestRedl->GetMark()->nNode = aSaveNd; - pDestRedl->GetMark()->nContent.Assign( aSaveNd.GetNode().GetContentNode(), - nSaveCnt ); + pDestRedl->GetMark()->Assign( aSaveNd, nSaveCnt ); if( pLastDestRedline && *pLastDestRedline->GetPoint() == *pDestRedl->GetPoint() ) *pLastDestRedline->GetPoint() = *pDestRedl->GetMark(); diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx index 1a52a8458cd7..dd178f7941aa 100644 --- a/sw/source/core/doc/docfld.cxx +++ b/sw/source/core/doc/docfld.cxx @@ -197,8 +197,7 @@ void SetGetExpField::GetPosOfContent( SwPosition& rPos ) const } else { - rPos.nNode = m_nNode; - rPos.nContent.Assign( rPos.GetNode().GetContentNode(), m_nContent ); + rPos.Assign( m_nNode, m_nContent ); } } diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx index 5ea677b2d9fc..c0d3efa66d35 100644 --- a/sw/source/core/doc/docnum.cxx +++ b/sw/source/core/doc/docnum.cxx @@ -69,10 +69,8 @@ namespace { if ( rPam.HasMark() && rPam.End()->GetNode().GetTextNode() ) { - SwPaM aPam( rPam.Start()->nNode, - rPam.End()->nNode ); - aPam.Start()->nContent = 0; - aPam.End()->nContent = rPam.End()->GetNode().GetTextNode()->Len(); + SwPaM aPam( rPam.Start()->nNode, 0, + rPam.End()->nNode, rPam.End()->GetNode().GetTextNode()->Len() ); pDoc->ResetAttrs( aPam, false, aResetAttrsArray, true, pLayout ); } else @@ -1563,8 +1561,7 @@ static bool lcl_GotoNextPrevNum( SwPosition& rPos, bool bNext, if( ::lcl_IsNumOk( nSrchNum, nLower, nUpper, bOverUpper, static_cast<sal_uInt8>(pNd->GetActualListLevel()) )) { - rPos.nNode = aIdx; - rPos.nContent.Assign( pNd, 0 ); + rPos.Assign(aIdx); bRet = true; break; } diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 435480730372..961bdeaadcdf 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -675,9 +675,7 @@ const SwTable* SwDoc::TextToTable( const SwInsertTableOptions& rInsTableOpts, || pEnd->GetNodeIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 ) { getIDocumentContentOperations().SplitNode( *pEnd, false ); - --const_cast<SwNodeIndex&>(pEnd->nNode); - const_cast<SwContentIndex&>(pEnd->nContent).Assign( - pEnd->GetNode().GetContentNode(), 0 ); + const_cast<SwPosition*>(pEnd)->Adjust(SwNodeOffset(-1)); // A Node and at the End? if( pStt->GetNodeIndex() >= pEnd->GetNodeIndex() ) --aRg.aStart; @@ -1152,7 +1150,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > //!!! not necessarily TextNodes !!! SwPaM aOriginal( rStartRange.aStart, rEndRange.aEnd ); const SwPosition *pStt = aOriginal.GetMark(); - const SwPosition *pEnd = aOriginal.GetPoint(); + SwPosition *pEnd = aOriginal.GetPoint(); bool const bUndo(GetIDocumentUndoRedo().DoesUndo()); if (bUndo) @@ -1177,9 +1175,7 @@ const SwTable* SwDoc::TextToTable( const std::vector< std::vector<SwNodeRange> > || pEnd->GetNodeIndex() >= GetNodes().GetEndOfContent().GetIndex()-1 ) { getIDocumentContentOperations().SplitNode( *pEnd, false ); - --const_cast<SwNodeIndex&>(pEnd->nNode); - const_cast<SwContentIndex&>(pEnd->nContent).Assign( - pEnd->GetNode().GetContentNode(), 0 ); + pEnd->Adjust(SwNodeOffset(-1)); // A Node and at the End? if( pStt->GetNodeIndex() >= pEnd->GetNodeIndex() ) --aRg.aStart; diff --git a/sw/source/core/edit/eddel.cxx b/sw/source/core/edit/eddel.cxx index 3dbb4ef5d963..d3fd0fc45b43 100644 --- a/sw/source/core/edit/eddel.cxx +++ b/sw/source/core/edit/eddel.cxx @@ -273,8 +273,7 @@ bool SwEditShell::Copy( SwEditShell& rDestShell ) { SwPaM* pCursor = rDestShell.GetCursor(); pCursor->SetMark(); - pCursor->GetPoint()->nNode = aSttNdIdx.GetIndex()+1; - pCursor->GetPoint()->nContent.Assign( pCursor->GetContentNode(),nSttCntIdx); + pCursor->GetPoint()->Assign( aSttNdIdx.GetIndex()+1, nSttCntIdx ); pCursor->Exchange(); } else diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 5184bfda4284..ce09668a739e 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -473,8 +473,7 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) if( pCNd ) { SwPaM* pPam = GetCursor(); - pPam->GetPoint()->nNode = aIdx; - pPam->GetPoint()->nContent.Assign( pCNd, 0 ); + pPam->GetPoint()->Assign( *pCNd, 0 ); pPam->SetMark(); // both want something pPam->DeleteMark(); } diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx index e197c7c6f9bc..9d4660336745 100644 --- a/sw/source/core/undo/unattr.cxx +++ b/sw/source/core/undo/unattr.cxx @@ -724,8 +724,7 @@ void SwUndoAttr::UndoImpl(::sw::UndoRedoContext & rContext) SwPaM aPam(pDoc->GetNodes().GetEndOfContent()); if ( NODE_OFFSET_MAX != m_nNodeIndex ) { aPam.DeleteMark(); - aPam.GetPoint()->nNode = m_nNodeIndex; - aPam.GetPoint()->nContent.Assign( aPam.GetContentNode(), m_nSttContent ); + aPam.GetPoint()->Assign( m_nNodeIndex, m_nSttContent ); aPam.SetMark(); ++aPam.GetPoint()->nContent; pDoc->getIDocumentRedlineAccess().DeleteRedline(aPam, false, RedlineType::Any); @@ -1040,8 +1039,7 @@ void SwUndoDontExpandFormat::UndoImpl(::sw::UndoRedoContext & rContext) SwDoc *const pDoc = & rContext.GetDoc(); SwPosition& rPos = *pPam->GetPoint(); - rPos.nNode = m_nNodeIndex; - rPos.nContent.Assign( rPos.GetNode().GetContentNode(), m_nContentIndex); + rPos.Assign( m_nNodeIndex, m_nContentIndex ); pDoc->DontExpandFormat( rPos, false ); } @@ -1051,8 +1049,7 @@ void SwUndoDontExpandFormat::RedoImpl(::sw::UndoRedoContext & rContext) SwDoc *const pDoc = & rContext.GetDoc(); SwPosition& rPos = *pPam->GetPoint(); - rPos.nNode = m_nNodeIndex; - rPos.nContent.Assign( rPos.GetNode().GetContentNode(), m_nContentIndex); + rPos.Assign( m_nNodeIndex, m_nContentIndex ); pDoc->DontExpandFormat( rPos ); } diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index f8a8c73e2372..6ba42b5327cc 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -279,9 +279,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) // set cursor to Undo range pPam->DeleteMark(); - pPam->GetPoint()->nNode = nNd; - pPam->GetPoint()->nContent.Assign( - pPam->GetPoint()->GetNode().GetContentNode(), nCnt ); + pPam->GetPoint()->Assign( nNd, nCnt ); } maUndoText.reset(); @@ -673,8 +671,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext) if (m_nSttNd != m_nEndNd) { // in case of regex inserting paragraph breaks, join nodes... assert(rPam.GetMark()->nContent == rPam.GetMark()->GetNode().GetTextNode()->Len()); - rPam.GetPoint()->nNode = m_nEndNd - m_nOffset; - rPam.GetPoint()->nContent.Assign(rPam.GetContentNode(true), m_nEndCnt); + rPam.GetPoint()->Assign( m_nEndNd - m_nOffset, m_nEndCnt ); pDoc->getIDocumentContentOperations().DeleteAndJoin(rPam); } rPam.DeleteMark(); @@ -718,8 +715,7 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext) } } - rPam.GetPoint()->nNode = m_nSttNd; - rPam.GetPoint()->nContent.Assign(rPam.GetPoint()->GetNode().GetTextNode(), m_nSttCnt); + rPam.GetPoint()->Assign( m_nSttNd, m_nSttCnt ); } void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext) diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx index 48327e653551..9117ddeadd62 100644 --- a/sw/source/core/undo/unredln.cxx +++ b/sw/source/core/undo/unredln.cxx @@ -356,8 +356,7 @@ void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) SwPaM aTmp( *rPam.GetMark() ); aTmp.GetMark()->nContent = 0; aTmp.SetMark(); - aTmp.GetPoint()->nNode = m_nSaveEndNode; - aTmp.GetPoint()->nContent.Assign( aTmp.GetContentNode(), m_nSaveEndContent ); + aTmp.GetPoint()->Assign( m_nSaveEndNode, m_nSaveEndContent ); rDoc.getIDocumentRedlineAccess().DeleteRedline( aTmp, true, RedlineType::Any ); } @@ -404,8 +403,7 @@ void SwUndoRedlineSort::RedoRedlineImpl(SwDoc & rDoc, SwPaM & rPam) SetValues( rPam ); SetPaM( rPam ); - rPam.GetPoint()->nNode = m_nSaveEndNode; - rPam.GetPoint()->nContent.Assign( rPam.GetContentNode(), m_nSaveEndContent ); + rPam.GetPoint()->Assign( m_nSaveEndNode, m_nSaveEndContent ); } void SwUndoRedlineSort::RepeatImpl(::sw::RepeatContext & rContext) diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx index d91f21570641..51afe0d8145e 100644 --- a/sw/source/core/undo/unspnd.cxx +++ b/sw/source/core/undo/unspnd.cxx @@ -116,9 +116,7 @@ void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext) if( IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() )) { rPam.SetMark(); - ++rPam.GetMark()->nNode; - rPam.GetMark()->nContent.Assign( rPam.GetMark()-> - GetNode().GetContentNode(), 0 ); + rPam.GetMark()->Adjust(SwNodeOffset(1)); pDoc->getIDocumentRedlineAccess().DeleteRedline( rPam, true, RedlineType::Any ); rPam.DeleteMark(); } @@ -142,8 +140,7 @@ void SwUndoSplitNode::UndoImpl(::sw::UndoRedoContext & rContext) // also set the cursor onto undo section rPam.DeleteMark(); - rPam.GetPoint()->nNode = m_nNode; - rPam.GetPoint()->nContent.Assign( rPam.GetContentNode(), m_nContent ); + rPam.GetPoint()->Assign( m_nNode, m_nContent ); } void SwUndoSplitNode::RedoImpl(::sw::UndoRedoContext & rContext) diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index bb715149e328..6b0a0f01a4b8 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -671,8 +671,7 @@ void SwUndoTableToText::RedoImpl(::sw::UndoRedoContext & rContext) OSL_FAIL( "Where is the TextNode now?" ); } - pPam->GetPoint()->nNode = aSaveIdx; - pPam->GetPoint()->nContent.Assign( pCNd, 0 ); + pPam->GetPoint()->Assign( aSaveIdx ); pPam->SetMark(); // log off all indices pPam->DeleteMark(); @@ -1990,8 +1989,7 @@ void SwUndoTableMerge::UndoImpl(::sw::UndoRedoContext & rContext) } SwPaM *const pPam(& rContext.GetCursorSupplier().CreateNewShellCursor()); pPam->DeleteMark(); - pPam->GetPoint()->nNode = m_nSttNode; - pPam->GetPoint()->nContent.Assign( pPam->GetContentNode(), m_nSttContent ); + pPam->GetPoint()->Assign(m_nSttNode, m_nSttContent ); pPam->SetMark(); pPam->DeleteMark(); diff --git a/sw/source/core/unocore/unoobj.cxx b/sw/source/core/unocore/unoobj.cxx index 53c98b71e149..60a560b8b042 100644 --- a/sw/source/core/unocore/unoobj.cxx +++ b/sw/source/core/unocore/unoobj.cxx @@ -1337,8 +1337,7 @@ SwXTextCursor::gotoEndOfWord(sal_Bool Expand) bRet = rUnoCursor.IsEndWordWT( nWordType ); if (!bRet) { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; + pPoint->Assign(rOldNode, nOldIndex); } else if (CursorType::Meta == m_eType) { @@ -1373,8 +1372,7 @@ SwXTextCursor::gotoStartOfWord(sal_Bool Expand) bRet = rUnoCursor.IsStartWordWT( nWordType ); if (!bRet) { - pPoint->nNode = rOldNode; - pPoint->nContent = nOldIndex; + pPoint->Assign(rOldNode, nOldIndex); } else if (CursorType::Meta == m_eType) { diff --git a/sw/source/core/unocore/unoobj2.cxx b/sw/source/core/unocore/unoobj2.cxx index 5df6323eaae7..4980208bb1ca 100644 --- a/sw/source/core/unocore/unoobj2.cxx +++ b/sw/source/core/unocore/unoobj2.cxx @@ -1075,10 +1075,9 @@ bool SwXTextRange::GetPositions(SwPaM& rToFill, ::sw::TextRangeMode const eMode) assert(pSectionNode->GetNodes().IsDocNodes()); rToFill.GetPoint()->Assign( pSectionNode->GetNode(), SwNodeOffset(1) ); rToFill.SetMark(); - rToFill.GetMark()->nNode = *pSectionNode->GetNode().EndOfSectionNode(); - --rToFill.GetMark()->nNode; - rToFill.GetMark()->nContent.Assign(rToFill.GetMark()->GetNode().GetContentNode(), - rToFill.GetMark()->GetNode().GetContentNode() ? rToFill.GetMark()->GetNode().GetContentNode()->Len() : 0); + rToFill.GetMark()->Assign( *pSectionNode->GetNode().EndOfSectionNode(), SwNodeOffset(-1) ); + if (const SwContentNode* pCNd = rToFill.GetMark()->GetContentNode()) + rToFill.GetMark()->AssignEndIndex(*pCNd); return true; } } diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx index b1e7c2bc2bac..7c88eae3c7b0 100644 --- a/sw/source/filter/ascii/parasc.cxx +++ b/sw/source/filter/ascii/parasc.cxx @@ -239,9 +239,8 @@ ErrCode SwASCIIParser::CallParser() { // then set over the insert range the defined attributes *pInsPam->GetMark() = *m_pPam->GetPoint(); - ++pInsPam->GetPoint()->nNode; - pInsPam->GetPoint()->nContent.Assign( - pInsPam->GetContentNode(), nSttContent ); + pInsPam->GetPoint()->Assign(pInsPam->GetPoint()->GetNode(), SwNodeOffset(1), + nSttContent ); // !!!!! OSL_ENSURE( false, "Have to change - hard attr. to para. style" ); diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 3dfe492c831a..0455fb909898 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -670,8 +670,7 @@ void SwAnnotationWin::SetPosAndSize() { SwShellTableCursor* pTableCursor = new SwShellTableCursor( mrView.GetWrtShell(), aStartPos ); pTableCursor->SetMark(); - pTableCursor->GetMark()->nNode = *pTextNode; - pTableCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 ); + pTableCursor->GetMark()->Assign( *pTextNode, pTextAnnotationField->GetStart()+1 ); pTableCursor->NewTableSelection(); pTmpCursor = pTableCursor; } @@ -679,8 +678,7 @@ void SwAnnotationWin::SetPosAndSize() { SwShellCursor* pCursor = new SwShellCursor( mrView.GetWrtShell(), aStartPos ); pCursor->SetMark(); - pCursor->GetMark()->nNode = *pTextNode; - pCursor->GetMark()->nContent.Assign( pTextNode, pTextAnnotationField->GetStart()+1 ); + pCursor->GetMark()->Assign(*pTextNode, pTextAnnotationField->GetStart()+1 ); pTmpCursor = pCursor; } std::unique_ptr<SwShellCursor> pTmpCursorForAnnotationTextRange( pTmpCursor ); diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 863b5ac6c65e..359d01ddec40 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -5833,23 +5833,19 @@ void SwEditWin::Command( const CommandEvent& rCEvt ) if( nPosNodeIdx < nMarkNodeIdx ) { - rSh.GetCursor()->GetPoint()->nNode = nPosNodeIdx; - rSh.GetCursor()->GetPoint()->nContent = nPosIdx; + rSh.GetCursor()->GetPoint()->Assign(nPosNodeIdx, nPosIdx); rSh.GetCursor()->GetMark()->nNode = nPosNodeIdx; rSh.GetCursor()->GetMark()->nContent = rSh.GetCursor()->GetContentNode()->Len(); } else if( nPosNodeIdx == nMarkNodeIdx ) { - rSh.GetCursor()->GetPoint()->nNode = nPosNodeIdx; - rSh.GetCursor()->GetPoint()->nContent = nPosIdx; - rSh.GetCursor()->GetMark()->nNode = nMarkNodeIdx; - rSh.GetCursor()->GetMark()->nContent = nMarkIdx; + rSh.GetCursor()->GetPoint()->Assign(nPosNodeIdx, nPosIdx); + rSh.GetCursor()->GetMark()->Assign(nMarkNodeIdx, nMarkIdx); } else { - rSh.GetCursor()->GetMark()->nNode = nMarkNodeIdx; - rSh.GetCursor()->GetMark()->nContent = nMarkIdx; + rSh.GetCursor()->GetMark()->Assign(nMarkNodeIdx, nMarkIdx); rSh.GetCursor()->GetPoint()->nNode = nMarkNodeIdx; rSh.GetCursor()->GetPoint()->nContent = rSh.GetCursor()->GetContentNode( false )->Len();