summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 14:35:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-19 08:30:49 +0200
commit8b0a69498b025e13d9772689e9e4fa3d6b05e609 (patch)
tree5fce654b3e02cd08d85dc95655c97d7181517687 /basic
parent5dccf84b14ed0e09262411295c5880f787342d59 (diff)
loplugin:flatten in basic
Change-Id: Icb8e3cda312b50c9a9f12f96bec1c746f41c8979 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92483 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/basmgr/basmgr.cxx144
-rw-r--r--basic/source/basmgr/vbahelper.cxx26
-rw-r--r--basic/source/classes/image.cxx48
-rw-r--r--basic/source/classes/sbunoobj.cxx958
-rw-r--r--basic/source/classes/sbxmod.cxx542
-rw-r--r--basic/source/comp/buffer.cxx42
-rw-r--r--basic/source/comp/dim.cxx198
-rw-r--r--basic/source/comp/exprgen.cxx76
-rw-r--r--basic/source/comp/exprnode.cxx336
-rw-r--r--basic/source/comp/parser.cxx70
-rw-r--r--basic/source/comp/symtbl.cxx80
-rw-r--r--basic/source/runtime/basrdll.cxx30
-rw-r--r--basic/source/runtime/iosys.cxx124
-rw-r--r--basic/source/runtime/methods.cxx82
-rw-r--r--basic/source/runtime/runtime.cxx181
-rw-r--r--basic/source/runtime/stdobj.cxx46
-rw-r--r--basic/source/runtime/stdobj1.cxx126
-rw-r--r--basic/source/sbx/sbxobj.cxx236
-rw-r--r--basic/source/sbx/sbxvar.cxx56
-rw-r--r--basic/source/uno/namecont.cxx763
-rw-r--r--basic/source/uno/scriptcont.cxx54
21 files changed, 2110 insertions, 2108 deletions
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 764e5d70150e..753aaf04b201 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -179,27 +179,27 @@ void BasMgrContainerListenerImpl::addLibraryModulesImpl( BasicManager const * pM
StarBASIC* pLib = pMgr->GetLib( aLibName );
DBG_ASSERT( pLib, "BasMgrContainerListenerImpl::addLibraryModulesImpl: Unknown lib!");
- if( pLib )
+ if( !pLib )
+ return;
+
+ const OUString* pNames = aModuleNames.getConstArray();
+ for( sal_Int32 j = 0 ; j < nModuleCount ; j++ )
{
- const OUString* pNames = aModuleNames.getConstArray();
- for( sal_Int32 j = 0 ; j < nModuleCount ; j++ )
+ OUString aModuleName = pNames[ j ];
+ uno::Any aElement = xLibNameAccess->getByName( aModuleName );
+ OUString aMod;
+ aElement >>= aMod;
+ uno::Reference< vba::XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, uno::UNO_QUERY );
+ if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aModuleName ) )
{
- OUString aModuleName = pNames[ j ];
- uno::Any aElement = xLibNameAccess->getByName( aModuleName );
- OUString aMod;
- aElement >>= aMod;
- uno::Reference< vba::XVBAModuleInfo > xVBAModuleInfo( xLibNameAccess, uno::UNO_QUERY );
- if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( aModuleName ) )
- {
- ModuleInfo aInfo = xVBAModuleInfo->getModuleInfo( aModuleName );
- pLib->MakeModule( aModuleName, aInfo, aMod );
- }
- else
- pLib->MakeModule( aModuleName, aMod );
+ ModuleInfo aInfo = xVBAModuleInfo->getModuleInfo( aModuleName );
+ pLib->MakeModule( aModuleName, aInfo, aMod );
}
-
- pLib->SetModified( false );
+ else
+ pLib->MakeModule( aModuleName, aMod );
}
+
+ pLib->SetModified( false );
}
@@ -266,19 +266,19 @@ void SAL_CALL BasMgrContainerListenerImpl::elementReplaced( const container::Con
DBG_ASSERT( !maLibName.isEmpty(), "library container fired elementReplaced()");
StarBASIC* pLib = mpMgr->GetLib( maLibName );
- if( pLib )
- {
- SbModule* pMod = pLib->FindModule( aName );
- OUString aMod;
- Event.Element >>= aMod;
+ if( !pLib )
+ return;
- if( pMod )
- pMod->SetSource32( aMod );
- else
- pLib->MakeModule( aName, aMod );
+ SbModule* pMod = pLib->FindModule( aName );
+ OUString aMod;
+ Event.Element >>= aMod;
- pLib->SetModified( false );
- }
+ if( pMod )
+ pMod->SetSource32( aMod );
+ else
+ pLib->MakeModule( aName, aMod );
+
+ pLib->SetModified( false );
}
@@ -770,51 +770,51 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage )
xManagerStream->SetBufferSize( 0 );
xManagerStream.clear(); // Close stream
- if ( !aLibs.isEmpty() )
- {
- INetURLObject aCurStorage( aStorName, INetProtocol::File );
- sal_Int32 nLibPos {0};
- do {
- const OUString aLibInfo(aLibs.getToken(0, LIB_SEP, nLibPos));
- sal_Int32 nInfoPos {0};
- const OUString aLibName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
- DBG_ASSERT( nInfoPos >= 0, "Invalid Lib-Info!" );
- const OUString aLibAbsStorageName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
- // TODO: fail also here if there are no more tokens?
- const OUString aLibRelStorageName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
- DBG_ASSERT( nInfoPos < 0, "Invalid Lib-Info!" );
- INetURLObject aLibAbsStorage( aLibAbsStorageName, INetProtocol::File );
-
- INetURLObject aLibRelStorage( aStorName );
- aLibRelStorage.removeSegment();
- bool bWasAbsolute = false;
- aLibRelStorage = aLibRelStorage.smartRel2Abs( aLibRelStorageName, bWasAbsolute);
- DBG_ASSERT(!bWasAbsolute, "RelStorageName was absolute!" );
+ if ( aLibs.isEmpty() )
+ return;
- tools::SvRef<SotStorage> xStorageRef;
- if ( aLibAbsStorage == aCurStorage || aLibRelStorageName == szImbedded )
- {
- xStorageRef = &rStorage;
- }
- else
- {
- xStorageRef = new SotStorage( false, aLibAbsStorage.GetMainURL
- ( INetURLObject::DecodeMechanism::NONE ), eStorageReadMode );
- if ( xStorageRef->GetError() != ERRCODE_NONE )
- xStorageRef = new SotStorage( false, aLibRelStorage.
- GetMainURL( INetURLObject::DecodeMechanism::NONE ), eStorageReadMode );
- }
- if ( xStorageRef.is() )
- {
- AddLib( *xStorageRef, aLibName, false );
- }
- else
- {
- StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, DialogMask::ButtonsOk );
- aErrors.emplace_back(*pErrInf, BasicErrorReason::STORAGENOTFOUND);
- }
- } while (nLibPos>=0);
- }
+ INetURLObject aCurStorage( aStorName, INetProtocol::File );
+ sal_Int32 nLibPos {0};
+ do {
+ const OUString aLibInfo(aLibs.getToken(0, LIB_SEP, nLibPos));
+ sal_Int32 nInfoPos {0};
+ const OUString aLibName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
+ DBG_ASSERT( nInfoPos >= 0, "Invalid Lib-Info!" );
+ const OUString aLibAbsStorageName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
+ // TODO: fail also here if there are no more tokens?
+ const OUString aLibRelStorageName( aLibInfo.getToken( 0, LIBINFO_SEP, nInfoPos ) );
+ DBG_ASSERT( nInfoPos < 0, "Invalid Lib-Info!" );
+ INetURLObject aLibAbsStorage( aLibAbsStorageName, INetProtocol::File );
+
+ INetURLObject aLibRelStorage( aStorName );
+ aLibRelStorage.removeSegment();
+ bool bWasAbsolute = false;
+ aLibRelStorage = aLibRelStorage.smartRel2Abs( aLibRelStorageName, bWasAbsolute);
+ DBG_ASSERT(!bWasAbsolute, "RelStorageName was absolute!" );
+
+ tools::SvRef<SotStorage> xStorageRef;
+ if ( aLibAbsStorage == aCurStorage || aLibRelStorageName == szImbedded )
+ {
+ xStorageRef = &rStorage;
+ }
+ else
+ {
+ xStorageRef = new SotStorage( false, aLibAbsStorage.GetMainURL
+ ( INetURLObject::DecodeMechanism::NONE ), eStorageReadMode );
+ if ( xStorageRef->GetError() != ERRCODE_NONE )
+ xStorageRef = new SotStorage( false, aLibRelStorage.
+ GetMainURL( INetURLObject::DecodeMechanism::NONE ), eStorageReadMode );
+ }
+ if ( xStorageRef.is() )
+ {
+ AddLib( *xStorageRef, aLibName, false );
+ }
+ else
+ {
+ StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, DialogMask::ButtonsOk );
+ aErrors.emplace_back(*pErrInf, BasicErrorReason::STORAGENOTFOUND);
+ }
+ } while (nLibPos>=0);
}
BasicManager::~BasicManager()
diff --git a/basic/source/basmgr/vbahelper.cxx b/basic/source/basmgr/vbahelper.cxx
index 231452612051..83165374a8f1 100644
--- a/basic/source/basmgr/vbahelper.cxx
+++ b/basic/source/basmgr/vbahelper.cxx
@@ -164,20 +164,20 @@ void enableContainerWindowsOfAllDocuments( const uno::Reference< frame::XModel >
void registerCurrentDirectory( const uno::Reference< frame::XModel >& rxModel, const OUString& rPath )
{
- if( !rPath.isEmpty() )
+ if( rPath.isEmpty() )
+ return;
+
+ CurrDirPool& rPool = StaticCurrDirPool::get();
+ ::osl::MutexGuard aGuard( rPool.maMutex );
+ try
+ {
+ uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() );
+ OUString aIdentifier = xModuleManager->identify( rxModel );
+ if( !aIdentifier.isEmpty() )
+ rPool.maCurrDirs[ aIdentifier ] = rPath;
+ }
+ catch(const uno::Exception& )
{
- CurrDirPool& rPool = StaticCurrDirPool::get();
- ::osl::MutexGuard aGuard( rPool.maMutex );
- try
- {
- uno::Reference< frame::XModuleManager2 > xModuleManager( lclCreateModuleManager() );
- OUString aIdentifier = xModuleManager->identify( rxModel );
- if( !aIdentifier.isEmpty() )
- rPool.maCurrDirs[ aIdentifier ] = rPath;
- }
- catch(const uno::Exception& )
- {
- }
}
}
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index a7f6c75a4bdc..e6e277647459 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -589,33 +589,33 @@ void SbiImage::AddString( const OUString& r )
{
bError = true;
}
+ if( bError )
+ return;
+
+ sal_Int32 len = r.getLength() + 1;
+ sal_uInt32 needed = nStringOff + len;
+ if( needed > 0xFFFFFF00 )
+ {
+ bError = true; // out of mem!
+ }
+ else if( needed > nStringSize )
+ {
+ sal_uInt32 nNewLen = needed + 1024;
+ nNewLen &= 0xFFFFFC00; // trim to 1K border
+ std::unique_ptr<sal_Unicode[]> p(new sal_Unicode[nNewLen]);
+ memcpy( p.get(), pStrings.get(), nStringSize * sizeof( sal_Unicode ) );
+ pStrings = std::move(p);
+ nStringSize = sal::static_int_cast< sal_uInt16 >(nNewLen);
+ }
if( !bError )
{
- sal_Int32 len = r.getLength() + 1;
- sal_uInt32 needed = nStringOff + len;
- if( needed > 0xFFFFFF00 )
+ mvStringOffsets[ nStringIdx++ ] = nStringOff;
+ memcpy( pStrings.get() + nStringOff, r.getStr(), len * sizeof( sal_Unicode ) );
+ nStringOff = nStringOff + len;
+ // Last String? The update the size of the buffer
+ if( nStringIdx >= short(mvStringOffsets.size()) )
{
- bError = true; // out of mem!
- }
- else if( needed > nStringSize )
- {
- sal_uInt32 nNewLen = needed + 1024;
- nNewLen &= 0xFFFFFC00; // trim to 1K border
- std::unique_ptr<sal_Unicode[]> p(new sal_Unicode[nNewLen]);
- memcpy( p.get(), pStrings.get(), nStringSize * sizeof( sal_Unicode ) );
- pStrings = std::move(p);
- nStringSize = sal::static_int_cast< sal_uInt16 >(nNewLen);
- }
- if( !bError )
- {
- mvStringOffsets[ nStringIdx++ ] = nStringOff;
- memcpy( pStrings.get() + nStringOff, r.getStr(), len * sizeof( sal_Unicode ) );
- nStringOff = nStringOff + len;
- // Last String? The update the size of the buffer
- if( nStringIdx >= short(mvStringOffsets.size()) )
- {
- nStringSize = nStringOff;
- }
+ nStringSize = nStringOff;
}
}
}
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index deef49e6af1c..1da0bf1b0314 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -1999,299 +1999,299 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
doIntrospection();
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
+ if( !pHint )
+ return;
+
+ SbxVariable* pVar = pHint->GetVar();
+ SbxArray* pParams = pVar->GetParameters();
+ SbUnoProperty* pProp = dynamic_cast<SbUnoProperty*>( pVar );
+ SbUnoMethod* pMeth = dynamic_cast<SbUnoMethod*>( pVar );
+ if( pProp )
{
- SbxVariable* pVar = pHint->GetVar();
- SbxArray* pParams = pVar->GetParameters();
- SbUnoProperty* pProp = dynamic_cast<SbUnoProperty*>( pVar );
- SbUnoMethod* pMeth = dynamic_cast<SbUnoMethod*>( pVar );
- if( pProp )
+ bool bInvocation = pProp->isInvocationBased();
+ if( pHint->GetId() == SfxHintId::BasicDataWanted )
{
- bool bInvocation = pProp->isInvocationBased();
- if( pHint->GetId() == SfxHintId::BasicDataWanted )
+ // Test-Properties
+ sal_Int32 nId = pProp->nId;
+ if( nId < 0 )
{
- // Test-Properties
- sal_Int32 nId = pProp->nId;
- if( nId < 0 )
+ // Id == -1: Display implemented interfaces according the ClassProvider
+ if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
{
- // Id == -1: Display implemented interfaces according the ClassProvider
- if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
- {
- OUString aRetStr = Impl_GetSupportedInterfaces(*this);
- pVar->PutString( aRetStr );
- }
- // Id == -2: output properties
- else if( nId == -2 ) // Property ID_DBG_PROPERTIES
- {
- // now all properties must be created
- implCreateAll();
- OUString aRetStr = Impl_DumpProperties(*this);
- pVar->PutString( aRetStr );
- }
- // Id == -3: output the methods
- else if( nId == -3 ) // Property ID_DBG_METHODS
- {
- // now all properties must be created
- implCreateAll();
- OUString aRetStr = Impl_DumpMethods(*this);
- pVar->PutString( aRetStr );
- }
- return;
+ OUString aRetStr = Impl_GetSupportedInterfaces(*this);
+ pVar->PutString( aRetStr );
+ }
+ // Id == -2: output properties
+ else if( nId == -2 ) // Property ID_DBG_PROPERTIES
+ {
+ // now all properties must be created
+ implCreateAll();
+ OUString aRetStr = Impl_DumpProperties(*this);
+ pVar->PutString( aRetStr );
+ }
+ // Id == -3: output the methods
+ else if( nId == -3 ) // Property ID_DBG_METHODS
+ {
+ // now all properties must be created
+ implCreateAll();
+ OUString aRetStr = Impl_DumpMethods(*this);
+ pVar->PutString( aRetStr );
}
+ return;
+ }
- if( !bInvocation && mxUnoAccess.is() )
+ if( !bInvocation && mxUnoAccess.is() )
+ {
+ try
{
- try
+ if ( maStructInfo.get() )
{
- if ( maStructInfo.get() )
+ StructRefInfo aMember = maStructInfo->getStructMember( pProp->GetName() );
+ if ( aMember.isEmpty() )
+ {
+ StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
+ }
+ else
{
- StructRefInfo aMember = maStructInfo->getStructMember( pProp->GetName() );
- if ( aMember.isEmpty() )
+ if ( pProp->isUnoStruct() )
{
- StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
+ SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), aMember );
+ SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject);
+ pVar->PutObject( xWrapper.get() );
}
else
{
- if ( pProp->isUnoStruct() )
- {
- SbUnoStructRefObject* pSbUnoObject = new SbUnoStructRefObject( pProp->GetName(), aMember );
- SbxObjectRef xWrapper = static_cast<SbxObject*>(pSbUnoObject);
- pVar->PutObject( xWrapper.get() );
- }
- else
- {
- Any aRetAny = aMember.getValue();
- // take over the value from Uno to Sbx
- unoToSbxValue( pVar, aRetAny );
- }
- return;
+ Any aRetAny = aMember.getValue();
+ // take over the value from Uno to Sbx
+ unoToSbxValue( pVar, aRetAny );
}
+ return;
}
- // get the value
- Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
- Any aRetAny = xPropSet->getPropertyValue( pProp->GetName() );
- // The use of getPropertyValue (instead of using the index) is
- // suboptimal, but the refactoring to XInvocation is already pending
- // Otherwise it is possible to use FastPropertySet
-
- // take over the value from Uno to Sbx
- unoToSbxValue( pVar, aRetAny );
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
}
+ // get the value
+ Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
+ Any aRetAny = xPropSet->getPropertyValue( pProp->GetName() );
+ // The use of getPropertyValue (instead of using the index) is
+ // suboptimal, but the refactoring to XInvocation is already pending
+ // Otherwise it is possible to use FastPropertySet
+
+ // take over the value from Uno to Sbx
+ unoToSbxValue( pVar, aRetAny );
}
- else if( bInvocation && mxInvocation.is() )
+ catch( const Exception& )
{
- try
- {
- sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0;
- bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() );
- Any aRetAny;
- if ( bCanBeConsideredAMethod && nParamCount )
- {
- // Automation properties have methods, so... we need to invoke this through
- // XInvocation
- Sequence<Any> args;
- processAutomationParams( pParams, args, nParamCount );
- aRetAny = invokeAutomationMethod( pProp->GetName(), args, pParams, nParamCount, mxInvocation, INVOKETYPE::GetProp );
- }
- else
- aRetAny = mxInvocation->getValue( pProp->GetName() );
- // take over the value from Uno to Sbx
- unoToSbxValue( pVar, aRetAny );
- if( pParams && bCanBeConsideredAMethod )
- pVar->SetParameters( nullptr );
-
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
- }
+ implHandleAnyException( ::cppu::getCaughtException() );
}
}
- else if( pHint->GetId() == SfxHintId::BasicDataChanged )
+ else if( bInvocation && mxInvocation.is() )
{
- if( !bInvocation && mxUnoAccess.is() )
+ try
{
- if( pProp->aUnoProp.Attributes & PropertyAttribute::READONLY )
+ sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0;
+ bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() );
+ Any aRetAny;
+ if ( bCanBeConsideredAMethod && nParamCount )
{
- StarBASIC::Error( ERRCODE_BASIC_PROP_READONLY );
- return;
+ // Automation properties have methods, so... we need to invoke this through
+ // XInvocation
+ Sequence<Any> args;
+ processAutomationParams( pParams, args, nParamCount );
+ aRetAny = invokeAutomationMethod( pProp->GetName(), args, pParams, nParamCount, mxInvocation, INVOKETYPE::GetProp );
}
- if ( maStructInfo.get() )
- {
- StructRefInfo aMember = maStructInfo->getStructMember( pProp->GetName() );
- if ( aMember.isEmpty() )
- {
- StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
- }
- else
- {
- Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
- aMember.setValue( aAnyValue );
- }
- return;
- }
+ else
+ aRetAny = mxInvocation->getValue( pProp->GetName() );
// take over the value from Uno to Sbx
- Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
- try
- {
- // set the value
- Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
- xPropSet->setPropertyValue( pProp->GetName(), aAnyValue );
- // The use of getPropertyValue (instead of using the index) is
- // suboptimal, but the refactoring to XInvocation is already pending
- // Otherwise it is possible to use FastPropertySet
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
- }
+ unoToSbxValue( pVar, aRetAny );
+ if( pParams && bCanBeConsideredAMethod )
+ pVar->SetParameters( nullptr );
+
}
- else if( bInvocation && mxInvocation.is() )
+ catch( const Exception& )
{
- // take over the value from Uno to Sbx
- Any aAnyValue = sbxToUnoValueImpl( pVar );
- try
+ implHandleAnyException( ::cppu::getCaughtException() );
+ }
+ }
+ }
+ else if( pHint->GetId() == SfxHintId::BasicDataChanged )
+ {
+ if( !bInvocation && mxUnoAccess.is() )
+ {
+ if( pProp->aUnoProp.Attributes & PropertyAttribute::READONLY )
+ {
+ StarBASIC::Error( ERRCODE_BASIC_PROP_READONLY );
+ return;
+ }
+ if ( maStructInfo.get() )
+ {
+ StructRefInfo aMember = maStructInfo->getStructMember( pProp->GetName() );
+ if ( aMember.isEmpty() )
{
- // set the value
- mxInvocation->setValue( pProp->GetName(), aAnyValue );
+ StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
}
- catch( const Exception& )
+ else
{
- implHandleAnyException( ::cppu::getCaughtException() );
+ Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
+ aMember.setValue( aAnyValue );
}
+ return;
+ }
+ // take over the value from Uno to Sbx
+ Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
+ try
+ {
+ // set the value
+ Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( cppu::UnoType<XPropertySet>::get()), UNO_QUERY );
+ xPropSet->setPropertyValue( pProp->GetName(), aAnyValue );
+ // The use of getPropertyValue (instead of using the index) is
+ // suboptimal, but the refactoring to XInvocation is already pending
+ // Otherwise it is possible to use FastPropertySet
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
+ }
+ }
+ else if( bInvocation && mxInvocation.is() )
+ {
+ // take over the value from Uno to Sbx
+ Any aAnyValue = sbxToUnoValueImpl( pVar );
+ try
+ {
+ // set the value
+ mxInvocation->setValue( pProp->GetName(), aAnyValue );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
}
}
}
- else if( pMeth )
+ }
+ else if( pMeth )
+ {
+ bool bInvocation = pMeth->isInvocationBased();
+ if( pHint->GetId() == SfxHintId::BasicDataWanted )
{
- bool bInvocation = pMeth->isInvocationBased();
- if( pHint->GetId() == SfxHintId::BasicDataWanted )
- {
- // number of Parameter -1 because of Param0 == this
- sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0;
- Sequence<Any> args;
- bool bOutParams = false;
+ // number of Parameter -1 because of Param0 == this
+ sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0;
+ Sequence<Any> args;
+ bool bOutParams = false;
- if( !bInvocation && mxUnoAccess.is() )
+ if( !bInvocation && mxUnoAccess.is() )
+ {
+ // get info
+ const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
+ const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
+ sal_uInt32 nUnoParamCount = rInfoSeq.getLength();
+ sal_uInt32 nAllocParamCount = nParamCount;
+
+ // ignore surplus parameter; alternative: throw an error
+ if( nParamCount > nUnoParamCount )
{
- // get info
- const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
- const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
- sal_uInt32 nUnoParamCount = rInfoSeq.getLength();
- sal_uInt32 nAllocParamCount = nParamCount;
-
- // ignore surplus parameter; alternative: throw an error
- if( nParamCount > nUnoParamCount )
- {
- nParamCount = nUnoParamCount;
- nAllocParamCount = nParamCount;
- }
- else if( nParamCount < nUnoParamCount )
+ nParamCount = nUnoParamCount;
+ nAllocParamCount = nParamCount;
+ }
+ else if( nParamCount < nUnoParamCount )
+ {
+ SbiInstance* pInst = GetSbData()->pInst;
+ if( pInst && pInst->IsCompatibility() )
{
- SbiInstance* pInst = GetSbData()->pInst;
- if( pInst && pInst->IsCompatibility() )
+ // Check types
+ bool bError = false;
+ for( sal_uInt32 i = nParamCount ; i < nUnoParamCount ; i++ )
{
- // Check types
- bool bError = false;
- for( sal_uInt32 i = nParamCount ; i < nUnoParamCount ; i++ )
+ const ParamInfo& rInfo = pParamInfos[i];
+ const Reference< XIdlClass >& rxClass = rInfo.aType;
+ if( rxClass->getTypeClass() != TypeClass_ANY )
{
- const ParamInfo& rInfo = pParamInfos[i];
- const Reference< XIdlClass >& rxClass = rInfo.aType;
- if( rxClass->getTypeClass() != TypeClass_ANY )
- {
- bError = true;
- StarBASIC::Error( ERRCODE_BASIC_NOT_OPTIONAL );
- }
+ bError = true;
+ StarBASIC::Error( ERRCODE_BASIC_NOT_OPTIONAL );
}
- if( !bError )
- nAllocParamCount = nUnoParamCount;
}
+ if( !bError )
+ nAllocParamCount = nUnoParamCount;
}
+ }
- if( nAllocParamCount > 0 )
+ if( nAllocParamCount > 0 )
+ {
+ args.realloc( nAllocParamCount );
+ Any* pAnyArgs = args.getArray();
+ for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
{
- args.realloc( nAllocParamCount );
- Any* pAnyArgs = args.getArray();
- for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
- {
- const ParamInfo& rInfo = pParamInfos[i];
- const Reference< XIdlClass >& rxClass = rInfo.aType;
+ const ParamInfo& rInfo = pParamInfos[i];
+ const Reference< XIdlClass >& rxClass = rInfo.aType;
- css::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() );
+ css::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() );
- // ATTENTION: Don't forget for Sbx-Parameter the offset!
- pAnyArgs[i] = sbxToUnoValue( pParams->Get32(i + 1), aType );
+ // ATTENTION: Don't forget for Sbx-Parameter the offset!
+ pAnyArgs[i] = sbxToUnoValue( pParams->Get32(i + 1), aType );
- // If it is not certain check whether the out-parameter are available.
- if( !bOutParams )
- {
- ParamMode aParamMode = rInfo.aMode;
- if( aParamMode != ParamMode_IN )
- bOutParams = true;
- }
+ // If it is not certain check whether the out-parameter are available.
+ if( !bOutParams )
+ {
+ ParamMode aParamMode = rInfo.aMode;
+ if( aParamMode != ParamMode_IN )
+ bOutParams = true;
}
}
}
- else if( bInvocation && pParams && mxInvocation.is() )
- {
- processAutomationParams( pParams, args, nParamCount );
- }
+ }
+ else if( bInvocation && pParams && mxInvocation.is() )
+ {
+ processAutomationParams( pParams, args, nParamCount );
+ }
- // call the method
- GetSbData()->bBlockCompilerError = true; // #106433 Block compiler errors for API calls
- try
+ // call the method
+ GetSbData()->bBlockCompilerError = true; // #106433 Block compiler errors for API calls
+ try
+ {
+ if( !bInvocation && mxUnoAccess.is() )
{
- if( !bInvocation && mxUnoAccess.is() )
- {
- Any aRetAny = pMeth->m_xUnoMethod->invoke( getUnoAny(), args );
+ Any aRetAny = pMeth->m_xUnoMethod->invoke( getUnoAny(), args );
- // take over the value from Uno to Sbx
- unoToSbxValue( pVar, aRetAny );
+ // take over the value from Uno to Sbx
+ unoToSbxValue( pVar, aRetAny );
- // Did we to copy back the Out-Parameter?
- if( bOutParams )
- {
- const Any* pAnyArgs = args.getConstArray();
+ // Did we to copy back the Out-Parameter?
+ if( bOutParams )
+ {
+ const Any* pAnyArgs = args.getConstArray();
- // get info
- const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
- const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
+ // get info
+ const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
+ const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
- sal_uInt32 j;
- for( j = 0 ; j < nParamCount ; j++ )
- {
- const ParamInfo& rInfo = pParamInfos[j];
- ParamMode aParamMode = rInfo.aMode;
- if( aParamMode != ParamMode_IN )
- unoToSbxValue( pParams->Get32(j + 1), pAnyArgs[ j ] );
- }
+ sal_uInt32 j;
+ for( j = 0 ; j < nParamCount ; j++ )
+ {
+ const ParamInfo& rInfo = pParamInfos[j];
+ ParamMode aParamMode = rInfo.aMode;
+ if( aParamMode != ParamMode_IN )
+ unoToSbxValue( pParams->Get32(j + 1), pAnyArgs[ j ] );
}
}
- else if( bInvocation && mxInvocation.is() )
- {
- Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation, INVOKETYPE::Func );
- unoToSbxValue( pVar, aRetAny );
- }
-
- // remove parameter here, because this was not done anymore in unoToSbxValue()
- // for arrays
- if( pParams )
- pVar->SetParameters( nullptr );
}
- catch( const Exception& )
+ else if( bInvocation && mxInvocation.is() )
{
- implHandleAnyException( ::cppu::getCaughtException() );
- }
- GetSbData()->bBlockCompilerError = false; // #106433 Unblock compiler errors
+ Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation, INVOKETYPE::Func );
+ unoToSbxValue( pVar, aRetAny );
+ }
+
+ // remove parameter here, because this was not done anymore in unoToSbxValue()
+ // for arrays
+ if( pParams )
+ pVar->SetParameters( nullptr );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
}
+ GetSbData()->bBlockCompilerError = false; // #106433 Unblock compiler errors
}
- else
- SbxObject::Notify( rBC, rHint );
}
+ else
+ SbxObject::Notify( rBC, rHint );
}
@@ -3233,47 +3233,47 @@ VBAConstantHelper::instance()
void VBAConstantHelper::init()
{
- if ( !isInited )
- {
- Sequence< TypeClass > types(1);
- types[ 0 ] = TypeClass_CONSTANTS;
- Reference< XTypeDescriptionEnumeration > xEnum = getTypeDescriptorEnumeration( "ooo.vba", types, TypeDescriptionSearchDepth_INFINITE );
+ if ( isInited )
+ return;
- if ( !xEnum.is())
- {
- return; //NULL;
- }
- while ( xEnum->hasMoreElements() )
+ Sequence< TypeClass > types(1);
+ types[ 0 ] = TypeClass_CONSTANTS;
+ Reference< XTypeDescriptionEnumeration > xEnum = getTypeDescriptorEnumeration( "ooo.vba", types, TypeDescriptionSearchDepth_INFINITE );
+
+ if ( !xEnum.is())
+ {
+ return; //NULL;
+ }
+ while ( xEnum->hasMoreElements() )
+ {
+ Reference< XConstantsTypeDescription > xConstants( xEnum->nextElement(), UNO_QUERY );
+ if ( xConstants.is() )
{
- Reference< XConstantsTypeDescription > xConstants( xEnum->nextElement(), UNO_QUERY );
- if ( xConstants.is() )
+ // store constant group name
+ OUString sFullName = xConstants->getName();
+ sal_Int32 indexLastDot = sFullName.lastIndexOf('.');
+ OUString sLeafName( sFullName );
+ if ( indexLastDot > -1 )
{
- // store constant group name
- OUString sFullName = xConstants->getName();
- sal_Int32 indexLastDot = sFullName.lastIndexOf('.');
- OUString sLeafName( sFullName );
+ sLeafName = sFullName.copy( indexLastDot + 1);
+ }
+ aConstCache.push_back( sLeafName ); // assume constant group names are unique
+ Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
+ for (sal_Int32 i = 0; i != aConsts.getLength(); ++i)
+ {
+ // store constant member name
+ sFullName = aConsts[i]->getName();
+ indexLastDot = sFullName.lastIndexOf('.');
+ sLeafName = sFullName;
if ( indexLastDot > -1 )
{
sLeafName = sFullName.copy( indexLastDot + 1);
}
- aConstCache.push_back( sLeafName ); // assume constant group names are unique
- Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants();
- for (sal_Int32 i = 0; i != aConsts.getLength(); ++i)
- {
- // store constant member name
- sFullName = aConsts[i]->getName();
- indexLastDot = sFullName.lastIndexOf('.');
- sLeafName = sFullName;
- if ( indexLastDot > -1 )
- {
- sLeafName = sFullName.copy( indexLastDot + 1);
- }
- aConstHash[ sLeafName.toAsciiLowerCase() ] = aConsts[i]->getConstantValue();
- }
+ aConstHash[ sLeafName.toAsciiLowerCase() ] = aConsts[i]->getConstantValue();
}
}
- isInited = true;
}
+ isInited = true;
}
bool
@@ -3532,151 +3532,151 @@ SbxVariable* SbUnoService::Find( const OUString& rName, SbxClassType )
void SbUnoService::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
+ if( !pHint )
+ return;
+
+ SbxVariable* pVar = pHint->GetVar();
+ SbxArray* pParams = pVar->GetParameters();
+ SbUnoServiceCtor* pUnoCtor = dynamic_cast<SbUnoServiceCtor*>( pVar );
+ if( pUnoCtor && pHint->GetId() == SfxHintId::BasicDataWanted )
{
- SbxVariable* pVar = pHint->GetVar();
- SbxArray* pParams = pVar->GetParameters();
- SbUnoServiceCtor* pUnoCtor = dynamic_cast<SbUnoServiceCtor*>( pVar );
- if( pUnoCtor && pHint->GetId() == SfxHintId::BasicDataWanted )
- {
- // Parameter count -1 because of Param0 == this
- sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0;
- Sequence<Any> args;
+ // Parameter count -1 because of Param0 == this
+ sal_uInt32 nParamCount = pParams ? (pParams->Count32() - 1) : 0;
+ Sequence<Any> args;
- Reference< XServiceConstructorDescription > xCtor = pUnoCtor->getServiceCtorDesc();
- Sequence< Reference< XParameter > > aParameterSeq = xCtor->getParameters();
- const Reference< XParameter >* pParameterSeq = aParameterSeq.getConstArray();
- sal_uInt32 nUnoParamCount = aParameterSeq.getLength();
+ Reference< XServiceConstructorDescription > xCtor = pUnoCtor->getServiceCtorDesc();
+ Sequence< Reference< XParameter > > aParameterSeq = xCtor->getParameters();
+ const Reference< XParameter >* pParameterSeq = aParameterSeq.getConstArray();
+ sal_uInt32 nUnoParamCount = aParameterSeq.getLength();
- // Default: Ignore not needed parameters
- bool bParameterError = false;
+ // Default: Ignore not needed parameters
+ bool bParameterError = false;
- // Is the last parameter a rest parameter?
- bool bRestParameterMode = false;
- if( nUnoParamCount > 0 )
+ // Is the last parameter a rest parameter?
+ bool bRestParameterMode = false;
+ if( nUnoParamCount > 0 )
+ {
+ Reference< XParameter > xLastParam = pParameterSeq[ nUnoParamCount - 1 ];
+ if( xLastParam.is() )
{
- Reference< XParameter > xLastParam = pParameterSeq[ nUnoParamCount - 1 ];
- if( xLastParam.is() )
- {
- if( xLastParam->isRestParameter() )
- bRestParameterMode = true;
- }
+ if( xLastParam->isRestParameter() )
+ bRestParameterMode = true;
}
+ }
- // Too many parameters with context as first parameter?
- sal_uInt32 nSbxParameterOffset = 1;
- sal_uInt32 nParameterOffsetByContext = 0;
- Reference < XComponentContext > xFirstParamContext;
- if( nParamCount > nUnoParamCount )
- {
- // Check if first parameter is a context and use it
- // then in createInstanceWithArgumentsAndContext
- Any aArg0 = sbxToUnoValue( pParams->Get32( nSbxParameterOffset ) );
- if( (aArg0 >>= xFirstParamContext) && xFirstParamContext.is() )
- nParameterOffsetByContext = 1;
- }
+ // Too many parameters with context as first parameter?
+ sal_uInt32 nSbxParameterOffset = 1;
+ sal_uInt32 nParameterOffsetByContext = 0;
+ Reference < XComponentContext > xFirstParamContext;
+ if( nParamCount > nUnoParamCount )
+ {
+ // Check if first parameter is a context and use it
+ // then in createInstanceWithArgumentsAndContext
+ Any aArg0 = sbxToUnoValue( pParams->Get32( nSbxParameterOffset ) );
+ if( (aArg0 >>= xFirstParamContext) && xFirstParamContext.is() )
+ nParameterOffsetByContext = 1;
+ }
- sal_uInt32 nEffectiveParamCount = nParamCount - nParameterOffsetByContext;
- sal_uInt32 nAllocParamCount = nEffectiveParamCount;
- if( nEffectiveParamCount > nUnoParamCount )
+ sal_uInt32 nEffectiveParamCount = nParamCount - nParameterOffsetByContext;
+ sal_uInt32 nAllocParamCount = nEffectiveParamCount;
+ if( nEffectiveParamCount > nUnoParamCount )
+ {
+ if( !bRestParameterMode )
{
- if( !bRestParameterMode )
- {
- nEffectiveParamCount = nUnoParamCount;
- nAllocParamCount = nUnoParamCount;
- }
+ nEffectiveParamCount = nUnoParamCount;
+ nAllocParamCount = nUnoParamCount;
}
- // Not enough parameters?
- else if( nUnoParamCount > nEffectiveParamCount )
+ }
+ // Not enough parameters?
+ else if( nUnoParamCount > nEffectiveParamCount )
+ {
+ // RestParameterMode only helps if one (the last) parameter is missing
+ int nDiff = nUnoParamCount - nEffectiveParamCount;
+ if( !bRestParameterMode || nDiff > 1 )
{
- // RestParameterMode only helps if one (the last) parameter is missing
- int nDiff = nUnoParamCount - nEffectiveParamCount;
- if( !bRestParameterMode || nDiff > 1 )
- {
- bParameterError = true;
- StarBASIC::Error( ERRCODE_BASIC_NOT_OPTIONAL );
- }
+ bParameterError = true;
+ StarBASIC::Error( ERRCODE_BASIC_NOT_OPTIONAL );
}
+ }
- if( !bParameterError )
+ if( !bParameterError )
+ {
+ bool bOutParams = false;
+ if( nAllocParamCount > 0 )
{
- bool bOutParams = false;
- if( nAllocParamCount > 0 )
+ args.realloc( nAllocParamCount );
+ Any* pAnyArgs = args.getArray();
+ for( sal_uInt32 i = 0 ; i < nEffectiveParamCount ; i++ )
{
- args.realloc( nAllocParamCount );
- Any* pAnyArgs = args.getArray();
- for( sal_uInt32 i = 0 ; i < nEffectiveParamCount ; i++ )
- {
- sal_uInt32 iSbx = i + nSbxParameterOffset + nParameterOffsetByContext;
+ sal_uInt32 iSbx = i + nSbxParameterOffset + nParameterOffsetByContext;
- // bRestParameterMode allows nEffectiveParamCount > nUnoParamCount
- Reference< XParameter > xParam;
- if( i < nUnoParamCount )
- {
- xParam = pParameterSeq[i];
- if( !xParam.is() )
- continue;
+ // bRestParameterMode allows nEffectiveParamCount > nUnoParamCount
+ Reference< XParameter > xParam;
+ if( i < nUnoParamCount )
+ {
+ xParam = pParameterSeq[i];
+ if( !xParam.is() )
+ continue;
- Reference< XTypeDescription > xParamTypeDesc = xParam->getType();
- if( !xParamTypeDesc.is() )
- continue;
- css::uno::Type aType( xParamTypeDesc->getTypeClass(), xParamTypeDesc->getName() );
+ Reference< XTypeDescription > xParamTypeDesc = xParam->getType();
+ if( !xParamTypeDesc.is() )
+ continue;
+ css::uno::Type aType( xParamTypeDesc->getTypeClass(), xParamTypeDesc->getName() );
- // sbx parameter needs offset 1
- pAnyArgs[i] = sbxToUnoValue( pParams->Get32( iSbx ), aType );
+ // sbx parameter needs offset 1
+ pAnyArgs[i] = sbxToUnoValue( pParams->Get32( iSbx ), aType );
- // Check for out parameter if not already done
- if( !bOutParams && xParam->isOut() )
- bOutParams = true;
- }
- else
- {
- pAnyArgs[i] = sbxToUnoValue( pParams->Get32( iSbx ) );
- }
+ // Check for out parameter if not already done
+ if( !bOutParams && xParam->isOut() )
+ bOutParams = true;
+ }
+ else
+ {
+ pAnyArgs[i] = sbxToUnoValue( pParams->Get32( iSbx ) );
}
}
+ }
- // "Call" ctor using createInstanceWithArgumentsAndContext
- Reference < XComponentContext > xContext(
- xFirstParamContext.is()
- ? xFirstParamContext
- : comphelper::getProcessComponentContext() );
- Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
+ // "Call" ctor using createInstanceWithArgumentsAndContext
+ Reference < XComponentContext > xContext(
+ xFirstParamContext.is()
+ ? xFirstParamContext
+ : comphelper::getProcessComponentContext() );
+ Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
- Any aRetAny;
- OUString aServiceName = GetName();
- Reference < XInterface > xRet;
- try
- {
- xRet = xServiceMgr->createInstanceWithArgumentsAndContext( aServiceName, args, xContext );
- }
- catch( const Exception& )
- {
- implHandleAnyException( ::cppu::getCaughtException() );
- }
- aRetAny <<= xRet;
- unoToSbxValue( pVar, aRetAny );
+ Any aRetAny;
+ OUString aServiceName = GetName();
+ Reference < XInterface > xRet;
+ try
+ {
+ xRet = xServiceMgr->createInstanceWithArgumentsAndContext( aServiceName, args, xContext );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
+ }
+ aRetAny <<= xRet;
+ unoToSbxValue( pVar, aRetAny );
- // Copy back out parameters?
- if( bOutParams )
- {
- const Any* pAnyArgs = args.getConstArray();
+ // Copy back out parameters?
+ if( bOutParams )
+ {
+ const Any* pAnyArgs = args.getConstArray();
- for( sal_uInt32 j = 0 ; j < nUnoParamCount ; j++ )
- {
- Reference< XParameter > xParam = pParameterSeq[j];
- if( !xParam.is() )
- continue;
+ for( sal_uInt32 j = 0 ; j < nUnoParamCount ; j++ )
+ {
+ Reference< XParameter > xParam = pParameterSeq[j];
+ if( !xParam.is() )
+ continue;
- if( xParam->isOut() )
- unoToSbxValue( pParams->Get32(j + 1), pAnyArgs[ j ] );
- }
+ if( xParam->isOut() )
+ unoToSbxValue( pParams->Get32(j + 1), pAnyArgs[ j ] );
}
}
}
- else
- SbxObject::Notify( rBC, rHint );
}
+ else
+ SbxObject::Notify( rBC, rHint );
}
@@ -3812,46 +3812,46 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet
{
SolarMutexGuard guard;
- if( xSbxObj.is() )
- {
- OUString aMethodName = aPrefixName + Event.MethodName;
+ if( !xSbxObj.is() )
+ return;
+
+ OUString aMethodName = aPrefixName + Event.MethodName;
- SbxVariable * pP = xSbxObj.get();
- while( pP->GetParent() )
+ SbxVariable * pP = xSbxObj.get();
+ while( pP->GetParent() )
+ {
+ pP = pP->GetParent();
+ StarBASIC * pLib = dynamic_cast<StarBASIC*>( pP );
+ if( pLib )
{
- pP = pP->GetParent();
- StarBASIC * pLib = dynamic_cast<StarBASIC*>( pP );
- if( pLib )
+ // Create in a Basic Array
+ SbxArrayRef xSbxArray = new SbxArray( SbxVARIANT );
+ const Any * pArgs = Event.Arguments.getConstArray();
+ sal_Int32 nCount = Event.Arguments.getLength();
+ for( sal_Int32 i = 0; i < nCount; i++ )
{
- // Create in a Basic Array
- SbxArrayRef xSbxArray = new SbxArray( SbxVARIANT );
- const Any * pArgs = Event.Arguments.getConstArray();
- sal_Int32 nCount = Event.Arguments.getLength();
- for( sal_Int32 i = 0; i < nCount; i++ )
- {
- // Convert elements
- SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
- unoToSbxValue( xVar.get(), pArgs[i] );
- xSbxArray->Put32( xVar.get(), i + 1 );
- }
+ // Convert elements
+ SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
+ unoToSbxValue( xVar.get(), pArgs[i] );
+ xSbxArray->Put32( xVar.get(), i + 1 );
+ }
- pLib->Call( aMethodName, xSbxArray.get() );
+ pLib->Call( aMethodName, xSbxArray.get() );
- // get the return value from the Param-Array, if requested
- if( pRet )
+ // get the return value from the Param-Array, if requested
+ if( pRet )
+ {
+ SbxVariable* pVar = xSbxArray->Get32( 0 );
+ if( pVar )
{
- SbxVariable* pVar = xSbxArray->Get32( 0 );
- if( pVar )
- {
- // #95792 Avoid a second call
- SbxFlagBits nFlags = pVar->GetFlags();
- pVar->SetFlag( SbxFlagBits::NoBroadcast );
- *pRet = sbxToUnoValueImpl( pVar );
- pVar->SetFlags( nFlags );
- }
+ // #95792 Avoid a second call
+ SbxFlagBits nFlags = pVar->GetFlags();
+ pVar->SetFlag( SbxFlagBits::NoBroadcast );
+ *pRet = sbxToUnoValueImpl( pVar );
+ pVar->SetFlags( nFlags );
}
- break;
}
+ break;
}
}
}
@@ -4473,29 +4473,29 @@ void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic )
void disposeComVariablesForBasic( StarBASIC const * pBasic )
{
DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
- if( it != GaDisposeItemVector.end() )
- {
- StarBasicDisposeItem* pItem = *it;
+ if( it == GaDisposeItemVector.end() )
+ return;
- SbxArray* pArray = pItem->m_pRegisteredVariables.get();
- sal_uInt32 nCount = pArray->Count32();
- for( sal_uInt32 i = 0 ; i < nCount ; ++i )
- {
- SbxVariable* pVar = pArray->Get32( i );
- pVar->ClearComListener();
- }
+ StarBasicDisposeItem* pItem = *it;
- ComponentRefVector& rv = pItem->m_vComImplementsObjects;
- for (auto const& elem : rv)
- {
- Reference< XComponent > xComponent( elem.get(), UNO_QUERY );
- if (xComponent.is())
- xComponent->dispose();
- }
+ SbxArray* pArray = pItem->m_pRegisteredVariables.get();
+ sal_uInt32 nCount = pArray->Count32();
+ for( sal_uInt32 i = 0 ; i < nCount ; ++i )
+ {
+ SbxVariable* pVar = pArray->Get32( i );
+ pVar->ClearComListener();
+ }
- delete pItem;
- GaDisposeItemVector.erase( it );
+ ComponentRefVector& rv = pItem->m_vComImplementsObjects;
+ for (auto const& elem : rv)
+ {
+ Reference< XComponent > xComponent( elem.get(), UNO_QUERY );
+ if (xComponent.is())
+ xComponent->dispose();
}
+
+ delete pItem;
+ GaDisposeItemVector.erase( it );
}
@@ -4830,72 +4830,72 @@ void SbUnoStructRefObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
if ( !mbMemberCacheInit )
initMemberCache();
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
+ if( !pHint )
+ return;
+
+ SbxVariable* pVar = pHint->GetVar();
+ SbUnoProperty* pProp = dynamic_cast<SbUnoProperty*>( pVar );
+ if( pProp )
{
- SbxVariable* pVar = pHint->GetVar();
- SbUnoProperty* pProp = dynamic_cast<SbUnoProperty*>( pVar );
- if( pProp )
+ StructFieldInfo::iterator it = maFields.find( pProp->GetName() );
+ // handle get/set of members of struct
+ if( pHint->GetId() == SfxHintId::BasicDataWanted )
{
- StructFieldInfo::iterator it = maFields.find( pProp->GetName() );
- // handle get/set of members of struct
- if( pHint->GetId() == SfxHintId::BasicDataWanted )
+ // Test-Properties
+ sal_Int32 nId = pProp->nId;
+ if( nId < 0 )
{
- // Test-Properties
- sal_Int32 nId = pProp->nId;
- if( nId < 0 )
+ // Id == -1: Display implemented interfaces according the ClassProvider
+ if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
{
- // Id == -1: Display implemented interfaces according the ClassProvider
- if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
- {
- OUString aRet = OUStringLiteral( ID_DBG_SUPPORTEDINTERFACES )
- + " not available.\n(TypeClass is not TypeClass_INTERFACE)\n";
+ OUString aRet = OUStringLiteral( ID_DBG_SUPPORTEDINTERFACES )
+ + " not available.\n(TypeClass is not TypeClass_INTERFACE)\n";
- pVar->PutString( aRet );
- }
- // Id == -2: output properties
- else if( nId == -2 ) // Property ID_DBG_PROPERTIES
- {
- // by now all properties must be established
- implCreateAll();
- OUString aRetStr = Impl_DumpProperties();
- pVar->PutString( aRetStr );
- }
- // Id == -3: output the methods
- else if( nId == -3 ) // Property ID_DBG_METHODS
- {
- // by now all properties must be established
- implCreateAll();
- OUString aRet = "Methods of object "
- + getDbgObjectName()
- + "\nNo methods found\n";
- pVar->PutString( aRet );
- }
- return;
+ pVar->PutString( aRet );
}
-
- if ( it != maFields.end() )
+ // Id == -2: output properties
+ else if( nId == -2 ) // Property ID_DBG_PROPERTIES
{
- Any aRetAny = it->second->getValue();
- unoToSbxValue( pVar, aRetAny );
+ // by now all properties must be established
+ implCreateAll();
+ OUString aRetStr = Impl_DumpProperties();
+ pVar->PutString( aRetStr );
}
- else
- StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
- }
- else if( pHint->GetId() == SfxHintId::BasicDataChanged )
- {
- if ( it != maFields.end() )
+ // Id == -3: output the methods
+ else if( nId == -3 ) // Property ID_DBG_METHODS
{
- // take over the value from Uno to Sbx
- Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
- it->second->setValue( aAnyValue );
+ // by now all properties must be established
+ implCreateAll();
+ OUString aRet = "Methods of object "
+ + getDbgObjectName()
+ + "\nNo methods found\n";
+ pVar->PutString( aRet );
}
- else
- StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
+ return;
+ }
+
+ if ( it != maFields.end() )
+ {
+ Any aRetAny = it->second->getValue();
+ unoToSbxValue( pVar, aRetAny );
}
+ else
+ StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
+ }
+ else if( pHint->GetId() == SfxHintId::BasicDataChanged )
+ {
+ if ( it != maFields.end() )
+ {
+ // take over the value from Uno to Sbx
+ Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp );
+ it->second->setValue( aAnyValue );
+ }
+ else
+ StarBASIC::Error( ERRCODE_BASIC_PROPERTY_NOT_FOUND );
}
- else
- SbxObject::Notify( rBC, rHint );
}
+ else
+ SbxObject::Notify( rBC, rHint );
}
StructRefInfo SbUnoStructRefObject::getStructMember( const OUString& rMemberName )
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 45a83f4ec18b..88ade90a4677 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -122,52 +122,52 @@ public:
DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar )
{
SbObjModule* pMod = dynamic_cast<SbObjModule*>( pVar );
- if ( pMod )
+ if ( !pMod )
+ return;
+
+ if ( pMod->GetModuleType() != ModuleType::DOCUMENT )
+ return;
+
+ // Use proxy factory service to create aggregatable proxy.
+ SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pMod->GetObject() );
+ Reference< XInterface > xIf;
+ if ( pUnoObj )
+ {
+ Any aObj = pUnoObj->getUnoAny();
+ aObj >>= xIf;
+ if ( xIf.is() )
+ {
+ m_xAggregateTypeProv.set( xIf, UNO_QUERY );
+ m_xAggInv.set( xIf, UNO_QUERY );
+ }
+ }
+ if ( xIf.is() )
{
- if ( pMod->GetModuleType() == ModuleType::DOCUMENT )
+ try
{
- // Use proxy factory service to create aggregatable proxy.
- SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pMod->GetObject() );
- Reference< XInterface > xIf;
- if ( pUnoObj )
- {
- Any aObj = pUnoObj->getUnoAny();
- aObj >>= xIf;
- if ( xIf.is() )
- {
- m_xAggregateTypeProv.set( xIf, UNO_QUERY );
- m_xAggInv.set( xIf, UNO_QUERY );
- }
- }
- if ( xIf.is() )
- {
- try
- {
- Reference< XProxyFactory > xProxyFac = ProxyFactory::create( comphelper::getProcessComponentContext() );
- m_xAggProxy = xProxyFac->createProxy( xIf );
- }
- catch(const Exception& )
- {
- TOOLS_WARN_EXCEPTION( "basic", "DocObjectWrapper::DocObjectWrapper" );
- }
- }
+ Reference< XProxyFactory > xProxyFac = ProxyFactory::create( comphelper::getProcessComponentContext() );
+ m_xAggProxy = xProxyFac->createProxy( xIf );
+ }
+ catch(const Exception& )
+ {
+ TOOLS_WARN_EXCEPTION( "basic", "DocObjectWrapper::DocObjectWrapper" );
+ }
+ }
- if ( m_xAggProxy.is() )
- {
- osl_atomic_increment( &m_refCount );
+ if ( !m_xAggProxy.is() )
+ return;
- /* i35609 - Fix crash on Solaris. The setDelegator call needs
- to be in its own block to ensure that all temporary Reference
- instances that are acquired during the call are released
- before m_refCount is decremented again */
- {
- m_xAggProxy->setDelegator( static_cast< cppu::OWeakObject * >( this ) );
- }
+ osl_atomic_increment( &m_refCount );
- osl_atomic_decrement( &m_refCount );
- }
- }
+ /* i35609 - Fix crash on Solaris. The setDelegator call needs
+ to be in its own block to ensure that all temporary Reference
+ instances that are acquired during the call are released
+ before m_refCount is decremented again */
+ {
+ m_xAggProxy->setDelegator( static_cast< cppu::OWeakObject * >( this ) );
}
+
+ osl_atomic_decrement( &m_refCount );
}
Sequence< Type > SAL_CALL DocObjectWrapper::getTypes()
@@ -673,126 +673,126 @@ void SbModule::SetParent( SbxObject* p )
void SbModule::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
+ if( !pHint )
+ return;
+
+ SbxVariable* pVar = pHint->GetVar();
+ SbProperty* pProp = dynamic_cast<SbProperty*>( pVar );
+ SbMethod* pMeth = dynamic_cast<SbMethod*>( pVar );
+ SbProcedureProperty* pProcProperty = dynamic_cast<SbProcedureProperty*>( pVar );
+ if( pProcProperty )
{
- SbxVariable* pVar = pHint->GetVar();
- SbProperty* pProp = dynamic_cast<SbProperty*>( pVar );
- SbMethod* pMeth = dynamic_cast<SbMethod*>( pVar );
- SbProcedureProperty* pProcProperty = dynamic_cast<SbProcedureProperty*>( pVar );
- if( pProcProperty )
+
+ if( pHint->GetId() == SfxHintId::BasicDataWanted )
{
+ OUString aProcName = "Property Get "
+ + pProcProperty->GetName();
- if( pHint->GetId() == SfxHintId::BasicDataWanted )
+ SbxVariable* pMethVar = Find( aProcName, SbxClassType::Method );
+ if( pMethVar )
{
- OUString aProcName = "Property Get "
- + pProcProperty->GetName();
+ SbxValues aVals;
+ aVals.eType = SbxVARIANT;
- SbxVariable* pMethVar = Find( aProcName, SbxClassType::Method );
- if( pMethVar )
+ SbxArray* pArg = pVar->GetParameters();
+ sal_uInt32 nVarParCount = (pArg != nullptr) ? pArg->Count32() : 0;
+ if( nVarParCount > 1 )
{
- SbxValues aVals;
- aVals.eType = SbxVARIANT;
-
- SbxArray* pArg = pVar->GetParameters();
- sal_uInt32 nVarParCount = (pArg != nullptr) ? pArg->Count32() : 0;
- if( nVarParCount > 1 )
+ auto xMethParameters = tools::make_ref<SbxArray>();
+ xMethParameters->Put32( pMethVar, 0 ); // Method as parameter 0
+ for( sal_uInt32 i = 1 ; i < nVarParCount ; ++i )
{
- auto xMethParameters = tools::make_ref<SbxArray>();
- xMethParameters->Put32( pMethVar, 0 ); // Method as parameter 0
- for( sal_uInt32 i = 1 ; i < nVarParCount ; ++i )
- {
- SbxVariable* pPar = pArg->Get32( i );
- xMethParameters->Put32( pPar, i );
- }
-
- pMethVar->SetParameters( xMethParameters.get() );
- pMethVar->Get( aVals );
- pMethVar->SetParameters( nullptr );
+ SbxVariable* pPar = pArg->Get32( i );
+ xMethParameters->Put32( pPar, i );
}
- else
- {
- pMethVar->Get( aVals );
- }
-
- pVar->Put( aVals );
- }
- }
- else if( pHint->GetId() == SfxHintId::BasicDataChanged )
- {
- SbxVariable* pMethVar = nullptr;
-
- bool bSet = pProcProperty->isSet();
- if( bSet )
- {
- pProcProperty->setSet( false );
- OUString aProcName = "Property Set "
- + pProcProperty->GetName();
- pMethVar = Find( aProcName, SbxClassType::Method );
- }
- if( !pMethVar ) // Let
- {
- OUString aProcName = "Property Let "
- + pProcProperty->GetName();
- pMethVar = Find( aProcName, SbxClassType::Method );
+ pMethVar->SetParameters( xMethParameters.get() );
+ pMethVar->Get( aVals );
+ pMethVar->SetParameters( nullptr );
}
-
- if( pMethVar )
+ else
{
- // Setup parameters
- SbxArrayRef xArray = new SbxArray;
- xArray->Put32( pMethVar, 0 ); // Method as parameter 0
- xArray->Put32( pVar, 1 );
- pMethVar->SetParameters( xArray.get() );
-
- SbxValues aVals;
pMethVar->Get( aVals );
- pMethVar->SetParameters( nullptr );
}
+
+ pVar->Put( aVals );
}
}
- if( pProp )
- {
- if( pProp->GetModule() != this )
- SetError( ERRCODE_BASIC_BAD_ACTION );
- }
- else if( pMeth )
+ else if( pHint->GetId() == SfxHintId::BasicDataChanged )
{
- if( pHint->GetId() == SfxHintId::BasicDataWanted )
+ SbxVariable* pMethVar = nullptr;
+
+ bool bSet = pProcProperty->isSet();
+ if( bSet )
{
- if( pMeth->bInvalid && !Compile() )
- {
- // auto compile has not worked!
- StarBASIC::Error( ERRCODE_BASIC_BAD_PROP_VALUE );
- }
- else
- {
- // Call of a subprogram
- SbModule* pOld = GetSbData()->pMod;
- GetSbData()->pMod = this;
- Run( static_cast<SbMethod*>(pVar) );
- GetSbData()->pMod = pOld;
- }
+ pProcProperty->setSet( false );
+
+ OUString aProcName = "Property Set "
+ + pProcProperty->GetName();
+ pMethVar = Find( aProcName, SbxClassType::Method );
+ }
+ if( !pMethVar ) // Let
+ {
+ OUString aProcName = "Property Let "
+ + pProcProperty->GetName();
+ pMethVar = Find( aProcName, SbxClassType::Method );
+ }
+
+ if( pMethVar )
+ {
+ // Setup parameters
+ SbxArrayRef xArray = new SbxArray;
+ xArray->Put32( pMethVar, 0 ); // Method as parameter 0
+ xArray->Put32( pVar, 1 );
+ pMethVar->SetParameters( xArray.get() );
+
+ SbxValues aVals;
+ pMethVar->Get( aVals );
+ pMethVar->SetParameters( nullptr );
}
}
- else
+ }
+ if( pProp )
+ {
+ if( pProp->GetModule() != this )
+ SetError( ERRCODE_BASIC_BAD_ACTION );
+ }
+ else if( pMeth )
+ {
+ if( pHint->GetId() == SfxHintId::BasicDataWanted )
{
- // #i92642: Special handling for name property to avoid
- // side effects when using name as variable implicitly
- bool bForwardToSbxObject = true;
-
- const SfxHintId nId = pHint->GetId();
- if( (nId == SfxHintId::BasicDataWanted || nId == SfxHintId::BasicDataChanged) &&
- pVar->GetName().equalsIgnoreAsciiCase( "name" ) )
+ if( pMeth->bInvalid && !Compile() )
{
- bForwardToSbxObject = false;
+ // auto compile has not worked!
+ StarBASIC::Error( ERRCODE_BASIC_BAD_PROP_VALUE );
}
- if( bForwardToSbxObject )
+ else
{
- SbxObject::Notify( rBC, rHint );
+ // Call of a subprogram
+ SbModule* pOld = GetSbData()->pMod;
+ GetSbData()->pMod = this;
+ Run( static_cast<SbMethod*>(pVar) );
+ GetSbData()->pMod = pOld;
}
}
}
+ else
+ {
+ // #i92642: Special handling for name property to avoid
+ // side effects when using name as variable implicitly
+ bool bForwardToSbxObject = true;
+
+ const SfxHintId nId = pHint->GetId();
+ if( (nId == SfxHintId::BasicDataWanted || nId == SfxHintId::BasicDataChanged) &&
+ pVar->GetName().equalsIgnoreAsciiCase( "name" ) )
+ {
+ bForwardToSbxObject = false;
+ }
+ if( bForwardToSbxObject )
+ {
+ SbxObject::Notify( rBC, rHint );
+ }
+ }
}
// The setting of the source makes the image invalid
@@ -975,19 +975,19 @@ static void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic )
void SbModule::SetVBACompat( bool bCompat )
{
- if( mbVBACompat != bCompat )
+ if( mbVBACompat == bCompat )
+ return;
+
+ mbVBACompat = bCompat;
+ // initialize VBA document API
+ if( mbVBACompat ) try
+ {
+ StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() );
+ uno::Reference< lang::XMultiServiceFactory > xFactory( getDocumentModel( pBasic ), uno::UNO_QUERY_THROW );
+ xFactory->createInstance( "ooo.vba.VBAGlobals" );
+ }
+ catch( Exception& )
{
- mbVBACompat = bCompat;
- // initialize VBA document API
- if( mbVBACompat ) try
- {
- StarBASIC* pBasic = static_cast< StarBASIC* >( GetParent() );
- uno::Reference< lang::XMultiServiceFactory > xFactory( getDocumentModel( pBasic ), uno::UNO_QUERY_THROW );
- xFactory->createInstance( "ooo.vba.VBAGlobals" );
- }
- catch( Exception& )
- {
- }
}
}
@@ -1242,26 +1242,26 @@ void SbModule::Run( SbMethod* pMeth )
// or the compilation
void SbModule::RunInit()
{
- if( pImage
+ if( !(pImage
&& !pImage->bInit
- && pImage->IsFlag( SbiImageFlags::INITCODE ) )
- {
- SbiGlobals* pSbData = GetSbData();
+ && pImage->IsFlag( SbiImageFlags::INITCODE )) )
+ return;
- // Set flag, so that RunInit get active (Testtool)
- pSbData->bRunInit = true;
+ SbiGlobals* pSbData = GetSbData();
- // The init code starts always here
- auto xRuntimeGuard(std::make_unique<RunInitGuard>(this, nullptr, 0, pSbData));
- xRuntimeGuard->run();
- xRuntimeGuard.reset();
+ // Set flag, so that RunInit get active (Testtool)
+ pSbData->bRunInit = true;
- pImage->bInit = true;
- pImage->bFirstInit = false;
+ // The init code starts always here
+ auto xRuntimeGuard(std::make_unique<RunInitGuard>(this, nullptr, 0, pSbData));
+ xRuntimeGuard->run();
+ xRuntimeGuard.reset();
- // RunInit is not active anymore
- pSbData->bRunInit = false;
- }
+ pImage->bInit = true;
+ pImage->bFirstInit = false;
+
+ // RunInit is not active anymore
+ pSbData->bRunInit = false;
}
// Delete with private/dim declared variables
@@ -1324,22 +1324,22 @@ void SbModule::implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC
return;
SbxObject* pObj = dynamic_cast<SbxObject*>( pVar->GetObject() );
- if( pObj != nullptr )
- {
- SbxObject* p = pObj;
+ if( pObj == nullptr )
+ return;
+
+ SbxObject* p = pObj;
- SbModule* pMod = dynamic_cast<SbModule*>( p );
- if( pMod != nullptr )
- pMod->ClearVarsDependingOnDeletedBasic( pDeletedBasic );
+ SbModule* pMod = dynamic_cast<SbModule*>( p );
+ if( pMod != nullptr )
+ pMod->ClearVarsDependingOnDeletedBasic( pDeletedBasic );
- while( (p = p->GetParent()) != nullptr )
+ while( (p = p->GetParent()) != nullptr )
+ {
+ StarBASIC* pBasic = dynamic_cast<StarBASIC*>( p );
+ if( pBasic != nullptr && pBasic == pDeletedBasic )
{
- StarBASIC* pBasic = dynamic_cast<StarBASIC*>( p );
- if( pBasic != nullptr && pBasic == pDeletedBasic )
- {
- pVar->SbxValue::Clear();
- break;
- }
+ pVar->SbxValue::Clear();
+ break;
}
}
}
@@ -1399,28 +1399,28 @@ void SbModule::GlobalRunInit( bool bBasicStart )
// Parent of the module is a Basic
StarBASIC *pBasic = dynamic_cast<StarBASIC*>( GetParent() );
- if( pBasic )
- {
- pBasic->InitAllModules();
+ if( !pBasic )
+ return;
- SbxObject* pParent_ = pBasic->GetParent();
- if( pParent_ )
- {
- StarBASIC * pParentBasic = dynamic_cast<StarBASIC*>( pParent_ );
- if( pParentBasic )
- {
- pParentBasic->InitAllModules( pBasic );
+ pBasic->InitAllModules();
- // #109018 Parent can also have a parent (library in doc)
- SbxObject* pParentParent = pParentBasic->GetParent();
- if( pParentParent )
- {
- StarBASIC * pParentParentBasic = dynamic_cast<StarBASIC*>( pParentParent );
- if( pParentParentBasic )
- pParentParentBasic->InitAllModules( pParentBasic );
- }
- }
- }
+ SbxObject* pParent_ = pBasic->GetParent();
+ if( !pParent_ )
+ return;
+
+ StarBASIC * pParentBasic = dynamic_cast<StarBASIC*>( pParent_ );
+ if( !pParentBasic )
+ return;
+
+ pParentBasic->InitAllModules( pBasic );
+
+ // #109018 Parent can also have a parent (library in doc)
+ SbxObject* pParentParent = pParentBasic->GetParent();
+ if( pParentParent )
+ {
+ StarBASIC * pParentParentBasic = dynamic_cast<StarBASIC*>( pParentParent );
+ if( pParentParentBasic )
+ pParentParentBasic->InitAllModules( pParentBasic );
}
}
@@ -2081,43 +2081,43 @@ ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller )
// #100883 Own Broadcast for SbMethod
void SbMethod::Broadcast( SfxHintId nHintId )
{
- if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) )
- {
- // Because the method could be called from outside, test here once again
- // the authorisation
- if( nHintId == SfxHintId::BasicDataWanted )
- if( !CanRead() )
- return;
- if( nHintId == SfxHintId::BasicDataChanged )
- if( !CanWrite() )
- return;
-
- if( pMod && !pMod->IsCompiled() )
- pMod->Compile();
-
- // Block broadcasts while creating new method
- std::unique_ptr<SfxBroadcaster> pSaveBroadcaster = std::move(mpBroadcaster);
- SbMethod* pThisCopy = new SbMethod( *this );
- SbMethodRef xHolder = pThisCopy;
- if( mpPar.is() )
- {
- // Enregister this as element 0, but don't reset the parent!
- if( GetType() != SbxVOID ) {
- mpPar->PutDirect( pThisCopy, 0 );
- }
- SetParameters( nullptr );
- }
+ if( !(mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast )) )
+ return;
+
+ // Because the method could be called from outside, test here once again
+ // the authorisation
+ if( nHintId == SfxHintId::BasicDataWanted )
+ if( !CanRead() )
+ return;
+ if( nHintId == SfxHintId::BasicDataChanged )
+ if( !CanWrite() )
+ return;
- mpBroadcaster = std::move(pSaveBroadcaster);
- mpBroadcaster->Broadcast( SbxHint( nHintId, pThisCopy ) );
+ if( pMod && !pMod->IsCompiled() )
+ pMod->Compile();
- SbxFlagBits nSaveFlags = GetFlags();
- SetFlag( SbxFlagBits::ReadWrite );
- pSaveBroadcaster = std::move(mpBroadcaster);
- Put( pThisCopy->GetValues_Impl() );
- mpBroadcaster = std::move(pSaveBroadcaster);
- SetFlags( nSaveFlags );
+ // Block broadcasts while creating new method
+ std::unique_ptr<SfxBroadcaster> pSaveBroadcaster = std::move(mpBroadcaster);
+ SbMethod* pThisCopy = new SbMethod( *this );
+ SbMethodRef xHolder = pThisCopy;
+ if( mpPar.is() )
+ {
+ // Enregister this as element 0, but don't reset the parent!
+ if( GetType() != SbxVOID ) {
+ mpPar->PutDirect( pThisCopy, 0 );
+ }
+ SetParameters( nullptr );
}
+
+ mpBroadcaster = std::move(pSaveBroadcaster);
+ mpBroadcaster->Broadcast( SbxHint( nHintId, pThisCopy ) );
+
+ SbxFlagBits nSaveFlags = GetFlags();
+ SetFlag( SbxFlagBits::ReadWrite );
+ pSaveBroadcaster = std::move(mpBroadcaster);
+ Put( pThisCopy->GetValues_Impl() );
+ mpBroadcaster = std::move(pSaveBroadcaster);
+ SetFlags( nSaveFlags );
}
@@ -2431,39 +2431,39 @@ void SbUserFormModule::triggerMethod( const OUString& aMethodToRun, Sequence< An
SAL_INFO("basic", "trigger " << aMethodToRun);
// Search method
SbxVariable* pMeth = SbObjModule::Find( aMethodToRun, SbxClassType::Method );
- if( pMeth )
+ if( !pMeth )
+ return;
+
+ if ( aArguments.hasElements() ) // Setup parameters
{
- if ( aArguments.hasElements() ) // Setup parameters
- {
- auto xArray = tools::make_ref<SbxArray>();
- xArray->Put32( pMeth, 0 ); // Method as parameter 0
+ auto xArray = tools::make_ref<SbxArray>();
+ xArray->Put32( pMeth, 0 ); // Method as parameter 0
- for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
- {
- auto xSbxVar = tools::make_ref<SbxVariable>( SbxVARIANT );
- unoToSbxValue( xSbxVar.get(), aArguments[i] );
- xArray->Put32( xSbxVar.get(), static_cast< sal_uInt32 >( i ) + 1 );
+ for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
+ {
+ auto xSbxVar = tools::make_ref<SbxVariable>( SbxVARIANT );
+ unoToSbxValue( xSbxVar.get(), aArguments[i] );
+ xArray->Put32( xSbxVar.get(), static_cast< sal_uInt32 >( i ) + 1 );
- // Enable passing by ref
- if ( xSbxVar->GetType() != SbxVARIANT )
- xSbxVar->SetFlag( SbxFlagBits::Fixed );
- }
- pMeth->SetParameters( xArray.get() );
+ // Enable passing by ref
+ if ( xSbxVar->GetType() != SbxVARIANT )
+ xSbxVar->SetFlag( SbxFlagBits::Fixed );
+ }
+ pMeth->SetParameters( xArray.get() );
- SbxValues aVals;
- pMeth->Get( aVals );
+ SbxValues aVals;
+ pMeth->Get( aVals );
- for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
- {
- aArguments[i] = sbxToUnoValue( xArray->Get32( static_cast< sal_uInt32 >(i) + 1) );
- }
- pMeth->SetParameters( nullptr );
- }
- else
+ for ( sal_Int32 i = 0; i < aArguments.getLength(); ++i )
{
- SbxValues aVals;
- pMeth->Get( aVals );
+ aArguments[i] = sbxToUnoValue( xArray->Get32( static_cast< sal_uInt32 >(i) + 1) );
}
+ pMeth->SetParameters( nullptr );
+ }
+ else
+ {
+ SbxValues aVals;
+ pMeth->Get( aVals );
}
}
@@ -2562,25 +2562,25 @@ void SbUserFormModule::Unload()
}
// Search method
SbxVariable* pMeth = SbObjModule::Find( "UnloadObject", SbxClassType::Method );
- if( pMeth )
+ if( !pMeth )
+ return;
+
+ SAL_INFO("basic", "Attempting to run the UnloadObjectMethod");
+ m_xDialog.clear(); //release ref to the uno object
+ SbxValues aVals;
+ bool bWaitForDispose = true; // assume dialog is showing
+ if (m_DialogListener)
{
- SAL_INFO("basic", "Attempting to run the UnloadObjectMethod");
- m_xDialog.clear(); //release ref to the uno object
- SbxValues aVals;
- bool bWaitForDispose = true; // assume dialog is showing
- if (m_DialogListener)
- {
- bWaitForDispose = m_DialogListener->isShowing();
- SAL_INFO("basic", "Showing " << bWaitForDispose );
- }
- pMeth->Get( aVals);
- if ( !bWaitForDispose )
- {
- // we've either already got a dispose or we are never going to get one
- ResetApiObj();
- } // else wait for dispose
- SAL_INFO("basic", "UnloadObject completed (we hope)");
+ bWaitForDispose = m_DialogListener->isShowing();
+ SAL_INFO("basic", "Showing " << bWaitForDispose );
}
+ pMeth->Get( aVals);
+ if ( !bWaitForDispose )
+ {
+ // we've either already got a dispose or we are never going to get one
+ ResetApiObj();
+ } // else wait for dispose
+ SAL_INFO("basic", "UnloadObject completed (we hope)");
}
diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx
index a7dca978b27a..80017fcca354 100644
--- a/basic/source/comp/buffer.cxx
+++ b/basic/source/comp/buffer.cxx
@@ -124,29 +124,29 @@ void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val )
void SbiBuffer::Chain( sal_uInt32 off )
{
- if( off && pBuf )
+ if( !(off && pBuf) )
+ return;
+
+ sal_uInt8 *ip;
+ sal_uInt32 i = off;
+ sal_uInt32 val1 = (nOff & 0xFFFF);
+ sal_uInt32 val2 = (nOff >> 16);
+ do
{
- sal_uInt8 *ip;
- sal_uInt32 i = off;
- sal_uInt32 val1 = (nOff & 0xFFFF);
- sal_uInt32 val2 = (nOff >> 16);
- do
+ ip = reinterpret_cast<sal_uInt8*>(pBuf.get()) + i;
+ sal_uInt8* pTmp = ip;
+ i = *pTmp++; i |= *pTmp++ << 8; i |= *pTmp++ << 16; i |= *pTmp++ << 24;
+
+ if( i >= nOff )
{
- ip = reinterpret_cast<sal_uInt8*>(pBuf.get()) + i;
- sal_uInt8* pTmp = ip;
- i = *pTmp++; i |= *pTmp++ << 8; i |= *pTmp++ << 16; i |= *pTmp++ << 24;
-
- if( i >= nOff )
- {
- pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "BACKCHAIN" );
- break;
- }
- *ip++ = static_cast<char>( val1 & 0xFF );
- *ip++ = static_cast<char>( val1 >> 8 );
- *ip++ = static_cast<char>( val2 & 0xFF );
- *ip = static_cast<char>( val2 >> 8 );
- } while( i );
- }
+ pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "BACKCHAIN" );
+ break;
+ }
+ *ip++ = static_cast<char>( val1 & 0xFF );
+ *ip++ = static_cast<char>( val1 >> 8 );
+ *ip++ = static_cast<char>( val2 & 0xFF );
+ *ip = static_cast<char>( val2 >> 8 );
+ } while( i );
}
void SbiBuffer::operator +=( sal_Int8 n )
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 0689e421e533..211d4e325f5b 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -79,116 +79,116 @@ SbiSymDef* SbiParser::VarDecl( SbiExprListPtr* ppDim, bool bStatic, bool bConst
void SbiParser::TypeDecl( SbiSymDef& rDef, bool bAsNewAlreadyParsed )
{
SbxDataType eType = rDef.GetType();
- if( bAsNewAlreadyParsed || Peek() == AS )
+ if( !(bAsNewAlreadyParsed || Peek() == AS) )
+ return;
+
+ short nSize = 0;
+ if( !bAsNewAlreadyParsed )
+ Next();
+ rDef.SetDefinedAs();
+ SbiToken eTok = Next();
+ if( !bAsNewAlreadyParsed && eTok == NEW )
{
- short nSize = 0;
- if( !bAsNewAlreadyParsed )
- Next();
- rDef.SetDefinedAs();
- SbiToken eTok = Next();
- if( !bAsNewAlreadyParsed && eTok == NEW )
- {
- rDef.SetNew();
- eTok = Next();
- }
- switch( eTok )
- {
- case ANY:
- if( rDef.IsNew() )
- Error( ERRCODE_BASIC_SYNTAX );
- eType = SbxVARIANT; break;
- case TINTEGER:
- case TLONG:
- case TSINGLE:
- case TDOUBLE:
- case TCURRENCY:
- case TDATE:
- case TSTRING:
- case TOBJECT:
- case ERROR_:
- case TBOOLEAN:
- case TVARIANT:
- case TBYTE:
- if( rDef.IsNew() )
- Error( ERRCODE_BASIC_SYNTAX );
- eType = (eTok==TBYTE) ? SbxBYTE : SbxDataType( eTok - TINTEGER + SbxINTEGER );
- if( eType == SbxSTRING )
- {
- // STRING*n ?
- if( Peek() == MUL )
- { // fixed size!
- Next();
- SbiConstExpression aSize( this );
- nSize = aSize.GetShortValue();
- if( nSize < 0 || (bVBASupportOn && nSize <= 0) )
- Error( ERRCODE_BASIC_OUT_OF_RANGE );
- else
- rDef.SetFixedStringLength( nSize );
- }
+ rDef.SetNew();
+ eTok = Next();
+ }
+ switch( eTok )
+ {
+ case ANY:
+ if( rDef.IsNew() )
+ Error( ERRCODE_BASIC_SYNTAX );
+ eType = SbxVARIANT; break;
+ case TINTEGER:
+ case TLONG:
+ case TSINGLE:
+ case TDOUBLE:
+ case TCURRENCY:
+ case TDATE:
+ case TSTRING:
+ case TOBJECT:
+ case ERROR_:
+ case TBOOLEAN:
+ case TVARIANT:
+ case TBYTE:
+ if( rDef.IsNew() )
+ Error( ERRCODE_BASIC_SYNTAX );
+ eType = (eTok==TBYTE) ? SbxBYTE : SbxDataType( eTok - TINTEGER + SbxINTEGER );
+ if( eType == SbxSTRING )
+ {
+ // STRING*n ?
+ if( Peek() == MUL )
+ { // fixed size!
+ Next();
+ SbiConstExpression aSize( this );
+ nSize = aSize.GetShortValue();
+ if( nSize < 0 || (bVBASupportOn && nSize <= 0) )
+ Error( ERRCODE_BASIC_OUT_OF_RANGE );
+ else
+ rDef.SetFixedStringLength( nSize );
}
- break;
- case SYMBOL: // can only be a TYPE or an object class!
- if( eScanType != SbxVARIANT )
- Error( ERRCODE_BASIC_SYNTAX );
- else
- {
- OUString aCompleteName = aSym;
+ }
+ break;
+ case SYMBOL: // can only be a TYPE or an object class!
+ if( eScanType != SbxVARIANT )
+ Error( ERRCODE_BASIC_SYNTAX );
+ else
+ {
+ OUString aCompleteName = aSym;
- // #52709 DIM AS NEW for Uno with full-qualified name
- if( Peek() == DOT )
+ // #52709 DIM AS NEW for Uno with full-qualified name
+ if( Peek() == DOT )
+ {
+ OUString aDotStr( '.' );
+ while( Peek() == DOT )
{
- OUString aDotStr( '.' );
- while( Peek() == DOT )
+ aCompleteName += aDotStr;
+ Next();
+ SbiToken ePeekTok = Peek();
+ if( ePeekTok == SYMBOL || IsKwd( ePeekTok ) )
{
- aCompleteName += aDotStr;
Next();
- SbiToken ePeekTok = Peek();
- if( ePeekTok == SYMBOL || IsKwd( ePeekTok ) )
- {
- Next();
- aCompleteName += aSym;
- }
- else
- {
- Next();
- Error( ERRCODE_BASIC_UNEXPECTED, SYMBOL );
- break;
- }
+ aCompleteName += aSym;
+ }
+ else
+ {
+ Next();
+ Error( ERRCODE_BASIC_UNEXPECTED, SYMBOL );
+ break;
}
}
- else if( rEnumArray->Find( aCompleteName, SbxClassType::Object ) || ( IsVBASupportOn() && VBAConstantHelper::instance().isVBAConstantType( aCompleteName ) ) )
- {
- eType = SbxLONG;
- break;
- }
+ }
+ else if( rEnumArray->Find( aCompleteName, SbxClassType::Object ) || ( IsVBASupportOn() && VBAConstantHelper::instance().isVBAConstantType( aCompleteName ) ) )
+ {
+ eType = SbxLONG;
+ break;
+ }
- // Take over in the string pool
- rDef.SetTypeId( aGblStrings.Add( aCompleteName ) );
+ // Take over in the string pool
+ rDef.SetTypeId( aGblStrings.Add( aCompleteName ) );
- if( rDef.IsNew() && pProc == nullptr )
- aRequiredTypes.push_back( aCompleteName );
- }
- eType = SbxOBJECT;
- break;
- case FIXSTRING: // new syntax for complex UNO types
- rDef.SetTypeId( aGblStrings.Add( aSym ) );
- eType = SbxOBJECT;
- break;
- default:
- Error( ERRCODE_BASIC_UNEXPECTED, eTok );
- Next();
- }
- // The variable could have been declared with a suffix
- if( rDef.GetType() != SbxVARIANT )
- {
- if( rDef.GetType() != eType )
- Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() );
- else if( eType == SbxSTRING && rDef.GetLen() != nSize )
- Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() );
- }
- rDef.SetType( eType );
- rDef.SetLen( nSize );
+ if( rDef.IsNew() && pProc == nullptr )
+ aRequiredTypes.push_back( aCompleteName );
+ }
+ eType = SbxOBJECT;
+ break;
+ case FIXSTRING: // new syntax for complex UNO types
+ rDef.SetTypeId( aGblStrings.Add( aSym ) );
+ eType = SbxOBJECT;
+ break;
+ default:
+ Error( ERRCODE_BASIC_UNEXPECTED, eTok );
+ Next();
+ }
+ // The variable could have been declared with a suffix
+ if( rDef.GetType() != SbxVARIANT )
+ {
+ if( rDef.GetType() != eType )
+ Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() );
+ else if( eType == SbxSTRING && rDef.GetLen() != nSize )
+ Error( ERRCODE_BASIC_VAR_DEFINED, rDef.GetName() );
}
+ rDef.SetType( eType );
+ rDef.SetLen( nSize );
}
// Here variables, arrays and structures were defined.
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
index 6c60c02b0d7e..2baf28a803e3 100644
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -210,49 +210,49 @@ void SbiExprNode::GenElement( SbiCodeGen& rGen, SbiOpcode eOp )
void SbiExprList::Gen(SbiCodeGen& rGen)
{
- if( !aData.empty() )
- {
- rGen.Gen( SbiOpcode::ARGC_ );
- // Type adjustment at DECLARE
+ if( aData.empty() )
+ return;
- for( auto& pExpr: aData )
- {
- pExpr->Gen();
- if( !pExpr->GetName().isEmpty() )
- {
- // named arg
- sal_uInt16 nSid = rGen.GetParser()->aGblStrings.Add( pExpr->GetName() );
- rGen.Gen( SbiOpcode::ARGN_, nSid );
+ rGen.Gen( SbiOpcode::ARGC_ );
+ // Type adjustment at DECLARE
- /* TODO: Check after Declare concept change
- // From 1996-01-10: Type adjustment at named -> search suitable parameter
- if( pProc )
- {
- // For the present: trigger an error
- pParser->Error( ERRCODE_BASIC_NO_NAMED_ARGS );
+ for( auto& pExpr: aData )
+ {
+ pExpr->Gen();
+ if( !pExpr->GetName().isEmpty() )
+ {
+ // named arg
+ sal_uInt16 nSid = rGen.GetParser()->aGblStrings.Add( pExpr->GetName() );
+ rGen.Gen( SbiOpcode::ARGN_, nSid );
- // Later, if Named Args at DECLARE is possible
- //for( sal_uInt16 i = 1 ; i < nParAnz ; i++ )
- //{
- // SbiSymDef* pDef = pPool->Get( i );
- // const String& rName = pDef->GetName();
- // if( rName.Len() )
- // {
- // if( pExpr->GetName().ICompare( rName )
- // == COMPARE_EQUAL )
- // {
- // pParser->aGen.Gen( ARGTYP_, pDef->GetType() );
- // break;
- // }
- // }
- //}
- }
- */
- }
- else
+ /* TODO: Check after Declare concept change
+ // From 1996-01-10: Type adjustment at named -> search suitable parameter
+ if( pProc )
{
- rGen.Gen( SbiOpcode::ARGV_ );
+ // For the present: trigger an error
+ pParser->Error( ERRCODE_BASIC_NO_NAMED_ARGS );
+
+ // Later, if Named Args at DECLARE is possible
+ //for( sal_uInt16 i = 1 ; i < nParAnz ; i++ )
+ //{
+ // SbiSymDef* pDef = pPool->Get( i );
+ // const String& rName = pDef->GetName();
+ // if( rName.Len() )
+ // {
+ // if( pExpr->GetName().ICompare( rName )
+ // == COMPARE_EQUAL )
+ // {
+ // pParser->aGen.Gen( ARGTYP_, pDef->GetType() );
+ // break;
+ // }
+ // }
+ //}
}
+ */
+ }
+ else
+ {
+ rGen.Gen( SbiOpcode::ARGV_ );
}
}
}
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 9e4c6ea2e6b3..8fb38b44eeb6 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -232,189 +232,189 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* pParser)
{
pLeft->FoldConstants(pParser);
pRight->FoldConstants(pParser);
- if( pLeft->IsConstant() && pRight->IsConstant()
- && pLeft->eNodeType == pRight->eNodeType )
+ if( !(pLeft->IsConstant() && pRight->IsConstant()
+ && pLeft->eNodeType == pRight->eNodeType) )
+ return;
+
+ CollectBits();
+ if( eTok == CAT )
+ // CAT affiliate also two numbers!
+ eType = SbxSTRING;
+ if( pLeft->eType == SbxSTRING )
+ // No Type Mismatch!
+ eType = SbxSTRING;
+ if( eType == SbxSTRING )
{
- CollectBits();
- if( eTok == CAT )
- // CAT affiliate also two numbers!
- eType = SbxSTRING;
- if( pLeft->eType == SbxSTRING )
- // No Type Mismatch!
+ OUString rl( pLeft->GetString() );
+ OUString rr( pRight->GetString() );
+ pLeft.reset();
+ pRight.reset();
+ if( eTok == PLUS || eTok == CAT )
+ {
+ eTok = CAT;
+ // Linking:
+ aStrVal = rl;
+ aStrVal += rr;
eType = SbxSTRING;
- if( eType == SbxSTRING )
+ eNodeType = SbxSTRVAL;
+ }
+ else
{
- OUString rl( pLeft->GetString() );
- OUString rr( pRight->GetString() );
- pLeft.reset();
- pRight.reset();
- if( eTok == PLUS || eTok == CAT )
+ eType = SbxDOUBLE;
+ eNodeType = SbxNUMVAL;
+ int eRes = rr.compareTo( rl );
+ switch( eTok )
{
- eTok = CAT;
- // Linking:
- aStrVal = rl;
- aStrVal += rr;
- eType = SbxSTRING;
- eNodeType = SbxSTRVAL;
+ case EQ:
+ nVal = ( eRes == 0 ) ? SbxTRUE : SbxFALSE;
+ break;
+ case NE:
+ nVal = ( eRes != 0 ) ? SbxTRUE : SbxFALSE;
+ break;
+ case LT:
+ nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE;
+ break;
+ case GT:
+ nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE;
+ break;
+ case LE:
+ nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE;
+ break;
+ case GE:
+ nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE;
+ break;
+ default:
+ pParser->Error( ERRCODE_BASIC_CONVERSION );
+ bError = true;
+ break;
}
- else
+ }
+ }
+ else
+ {
+ double nl = pLeft->nVal;
+ double nr = pRight->nVal;
+ long ll = 0, lr = 0;
+ long llMod = 0, lrMod = 0;
+ if( ( eTok >= AND && eTok <= IMP )
+ || eTok == IDIV || eTok == MOD )
+ {
+ // Integer operations
+ bool bErr = false;
+ if( nl > SbxMAXLNG )
{
- eType = SbxDOUBLE;
- eNodeType = SbxNUMVAL;
- int eRes = rr.compareTo( rl );
- switch( eTok )
- {
- case EQ:
- nVal = ( eRes == 0 ) ? SbxTRUE : SbxFALSE;
- break;
- case NE:
- nVal = ( eRes != 0 ) ? SbxTRUE : SbxFALSE;
- break;
- case LT:
- nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE;
- break;
- case GT:
- nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE;
- break;
- case LE:
- nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE;
- break;
- case GE:
- nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE;
- break;
- default:
- pParser->Error( ERRCODE_BASIC_CONVERSION );
- bError = true;
- break;
- }
+ bErr = true;
+ nl = SbxMAXLNG;
+ }
+ else if( nl < SbxMINLNG )
+ {
+ bErr = true;
+ nl = SbxMINLNG;
+ }
+ if( nr > SbxMAXLNG )
+ {
+ bErr = true;
+ nr = SbxMAXLNG;
+ }
+ else if( nr < SbxMINLNG )
+ {
+ bErr = true;
+ nr = SbxMINLNG;
+ }
+ ll = static_cast<long>(nl); lr = static_cast<long>(nr);
+ llMod = static_cast<long>(nl);
+ lrMod = static_cast<long>(nr);
+ if( bErr )
+ {
+ pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW );
+ bError = true;
}
}
- else
+ bool bBothInt = ( pLeft->eType < SbxSINGLE
+ && pRight->eType < SbxSINGLE );
+ pLeft.reset();
+ pRight.reset();
+ nVal = 0;
+ eType = SbxDOUBLE;
+ eNodeType = SbxNUMVAL;
+ bool bCheckType = false;
+ switch( eTok )
{
- double nl = pLeft->nVal;
- double nr = pRight->nVal;
- long ll = 0, lr = 0;
- long llMod = 0, lrMod = 0;
- if( ( eTok >= AND && eTok <= IMP )
- || eTok == IDIV || eTok == MOD )
- {
- // Integer operations
- bool bErr = false;
- if( nl > SbxMAXLNG )
- {
- bErr = true;
- nl = SbxMAXLNG;
- }
- else if( nl < SbxMINLNG )
+ case EXPON:
+ nVal = pow( nl, nr ); break;
+ case MUL:
+ bCheckType = true;
+ nVal = nl * nr; break;
+ case DIV:
+ if( !nr )
{
- bErr = true;
- nl = SbxMINLNG;
- }
- if( nr > SbxMAXLNG )
- {
- bErr = true;
- nr = SbxMAXLNG;
- }
- else if( nr < SbxMINLNG )
+ pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
+ bError = true;
+ } else nVal = nl / nr;
+ break;
+ case PLUS:
+ bCheckType = true;
+ nVal = nl + nr; break;
+ case MINUS:
+ bCheckType = true;
+ nVal = nl - nr; break;
+ case EQ:
+ nVal = ( nl == nr ) ? SbxTRUE : SbxFALSE;
+ eType = SbxINTEGER; break;
+ case NE:
+ nVal = ( nl != nr ) ? SbxTRUE : SbxFALSE;
+ eType = SbxINTEGER; break;
+ case LT:
+ nVal = ( nl < nr ) ? SbxTRUE : SbxFALSE;
+ eType = SbxINTEGER; break;
+ case GT:
+ nVal = ( nl > nr ) ? SbxTRUE : SbxFALSE;
+ eType = SbxINTEGER; break;
+ case LE:
+ nVal = ( nl <= nr ) ? SbxTRUE : SbxFALSE;
+ eType = SbxINTEGER; break;
+ case GE:
+ nVal = ( nl >= nr ) ? SbxTRUE : SbxFALSE;
+ eType = SbxINTEGER; break;
+ case IDIV:
+ if( !lr )
{
- bErr = true;
- nr = SbxMINLNG;
- }
- ll = static_cast<long>(nl); lr = static_cast<long>(nr);
- llMod = static_cast<long>(nl);
- lrMod = static_cast<long>(nr);
- if( bErr )
+ pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
+ bError = true;
+ } else nVal = ll / lr;
+ eType = SbxLONG; break;
+ case MOD:
+ if( !lr )
{
- pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW );
+ pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
bError = true;
- }
- }
- bool bBothInt = ( pLeft->eType < SbxSINGLE
- && pRight->eType < SbxSINGLE );
- pLeft.reset();
- pRight.reset();
- nVal = 0;
- eType = SbxDOUBLE;
- eNodeType = SbxNUMVAL;
- bool bCheckType = false;
- switch( eTok )
- {
- case EXPON:
- nVal = pow( nl, nr ); break;
- case MUL:
- bCheckType = true;
- nVal = nl * nr; break;
- case DIV:
- if( !nr )
- {
- pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
- bError = true;
- } else nVal = nl / nr;
- break;
- case PLUS:
- bCheckType = true;
- nVal = nl + nr; break;
- case MINUS:
- bCheckType = true;
- nVal = nl - nr; break;
- case EQ:
- nVal = ( nl == nr ) ? SbxTRUE : SbxFALSE;
- eType = SbxINTEGER; break;
- case NE:
- nVal = ( nl != nr ) ? SbxTRUE : SbxFALSE;
- eType = SbxINTEGER; break;
- case LT:
- nVal = ( nl < nr ) ? SbxTRUE : SbxFALSE;
- eType = SbxINTEGER; break;
- case GT:
- nVal = ( nl > nr ) ? SbxTRUE : SbxFALSE;
- eType = SbxINTEGER; break;
- case LE:
- nVal = ( nl <= nr ) ? SbxTRUE : SbxFALSE;
- eType = SbxINTEGER; break;
- case GE:
- nVal = ( nl >= nr ) ? SbxTRUE : SbxFALSE;
- eType = SbxINTEGER; break;
- case IDIV:
- if( !lr )
- {
- pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
- bError = true;
- } else nVal = ll / lr;
- eType = SbxLONG; break;
- case MOD:
- if( !lr )
- {
- pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
- bError = true;
- } else nVal = llMod - lrMod * (llMod/lrMod);
- eType = SbxLONG; break;
- case AND:
- nVal = static_cast<double>( ll & lr ); eType = SbxLONG; break;
- case OR:
- nVal = static_cast<double>( ll | lr ); eType = SbxLONG; break;
- case XOR:
- nVal = static_cast<double>( ll ^ lr ); eType = SbxLONG; break;
- case EQV:
- nVal = static_cast<double>( ~ll ^ lr ); eType = SbxLONG; break;
- case IMP:
- nVal = static_cast<double>( ~ll | lr ); eType = SbxLONG; break;
- default: break;
- }
+ } else nVal = llMod - lrMod * (llMod/lrMod);
+ eType = SbxLONG; break;
+ case AND:
+ nVal = static_cast<double>( ll & lr ); eType = SbxLONG; break;
+ case OR:
+ nVal = static_cast<double>( ll | lr ); eType = SbxLONG; break;
+ case XOR:
+ nVal = static_cast<double>( ll ^ lr ); eType = SbxLONG; break;
+ case EQV:
+ nVal = static_cast<double>( ~ll ^ lr ); eType = SbxLONG; break;
+ case IMP:
+ nVal = static_cast<double>( ~ll | lr ); eType = SbxLONG; break;
+ default: break;
+ }
- if( !std::isfinite( nVal ) )
- pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW );
+ if( !std::isfinite( nVal ) )
+ pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW );
- // Recover the data type to kill rounding error
- if( bCheckType && bBothInt
- && nVal >= SbxMINLNG && nVal <= SbxMAXLNG )
- {
- // Decimal place away
- long n = static_cast<long>(nVal);
- nVal = n;
- eType = ( n >= SbxMININT && n <= SbxMAXINT )
- ? SbxINTEGER : SbxLONG;
- }
+ // Recover the data type to kill rounding error
+ if( bCheckType && bBothInt
+ && nVal >= SbxMINLNG && nVal <= SbxMAXLNG )
+ {
+ // Decimal place away
+ long n = static_cast<long>(nVal);
+ nVal = n;
+ eType = ( n >= SbxMININT && n <= SbxMAXINT )
+ ? SbxINTEGER : SbxLONG;
}
}
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 45cf7e358fe6..c2b6329e44eb 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -211,19 +211,19 @@ void SbiParser::OpenBlock( SbiToken eTok, SbiExprNode* pVar )
void SbiParser::CloseBlock()
{
- if( pStack )
- {
- SbiParseStack* p = pStack;
+ if( !pStack )
+ return;
- // #29955 service the for-loop level
- if( p->eExitTok == FOR )
- aGen.DecForLevel();
+ SbiParseStack* p = pStack;
- aGen.BackChain( p->nChain );
- pStack = p->pNext;
- pWithVar = p->pWithVar;
- delete p;
- }
+ // #29955 service the for-loop level
+ if( p->eExitTok == FOR )
+ aGen.DecForLevel();
+
+ aGen.BackChain( p->nChain );
+ pStack = p->pNext;
+ pWithVar = p->pWithVar;
+ delete p;
}
// EXIT ...
@@ -525,37 +525,37 @@ void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo )
}
}
aVar.Gen( eRecMode );
- if( !bSpecialMidHandling )
+ if( bSpecialMidHandling )
+ return;
+
+ if( !bEQ )
{
- if( !bEQ )
- {
- aGen.Gen( SbiOpcode::GET_ );
- }
- else
+ aGen.Gen( SbiOpcode::GET_ );
+ }
+ else
+ {
+ // so it must be an assignment!
+ if( !aVar.IsLvalue() )
+ Error( ERRCODE_BASIC_LVALUE_EXPECTED );
+ TestToken( EQ );
+ SbiExpression aExpr( this );
+ aExpr.Gen();
+ SbiOpcode eOp = SbiOpcode::PUT_;
+ if( pDef )
{
- // so it must be an assignment!
- if( !aVar.IsLvalue() )
- Error( ERRCODE_BASIC_LVALUE_EXPECTED );
- TestToken( EQ );
- SbiExpression aExpr( this );
- aExpr.Gen();
- SbiOpcode eOp = SbiOpcode::PUT_;
- if( pDef )
+ if( pDef->GetConstDef() )
+ Error( ERRCODE_BASIC_DUPLICATE_DEF, pDef->GetName() );
+ if( pDef->GetType() == SbxOBJECT )
{
- if( pDef->GetConstDef() )
- Error( ERRCODE_BASIC_DUPLICATE_DEF, pDef->GetName() );
- if( pDef->GetType() == SbxOBJECT )
+ eOp = SbiOpcode::SET_;
+ if( pDef->GetTypeId() )
{
- eOp = SbiOpcode::SET_;
- if( pDef->GetTypeId() )
- {
- aGen.Gen( SbiOpcode::SETCLASS_, pDef->GetTypeId() );
- return;
- }
+ aGen.Gen( SbiOpcode::SETCLASS_, pDef->GetTypeId() );
+ return;
}
}
- aGen.Gen( eOp );
}
+ aGen.Gen( eOp );
}
}
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 8385a31a3fdd..00a857abad6a 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -132,39 +132,39 @@ SbiProcDef* SbiSymPool::AddProc( const OUString& rName )
void SbiSymPool::Add( SbiSymDef* pDef )
{
- if( pDef && pDef->pIn != this )
+ if( !(pDef && pDef->pIn != this) )
+ return;
+
+ if( pDef->pIn )
{
- if( pDef->pIn )
- {
#ifdef DBG_UTIL
- pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "Dbl Pool" );
+ pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "Dbl Pool" );
#endif
- return;
- }
+ return;
+ }
- pDef->nPos = m_Data.size();
- if( !pDef->nId )
+ pDef->nPos = m_Data.size();
+ if( !pDef->nId )
+ {
+ // A unique name must be created in the string pool
+ // for static variables (Form ProcName:VarName)
+ OUString aName( pDef->aName );
+ if( pDef->IsStatic() )
{
- // A unique name must be created in the string pool
- // for static variables (Form ProcName:VarName)
- OUString aName( pDef->aName );
- if( pDef->IsStatic() )
- {
- aName = pParser->aGblStrings.Find( nProcId )
- + ":"
- + pDef->aName;
- }
- pDef->nId = rStrings.Add( aName );
+ aName = pParser->aGblStrings.Find( nProcId )
+ + ":"
+ + pDef->aName;
}
+ pDef->nId = rStrings.Add( aName );
+ }
- if( !pDef->GetProcDef() )
- {
- pDef->nProcId = nProcId;
- }
- pDef->pIn = this;
- m_Data.insert( m_Data.begin() + pDef->nPos, std::unique_ptr<SbiSymDef>(pDef) );
+ if( !pDef->GetProcDef() )
+ {
+ pDef->nProcId = nProcId;
}
+ pDef->pIn = this;
+ m_Data.insert( m_Data.begin() + pDef->nPos, std::unique_ptr<SbiSymDef>(pDef) );
}
@@ -454,24 +454,24 @@ void SbiProcDef::Match( SbiProcDef* pOld )
void SbiProcDef::setPropertyMode( PropertyMode ePropMode )
{
mePropMode = ePropMode;
- if( mePropMode != PropertyMode::NONE )
- {
- // Prop name = original scanned procedure name
- maPropName = aName;
+ if( mePropMode == PropertyMode::NONE )
+ return;
- // CompleteProcName includes "Property xxx "
- // to avoid conflicts with other symbols
- OUString aCompleteProcName = "Property ";
- switch( mePropMode )
- {
- case PropertyMode::Get: aCompleteProcName += "Get "; break;
- case PropertyMode::Let: aCompleteProcName += "Let "; break;
- case PropertyMode::Set: aCompleteProcName += "Set "; break;
- case PropertyMode::NONE: OSL_FAIL( "Illegal PropertyMode PropertyMode::NONE" ); break;
- }
- aCompleteProcName += aName;
- aName = aCompleteProcName;
+ // Prop name = original scanned procedure name
+ maPropName = aName;
+
+ // CompleteProcName includes "Property xxx "
+ // to avoid conflicts with other symbols
+ OUString aCompleteProcName = "Property ";
+ switch( mePropMode )
+ {
+ case PropertyMode::Get: aCompleteProcName += "Get "; break;
+ case PropertyMode::Let: aCompleteProcName += "Let "; break;
+ case PropertyMode::Set: aCompleteProcName += "Set "; break;
+ case PropertyMode::NONE: OSL_FAIL( "Illegal PropertyMode PropertyMode::NONE" ); break;
}
+ aCompleteProcName += aName;
+ aName = aCompleteProcName;
}
diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx
index b18284607b01..6da6ed9e2e2d 100644
--- a/basic/source/runtime/basrdll.cxx
+++ b/basic/source/runtime/basrdll.cxx
@@ -98,22 +98,22 @@ void BasicDLL::BasicBreak()
{
DBG_ASSERT( BasicDLLImpl::BASIC_DLL, "BasicDLL::EnableBreak: No instance yet!" );
#if HAVE_FEATURE_SCRIPTING
- if (BasicDLLImpl::BASIC_DLL)
+ if (!BasicDLLImpl::BASIC_DLL)
+ return;
+
+ // bJustStopping: if there's someone pressing STOP like crazy umpteen times,
+ // but the Basic doesn't stop early enough, the box might appear more often...
+ static bool bJustStopping = false;
+ if (StarBASIC::IsRunning() && !bJustStopping
+ && (BasicDLLImpl::BASIC_DLL->bBreakEnabled || BasicDLLImpl::BASIC_DLL->bDebugMode))
{
- // bJustStopping: if there's someone pressing STOP like crazy umpteen times,
- // but the Basic doesn't stop early enough, the box might appear more often...
- static bool bJustStopping = false;
- if (StarBASIC::IsRunning() && !bJustStopping
- && (BasicDLLImpl::BASIC_DLL->bBreakEnabled || BasicDLLImpl::BASIC_DLL->bDebugMode))
- {
- bJustStopping = true;
- StarBASIC::Stop();
- std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr,
- VclMessageType::Info, VclButtonsType::Ok,
- BasResId(IDS_SBERR_TERMINATED)));
- xInfoBox->run();
- bJustStopping = false;
- }
+ bJustStopping = true;
+ StarBASIC::Stop();
+ std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(nullptr,
+ VclMessageType::Info, VclButtonsType::Ok,
+ BasResId(IDS_SBERR_TERMINATED)));
+ xInfoBox->run();
+ bJustStopping = false;
}
#endif
}
diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx
index 533ee4f4d6a4..d525d1a13801 100644
--- a/basic/source/runtime/iosys.cxx
+++ b/basic/source/runtime/iosys.cxx
@@ -106,26 +106,26 @@ SbiStream::~SbiStream()
void SbiStream::MapError()
{
- if( pStrm )
- {
- ErrCode nEC = pStrm->GetError();
- if (nEC == ERRCODE_NONE)
- nError = ERRCODE_NONE;
- else if (nEC == SVSTREAM_FILE_NOT_FOUND)
- nError = ERRCODE_BASIC_FILE_NOT_FOUND;
- else if (nEC ==SVSTREAM_PATH_NOT_FOUND)
- nError = ERRCODE_BASIC_PATH_NOT_FOUND;
- else if (nEC ==SVSTREAM_TOO_MANY_OPEN_FILES)
- nError = ERRCODE_BASIC_TOO_MANY_FILES;
- else if (nEC ==SVSTREAM_ACCESS_DENIED)
- nError = ERRCODE_BASIC_ACCESS_DENIED;
- else if (nEC ==SVSTREAM_INVALID_PARAMETER)
- nError = ERRCODE_BASIC_BAD_ARGUMENT;
- else if (nEC ==SVSTREAM_OUTOFMEMORY)
- nError = ERRCODE_BASIC_NO_MEMORY;
- else
- nError = ERRCODE_BASIC_IO_ERROR;
- }
+ if( !pStrm )
+ return;
+
+ ErrCode nEC = pStrm->GetError();
+ if (nEC == ERRCODE_NONE)
+ nError = ERRCODE_NONE;
+ else if (nEC == SVSTREAM_FILE_NOT_FOUND)
+ nError = ERRCODE_BASIC_FILE_NOT_FOUND;
+ else if (nEC ==SVSTREAM_PATH_NOT_FOUND)
+ nError = ERRCODE_BASIC_PATH_NOT_FOUND;
+ else if (nEC ==SVSTREAM_TOO_MANY_OPEN_FILES)
+ nError = ERRCODE_BASIC_TOO_MANY_FILES;
+ else if (nEC ==SVSTREAM_ACCESS_DENIED)
+ nError = ERRCODE_BASIC_ACCESS_DENIED;
+ else if (nEC ==SVSTREAM_INVALID_PARAMETER)
+ nError = ERRCODE_BASIC_BAD_ARGUMENT;
+ else if (nEC ==SVSTREAM_OUTOFMEMORY)
+ nError = ERRCODE_BASIC_NO_MEMORY;
+ else
+ nError = ERRCODE_BASIC_IO_ERROR;
}
// Returns sal_True if UNO is available, otherwise the old file
@@ -543,23 +543,23 @@ ErrCode const & SbiStream::Read( char& ch )
void SbiStream::ExpandFile()
{
- if ( nExpandOnWriteTo )
+ if ( !nExpandOnWriteTo )
+ return;
+
+ sal_uInt64 nCur = pStrm->Seek(STREAM_SEEK_TO_END);
+ if( nCur < nExpandOnWriteTo )
{
- sal_uInt64 nCur = pStrm->Seek(STREAM_SEEK_TO_END);
- if( nCur < nExpandOnWriteTo )
- {
- sal_uInt64 nDiff = nExpandOnWriteTo - nCur;
- while( nDiff-- )
- {
- pStrm->WriteChar( 0 );
- }
- }
- else
+ sal_uInt64 nDiff = nExpandOnWriteTo - nCur;
+ while( nDiff-- )
{
- pStrm->Seek( nExpandOnWriteTo );
+ pStrm->WriteChar( 0 );
}
- nExpandOnWriteTo = 0;
}
+ else
+ {
+ pStrm->Seek( nExpandOnWriteTo );
+ }
+ nExpandOnWriteTo = 0;
}
namespace
@@ -811,37 +811,37 @@ void SbiIoSystem::WriteCon(const OUString& rText)
aOut += rText;
sal_Int32 n1 = aOut.indexOf('\n');
sal_Int32 n2 = aOut.indexOf('\r');
- if( n1 != -1 || n2 != -1 )
+ if( n1 == -1 && n2 == -1 )
+ return;
+
+ if( n1 == -1 )
{
- if( n1 == -1 )
- {
- n1 = n2;
- }
- else if( n2 == -1 )
- {
- n2 = n1;
- }
- if( n1 > n2 )
- {
- n1 = n2;
- }
- OUString s(aOut.copy(0, n1));
- aOut = aOut.copy(n1);
- while ( !aOut.isEmpty() && (aOut[0] == '\n' || aOut[0] == '\r') )
- {
- aOut = aOut.copy(1);
- }
- {
- SolarMutexGuard aSolarGuard;
+ n1 = n2;
+ }
+ else if( n2 == -1 )
+ {
+ n2 = n1;
+ }
+ if( n1 > n2 )
+ {
+ n1 = n2;
+ }
+ OUString s(aOut.copy(0, n1));
+ aOut = aOut.copy(n1);
+ while ( !aOut.isEmpty() && (aOut[0] == '\n' || aOut[0] == '\r') )
+ {
+ aOut = aOut.copy(1);
+ }
+ {
+ SolarMutexGuard aSolarGuard;
- vcl::Window* pParent = Application::GetDefDialogParent();
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, VclMessageType::Warning,
- VclButtonsType::OkCancel, s));
- xBox->set_default_response(RET_OK);
- if (!xBox->run())
- {
- nError = ERRCODE_BASIC_USER_ABORT;
- }
+ vcl::Window* pParent = Application::GetDefDialogParent();
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent ? pParent->GetFrameWeld() : nullptr, VclMessageType::Warning,
+ VclButtonsType::OkCancel, s));
+ xBox->set_default_response(RET_OK);
+ if (!xBox->run())
+ {
+ nError = ERRCODE_BASIC_USER_ABORT;
}
}
}
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 3214dd28602c..df177d334166 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -478,32 +478,32 @@ void SbRtl_ChDrive(StarBASIC *, SbxArray & rPar, bool)
void implStepRenameUCB( const OUString& aSource, const OUString& aDest )
{
const uno::Reference< ucb::XSimpleFileAccess3 >& xSFI = getFileAccess();
- if( xSFI.is() )
+ if( !xSFI.is() )
+ return;
+
+ try
{
- try
+ OUString aSourceFullPath = getFullPath( aSource );
+ if( !xSFI->exists( aSourceFullPath ) )
{
- OUString aSourceFullPath = getFullPath( aSource );
- if( !xSFI->exists( aSourceFullPath ) )
- {
- StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
- return;
- }
+ StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
+ return;
+ }
- OUString aDestFullPath = getFullPath( aDest );
- if( xSFI->exists( aDestFullPath ) )
- {
- StarBASIC::Error( ERRCODE_BASIC_FILE_EXISTS );
- }
- else
- {
- xSFI->move( aSourceFullPath, aDestFullPath );
- }
+ OUString aDestFullPath = getFullPath( aDest );
+ if( xSFI->exists( aDestFullPath ) )
+ {
+ StarBASIC::Error( ERRCODE_BASIC_FILE_EXISTS );
}
- catch(const Exception & )
+ else
{
- StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
+ xSFI->move( aSourceFullPath, aDestFullPath );
}
}
+ catch(const Exception & )
+ {
+ StarBASIC::Error( ERRCODE_BASIC_FILE_NOT_FOUND );
+ }
}
// Implementation of StepRENAME with OSL
@@ -4241,19 +4241,19 @@ void SbRtl_Load(StarBASIC *, SbxArray & rPar, bool)
SbxBase* pObj = rPar.Get32(1)->GetObject();
- if ( pObj )
+ if ( !pObj )
+ return;
+
+ if (SbUserFormModule* pModule = dynamic_cast<SbUserFormModule*>(pObj))
{
- if (SbUserFormModule* pModule = dynamic_cast<SbUserFormModule*>(pObj))
- {
- pModule->Load();
- }
- else if (SbxObject* pSbxObj = dynamic_cast<SbxObject*>(pObj))
+ pModule->Load();
+ }
+ else if (SbxObject* pSbxObj = dynamic_cast<SbxObject*>(pObj))
+ {
+ SbxVariable* pVar = pSbxObj->Find("Load", SbxClassType::Method);
+ if( pVar )
{
- SbxVariable* pVar = pSbxObj->Find("Load", SbxClassType::Method);
- if( pVar )
- {
- pVar->GetInteger();
- }
+ pVar->GetInteger();
}
}
}
@@ -4269,19 +4269,19 @@ void SbRtl_Unload(StarBASIC *, SbxArray & rPar, bool)
SbxBase* pObj = rPar.Get32(1)->GetObject();
- if ( pObj )
+ if ( !pObj )
+ return;
+
+ if (SbUserFormModule* pFormModule = dynamic_cast<SbUserFormModule*>(pObj))
{
- if (SbUserFormModule* pFormModule = dynamic_cast<SbUserFormModule*>(pObj))
- {
- pFormModule->Unload();
- }
- else if (SbxObject *pSbxObj = dynamic_cast<SbxObject*>(pObj))
+ pFormModule->Unload();
+ }
+ else if (SbxObject *pSbxObj = dynamic_cast<SbxObject*>(pObj))
+ {
+ SbxVariable* pVar = pSbxObj->Find("Unload", SbxClassType::Method);
+ if( pVar )
{
- SbxVariable* pVar = pSbxObj->Find("Unload", SbxClassType::Method);
- if( pVar )
- {
- pVar->GetInteger();
- }
+ pVar->GetInteger();
}
}
}
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 9d81ea52c62d..afe6c21790a1 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -740,19 +740,19 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
}
// ParamArray for missing parameter
- if( pInfo )
+ if( !pInfo )
+ return;
+
+ // #111897 Check first missing parameter for ParamArray
+ const SbxParamInfo* p = pInfo->GetParam(sal::static_int_cast<sal_uInt16>(nParamCount));
+ if( p && (p->nUserData & PARAM_INFO_PARAMARRAY) != 0 )
{
- // #111897 Check first missing parameter for ParamArray
- const SbxParamInfo* p = pInfo->GetParam(sal::static_int_cast<sal_uInt16>(nParamCount));
- if( p && (p->nUserData & PARAM_INFO_PARAMARRAY) != 0 )
- {
- SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
- pArray->unoAddDim32( 0, -1 );
- SbxVariable* pArrayVar = new SbxVariable( SbxVARIANT );
- pArrayVar->SetFlag( SbxFlagBits::ReadWrite );
- pArrayVar->PutObject( pArray );
- refParams->Put32( pArrayVar, nParamCount );
- }
+ SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
+ pArray->unoAddDim32( 0, -1 );
+ SbxVariable* pArrayVar = new SbxVariable( SbxVARIANT );
+ pArrayVar->SetFlag( SbxFlagBits::ReadWrite );
+ pArrayVar->PutObject( pArray );
+ refParams->Put32( pArrayVar, nParamCount );
}
}
@@ -907,40 +907,40 @@ bool SbiRuntime::Step()
void SbiRuntime::Error( ErrCode n, bool bVBATranslationAlreadyDone )
{
- if( n )
+ if( !n )
+ return;
+
+ nError = n;
+ if( !(isVBAEnabled() && !bVBATranslationAlreadyDone) )
+ return;
+
+ OUString aMsg = pInst->GetErrorMsg();
+ sal_Int32 nVBAErrorNumber = translateErrorToVba( nError, aMsg );
+ SbxVariable* pSbxErrObjVar = SbxErrObject::getErrObject().get();
+ SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( pSbxErrObjVar );
+ if( pGlobErr != nullptr )
{
- nError = n;
- if( isVBAEnabled() && !bVBATranslationAlreadyDone )
- {
- OUString aMsg = pInst->GetErrorMsg();
- sal_Int32 nVBAErrorNumber = translateErrorToVba( nError, aMsg );
- SbxVariable* pSbxErrObjVar = SbxErrObject::getErrObject().get();
- SbxErrObject* pGlobErr = static_cast< SbxErrObject* >( pSbxErrObjVar );
- if( pGlobErr != nullptr )
- {
- pGlobErr->setNumberAndDescription( nVBAErrorNumber, aMsg );
- }
- pInst->aErrorMsg = aMsg;
- nError = ERRCODE_BASIC_COMPAT;
- }
+ pGlobErr->setNumberAndDescription( nVBAErrorNumber, aMsg );
}
+ pInst->aErrorMsg = aMsg;
+ nError = ERRCODE_BASIC_COMPAT;
}
void SbiRuntime::Error( ErrCode _errCode, const OUString& _details )
{
- if ( _errCode )
+ if ( !_errCode )
+ return;
+
+ // Not correct for class module usage, remove for now
+ //OSL_WARN_IF( pInst->pRun != this, "basic", "SbiRuntime::Error: can't propagate the error message details!" );
+ if ( pInst->pRun == this )
{
- // Not correct for class module usage, remove for now
- //OSL_WARN_IF( pInst->pRun != this, "basic", "SbiRuntime::Error: can't propagate the error message details!" );
- if ( pInst->pRun == this )
- {
- pInst->Error( _errCode, _details );
- //OSL_WARN_IF( nError != _errCode, "basic", "SbiRuntime::Error: the instance is expected to propagate the error code back to me!" );
- }
- else
- {
- nError = _errCode;
- }
+ pInst->Error( _errCode, _details );
+ //OSL_WARN_IF( nError != _errCode, "basic", "SbiRuntime::Error: the instance is expected to propagate the error code back to me!" );
+ }
+ else
+ {
+ nError = _errCode;
}
}
@@ -2928,19 +2928,19 @@ void SbiRuntime::StepPAD( sal_uInt32 nOp1 )
SbxVariable* p = GetTOS();
OUString s = p->GetOUString();
sal_Int32 nLen(nOp1);
- if( s.getLength() != nLen )
+ if( s.getLength() == nLen )
+ return;
+
+ OUStringBuffer aBuf(s);
+ if (aBuf.getLength() > nLen)
{
- OUStringBuffer aBuf(s);
- if (aBuf.getLength() > nLen)
- {
- comphelper::string::truncateToLength(aBuf, nLen);
- }
- else
- {
- comphelper::string::padToLength(aBuf, nLen, ' ');
- }
- s = aBuf.makeStringAndClear();
+ comphelper::string::truncateToLength(aBuf, nLen);
+ }
+ else
+ {
+ comphelper::string::padToLength(aBuf, nLen, ' ');
}
+ s = aBuf.makeStringAndClear();
}
// jump (+target)
@@ -4355,52 +4355,53 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 )
return;
}
- if (SbxDimArray* pArray = dynamic_cast<SbxDimArray*>(pObj))
- {
- const sal_Int32 nDims = pArray->GetDims32();
- sal_Int32 nTotalSize = nDims > 0 ? 1 : 0;
+ SbxDimArray* pArray = dynamic_cast<SbxDimArray*>(pObj);
+ if (!pArray)
+ return;
- // must be a one-dimensional array
- sal_Int32 nLower, nUpper;
- for( sal_Int32 i = 0 ; i < nDims ; ++i )
- {
- pArray->GetDim32( i+1, nLower, nUpper );
- const sal_Int32 nSize = nUpper - nLower + 1;
- nTotalSize *= nSize;
- }
+ const sal_Int32 nDims = pArray->GetDims32();
+ sal_Int32 nTotalSize = nDims > 0 ? 1 : 0;
- // Optimization: pre-allocate underlying container
- if (nTotalSize > 0)
- pArray->SbxArray::GetRef32(nTotalSize - 1);
+ // must be a one-dimensional array
+ sal_Int32 nLower, nUpper;
+ for( sal_Int32 i = 0 ; i < nDims ; ++i )
+ {
+ pArray->GetDim32( i+1, nLower, nUpper );
+ const sal_Int32 nSize = nUpper - nLower + 1;
+ nTotalSize *= nSize;
+ }
- // First, fill those parts of the array that are preserved
- bool bWasError = false;
- const bool bRestored = implRestorePreservedArray(pArray, refRedimpArray, &bWasError);
- if (bWasError)
- nTotalSize = 0; // on error, don't create objects
+ // Optimization: pre-allocate underlying container
+ if (nTotalSize > 0)
+ pArray->SbxArray::GetRef32(nTotalSize - 1);
- // create objects and insert them into the array
- OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) );
- OUString aName;
- for( sal_Int32 i = 0 ; i < nTotalSize ; ++i )
+ // First, fill those parts of the array that are preserved
+ bool bWasError = false;
+ const bool bRestored = implRestorePreservedArray(pArray, refRedimpArray, &bWasError);
+ if (bWasError)
+ nTotalSize = 0; // on error, don't create objects
+
+ // create objects and insert them into the array
+ OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) );
+ OUString aName;
+ for( sal_Int32 i = 0 ; i < nTotalSize ; ++i )
+ {
+ if (!bRestored || !pArray->SbxArray::GetRef32(i)) // For those left unset after preserve
{
- if (!bRestored || !pArray->SbxArray::GetRef32(i)) // For those left unset after preserve
+ SbxObject* pClassObj = SbxBase::CreateObject(aClass);
+ if (!pClassObj)
{
- SbxObject* pClassObj = SbxBase::CreateObject(aClass);
- if (!pClassObj)
- {
- Error(ERRCODE_BASIC_INVALID_OBJECT);
- break;
- }
- else
- {
- if (aName.isEmpty())
- aName = pImg->GetString(static_cast<short>(nOp1));
- pClassObj->SetName(aName);
- // the object must be able to call the basic
- pClassObj->SetParent(&rBasic);
- pArray->SbxArray::Put32(pClassObj, i);
- }
+ Error(ERRCODE_BASIC_INVALID_OBJECT);
+ break;
+ }
+ else
+ {
+ if (aName.isEmpty())
+ aName = pImg->GetString(static_cast<short>(nOp1));
+ pClassObj->SetName(aName);
+ // the object must be able to call the basic
+ pClassObj->SetParent(&rBasic);
+ pArray->SbxArray::Put32(pClassObj, i);
}
}
}
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 708c09649a84..8a9513e81e0e 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -838,37 +838,37 @@ void SbiStdObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
+ if( !pHint )
+ return;
+
+ SbxVariable* pVar = pHint->GetVar();
+ SbxArray* pPar_ = pVar->GetParameters();
+ const sal_uInt16 nCallId = static_cast<sal_uInt16>(pVar->GetUserData());
+ if( nCallId )
{
- SbxVariable* pVar = pHint->GetVar();
- SbxArray* pPar_ = pVar->GetParameters();
- const sal_uInt16 nCallId = static_cast<sal_uInt16>(pVar->GetUserData());
- if( nCallId )
+ const SfxHintId t = pHint->GetId();
+ if( t == SfxHintId::BasicInfoWanted )
+ pVar->SetInfo( GetInfo( static_cast<short>(pVar->GetUserData()) ) );
+ else
{
- const SfxHintId t = pHint->GetId();
- if( t == SfxHintId::BasicInfoWanted )
- pVar->SetInfo( GetInfo( static_cast<short>(pVar->GetUserData()) ) );
- else
+ bool bWrite = false;
+ if( t == SfxHintId::BasicDataChanged )
+ bWrite = true;
+ if( t == SfxHintId::BasicDataWanted || bWrite )
{
- bool bWrite = false;
- if( t == SfxHintId::BasicDataChanged )
- bWrite = true;
- if( t == SfxHintId::BasicDataWanted || bWrite )
+ RtlCall p = aMethods[ nCallId-1 ].pFunc;
+ SbxArrayRef rPar( pPar_ );
+ if( !pPar_ )
{
- RtlCall p = aMethods[ nCallId-1 ].pFunc;
- SbxArrayRef rPar( pPar_ );
- if( !pPar_ )
- {
- rPar = pPar_ = new SbxArray;
- pPar_->Put32( pVar, 0 );
- }
- p( static_cast<StarBASIC*>(GetParent()), *pPar_, bWrite );
- return;
+ rPar = pPar_ = new SbxArray;
+ pPar_->Put32( pVar, 0 );
}
+ p( static_cast<StarBASIC*>(GetParent()), *pPar_, bWrite );
+ return;
}
}
- SbxObject::Notify( rBC, rHint );
}
+ SbxObject::Notify( rBC, rHint );
}
// building the info-structure for single elements
diff --git a/basic/source/runtime/stdobj1.cxx b/basic/source/runtime/stdobj1.cxx
index aad42547a58e..20268bfbf44b 100644
--- a/basic/source/runtime/stdobj1.cxx
+++ b/basic/source/runtime/stdobj1.cxx
@@ -126,28 +126,28 @@ void SbStdPicture::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
- {
- if( pHint->GetId() == SfxHintId::BasicInfoWanted )
- {
- SbxObject::Notify( rBC, rHint );
- return;
- }
-
- SbxVariable* pVar = pHint->GetVar();
- const sal_uInt32 nWhich = pVar->GetUserData();
- bool bWrite = pHint->GetId() == SfxHintId::BasicDataChanged;
-
- // Properties
- switch( nWhich )
- {
- case ATTR_IMP_TYPE: PropType( pVar, bWrite ); return;
- case ATTR_IMP_WIDTH: PropWidth( pVar, bWrite ); return;
- case ATTR_IMP_HEIGHT: PropHeight( pVar, bWrite ); return;
- }
+ if( !pHint )
+ return;
+ if( pHint->GetId() == SfxHintId::BasicInfoWanted )
+ {
SbxObject::Notify( rBC, rHint );
+ return;
}
+
+ SbxVariable* pVar = pHint->GetVar();
+ const sal_uInt32 nWhich = pVar->GetUserData();
+ bool bWrite = pHint->GetId() == SfxHintId::BasicDataChanged;
+
+ // Properties
+ switch( nWhich )
+ {
+ case ATTR_IMP_TYPE: PropType( pVar, bWrite ); return;
+ case ATTR_IMP_WIDTH: PropWidth( pVar, bWrite ); return;
+ case ATTR_IMP_HEIGHT: PropHeight( pVar, bWrite ); return;
+ }
+
+ SbxObject::Notify( rBC, rHint );
}
@@ -243,31 +243,31 @@ void SbStdFont::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
- {
- if( pHint->GetId() == SfxHintId::BasicInfoWanted )
- {
- SbxObject::Notify( rBC, rHint );
- return;
- }
-
- SbxVariable* pVar = pHint->GetVar();
- const sal_uInt32 nWhich = pVar->GetUserData();
- bool bWrite = pHint->GetId() == SfxHintId::BasicDataChanged;
-
- // Properties
- switch( nWhich )
- {
- case ATTR_IMP_BOLD: PropBold( pVar, bWrite ); return;
- case ATTR_IMP_ITALIC: PropItalic( pVar, bWrite ); return;
- case ATTR_IMP_STRIKETHROUGH:PropStrikeThrough( pVar, bWrite ); return;
- case ATTR_IMP_UNDERLINE: PropUnderline( pVar, bWrite ); return;
- case ATTR_IMP_SIZE: PropSize( pVar, bWrite ); return;
- case ATTR_IMP_NAME: PropName( pVar, bWrite ); return;
- }
+ if( !pHint )
+ return;
+ if( pHint->GetId() == SfxHintId::BasicInfoWanted )
+ {
SbxObject::Notify( rBC, rHint );
+ return;
}
+
+ SbxVariable* pVar = pHint->GetVar();
+ const sal_uInt32 nWhich = pVar->GetUserData();
+ bool bWrite = pHint->GetId() == SfxHintId::BasicDataChanged;
+
+ // Properties
+ switch( nWhich )
+ {
+ case ATTR_IMP_BOLD: PropBold( pVar, bWrite ); return;
+ case ATTR_IMP_ITALIC: PropItalic( pVar, bWrite ); return;
+ case ATTR_IMP_STRIKETHROUGH:PropStrikeThrough( pVar, bWrite ); return;
+ case ATTR_IMP_UNDERLINE: PropUnderline( pVar, bWrite ); return;
+ case ATTR_IMP_SIZE: PropSize( pVar, bWrite ); return;
+ case ATTR_IMP_NAME: PropName( pVar, bWrite ); return;
+ }
+
+ SbxObject::Notify( rBC, rHint );
}
@@ -391,31 +391,31 @@ void SbStdClipboard::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
const SbxHint* pHint = dynamic_cast<const SbxHint*>(&rHint);
- if( pHint )
- {
- if( pHint->GetId() == SfxHintId::BasicInfoWanted )
- {
- SbxObject::Notify( rBC, rHint );
- return;
- }
-
- SbxVariable* pVar = pHint->GetVar();
- SbxArray* pPar_ = pVar->GetParameters();
- const sal_uInt32 nWhich = pVar->GetUserData();
-
- // Methods
- switch( nWhich )
- {
- case METH_CLEAR: MethClear( pPar_ ); return;
- case METH_GETDATA: MethGetData( pPar_ ); return;
- case METH_GETFORMAT: MethGetFormat( pVar, pPar_ ); return;
- case METH_GETTEXT: MethGetText( pVar, pPar_ ); return;
- case METH_SETDATA: MethSetData( pPar_ ); return;
- case METH_SETTEXT: MethSetText( pPar_ ); return;
- }
+ if( !pHint )
+ return;
+ if( pHint->GetId() == SfxHintId::BasicInfoWanted )
+ {
SbxObject::Notify( rBC, rHint );
+ return;
}
+
+ SbxVariable* pVar = pHint->GetVar();
+ SbxArray* pPar_ = pVar->GetParameters();
+ const sal_uInt32 nWhich = pVar->GetUserData();
+
+ // Methods
+ switch( nWhich )
+ {
+ case METH_CLEAR: MethClear( pPar_ ); return;
+ case METH_GETDATA: MethGetData( pPar_ ); return;
+ case METH_GETFORMAT: MethGetFormat( pVar, pPar_ ); return;
+ case METH_GETTEXT: MethGetText( pVar, pPar_ ); return;
+ case METH_SETDATA: MethSetData( pPar_ ); return;
+ case METH_SETTEXT: MethSetText( pPar_ ); return;
+ }
+
+ SbxObject::Notify( rBC, rHint );
}
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index 5c7185276ac7..fe42fa1939a1 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -138,38 +138,38 @@ void SbxObject::Clear()
void SbxObject::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
const SbxHint* p = dynamic_cast<const SbxHint*>(&rHint);
- if( p )
+ if( !p )
+ return;
+
+ const SfxHintId nId = p->GetId();
+ bool bRead = ( nId == SfxHintId::BasicDataWanted );
+ bool bWrite = ( nId == SfxHintId::BasicDataChanged );
+ SbxVariable* pVar = p->GetVar();
+ if( !(bRead || bWrite) )
+ return;
+
+ OUString aVarName( pVar->GetName() );
+ sal_uInt16 nHash_ = MakeHashCode( aVarName );
+ if( nHash_ == nNameHash && aVarName.equalsIgnoreAsciiCase( pNameProp ) )
{
- const SfxHintId nId = p->GetId();
- bool bRead = ( nId == SfxHintId::BasicDataWanted );
- bool bWrite = ( nId == SfxHintId::BasicDataChanged );
- SbxVariable* pVar = p->GetVar();
- if( bRead || bWrite )
+ if( bRead )
{
- OUString aVarName( pVar->GetName() );
- sal_uInt16 nHash_ = MakeHashCode( aVarName );
- if( nHash_ == nNameHash && aVarName.equalsIgnoreAsciiCase( pNameProp ) )
- {
- if( bRead )
- {
- pVar->PutString( GetName() );
- }
- else
- {
- SetName( pVar->GetOUString() );
- }
- }
- else if( nHash_ == nParentHash && aVarName.equalsIgnoreAsciiCase( pParentProp ) )
- {
- SbxObject* p_ = GetParent();
- if( !p_ )
- {
- p_ = this;
- }
- pVar->PutObject( p_ );
- }
+ pVar->PutString( GetName() );
+ }
+ else
+ {
+ SetName( pVar->GetOUString() );
}
}
+ else if( nHash_ == nParentHash && aVarName.equalsIgnoreAsciiCase( pParentProp ) )
+ {
+ SbxObject* p_ = GetParent();
+ if( !p_ )
+ {
+ p_ = this;
+ }
+ pVar->PutObject( p_ );
+ }
}
bool SbxObject::IsClass( const OUString& rName ) const
@@ -392,59 +392,59 @@ void SbxObject::Insert( SbxVariable* pVar )
{
sal_uInt32 nIdx;
SbxArray* pArray = FindVar( pVar, nIdx );
- if( pArray )
+ if( !pArray )
+ return;
+
+ // Into with it. But you should pay attention at the Pointer!
+ if( nIdx < pArray->Count32() )
{
- // Into with it. But you should pay attention at the Pointer!
- if( nIdx < pArray->Count32() )
+ // Then this element exists already
+ // There are objects of the same name allowed at collections
+ if( pArray == pObjs.get() && dynamic_cast<const SbxCollection*>( this ) != nullptr )
{
- // Then this element exists already
- // There are objects of the same name allowed at collections
- if( pArray == pObjs.get() && dynamic_cast<const SbxCollection*>( this ) != nullptr )
+ nIdx = pArray->Count32();
+ }
+ else
+ {
+ SbxVariable* pOld = pArray->Get32( nIdx );
+ // already inside: overwrite
+ if( pOld == pVar )
{
- nIdx = pArray->Count32();
+ return;
}
- else
+ EndListening( pOld->GetBroadcaster(), true );
+ if( pVar->GetClass() == SbxClassType::Property )
{
- SbxVariable* pOld = pArray->Get32( nIdx );
- // already inside: overwrite
- if( pOld == pVar )
+ if( pOld == pDfltProp )
{
- return;
- }
- EndListening( pOld->GetBroadcaster(), true );
- if( pVar->GetClass() == SbxClassType::Property )
- {
- if( pOld == pDfltProp )
- {
- pDfltProp = static_cast<SbxProperty*>(pVar);
- }
+ pDfltProp = static_cast<SbxProperty*>(pVar);
}
}
}
- StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
- pArray->Put32( pVar, nIdx );
- if( pVar->GetParent() != this )
- {
- pVar->SetParent( this );
- }
- SetModified( true );
+ }
+ StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
+ pArray->Put32( pVar, nIdx );
+ if( pVar->GetParent() != this )
+ {
+ pVar->SetParent( this );
+ }
+ SetModified( true );
#ifdef DBG_UTIL
- static const char* pCls[] =
- { "DontCare","Array","Value","Variable","Method","Property","Object" };
- OUString aVarName( pVar->GetName() );
- if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
- {
- aVarName = pSbxObj->GetClassName();
- }
- SAL_INFO(
- "basic.sbx",
- "insert "
- << ((pVar->GetClass() >= SbxClassType::DontCare
- && pVar->GetClass() <= SbxClassType::Object)
- ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
- << " " << aVarName << " in " << SbxVariable::GetName());
-#endif
+ static const char* pCls[] =
+ { "DontCare","Array","Value","Variable","Method","Property","Object" };
+ OUString aVarName( pVar->GetName() );
+ if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
+ {
+ aVarName = pSbxObj->GetClassName();
}
+ SAL_INFO(
+ "basic.sbx",
+ "insert "
+ << ((pVar->GetClass() >= SbxClassType::DontCare
+ && pVar->GetClass() <= SbxClassType::Object)
+ ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
+ << " " << aVarName << " in " << SbxVariable::GetName());
+#endif
}
// Optimisation, Insertion without checking about
@@ -463,32 +463,32 @@ void SbxObject::QuickInsert( SbxVariable* pVar )
default: SAL_WARN( "basic.sbx", "Invalid SBX-Class" ); break;
}
}
- if( pArray )
+ if( !pArray )
+ return;
+
+ StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
+ pArray->Put32( pVar, pArray->Count32() );
+ if( pVar->GetParent() != this )
{
- StartListening(pVar->GetBroadcaster(), DuplicateHandling::Prevent);
- pArray->Put32( pVar, pArray->Count32() );
- if( pVar->GetParent() != this )
- {
- pVar->SetParent( this );
- }
- SetModified( true );
+ pVar->SetParent( this );
+ }
+ SetModified( true );
#ifdef DBG_UTIL
- static const char* pCls[] =
- { "DontCare","Array","Value","Variable","Method","Property","Object" };
- OUString aVarName( pVar->GetName() );
- if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
- {
- aVarName = pSbxObj->GetClassName();
- }
- SAL_INFO(
- "basic.sbx",
- "insert "
- << ((pVar->GetClass() >= SbxClassType::DontCare
- && pVar->GetClass() <= SbxClassType::Object)
- ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
- << " " << aVarName << " in " << SbxVariable::GetName());
-#endif
+ static const char* pCls[] =
+ { "DontCare","Array","Value","Variable","Method","Property","Object" };
+ OUString aVarName( pVar->GetName() );
+ if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
+ {
+ aVarName = pSbxObj->GetClassName();
}
+ SAL_INFO(
+ "basic.sbx",
+ "insert "
+ << ((pVar->GetClass() >= SbxClassType::DontCare
+ && pVar->GetClass() <= SbxClassType::Object)
+ ? pCls[static_cast<int>(pVar->GetClass()) - 1] : "Unknown class")
+ << " " << aVarName << " in " << SbxVariable::GetName());
+#endif
}
void SbxObject::Remove( const OUString& rName, SbxClassType t )
@@ -500,34 +500,34 @@ void SbxObject::Remove( SbxVariable* pVar )
{
sal_uInt32 nIdx;
SbxArray* pArray = FindVar( pVar, nIdx );
- if( pArray && nIdx < pArray->Count32() )
- {
+ if( !(pArray && nIdx < pArray->Count32()) )
+ return;
+
#ifdef DBG_UTIL
- OUString aVarName( pVar->GetName() );
- if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
- {
- aVarName = pSbxObj->GetClassName();
- }
- SAL_INFO(
- "basic.sbx",
- "remove " << aVarName << " in " << SbxVariable::GetName());
+ OUString aVarName( pVar->GetName() );
+ if (const SbxObject *pSbxObj = aVarName.isEmpty() ? dynamic_cast<const SbxObject*>(pVar) : nullptr)
+ {
+ aVarName = pSbxObj->GetClassName();
+ }
+ SAL_INFO(
+ "basic.sbx",
+ "remove " << aVarName << " in " << SbxVariable::GetName());
#endif
- SbxVariableRef pVar_ = pArray->Get32( nIdx );
- if( pVar_->IsBroadcaster() )
- {
- EndListening( pVar_->GetBroadcaster(), true );
- }
- if( pVar_.get() == pDfltProp )
- {
- pDfltProp = nullptr;
- }
- pArray->Remove( nIdx );
- if( pVar_->GetParent() == this )
- {
- pVar_->SetParent( nullptr );
- }
- SetModified( true );
+ SbxVariableRef pVar_ = pArray->Get32( nIdx );
+ if( pVar_->IsBroadcaster() )
+ {
+ EndListening( pVar_->GetBroadcaster(), true );
+ }
+ if( pVar_.get() == pDfltProp )
+ {
+ pDfltProp = nullptr;
}
+ pArray->Remove( nIdx );
+ if( pVar_->GetParent() == this )
+ {
+ pVar_->SetParent( nullptr );
+ }
+ SetModified( true );
}
static bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray )
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index d8425d59aaa6..5f892417825b 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -146,42 +146,42 @@ SbxArray* SbxVariable::GetParameters() const
void SbxVariable::Broadcast( SfxHintId nHintId )
{
- if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) )
+ if( !(mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast )) )
+ return;
+
+ // Because the method could be called from outside, check the
+ // rights here again
+ if( nHintId == SfxHintId::BasicDataWanted )
{
- // Because the method could be called from outside, check the
- // rights here again
- if( nHintId == SfxHintId::BasicDataWanted )
+ if( !CanRead() )
{
- if( !CanRead() )
- {
- return;
- }
+ return;
}
- if( nHintId == SfxHintId::BasicDataChanged )
+ }
+ if( nHintId == SfxHintId::BasicDataChanged )
+ {
+ if( !CanWrite() )
{
- if( !CanWrite() )
- {
- return;
- }
+ return;
}
+ }
- //fdo#86843 Add a ref during the following block to guard against
- //getting deleted before completing this method
- SbxVariableRef aBroadcastGuard(this);
+ //fdo#86843 Add a ref during the following block to guard against
+ //getting deleted before completing this method
+ SbxVariableRef aBroadcastGuard(this);
- // Avoid further broadcasting
- std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster);
- SbxFlagBits nSaveFlags = GetFlags();
- SetFlag( SbxFlagBits::ReadWrite );
- if( mpPar.is() )
- {
- // Register this as element 0, but don't change over the parent!
- mpPar->GetRef32( 0 ) = this;
- }
- pSave->Broadcast( SbxHint( nHintId, this ) );
- mpBroadcaster = std::move(pSave);
- SetFlags( nSaveFlags );
+ // Avoid further broadcasting
+ std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster);
+ SbxFlagBits nSaveFlags = GetFlags();
+ SetFlag( SbxFlagBits::ReadWrite );
+ if( mpPar.is() )
+ {
+ // Register this as element 0, but don't change over the parent!
+ mpPar->GetRef32( 0 ) = this;
}
+ pSave->Broadcast( SbxHint( nHintId, this ) );
+ mpBroadcaster = std::move(pSave);
+ SetFlags( nSaveFlags );
}
SbxInfo* SbxVariable::GetInfo()
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 6a510e0cc313..0904dcb766c2 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -983,232 +983,232 @@ void SfxLibraryContainer::init_Impl( const OUString& rInitialDocumentURL,
}
}
- if( meInitMode == DEFAULT )
- {
- INetURLObject aUserBasicInetObj( maLibraryPath.getToken(1, ';') );
- OUString aStandardStr("Standard");
+ if( meInitMode != DEFAULT )
+ return;
- INetURLObject aPrevUserBasicInetObj_1( aUserBasicInetObj );
- aPrevUserBasicInetObj_1.removeSegment();
- INetURLObject aPrevUserBasicInetObj_2 = aPrevUserBasicInetObj_1;
- aPrevUserBasicInetObj_1.Append( "__basic_80" );
- aPrevUserBasicInetObj_2.Append( "__basic_80_2" );
+ INetURLObject aUserBasicInetObj( maLibraryPath.getToken(1, ';') );
+ OUString aStandardStr("Standard");
- // #i93163
- bool bCleanUp = false;
- try
+ INetURLObject aPrevUserBasicInetObj_1( aUserBasicInetObj );
+ aPrevUserBasicInetObj_1.removeSegment();
+ INetURLObject aPrevUserBasicInetObj_2 = aPrevUserBasicInetObj_1;
+ aPrevUserBasicInetObj_1.Append( "__basic_80" );
+ aPrevUserBasicInetObj_2.Append( "__basic_80_2" );
+
+ // #i93163
+ bool bCleanUp = false;
+ try
+ {
+ INetURLObject aPrevUserBasicInetObj = aPrevUserBasicInetObj_1;
+ OUString aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( mxSFI->isFolder( aPrevFolder ) )
{
- INetURLObject aPrevUserBasicInetObj = aPrevUserBasicInetObj_1;
- OUString aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevFolder ) )
+ // Check if Standard folder exists and is complete
+ INetURLObject aUserBasicStandardInetObj( aUserBasicInetObj );
+ aUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ INetURLObject aPrevUserBasicStandardInetObj( aPrevUserBasicInetObj );
+ aPrevUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ OUString aPrevStandardFolder = aPrevUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( mxSFI->isFolder( aPrevStandardFolder ) )
{
- // Check if Standard folder exists and is complete
- INetURLObject aUserBasicStandardInetObj( aUserBasicInetObj );
- aUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- INetURLObject aPrevUserBasicStandardInetObj( aPrevUserBasicInetObj );
- aPrevUserBasicStandardInetObj.insertName( aStandardStr, true, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- OUString aPrevStandardFolder = aPrevUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevStandardFolder ) )
- {
- OUString aXlbExtension( "xlb" );
- OUString aCheckFileName;
-
- // Check if script.xlb exists
- aCheckFileName = "script";
- checkAndCopyFileImpl( aUserBasicStandardInetObj,
- aPrevUserBasicStandardInetObj,
- aCheckFileName, aXlbExtension, mxSFI );
-
- // Check if dialog.xlb exists
- aCheckFileName = "dialog";
- checkAndCopyFileImpl( aUserBasicStandardInetObj,
- aPrevUserBasicStandardInetObj,
- aCheckFileName, aXlbExtension, mxSFI );
-
- // Check if module1.xba exists
- aCheckFileName = "Module1";
- checkAndCopyFileImpl( aUserBasicStandardInetObj,
- aPrevUserBasicStandardInetObj,
- aCheckFileName, "xba", mxSFI );
- }
- else
- {
- OUString aStandardFolder = aUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- mxSFI->copy( aStandardFolder, aPrevStandardFolder );
- }
-
- OUString aPrevCopyToFolder = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- mxSFI->copy( aPrevFolder, aPrevCopyToFolder );
+ OUString aXlbExtension( "xlb" );
+ OUString aCheckFileName;
+
+ // Check if script.xlb exists
+ aCheckFileName = "script";
+ checkAndCopyFileImpl( aUserBasicStandardInetObj,
+ aPrevUserBasicStandardInetObj,
+ aCheckFileName, aXlbExtension, mxSFI );
+
+ // Check if dialog.xlb exists
+ aCheckFileName = "dialog";
+ checkAndCopyFileImpl( aUserBasicStandardInetObj,
+ aPrevUserBasicStandardInetObj,
+ aCheckFileName, aXlbExtension, mxSFI );
+
+ // Check if module1.xba exists
+ aCheckFileName = "Module1";
+ checkAndCopyFileImpl( aUserBasicStandardInetObj,
+ aPrevUserBasicStandardInetObj,
+ aCheckFileName, "xba", mxSFI );
}
else
{
- aPrevUserBasicInetObj = aPrevUserBasicInetObj_2;
- aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ OUString aStandardFolder = aUserBasicStandardInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ mxSFI->copy( aStandardFolder, aPrevStandardFolder );
}
- if( mxSFI->isFolder( aPrevFolder ) )
- {
- rtl::Reference<SfxLibraryContainer> pPrevCont = createInstanceImpl();
- // Rename previous basic folder to make storage URLs correct during initialisation
- OUString aFolderUserBasic = aUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- INetURLObject aUserBasicTmpInetObj( aUserBasicInetObj );
- aUserBasicTmpInetObj.removeSegment();
- aUserBasicTmpInetObj.Append( "__basic_tmp" );
- OUString aFolderTmp = aUserBasicTmpInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ OUString aPrevCopyToFolder = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ mxSFI->copy( aPrevFolder, aPrevCopyToFolder );
+ }
+ else
+ {
+ aPrevUserBasicInetObj = aPrevUserBasicInetObj_2;
+ aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ }
+ if( mxSFI->isFolder( aPrevFolder ) )
+ {
+ rtl::Reference<SfxLibraryContainer> pPrevCont = createInstanceImpl();
+
+ // Rename previous basic folder to make storage URLs correct during initialisation
+ OUString aFolderUserBasic = aUserBasicInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ INetURLObject aUserBasicTmpInetObj( aUserBasicInetObj );
+ aUserBasicTmpInetObj.removeSegment();
+ aUserBasicTmpInetObj.Append( "__basic_tmp" );
+ OUString aFolderTmp = aUserBasicTmpInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- mxSFI->move( aFolderUserBasic, aFolderTmp );
+ mxSFI->move( aFolderUserBasic, aFolderTmp );
+ try
+ {
+ mxSFI->move( aPrevFolder, aFolderUserBasic );
+ }
+ catch(const Exception& )
+ {
+ // Move back user/basic folder
try
{
- mxSFI->move( aPrevFolder, aFolderUserBasic );
+ mxSFI->kill( aFolderUserBasic );
}
catch(const Exception& )
- {
- // Move back user/basic folder
- try
- {
- mxSFI->kill( aFolderUserBasic );
- }
- catch(const Exception& )
- {}
- mxSFI->move( aFolderTmp, aFolderUserBasic );
- throw;
- }
-
- INetURLObject aPrevUserBasicLibInfoInetObj( aUserBasicInetObj );
- aPrevUserBasicLibInfoInetObj.insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- aPrevUserBasicLibInfoInetObj.setExtension( "xlc");
- OUString aLibInfoFileName = aPrevUserBasicLibInfoInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- Sequence<Any> aInitSeq( 1 );
- aInitSeq.getArray()[0] <<= aLibInfoFileName;
- GbMigrationSuppressErrors = true;
- pPrevCont->initialize( aInitSeq );
- GbMigrationSuppressErrors = false;
-
- // Rename folders back
- mxSFI->move( aFolderUserBasic, aPrevFolder );
+ {}
mxSFI->move( aFolderTmp, aFolderUserBasic );
+ throw;
+ }
- Sequence< OUString > aNames = pPrevCont->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nNameCount = aNames.getLength();
+ INetURLObject aPrevUserBasicLibInfoInetObj( aUserBasicInetObj );
+ aPrevUserBasicLibInfoInetObj.insertName( maInfoFileName, false, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ aPrevUserBasicLibInfoInetObj.setExtension( "xlc");
+ OUString aLibInfoFileName = aPrevUserBasicLibInfoInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ Sequence<Any> aInitSeq( 1 );
+ aInitSeq.getArray()[0] <<= aLibInfoFileName;
+ GbMigrationSuppressErrors = true;
+ pPrevCont->initialize( aInitSeq );
+ GbMigrationSuppressErrors = false;
+
+ // Rename folders back
+ mxSFI->move( aFolderUserBasic, aPrevFolder );
+ mxSFI->move( aFolderTmp, aFolderUserBasic );
+
+ Sequence< OUString > aNames = pPrevCont->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_Int32 nNameCount = aNames.getLength();
- for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ {
+ OUString aLibName = pNames[ i ];
+ if( hasByName( aLibName ) )
{
- OUString aLibName = pNames[ i ];
- if( hasByName( aLibName ) )
+ if( aLibName == aStandardStr )
{
- if( aLibName == aStandardStr )
- {
- SfxLibrary* pImplLib = getImplLib( aStandardStr );
- OUString aStandardFolder = pImplLib->maStorageURL;
- mxSFI->kill( aStandardFolder );
- }
- else
- {
- continue;
- }
+ SfxLibrary* pImplLib = getImplLib( aStandardStr );
+ OUString aStandardFolder = pImplLib->maStorageURL;
+ mxSFI->kill( aStandardFolder );
}
+ else
+ {
+ continue;
+ }
+ }
- SfxLibrary* pImplLib = pPrevCont->getImplLib( aLibName );
- if( pImplLib->mbLink )
+ SfxLibrary* pImplLib = pPrevCont->getImplLib( aLibName );
+ if( pImplLib->mbLink )
+ {
+ OUString aStorageURL = pImplLib->maUnexpandedStorageURL;
+ bool bCreateLink = true;
+ if( aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ) != -1 ||
+ aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ) != -1 ||
+ aStorageURL.indexOf( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ) != -1 ||
+ aStorageURL.indexOf( "$(INST)" ) != -1 )
{
- OUString aStorageURL = pImplLib->maUnexpandedStorageURL;
- bool bCreateLink = true;
- if( aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ) != -1 ||
- aStorageURL.indexOf( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ) != -1 ||
- aStorageURL.indexOf( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ) != -1 ||
- aStorageURL.indexOf( "$(INST)" ) != -1 )
- {
- bCreateLink = false;
- }
- if( bCreateLink )
- {
- createLibraryLink( aLibName, pImplLib->maStorageURL, pImplLib->mbReadOnly );
- }
+ bCreateLink = false;
}
- else
+ if( bCreateLink )
{
- // Move folder if not already done
- INetURLObject aUserBasicLibFolderInetObj( aUserBasicInetObj );
- aUserBasicLibFolderInetObj.Append( aLibName );
- OUString aLibFolder = aUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
-
- INetURLObject aPrevUserBasicLibFolderInetObj( aPrevUserBasicInetObj );
- aPrevUserBasicLibFolderInetObj.Append( aLibName );
- OUString aPrevLibFolder = aPrevUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ createLibraryLink( aLibName, pImplLib->maStorageURL, pImplLib->mbReadOnly );
+ }
+ }
+ else
+ {
+ // Move folder if not already done
+ INetURLObject aUserBasicLibFolderInetObj( aUserBasicInetObj );
+ aUserBasicLibFolderInetObj.Append( aLibName );
+ OUString aLibFolder = aUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevLibFolder ) && !mxSFI->isFolder( aLibFolder ) )
- {
- mxSFI->move( aPrevLibFolder, aLibFolder );
- }
+ INetURLObject aPrevUserBasicLibFolderInetObj( aPrevUserBasicInetObj );
+ aPrevUserBasicLibFolderInetObj.Append( aLibName );
+ OUString aPrevLibFolder = aPrevUserBasicLibFolderInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( aLibName == aStandardStr )
- {
- maNameContainer->removeByName( aLibName );
- }
+ if( mxSFI->isFolder( aPrevLibFolder ) && !mxSFI->isFolder( aLibFolder ) )
+ {
+ mxSFI->move( aPrevLibFolder, aLibFolder );
+ }
- // Create library
- Reference< XNameContainer > xLib = createLibrary( aLibName );
- SfxLibrary* pNewLib = static_cast< SfxLibrary* >( xLib.get() );
- pNewLib->mbLoaded = false;
- pNewLib->implSetModified( false );
- checkStorageURL( aLibFolder, pNewLib->maLibInfoFileURL,
- pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
-
- uno::Reference< embed::XStorage > xDummyStor;
- ::xmlscript::LibDescriptor aLibDesc;
- implLoadLibraryIndexFile( pNewLib, aLibDesc, xDummyStor, pNewLib->maLibInfoFileURL );
- implImportLibDescriptor( pNewLib, aLibDesc );
+ if( aLibName == aStandardStr )
+ {
+ maNameContainer->removeByName( aLibName );
}
+
+ // Create library
+ Reference< XNameContainer > xLib = createLibrary( aLibName );
+ SfxLibrary* pNewLib = static_cast< SfxLibrary* >( xLib.get() );
+ pNewLib->mbLoaded = false;
+ pNewLib->implSetModified( false );
+ checkStorageURL( aLibFolder, pNewLib->maLibInfoFileURL,
+ pNewLib->maStorageURL, pNewLib->maUnexpandedStorageURL );
+
+ uno::Reference< embed::XStorage > xDummyStor;
+ ::xmlscript::LibDescriptor aLibDesc;
+ implLoadLibraryIndexFile( pNewLib, aLibDesc, xDummyStor, pNewLib->maLibInfoFileURL );
+ implImportLibDescriptor( pNewLib, aLibDesc );
}
- mxSFI->kill( aPrevFolder );
}
+ mxSFI->kill( aPrevFolder );
}
- catch(const Exception&)
+ }
+ catch(const Exception&)
+ {
+ TOOLS_WARN_EXCEPTION("basic", "Upgrade of Basic installation failed somehow" );
+ bCleanUp = true;
+ }
+
+ // #i93163
+ if( !bCleanUp )
+ return;
+
+ INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj );
+ aPrevUserBasicInetObj_Err.removeSegment();
+ aPrevUserBasicInetObj_Err.Append( "__basic_80_err" );
+ OUString aPrevFolder_Err = aPrevUserBasicInetObj_Err.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+
+ bool bSaved = false;
+ try
+ {
+ OUString aPrevFolder_1 = aPrevUserBasicInetObj_1.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( mxSFI->isFolder( aPrevFolder_1 ) )
{
- TOOLS_WARN_EXCEPTION("basic", "Upgrade of Basic installation failed somehow" );
- bCleanUp = true;
+ mxSFI->move( aPrevFolder_1, aPrevFolder_Err );
+ bSaved = true;
}
-
- // #i93163
- if( bCleanUp )
+ }
+ catch(const Exception& )
+ {}
+ try
+ {
+ OUString aPrevFolder_2 = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( !bSaved && mxSFI->isFolder( aPrevFolder_2 ) )
{
- INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj );
- aPrevUserBasicInetObj_Err.removeSegment();
- aPrevUserBasicInetObj_Err.Append( "__basic_80_err" );
- OUString aPrevFolder_Err = aPrevUserBasicInetObj_Err.GetMainURL( INetURLObject::DecodeMechanism::NONE );
-
- bool bSaved = false;
- try
- {
- OUString aPrevFolder_1 = aPrevUserBasicInetObj_1.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( mxSFI->isFolder( aPrevFolder_1 ) )
- {
- mxSFI->move( aPrevFolder_1, aPrevFolder_Err );
- bSaved = true;
- }
- }
- catch(const Exception& )
- {}
- try
- {
- OUString aPrevFolder_2 = aPrevUserBasicInetObj_2.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( !bSaved && mxSFI->isFolder( aPrevFolder_2 ) )
- {
- mxSFI->move( aPrevFolder_2, aPrevFolder_Err );
- }
- else
- {
- mxSFI->kill( aPrevFolder_2 );
- }
- }
- catch(const Exception& )
- {}
+ mxSFI->move( aPrevFolder_2, aPrevFolder_Err );
+ }
+ else
+ {
+ mxSFI->kill( aPrevFolder_2 );
}
}
+ catch(const Exception& )
+ {}
}
void SfxLibraryContainer::implScanExtensions()
@@ -1715,21 +1715,21 @@ bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib,
void SfxLibraryContainer::implImportLibDescriptor( SfxLibrary* pLib,
::xmlscript::LibDescriptor const & rLib )
{
- if( !pLib->mbInitialised )
+ if( pLib->mbInitialised )
+ return;
+
+ sal_Int32 nElementCount = rLib.aElementNames.getLength();
+ const OUString* pElementNames = rLib.aElementNames.getConstArray();
+ Any aDummyElement = createEmptyLibraryElement();
+ for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
{
- sal_Int32 nElementCount = rLib.aElementNames.getLength();
- const OUString* pElementNames = rLib.aElementNames.getConstArray();
- Any aDummyElement = createEmptyLibraryElement();
- for( sal_Int32 i = 0 ; i < nElementCount ; i++ )
- {
- pLib->maNameContainer->insertByName( pElementNames[i], aDummyElement );
- }
- pLib->mbPasswordProtected = rLib.bPasswordProtected;
- pLib->mbReadOnly = rLib.bReadOnly;
- pLib->mbPreload = rLib.bPreload;
- pLib->implSetModified( false );
- pLib->mbInitialised = true;
+ pLib->maNameContainer->insertByName( pElementNames[i], aDummyElement );
}
+ pLib->mbPasswordProtected = rLib.bPasswordProtected;
+ pLib->mbReadOnly = rLib.bReadOnly;
+ pLib->mbPreload = rLib.bPreload;
+ pLib->implSetModified( false );
+ pLib->mbInitialised = true;
}
@@ -2227,56 +2227,56 @@ void SAL_CALL SfxLibraryContainer::removeLibrary( const OUString& Name )
maModifiable.setModified( true );
// Delete library files, but not for linked libraries
- if( !pImplLib->mbLink )
+ if( pImplLib->mbLink )
+ return;
+
+ if( mxStorage.is() )
+ {
+ return;
+ }
+ if( xNameAccess->hasElements() )
{
- if( mxStorage.is() )
+ Sequence< OUString > aNames = pImplLib->getElementNames();
+ sal_Int32 nNameCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+ for( sal_Int32 i = 0 ; i < nNameCount ; ++i, ++pNames )
{
- return;
- }
- if( xNameAccess->hasElements() )
- {
- Sequence< OUString > aNames = pImplLib->getElementNames();
- sal_Int32 nNameCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
- for( sal_Int32 i = 0 ; i < nNameCount ; ++i, ++pNames )
- {
- pImplLib->removeElementWithoutChecks( *pNames, SfxLibrary::LibraryContainerAccess() );
- }
+ pImplLib->removeElementWithoutChecks( *pNames, SfxLibrary::LibraryContainerAccess() );
}
+ }
- // Delete index file
- createAppLibraryFolder( pImplLib, Name );
- OUString aLibInfoPath = pImplLib->maLibInfoFileURL;
- try
+ // Delete index file
+ createAppLibraryFolder( pImplLib, Name );
+ OUString aLibInfoPath = pImplLib->maLibInfoFileURL;
+ try
+ {
+ if( mxSFI->exists( aLibInfoPath ) )
{
- if( mxSFI->exists( aLibInfoPath ) )
- {
- mxSFI->kill( aLibInfoPath );
- }
+ mxSFI->kill( aLibInfoPath );
}
- catch(const Exception& ) {}
+ }
+ catch(const Exception& ) {}
- // Delete folder if empty
- INetURLObject aInetObj( maLibraryPath.getToken(1, ';') );
- aInetObj.insertName( Name, true, INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ // Delete folder if empty
+ INetURLObject aInetObj( maLibraryPath.getToken(1, ';') );
+ aInetObj.insertName( Name, true, INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ OUString aLibDirPath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- try
+ try
+ {
+ if( mxSFI->isFolder( aLibDirPath ) )
{
- if( mxSFI->isFolder( aLibDirPath ) )
+ Sequence< OUString > aContentSeq = mxSFI->getFolderContents( aLibDirPath, true );
+ sal_Int32 nCount = aContentSeq.getLength();
+ if( !nCount )
{
- Sequence< OUString > aContentSeq = mxSFI->getFolderContents( aLibDirPath, true );
- sal_Int32 nCount = aContentSeq.getLength();
- if( !nCount )
- {
- mxSFI->kill( aLibDirPath );
- }
+ mxSFI->kill( aLibDirPath );
}
}
- catch(const Exception& )
- {
- }
+ }
+ catch(const Exception& )
+ {
}
}
@@ -2299,132 +2299,132 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
bool bLoaded = pImplLib->mbLoaded;
pImplLib->mbLoaded = true;
- if( !bLoaded && xNameAccess->hasElements() )
+ if( !(!bLoaded && xNameAccess->hasElements()) )
+ return;
+
+ if( pImplLib->mbPasswordProtected )
{
- if( pImplLib->mbPasswordProtected )
- {
- implLoadPasswordLibrary( pImplLib, Name );
- return;
- }
+ implLoadPasswordLibrary( pImplLib, Name );
+ return;
+ }
- bool bLink = pImplLib->mbLink;
- bool bStorage = mxStorage.is() && !bLink;
+ bool bLink = pImplLib->mbLink;
+ bool bStorage = mxStorage.is() && !bLink;
- uno::Reference< embed::XStorage > xLibrariesStor;
- uno::Reference< embed::XStorage > xLibraryStor;
- if( bStorage )
- {
+ uno::Reference< embed::XStorage > xLibrariesStor;
+ uno::Reference< embed::XStorage > xLibraryStor;
+ if( bStorage )
+ {
#if OSL_DEBUG_LEVEL > 0
- try
- {
+ try
+ {
#endif
- xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
- SAL_WARN_IF(
- !xLibrariesStor.is(), "basic",
- ("The method must either throw exception or return a"
- " storage!"));
- if ( !xLibrariesStor.is() )
- {
- throw uno::RuntimeException("null returned from openStorageElement");
- }
-
- xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
- SAL_WARN_IF(
- !xLibraryStor.is(), "basic",
- ("The method must either throw exception or return a"
- " storage!"));
- if ( !xLibrariesStor.is() )
- {
- throw uno::RuntimeException("null returned from openStorageElement");
- }
-#if OSL_DEBUG_LEVEL > 0
+ xLibrariesStor = mxStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ );
+ SAL_WARN_IF(
+ !xLibrariesStor.is(), "basic",
+ ("The method must either throw exception or return a"
+ " storage!"));
+ if ( !xLibrariesStor.is() )
+ {
+ throw uno::RuntimeException("null returned from openStorageElement");
}
- catch(const uno::Exception& )
+
+ xLibraryStor = xLibrariesStor->openStorageElement( Name, embed::ElementModes::READ );
+ SAL_WARN_IF(
+ !xLibraryStor.is(), "basic",
+ ("The method must either throw exception or return a"
+ " storage!"));
+ if ( !xLibrariesStor.is() )
{
- TOOLS_WARN_EXCEPTION(
- "basic",
- "couldn't open sub storage for library \"" << Name << "\"");
- throw;
+ throw uno::RuntimeException("null returned from openStorageElement");
}
-#endif
+#if OSL_DEBUG_LEVEL > 0
}
+ catch(const uno::Exception& )
+ {
+ TOOLS_WARN_EXCEPTION(
+ "basic",
+ "couldn't open sub storage for library \"" << Name << "\"");
+ throw;
+ }
+#endif
+ }
- Sequence< OUString > aNames = pImplLib->getElementNames();
- sal_Int32 nNameCount = aNames.getLength();
- const OUString* pNames = aNames.getConstArray();
- for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ Sequence< OUString > aNames = pImplLib->getElementNames();
+ sal_Int32 nNameCount = aNames.getLength();
+ const OUString* pNames = aNames.getConstArray();
+ for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
+ {
+ OUString aElementName = pNames[ i ];
+
+ OUString aFile;
+ uno::Reference< io::XInputStream > xInStream;
+
+ if( bStorage )
{
- OUString aElementName = pNames[ i ];
+ uno::Reference< io::XStream > xElementStream;
- OUString aFile;
- uno::Reference< io::XInputStream > xInStream;
+ aFile = aElementName + ".xml";
- if( bStorage )
+ try
{
- uno::Reference< io::XStream > xElementStream;
-
- aFile = aElementName + ".xml";
+ xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
+ }
+ catch(const uno::Exception& )
+ {}
+ if( !xElementStream.is() )
+ {
+ // Check for EA2 document version with wrong extensions
+ aFile = aElementName + "." + maLibElementFileExtension;
try
{
xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
}
catch(const uno::Exception& )
{}
-
- if( !xElementStream.is() )
- {
- // Check for EA2 document version with wrong extensions
- aFile = aElementName + "." + maLibElementFileExtension;
- try
- {
- xElementStream = xLibraryStor->openStreamElement( aFile, embed::ElementModes::READ );
- }
- catch(const uno::Exception& )
- {}
- }
-
- if ( xElementStream.is() )
- {
- xInStream = xElementStream->getInputStream();
- }
- if ( !xInStream.is() )
- {
- SAL_WARN(
- "basic",
- "couldn't open library element stream - attempted to"
- " open library \"" << Name << '"');
- throw RuntimeException("couldn't open library element stream", *this);
- }
}
- else
+
+ if ( xElementStream.is() )
{
- OUString aLibDirPath = pImplLib->maStorageURL;
- INetURLObject aElementInetObj( aLibDirPath );
- aElementInetObj.insertName( aElementName, false,
- INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- aElementInetObj.setExtension( maLibElementFileExtension );
- aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ xInStream = xElementStream->getInputStream();
}
-
- Reference< XNameContainer > xLib( pImplLib );
- Any aAny = importLibraryElement( xLib, aElementName,
- aFile, xInStream );
- if( pImplLib->hasByName( aElementName ) )
+ if ( !xInStream.is() )
{
- if( aAny.hasValue() )
- {
- pImplLib->maNameContainer->replaceByName( aElementName, aAny );
- }
+ SAL_WARN(
+ "basic",
+ "couldn't open library element stream - attempted to"
+ " open library \"" << Name << '"');
+ throw RuntimeException("couldn't open library element stream", *this);
}
- else
+ }
+ else
+ {
+ OUString aLibDirPath = pImplLib->maStorageURL;
+ INetURLObject aElementInetObj( aLibDirPath );
+ aElementInetObj.insertName( aElementName, false,
+ INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ aElementInetObj.setExtension( maLibElementFileExtension );
+ aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ }
+
+ Reference< XNameContainer > xLib( pImplLib );
+ Any aAny = importLibraryElement( xLib, aElementName,
+ aFile, xInStream );
+ if( pImplLib->hasByName( aElementName ) )
+ {
+ if( aAny.hasValue() )
{
- pImplLib->maNameContainer->insertNoCheck(aElementName, aAny);
+ pImplLib->maNameContainer->replaceByName( aElementName, aAny );
}
}
- pImplLib->implSetModified( false );
+ else
+ {
+ pImplLib->maNameContainer->insertNoCheck(aElementName, aAny);
+ }
}
+ pImplLib->implSetModified( false );
}
// Methods XLibraryContainer2
@@ -2801,34 +2801,35 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( sal_Bool _vbacompatm
to getBasicManager() may call getVBACompatibilityMode() which returns
this value. */
mbVBACompat = _vbacompatmodeon;
- if( BasicManager* pBasMgr = getBasicManager() )
+ BasicManager* pBasMgr = getBasicManager();
+ if( !pBasMgr )
+ return;
+
+ // get the standard library
+ OUString aLibName = pBasMgr->GetName();
+ if ( aLibName.isEmpty())
+ {
+ aLibName = "Standard";
+ }
+ if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) )
+ {
+ pBasic->SetVBAEnabled( _vbacompatmodeon );
+ }
+ /* If in VBA compatibility mode, force creation of the VBA Globals
+ object. Each application will create an instance of its own
+ implementation and store it in its Basic manager. Implementations
+ will do all necessary additional initialization, such as
+ registering the global "This***Doc" UNO constant, starting the
+ document events processor etc.
+ */
+ if( mbVBACompat ) try
+ {
+ Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
+ Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
+ xFactory->createInstance("ooo.vba.VBAGlobals");
+ }
+ catch(const Exception& )
{
- // get the standard library
- OUString aLibName = pBasMgr->GetName();
- if ( aLibName.isEmpty())
- {
- aLibName = "Standard";
- }
- if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) )
- {
- pBasic->SetVBAEnabled( _vbacompatmodeon );
- }
- /* If in VBA compatibility mode, force creation of the VBA Globals
- object. Each application will create an instance of its own
- implementation and store it in its Basic manager. Implementations
- will do all necessary additional initialization, such as
- registering the global "This***Doc" UNO constant, starting the
- document events processor etc.
- */
- if( mbVBACompat ) try
- {
- Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
- Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
- xFactory->createInstance("ooo.vba.VBAGlobals");
- }
- catch(const Exception& )
- {
- }
}
}
@@ -3066,27 +3067,27 @@ void SfxLibrary::impl_removeWithoutChecks( const OUString& _rElementName )
implSetModified( true );
// Remove element file
- if( !maStorageURL.isEmpty() )
- {
- INetURLObject aElementInetObj( maStorageURL );
- aElementInetObj.insertName( _rElementName, false,
- INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- aElementInetObj.setExtension( maLibElementFileExtension );
- OUString aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( maStorageURL.isEmpty() )
+ return;
- try
- {
- if( mxSFI->exists( aFile ) )
- {
- mxSFI->kill( aFile );
- }
- }
- catch(const Exception& )
+ INetURLObject aElementInetObj( maStorageURL );
+ aElementInetObj.insertName( _rElementName, false,
+ INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ aElementInetObj.setExtension( maLibElementFileExtension );
+ OUString aFile = aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+
+ try
+ {
+ if( mxSFI->exists( aFile ) )
{
- DBG_UNHANDLED_EXCEPTION("basic");
+ mxSFI->kill( aFile );
}
}
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basic");
+ }
}
void SfxLibrary::removeByName( const OUString& Name )
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index cf55c7ed28af..c9b8fdeb0793 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -484,40 +484,40 @@ void SAL_CALL SfxScriptLibraryContainer::changeLibraryPassword( const OUString&
}
}
- if( bKillCryptedFiles || bKillUncryptedFiles )
+ if( !(bKillCryptedFiles || bKillUncryptedFiles) )
+ return;
+
+ Sequence< OUString > aElementNames = pImplLib->getElementNames();
+ sal_Int32 nNameCount = aElementNames.getLength();
+ const OUString* pNames = aElementNames.getConstArray();
+ OUString aLibDirPath = createAppLibraryFolder( pImplLib, Name );
+ try
{
- Sequence< OUString > aElementNames = pImplLib->getElementNames();
- sal_Int32 nNameCount = aElementNames.getLength();
- const OUString* pNames = aElementNames.getConstArray();
- OUString aLibDirPath = createAppLibraryFolder( pImplLib, Name );
- try
+ for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
{
- for( sal_Int32 i = 0 ; i < nNameCount ; i++ )
- {
- OUString aElementName = pNames[ i ];
+ OUString aElementName = pNames[ i ];
- INetURLObject aElementInetObj( aLibDirPath );
- aElementInetObj.insertName( aElementName, false,
- INetURLObject::LAST_SEGMENT,
- INetURLObject::EncodeMechanism::All );
- if( bKillUncryptedFiles )
- {
- aElementInetObj.setExtension( maLibElementFileExtension );
- }
- else
- {
- aElementInetObj.setExtension( "pba" );
- }
- OUString aElementPath( aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ INetURLObject aElementInetObj( aLibDirPath );
+ aElementInetObj.insertName( aElementName, false,
+ INetURLObject::LAST_SEGMENT,
+ INetURLObject::EncodeMechanism::All );
+ if( bKillUncryptedFiles )
+ {
+ aElementInetObj.setExtension( maLibElementFileExtension );
+ }
+ else
+ {
+ aElementInetObj.setExtension( "pba" );
+ }
+ OUString aElementPath( aElementInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
- if( mxSFI->exists( aElementPath ) )
- {
- mxSFI->kill( aElementPath );
- }
+ if( mxSFI->exists( aElementPath ) )
+ {
+ mxSFI->kill( aElementPath );
}
}
- catch(const Exception& ) {}
}
+ catch(const Exception& ) {}
}