sw/qa/extras/uiwriter/uiwriter5.cxx | 30 ++++++++++++++++++++++++++++++ sw/source/core/frmedt/fetab.cxx | 33 +++++++++++++++++++++++---------- 2 files changed, 53 insertions(+), 10 deletions(-)
New commits: commit dfa57ee45bf9aef73f8bf385b089739ee0572998 Author: László Németh <nem...@numbertext.org> AuthorDate: Tue Aug 8 19:46:15 2023 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Aug 14 11:13:14 2023 +0200 tdf#156487 sw tracked table column: fix Hide Changes In Hide Changes mode, deleting table columns with change tracking wasn't applied on the table layout immediately, only using Show Changes and Hide Changes again. Now the deleted column removed from the table instead leaving an empty table column. Also revert commit 33058b5dc47a140516669945efbdd30ea65138a6 "tdf#156544 sw tracked table column: delete empty column". See also commit a74c51025fa4519caaf461492e4ed8e68bd34885 "tdf#146962 sw: hide deleted row at deletion in Hide Changes". Change-Id: If03d2bc5996a168cb44839b0753effb9031edbc7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155522 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 43b128a960d1712b984402e1b69cefecdb75462a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155478 Tested-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 3e8babfff390..285a3adb7c61 100644 --- a/sw/qa/extras/uiwriter/uiwriter5.cxx +++ b/sw/qa/extras/uiwriter/uiwriter5.cxx @@ -2777,6 +2777,36 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156544) assertXPath(pXmlDoc, "//page[1]//body/tab/row/cell", 2); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf156487) +{ + // load a table, and delete a column in Hide Changes mode + createSwDoc("tdf118311.fodt"); + SwDoc* pDoc = getSwDoc(); + + // 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 shouldn't be visible", + !IDocumentRedlineAccess::IsShowChanges( + pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + + // delete table column with enabled change tracking + // (HasTextChangesOnly property of the cell will be false) + dispatchCommand(mxComponent, ".uno:DeleteColumns", {}); + + // Dump the rendering of the first page as an XML file. + SwDocShell* pShell = pDoc->GetDocShell(); + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // This would be 2 without hiding the first cell + assertXPath(pXmlDoc, "/metafile/push/push/push/textarray/text", 1); +} + #ifndef DBG_UTIL CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf149498) { diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index a766596daa29..dced56c1f2a0 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -279,11 +279,14 @@ bool SwFEShell::DeleteCol() CurrShell aCurr( this ); + bool bRecordChanges = GetDoc()->GetDocShell()->IsChangeRecording(); + bool bRecordAndHideChanges = bRecordChanges && + GetDoc()->getIDocumentLayoutAccess().GetCurrentLayout()->IsHideRedlines(); + // tracked deletion: remove only textbox content, // and set IsNoTracked table box property to false - if ( GetDoc()->GetDocShell()->IsChangeRecording() ) + if ( bRecordChanges ) { - bool bDeletedEmptyCell = false; StartUndo(SwUndoId::COL_DELETE); StartAllAction(); @@ -296,6 +299,10 @@ bool SwFEShell::DeleteCol() TableWait aWait( 20, pFrame, *GetDoc()->GetDocShell(), aBoxes.size() ); + SwTableNode* pTableNd = pFrame->IsTextFrame() + ? static_cast<SwTextFrame*>(pFrame)->GetTextNodeFirst()->FindTableNode() + : static_cast<SwNoTextFrame*>(pFrame)->GetNode()->FindTableNode(); + for (size_t i = 0; i < aBoxes.size(); ++i) { SwTableBox *pBox = aBoxes[i]; @@ -318,24 +325,30 @@ bool SwFEShell::DeleteCol() aCursor.GetMark()->SetContent(0); rIDRA.SetRedlineFlags_intern( eOld ); rIDCO.DeleteAndJoin( aCursor ); - bDeletedEmptyCell = true; } } } SwEditShell* pEditShell = GetDoc()->GetEditShell(); - SwRedlineTable::size_type nPrev = pEditShell->GetRedlineCount(); pEditShell->Delete(); + // remove cell frames in Hide Changes mode (and table frames, if needed) + if ( bRecordAndHideChanges ) + { + // remove all frames of the table, and make them again without the deleted ones + // TODO remove only the deleted frames + pTableNd->DelFrames(); + + if ( !pTableNd->GetTable().IsDeleted() ) + { + pTableNd->MakeOwnFrames(); + } + } + EndAllActionAndCall(); EndUndo(SwUndoId::COL_DELETE); - - // track column deletion only if there were tracked text changes - // FIXME redline count can be the same in special cases, e.g. adding a - // new tracked deletion with removing an own tracked insertion... - if ( bDeletedEmptyCell || nPrev != pEditShell->GetRedlineCount() ) - return true; + return true; } StartAllAction();