From 5e8aa259e48d5602b932353bb146ebb523982cf2 Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 24 Jan 2022 17:37:09 +0100 Subject: tdf#146967 sw table: fix freezing in Hide Changes mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During change tracking, drag & drop or Cut & Paste a table row resulted freezing in Hide Changes mode. Test: In Hide Changes mode, select a table row by clicking on their left border, and drag & drop or Cut & Paste it in a different table row. Regression from commit 5a1c19624eda0c8b847af0dcee70b82502578ceb. Follow-up to commit 5a1c19624eda0c8b847af0dcee70b82502578ceb tdf#146965 sw track changes: fix tracked table row moving Change-Id: Iab606ce036fedcc70e42638e3ccf804c9dbca064 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128875 Tested-by: László Németh Reviewed-by: László Németh --- sw/qa/extras/uiwriter/uiwriter2.cxx | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'sw/qa') diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 157891b1b363..a1fc810fafec 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -5110,6 +5110,52 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testPasteTrackedTableRow) CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRows()->getCount()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testPasteTrackedTableRowInHideChangesMode) +{ + // load a 1-row table + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf118311.fodt"); + + // turn on red-lining and show changes + pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT_MESSAGE("redlines should be invisible", + !IDocumentRedlineAccess::IsShowChanges( + pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + + // check table count + uno::Reference xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xTables(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + + // check table row count + uno::Reference 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", {}); + + // This resulted freezing + 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()); + + dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); + dispatchCommand(mxComponent, ".uno:Undo", {}); // FIXME Why 3 Undos? + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTable->getRows()->getCount()); + + dispatchCommand(mxComponent, ".uno:Redo", {}); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTable->getRows()->getCount()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf145091) { // load a deleted table, reject them, and delete only its text and export to DOCX -- cgit