basic/source/classes/sbunoobj.cxx |    9 +++++++++
 sw/qa/core/data/odt/tdf162431.odt |binary
 sw/qa/core/macros-test.cxx        |   14 ++++++++++++++
 3 files changed, 23 insertions(+)

New commits:
commit f69de110cc73e4b10941cee17c86f89590e43bfa
Author:     Andreas Heinisch <andreas.heini...@yahoo.de>
AuthorDate: Thu Aug 29 13:52:06 2024 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Sep 23 11:49:36 2024 +0200

    tdf#162431 - Check for missing parameters
    
    Don't silently convert missing parameters including their error code to the 
request target typen when the target type can't handle the conversion.
    
    Change-Id: I2300aa594ae3cc1045a6397c1195718b6662aa61
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172593
    Reviewed-by: Andreas Heinisch <andreas.heini...@yahoo.de>
    Tested-by: Jenkins
    (cherry picked from commit 4506cd04c78baf628c8c6fd7e9c5f27a407d8f87)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173790
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/basic/source/classes/sbunoobj.cxx 
b/basic/source/classes/sbunoobj.cxx
index 419b2bb31a84..3244085c3688 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -1185,6 +1185,15 @@ Any sbxToUnoValue( const SbxValue* pVar, const Type& 
rType, Property const * pUn
     }
 
     TypeClass eType = rType.getTypeClass();
+
+    // tdf#162431 - check for missing parameters
+    if (eType != TypeClass_ANY && eType != TypeClass_VOID && pVar->GetType() 
== SbxERROR)
+    {
+        SbxVariable* paSbxVariable = 
dynamic_cast<SbxVariable*>(const_cast<SbxValue*>(pVar));
+        if (paSbxVariable && SbiRuntime::IsMissing(paSbxVariable, 1))
+            StarBASIC::Error(ERRCODE_BASIC_NOT_OPTIONAL);
+    }
+
     switch( eType )
     {
         case TypeClass_INTERFACE:
diff --git a/sw/qa/core/data/odt/tdf162431.odt 
b/sw/qa/core/data/odt/tdf162431.odt
new file mode 100644
index 000000000000..de273e7345f5
Binary files /dev/null and b/sw/qa/core/data/odt/tdf162431.odt differ
diff --git a/sw/qa/core/macros-test.cxx b/sw/qa/core/macros-test.cxx
index 21798735cd09..34fa7540df79 100644
--- a/sw/qa/core/macros-test.cxx
+++ b/sw/qa/core/macros-test.cxx
@@ -69,6 +69,7 @@ public:
     void testBookmarkDeleteTdf90816();
     void testControlShapeGrouping();
     void testTdf151846();
+    void testTdf162431();
     void testFdo55289();
     void testFdo68983();
     void testFdo87530();
@@ -81,6 +82,7 @@ public:
     CPPUNIT_TEST(testBookmarkDeleteTdf90816);
     CPPUNIT_TEST(testControlShapeGrouping);
     CPPUNIT_TEST(testTdf151846);
+    CPPUNIT_TEST(testTdf162431);
     CPPUNIT_TEST(testFdo55289);
     CPPUNIT_TEST(testFdo68983);
     CPPUNIT_TEST(testFdo87530);
@@ -357,6 +359,18 @@ void SwMacrosTest::testTdf151846()
     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeq.getLength());
 }
 
+void SwMacrosTest::testTdf162431()
+{
+    loadFromFile(u"odt/tdf162431.odt");
+
+    uno::Any aRet = executeMacro(
+        
u"vnd.sun.Star.script:Standard.Module1.TestIsMissingUnoParameter?language=Basic&location=document"_ustr);
+
+    OUString aStringRes;
+    CPPUNIT_ASSERT(aRet >>= aStringRes);
+    CPPUNIT_ASSERT_EQUAL(u"OK"_ustr, aStringRes);
+}
+
 void SwMacrosTest::testFdo55289()
 {
     SwDoc* const pDoc = new SwDoc;

Reply via email to