sw/source/core/crsr/pam.cxx     |   16 +++++++++++++++-
 sw/source/core/crsr/paminit.cxx |    4 ++--
 sw/source/core/inc/pamtyp.hxx   |    4 +++-
 3 files changed, 20 insertions(+), 4 deletions(-)

New commits:
commit 20a5e0feaf22804de8c55d1471fd076e40cd2ce6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Aug 4 13:04:33 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Aug 4 19:36:59 2022 +0200

    MvSection functions should maintain the SwPosition::nContent field
    
    i.e. when it moves the SwPosition::nIndex, it should move the
    SwPosition::nContent too.
    
    Change-Id: I96bee46766ebb303f97790aeb09024380b1cdc35
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137801
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index bf90bc847719..d2bec56c9f98 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -1051,6 +1051,13 @@ void GoStartSection( SwPosition * pPos )
     pPos->AssignStartIndex(*pPos->GetNode().GetContentNode());
 }
 
+void GoStartOfSection( SwPosition * pPos )
+{
+    // jump to section's beginning
+    SwNodes::GoStartOfSection( &pPos->nNode );
+    pPos->nContent.Assign(pPos->GetNode().GetContentNode(), 0);
+}
+
 /// go to the end of the current base section
 void GoEndSection( SwPosition * pPos )
 {
@@ -1066,6 +1073,13 @@ void GoEndSection( SwPosition * pPos )
         pPos->AssignEndIndex(*pCNd);
 }
 
+void GoEndOfSection( SwPosition * pPos )
+{
+    SwNodes::GoEndOfSection( &pPos->nNode );
+    SwContentNode* pCNd = pPos->nNode.GetNode().GetContentNode();
+    pPos->nContent.Assign(pCNd, pCNd ? pCNd->Len() : 0);
+}
+
 bool GoInDoc( SwPaM & rPam, SwMoveFnCollection const & fnMove )
 {
     (*fnMove.fnDoc)( rPam.GetPoint() );
@@ -1179,7 +1193,7 @@ bool GoCurrSection( SwPaM & rPam, SwMoveFnCollection 
const & fnMove )
 {
     SwPosition& rPos = *rPam.GetPoint();
     SwPosition aSavePos( rPos ); // position for comparison
-    (fnMove.fnSection)( &rPos.nNode );
+    (fnMove.fnSection)( &rPos );
     SwContentNode *pNd;
     if( nullptr == ( pNd = rPos.GetNode().GetContentNode()) &&
         nullptr == ( pNd = (*fnMove.fnNds)( &rPos.nNode, true )) )
diff --git a/sw/source/core/crsr/paminit.cxx b/sw/source/core/crsr/paminit.cxx
index 367be6e02e37..f8dcb49e7d94 100644
--- a/sw/source/core/crsr/paminit.cxx
+++ b/sw/source/core/crsr/paminit.cxx
@@ -29,7 +29,7 @@ const SwMoveFnCollection aFwrd = {
     /* fnCmpOp      */  &SwPosition::operator<,
     /* fnGetHint    */  &GetFrwrdTextHint,
     /* fnSearch     */  &utl::TextSearch::SearchForward,
-    /* fnSection    */  &SwNodes::GoStartOfSection
+    /* fnSection    */  &GoStartOfSection
 };
 
 const SwMoveFnCollection aBwrd = {
@@ -40,7 +40,7 @@ const SwMoveFnCollection aBwrd = {
     /* fnCmpOp      */  &SwPosition::operator>,
     /* fnGetHint    */  &GetBkwrdTextHint,
     /* fnSearch     */  &utl::TextSearch::SearchBackward,
-    /* fnSection    */  &SwNodes::GoEndOfSection
+    /* fnSection    */  &GoEndOfSection
 };
 
 SwMoveFnCollection const & fnParaStart   = aFwrd;
diff --git a/sw/source/core/inc/pamtyp.hxx b/sw/source/core/inc/pamtyp.hxx
index e8ba4c3cda26..837f553f1cfb 100644
--- a/sw/source/core/inc/pamtyp.hxx
+++ b/sw/source/core/inc/pamtyp.hxx
@@ -48,6 +48,8 @@ void GoStartDoc( SwPosition*);
 void GoEndDoc( SwPosition*);
 void GoStartSection( SwPosition*);
 void GoEndSection( SwPosition*);
+void GoStartOfSection( SwPosition*);
+void GoEndOfSection( SwPosition*);
 const SwTextAttr* GetFrwrdTextHint( const SwpHints&, size_t&, sal_Int32 );
 const SwTextAttr* GetBkwrdTextHint( const SwpHints&, size_t&, sal_Int32 );
 
@@ -65,7 +67,7 @@ typedef bool (SwPosition::*CmpOp)( const SwPosition& ) const;
 typedef const SwTextAttr* (*GetHint)( const SwpHints&, size_t&, sal_Int32 );
 typedef bool (utl::TextSearch::*SearchText)( const OUString&, sal_Int32*,
                     sal_Int32*, css::util::SearchResult* );
-typedef void (*MvSection)( SwNodeIndex * );
+typedef void (*MvSection)( SwPosition * );
 
 struct SwMoveFnCollection
 {

Reply via email to