Kaydet (Commit) 3c041720 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Simplify: Use AutomationInvokedZone::isActive()

Don't need the mbFromOLE boolean flag and the special "FromOLE"
parameter passed to the InvocationService::
createInstanceWithArguments().

Change-Id: I05e10a78955d87cb7c37e198c60c3ddcfdbc4275
üst bfedeb79
...@@ -1395,9 +1395,8 @@ void UnoConversionUtilities<T>::createUnoObjectWrapper(const Any & rObj, VARIANT ...@@ -1395,9 +1395,8 @@ void UnoConversionUtilities<T>::createUnoObjectWrapper(const Any & rObj, VARIANT
Reference<XSingleServiceFactory> xInvFactory= getInvocationFactory(rObj); Reference<XSingleServiceFactory> xInvFactory= getInvocationFactory(rObj);
if (xInvFactory.is()) if (xInvFactory.is())
{ {
Sequence<Any> params(2); Sequence<Any> params(1);
params.getArray()[0] = rObj; params.getArray()[0] = rObj;
params.getArray()[1] = makeAny(OUString("FromOLE"));
Reference<XInterface> xInt2 = xInvFactory->createInstanceWithArguments(params); Reference<XInterface> xInt2 = xInvFactory->createInstanceWithArguments(params);
xInv.set(xInt2, UNO_QUERY); xInv.set(xInt2, UNO_QUERY);
} }
......
...@@ -16,6 +16,7 @@ $(eval $(call gb_Library_use_udk_api,invocation)) ...@@ -16,6 +16,7 @@ $(eval $(call gb_Library_use_udk_api,invocation))
$(eval $(call gb_Library_use_libraries,invocation,\ $(eval $(call gb_Library_use_libraries,invocation,\
cppu \ cppu \
cppuhelper \ cppuhelper \
comphelper \
sal \ sal \
)) ))
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <comphelper/automationinvokedzone.hxx>
#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
...@@ -99,8 +100,7 @@ class Invocation_Impl ...@@ -99,8 +100,7 @@ class Invocation_Impl
public: public:
Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &, Invocation_Impl( const Any & rAdapted, const Reference<XTypeConverter> &,
const Reference<XIntrospection> &, const Reference<XIntrospection> &,
const Reference<XIdlReflection> &, const Reference<XIdlReflection> & );
bool bFromOLE );
// XInterface // XInterface
virtual Any SAL_CALL queryInterface( const Type & aType) override; virtual Any SAL_CALL queryInterface( const Type & aType) override;
...@@ -214,8 +214,6 @@ private: ...@@ -214,8 +214,6 @@ private:
Reference<XExactName> _xENDirect, _xENIntrospection; Reference<XExactName> _xENDirect, _xENIntrospection;
bool mbFromOLE;
}; };
...@@ -224,13 +222,11 @@ Invocation_Impl::Invocation_Impl ...@@ -224,13 +222,11 @@ Invocation_Impl::Invocation_Impl
const Any & rAdapted, const Any & rAdapted,
const Reference<XTypeConverter> & rTC, const Reference<XTypeConverter> & rTC,
const Reference<XIntrospection> & rI, const Reference<XIntrospection> & rI,
const Reference<XIdlReflection> & rCR, const Reference<XIdlReflection> & rCR
bool bFromOLE
) )
: xTypeConverter( rTC ) : xTypeConverter( rTC )
, xIntrospection( rI ) , xIntrospection( rI )
, xCoreReflection( rCR ) , xCoreReflection( rCR )
, mbFromOLE( bFromOLE )
{ {
setMaterial( rAdapted ); setMaterial( rAdapted );
} }
...@@ -254,7 +250,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType ) ...@@ -254,7 +250,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
{ {
// Invocation does not support XExactName, if direct object supports // Invocation does not support XExactName, if direct object supports
// XInvocation, but not XExactName. Except when called from OLE Automation. // XInvocation, but not XExactName. Except when called from OLE Automation.
if (mbFromOLE || if (comphelper::Automation::AutomationInvokedZone::isActive() ||
(_xDirect.is() && _xENDirect.is()) || (_xDirect.is() && _xENDirect.is()) ||
(!_xDirect.is() && _xENIntrospection.is())) (!_xDirect.is() && _xENIntrospection.is()))
{ {
...@@ -308,7 +304,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType ) ...@@ -308,7 +304,7 @@ Any SAL_CALL Invocation_Impl::queryInterface( const Type & aType )
{ {
// Invocation does not support XInvocation2, if direct object supports // Invocation does not support XInvocation2, if direct object supports
// XInvocation, but not XInvocation2. // XInvocation, but not XInvocation2.
if ( mbFromOLE || if ( comphelper::Automation::AutomationInvokedZone::isActive() ||
( _xDirect.is() && _xDirect2.is()) || ( _xDirect.is() && _xDirect2.is()) ||
(!_xDirect.is() && _xIntrospectionAccess.is() ) ) (!_xDirect.is() && _xIntrospectionAccess.is() ) )
{ {
...@@ -352,7 +348,7 @@ void Invocation_Impl::setMaterial( const Any& rMaterial ) ...@@ -352,7 +348,7 @@ void Invocation_Impl::setMaterial( const Any& rMaterial )
// First do this outside the guard // First do this outside the guard
_xDirect.set( rMaterial, UNO_QUERY ); _xDirect.set( rMaterial, UNO_QUERY );
if( !mbFromOLE && _xDirect.is() ) if( !comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is() )
{ {
// Consult object directly // Consult object directly
_xElementAccess.set( _xDirect, UNO_QUERY ); _xElementAccess.set( _xDirect, UNO_QUERY );
...@@ -448,7 +444,7 @@ Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection() ...@@ -448,7 +444,7 @@ Reference<XIntrospectionAccess> Invocation_Impl::getIntrospection()
sal_Bool Invocation_Impl::hasMethod( const OUString& Name ) sal_Bool Invocation_Impl::hasMethod( const OUString& Name )
{ {
if (!mbFromOLE && _xDirect.is()) if (!comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is())
return _xDirect->hasMethod( Name ); return _xDirect->hasMethod( Name );
if( _xIntrospectionAccess.is() ) if( _xIntrospectionAccess.is() )
return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS ); return _xIntrospectionAccess->hasMethod( Name, MethodConcept::ALL ^ MethodConcept::DANGEROUS );
...@@ -461,7 +457,7 @@ sal_Bool Invocation_Impl::hasProperty( const OUString& Name ) ...@@ -461,7 +457,7 @@ sal_Bool Invocation_Impl::hasProperty( const OUString& Name )
if (_xDirect.is()) if (_xDirect.is())
{ {
bool bRet = _xDirect->hasProperty( Name ); bool bRet = _xDirect->hasProperty( Name );
if (bRet || !mbFromOLE) if (bRet || !comphelper::Automation::AutomationInvokedZone::isActive())
return bRet; return bRet;
} }
// PropertySet // PropertySet
...@@ -484,7 +480,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName ) ...@@ -484,7 +480,7 @@ Any Invocation_Impl::getValue( const OUString& PropertyName )
} }
catch (UnknownPropertyException &) catch (UnknownPropertyException &)
{ {
if (!mbFromOLE) if (!comphelper::Automation::AutomationInvokedZone::isActive())
throw; throw;
} }
try try
...@@ -528,7 +524,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value ) ...@@ -528,7 +524,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
} }
catch (UnknownPropertyException &) catch (UnknownPropertyException &)
{ {
if (!mbFromOLE) if (!comphelper::Automation::AutomationInvokedZone::isActive())
throw; throw;
} }
try try
...@@ -602,7 +598,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value ) ...@@ -602,7 +598,7 @@ void Invocation_Impl::setValue( const OUString& PropertyName, const Any& Value )
Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams, Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& InParams,
Sequence<sal_Int16>& OutIndices, Sequence<Any>& OutParams ) Sequence<sal_Int16>& OutIndices, Sequence<Any>& OutParams )
{ {
if (!mbFromOLE && _xDirect.is()) if (!comphelper::Automation::AutomationInvokedZone::isActive() && _xDirect.is())
return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams ); return _xDirect->invoke( FunctionName, InParams, OutIndices, OutParams );
if (_xIntrospectionAccess.is()) if (_xIntrospectionAccess.is())
...@@ -1111,22 +1107,11 @@ Reference<XInterface> InvocationService::createInstance() ...@@ -1111,22 +1107,11 @@ Reference<XInterface> InvocationService::createInstance()
Reference<XInterface> InvocationService::createInstanceWithArguments( Reference<XInterface> InvocationService::createInstanceWithArguments(
const Sequence<Any>& rArguments ) const Sequence<Any>& rArguments )
{ {
if (rArguments.getLength() == 2)
{
OUString aArg1;
if ((rArguments[1] >>= aArg1) &&
aArg1 == "FromOLE")
{
return Reference< XInterface >
( *new Invocation_Impl( *rArguments.getConstArray(),
xTypeConverter, xIntrospection, xCoreReflection, true ) );
}
}
if (rArguments.getLength() == 1) if (rArguments.getLength() == 1)
{ {
return Reference< XInterface > return Reference< XInterface >
( *new Invocation_Impl( *rArguments.getConstArray(), ( *new Invocation_Impl( *rArguments.getConstArray(),
xTypeConverter, xIntrospection, xCoreReflection, false ) ); xTypeConverter, xIntrospection, xCoreReflection ) );
} }
//TODO:throw( Exception("no default construction of invocation adapter possible!", *this) ); //TODO:throw( Exception("no default construction of invocation adapter possible!", *this) );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment