sw/qa/extras/uiwriter/uiwriter3.cxx |    8 ++++++++
 sw/source/core/frmedt/tblsel.cxx    |   11 ++++++++++-
 sw/source/core/undo/untbl.cxx       |   11 +++++++++++
 3 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit 0c6221e1545e7b96d9df23cdc24302c28ae935b8
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Fri Mar 25 15:27:21 2022 +0100
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Mon Mar 28 09:41:34 2022 +0200

    tdf#148227 sw: fix Undo of tracked row deletion in Hide Changes mode
    
    In Hide Changes mode, table rows didn't reappear during
    Undo of tracked deletion of table rows, only by saving
    and reloading the document.
    
    Follow-up to commit a74c51025fa4519caaf461492e4ed8e68bd34885
    "tdf#146962 sw: hide deleted row at deletion in Hide Changes"
    and commit 794fd10af7361d5a64a0f8bfbe5c8b5f308617a5
    "tdf#147347 sw: hide deleted table at deletion in Hide Changes".
    
    Change-Id: I7ffe8a3687d1d385a549f7d438f7058d829ffd8c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132123
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 6e86ef526f5d..1559aab9887e 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2353,6 +2353,14 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146962)
     pXmlDoc = parseLayoutDump();
     // only a single row is visible again
     assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1);
+
+    // check Undo
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+    // This was 1
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
 }
 
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147347)
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index 984b59186109..45fc820b2e1f 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -2333,6 +2333,10 @@ void FndBox_::MakeFrames( SwTable &rTable )
     // And this for all instances of a table (for example in header/footer).
     sal_uInt16 nStPos = 0;
     sal_uInt16 nEndPos= rTable.GetTabLines().size() - 1;
+    SwRootFrame* pLayout =
+        
rTable.GetFrameFormat()->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout();
+    bool bHideChanges = pLayout && pLayout->IsHideRedlines();
+
     if ( m_pLineBefore )
     {
         nStPos = rTable.GetTabLines().GetPos(
@@ -2386,9 +2390,14 @@ void FndBox_::MakeFrames( SwTable &rTable )
 // ???? or is this the last Follow of the table ????
                 pUpperFrame = pTable;
 
+            SwRedlineTable::size_type nRedlinePos = 0;
             for ( sal_uInt16 j = nStPos; j <= nEndPos; ++j )
-                ::lcl_InsertRow( *rTable.GetTabLines()[j],
+            {
+                SwTableLine * pLine = rTable.GetTabLines()[j];
+                if ( !bHideChanges || !pLine->IsDeleted(nRedlinePos) )
+                    ::lcl_InsertRow( *pLine,
                                 static_cast<SwLayoutFrame*>(pUpperFrame), 
pSibling );
+            }
             if ( pUpperFrame->IsTabFrame() )
                 static_cast<SwTabFrame*>(pUpperFrame)->SetCalcLowers();
         }
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 5be409d15078..2af21afa418f 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -35,6 +35,8 @@
 #include <IDocumentRedlineAccess.hxx>
 #include <IDocumentFieldsAccess.hxx>
 #include <IDocumentStylePoolAccess.hxx>
+#include <IDocumentLayoutAccess.hxx>
+#include <rootfrm.hxx>
 #include <editsh.hxx>
 #include <docary.hxx>
 #include <ndtxt.hxx>
@@ -936,6 +938,12 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool 
bMdfyBox )
 {
     m_bModifyBox = bMdfyBox;
 
+    FndBox_ aTmpBox( nullptr, nullptr );
+    bool bHideChanges = 
rTable.GetFrameFormat()->GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines();
+    // TODO delete/make frames only at changing line attribute TextChangesOnly 
(RES_PRINT) to true again
+    if ( bHideChanges )
+        aTmpBox.DelFrames( rTable );
+
     // first, get back attributes of TableFrameFormat
     SwFrameFormat* pFormat = rTable.GetFrameFormat();
     SfxItemSet& rFormatSet  = const_cast<SfxItemSet&>(static_cast<SfxItemSet 
const &>(pFormat->GetAttrSet()));
@@ -976,6 +984,9 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox 
)
 
     m_aFrameFormats.clear();
     m_bModifyBox = false;
+
+    if ( bHideChanges )
+        aTmpBox.MakeFrames( rTable );
 }
 
 void SaveTable::SaveContentAttrs( SwDoc* pDoc )

Reply via email to