summaryrefslogtreecommitdiffstats
path: root/sw/qa/extras/unowriter
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/extras/unowriter')
-rw-r--r--sw/qa/extras/unowriter/data/tdf161035.fodt9
-rw-r--r--sw/qa/extras/unowriter/unowriter.cxx27
2 files changed, 36 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+ <office:text>
+ <text:p>Lorem <text:bookmark text:name="Bookmark"/>ipsum.</text:p>
+ </office:text>
+ </office:body>
+</office:document> \ 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<frame::XModel>();
+
+ // Create a text view cursor in the paragraph.
+ auto xController = xModel->getCurrentController().queryThrow<text::XTextViewCursorSupplier>();
+ 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<container::XEnumerationAccess>()->createEnumeration();
+ CPPUNIT_ASSERT(xParaEnum);
+ auto xPara = xParaEnum->nextElement().queryThrow<container::XEnumerationAccess>();
+ // 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: */