From d4e2ed9324bd736275f07577ba81c974a0a70eb1 Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 4 Apr 2022 18:46:17 +0200 Subject: tdf#148345 sw: reject all tracked row deletion in Hide Changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- sw/qa/extras/uiwriter/uiwriter3.cxx | 53 +++++++++++++++++++++++++++++++++++++ sw/source/uibase/app/docsh2.cxx | 42 +++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index 839106e5d41c..654e08ace527 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -2416,6 +2416,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 a443e1574c78..92514a5e1486 100644 --- a/sw/source/uibase/app/docsh2.cxx +++ b/sw/source/uibase/app/docsh2.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -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(); } -- cgit