sw/inc/node.hxx | 6 ++--- sw/qa/core/uwriter.cxx | 4 +-- sw/source/core/crsr/pam.cxx | 45 +++++++++++++--------------------------- sw/source/core/crsr/paminit.cxx | 2 - sw/source/core/doc/docruby.cxx | 2 - sw/source/core/docnode/node.cxx | 28 ++++++++++++------------ sw/source/core/edit/edattr.cxx | 2 - sw/source/core/inc/pamtyp.hxx | 10 ++------ 8 files changed, 39 insertions(+), 60 deletions(-)
New commits: commit 4c6316ef441a2013cf92ed81436ad569d6ebe44a Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sun Jan 19 18:33:22 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Mon Jan 20 17:19:34 2025 +0100 fnNds is dead ever since commit f761e0aee58fe152b69daaa0e4b9697ad4f0e038 Author: Noel Grandin <noelgran...@gmail.com> Date: Tue Oct 11 10:45:31 2022 +0200 use more SwPosition::Assign Change-Id: I4eadbf3cc7dfb8cba6fb778e551cf016355ac337 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180481 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index a073af0f42bf..15e96d25574f 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -392,22 +392,7 @@ bool GoPrevious( SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ) return false; } -SwContentNode* GoNextNds( SwNodeIndex* pIdx, bool bChk ) -{ - SwNodeIndex aIdx( *pIdx ); - SwContentNode* pNd = SwNodes::GoNext(&aIdx); - if( pNd ) - { - if( bChk && SwNodeOffset(1) != aIdx.GetIndex() - pIdx->GetIndex() && - !CheckNodesRange( pIdx->GetNode(), aIdx.GetNode(), true ) ) - pNd = nullptr; - else - *pIdx = aIdx; - } - return pNd; -} - -SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool bChk ) +static SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool bChk ) { SwNodeIndex aIdx( *pIdx ); SwContentNode* pNd = SwNodes::GoPrevious( &aIdx ); diff --git a/sw/source/core/crsr/paminit.cxx b/sw/source/core/crsr/paminit.cxx index a415aee2c21c..39f2a55df43f 100644 --- a/sw/source/core/crsr/paminit.cxx +++ b/sw/source/core/crsr/paminit.cxx @@ -23,7 +23,6 @@ const SwMoveFnCollection aFwrd = { /* fnNd */ &GoNext, - /* fnNds */ &GoNextNds, /* fnPos */ &GoNextPos, /* fnDoc */ &GoEndDoc, /* fnSections */ &GoEndSection, @@ -35,7 +34,6 @@ const SwMoveFnCollection aFwrd = { const SwMoveFnCollection aBwrd = { /* fnNd */ &GoPrevious, - /* fnNds */ &GoPreviousNds, /* fnPos */ &GoPreviousPos, /* fnDoc */ &GoStartDoc, /* fnSections */ &GoStartSection, diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx index 30e53f1d2848..33c920e41ebb 100644 --- a/sw/source/core/inc/pamtyp.hxx +++ b/sw/source/core/inc/pamtyp.hxx @@ -56,14 +56,11 @@ const SwTextAttr* GetBkwrdTextHint( const SwpHints&, size_t&, sal_Int32 ); bool GoNext(SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ); bool GoPrevious(SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ); -SwContentNode* GoNextNds( SwNodeIndex * pIdx, bool ); -SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool ); SwContentNode* GoNextPos( SwPosition * pIdx, bool ); SwContentNode* GoPreviousPos( SwPosition * pIdx, bool ); // type definitions of functions typedef bool (*GoNd)( SwNode&, SwContentIndex&, SwCursorSkipMode ); -typedef SwContentNode* (*GoNds)( SwNodeIndex*, bool ); typedef SwContentNode* (*GoPos)( SwPosition*, bool ); typedef void (*GoDoc)( SwPosition* ); typedef void (*GoSection)( SwPosition* ); @@ -76,7 +73,6 @@ typedef void (*MvSection)( SwPosition * ); struct SwMoveFnCollection { GoNd fnNd; - GoNds fnNds; GoPos fnPos; GoDoc fnDoc; GoSection fnSections; commit f60995e97f50152aca57305a0f13e708265186a6 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jan 18 19:19:14 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Mon Jan 20 17:19:23 2025 +0100 pass param by reference in GoNext/GoPrevious to enforce that they are never nullptr Change-Id: I973dcc143b5334c3060a0f815474e569deae4c27 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180459 Tested-by: Jenkins Reviewed-by: Ashod Nakashian <a...@collabora.com> diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx index 13bbda8a81cb..a19d48e247c1 100644 --- a/sw/inc/node.hxx +++ b/sw/inc/node.hxx @@ -439,9 +439,9 @@ public: bool CanJoinNext( SwPosition* pIdx ) const; SW_DLLPUBLIC bool CanJoinPrev( SwNodeIndex* pIdx =nullptr ) const; - bool GoNext(SwContentIndex *, SwCursorSkipMode nMode ) const; - bool GoNext(SwPosition*, SwCursorSkipMode nMode ) const; - bool GoPrevious(SwContentIndex *, SwCursorSkipMode nMode ) const; + bool GoNext(SwContentIndex&, SwCursorSkipMode nMode ) const; + bool GoNext(SwPosition&, SwCursorSkipMode nMode ) const; + bool GoPrevious(SwContentIndex&, SwCursorSkipMode nMode ) const; /// @see GetFrameOfModify SW_DLLPUBLIC SwContentFrame *getLayoutFrame( const SwRootFrame*, diff --git a/sw/qa/core/uwriter.cxx b/sw/qa/core/uwriter.cxx index 4f6be8ff159e..8a03254e7c5d 100644 --- a/sw/qa/core/uwriter.cxx +++ b/sw/qa/core/uwriter.cxx @@ -2477,7 +2477,7 @@ void SwDocTest::testSetRubyList() SwPosition aNewPos{ aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent }; const SwTextNode* pTNd = aNewPos.GetNode().GetTextNode(); - pTNd->GoNext(&aNewPos, SwCursorSkipMode::Chars); + pTNd->GoNext(aNewPos, SwCursorSkipMode::Chars); SwPaM aEmptyPaM{ aNewPos }; aEmptyPaM.SetMark(); @@ -2548,7 +2548,7 @@ void SwDocTest::testSetRubyList() SwPosition aNewPos{ aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent }; const SwTextNode* pTNd = aNewPos.GetNode().GetTextNode(); - pTNd->GoNext(&aNewPos, SwCursorSkipMode::Chars); + pTNd->GoNext(aNewPos, SwCursorSkipMode::Chars); SwPaM aEmptyPaM{ aNewPos }; aEmptyPaM.SetMark(); diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index b122b474e38e..a073af0f42bf 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -378,17 +378,17 @@ bool CheckNodesRange( const SwNode& rStt, return false; // somewhere in between => error } -bool GoNext(SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ) +bool GoNext(SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ) { - if( pNd->IsContentNode() ) - return static_cast<SwContentNode*>(pNd)->GoNext( pIdx, nMode ); + if( rNd.IsContentNode() ) + return static_cast<SwContentNode&>(rNd).GoNext( rIdx, nMode ); return false; } -bool GoPrevious( SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ) +bool GoPrevious( SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ) { - if( pNd->IsContentNode() ) - return static_cast<SwContentNode*>(pNd)->GoPrevious( pIdx, nMode ); + if( rNd.IsContentNode() ) + return static_cast<SwContentNode&>(rNd).GoPrevious( rIdx, nMode ); return false; } @@ -1205,32 +1205,32 @@ bool GoInNode( SwPaM & rPam, SwMoveFnCollection const & fnMove ) bool GoInContent( SwPaM & rPam, SwMoveFnCollection const & fnMove ) { - if( (*fnMove.fnNd)( &rPam.GetPoint()->GetNode(), - &rPam.GetPoint()->nContent, SwCursorSkipMode::Chars )) + if( (*fnMove.fnNd)( rPam.GetPoint()->GetNode(), + rPam.GetPoint()->nContent, SwCursorSkipMode::Chars )) return true; return GoInNode( rPam, fnMove ); } bool GoInContentCells( SwPaM & rPam, SwMoveFnCollection const & fnMove ) { - if( (*fnMove.fnNd)( &rPam.GetPoint()->GetNode(), - &rPam.GetPoint()->nContent, SwCursorSkipMode::Cells )) + if( (*fnMove.fnNd)( rPam.GetPoint()->GetNode(), + rPam.GetPoint()->nContent, SwCursorSkipMode::Cells )) return true; return GoInNode( rPam, fnMove ); } bool GoInContentSkipHidden( SwPaM & rPam, SwMoveFnCollection const & fnMove ) { - if( (*fnMove.fnNd)( &rPam.GetPoint()->GetNode(), - &rPam.GetPoint()->nContent, SwCursorSkipMode::Chars | SwCursorSkipMode::Hidden ) ) + if( (*fnMove.fnNd)( rPam.GetPoint()->GetNode(), + rPam.GetPoint()->nContent, SwCursorSkipMode::Chars | SwCursorSkipMode::Hidden ) ) return true; return GoInNode( rPam, fnMove ); } bool GoInContentCellsSkipHidden( SwPaM & rPam, SwMoveFnCollection const & fnMove ) { - if( (*fnMove.fnNd)( &rPam.GetPoint()->GetNode(), - &rPam.GetPoint()->nContent, SwCursorSkipMode::Cells | SwCursorSkipMode::Hidden ) ) + if( (*fnMove.fnNd)( rPam.GetPoint()->GetNode(), + rPam.GetPoint()->nContent, SwCursorSkipMode::Cells | SwCursorSkipMode::Hidden ) ) return true; return GoInNode( rPam, fnMove ); } diff --git a/sw/source/core/doc/docruby.cxx b/sw/source/core/doc/docruby.cxx index 6eb4b4ad1422..e6f32a4e24e3 100644 --- a/sw/source/core/doc/docruby.cxx +++ b/sw/source/core/doc/docruby.cxx @@ -368,7 +368,7 @@ bool SwDoc::SelectNextRubyChars( SwPaM& rPam, SwRubyListEntry& rEntry ) nWordEnd = nEnd; } } - pTNd->GoNext( pPos, SwCursorSkipMode::Chars ); + pTNd->GoNext( *pPos, SwCursorSkipMode::Chars ); nStart = pPos->GetContentIndex(); } diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index 4926f33fb4e3..c3e9688762e8 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1282,26 +1282,26 @@ SwFormatColl *SwContentNode::ChgFormatColl( SwFormatColl *pNewColl ) return pOldColl; } -bool SwContentNode::GoNext(SwPosition* pPos, SwCursorSkipMode nMode ) const +bool SwContentNode::GoNext(SwPosition& rPos, SwCursorSkipMode nMode ) const { - if (!GoNext(&pPos->nContent, nMode)) + if (!GoNext(rPos.nContent, nMode)) return false; - if (pPos->nContent.GetContentNode() != &pPos->GetNode()) - pPos->nNode.Assign(*pPos->nContent.GetContentNode()); + if (rPos.nContent.GetContentNode() != &rPos.GetNode()) + rPos.nNode.Assign(*rPos.nContent.GetContentNode()); return true; } -bool SwContentNode::GoNext(SwContentIndex * pIdx, SwCursorSkipMode nMode ) const +bool SwContentNode::GoNext(SwContentIndex& rIdx, SwCursorSkipMode nMode ) const { bool bRet = true; - if( pIdx->GetIndex() < Len() ) + if( rIdx.GetIndex() < Len() ) { if( !IsTextNode() ) - ++(*pIdx); + ++rIdx; else { const SwTextNode& rTNd = *GetTextNode(); - sal_Int32 nPos = pIdx->GetIndex(); + sal_Int32 nPos = rIdx.GetIndex(); assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is()); sal_Int32 nDone = 0; sal_uInt16 nItrMode = ( SwCursorSkipMode::Cells & nMode ) ? @@ -1322,7 +1322,7 @@ bool SwContentNode::GoNext(SwContentIndex * pIdx, SwCursorSkipMode nMode ) const } if( 1 == nDone ) - *pIdx = nPos; + rIdx = nPos; else bRet = false; } @@ -1332,17 +1332,17 @@ bool SwContentNode::GoNext(SwContentIndex * pIdx, SwCursorSkipMode nMode ) const return bRet; } -bool SwContentNode::GoPrevious(SwContentIndex * pIdx, SwCursorSkipMode nMode ) const +bool SwContentNode::GoPrevious(SwContentIndex& rIdx, SwCursorSkipMode nMode ) const { bool bRet = true; - if( pIdx->GetIndex() > 0 ) + if( rIdx.GetIndex() > 0 ) { if( !IsTextNode() ) - --(*pIdx); + --rIdx; else { const SwTextNode& rTNd = *GetTextNode(); - sal_Int32 nPos = pIdx->GetIndex(); + sal_Int32 nPos = rIdx.GetIndex(); assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is()); sal_Int32 nDone = 0; sal_uInt16 nItrMode = ( SwCursorSkipMode::Cells & nMode ) ? @@ -1363,7 +1363,7 @@ bool SwContentNode::GoPrevious(SwContentIndex * pIdx, SwCursorSkipMode nMode ) c } if( 1 == nDone ) - *pIdx = nPos; + rIdx = nPos; else bRet = false; } diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx index 1dfc2877628f..624a2e663ddb 100644 --- a/sw/source/core/edit/edattr.cxx +++ b/sw/source/core/edit/edattr.cxx @@ -678,7 +678,7 @@ SvtScriptType SwEditShell::GetScriptType() const if( nPos ) { SwContentIndex aIdx( pStart->GetContentNode(), pStart->GetContentIndex() ); - if( pTNd->GoPrevious( &aIdx, SwCursorSkipMode::Chars ) ) + if( pTNd->GoPrevious( aIdx, SwCursorSkipMode::Chars ) ) nPos = aIdx.GetIndex(); } diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx index d8c1110dea8c..30e53f1d2848 100644 --- a/sw/source/core/inc/pamtyp.hxx +++ b/sw/source/core/inc/pamtyp.hxx @@ -54,15 +54,15 @@ void GoEndOfSection( SwPosition*); const SwTextAttr* GetFrwrdTextHint( const SwpHints&, size_t&, sal_Int32 ); const SwTextAttr* GetBkwrdTextHint( const SwpHints&, size_t&, sal_Int32 ); -bool GoNext(SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ); -bool GoPrevious(SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ); +bool GoNext(SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ); +bool GoPrevious(SwNode& rNd, SwContentIndex& rIdx, SwCursorSkipMode nMode ); SwContentNode* GoNextNds( SwNodeIndex * pIdx, bool ); SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool ); SwContentNode* GoNextPos( SwPosition * pIdx, bool ); SwContentNode* GoPreviousPos( SwPosition * pIdx, bool ); // type definitions of functions -typedef bool (*GoNd)( SwNode*, SwContentIndex*, SwCursorSkipMode ); +typedef bool (*GoNd)( SwNode&, SwContentIndex&, SwCursorSkipMode ); typedef SwContentNode* (*GoNds)( SwNodeIndex*, bool ); typedef SwContentNode* (*GoPos)( SwPosition*, bool ); typedef void (*GoDoc)( SwPosition* );