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 4506cd04c78baf628c8c6fd7e9c5f27a407d8f87 Author: Andreas Heinisch <andreas.heini...@yahoo.de> AuthorDate: Thu Aug 29 13:52:06 2024 +0200 Commit: Andreas Heinisch <andreas.heini...@yahoo.de> CommitDate: Fri Sep 20 16:56:34 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 diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 4ead3c8cd1d1..bede3ce759eb 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -1186,6 +1186,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 73b7bc399275..e34a94a7f101 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;