sw/qa/extras/uiwriter/uiwriter5.cxx | 43 ++++++++++++++++++++++++++++++++++++ sw/source/core/frmedt/fetab.cxx | 4 +-- 2 files changed, 45 insertions(+), 2 deletions(-)
New commits: commit 6383362999b72160eab6abdfc6ea6bdbd231b100 Author: László Németh <nem...@numbertext.org> AuthorDate: Mon Oct 17 14:30:28 2022 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Oct 21 11:36:41 2022 +0200 tdf#151657 sw: delete row with nested table in Hide Changes Fix for tdf#150976 didn't work in Hide Changes mode. Follow-up to commit c809867f3ee92a8eb36cbab840bd6d6c5b3b1c26 "tdf#150976 sw: fix tracked deletion of row with nested table". Change-Id: If10c8184a01d025e3df53e33fc9503107fce0980 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141611 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx index ab457a51171e..1e93a764cc25 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -1898,6 +1898,49 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf150976) CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRow()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf151657) +{ + // load a 1-row table, and delete the row with hidden track changes + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "select-row.fodt"); + + // turn on red-lining and hide 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 + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "//page[1]//body/tab"); + // nested table in the last cell + assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell[2]/tab"); + + // delete table row with enabled change tracking + dispatchCommand(mxComponent, ".uno:DeleteRows", {}); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "//page[1]//body/tab"); + + // deleted text content + SwEditShell* const pEditShell(pDoc->GetEditShell()); + // This was 1 before fixing tdf#151478 (testSelectRowWithNestedTable) + CPPUNIT_ASSERT_EQUAL(static_cast<SwRedlineTable::size_type>(3), pEditShell->GetRedlineCount()); + + SwRootFrame* pLayout = pDoc->getIDocumentLayoutAccess().GetCurrentLayout(); + SwFrame* pPage = pLayout->Lower(); + SwFrame* pBody = pPage->GetLower(); + SwFrame* pTable = pBody->GetLower(); + CPPUNIT_ASSERT(pTable->IsTabFrame()); + + SwTabFrame* pTabFrame = static_cast<SwTabFrame*>(pTable); + + // This was false (not deleted row) + CPPUNIT_ASSERT(pTabFrame->GetTable()->HasDeletedRow()); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testSelectRowWithNestedTable) { // load a 1-row table, and select the row diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 4070fe8d7895..19bee641b2cf 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -479,8 +479,8 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) pTableCursor->DeleteMark(); // set start and end of the selection - pTableCursor->GetPoint()->Assign( *pEnd->GetSttNd() ); - pTableCursor->Move( fnMoveForward, GoInContent ); + pTableCursor->GetPoint()->Assign( *pEnd->GetSttNd()->EndOfSectionNode() ); + pTableCursor->Move( fnMoveBackward, GoInContent ); pTableCursor->SetMark(); pTableCursor->GetPoint()->Assign( *pStt->GetSttNd()->EndOfSectionNode() ); pTableCursor->Move( fnMoveBackward, GoInContent );