sw/qa/extras/uiwriter/uiwriter3.cxx | 45 ++++++++++++++++++++++++++++++++++++ sw/source/core/frmedt/fetab.cxx | 22 ++++------------- sw/source/core/txtnode/fntcache.cxx | 4 +++ 3 files changed, 54 insertions(+), 17 deletions(-)
New commits: commit 5f95e6830b4bfe48dab2868152520fc2c4462b90 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Mar 17 11:14:15 2022 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Mar 21 11:00:53 2022 +0100 tdf#147347 sw: hide deleted table at deletion in Hide Changes Last deleted row of a table frame was visible in Hide Changes mode, if it is deleted in Hide Changes mode. Fix also missing immediate update of the table layout during deleting only rows in the table. Follow-up to commit a74c51025fa4519caaf461492e4ed8e68bd34885 "tdf#146962 sw: hide deleted row at deletion in Hide Changes" Change-Id: Ic0bf09ac68dd336bd53e84e58f52ebe88ca56238 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131701 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 794fd10af7361d5a64a0f8bfbe5c8b5f308617a5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131599 diff --git a/sw/qa/extras/uiwriter/uiwriter3.cxx b/sw/qa/extras/uiwriter/uiwriter3.cxx index a7db089432e0..b8cb857043b2 100644 --- a/sw/qa/extras/uiwriter/uiwriter3.cxx +++ b/sw/qa/extras/uiwriter/uiwriter3.cxx @@ -1989,6 +1989,51 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf146962) assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 1); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf147347) +{ + // load a 2-row table, set Hide Changes mode and delete the table with change tracking + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf116789.fodt"); + CPPUNIT_ASSERT(pDoc); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + // enable redlining + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + // hide changes + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + dispatchCommand(mxComponent, ".uno:DeleteTable", {}); + + // Without the fix in place, the deleted row would be visible + + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // This was 1 + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 0); + + // check it in Show Changes mode + + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + CPPUNIT_ASSERT(!pWrtShell->GetLayout()->IsHideRedlines()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + // 2 rows are visible now + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 2); + + // check it in Hide Changes mode again + + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + // no visible row again + assertXPath(pXmlDoc, "/root/page[1]/body/tab/row", 0); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest3, testTdf135014) { createSwDoc(); diff --git a/sw/source/core/frmedt/fetab.cxx b/sw/source/core/frmedt/fetab.cxx index 7bb2ff5edc68..ecb7cfc39f2a 100644 --- a/sw/source/core/frmedt/fetab.cxx +++ b/sw/source/core/frmedt/fetab.cxx @@ -480,26 +480,14 @@ bool SwFEShell::DeleteRow(bool bCompleteTable) pPam->DeleteMark(); } - // remove row frames in Hide Changes mode + // remove row frames in Hide Changes mode (and table frames, if needed) if ( bRecordAndHideChanges ) { - for (auto & rpFndLine : aFndBox.GetLines()) + pTableNd->DelFrames(); + if ( !pTableNd->GetTable().IsDeleted() ) { - SwTableLine* pTmpLine = rpFndLine->GetLine(); - SwIterator<SwRowFrame,SwFormat> aIt( *pTmpLine->GetFrameFormat() ); - for( SwRowFrame* pRowFrame = aIt.First(); pRowFrame; pRowFrame = aIt.Next() ) - { - auto pTabFrame = pRowFrame->GetUpper(); - // FIXME remove table frame instead of keeping the last row frame - if ( pTabFrame->IsTabFrame() && pTabFrame->Lower() == pTabFrame->GetLastLower() ) - break; - - if( pRowFrame->GetTabLine() == pTmpLine ) - { - pRowFrame->RemoveFromLayout(); - SwFrame::DestroyFrame(pRowFrame); - } - } + SwNodeIndex aTableIdx( *pTableNd->EndOfSectionNode(), 1 ); + pTableNd->MakeOwnFrames(&aTableIdx); } EndAllActionAndCall(); commit 29e996bd5e364e1b6b22d88d56d28dac7d3c97d6 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Mar 17 16:24:16 2022 +0000 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Mar 21 11:00:39 2022 +0100 Resolves: tdf#148053 fix a crash in out of range dx array also seen with tdf#124116 Change-Id: I211c5b9d58ee5857c8286b2009e4159b35a9e047 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131602 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 93e83c2013e9..109865861064 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -2258,6 +2258,10 @@ TextFrameIndex SwFntObj::GetModelPositionForViewPoint(SwDrawTextInfo &rInf) if ( nIdx <= nLastIdx ) break; + // the next character might be outside the layout range (e.g tdf124116-1.odt) + if (nIdx > nEnd) + nIdx = nEnd; + nLeft = nRight; nRight = aKernArray[sal_Int32(nIdx - rInf.GetIdx()) - 1] + nKernSum + nSpaceSum;