sw/source/core/doc/docedt.cxx |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit b484e5d9e0d22b794c2d1c73741191836158a4ad
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Sat Oct 8 07:54:48 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Sun Oct 9 19:16:29 2022 +0200

    use more SwPosition::Assign
    
    part of the process of hiding the internals of SwPosition
    
    Change-Id: I20842b90d0abb4435d6b06970c2545229268e5e8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141097
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index eb9b5a85a2b0..d2bb92dd4058 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -520,7 +520,8 @@ uno::Any SwDoc::Spell( SwPaM& rPaM,
                     SwRootFrame const*const pLayout,
                     SwConversionArgs *pConvArgs  ) const
 {
-    SwPosition* pSttPos = rPaM.Start(), *pEndPos = rPaM.End();
+    SwPosition* const pSttPos = rPaM.Start();
+    SwPosition* const pEndPos = rPaM.End();
 
     std::unique_ptr<SwSpellArgs> pSpellArgs;
     if (pConvArgs)
@@ -600,13 +601,16 @@ uno::Any SwDoc::Spell( SwPaM& rPaM,
                             ( pConvArgs && pNd->GetTextNode()->Convert( 
*pConvArgs )))
                         {
                             // Cancel and remember position
-                            pSttPos->nNode = nCurrNd;
-                            pEndPos->nNode = nCurrNd;
-                            nCurrNd = nEndNd;
                             if( pSpellArgs )
                                 nSpellErrorPosition = 
pSpellArgs->pStartPos->GetContentIndex() > 
pSpellArgs->pEndPos->GetContentIndex() ?
                                             
pSpellArgs->pEndPos->GetContentIndex() :
                                             
pSpellArgs->pStartPos->GetContentIndex();
+                            if( nCurrNd != nEndNd )
+                            {
+                                pSttPos->Assign(nCurrNd);
+                                pEndPos->Assign(nCurrNd);
+                                nCurrNd = nEndNd;
+                            }
                         }
 
                         if( pSpellArgs && pSpellArgs->bIsGrammarCheck )
@@ -649,8 +653,8 @@ uno::Any SwDoc::Spell( SwPaM& rPaM,
                                     //put the cursor to the current error
                                     const linguistic2::SingleProofreadingError 
&rError = aResult.aErrors[0];
                                     nCurrNd = pNd->GetIndex();
-                                    pSttPos->nNode = nCurrNd;
-                                    pEndPos->nNode = nCurrNd;
+                                    pSttPos->Assign(nCurrNd);
+                                    pEndPos->Assign(nCurrNd);
                                     
pSpellArgs->pStartPos->Assign(*pNd->GetTextNode(), 
aConversionMap.ConvertToModelPosition( rError.nErrorStart ).mnPos );
                                     
pSpellArgs->pEndPos->Assign(*pNd->GetTextNode(), 
aConversionMap.ConvertToModelPosition( rError.nErrorStart + rError.nErrorLength 
).mnPos );
                                     nCurrNd = nEndNd;

Reply via email to