diff options
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 46 | ||||
-rw-r--r-- | sw/source/core/undo/undel.cxx | 5 |
2 files changed, 50 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 699264592bba..7e77a4eced99 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1549,6 +1549,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 f3fbf5eac553..0de31cd9adb2 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -1137,7 +1137,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); } |