summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-01-26 13:44:39 +0100
committerLászló Németh <nemeth@numbertext.org>2022-01-27 08:15:41 +0100
commit29233e10f00af0af132849485648664aadefd456 (patch)
tree3b5ca46a7fb8e9ad753f0ecc40b2832a1b8ddd25 /sw/qa/extras/uiwriter
parent6dcda6ac592f062a68c029bfe26a47ad7160c930 (diff)
tdf#146966 sw: fix inserting empty rows at copying multiple rows
HTML expansion of the clipboard content is used to calculate the row number of the table on the clipboard. Skip its empty <tr></tr> elements here, similar to Paste As HTML in Edit->Paste Special-> Paste Special... to avoid inserting empty rows (e.g. selecting and copying/moving 4 rows inserted 30 extra empty rows). Note: likely this was a regression, related to the new empty rows in the clipboard/expansion code. Change-Id: I58b16c7869c08cda7e2a2c21c3c03bf38446d826 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128986 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org> (cherry picked from commit 6ad9a3d74ef6eae3e645df12dedbe059acc180c4) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128959
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter2.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index fea93243bdc8..79aa517c66f4 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -5156,6 +5156,42 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testPasteTrackedTableRowInHideChangesMode)
CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount());
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf146966)
+{
+ // load a 4-row table, select more than 1 row and copy them
+ // to check insertion of unnecessary empty rows
+ SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf144748.fodt");
+
+ // check table row 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());
+ uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getRows()->getCount());
+
+ // copy table row and paste it by Paste Special->Rows Above
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Down(/*bSelect=*/false);
+ dispatchCommand(mxComponent, ".uno:SelectTable", {});
+ dispatchCommand(mxComponent, ".uno:Copy", {});
+ dispatchCommand(mxComponent, ".uno:Escape", {});
+ dispatchCommand(mxComponent, ".uno:PasteRowsBefore", {});
+
+ // This was 35 (extra empty rows)
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xTable->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {});
+ dispatchCommand(mxComponent, ".uno:Undo", {}); // FIXME Why 3 Undos?
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xTable->getRows()->getCount());
+
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ dispatchCommand(mxComponent, ".uno:Redo", {});
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xTable->getRows()->getCount());
+ // dispatchCommand(mxComponent, ".uno:Redo", {}); // FIXME assert
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf145091)
{
// load a deleted table, reject them, and delete only its text and export to DOCX