summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
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 16:13:34 +0100
commit8aab37daf004ed31c67f21a352fba95ab1229086 (patch)
tree693db593e7548b786a34de536048d341b50239c4 /sw/qa/extras/uiwriter
parent5225a8d7febfc51982242511d557c59478bebb67 (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> Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128921
Diffstat (limited to 'sw/qa/extras/uiwriter')
-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 abb6d02556f8..c0c5c9f103e7 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