From fde4c9c8dfdcde2f2c60e746ebc881851e270967 Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 6 Mar 2023 14:02:02 +0100 Subject: tdf#153819 sw: fix crashing MakeFramesForAdjacentContentNode() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Hide Changes mode, copying cells before a tracked deleted table crashed in SwTableNode::MakeFramesForAdjacentContentNode(). Regression from commit 794fd10af7361d5a64a0f8bfbe5c8b5f308617a5 "tdf#147347 sw: hide deleted table at deletion in Hide Changes". Change-Id: I3ac070d35006e61b01a065359431e302e6974e17 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148344 Tested-by: Jenkins Reviewed-by: László Németh (cherry picked from commit 317ed3e81a5aa7826176a5122c2d8ea76aa0fb37) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148323 Tested-by: László Németh Signed-off-by: Xisco Fauli Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148640 --- sw/qa/extras/uiwriter/data/tdf153819.fodt | 174 ++++++++++++++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter7.cxx | 18 ++++ sw/source/core/docnode/ndtbl.cxx | 7 +- 3 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 sw/qa/extras/uiwriter/data/tdf153819.fodt diff --git a/sw/qa/extras/uiwriter/data/tdf153819.fodt b/sw/qa/extras/uiwriter/data/tdf153819.fodt new file mode 100644 index 000000000000..910807825204 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf153819.fodt @@ -0,0 +1,174 @@ + + + + 2023-03-06T12:23:04.8519275222023-03-06T12:26:09.438416733PT1M28S2LibreOfficeDev/7.6.0.0.alpha0$Linux_X86_64 LibreOffice_project/e29c2b96b1aaba0fef5c83de7be18448e5903d08 + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unknown Author + 2023-03-06T12:26:07 + + + + + + + + + + + + + + + + x + + + + + + + + + + + + + + + + diff --git a/sw/qa/extras/uiwriter/uiwriter7.cxx b/sw/qa/extras/uiwriter/uiwriter7.cxx index 0ac6b0183068..833a35f97e61 100644 --- a/sw/qa/extras/uiwriter/uiwriter7.cxx +++ b/sw/qa/extras/uiwriter/uiwriter7.cxx @@ -147,6 +147,24 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf77340) CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(3)), xPropSet->getPropertyValue("PageNumberOffset")); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf153819) +{ + // copy a table before a deleted table in Hide Changes mode + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf153819.fodt"); + CPPUNIT_ASSERT(pDoc); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + // hide changes + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + dispatchCommand(mxComponent, ".uno:SelectTable", {}); + dispatchCommand(mxComponent, ".uno:Copy", {}); + dispatchCommand(mxComponent, ".uno:GoDown", {}); + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:Paste", {}); + // FIXME: Show Changes, otherwise ~SwTableNode() would have crashed + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest7, testTdf79236) { SwDoc* pDoc = createSwDoc(); diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index edeb5b7cb2ba..e76a0bbf1f3f 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -2375,8 +2375,11 @@ void SwTableNode::MakeFramesForAdjacentContentNode(const SwNodeIndex & rIdx) while( nullptr != (pFrame = aNode2Layout.NextFrame()) ) { - if (pFrame->getRootFrame()->HasMergedParas() - && !pNode->IsCreateFrameWhenHidingRedlines()) + if ( ( pFrame->getRootFrame()->HasMergedParas() && + !pNode->IsCreateFrameWhenHidingRedlines() ) || + // tdf#153819 table deletion with change tracking: + // table node without frames in Hide Changes mode + !pFrame->GetUpper() ) { continue; } -- cgit v1.2.3