diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-03-07 15:57:09 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-10 10:34:23 +0100 |
commit | 6a1024962f7b286df0535b39e3b79202314245e0 (patch) | |
tree | 226c4baf9c848b60ade6952364a1501cce46ae26 | |
parent | tdf#136632: Use 'Save transparency' when exporting selected objects for PNG (diff) | |
download | core-6a1024962f7b286df0535b39e3b79202314245e0.tar.gz core-6a1024962f7b286df0535b39e3b79202314245e0.zip |
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.stahl@allotropia.de>
(cherry picked from commit 6f20bcb152948a24dbe40ca2e6c4ecef2bebf853)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131132
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-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); } |