sw/qa/extras/uiwriter/uiwriter3.cxx |   10 +++++++++-
 sw/source/core/undo/untbl.cxx       |   20 +++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

New commits:
commit 8baae1fe3de398f1e6a01d1941f78e4088c0a697
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Mar 28 11:35:35 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Mar 28 20:53:15 2022 +0200

    tdf#148228 sw: fix Undo of tracked table deletion in Hide Changes mode
    
    In Hide Changes mode, tables didn't reappear during
    Undo of their tracked deletion, only by saving and
    reloading the document.
    
    Follow-up to commit 0c6221e1545e7b96d9df23cdc24302c28ae935b8
    "tdf#148227 sw: fix Undo of tracked row deletion in Hide Changes mode".
    
    Change-Id: Ifdc25ab4ae0be25a0c7559ee05b6af2e4f1aa8cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132169
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit eda1a7aeff42c08e02295e5a8353a6d86a61a118)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132178
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 57f5e6649b70..559d47641a99 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1988,7 +1988,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146962)
     // only a single row is visible again
     assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1);
 
-    // check Undo
+    // tdf#148227 check Undo of tracked table row deletion
 
     dispatchCommand(mxComponent, ".uno:Undo", {});
     discardDumpedLayout();
@@ -2040,6 +2040,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147347)
     pXmlDoc = parseLayoutDump();
     // no visible row again
     assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 0);
+
+    // tdf#148228 check Undo of tracked table deletion
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+    // This was 0
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014)
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index d5536b01e624..d5c15a0fbc4a 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -952,14 +952,20 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool 
bMdfyBox )
 
     pFormat->InvalidateInSwCache(RES_ATTRSET_CHG);
 
+    // table without table frame
+    bool bHiddenTable = true;
+
     // for safety, invalidate all TableFrames
     SwIterator<SwTabFrame,SwFormat> aIter( *pFormat );
     for( SwTabFrame* pLast = aIter.First(); pLast; pLast = aIter.Next() )
+    {
         if( pLast->GetTable() == &rTable )
         {
             pLast->InvalidateAll();
             pLast->SetCompletePaint();
+            bHiddenTable = false;
         }
+    }
 
     // fill FrameFormats with defaults (0)
     pFormat = nullptr;
@@ -986,7 +992,19 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool 
bMdfyBox )
     m_bModifyBox = false;
 
     if ( bHideChanges )
-        aTmpBox.MakeFrames( rTable );
+    {
+        if ( bHiddenTable )
+        {
+            SwTableNode* pTableNode = rTable.GetTableNode();
+            pTableNode->DelFrames();
+            SwNodeIndex aTableIdx( *pTableNode->EndOfSectionNode(), 1 );
+            pTableNode->MakeOwnFrames(&aTableIdx);
+        }
+        else
+        {
+            aTmpBox.MakeFrames( rTable );
+        }
+    }
 }
 
 void SaveTable::SaveContentAttrs( SwDoc* pDoc )

Reply via email to