From 0e0c7616bace9f64079fe9c19c06aca823815666 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Tue, 27 Oct 2020 16:33:30 +0100 Subject: tdf#136453 sw_redlinehide: SwUndoDelete: only create extra frames... ... at the start if the section nodes were at the start. m_bBackSp and m_bJoinNext can't both be true. (regression from 740f1796504f66408b692225a9676c9ee3d63722) Change-Id: I999ed3809ca8f527bc3e754b229df02da4576825 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104891 Tested-by: Jenkins Reviewed-by: Michael Stahl (cherry picked from commit c4967928475f2be20ac2d79e3fa84ac435a7e560) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104920 Tested-by: Michael Stahl --- sw/qa/extras/uiwriter/data/tdf136453.fodt | 66 +++++++++++++++++++++++++++++++ sw/qa/extras/uiwriter/uiwriter.cxx | 51 ++++++++++++++++++++++++ sw/source/core/undo/undel.cxx | 3 +- 3 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 sw/qa/extras/uiwriter/data/tdf136453.fodt diff --git a/sw/qa/extras/uiwriter/data/tdf136453.fodt b/sw/qa/extras/uiwriter/data/tdf136453.fodt new file mode 100644 index 000000000000..2234957e1db8 --- /dev/null +++ b/sw/qa/extras/uiwriter/data/tdf136453.fodt @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + foo + bar + + baz + + + + diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index b98a12d0e90c..7e28d0f57ead 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -1136,6 +1136,57 @@ void SwUiWriterTest::testWatermarkDOCX() CPPUNIT_ASSERT_EQUAL(sal_Int16(50), pWatermark->GetTransparency()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf136453) +{ + load(DATA_DIRECTORY, "tdf136453.fodt"); + + SwXTextDocument *const pTextDoc(dynamic_cast(mxComponent.get())); + CPPUNIT_ASSERT(pTextDoc); + SwDoc* const pDoc(pTextDoc->GetDocShell()->GetDoc()); + SwWrtShell *const pWrtShell(pDoc->GetDocShell()->GetWrtShell()); + + sal_uLong const nNodes(pDoc->GetNodes().Count()); + + pWrtShell->SttEndDoc(false); + pWrtShell->SetMark(); + pWrtShell->Up(true, 1); + pWrtShell->SttPara(true); + pWrtShell->Delete(); + + // one paragraph deleted, section is gone + CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count()); + + pWrtShell->Undo(); + + CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count()); + + // check that every node has 1 frame + xmlDocPtr pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[1]/body/section", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1); + + pWrtShell->Redo(); + + // one paragraph deleted, section is gone + CPPUNIT_ASSERT_EQUAL(nNodes - 3, pDoc->GetNodes().Count()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[1]/body/section", 0); + + pWrtShell->Undo(); + + CPPUNIT_ASSERT_EQUAL(nNodes, pDoc->GetNodes().Count()); + + discardDumpedLayout(); + pXmlDoc = parseLayoutDump(); + assertXPath(pXmlDoc, "/root/page[1]/body/txt", 3); + assertXPath(pXmlDoc, "/root/page[1]/body/section", 1); + assertXPath(pXmlDoc, "/root/page[1]/body/section/txt", 1); +} + void SwUiWriterTest::testWatermarkPosition() { // tdf#108494 Watermark inserted in the document with page break was outside the first page diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 5cf415feab3a..4e55a46196b4 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -1115,7 +1115,8 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext) // create frames after SetSaveData has recreated redlines if (0 != m_nNode) { - if (m_nReplaceDummy != 0) + // tdf#136453 only if section nodes at the start + if (m_bBackSp && m_nReplaceDummy != 0) { // tdf#134252 *first* create outer section frames // note: text node m_nSttNode currently has frame with an upper; -- cgit