sc/qa/extras/macros-test.cxx             |    6 +++---
 sc/qa/extras/testdocuments/tdf143582.ods |binary
 scripting/source/basprov/basscript.cxx   |    3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 822998f1dc202aba7a558767f641687aef0c1148
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 22 14:55:01 2021 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 22 16:39:32 2021 +0100

    tdf#143582: Avoid error on clearing leftover return value of a method
    
    SbxValue::Clear happens to not error out on clearing string and some
    other types of objects, but for the rest, it calls SbxValue::Put, and
    the latter errors out if not CanWrite(). The original test implemented
    in commit 24d24debef4cda7de702c4b470a3707f1aae3ea3 only checked string
    return value, so happened to miss this problem.
    
    See similar code in SbiRuntime::FindElement.
    
    Change-Id: I7c17137cc9e7ee3133ee86a9f701559df66e53b6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127248
    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 a68b39ce1cbc..b18bb7ab52a1 100644
--- a/sc/qa/extras/macros-test.cxx
+++ b/sc/qa/extras/macros-test.cxx
@@ -1061,9 +1061,9 @@ void ScMacrosTest::testTdf143582()
     aRet >>= aReturnValue;
 
     // Without the fix in place, this test would have failed with
-    // - Expected: Test
-    // - Actual  : TeTest
-    CPPUNIT_ASSERT_EQUAL(OUString("Test"), aReturnValue);
+    // - Expected: Test6
+    // - Actual  : TeTest8
+    CPPUNIT_ASSERT_EQUAL(OUString("Test6"), aReturnValue);
 
     css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, 
css::uno::UNO_QUERY_THROW);
     xCloseable->close(true);
diff --git a/sc/qa/extras/testdocuments/tdf143582.ods 
b/sc/qa/extras/testdocuments/tdf143582.ods
index 05f4f07cea2c..1375bf5b9565 100644
Binary files a/sc/qa/extras/testdocuments/tdf143582.ods and 
b/sc/qa/extras/testdocuments/tdf143582.ods differ
diff --git a/scripting/source/basprov/basscript.cxx 
b/scripting/source/basprov/basscript.cxx
index 0b411c83f180..2cc67d4feb05 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -245,7 +245,10 @@ constexpr OUStringLiteral BASSCRIPT_PROPERTY_CALLER = 
u"Caller";
                 aOldThisComponent = 
m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( 
m_xDocumentScriptContext ) );
 
             // tdf#143582 - clear return value of the method before calling it
+            const SbxFlagBits nSavFlags = m_xMethod->GetFlags();
+            m_xMethod->SetFlag(SbxFlagBits::ReadWrite | 
SbxFlagBits::NoBroadcast);
             m_xMethod->Clear();
+            m_xMethod->SetFlags(nSavFlags);
             if ( m_caller.hasElements() && m_caller[ 0 ].hasValue()  )
             {
                 SbxVariableRef xCallerVar = new SbxVariable( SbxVARIANT );

Reply via email to