summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic/source/basmgr/basmgr.cxx19
-rw-r--r--include/basic/basmgr.hxx4
-rw-r--r--scripting/source/basprov/basscript.cxx2
-rw-r--r--sfx2/source/appl/macroloader.cxx2
4 files changed, 13 insertions, 14 deletions
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index fec7e5eaa496..4e01bff8cc9d 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -1367,25 +1367,24 @@ bool BasicManager::GetGlobalUNOConstant( const OUString& rName, uno::Any& aOut )
return bRes;
}
-uno::Any BasicManager::SetGlobalUNOConstant( const OUString& rName, const uno::Any& _rValue )
+void BasicManager::SetGlobalUNOConstant( const OUString& rName, const uno::Any& _rValue, css::uno::Any* pOldValue )
{
- uno::Any aOldValue;
-
StarBASIC* pStandardLib = GetStdLib();
OSL_PRECOND( pStandardLib, "BasicManager::SetGlobalUNOConstant: no lib to insert into!" );
if ( !pStandardLib )
- return aOldValue;
+ return;
- // obtain the old value
- SbxVariable* pVariable = pStandardLib->Find( rName, SbxClassType::Object );
- if ( pVariable )
- aOldValue = sbxToUnoValue( pVariable );
+ if (pOldValue)
+ {
+ // obtain the old value
+ SbxVariable* pVariable = pStandardLib->Find( rName, SbxClassType::Object );
+ if ( pVariable )
+ *pOldValue = sbxToUnoValue( pVariable );
+ }
SbxObjectRef xUnoObj = GetSbUnoObject( _rValue.getValueType ().getTypeName () , _rValue );
xUnoObj->SetName(rName);
xUnoObj->SetFlag( SbxFlagBits::DontStore );
pStandardLib->Insert( xUnoObj.get() );
-
- return aOldValue;
}
bool BasicManager::LegacyPsswdBinaryLimitExceeded( std::vector< OUString >& _out_rModuleNames )
diff --git a/include/basic/basmgr.hxx b/include/basic/basmgr.hxx
index 11c90fea1dfa..94fea1a0bf77 100644
--- a/include/basic/basmgr.hxx
+++ b/include/basic/basmgr.hxx
@@ -174,10 +174,10 @@ public:
/** sets a global constant in the basic library, referring to some UNO object, to a new value.
If a constant with this name already existed before, its value is changed, and the old constant is
- returned. If it does not yet exist, it is newly created, and inserted into the basic library.
+ returned in pOldValue. If it does not yet exist, it is newly created, and inserted into the basic library.
*/
IF_MERGELIBS(BASIC_DLLPUBLIC)
- css::uno::Any SetGlobalUNOConstant( const OUString& rName, const css::uno::Any& _rValue );
+ void SetGlobalUNOConstant( const OUString& rName, const css::uno::Any& _rValue, css::uno::Any* pOldValue = nullptr );
/** retrieves a global constant in the basic library, referring to some UNO object, returns true if a value is found ( value is in aOut ) false otherwise. */
IF_MERGELIBS(BASIC_DLLPUBLIC)
diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx
index d64fa5af4357..b5a3f6136534 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -242,7 +242,7 @@ constexpr OUStringLiteral BASSCRIPT_PROPERTY_CALLER = u"Caller";
// if it's a document-based script, temporarily reset ThisComponent to the script invocation context
Any aOldThisComponent;
if ( m_documentBasicManager && m_xDocumentScriptContext.is() )
- aOldThisComponent = m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", Any( m_xDocumentScriptContext ) );
+ m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", Any( m_xDocumentScriptContext ), &aOldThisComponent );
if ( m_caller.hasElements() && m_caller[ 0 ].hasValue() )
{
diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx
index fff7fc140450..0892bb78e4d9 100644
--- a/sfx2/source/appl/macroloader.cxx
+++ b/sfx2/source/appl/macroloader.cxx
@@ -275,7 +275,7 @@ ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, css::uno::Any& rRetval,
if ( bSetGlobalThisComponent )
{
// document is executed via AppBASIC, adjust ThisComponent variable
- aOldThisComponent = pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( pDoc->GetModel() ) );
+ pAppMgr->SetGlobalUNOConstant( "ThisComponent", Any( pDoc->GetModel() ), &aOldThisComponent );
}
// just to let the shell be alive