diff options
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 33 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf133889.ods | bin | 0 -> 8202 bytes | |||
-rw-r--r-- | scripting/source/basprov/basscript.cxx | 15 |
3 files changed, 48 insertions, 0 deletions
diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 00c8474a38b6..7efa20e5f60f 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -53,6 +53,7 @@ public: void testTdf71271(); void testTdf43003(); void testTdf133887(); + void testTdf133889(); CPPUNIT_TEST_SUITE(ScMacrosTest); CPPUNIT_TEST(testStarBasic); @@ -72,6 +73,7 @@ public: CPPUNIT_TEST(testTdf71271); CPPUNIT_TEST(testTdf43003); CPPUNIT_TEST(testTdf133887); + CPPUNIT_TEST(testTdf133889); CPPUNIT_TEST_SUITE_END(); }; @@ -897,6 +899,37 @@ void ScMacrosTest::testTdf133887() xCloseable->close(true); } +void ScMacrosTest::testTdf133889() +{ + OUString aFileName; + createFileURL(u"tdf133889.ods", aFileName); + auto xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + + CPPUNIT_ASSERT_MESSAGE("Failed to load the doc", xComponent.is()); + + css::uno::Any aRet; + css::uno::Sequence<sal_Int16> aOutParamIndex; + css::uno::Sequence<css::uno::Any> aOutParam; + css::uno::Sequence<css::uno::Any> aParams{ css::uno::Any(sal_Int32(0)) }; + + SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:Standard.Module1.TestInvoke?language=Basic&location=document", aParams, + aRet, aOutParamIndex, aOutParam); + + sal_Int32 aReturnValue; + aOutParam[0] >>= aReturnValue; + + // Without the fix in place, this test would have failed with + // - Expected: 100000 + // - Actual : 0 + + CPPUNIT_ASSERT_EQUAL(sal_Int32(100000), aReturnValue); + + css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(true); +} + ScMacrosTest::ScMacrosTest() : UnoApiTest("/sc/qa/extras/testdocuments") { diff --git a/sc/qa/extras/testdocuments/tdf133889.ods b/sc/qa/extras/testdocuments/tdf133889.ods Binary files differnew file mode 100644 index 000000000000..db87da6129a7 --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf133889.ods diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 16ffeb9dc9ee..4d6f2477ed92 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -210,6 +210,21 @@ namespace basprov if (auto* p = pInfo->GetParam(static_cast<sal_uInt16>(i) + 1)) { SbxDataType t = static_cast<SbxDataType>(p->eType & 0x0FFF); + // tdf#133889 Revert the downcasting performed in sbxToUnoValueImpl + // to allow passing by reference. + SbxDataType a = xSbxVar->GetType(); + if (t == SbxSINGLE && (a == SbxINTEGER || a == SbxLONG)) + { + sal_Int32 val = xSbxVar->GetLong(); + if (val >= -16777216 && val <= 16777215) + xSbxVar->SetType(t); + } + else if (t == SbxDOUBLE && (a == SbxINTEGER || a == SbxLONG)) + xSbxVar->SetType(t); + else if (t == SbxLONG && a == SbxINTEGER) + xSbxVar->SetType(t); + else if (t == SbxULONG && a == SbxUSHORT) + xSbxVar->SetType(t); // Enable passing by ref if (t != SbxVARIANT) xSbxVar->SetFlag(SbxFlagBits::Fixed); |