sw/qa/core/data/odt/tdf151846.odt |binary
 sw/qa/core/macros-test.cxx        |   18 ++++++++++++++++++
 2 files changed, 18 insertions(+)

New commits:
commit 4440f321fcf0157ef52e988dd519d79efd49565b
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jan 10 13:38:24 2023 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jan 10 18:26:17 2023 +0000

    tdf#151846: sw_macros: Add unittest
    
    For that I used the test document from tdf#152732
    
    Change-Id: I19257f4e20a509e6adaf49dd5ea8f180c3feaef5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145266
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/core/data/odt/tdf151846.odt 
b/sw/qa/core/data/odt/tdf151846.odt
new file mode 100644
index 000000000000..4f62ef9e81bc
Binary files /dev/null and b/sw/qa/core/data/odt/tdf151846.odt differ
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 688fe7417fc6..72ed9b5a9612 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -67,6 +67,7 @@ public:
     void testBookmarkDeleteAndJoin();
     void testBookmarkDeleteTdf90816();
     void testControlShapeGrouping();
+    void testTdf151846();
     void testFdo55289();
     void testFdo68983();
     void testFdo87530();
@@ -78,6 +79,7 @@ public:
     CPPUNIT_TEST(testBookmarkDeleteAndJoin);
     CPPUNIT_TEST(testBookmarkDeleteTdf90816);
     CPPUNIT_TEST(testControlShapeGrouping);
+    CPPUNIT_TEST(testTdf151846);
     CPPUNIT_TEST(testFdo55289);
     CPPUNIT_TEST(testFdo68983);
     CPPUNIT_TEST(testFdo87530);
@@ -339,6 +341,22 @@ void SwMacrosTest::testControlShapeGrouping()
 #endif
 }
 
+void SwMacrosTest::testTdf151846()
+{
+    loadFromURL(u"odt/tdf151846.odt");
+
+    // Without the fix in place, this test would have failed with
+    // Property or method not found: createDiagramByDataSource.
+    
executeMacro("vnd.sun.Star.script:Standard.Module1.Main?language=Basic&location=document");
+
+    uno::Reference<text::XTextEmbeddedObjectsSupplier> 
xTEOSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XNameAccess> 
xAccess(xTEOSupplier->getEmbeddedObjects());
+    uno::Sequence<OUString> aSeq(xAccess->getElementNames());
+
+    // Check number of embedded objects.
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeq.getLength());
+}
+
 void SwMacrosTest::testFdo55289()
 {
     SwDoc* const pDoc = new SwDoc;

Reply via email to