summaryrefslogtreecommitdiff
path: root/basic/source/classes/sbunoobj.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/classes/sbunoobj.cxx')
-rwxr-xr-x[-rw-r--r--]basic/source/classes/sbunoobj.cxx663
1 files changed, 536 insertions, 127 deletions
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 9dffcf2136..c66770c976 100644..100755
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -34,15 +34,18 @@
#include <svl/hint.hxx>
#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/typeprovider.hxx>
-#include <cppuhelper/extract.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
+#include <comphelper/extract.hxx>
#include <comphelper/processfactory.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
#include <com/sun/star/script/ArrayWrapper.hpp>
+#include <com/sun/star/script/NativeObjectWrapper.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/DeploymentException.hpp>
@@ -60,6 +63,7 @@
#include <com/sun/star/script/XTypeConverter.hpp>
#include <com/sun/star/script/XDefaultProperty.hpp>
#include <com/sun/star/script/XDefaultMethod.hpp>
+#include <com/sun/star/script/XDirectInvocation.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/reflection/XIdlArray.hpp>
@@ -454,7 +458,7 @@ String implGetWrappedMsg( const WrappedTargetException& e )
void implHandleBasicErrorException( BasicErrorException& e )
{
- SbError nError = StarBASIC::GetSfxFromVBError( (USHORT)e.ErrorCode );
+ SbError nError = StarBASIC::GetSfxFromVBError( (sal_uInt16)e.ErrorCode );
StarBASIC::Error( nError, e.ErrorMessageArgument );
}
@@ -480,7 +484,7 @@ void implHandleWrappedTargetException( const Any& _rWrappedTargetException )
{
if ( aBasicError.ErrorCode != 0 )
{
- nError = StarBASIC::GetSfxFromVBError( (USHORT) aBasicError.ErrorCode );
+ nError = StarBASIC::GetSfxFromVBError( (sal_uInt16) aBasicError.ErrorCode );
if ( nError == 0 )
{
nError = (SbError) aBasicError.ErrorCode;
@@ -507,7 +511,7 @@ void implHandleWrappedTargetException( const Any& _rWrappedTargetException )
// special handling for BasicErrorException errors
if ( aWrapped.TargetException >>= aBasicError )
{
- nError = StarBASIC::GetSfxFromVBError( (USHORT)aBasicError.ErrorCode );
+ nError = StarBASIC::GetSfxFromVBError( (sal_uInt16)aBasicError.ErrorCode );
aMessageBuf.append( aBasicError.ErrorMessageArgument );
aExamine.clear();
break;
@@ -552,6 +556,43 @@ static void implHandleAnyException( const Any& _rCaughtException )
}
}
+// NativeObjectWrapper handling
+struct ObjectItem
+{
+ SbxObjectRef m_xNativeObj;
+
+ ObjectItem( void )
+ {}
+ ObjectItem( SbxObject* pNativeObj )
+ : m_xNativeObj( pNativeObj )
+ {}
+};
+static std::vector< ObjectItem > GaNativeObjectWrapperVector;
+
+void clearNativeObjectWrapperVector( void )
+{
+ GaNativeObjectWrapperVector.clear();
+}
+
+sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj )
+{
+ sal_uInt32 nIndex = GaNativeObjectWrapperVector.size();
+ GaNativeObjectWrapperVector.push_back( ObjectItem( pNativeObj ) );
+ return nIndex;
+}
+
+SbxObject* lcl_getNativeObject( sal_uInt32 nIndex )
+{
+ SbxObjectRef xRetObj;
+ if( nIndex < GaNativeObjectWrapperVector.size() )
+ {
+ ObjectItem& rItem = GaNativeObjectWrapperVector[ nIndex ];
+ xRetObj = rItem.m_xNativeObj;
+ }
+ return xRetObj;
+}
+
+
// convert from Uno to Sbx
SbxDataType unoToSbxType( TypeClass eType )
{
@@ -634,7 +675,7 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int
sal_Int32 nLen = xIdlArray->getLen( aValue );
for ( sal_Int32 index = 0; index < nLen; ++index )
{
- Any aElementAny = xIdlArray->get( aValue, (UINT32)index );
+ Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)index );
// This detects the dimension were currently processing
if ( dimCopy == dimension )
{
@@ -736,6 +777,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
if( eTypeClass == TypeClass_STRUCT )
{
ArrayWrapper aWrap;
+ NativeObjectWrapper aNativeObjectWrapper;
if ( (aValue >>= aWrap) )
{
SbxDimArray* pArray = NULL;
@@ -746,7 +788,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
if ( pArray )
{
SbxDimArrayRef xArray = pArray;
- USHORT nFlags = pVar->GetFlags();
+ sal_uInt16 nFlags = pVar->GetFlags();
pVar->ResetFlag( SBX_FIXED );
pVar->PutObject( (SbxDimArray*)xArray );
pVar->SetFlags( nFlags );
@@ -755,6 +797,18 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
pVar->PutEmpty();
break;
}
+ else if ( (aValue >>= aNativeObjectWrapper) )
+ {
+ sal_uInt32 nIndex = 0;
+ if( (aNativeObjectWrapper.ObjectId >>= nIndex) )
+ {
+ SbxObject* pObj = lcl_getNativeObject( nIndex );
+ pVar->PutObject( pObj );
+ }
+ else
+ pVar->PutEmpty();
+ break;
+ }
else
{
SbiInstance* pInst = pINST;
@@ -856,7 +910,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
for( i = 0 ; i < nLen ; i++ )
{
// convert elements
- Any aElementAny = xIdlArray->get( aValue, (UINT32)i );
+ Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)i );
SbxVariableRef xVar = new SbxVariable( eSbxElementType );
unoToSbxValue( (SbxVariable*)xVar, aElementAny );
@@ -870,7 +924,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
}
// return the Array
- USHORT nFlags = pVar->GetFlags();
+ sal_uInt16 nFlags = pVar->GetFlags();
pVar->ResetFlag( SBX_FIXED );
pVar->PutObject( (SbxDimArray*)xArray );
pVar->SetFlags( nFlags );
@@ -1008,9 +1062,9 @@ Type getUnoTypeForSbxValue( SbxValue* pVal )
// this one - otherwise the whole will be considered as Any-Sequence
sal_Bool bNeedsInit = sal_True;
- INT32 nSize = nUpper - nLower + 1;
- INT32 nIdx = nLower;
- for( INT32 i = 0 ; i < nSize ; i++,nIdx++ )
+ sal_Int32 nSize = nUpper - nLower + 1;
+ sal_Int32 nIdx = nLower;
+ for( sal_Int32 i = 0 ; i < nSize ; i++,nIdx++ )
{
SbxVariableRef xVar = pArray->Get32( &nIdx );
Type aType = getUnoTypeForSbxValue( (SbxVariable*)xVar );
@@ -1046,10 +1100,10 @@ Type getUnoTypeForSbxValue( SbxValue* pVal )
if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY )
{
// For this check the array's dim structure does not matter
- UINT32 nFlatArraySize = pArray->Count32();
+ sal_uInt32 nFlatArraySize = pArray->Count32();
sal_Bool bNeedsInit = sal_True;
- for( UINT32 i = 0 ; i < nFlatArraySize ; i++ )
+ for( sal_uInt32 i = 0 ; i < nFlatArraySize ; i++ )
{
SbxVariableRef xVar = pArray->SbxArray::Get32( i );
Type aType = getUnoTypeForSbxValue( (SbxVariable*)xVar );
@@ -1123,6 +1177,20 @@ Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType =
if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) )
return aRetAny;
}
+ if( !xObj->ISA(SbUnoObject) )
+ {
+ // Create NativeObjectWrapper to identify object in case of callbacks
+ SbxObject* pObj = PTR_CAST(SbxObject,pVar->GetObject());
+ if( pObj != NULL )
+ {
+ NativeObjectWrapper aNativeObjectWrapper;
+ sal_uInt32 nIndex = lcl_registerNativeObjectWrapper( pObj );
+ aNativeObjectWrapper.ObjectId <<= nIndex;
+ Any aRetAny;
+ aRetAny <<= aNativeObjectWrapper;
+ return aRetAny;
+ }
+ }
}
}
@@ -1259,6 +1327,29 @@ Any sbxToUnoValue( SbxVariable* pVar )
return sbxToUnoValueImpl( pVar );
}
+// Funktion, um einen globalen Bezeichner im
+// UnoScope zu suchen und fuer Sbx zu wrappen
+static bool implGetTypeByName( const String& rName, Type& rRetType )
+{
+ bool bSuccess = false;
+
+ Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
+ if( xTypeAccess->hasByHierarchicalName( rName ) )
+ {
+ Any aRet = xTypeAccess->getByHierarchicalName( rName );
+ Reference< XTypeDescription > xTypeDesc;
+ aRet >>= xTypeDesc;
+
+ if( xTypeDesc.is() )
+ {
+ rRetType = Type( xTypeDesc->getTypeClass(), xTypeDesc->getName() );
+ bSuccess = true;
+ }
+ }
+ return bSuccess;
+}
+
+
// converting of Sbx to Uno with known target class
Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty )
{
@@ -1344,6 +1435,39 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty
}
break;
+ case TypeClass_TYPE:
+ {
+ if( eBaseType == SbxOBJECT )
+ {
+ // XIdlClass?
+ Reference< XIdlClass > xIdlClass;
+
+ SbxBaseRef pObj = (SbxBase*)pVar->GetObject();
+ if( pObj && pObj->ISA(SbUnoObject) )
+ {
+ Any aUnoAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
+ aUnoAny >>= xIdlClass;
+ }
+
+ if( xIdlClass.is() )
+ {
+ ::rtl::OUString aClassName = xIdlClass->getName();
+ Type aType( xIdlClass->getTypeClass(), aClassName.getStr() );
+ aRetVal <<= aType;
+ }
+ }
+ else if( eBaseType == SbxSTRING )
+ {
+ // String representing type?
+ String aTypeName = pVar->GetString();
+ Type aType;
+ bool bSuccess = implGetTypeByName( aTypeName, aType );
+ if( bSuccess )
+ aRetVal <<= aType;
+ }
+ }
+ break;
+
/* we leave out the following types
case TypeClass_SERVICE: break;
case TypeClass_CLASS: break;
@@ -1532,7 +1656,7 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty
return aRetVal;
}
-void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOLEAutomation, UINT32 nParamCount )
+void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOLEAutomation, sal_uInt32 nParamCount )
{
AutomationNamedArgsSbxArray* pArgNamesArray = NULL;
if( bOLEAutomation )
@@ -1541,7 +1665,7 @@ void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOL
args.realloc( nParamCount );
Any* pAnyArgs = args.getArray();
bool bBlockConversionToSmallestType = pINST->IsCompatibility();
- UINT32 i = 0;
+ sal_uInt32 i = 0;
if( pArgNamesArray )
{
Sequence< ::rtl::OUString >& rNameSeq = pArgNamesArray->getNames();
@@ -1549,7 +1673,7 @@ void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOL
Any aValAny;
for( i = 0 ; i < nParamCount ; i++ )
{
- USHORT iSbx = (USHORT)(i+1);
+ sal_uInt16 iSbx = (sal_uInt16)(i+1);
aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ),
bBlockConversionToSmallestType );
@@ -1572,7 +1696,7 @@ void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOL
{
for( i = 0 ; i < nParamCount ; i++ )
{
- pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (USHORT)(i+1) ),
+ pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (sal_uInt16)(i+1) ),
bBlockConversionToSmallestType );
}
}
@@ -1584,9 +1708,9 @@ enum INVOKETYPE
SetProp,
Func
};
-Any invokeAutomationMethod( const String& Name, Sequence< Any >& args, SbxArray* pParams, UINT32 nParamCount, Reference< XInvocation >& rxInvocation, INVOKETYPE invokeType = Func )
+Any invokeAutomationMethod( const String& Name, Sequence< Any >& args, SbxArray* pParams, sal_uInt32 nParamCount, Reference< XInvocation >& rxInvocation, INVOKETYPE invokeType = Func )
{
- Sequence< INT16 > OutParamIndex;
+ Sequence< sal_Int16 > OutParamIndex;
Sequence< Any > OutParam;
Any aRetAny;
@@ -1611,30 +1735,30 @@ Any invokeAutomationMethod( const String& Name, Sequence< Any >& args, SbxArray*
break; // should introduce an error here
}
- const INT16* pIndices = OutParamIndex.getConstArray();
- UINT32 nLen = OutParamIndex.getLength();
+ const sal_Int16* pIndices = OutParamIndex.getConstArray();
+ sal_uInt32 nLen = OutParamIndex.getLength();
if( nLen )
{
const Any* pNewValues = OutParam.getConstArray();
- for( UINT32 j = 0 ; j < nLen ; j++ )
+ for( sal_uInt32 j = 0 ; j < nLen ; j++ )
{
- INT16 iTarget = pIndices[ j ];
- if( iTarget >= (INT16)nParamCount )
+ sal_Int16 iTarget = pIndices[ j ];
+ if( iTarget >= (sal_Int16)nParamCount )
break;
- unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pNewValues[ j ] );
+ unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pNewValues[ j ] );
}
}
return aRetAny;
}
// Debugging help method to readout the imlemented interfaces of an object
-String Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, USHORT nRekLevel )
+String Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, sal_uInt16 nRekLevel )
{
Type aIfaceType = ::getCppuType( (const Reference< XInterface > *)0 );
static Reference< XIdlClass > xIfaceClass = TypeToIdlClass( aIfaceType );
String aRetStr;
- for( USHORT i = 0 ; i < nRekLevel ; i++ )
+ for( sal_uInt16 i = 0 ; i < nRekLevel ; i++ )
aRetStr.AppendAscii( " " );
aRetStr += String( xClass->getName() );
::rtl::OUString aClassName = xClass->getName();
@@ -1653,8 +1777,8 @@ String Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference<
// get the super interfaces
Sequence< Reference< XIdlClass > > aSuperClassSeq = xClass->getSuperclasses();
const Reference< XIdlClass >* pClasses = aSuperClassSeq.getConstArray();
- UINT32 nSuperIfaceCount = aSuperClassSeq.getLength();
- for( UINT32 j = 0 ; j < nSuperIfaceCount ; j++ )
+ sal_uInt32 nSuperIfaceCount = aSuperClassSeq.getLength();
+ for( sal_uInt32 j = 0 ; j < nSuperIfaceCount ; j++ )
{
const Reference< XIdlClass >& rxIfaceClass = pClasses[j];
if( !rxIfaceClass->equals( xIfaceClass ) )
@@ -1735,8 +1859,8 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj,
{
Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
const Type* pTypeArray = aTypeSeq.getConstArray();
- UINT32 nIfaceCount = aTypeSeq.getLength();
- for( UINT32 j = 0 ; j < nIfaceCount ; j++ )
+ sal_uInt32 nIfaceCount = aTypeSeq.getLength();
+ for( sal_uInt32 j = 0 ; j < nIfaceCount ; j++ )
{
const Type& rType = pTypeArray[j];
@@ -1814,8 +1938,8 @@ String Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj )
// get the interfaces of the implementation
Sequence< Type > aTypeSeq = xTypeProvider->getTypes();
const Type* pTypeArray = aTypeSeq.getConstArray();
- UINT32 nIfaceCount = aTypeSeq.getLength();
- for( UINT32 j = 0 ; j < nIfaceCount ; j++ )
+ sal_uInt32 nIfaceCount = aTypeSeq.getLength();
+ for( sal_uInt32 j = 0 ; j < nIfaceCount ; j++ )
{
const Type& rType = pTypeArray[j];
@@ -1913,13 +2037,13 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj )
}
Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
- UINT32 nUnoPropCount = props.getLength();
+ sal_uInt32 nUnoPropCount = props.getLength();
const Property* pUnoProps = props.getConstArray();
SbxArray* pProps = pUnoObj->GetProperties();
- USHORT nPropCount = pProps->Count();
- USHORT nPropsPerLine = 1 + nPropCount / 30;
- for( USHORT i = 0; i < nPropCount; i++ )
+ sal_uInt16 nPropCount = pProps->Count();
+ sal_uInt16 nPropsPerLine = 1 + nPropCount / 30;
+ for( sal_uInt16 i = 0; i < nPropCount; i++ )
{
SbxVariable* pVar = pProps->Get( i );
if( pVar )
@@ -1932,7 +2056,7 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj )
// Is it in Uno a sequence?
SbxDataType eType = pVar->GetFullType();
- BOOL bMaybeVoid = FALSE;
+ sal_Bool bMaybeVoid = sal_False;
if( i < nUnoPropCount )
{
const Property& rProp = pUnoProps[ i ];
@@ -1942,7 +2066,7 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj )
if( rProp.Attributes & PropertyAttribute::MAYBEVOID )
{
eType = unoToSbxType( rProp.Type.getTypeClass() );
- bMaybeVoid = TRUE;
+ bMaybeVoid = sal_True;
}
if( eType == SbxOBJECT )
{
@@ -1993,14 +2117,14 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj )
const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray();
SbxArray* pMethods = pUnoObj->GetMethods();
- USHORT nMethodCount = pMethods->Count();
+ sal_uInt16 nMethodCount = pMethods->Count();
if( !nMethodCount )
{
aRet.AppendAscii( "\nNo methods found\n" );
return aRet;
}
- USHORT nPropsPerLine = 1 + nMethodCount / 30;
- for( USHORT i = 0; i < nMethodCount; i++ )
+ sal_uInt16 nPropsPerLine = 1 + nMethodCount / 30;
+ for( sal_uInt16 i = 0; i < nMethodCount; i++ )
{
SbxVariable* pVar = pMethods->Get( i );
if( pVar )
@@ -2028,12 +2152,12 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj )
// the get-method mustn't have a parameter
Sequence< Reference< XIdlClass > > aParamsSeq = rxMethod->getParameterTypes();
- UINT32 nParamCount = aParamsSeq.getLength();
+ sal_uInt32 nParamCount = aParamsSeq.getLength();
const Reference< XIdlClass >* pParams = aParamsSeq.getConstArray();
if( nParamCount > 0 )
{
- for( USHORT j = 0; j < nParamCount; j++ )
+ for( sal_uInt16 j = 0; j < nParamCount; j++ )
{
String aTypeStr = Dbg_SbxDataType2String( unoToSbxType( pParams[ j ] ) );
aPropStr += aTypeStr;
@@ -2080,7 +2204,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
if( pHint->GetId() == SBX_HINT_DATAWANTED )
{
// Test-Properties
- INT32 nId = pProp->nId;
+ sal_Int32 nId = pProp->nId;
if( nId < 0 )
{
// Id == -1: Display implemented interfaces according the ClassProvider
@@ -2131,7 +2255,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
{
try
{
- UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0;
+ sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
sal_Bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() );
Any aRetAny;
if ( bCanBeConsideredAMethod && nParamCount )
@@ -2204,18 +2328,18 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
if( pHint->GetId() == SBX_HINT_DATAWANTED )
{
// number of Parameter -1 because of Param0 == this
- UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0;
+ sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
Sequence<Any> args;
- BOOL bOutParams = FALSE;
- UINT32 i;
+ sal_Bool bOutParams = sal_False;
+ sal_uInt32 i;
if( !bInvocation && mxUnoAccess.is() )
{
// get info
const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
- UINT32 nUnoParamCount = rInfoSeq.getLength();
- UINT32 nAllocParamCount = nParamCount;
+ sal_uInt32 nUnoParamCount = rInfoSeq.getLength();
+ sal_uInt32 nAllocParamCount = nParamCount;
// ignore surplus parameter; alternative: throw an error
if( nParamCount > nUnoParamCount )
@@ -2258,14 +2382,14 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
com::sun::star::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() );
// ATTENTION: Don't forget for Sbx-Parameter the offset!
- pAnyArgs[i] = sbxToUnoValue( pParams->Get( (USHORT)(i+1) ), aType );
+ pAnyArgs[i] = sbxToUnoValue( pParams->Get( (sal_uInt16)(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;
+ bOutParams = sal_True;
}
}
}
@@ -2277,7 +2401,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
}
// call the method
- GetSbData()->bBlockCompilerError = TRUE; // #106433 Block compiler errors for API calls
+ GetSbData()->bBlockCompilerError = sal_True; // #106433 Block compiler errors for API calls
try
{
if( !bInvocation && mxUnoAccess.is() )
@@ -2296,13 +2420,13 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos();
const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
- UINT32 j;
+ sal_uInt32 j;
for( j = 0 ; j < nParamCount ; j++ )
{
const ParamInfo& rInfo = pParamInfos[j];
ParamMode aParamMode = rInfo.aMode;
if( aParamMode != ParamMode_IN )
- unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pAnyArgs[ j ] );
+ unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pAnyArgs[ j ] );
}
}
}
@@ -2310,7 +2434,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
{
Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation );
unoToSbxValue( pVar, aRetAny );
- }
+ }
// remove parameter here, because this was not done anymore in unoToSbxValue()
// for arrays
@@ -2321,7 +2445,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
{
implHandleAnyException( ::cppu::getCaughtException() );
}
- GetSbData()->bBlockCompilerError = FALSE; // #106433 Unblock compiler errors
+ GetSbData()->bBlockCompilerError = sal_False; // #106433 Unblock compiler errors
}
}
else
@@ -2337,8 +2461,8 @@ Reference< XInvocation > createDynamicInvocationFor( const Any& aAny );
SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ )
: SbxObject( aName_ )
- , bNeedIntrospection( TRUE )
- , bIgnoreNativeCOMObjectMembers( FALSE )
+ , bNeedIntrospection( sal_True )
+ , bNativeCOMObject( sal_False )
{
static Reference< XIntrospection > xIntrospection;
@@ -2381,7 +2505,7 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ )
// The remainder refers only to the introspection
if( !xTypeProvider.is() )
{
- bNeedIntrospection = FALSE;
+ bNeedIntrospection = sal_False;
return;
}
@@ -2389,34 +2513,34 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ )
// hiding of equally named COM symbols, e.g. XInvocation::getValue
Reference< oleautomation::XAutomationObject > xAutomationObject( aUnoObj_, UNO_QUERY );
if( xAutomationObject.is() )
- bIgnoreNativeCOMObjectMembers = TRUE;
+ bNativeCOMObject = sal_True;
}
maTmpUnoObj = aUnoObj_;
//*** Define the name ***
- BOOL bFatalError = TRUE;
+ sal_Bool bFatalError = sal_True;
// Is it an interface or a struct?
- BOOL bSetClassName = FALSE;
+ sal_Bool bSetClassName = sal_False;
String aClassName_;
if( eType == TypeClass_STRUCT || eType == TypeClass_EXCEPTION )
{
// Struct is Ok
- bFatalError = FALSE;
+ bFatalError = sal_False;
// insert the real name of the class
if( aName_.Len() == 0 )
{
aClassName_ = String( aUnoObj_.getValueType().getTypeName() );
- bSetClassName = TRUE;
+ bSetClassName = sal_True;
}
}
else if( eType == TypeClass_INTERFACE )
{
// Interface works always through the type in the Any
- bFatalError = FALSE;
+ bFatalError = sal_False;
// Ask for the XIdlClassProvider-Interface
Reference< XIdlClassProvider > xClassProvider( x, UNO_QUERY );
@@ -2426,14 +2550,14 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ )
if( aName_.Len() == 0 )
{
Sequence< Reference< XIdlClass > > szClasses = xClassProvider->getIdlClasses();
- UINT32 nLen = szClasses.getLength();
+ sal_uInt32 nLen = szClasses.getLength();
if( nLen )
{
const Reference< XIdlClass > xImplClass = szClasses.getConstArray()[ 0 ];
if( xImplClass.is() )
{
aClassName_ = String( xImplClass->getName() );
- bSetClassName = TRUE;
+ bSetClassName = sal_True;
}
}
}
@@ -2464,7 +2588,7 @@ void SbUnoObject::doIntrospection( void )
if( !bNeedIntrospection )
return;
- bNeedIntrospection = FALSE;
+ bNeedIntrospection = sal_False;
if( !xIntrospection.is() )
{
@@ -2513,6 +2637,47 @@ void SbUnoObject::doIntrospection( void )
// Start of a list of all SbUnoMethod-Instances
static SbUnoMethod* pFirst = NULL;
+void clearUnoMethodsForBasic( StarBASIC* pBasic )
+{
+ SbUnoMethod* pMeth = pFirst;
+ while( pMeth )
+ {
+ SbxObject* pObject = dynamic_cast< SbxObject* >( pMeth->GetParent() );
+ if ( pObject )
+ {
+ StarBASIC* pModBasic = dynamic_cast< StarBASIC* >( pObject->GetParent() );
+ if ( pModBasic == pBasic )
+ {
+ // for now the solution is to remove the method from the list and to clear it,
+ // but in case the element should be correctly transfered to another StarBASIC,
+ // we should either set module parent to NULL without clearing it, or even
+ // set the new StarBASIC as the parent of the module
+ // pObject->SetParent( NULL );
+
+ if( pMeth == pFirst )
+ pFirst = pMeth->pNext;
+ else if( pMeth->pPrev )
+ pMeth->pPrev->pNext = pMeth->pNext;
+ if( pMeth->pNext )
+ pMeth->pNext->pPrev = pMeth->pPrev;
+
+ pMeth->pPrev = NULL;
+ pMeth->pNext = NULL;
+
+ pMeth->SbxValue::Clear();
+ pObject->SbxValue::Clear();
+
+ // start from the beginning after object clearing, the cycle will end since the method is removed each time
+ pMeth = pFirst;
+ }
+ else
+ pMeth = pMeth->pNext;
+ }
+ else
+ pMeth = pMeth->pNext;
+ }
+}
+
void clearUnoMethods( void )
{
SbUnoMethod* pMeth = pFirst;
@@ -2529,10 +2694,12 @@ SbUnoMethod::SbUnoMethod
const String& aName_,
SbxDataType eSbxType,
Reference< XIdlMethod > xUnoMethod_,
- bool bInvocation
+ bool bInvocation,
+ bool bDirect
)
: SbxMethod( aName_, eSbxType )
, mbInvocation( bInvocation )
+ , mbDirectInvocation( bDirect )
{
m_xUnoMethod = xUnoMethod_;
pParamInfoSeq = NULL;
@@ -2568,16 +2735,16 @@ SbxInfo* SbUnoMethod::GetInfo()
const Sequence<ParamInfo>& rInfoSeq = getParamInfos();
const ParamInfo* pParamInfos = rInfoSeq.getConstArray();
- UINT32 nParamCount = rInfoSeq.getLength();
+ sal_uInt32 nParamCount = rInfoSeq.getLength();
- for( UINT32 i = 0 ; i < nParamCount ; i++ )
+ for( sal_uInt32 i = 0 ; i < nParamCount ; i++ )
{
const ParamInfo& rInfo = pParamInfos[i];
::rtl::OUString aParamName = rInfo.aName;
// const Reference< XIdlClass >& rxClass = rInfo.aType;
SbxDataType t = SbxVARIANT;
- USHORT nFlags_ = SBX_READ;
+ sal_uInt16 nFlags_ = SBX_READ;
pInfo->AddParam( aParamName, t, nFlags_ );
}
}
@@ -2600,7 +2767,7 @@ SbUnoProperty::SbUnoProperty
const String& aName_,
SbxDataType eSbxType,
const Property& aUnoProp_,
- INT32 nId_,
+ sal_Int32 nId_,
bool bInvocation
)
: SbxProperty( aName_, eSbxType )
@@ -2633,7 +2800,7 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t )
if( !pRes )
{
::rtl::OUString aUName( rName );
- if( mxUnoAccess.is() && !bIgnoreNativeCOMObjectMembers )
+ if( mxUnoAccess.is() && !bNativeCOMObject )
{
if( mxExactName.is() )
{
@@ -2734,6 +2901,17 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t )
QuickInsert( (SbxVariable*)xMethRef );
pRes = xMethRef;
}
+ else
+ {
+ Reference< XDirectInvocation > xDirectInvoke( mxInvocation, UNO_QUERY );
+ if ( xDirectInvoke.is() && xDirectInvoke->hasMember( aUName ) )
+ {
+ SbxVariableRef xMethRef = new SbUnoMethod( aUName, SbxVARIANT, xDummyMethod, true, true );
+ QuickInsert( (SbxVariable*)xMethRef );
+ pRes = xMethRef;
+ }
+
+ }
}
catch( RuntimeException& e )
{
@@ -2793,11 +2971,11 @@ void SbUnoObject::implCreateAll( void )
// get instrospection
Reference< XIntrospectionAccess > xAccess = mxUnoAccess;
- if( !xAccess.is() || bIgnoreNativeCOMObjectMembers )
+ if( !xAccess.is() || bNativeCOMObject )
{
if( mxInvocation.is() )
xAccess = mxInvocation->getIntrospection();
- else if( bIgnoreNativeCOMObjectMembers )
+ else if( bNativeCOMObject )
return;
}
if( !xAccess.is() )
@@ -2805,10 +2983,10 @@ void SbUnoObject::implCreateAll( void )
// Establish properties
Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS );
- UINT32 nPropCount = props.getLength();
+ sal_uInt32 nPropCount = props.getLength();
const Property* pProps_ = props.getConstArray();
- UINT32 i;
+ sal_uInt32 i;
for( i = 0 ; i < nPropCount ; i++ )
{
const Property& rProp = pProps_[ i ];
@@ -2831,7 +3009,7 @@ void SbUnoObject::implCreateAll( void )
// Create methods
Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods
( MethodConcept::ALL - MethodConcept::DANGEROUS );
- UINT32 nMethCount = aMethodSeq.getLength();
+ sal_uInt32 nMethCount = aMethodSeq.getLength();
const Reference< XIdlMethod >* pMethods_ = aMethodSeq.getConstArray();
for( i = 0 ; i < nMethCount ; i++ )
{
@@ -2891,7 +3069,7 @@ SbUnoObject* Impl_CreateUnoStruct( const String& aClassName )
// Factory-Class to create Uno-Structs per DIM AS NEW
-SbxBase* SbUnoFactory::Create( UINT16, UINT32 )
+SbxBase* SbUnoFactory::Create( sal_uInt16, sal_uInt32 )
{
// Via SbxId nothing works in Uno
return NULL;
@@ -2924,7 +3102,7 @@ void createAllObjectProperties( SbxObject* pObj )
}
-void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -2949,7 +3127,7 @@ void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
refVar->PutObject( (SbUnoObject*)xUnoObj );
}
-void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -3003,7 +3181,7 @@ void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
}
}
-void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -3061,7 +3239,7 @@ void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar,
}
}
-void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -3085,13 +3263,13 @@ void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, BOOL
}
}
-void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
// We need 2 parameter minimum
- USHORT nParCount = rPar.Count();
+ sal_uInt16 nParCount = rPar.Count();
if( nParCount < 3 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
@@ -3100,7 +3278,7 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
// variable for the return value
SbxVariableRef refVar = rPar.Get(0);
- refVar->PutBool( FALSE );
+ refVar->PutBool( sal_False );
// get the Uno-Object
SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
@@ -3119,7 +3297,7 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
if( !xCoreReflection.is() )
return;
- for( USHORT i = 2 ; i < nParCount ; i++ )
+ for( sal_uInt16 i = 2 ; i < nParCount ; i++ )
{
// get the name of the interface of the struct
String aIfaceName = rPar.Get( i )->GetString();
@@ -3137,10 +3315,10 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
}
// Every thing works; then return TRUE
- refVar->PutBool( TRUE );
+ refVar->PutBool( sal_True );
}
-void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -3154,7 +3332,7 @@ void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
// variable for the return value
SbxVariableRef refVar = rPar.Get(0);
- refVar->PutBool( FALSE );
+ refVar->PutBool( sal_False );
// get the Uno-Object
SbxVariableRef xParam = rPar.Get( 1 );
@@ -3166,11 +3344,11 @@ void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
Any aAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
TypeClass eType = aAny.getValueType().getTypeClass();
if( eType == TypeClass_STRUCT )
- refVar->PutBool( TRUE );
+ refVar->PutBool( sal_True );
}
-void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -3183,7 +3361,7 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
// variable for the return value
SbxVariableRef refVar = rPar.Get(0);
- refVar->PutBool( FALSE );
+ refVar->PutBool( sal_False );
// get the Uno-Objects
SbxVariableRef xParam1 = rPar.Get( 1 );
@@ -3215,7 +3393,7 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
//XInterfaceRef x2 = *(XInterfaceRef*)aAny2.get();
if( x1 == x2 )
- refVar->PutBool( TRUE );
+ refVar->PutBool( sal_True );
}
typedef boost::unordered_map< ::rtl::OUString, std::vector< ::rtl::OUString >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleHash;
@@ -3488,7 +3666,7 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t )
// Take us out as listener at once,
// the values are all constant
if( pRes->IsBroadcaster() )
- EndListening( pRes->GetBroadcaster(), TRUE );
+ EndListening( pRes->GetBroadcaster(), sal_True );
}
}
return pRes;
@@ -3572,14 +3750,14 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
if( pUnoCtor && pHint->GetId() == SBX_HINT_DATAWANTED )
{
// Parameter count -1 because of Param0 == this
- UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0;
+ sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
Sequence<Any> args;
- BOOL bOutParams = FALSE;
+ sal_Bool bOutParams = sal_False;
Reference< XServiceConstructorDescription > xCtor = pUnoCtor->getServiceCtorDesc();
Sequence< Reference< XParameter > > aParameterSeq = xCtor->getParameters();
const Reference< XParameter >* pParameterSeq = aParameterSeq.getConstArray();
- UINT32 nUnoParamCount = aParameterSeq.getLength();
+ sal_uInt32 nUnoParamCount = aParameterSeq.getLength();
// Default: Ignore not needed parameters
bool bParameterError = false;
@@ -3597,8 +3775,8 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
}
// Too many parameters with context as first parameter?
- USHORT nSbxParameterOffset = 1;
- USHORT nParameterOffsetByContext = 0;
+ sal_uInt16 nSbxParameterOffset = 1;
+ sal_uInt16 nParameterOffsetByContext = 0;
Reference < XComponentContext > xFirstParamContext;
if( nParamCount > nUnoParamCount )
{
@@ -3609,8 +3787,8 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
nParameterOffsetByContext = 1;
}
- UINT32 nEffectiveParamCount = nParamCount - nParameterOffsetByContext;
- UINT32 nAllocParamCount = nEffectiveParamCount;
+ sal_uInt32 nEffectiveParamCount = nParamCount - nParameterOffsetByContext;
+ sal_uInt32 nAllocParamCount = nEffectiveParamCount;
if( nEffectiveParamCount > nUnoParamCount )
{
if( !bRestParameterMode )
@@ -3637,9 +3815,9 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
{
args.realloc( nAllocParamCount );
Any* pAnyArgs = args.getArray();
- for( UINT32 i = 0 ; i < nEffectiveParamCount ; i++ )
+ for( sal_uInt32 i = 0 ; i < nEffectiveParamCount ; i++ )
{
- USHORT iSbx = (USHORT)(i + nSbxParameterOffset + nParameterOffsetByContext);
+ sal_uInt16 iSbx = (sal_uInt16)(i + nSbxParameterOffset + nParameterOffsetByContext);
// bRestParameterMode allows nEffectiveParamCount > nUnoParamCount
Reference< XParameter > xParam;
@@ -3661,7 +3839,7 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
if( !bOutParams )
{
if( xParam->isOut() )
- bOutParams = TRUE;
+ bOutParams = sal_True;
}
}
else
@@ -3706,14 +3884,14 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
{
const Any* pAnyArgs = args.getConstArray();
- for( UINT32 j = 0 ; j < nUnoParamCount ; j++ )
+ for( sal_uInt32 j = 0 ; j < nUnoParamCount ; j++ )
{
Reference< XParameter > xParam = pParameterSeq[j];
if( !xParam.is() )
continue;
if( xParam->isOut() )
- unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pAnyArgs[ j ] );
+ unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pAnyArgs[ j ] );
}
}
}
@@ -3798,8 +3976,8 @@ void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
{
SbxVariable* pVar = pHint->GetVar();
SbxArray* pParams = pVar->GetParameters();
- UINT32 nParamCount = pParams ? ((UINT32)pParams->Count() - 1) : 0;
- UINT32 nAllowedParamCount = 1;
+ sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0;
+ sal_uInt32 nAllowedParamCount = 1;
Reference < XComponentContext > xContextToUse;
if( nParamCount > 0 )
@@ -3858,7 +4036,7 @@ public:
~BasicAllListener_Impl();
// Methods of XInterface
- //virtual BOOL queryInterface( Uik aUik, Reference< XInterface > & rOut );
+ //virtual sal_Bool queryInterface( Uik aUik, Reference< XInterface > & rOut );
// Methods of XAllListener
virtual void SAL_CALL firing(const AllEventObject& Event) throw ( RuntimeException );
@@ -3904,13 +4082,13 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet
// Create in a Basic Array
SbxArrayRef xSbxArray = new SbxArray( SbxVARIANT );
const Any * pArgs = Event.Arguments.getConstArray();
- INT32 nCount = Event.Arguments.getLength();
- for( INT32 i = 0; i < nCount; i++ )
+ sal_Int32 nCount = Event.Arguments.getLength();
+ for( sal_Int32 i = 0; i < nCount; i++ )
{
// Convert elements
SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
- xSbxArray->Put( xVar, sal::static_int_cast< USHORT >(i+1) );
+ xSbxArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) );
}
pLib->Call( aMethodName, xSbxArray );
@@ -3922,7 +4100,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet
if( pVar )
{
// #95792 Avoid a second call
- USHORT nFlags = pVar->GetFlags();
+ sal_uInt16 nFlags = pVar->GetFlags();
pVar->SetFlag( SBX_NO_BROADCAST );
*pRet = sbxToUnoValueImpl( pVar );
pVar->SetFlags( nFlags );
@@ -4117,7 +4295,7 @@ sal_Bool SAL_CALL InvocationToAllListenerMapper::hasProperty(const ::rtl::OUStri
// Uno-Service erzeugen
// 1. Parameter == Prefix-Name of the macro
// 2. Parameter == fully qualified name of the listener
-void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
//RTLFUNC(CreateUnoListener)
{
(void)bWrite;
@@ -4181,7 +4359,7 @@ void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
//========================================================================
// Represents the DefaultContext property of the ProcessServiceManager
// in the Basic runtime system.
-void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
@@ -4209,11 +4387,13 @@ void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite
//========================================================================
// Creates a Basic wrapper object for a strongly typed Uno value
// 1. parameter: Uno type as full qualified type name, e.g. "byte[]"
-void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
{
(void)pBasic;
(void)bWrite;
+ static String aTypeTypeString( RTL_CONSTASCII_USTRINGPARAM("type") );
+
// 2 parameters needed
if ( rPar.Count() != 3 )
{
@@ -4225,6 +4405,41 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
String aTypeName = rPar.Get(1)->GetString();
SbxVariable* pVal = rPar.Get(2);
+ if( aTypeName == aTypeTypeString )
+ {
+ SbxDataType eBaseType = pVal->SbxValue::GetType();
+ String aValTypeName;
+ if( eBaseType == SbxSTRING )
+ {
+ aValTypeName = pVal->GetString();
+ }
+ else if( eBaseType == SbxOBJECT )
+ {
+ // XIdlClass?
+ Reference< XIdlClass > xIdlClass;
+
+ SbxBaseRef pObj = (SbxBase*)pVal->GetObject();
+ if( pObj && pObj->ISA(SbUnoObject) )
+ {
+ Any aUnoAny = ((SbUnoObject*)(SbxBase*)pObj)->getUnoAny();
+ aUnoAny >>= xIdlClass;
+ }
+
+ if( xIdlClass.is() )
+ aValTypeName = xIdlClass->getName();
+ }
+ Type aType;
+ bool bSuccess = implGetTypeByName( aValTypeName, aType );
+ if( bSuccess )
+ {
+ Any aTypeAny( aType );
+ SbxVariableRef refVar = rPar.Get(0);
+ SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aTypeAny );
+ refVar->PutObject( xUnoAnyObject );
+ }
+ return;
+ }
+
// Check the type
Reference< XHierarchicalNameAccess > xTypeAccess = getTypeProvider_Impl();
Any aRet;
@@ -4280,14 +4495,26 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
//==========================================================================
-typedef WeakImplHelper1< XInvocation > ModuleInvocationProxyHelper;
+namespace {
+class OMutexBasis
+{
+protected:
+ // this mutex is necessary for OInterfaceContainerHelper
+ ::osl::Mutex m_aMutex;
+};
+} // namespace
+
+typedef WeakImplHelper2< XInvocation, XComponent > ModuleInvocationProxyHelper;
-class ModuleInvocationProxy : public ModuleInvocationProxyHelper
+class ModuleInvocationProxy : public OMutexBasis,
+ public ModuleInvocationProxyHelper
{
::rtl::OUString m_aPrefix;
SbxObjectRef m_xScopeObj;
bool m_bProxyIsClassModuleObject;
+ ::cppu::OInterfaceContainerHelper m_aListeners;
+
public:
ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
~ModuleInvocationProxy()
@@ -4307,11 +4534,17 @@ public:
Sequence< sal_Int16 >& rOutParamIndex,
Sequence< Any >& rOutParam )
throw( CannotConvertException, InvocationTargetException );
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw(RuntimeException);
+ virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
+ virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException);
};
ModuleInvocationProxy::ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
: m_aPrefix( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_") ) )
, m_xScopeObj( xScopeObj )
+ , m_aListeners( m_aMutex )
{
m_bProxyIsClassModuleObject = xScopeObj.Is() ? xScopeObj->ISA(SbClassModuleObject) : false;
}
@@ -4408,13 +4641,27 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
SolarMutexGuard guard;
Any aRet;
- if( !m_xScopeObj.Is() )
+ SbxObjectRef xScopeObj = m_xScopeObj;
+ if( !xScopeObj.Is() )
return aRet;
::rtl::OUString aFunctionName = m_aPrefix;
aFunctionName += rFunction;
- SbxVariable* p = m_xScopeObj->Find( aFunctionName, SbxCLASS_METHOD );
+ sal_Bool bSetRescheduleBack = sal_False;
+ sal_Bool bOldReschedule = sal_True;
+ SbiInstance* pInst = pINST;
+ if( pInst && pInst->IsCompatibility() )
+ {
+ bOldReschedule = pInst->IsReschedule();
+ if ( bOldReschedule )
+ {
+ pInst->EnableReschedule( sal_False );
+ bSetRescheduleBack = sal_True;
+ }
+ }
+
+ SbxVariable* p = xScopeObj->Find( aFunctionName, SbxCLASS_METHOD );
SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
if( pMeth == NULL )
{
@@ -4434,7 +4681,7 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
{
SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
- xArray->Put( xVar, sal::static_int_cast< USHORT >(i+1) );
+ xArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) );
}
}
@@ -4446,11 +4693,38 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
aRet = sbxToUnoValue( xValue );
pMeth->SetParameters( NULL );
+ if( bSetRescheduleBack )
+ pInst->EnableReschedule( bOldReschedule );
+
// TODO: OutParameter?
return aRet;
}
+void SAL_CALL ModuleInvocationProxy::dispose()
+ throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ EventObject aEvent( (XComponent*)this );
+ m_aListeners.disposeAndClear( aEvent );
+
+ m_xScopeObj = NULL;
+}
+
+void SAL_CALL ModuleInvocationProxy::addEventListener( const Reference< XEventListener >& xListener )
+ throw (RuntimeException)
+{
+ m_aListeners.addInterface( xListener );
+}
+
+void SAL_CALL ModuleInvocationProxy::removeEventListener( const Reference< XEventListener >& xListener )
+ throw (RuntimeException)
+{
+ m_aListeners.removeInterface( xListener );
+}
+
+
Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType,
const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
{
@@ -4480,6 +4754,97 @@ Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::
return xRet;
}
+typedef std::vector< WeakReference< XComponent > > ComponentRefVector;
+
+struct StarBasicDisposeItem
+{
+ StarBASIC* m_pBasic;
+ SbxArrayRef m_pRegisteredVariables;
+ ComponentRefVector m_vComImplementsObjects;
+
+ StarBasicDisposeItem( StarBASIC* pBasic )
+ : m_pBasic( pBasic )
+ {
+ m_pRegisteredVariables = new SbxArray();
+ }
+};
+
+typedef std::vector< StarBasicDisposeItem* > DisposeItemVector;
+
+static DisposeItemVector GaDisposeItemVector;
+
+DisposeItemVector::iterator lcl_findItemForBasic( StarBASIC* pBasic )
+{
+ DisposeItemVector::iterator it;
+ for( it = GaDisposeItemVector.begin() ; it != GaDisposeItemVector.end() ; ++it )
+ {
+ StarBasicDisposeItem* pItem = *it;
+ if( pItem->m_pBasic == pBasic )
+ return it;
+ }
+ return GaDisposeItemVector.end();
+}
+
+StarBasicDisposeItem* lcl_getOrCreateItemForBasic( StarBASIC* pBasic )
+{
+ DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
+ StarBasicDisposeItem* pItem = (it != GaDisposeItemVector.end()) ? *it : NULL;
+ if( pItem == NULL )
+ {
+ pItem = new StarBasicDisposeItem( pBasic );
+ GaDisposeItemVector.push_back( pItem );
+ }
+ return pItem;
+}
+
+void registerComponentToBeDisposedForBasic
+ ( Reference< XComponent > xComponent, StarBASIC* pBasic )
+{
+ StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
+ pItem->m_vComImplementsObjects.push_back( xComponent );
+}
+
+void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic )
+{
+ StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
+ SbxArray* pArray = pItem->m_pRegisteredVariables;
+ pArray->Put( pVar, pArray->Count() );
+}
+
+void disposeComVariablesForBasic( StarBASIC* pBasic )
+{
+ DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
+ if( it != GaDisposeItemVector.end() )
+ {
+ StarBasicDisposeItem* pItem = *it;
+
+ SbxArray* pArray = pItem->m_pRegisteredVariables;
+ sal_uInt16 nCount = pArray->Count();
+ for( sal_uInt16 i = 0 ; i < nCount ; ++i )
+ {
+ SbxVariable* pVar = pArray->Get( i );
+ pVar->ClearComListener();
+ }
+
+ ComponentRefVector& rv = pItem->m_vComImplementsObjects;
+ ComponentRefVector::iterator itCRV;
+ for( itCRV = rv.begin() ; itCRV != rv.end() ; ++itCRV )
+ {
+ try
+ {
+ Reference< XComponent > xComponent( (*itCRV).get(), UNO_QUERY_THROW );
+ xComponent->dispose();
+ }
+ catch( Exception& )
+ {}
+ }
+
+ delete pItem;
+ GaDisposeItemVector.erase( it );
+ }
+}
+
+
// Handle module implements mechanism for OLE types
bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject )
{
@@ -4500,8 +4865,8 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
bool bSuccess = false;
SbxArray* pModIfaces = pClassData->mxIfaces;
- USHORT nCount = pModIfaces->Count();
- for( USHORT i = 0 ; i < nCount ; ++i )
+ sal_uInt16 nCount = pModIfaces->Count();
+ for( sal_uInt16 i = 0 ; i < nCount ; ++i )
{
SbxVariable* pVar = pModIfaces->Get( i );
::rtl::OUString aIfaceName = pVar->GetName();
@@ -4533,6 +4898,23 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
if( bSuccess )
{
+ Reference< XComponent > xComponent( xProxy, UNO_QUERY );
+ if( xComponent.is() )
+ {
+ StarBASIC* pParentBasic = NULL;
+ SbxObject* pCurObject = this;
+ do
+ {
+ SbxObject* pObjParent = pCurObject->GetParent();
+ pParentBasic = PTR_CAST( StarBASIC, pObjParent );
+ pCurObject = pObjParent;
+ }
+ while( pParentBasic == NULL && pCurObject != NULL );
+
+ OSL_ASSERT( pParentBasic != NULL );
+ registerComponentToBeDisposedForBasic( xComponent, pParentBasic );
+ }
+
o_rRetAny <<= xRet;
break;
}
@@ -4542,4 +4924,31 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
return bSuccess;
}
+
+// Due to an incorrect behavior IE returns an object instead of a string
+// in some scenarios. Calling toString at the object may correct this.
+// Helper function used in sbxvalue.cxx
+bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal )
+{
+ bool bSuccess = false;
+
+ SbUnoObject* pUnoObj = NULL;
+ if( pObj != NULL && (pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*)pObj)) != NULL )
+ {
+ // Only for native COM objects
+ if( pUnoObj->isNativeCOMObject() )
+ {
+ SbxVariableRef pMeth = pObj->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "toString" ) ), SbxCLASS_METHOD );
+ if ( pMeth.Is() )
+ {
+ SbxValues aRes;
+ pMeth->Get( aRes );
+ pVal->Put( aRes );
+ bSuccess = true;
+ }
+ }
+ }
+ return bSuccess;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */