diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-10 16:26:40 +0200 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-06-13 17:59:14 +0200 |
commit | 646c6ddd91a98afddf914e3889cb269fc814c060 (patch) | |
tree | fabcd279b184ddf791c9f39dba387a0edb87572b /sw/qa | |
parent | 5687eba49fa06202bd190c87ad8e7af634354799 (diff) |
tdf#139982 sw: preserve flys in Replace with redlining enabled
The problem is that there isn't a redline type "Replace" so it's
represented as Delete+Insert.
To prevent the flys anchored in the text from being deleted, move the
anchors to the point between the old (deleted) and new (inserted) text.
(regression from commit 28b77c89dfcafae82cf2a6d85731b643ff9290e5)
Change-Id: Ib600c9dbfb9421917e4b8d61195c48cf0b364f06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135604
Tested-by: Michael Stahl <michael.stahl@allotropia.de>
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/uiwriter/uiwriter2.cxx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 8aedaf38ef7a..e62532c0a20d 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1031,6 +1031,56 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf140007) pDoc->GetNodes()[SwNodeOffset(11)]->GetTextNode()->GetText()); } +CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf139982) +{ + SwDoc* const pDoc = createSwDoc(); + SwWrtShell* const pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + + // turn on redlining and show changes + pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete + | RedlineFlags::ShowInsert); + CPPUNIT_ASSERT_MESSAGE("redlining should be on", + pDoc->getIDocumentRedlineAccess().IsRedlineOn()); + CPPUNIT_ASSERT_MESSAGE( + "redlines should be visible", + IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags())); + + pWrtShell->Insert("helloo"); + + pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false); + { + SwFormatAnchor anchor(RndStdIds::FLY_AT_CHAR); + anchor.SetAnchor(pWrtShell->GetCursor()->GetPoint()); + SfxItemSet flySet(pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>); + flySet.Put(anchor); + SwFrameFormat const* pFly = pWrtShell->NewFlyFrame(flySet, /*bAnchValid=*/true); + CPPUNIT_ASSERT(pFly != nullptr); + } + + pWrtShell->SttEndDoc(true); + pWrtShell->EndPara(/*bSelect=*/true); + + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + + pWrtShell->Replace("hello", true); + + // the problem was that a redline delete with the same author as redline + // insert has its text deleted immediately, including anchored flys. + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + + pWrtShell->Undo(); + + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + + pWrtShell->Redo(); + + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); + + pWrtShell->Undo(); + + CPPUNIT_ASSERT_EQUAL(size_t(1), pWrtShell->GetFlyCount(FLYCNTTYPE_FRM)); +} + CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf39721) { // FIXME: disabled on Windows because of a not reproducible problem (not related to the patch) |