summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-04-22 19:26:47 +0200
committerAndras Timar <andras.timar@collabora.com>2022-04-27 13:20:00 +0200
commit09943927e3e907130432c86911cfce0746a7133d (patch)
tree2081297cd4d30bf9804035099cc85b77f85a0a7e /sw/qa/extras/uiwriter
parent5067422e2b67825b4e65e2c586a525716a86a40b (diff)
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/+/133371 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx51
1 files changed, 51 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");