diff options
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter.cxx | 51 | ||||
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 5 |
2 files changed, 56 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 1e6f8be07b06..d38c33364803 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -693,6 +693,57 @@ void SwUiWriterTest::testTdf67238() CPPUNIT_ASSERT(!((rTable.GetTableBox("C3"))->GetFrameFormat()->GetProtect()).IsContentProtected()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest, testTdf135978) +{ + SwDoc* pDoc = createSwDoc(); + 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 + dispatchCommand(mxComponent, ".uno:ShowTrackedChanges", {}); + 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); +} + void SwUiWriterTest::testFdo75110() { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "fdo75110.odt"); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 4d109a8add1c..5c8a501386fa 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -884,6 +884,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! } |