sw/qa/extras/uiwriter/uiwriter5.cxx | 49 ++++++++++++++++++++++++++ sw/source/core/doc/DocumentRedlineManager.cxx | 3 - 2 files changed, 50 insertions(+), 2 deletions(-)
New commits: commit 6725d03d9a4f0562922e91c88d4494f5b74be063 Author: László Németh <nem...@numbertext.org> AuthorDate: Wed Jul 26 11:00:38 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Wed Aug 2 10:50:27 2023 +0200 tdf#156474 sw tracked table column: fix accept of insertion Accepting tracked table column insertion didn't reset HasTextChangesOnly bit of the table cells, resulting blue/pink cells (i.e. column change) after modifying only text content of the text, and later bad column deletion at accepting text-only deletion and at rejecting text-only insertion. Follow-up to commit 472abf99a4d90d7a53316394a2e51a26b7e62345 "tdf#155341 sw tracked table column: add insertion". Change-Id: I2e06e1b064d51c5e7cf8140a5fd7932e7be4f765 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154935 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 4caebc0b54461a1aadc8378a6749c0d5f05d7204) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154951 diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index dfe0cc80f7ec..937567b9b2bc 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2556,6 +2556,55 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testRedlineTableColumnDeletion) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 1); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156474) +{ + // load a table, and insert a column with change tracking + createSwDoc("tdf118311.fodt"); + SwDoc* pDoc = getSwDoc(); + + // 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())); + + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), + uno::UNO_QUERY); + + // there is a table in the text with two columns + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount()); + + // insert table column with enabled change tracking + // (HasTextChangesOnly property of the cell will be false) + dispatchCommand(mxComponent, ".uno:InsertColumnsBefore", {}); + + // 3 columns + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); + + // accept tracked changes: remove HasTextChangesOnly = false of the inserted cells + dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {}); + + // still 3 columns + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); + + // delete the text content (dummy character of the previous text change) of the newly + // inserted cell, and accept tracked changes + SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + pWrtShell->Left(SwCursorSkipMode::Chars, /*bSelect=*/false, 1, /*bBasicCall=*/false); + dispatchCommand(mxComponent, ".uno:SwBackspace", {}); + dispatchCommand(mxComponent, ".uno:AcceptAllTrackedChanges", {}); + + // This was 2 columns (not removed HasTextChangesOnly = false resulted column deletion + // instead of deleting only content of the cell) + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xTextTable->getColumns()->getCount()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf155747) { // load a table, and delete the first column with enabled change tracking: diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index efed70b44a1a..898590d6201b 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -517,8 +517,7 @@ namespace const SvxPrintItem *pHasBoxTextChangesOnlyProp = pBox->GetFrameFormat()->GetAttrSet().GetItem<SvxPrintItem>(RES_PRINT); // table cell property "HasTextChangesOnly" is set and its value is false - if ( bRejectDeletion && pHasBoxTextChangesOnlyProp && - !pHasBoxTextChangesOnlyProp->GetValue() ) + if ( pHasBoxTextChangesOnlyProp && !pHasBoxTextChangesOnlyProp->GetValue() ) { SvxPrintItem aUnsetTracking(RES_PRINT, true); SwCursor aCursor( *pPos, nullptr );