diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-22 11:20:03 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-22 15:17:51 +0200 |
commit | d6a1408ca7ac16994467d1ec6ea9a3d86abae854 (patch) | |
tree | ba77278038b15c9b8b5ac272306faa41c9c06cd6 /sw | |
parent | 590796ca0866168e3129d2abd0a0197114cddcdc (diff) |
add a function to SwMoveFnCollection to move a SwPosition
part of the process of hiding the internals of SwPosition
Change-Id: I9cba241062f0539dd55fe3c943504bc0db16837b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140405
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/crsr/findattr.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/crsr/findfmt.cxx | 4 | ||||
-rw-r--r-- | sw/source/core/crsr/pam.cxx | 34 | ||||
-rw-r--r-- | sw/source/core/crsr/paminit.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/inc/pamtyp.hxx | 4 |
5 files changed, 44 insertions, 8 deletions
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx index fbbea5cb7846..20d52b2a95c7 100644 --- a/sw/source/core/crsr/findattr.cxx +++ b/sw/source/core/crsr/findattr.cxx @@ -931,12 +931,12 @@ bool FindAttrImpl(SwPaM & rSearchPam, ? oPam->GetPoint()->GetContentIndex() == oPam->GetPointContentNode()->Len() : !oPam->GetPoint()->GetContentIndex() ) { - if( !(*fnMove.fnNds)( &oPam->GetPoint()->nNode, false )) + if( !(*fnMove.fnPos)( oPam->GetPoint(), false )) { return false; } SwContentNode *pNd = oPam->GetPointContentNode(); - oPam->GetPoint()->nContent.Assign( pNd, bSrchForward ? 0 : pNd->Len() ); + oPam->GetPoint()->SetContent( bSrchForward ? 0 : pNd->Len() ); } while (nullptr != (pNode = ::GetNode(*oPam, bFirst, fnMove, bInReadOnly, pLayout))) @@ -1069,12 +1069,12 @@ static bool FindAttrsImpl(SwPaM & rSearchPam, ? oPam->GetPoint()->GetContentIndex() == oPam->GetPointContentNode()->Len() : !oPam->GetPoint()->GetContentIndex() ) ) { - if( !(*fnMove.fnNds)( &oPam->GetPoint()->nNode, false )) + if( !(*fnMove.fnPos)( oPam->GetPoint(), false )) { return false; } SwContentNode *pNd = oPam->GetPointContentNode(); - oPam->GetPoint()->nContent.Assign( pNd, bSrchForward ? 0 : pNd->Len() ); + oPam->GetPoint()->SetContent( bSrchForward ? 0 : pNd->Len() ); } while (nullptr != (pNode = ::GetNode(*oPam, bFirst, fnMove, bInReadOnly, pLayout))) diff --git a/sw/source/core/crsr/findfmt.cxx b/sw/source/core/crsr/findfmt.cxx index d5b0eb4656b5..aa6d9b48468c 100644 --- a/sw/source/core/crsr/findfmt.cxx +++ b/sw/source/core/crsr/findfmt.cxx @@ -40,12 +40,12 @@ bool FindFormatImpl(SwPaM & rSearchPam, ? oPam->GetPoint()->GetContentIndex() == oPam->GetPointContentNode()->Len() : !oPam->GetPoint()->GetContentIndex() ) { - if( !(*fnMove.fnNds)( &oPam->GetPoint()->nNode, false )) + if( !(*fnMove.fnPos)( oPam->GetPoint(), false )) { return false; } SwContentNode *pNd = oPam->GetPoint()->GetNode().GetContentNode(); - oPam->GetPoint()->nContent.Assign( pNd, bSrchForward ? 0 : pNd->Len() ); + oPam->GetPoint()->SetContent( bSrchForward ? 0 : pNd->Len() ); } bool bFirst = true; diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 2b4e8cc0bf9c..a00ccc8224ef 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -421,6 +421,36 @@ SwContentNode* GoPreviousNds( SwNodeIndex * pIdx, bool bChk ) return pNd; } +SwContentNode* GoNextPos( SwPosition* pIdx, bool bChk ) +{ + SwNodeIndex aIdx( pIdx->GetNode() ); + SwContentNode* pNd = aIdx.GetNodes().GoNext( &aIdx ); + if( pNd ) + { + if( bChk && SwNodeOffset(1) != aIdx.GetIndex() - pIdx->GetNodeIndex() && + !CheckNodesRange( pIdx->GetNode(), aIdx.GetNode(), true ) ) + pNd = nullptr; + else + pIdx->Assign(aIdx); + } + return pNd; +} + +SwContentNode* GoPreviousPos( SwPosition * pIdx, bool bChk ) +{ + SwNodeIndex aIdx( pIdx->GetNode() ); + SwContentNode* pNd = SwNodes::GoPrevious( &aIdx ); + if( pNd ) + { + if( bChk && SwNodeOffset(1) != pIdx->GetNodeIndex() - aIdx.GetIndex() && + !CheckNodesRange( pIdx->GetNode(), aIdx.GetNode(), true ) ) + pNd = nullptr; + else + pIdx->Assign(aIdx); + } + return pNd; +} + SwPaM::SwPaM( const SwPosition& rPos, SwPaM* pRing ) : Ring( pRing ) , m_Bound1( rPos ) @@ -1132,9 +1162,9 @@ bool GoInSection( SwPaM & rPam, SwMoveFnCollection const & fnMove ) bool GoInNode( SwPaM & rPam, SwMoveFnCollection const & fnMove ) { - SwContentNode *pNd = (*fnMove.fnNds)( &rPam.GetPoint()->nNode, true ); + SwContentNode *pNd = (*fnMove.fnPos)( rPam.GetPoint(), true ); if( pNd ) - rPam.GetPoint()->nContent.Assign( pNd, + rPam.GetPoint()->SetContent( ::GetSttOrEnd( &fnMove == &fnMoveForward, *pNd ) ); return pNd; } diff --git a/sw/source/core/crsr/paminit.cxx b/sw/source/core/crsr/paminit.cxx index f8dcb49e7d94..a415aee2c21c 100644 --- a/sw/source/core/crsr/paminit.cxx +++ b/sw/source/core/crsr/paminit.cxx @@ -24,6 +24,7 @@ const SwMoveFnCollection aFwrd = { /* fnNd */ &GoNext, /* fnNds */ &GoNextNds, + /* fnPos */ &GoNextPos, /* fnDoc */ &GoEndDoc, /* fnSections */ &GoEndSection, /* fnCmpOp */ &SwPosition::operator<, @@ -35,6 +36,7 @@ const SwMoveFnCollection aFwrd = { const SwMoveFnCollection aBwrd = { /* fnNd */ &GoPrevious, /* fnNds */ &GoPreviousNds, + /* fnPos */ &GoPreviousPos, /* fnDoc */ &GoStartDoc, /* fnSections */ &GoStartSection, /* fnCmpOp */ &SwPosition::operator>, diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx index fa9d34af3dda..d8c1110dea8c 100644 --- a/sw/source/core/inc/pamtyp.hxx +++ b/sw/source/core/inc/pamtyp.hxx @@ -58,10 +58,13 @@ bool GoNext(SwNode* pNd, SwContentIndex * pIdx, SwCursorSkipMode nMode ); bool GoPrevious(SwNode* pNd, SwContentIndex * pIdx, 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* ); typedef bool (SwPosition::*CmpOp)( const SwPosition& ) const; @@ -74,6 +77,7 @@ struct SwMoveFnCollection { GoNd fnNd; GoNds fnNds; + GoPos fnPos; GoDoc fnDoc; GoSection fnSections; CmpOp fnCmpOp; |