summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-01-21 11:13:27 +0100
committerLászló Németh <nemeth@numbertext.org>2022-01-25 09:51:11 +0100
commit5a1c19624eda0c8b847af0dcee70b82502578ceb (patch)
tree54c062c982b950308c25dc047a1016ac29fedd66 /sw/qa
parentcd7abd3e2c6bb28ecfeb1acef675280cfe438e3e (diff)
tdf#146965 sw track changes: fix tracked table row moving
During track changes, drag & drop or Cut & Paste a table row resulted a nested table in the first cell of the newly inserted empty table row instead of moving the original table row. Test: select a table row by clicking on their left border, and drag & drop or Cut & Paste it in a different table row. Note: This fixes crashing at Redo of tracked table row insertion, too. Regression from commit dbc82c02eb24ec1c97c6ee32069771d8deb394f9 "tdf#143358 sw: track insertion of empty table rows". Change-Id: I9a31cae2c0e6e5e05450336a1e5b8d792035df35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128726 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx47
1 files changed, 47 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 3463f850d3dd..157891b1b363 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -5063,6 +5063,53 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf145089_RedlineTableRowInsertionDOCX
assertXPath(pXmlDoc, "//page[1]//body/tab/row", 1);
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testPasteTrackedTableRow)
+{
+ // load a 1-row table
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf118311.fodt");
+
+ // turn on red-lining and show changes
+ pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+ | RedlineFlags::ShowInsert);
+ CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+ pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+ CPPUNIT_ASSERT_MESSAGE(
+ "redlines should be visible",
+ IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+ // check table count
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+ // check table row count
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRows()->getCount());
+
+ // copy table row and paste it by Paste Special->Rows Above
+ dispatchCommand(mxComponent, ".uno:SelectTable", {});
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+ dispatchCommand(mxComponent, ".uno:Escape", {});
+ dispatchCommand(mxComponent, ".uno:PasteRowsBefore", {});
+
+ // 2-row table
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount());
+
+ // This was 2 (inserted as a nested table in the first cell of the new row)
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
+
+ // Is it a tracked row insertion? Its rejection results the original 1-row table
+ dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRows()->getCount());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf145091)
{
// load a deleted table, reject them, and delete only its text and export to DOCX