summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-02-14 19:13:37 +0100
committerAndras Timar <andras.timar@collabora.com>2022-02-18 12:35:43 +0100
commit58555b46fa5017099242d3c519e91ca2680429b3 (patch)
tree50f647191e603c17ac9e2bb9043a24e1438d0753 /sw/qa/extras/uiwriter
parentf60fe1c587f38e5a7ad5748466df09643bc23f31 (diff)
tdf#146622 sw crash fix: don't delete already deleted rows
Delete tables and rows removed also tables and table rows with tracked row deletion/insertion. This resulted not only lost change tracking, but a crashing Undo. Crash regression from commit 99059a1ececa3621c2fe46fabdd79eed9d626c42 "tdf#143359 sw: track deletion of empty table rows". Non-tracked deletion of the tracked row changes was a temporary solution for the missing UI of tracked row changes, implemented in commit 05366b8e6683363688de8708a3d88cf144c7a2bf "tdf#60382 sw offapi: add change tracking of table/row deletion". Note: UI was added in commit f348440e17debacbcba9153e238e010e8c020bdc "tdf#146120 sw: show tracked table changes with different color", commit 95c003d75e0f8b255344715a35358072b5eba99d "tdf#146145 sw: 1-click Accept/Reject of table row changes", commit 84fbb3398f7486f00e7b7dea415e1ea2510a9535 "tdf#146144 sw: add tooltip to table rows with change tracking", commit eebe4747d2d13545004937bb0267ccfc8ab9d63f "tdf#144270 sw: manage tracked table (row) deletion/insertion", commit f481c2c8e74bded11fac754e493560391229dbcd "tdf#144057 sw track changes: hide deleted table rows" and commit 23846867ea32667ccf328c36142394dd6aaee8ba "tdf#147182 sw: accept/reject all changes of a table selection". (cherry-picked from commit 95213407dfcbf34056037d60243ff915340d1a2e) Change-Id: I384b750b0d3626fa8b3f256c7eaf5b93f382e4e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130011 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter3.cxx53
1 files changed, 53 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx
index cf8c4e07e9b6..d2123c33b20c 100644
--- a/sw/qa/extras/uiwriter/uiwriter3.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter3.cxx
@@ -1890,6 +1890,59 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf132744)
CPPUNIT_ASSERT_EQUAL(1, getShapes());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146622)
+{
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "TC-table-del-add.docx");
+ CPPUNIT_ASSERT(pDoc);
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ CPPUNIT_ASSERT(pWrtShell);
+
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+
+ uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTables->getCount());
+ uno::Reference<container::XNameAccess> xTableNames = xTablesSupplier->getTextTables();
+ CPPUNIT_ASSERT(xTableNames->hasByName("Table1"));
+ uno::Reference<text::XTextTable> xTable1(xTableNames->getByName("Table1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+
+ // This was 3 (deleting the already deleted row with change tracking)
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ Scheduler::ProcessEventsToIdle();
+
+ dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ dispatchCommand(mxComponent, ".uno:SelectAll", {});
+ Scheduler::ProcessEventsToIdle();
+
+ dispatchCommand(mxComponent, ".uno:DeleteRows", {});
+ // This was 2 (deleting the already deleted table with change tracking)
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTables->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable1->getRows()->getCount());
+
+ // check that the first table was deleted with change tracking
+ dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+ // Undo AcceptAllTrackedChanges and DeleteRows
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+
+ // now only the second table deleted by AcceptAllTrackedChanges
+ dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014)
{
createSwDoc();