sc/qa/extras/macros-test.cxx | 33 +++++++++++++++++++++++++++++++ sc/qa/extras/testdocuments/tdf133887.ods |binary scripting/source/basprov/basscript.cxx | 15 ++++++++++---- 3 files changed, 44 insertions(+), 4 deletions(-)
New commits: commit 3b3591d3c127c306f4d5f6bbb34118b03c3124c0 Author: tushar <tusharrai...@gmail.com> AuthorDate: Sun Jan 10 21:22:11 2021 +0530 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Jan 18 12:44:05 2021 +0100 tdf#133887 Set flag of variable when formal parameter is not expecting variant. If there is no param info for formal paramter then type of formal parameter and actual parameter will be same and there is no need to set the flag in that case. Change-Id: I12af64f82fc5b2d6d7fb920bde1cb96f8c7bd51b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109070 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index b5a48353b4e4..00c8474a38b6 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -52,6 +52,7 @@ public: void testTdf128218(); void testTdf71271(); void testTdf43003(); + void testTdf133887(); CPPUNIT_TEST_SUITE(ScMacrosTest); CPPUNIT_TEST(testStarBasic); @@ -70,6 +71,7 @@ public: CPPUNIT_TEST(testTdf128218); CPPUNIT_TEST(testTdf71271); CPPUNIT_TEST(testTdf43003); + CPPUNIT_TEST(testTdf133887); CPPUNIT_TEST_SUITE_END(); }; @@ -864,6 +866,37 @@ void ScMacrosTest::testTdf43003() xCloseable->close(true); } +void ScMacrosTest::testTdf133887() +{ + OUString aFileName; + createFileURL(u"tdf133887.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_Int16(0)) }; + + SfxObjectShell::CallXScript( + xComponent, + "vnd.sun.Star.script:Standard.Module1.TestInvoke?language=Basic&location=document", aParams, + aRet, aOutParamIndex, aOutParam); + + double aReturnValue; + aOutParam[0] >>= aReturnValue; + + // Without the fix in place, this test would have failed with + // - Expected: 6.75 + // - Actual : 7 + + CPPUNIT_ASSERT_EQUAL(6.75, 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/tdf133887.ods b/sc/qa/extras/testdocuments/tdf133887.ods new file mode 100644 index 000000000000..92d135f5834a Binary files /dev/null and b/sc/qa/extras/testdocuments/tdf133887.ods differ diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 216e2fa99bd6..16ffeb9dc9ee 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -205,10 +205,17 @@ namespace basprov unoToSbxValue( xSbxVar.get(), pParams[i] ); xSbxParams->Put32( xSbxVar.get(), static_cast< sal_uInt32 >( i ) + 1 ); - // Enable passing by ref - if ( xSbxVar->GetType() != SbxVARIANT ) - xSbxVar->SetFlag( SbxFlagBits::Fixed ); - } + if (pInfo) + { + if (auto* p = pInfo->GetParam(static_cast<sal_uInt16>(i) + 1)) + { + SbxDataType t = static_cast<SbxDataType>(p->eType & 0x0FFF); + // Enable passing by ref + if (t != SbxVARIANT) + xSbxVar->SetFlag(SbxFlagBits::Fixed); + } + } + } } if ( xSbxParams.is() ) m_xMethod->SetParameters( xSbxParams.get() ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits