From 9c0049cfae49c8e4ddef9125a69db2ad134c10c6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 13:48:25 +0200 Subject: Merging upstream version 4:24.2.4. Signed-off-by: Daniel Baumann --- sw/qa/extras/unowriter/data/tdf161035.fodt | 9 +++++++++ sw/qa/extras/unowriter/unowriter.cxx | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 sw/qa/extras/unowriter/data/tdf161035.fodt (limited to 'sw/qa/extras/unowriter') diff --git a/sw/qa/extras/unowriter/data/tdf161035.fodt b/sw/qa/extras/unowriter/data/tdf161035.fodt new file mode 100644 index 0000000000..8f1d53b083 --- /dev/null +++ b/sw/qa/extras/unowriter/data/tdf161035.fodt @@ -0,0 +1,9 @@ + + + + + + Lorem ipsum. + + + \ No newline at end of file diff --git a/sw/qa/extras/unowriter/unowriter.cxx b/sw/qa/extras/unowriter/unowriter.cxx index 80b9e556f7..7175e702d7 100644 --- a/sw/qa/extras/unowriter/unowriter.cxx +++ b/sw/qa/extras/unowriter/unowriter.cxx @@ -1222,6 +1222,33 @@ CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTdf160278) CPPUNIT_ASSERT_EQUAL(u"12test"_ustr, xText->getString()); } +CPPUNIT_TEST_FIXTURE(SwUnoWriter, testTdf161035) +{ + // Given a paragraph with a bookmark: + createSwDoc("tdf161035.fodt"); + auto xModel = mxComponent.queryThrow(); + + // Create a text view cursor in the paragraph. + auto xController = xModel->getCurrentController().queryThrow(); + auto xViewCursor = xController->getViewCursor(); + CPPUNIT_ASSERT(xViewCursor); + auto xText = xViewCursor->getText(); + CPPUNIT_ASSERT(xText); + // Create a text cursor from the text view cursor, and move it to the end of the paragraph + auto xTextCursor = xText->createTextCursorByRange(xViewCursor); + CPPUNIT_ASSERT(xTextCursor); + xTextCursor->gotoEnd(false); + // Get the first paragraph portion from the text cursor + auto xParaEnum = xTextCursor.queryThrow()->createEnumeration(); + CPPUNIT_ASSERT(xParaEnum); + auto xPara = xParaEnum->nextElement().queryThrow(); + // Try to enumerate text portions. Without the fix, it would fail an assertion in debug builds, + // and hang in release builds, because the paragraph portion started after the bookmark, and + // so the bookmark wasn't processed (expectedly): + auto xRunEnum = xPara->createEnumeration(); + CPPUNIT_ASSERT(!xRunEnum->hasMoreElements()); // Empty enumeration for empty selection +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3