sw/source/core/undo/untbl.cxx |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

New commits:
commit 3d8697dab9a4a29666440a30c5c7a6d9d9f76d76
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Fri Aug 4 13:06:51 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri Aug 4 18:14:02 2023 +0200

    tdf#147938 sw: Undo of table to text uses ContentIdxStore wrong
    
    ContentIdxStore must be created for every SplitContentNode() with its
    content index and used there; SwNodes::UndoTableToText() creates it once
    per text node which is rather unhelpful and in this case results in a
    redline with incorrect range, starting in one table cell and ending in
    another.
    
    This problem exists since initial CVS import.
    
    Change-Id: I8a20b13b42384658bf869c5202ccbad2213c12f7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155344
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 8c351559db69..d6e58e633844 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -561,7 +561,6 @@ SwTableNode* SwNodes::UndoTableToText( SwNodeOffset nSttNd, 
SwNodeOffset nEndNd,
     SwTableLine* pLine = new SwTableLine( pLineFormat, rSavedData.size(), 
nullptr );
     pTableNd->GetTable().GetTabLines().insert( 
pTableNd->GetTable().GetTabLines().begin(), pLine );
 
-    const std::shared_ptr<sw::mark::ContentIdxStore> 
pContentStore(sw::mark::ContentIdxStore::Create());
     for( size_t n = rSavedData.size(); n; )
     {
         const SwTableToTextSave *const pSave = rSavedData[ --n ].get();
@@ -576,6 +575,9 @@ SwTableNode* SwNodes::UndoTableToText( SwNodeOffset nSttNd, 
SwNodeOffset nEndNd,
             OSL_ENSURE( pTextNd, "Where is my TextNode?" );
             SwContentIndex aCntPos( pTextNd, pSave->m_nContent - 1 );
 
+            const std::shared_ptr<sw::mark::ContentIdxStore> 
pContentStore(sw::mark::ContentIdxStore::Create());
+            pContentStore->Save(GetDoc(), aSttIdx.GetIndex(), 
aCntPos.GetIndex());
+
             pTextNd->EraseText( aCntPos, 1 );
 
             std::function<void (SwTextNode *, sw::mark::RestoreMode, bool)> 
restoreFunc(
@@ -589,14 +591,6 @@ SwTableNode* SwNodes::UndoTableToText( SwNodeOffset 
nSttNd, SwNodeOffset nEndNd,
             pTextNd->SplitContentNode(
                         SwPosition(aSttIdx, aCntPos), &restoreFunc);
         }
-        else
-        {
-            pContentStore->Clear();
-            if( pTextNd )
-            {
-                pContentStore->Save(GetDoc(), aSttIdx.GetIndex(), 
SAL_MAX_INT32);
-            }
-        }
 
         if( pTextNd )
         {

Reply via email to