diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2022-01-31 20:02:50 +0100 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2022-02-03 09:43:37 +0100 |
commit | 6a0f00d3b9d1a74637c92ec6eff1ba5fedc82f3d (patch) | |
tree | 16b4cdcba938800bdfbd41582600cbfca3b98855 | |
parent | 65b09ef1c5e24651579eb11900cf2ddbbb7b0971 (diff) |
tdf#146742 - Move the initialization code of a method to SbMethod::Call
Change-Id: I516bacdcd22ed094a0e9b6e125e941f32fe88c82
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129238
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 6 | ||||
-rw-r--r-- | sc/qa/extras/macros-test.cxx | 30 | ||||
-rw-r--r-- | sc/qa/extras/testdocuments/tdf146742.ods | bin | 0 -> 10382 bytes | |||
-rw-r--r-- | scripting/source/basprov/basscript.cxx | 5 |
4 files changed, 36 insertions, 5 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 2d38de16dcfd..e9502a29aa13 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -2062,6 +2062,12 @@ ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller ) if( bInvalid && !pMod_->Compile() ) StarBASIC::Error( ERRCODE_BASIC_BAD_PROP_VALUE ); + // tdf#143582 - clear return value of the method before calling it + const SbxFlagBits nSavFlags = GetFlags(); + SetFlag(SbxFlagBits::ReadWrite | SbxFlagBits::NoBroadcast); + Clear(); + SetFlags(nSavFlags); + Get( aVals ); if ( pRet ) pRet->Put( aVals ); diff --git a/sc/qa/extras/macros-test.cxx b/sc/qa/extras/macros-test.cxx index 2326f101626e..a774129f5ae7 100644 --- a/sc/qa/extras/macros-test.cxx +++ b/sc/qa/extras/macros-test.cxx @@ -66,6 +66,7 @@ public: void testTdf143582(); void testTdf144085(); void testTdf130307(); + void testTdf146742(); void testMacroButtonFormControlXlsxExport(); CPPUNIT_TEST_SUITE(ScMacrosTest); @@ -92,6 +93,7 @@ public: CPPUNIT_TEST(testTdf143582); CPPUNIT_TEST(testTdf144085); CPPUNIT_TEST(testTdf130307); + CPPUNIT_TEST(testTdf146742); CPPUNIT_TEST(testMacroButtonFormControlXlsxExport); CPPUNIT_TEST_SUITE_END(); @@ -266,6 +268,34 @@ void ScMacrosTest::testRowColumn() pDocSh->DoClose(); } +void ScMacrosTest::testTdf146742() +{ + OUString aFileName; + createFileURL(u"tdf146742.ods", aFileName); + uno::Reference<css::lang::XComponent> xComponent = loadFromDesktop(aFileName, "com.sun.star.sheet.SpreadsheetDocument"); + + // Export to ODS and reload the file + saveAndReload(xComponent, "calc8"); + CPPUNIT_ASSERT(xComponent); + + SfxObjectShell* pFoundShell = SfxObjectShell::GetShellFromComponent(xComponent); + CPPUNIT_ASSERT_MESSAGE("Failed to access document shell", pFoundShell); + ScDocShell* pDocSh = static_cast<ScDocShell*>(pFoundShell); + ScDocument& rDoc = pDocSh->GetDocument(); + + CPPUNIT_ASSERT_EQUAL(OUString("1"), rDoc.GetString(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(OUString("2"), rDoc.GetString(ScAddress(0,1,0))); + + CPPUNIT_ASSERT_EQUAL(OUString("TRUE"), rDoc.GetString(ScAddress(1,0,0))); + // Without the fix in place, this test would have failed with + // - Expected: FALSE + // - Actual : TRUE + CPPUNIT_ASSERT_EQUAL(OUString("FALSE"), rDoc.GetString(ScAddress(1,1,0))); + + css::uno::Reference<css::util::XCloseable> xCloseable(xComponent, css::uno::UNO_QUERY_THROW); + xCloseable->close(true); +} + void ScMacrosTest::testMacroButtonFormControlXlsxExport() { // Given a button form control with an associated macro: diff --git a/sc/qa/extras/testdocuments/tdf146742.ods b/sc/qa/extras/testdocuments/tdf146742.ods Binary files differnew file mode 100644 index 000000000000..18ede8a040a0 --- /dev/null +++ b/sc/qa/extras/testdocuments/tdf146742.ods diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 2cc67d4feb05..9054ee4bfc27 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -244,11 +244,6 @@ constexpr OUStringLiteral BASSCRIPT_PROPERTY_CALLER = u"Caller"; if ( m_documentBasicManager && m_xDocumentScriptContext.is() ) 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 ); |