diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-04-22 19:26:47 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-20 11:19:06 +0200 |
commit | f47402355972af94d444c9fbcb992865c38eb3f3 (patch) | |
tree | 012df0c9a08d7c986053872377276ac0ac508317 | |
parent | sw: layout: fix crash when deleting page with section being formatted (diff) | |
download | core-f47402355972af94d444c9fbcb992865c38eb3f3.tar.gz core-f47402355972af94d444c9fbcb992865c38eb3f3.zip |
tdf#135978 sw_redlinehide: recreate fly frames anchored to subsequent nodes
... in SwTextNode::JoinNext().
The 2nd node is deleted, so its frame is deleted, and if it is the start
of a merged frame, fly frames on the node itself will be recreated
already, but those on subseqent nodes need an extra call.
Change-Id: I18999946334f5560b720d3d275610bc8b07973f6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133335
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 98ae340307786c8fe18addc3714c9b859fdf12dd)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133293
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
(cherry picked from commit 78f726541be4316a8fe18c50f7d146304f6e0e87)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133886
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 53 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 5 |
2 files changed, 57 insertions, 1 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 8f6606eb83f5..c7642d54d9dd 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -590,7 +590,7 @@ public: CPPUNIT_TEST(testTdf59666); CPPUNIT_TEST_SUITE_END(); -private: +protected: SwDoc* createDoc(const char* pName = nullptr); std::unique_ptr<SwTextBlocks> readDOCXAutotext(const OUString& sFileName, bool bEmpty = false); }; @@ -4147,6 +4147,57 @@ static void lcl_dispatchCommand(const uno::Reference<lang::XComponent>& xCompone xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf135978) +{ + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + pWrtShell->Insert("foobar"); + pWrtShell->SplitNode(); + pWrtShell->Insert("bazquux"); + + CPPUNIT_ASSERT(pWrtShell->IsEndOfDoc()); + + SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR); + anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint()); + SfxItemSet flySet(pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{}); + flySet.Put(anchor); + SwFlyFrameFormat const* pFly = dynamic_cast<SwFlyFrameFormat const*>( + pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true)); + CPPUNIT_ASSERT(pFly != nullptr); + CPPUNIT_ASSERT(pFly->GetFrame() != nullptr); + // move cursor back to body + pWrtShell->SttEndDoc(/*bStt=*/false); + + // hide and enable + lcl_dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + lcl_dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + + CPPUNIT_ASSERT(pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT( + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + CPPUNIT_ASSERT(pWrtShell->GetLayout()->IsHideRedlines()); + + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 4, /*bBasicCall=*/false); + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 6, /*bBasicCall=*/false); + pWrtShell->Delete(); + + // now split + pWrtShell->SttEndDoc(/*bStt=*/true); + pWrtShell->SplitNode(); + CPPUNIT_ASSERT(pFly->GetFrame() != nullptr); + + // the problem was that undo removed the fly frame from the layout + pWrtShell->Undo(); + CPPUNIT_ASSERT(pFly->GetFrame() != nullptr); + + pWrtShell->Redo(); + CPPUNIT_ASSERT(pFly->GetFrame() != nullptr); + + pWrtShell->Undo(); + CPPUNIT_ASSERT(pFly->GetFrame() != nullptr); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf139843) { load(DATA_DIRECTORY, "tdf139843.odt"); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 1660f5ae5f7c..f42adf2a642c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -900,6 +900,11 @@ void CheckResetRedlineMergeFlag(SwTextNode & rNode, Recreate const eRecreateMerg { assert(pFrame->GetMergedPara()->listener.IsListeningTo(&rNode)); assert(rNode.GetIndex() <= pFrame->GetMergedPara()->pLastNode->GetIndex()); + // tdf#135978 Join: recreate fly frames anchored to subsequent nodes + if (eRecreateMerged == sw::Recreate::ThisNode) + { + AddRemoveFlysAnchoredToFrameStartingAtNode(*pFrame, rNode, nullptr); + } } eMode = sw::FrameMode::New; // Existing is not idempotent! } |