sw/source/filter/html/swhtml.cxx |    6 ++++--
 sw/source/filter/xml/xmlimp.cxx  |   15 ++++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 7aa0d01818e6934d1bbb361b750a91204251b465
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Oct 11 18:53:16 2022 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Oct 12 12:39:15 2022 +0200

    rearrange node logic here
    
    so we don't have to touch SwPosition.nContent.
    
    Part of the process of hiding the internals of SwPosition
    
    Change-Id: I797eec2b4ccb01360602f2f19ae4a7a51fe712fd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141235
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 364fa0a096c1..438f19829935 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -842,9 +842,11 @@ void SwHTMLParser::Continue( HtmlTokenId nToken )
                 }
                 else if (pCurrentNd->GetText().isEmpty())
                 {
-                    pPos->nContent.Assign( nullptr, 0 );
                     m_pPam->SetMark(); m_pPam->DeleteMark();
-                    m_xDoc->GetNodes().Delete( pPos->GetNode() );
+                    SwNode& rDelNode = pPos->GetNode();
+                    // move so we don't have a dangling SwContentIndex to the 
deleted node
+                    m_pPam->GetPoint()->Adjust(SwNodeOffset(+1));
+                    m_xDoc->GetNodes().Delete( rDelNode );
                     m_pPam->Move( fnMoveBackward );
                 }
             }
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index f2bd52292b01..62263ce2737f 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -731,9 +731,12 @@ void SwXMLImport::endDocument()
                     if( pCNd && pCNd->StartOfSectionIndex()+2 <
                         pCNd->EndOfSectionIndex() )
                     {
-                        pPaM->GetBound().nContent.Assign( nullptr, 0 );
-                        pPaM->GetBound(false).nContent.Assign( nullptr, 0 );
-                        pDoc->GetNodes().Delete( pPaM->GetPoint()->GetNode() );
+                        SwNode& rDelNode = pPaM->GetPoint()->GetNode();
+                        // move so we don't have a dangling SwContentIndex to 
the deleted node
+                        pPaM->GetPoint()->Adjust(SwNodeOffset(+1));
+                        if (pPaM->HasMark())
+                            pPaM->GetMark()->Adjust(SwNodeOffset(+1));
+                        pDoc->GetNodes().Delete( rDelNode );
                     }
                 }
             }
@@ -768,9 +771,11 @@ void SwXMLImport::endDocument()
                 }
                 else if (pCurrNd->GetText().isEmpty())
                 {
-                    pPos->nContent.Assign( nullptr, 0 );
                     pPaM->SetMark(); pPaM->DeleteMark();
-                    pDoc->GetNodes().Delete( pPos->GetNode() );
+                    SwNode& rDelNode = pPos->GetNode();
+                    // move so we don't have a dangling SwContentIndex to the 
deleted node
+                    pPaM->GetPoint()->Adjust(SwNodeOffset(+1));
+                    pDoc->GetNodes().Delete( rDelNode );
                     pPaM->Move( fnMoveBackward );
                 }
             }

Reply via email to