sw/qa/extras/uiwriter/uiwriter3.cxx |   53 ++++++++++++++++++++++++++++++++++++
 sw/source/uibase/app/docsh2.cxx     |   42 ++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

New commits:
commit 4494e24c29d9a673964feb9c637b13122ee17f87
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Mon Apr 4 18:46:17 2022 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Apr 5 15:15:19 2022 +0200

    tdf#148345 sw: reject all tracked row deletion in Hide Changes
    
    In Hide Changes mode, undeleted rows didn't reappear at applying
    Reject All for tracked row deletions.
    
    See also commit a74c51025fa4519caaf461492e4ed8e68bd34885
    "tdf#146962 sw: hide deleted row at deletion in Hide Changes".
    
    Change-Id: I55d76fb0165fefc330934c5a2a6b018904d3a1a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132527
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit d4e2ed9324bd736275f07577ba81c974a0a70eb1)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132391

diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx 
b/sw/qa/extras/uiwriter/uiwriter3.cxx
index 559d47641a99..13d62a49ef58 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -2050,6 +2050,59 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147347)
     assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf148345)
+{
+    // load a 2-row table, set Hide Changes mode and delete the first row with 
change tracking
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf116789.fodt");
+    CPPUNIT_ASSERT(pDoc);
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    CPPUNIT_ASSERT(pWrtShell);
+
+    // enable redlining
+    dispatchCommand(mxComponent, ".uno:TrackChanges", {});
+    CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+                           pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+    // hide changes
+    dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+    CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
+
+    dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+
+    // Without the fix in place, the deleted row would be visible
+
+    xmlDocUniquePtr pXmlDoc = parseLayoutDump();
+    // This was 2
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1);
+
+    // check it in Show Changes mode
+
+    dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+    CPPUNIT_ASSERT(!pWrtShell->GetLayout()->IsHideRedlines());
+
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+    // 2 rows are visible now
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
+
+    // check it in Hide Changes mode again
+
+    dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {});
+    CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines());
+
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+    // only a single row is visible again
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1);
+
+    // tdf#148227 check Reject All of tracked table row deletion
+
+    dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+    discardDumpedLayout();
+    pXmlDoc = parseLayoutDump();
+    // This was 1
+    assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014)
 {
     createSwDoc();
diff --git a/sw/source/uibase/app/docsh2.cxx b/sw/source/uibase/app/docsh2.cxx
index 063b74e7da4a..a18526663555 100644
--- a/sw/source/uibase/app/docsh2.cxx
+++ b/sw/source/uibase/app/docsh2.cxx
@@ -69,6 +69,7 @@
 #include <docsh.hxx>
 #include <docary.hxx>
 #include <wrtsh.hxx>
+#include <rootfrm.hxx>
 #include <fldbas.hxx>
 #include <viewopt.hxx>
 #include <globdoc.hxx>
@@ -1296,6 +1297,39 @@ void SwDocShell::Execute(SfxRequest& rReq)
                 break;
             }
 
+            // tables with tracked deletion need Show Changes
+            bool bHideChanges = pWrtShell && pWrtShell->GetLayout() &&
+                                pWrtShell->GetLayout()->IsHideRedlines();
+            bool bChangedHideChanges = false;
+            if ( bHideChanges )
+            {
+                SwTableNode* pOldTableNd = nullptr;
+                const SwRedlineTable& aRedlineTable = 
rRedlineAccess.GetRedlineTable();
+                for (SwRedlineTable::size_type n = 0; n < 
aRedlineTable.size(); ++n)
+                {
+                    const SwRangeRedline* pRedline = aRedlineTable[n];
+                    if ( pRedline->GetType() == RedlineType::Delete )
+                    {
+                        SwTableNode* pTableNd =
+                            
pRedline->GetPoint()->nNode.GetNode().FindTableNode();
+                        if ( pTableNd && pTableNd !=
+                                pOldTableNd && 
pTableNd->GetTable().HasDeletedRow() )
+                        {
+                            SfxBoolItem aShow(FN_REDLINE_SHOW, true);
+                            SfxViewShell* pViewShell = GetView()
+                                    ? GetView()
+                                    : SfxViewShell::Current();
+                            
pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+                                    FN_REDLINE_SHOW, 
SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
+                                    { &aShow });
+                            bChangedHideChanges = true;
+                            break;
+                        }
+                        pOldTableNd = pTableNd;
+                    }
+                }
+            }
+
             if (pWrtShell)
             {
                 pWrtShell->StartAllAction();
@@ -1308,6 +1342,14 @@ void SwDocShell::Execute(SfxRequest& rReq)
                 pWrtShell->EndAllAction();
             }
 
+            if ( bChangedHideChanges )
+            {
+                SfxBoolItem aShow(FN_REDLINE_SHOW, false);
+                SfxViewShell* pViewShell = GetView()? GetView(): 
SfxViewShell::Current();
+                pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(
+                        FN_REDLINE_SHOW, 
SfxCallMode::SYNCHRON|SfxCallMode::RECORD, { &aShow });
+            }
+
             Broadcast(SfxHint(SfxHintId::RedlineChanged));
             rReq.Done();
         }

Reply via email to