sw/qa/extras/uiwriter/uiwriter2.cxx | 46 ++++++++++++++++++++++++++++++++++++ sw/source/core/undo/undel.cxx | 5 +++ 2 files changed, 50 insertions(+), 1 deletion(-)
New commits: commit d65b07c42206476ab471320c8261a96adad4d515 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Mon Mar 7 15:57:09 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Mar 10 10:31:02 2022 +0100 tdf#147310 sw_redlinehide: recreate frames for whole table deleted SwUndoDelete calls MakeFrames with end being end node of the table, but it needs to be the following node (with a frame). (regression from commit 723728cd358693b8f4bc9d913541aa4479f2bd48) Change-Id: Id0974c8349be5aef9630822738eae9462bbcb4f0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131112 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 6f20bcb152948a24dbe40ca2e6c4ecef2bebf853) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131131 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 4e9080bdc951..d5f6f045da70 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1545,6 +1545,52 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf109376) CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf147310) +{ + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + CPPUNIT_ASSERT(pWrtShell); + + // somehow bug happens only with 2 tables + SwInsertTableOptions tableOpt(SwInsertTableFlags::DefaultBorder, 0); + pWrtShell->InsertTable(tableOpt, 1, 1); + pWrtShell->InsertTable(tableOpt, 1, 1); + + pWrtShell->SttEndDoc(/*bStart=*/true); + + pWrtShell->DeleteRow(false); + pWrtShell->DeleteRow(false); + + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page/body/tab", 0); + discardDumpedLayout(); + } + pWrtShell->Undo(); + // this did not create frames for the table + pWrtShell->Undo(); + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // there are 2 tables + assertXPath(pXmlDoc, "/root/page/body/tab", 2); + discardDumpedLayout(); + } + pWrtShell->Redo(); + pWrtShell->Redo(); + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page/body/tab", 0); + discardDumpedLayout(); + } + pWrtShell->Undo(); + pWrtShell->Undo(); + { + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + // there are 2 tables + assertXPath(pXmlDoc, "/root/page/body/tab", 2); + } +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf64242_optimizeTable) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf64242_optimizeTable.odt"); diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index ed1cdf38794d..2d35811a9b86 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -1136,7 +1136,10 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) // don't include end node in the range: it may have been merged already // by the start node, or it may be merged by one of the moved nodes, // but if it isn't merged, its current frame(s) should be good... - SwNodeIndex const end(rDoc.GetNodes(), m_bDelFullPara ? delFullParaEndNode : m_nEndNode); + SwNodeIndex const end(rDoc.GetNodes(), m_bDelFullPara + ? delFullParaEndNode + // tdf#147310 SwDoc::DeleteRowCol() may delete whole table - end must be node following table! + : (m_nEndNode + (rDoc.GetNodes()[m_nSttNode]->IsTableNode() && rDoc.GetNodes()[m_nEndNode]->IsEndNode() ? 1 : 0))); ::MakeFrames(&rDoc, start, end); }