summaryrefslogtreecommitdiffstats
path: root/sw/qa/core/frmedt
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:48:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 11:48:25 +0000
commit9c0049cfae49c8e4ddef9125a69db2ad134c10c6 (patch)
tree812a86c0eee63dfc5ace12f2622ed3ce9cd3d680 /sw/qa/core/frmedt
parentReleasing progress-linux version 4:24.2.3-2~progress7.99u1. (diff)
downloadlibreoffice-9c0049cfae49c8e4ddef9125a69db2ad134c10c6.tar.xz
libreoffice-9c0049cfae49c8e4ddef9125a69db2ad134c10c6.zip
Merging upstream version 4:24.2.4.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/core/frmedt')
-rw-r--r--sw/qa/core/frmedt/frmedt.cxx35
1 files changed, 35 insertions, 0 deletions
diff --git a/sw/qa/core/frmedt/frmedt.cxx b/sw/qa/core/frmedt/frmedt.cxx
index b2a53e60db..37425c1306 100644
--- a/sw/qa/core/frmedt/frmedt.cxx
+++ b/sw/qa/core/frmedt/frmedt.cxx
@@ -250,6 +250,41 @@ CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testSplitFlyUnfloat)
CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pDoc->GetTableFrameFormatCount(/*bUsed=*/true));
}
+CPPUNIT_TEST_FIXTURE(SwCoreFrmedtTest, testInsertOnGrfNodeAsChar)
+{
+ // Given a selected as-char image:
+ createSwDoc();
+ SwDoc* pDoc = getSwDocShell()->GetDoc();
+ SwWrtShell* pWrtShell = getSwDocShell()->GetWrtShell();
+ {
+ SfxItemSet aFrameSet(pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>);
+ SwFormatAnchor aAnchor(RndStdIds::FLY_AS_CHAR);
+ aFrameSet.Put(aAnchor);
+ Graphic aGrf;
+ pWrtShell->SwFEShell::Insert(OUString(), OUString(), &aGrf, &aFrameSet);
+ }
+
+ // When inserting another as-char image:
+ SfxItemSet aFrameSet(pDoc->GetAttrPool(), svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END - 1>);
+ SwFormatAnchor aAnchor(RndStdIds::FLY_AS_CHAR);
+ aFrameSet.Put(aAnchor);
+ Graphic aGrf;
+ // Without the accompanying fix in place, this call crashed, we try to set a graphic node as an
+ // anchor of an as-char image (which should be a text node).
+ pWrtShell->SwFEShell::Insert(OUString(), OUString(), &aGrf, &aFrameSet);
+
+ // Then make sure that the anchor of the second image is next to the first anchor:
+ CPPUNIT_ASSERT(pDoc->GetSpzFrameFormats());
+ sw::FrameFormats<sw::SpzFrameFormat*>& rFormats = *pDoc->GetSpzFrameFormats();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), rFormats.size());
+ const sw::SpzFrameFormat& rFormat1 = *rFormats[0];
+ const SwPosition* pAnchor1 = rFormat1.GetAnchor().GetContentAnchor();
+ const sw::SpzFrameFormat& rFormat2 = *rFormats[1];
+ const SwPosition* pAnchor2 = rFormat2.GetAnchor().GetContentAnchor();
+ CPPUNIT_ASSERT_EQUAL(pAnchor1->nNode, pAnchor2->nNode);
+ CPPUNIT_ASSERT_EQUAL(pAnchor1->GetContentIndex() + 1, pAnchor2->GetContentIndex());
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */