checkUnoObjectType etc always deref their ptr arg, convert to ref

Change-Id: Iabdb057fb2dc05cfb8c98864dc5109360b50633a
This commit is contained in:
Caolán McNamara 2015-10-02 09:27:37 +01:00
parent 446be18a3e
commit e9ae1b64af
3 changed files with 44 additions and 47 deletions

View File

@ -1607,33 +1607,29 @@ OUString Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Referenc
return aRetStr.makeStringAndClear(); return aRetStr.makeStringAndClear();
} }
OUString getDbgObjectNameImpl( SbUnoObject* pUnoObj ) OUString getDbgObjectNameImpl(SbUnoObject& rUnoObj)
{ {
OUString aName; OUString aName = rUnoObj.GetClassName();
if( pUnoObj ) if( aName.isEmpty() )
{ {
aName = pUnoObj->GetClassName(); Any aToInspectObj = rUnoObj.getUnoAny();
if( aName.isEmpty() ) TypeClass eType = aToInspectObj.getValueType().getTypeClass();
Reference< XInterface > xObj;
if( eType == TypeClass_INTERFACE )
xObj = *static_cast<Reference< XInterface > const *>(aToInspectObj.getValue());
if( xObj.is() )
{ {
Any aToInspectObj = pUnoObj->getUnoAny(); Reference< XServiceInfo > xServiceInfo( xObj, UNO_QUERY );
TypeClass eType = aToInspectObj.getValueType().getTypeClass(); if( xServiceInfo.is() )
Reference< XInterface > xObj; aName = xServiceInfo->getImplementationName();
if( eType == TypeClass_INTERFACE )
xObj = *static_cast<Reference< XInterface > const *>(aToInspectObj.getValue());
if( xObj.is() )
{
Reference< XServiceInfo > xServiceInfo( xObj, UNO_QUERY );
if( xServiceInfo.is() )
aName = xServiceInfo->getImplementationName();
}
} }
} }
return aName; return aName;
} }
OUString getDbgObjectName( SbUnoObject* pUnoObj ) OUString getDbgObjectName(SbUnoObject& rUnoObj)
{ {
OUString aName = getDbgObjectNameImpl( pUnoObj ); OUString aName = getDbgObjectNameImpl(rUnoObj);
if( aName.isEmpty() ) if( aName.isEmpty() )
aName += "Unknown"; aName += "Unknown";
@ -1650,22 +1646,23 @@ OUString getDbgObjectName( SbUnoObject* pUnoObj )
OUString getBasicObjectTypeName( SbxObject* pObj ) OUString getBasicObjectTypeName( SbxObject* pObj )
{ {
OUString aName; if (pObj)
if( pObj )
{ {
SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>( pObj ); if (SbUnoObject* pUnoObj = dynamic_cast<SbUnoObject*>(pObj))
SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>( pObj ); {
if( pUnoObj ) return getDbgObjectNameImpl(*pUnoObj);
aName = getDbgObjectNameImpl( pUnoObj ); }
else if ( pUnoStructObj ) else if (SbUnoStructRefObject* pUnoStructObj = dynamic_cast<SbUnoStructRefObject*>(pObj))
aName = pUnoStructObj->GetClassName(); {
return pUnoStructObj->GetClassName();
}
} }
return aName; return OUString();
} }
bool checkUnoObjectType( SbUnoObject* pUnoObj, const OUString& rClass ) bool checkUnoObjectType(SbUnoObject& rUnoObj, const OUString& rClass)
{ {
Any aToInspectObj = pUnoObj->getUnoAny(); Any aToInspectObj = rUnoObj.getUnoAny();
TypeClass eType = aToInspectObj.getValueType().getTypeClass(); TypeClass eType = aToInspectObj.getValueType().getTypeClass();
if( eType != TypeClass_INTERFACE ) if( eType != TypeClass_INTERFACE )
{ {
@ -1759,9 +1756,9 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, const OUString& rClass )
} }
// Debugging help method to readout the imlemented interfaces of an object // Debugging help method to readout the imlemented interfaces of an object
OUString Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj ) OUString Impl_GetSupportedInterfaces(SbUnoObject& rUnoObj)
{ {
Any aToInspectObj = pUnoObj->getUnoAny(); Any aToInspectObj = rUnoObj.getUnoAny();
// allow only TypeClass interface // allow only TypeClass interface
TypeClass eType = aToInspectObj.getValueType().getTypeClass(); TypeClass eType = aToInspectObj.getValueType().getTypeClass();
@ -1779,7 +1776,7 @@ OUString Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj )
Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY ); Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
aRet.append( "Supported interfaces by object " ); aRet.append( "Supported interfaces by object " );
aRet.append( getDbgObjectName( pUnoObj ) ); aRet.append(getDbgObjectName(rUnoObj));
aRet.append( "\n" ); aRet.append( "\n" );
if( xTypeProvider.is() ) if( xTypeProvider.is() )
{ {
@ -1858,17 +1855,17 @@ OUString Dbg_SbxDataType2String( SbxDataType eType )
} }
// Debugging help method to display the properties of a SbUnoObjects // Debugging help method to display the properties of a SbUnoObjects
OUString Impl_DumpProperties( SbUnoObject* pUnoObj ) OUString Impl_DumpProperties(SbUnoObject& rUnoObj)
{ {
OUStringBuffer aRet; OUStringBuffer aRet;
aRet.append("Properties of object "); aRet.append("Properties of object ");
aRet.append( getDbgObjectName( pUnoObj ) ); aRet.append(getDbgObjectName(rUnoObj));
// analyse the Uno-Infos to recognise the arrays // analyse the Uno-Infos to recognise the arrays
Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess(); Reference< XIntrospectionAccess > xAccess = rUnoObj.getIntrospectionAccess();
if( !xAccess.is() ) if( !xAccess.is() )
{ {
Reference< XInvocation > xInvok = pUnoObj->getInvocation(); Reference< XInvocation > xInvok = rUnoObj.getInvocation();
if( xInvok.is() ) if( xInvok.is() )
xAccess = xInvok->getIntrospection(); xAccess = xInvok->getIntrospection();
} }
@ -1882,7 +1879,7 @@ OUString Impl_DumpProperties( SbUnoObject* pUnoObj )
sal_uInt32 nUnoPropCount = props.getLength(); sal_uInt32 nUnoPropCount = props.getLength();
const Property* pUnoProps = props.getConstArray(); const Property* pUnoProps = props.getConstArray();
SbxArray* pProps = pUnoObj->GetProperties(); SbxArray* pProps = rUnoObj.GetProperties();
sal_uInt16 nPropCount = pProps->Count(); sal_uInt16 nPropCount = pProps->Count();
sal_uInt16 nPropsPerLine = 1 + nPropCount / 30; sal_uInt16 nPropsPerLine = 1 + nPropCount / 30;
for( sal_uInt16 i = 0; i < nPropCount; i++ ) for( sal_uInt16 i = 0; i < nPropCount; i++ )
@ -1935,17 +1932,17 @@ OUString Impl_DumpProperties( SbUnoObject* pUnoObj )
} }
// Debugging help method to display the methods of an SbUnoObjects // Debugging help method to display the methods of an SbUnoObjects
OUString Impl_DumpMethods( SbUnoObject* pUnoObj ) OUString Impl_DumpMethods(SbUnoObject& rUnoObj)
{ {
OUStringBuffer aRet; OUStringBuffer aRet;
aRet.append("Methods of object "); aRet.append("Methods of object ");
aRet.append( getDbgObjectName( pUnoObj ) ); aRet.append(getDbgObjectName(rUnoObj));
// XIntrospectionAccess, so that the types of the parameter could be outputted // XIntrospectionAccess, so that the types of the parameter could be outputted
Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess(); Reference< XIntrospectionAccess > xAccess = rUnoObj.getIntrospectionAccess();
if( !xAccess.is() ) if( !xAccess.is() )
{ {
Reference< XInvocation > xInvok = pUnoObj->getInvocation(); Reference< XInvocation > xInvok = rUnoObj.getInvocation();
if( xInvok.is() ) if( xInvok.is() )
xAccess = xInvok->getIntrospection(); xAccess = xInvok->getIntrospection();
} }
@ -1958,7 +1955,7 @@ OUString Impl_DumpMethods( SbUnoObject* pUnoObj )
( MethodConcept::ALL - MethodConcept::DANGEROUS ); ( MethodConcept::ALL - MethodConcept::DANGEROUS );
const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray(); const Reference< XIdlMethod >* pUnoMethods = methods.getConstArray();
SbxArray* pMethods = pUnoObj->GetMethods(); SbxArray* pMethods = rUnoObj.GetMethods();
sal_uInt16 nMethodCount = pMethods->Count(); sal_uInt16 nMethodCount = pMethods->Count();
if( !nMethodCount ) if( !nMethodCount )
{ {
@ -2046,7 +2043,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
// Id == -1: Display implemented interfaces according the ClassProvider // Id == -1: Display implemented interfaces according the ClassProvider
if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES" if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES"
{ {
OUString aRetStr = Impl_GetSupportedInterfaces( this ); OUString aRetStr = Impl_GetSupportedInterfaces(*this);
pVar->PutString( aRetStr ); pVar->PutString( aRetStr );
} }
// Id == -2: output properties // Id == -2: output properties
@ -2054,7 +2051,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{ {
// now all properties must be created // now all properties must be created
implCreateAll(); implCreateAll();
OUString aRetStr = Impl_DumpProperties( this ); OUString aRetStr = Impl_DumpProperties(*this);
pVar->PutString( aRetStr ); pVar->PutString( aRetStr );
} }
// Id == -3: output the methods // Id == -3: output the methods
@ -2062,7 +2059,7 @@ void SbUnoObject::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{ {
// now all properties must be created // now all properties must be created
implCreateAll(); implCreateAll();
OUString aRetStr = Impl_DumpMethods( this ); OUString aRetStr = Impl_DumpMethods(*this);
pVar->PutString( aRetStr ); pVar->PutString( aRetStr );
} }
return; return;

View File

@ -410,7 +410,7 @@ css::uno::Reference< css::uno::XInterface > createComListener( const css::uno::A
const OUString& aPrefix, const OUString& aPrefix,
SbxObjectRef xScopeObj ); SbxObjectRef xScopeObj );
bool checkUnoObjectType( SbUnoObject* refVal, const OUString& aClass ); bool checkUnoObjectType(SbUnoObject& refVal, const OUString& aClass);
SbUnoObject* createOLEObject_Impl( const OUString& aType ); SbUnoObject* createOLEObject_Impl( const OUString& aType );

View File

@ -3255,7 +3255,7 @@ bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal,
if ( ( bVBAEnabled || CodeCompleteOptions::IsExtendedTypeDeclaration() ) && pObj->IsA( TYPE(SbUnoObject) ) ) if ( ( bVBAEnabled || CodeCompleteOptions::IsExtendedTypeDeclaration() ) && pObj->IsA( TYPE(SbUnoObject) ) )
{ {
SbUnoObject& rUnoObj = dynamic_cast<SbUnoObject&>(*pObj); SbUnoObject& rUnoObj = dynamic_cast<SbUnoObject&>(*pObj);
bOk = checkUnoObjectType(&rUnoObj, aClass); bOk = checkUnoObjectType(rUnoObj, aClass);
} }
else else
bOk = false; bOk = false;