sw/qa/extras/odfimport/data/tdf151375.ott |binary
 sw/qa/extras/odfimport/odfimport.cxx      |   17 +++++++++++++++++
 2 files changed, 17 insertions(+)

New commits:
commit 06f990a50d211564b89420af184edcf6145c0ce8
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Thu Oct 13 11:27:38 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Oct 13 12:14:12 2022 +0200

    tdf#151375: sw_odfimport: Add unittest
    
    Change-Id: I702059fcfc8e99b11412f959bc924af73780d351
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141284
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/odfimport/data/tdf151375.ott 
b/sw/qa/extras/odfimport/data/tdf151375.ott
new file mode 100644
index 000000000000..1215cc7722e0
Binary files /dev/null and b/sw/qa/extras/odfimport/data/tdf151375.ott differ
diff --git a/sw/qa/extras/odfimport/odfimport.cxx 
b/sw/qa/extras/odfimport/odfimport.cxx
index c7d7209a14b6..4644bac54457 100644
--- a/sw/qa/extras/odfimport/odfimport.cxx
+++ b/sw/qa/extras/odfimport/odfimport.cxx
@@ -1193,6 +1193,23 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf134971)
     CPPUNIT_ASSERT_EQUAL(OUString("Arial"), sString);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf151375)
+{
+    // Create a new document.
+    mxComponent = loadFromDesktop("private:factory/swriter", 
"com.sun.star.text.TextDocument");
+
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<text::XText> xText = xTextDocument->getText();
+    uno::Reference<document::XDocumentInsertable> 
xCursor(xText->createTextCursorByRange(xText->getStart()), uno::UNO_QUERY);
+
+    // Without the fix in place, this test would have crashed here
+    
xCursor->insertDocumentFromURL(m_directories.getURLFromSrc(mpTestDocumentPath) 
+ "tdf151375.ott", {});
+
+    uno::Reference<text::XTextFramesSupplier> const 
xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> const 
xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(7), xIndexAccess->getCount());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf138879)
 {
     // Create a new document.

Reply via email to