From 0cd0153b2493bdeaac22e271884164c7c663f302 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 25 Jun 2010 08:57:06 +0200 Subject: mib17: #i110821# COM default member support --- extensions/source/ole/oleobjw.cxx | 68 ++++++++++++++++++++++++++++++++------- extensions/source/ole/oleobjw.hxx | 11 ++++++- 2 files changed, 66 insertions(+), 13 deletions(-) (limited to 'extensions/source') diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index ea9377ccf596..b1c90018f15e 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -69,6 +69,7 @@ using namespace boost; using namespace osl; using namespace rtl; using namespace cppu; +using namespace com::sun::star::script; using namespace com::sun::star::lang; using namespace com::sun::star::bridge; using namespace com::sun::star::bridge::oleautomation; @@ -108,7 +109,7 @@ IUnknownWrapper_Impl::IUnknownWrapper_Impl( Reference& xFa sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass): UnoConversionUtilities( xFactory, unoWrapperClass, comWrapperClass), m_pxIdlClass( NULL), m_eJScript( JScriptUndefined), - m_bComTlbIndexInit(false) + m_bComTlbIndexInit(false), m_bHasDfltMethod(false), m_bHasDfltProperty(false) { } @@ -147,17 +148,15 @@ IUnknownWrapper_Impl::~IUnknownWrapper_Impl() Any IUnknownWrapper_Impl::queryInterface(const Type& t) throw (RuntimeException) { - if (t == getCppuType(static_cast*>( 0))) - { - if (m_spDispatch) - return WeakImplHelper4::queryInterface(t); - else - return Any(); - } - - return WeakImplHelper4::queryInterface(t); + if (t == getCppuType(static_cast*>( 0)) && !m_bHasDfltMethod ) + return Any(); + if (t == getCppuType(static_cast*>( 0)) && !m_bHasDfltProperty ) + return Any(); + if (t == getCppuType(static_cast*>( 0)) && !m_spDispatch) + return Any(); + + return WeakImplHelper6::queryInterface(t); } Reference SAL_CALL IUnknownWrapper_Impl::getIntrospection(void) @@ -1194,6 +1193,51 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument aArguments[1] >>= m_bOriginalDispatch; aArguments[2] >>= m_seqTypes; + try + { + ITypeInfo* pType= getTypeInfo(); + // Get Default member + CComBSTR defaultMemberName; + if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, 0, 0, 0 ) ) ) + { + OUString usName(reinterpret_cast(LPCOLESTR(defaultMemberName))); + FuncDesc aDescGet(pType); + FuncDesc aDescPut(pType); + VarDesc aVarDesc(pType); + // see if this is a property first ( more likely to be a property then a method ) + getPropDesc( usName, & aDescGet, & aDescPut, & aVarDesc); + + if ( !aDescGet && !aDescPut ) + { + getFuncDesc( usName, &aDescGet ); + if ( !aDescGet ) + throw BridgeRuntimeError( OUSTR("[automation bridge]IUnknownWrapper_Impl::initialize() Failed to get Function or Property desc. for " ) + usName ); + } + // now for some funny heuristics to make basic understand what to do + // a single aDescGet ( that doesn't take any params ) would be + // a read only ( defaultmember ) property e.g. this object + // should implement XDefaultProperty + // a single aDescGet ( that *does* ) take params is basically a + // default method e.g. implement XDefaultMethod + + // a DescPut ( I guess we only really support a default param with '1' param ) as a setValue ( but I guess we can leave it through, the object will fail if we don't get it right anyway ) + if ( aDescPut || ( aDescGet && aDescGet->cParams == 0 ) ) + m_bHasDfltProperty = true; + if ( aDescGet->cParams > 0 ) + m_bHasDfltMethod = true; + if ( m_bHasDfltProperty || m_bHasDfltMethod ) + m_sDefaultMember = usName; + } + } + catch (BridgeRuntimeError & e) + { + throw RuntimeException(e.message, Reference()); + } + catch( Exception& e) + { + throw RuntimeException(OUSTR("[automation bridge] unexpected exception in IUnknownWrapper_Impl::initialiase() error message: \n") + + e.Message, Reference()); + } } // UnoConversionUtilities -------------------------------------------------------------------------------- diff --git a/extensions/source/ole/oleobjw.hxx b/extensions/source/ole/oleobjw.hxx index 230de2b7dcf8..b990ac3af17d 100644 --- a/extensions/source/ole/oleobjw.hxx +++ b/extensions/source/ole/oleobjw.hxx @@ -50,11 +50,14 @@ #endif #include #include +#include #include #include #include +#include +#include #include #include "unoconversionutilities.hxx" @@ -78,7 +81,8 @@ typedef hash_multimap, +class IUnknownWrapper_Impl : public WeakImplHelper6, + public UnoConversionUtilities { @@ -126,7 +130,9 @@ public: // XInitialization virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw(Exception, RuntimeException); + virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; } protected: + virtual ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; } // ---------------------------------------------------------------------------- virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName, @@ -253,6 +259,9 @@ protected: bool m_bComTlbIndexInit; // Keeps the ITypeInfo obtained from IDispatch::GetTypeInfo CComPtr< ITypeInfo > m_spTypeInfo; + rtl::OUString m_sDefaultMember; + bool m_bHasDfltMethod; + bool m_bHasDfltProperty; }; } // end namespace -- cgit From 6d6a5c8567d7d43a882aa2e2be88b1992a6b4f55 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 29 Jun 2010 16:34:19 +0200 Subject: mib17: #i110821# Hot fix to avoid regression --- extensions/source/ole/oleobjw.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'extensions/source') diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index b1c90018f15e..0e203309407b 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -1231,7 +1231,9 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument } catch (BridgeRuntimeError & e) { - throw RuntimeException(e.message, Reference()); + // #i110821 Hot Fix: Fails for some objects that have + // worked before, will be evaluated in follow up issue. + //throw RuntimeException(e.message, Reference()); } catch( Exception& e) { -- cgit From f04dcac7750da85761a89e27e534032c0ce10b8d Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Tue, 6 Jul 2010 15:41:44 +0200 Subject: mib17: #162858# allow to transport COM objects without TypeInfo as before --- extensions/source/ole/oleobjw.cxx | 95 ++++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 40 deletions(-) (limited to 'extensions/source') diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index 0e203309407b..2d83d695be72 100644 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -1193,52 +1193,67 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument aArguments[1] >>= m_bOriginalDispatch; aArguments[2] >>= m_seqTypes; + + ITypeInfo* pType = NULL; try { - ITypeInfo* pType= getTypeInfo(); - // Get Default member - CComBSTR defaultMemberName; - if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, 0, 0, 0 ) ) ) + // a COM object implementation that has no TypeInfo is still a legal COM object; + // such objects can at least be transported through UNO using the bridge + // so we should allow to create wrappers for them as well + pType = getTypeInfo(); + } + catch( BridgeRuntimeError& ) + {} + catch( Exception& ) + {} + + if ( pType ) + { + try { - OUString usName(reinterpret_cast(LPCOLESTR(defaultMemberName))); - FuncDesc aDescGet(pType); - FuncDesc aDescPut(pType); - VarDesc aVarDesc(pType); - // see if this is a property first ( more likely to be a property then a method ) - getPropDesc( usName, & aDescGet, & aDescPut, & aVarDesc); - - if ( !aDescGet && !aDescPut ) + // Get Default member + CComBSTR defaultMemberName; + if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, 0, 0, 0 ) ) ) { - getFuncDesc( usName, &aDescGet ); - if ( !aDescGet ) - throw BridgeRuntimeError( OUSTR("[automation bridge]IUnknownWrapper_Impl::initialize() Failed to get Function or Property desc. for " ) + usName ); + OUString usName(reinterpret_cast(LPCOLESTR(defaultMemberName))); + FuncDesc aDescGet(pType); + FuncDesc aDescPut(pType); + VarDesc aVarDesc(pType); + // see if this is a property first ( more likely to be a property then a method ) + getPropDesc( usName, & aDescGet, & aDescPut, & aVarDesc); + + if ( !aDescGet && !aDescPut ) + { + getFuncDesc( usName, &aDescGet ); + if ( !aDescGet ) + throw BridgeRuntimeError( OUSTR("[automation bridge]IUnknownWrapper_Impl::initialize() Failed to get Function or Property desc. for " ) + usName ); + } + // now for some funny heuristics to make basic understand what to do + // a single aDescGet ( that doesn't take any params ) would be + // a read only ( defaultmember ) property e.g. this object + // should implement XDefaultProperty + // a single aDescGet ( that *does* ) take params is basically a + // default method e.g. implement XDefaultMethod + + // a DescPut ( I guess we only really support a default param with '1' param ) as a setValue ( but I guess we can leave it through, the object will fail if we don't get it right anyway ) + if ( aDescPut || ( aDescGet && aDescGet->cParams == 0 ) ) + m_bHasDfltProperty = true; + if ( aDescGet->cParams > 0 ) + m_bHasDfltMethod = true; + if ( m_bHasDfltProperty || m_bHasDfltMethod ) + m_sDefaultMember = usName; } - // now for some funny heuristics to make basic understand what to do - // a single aDescGet ( that doesn't take any params ) would be - // a read only ( defaultmember ) property e.g. this object - // should implement XDefaultProperty - // a single aDescGet ( that *does* ) take params is basically a - // default method e.g. implement XDefaultMethod - - // a DescPut ( I guess we only really support a default param with '1' param ) as a setValue ( but I guess we can leave it through, the object will fail if we don't get it right anyway ) - if ( aDescPut || ( aDescGet && aDescGet->cParams == 0 ) ) - m_bHasDfltProperty = true; - if ( aDescGet->cParams > 0 ) - m_bHasDfltMethod = true; - if ( m_bHasDfltProperty || m_bHasDfltMethod ) - m_sDefaultMember = usName; } - } - catch (BridgeRuntimeError & e) - { - // #i110821 Hot Fix: Fails for some objects that have - // worked before, will be evaluated in follow up issue. - //throw RuntimeException(e.message, Reference()); - } - catch( Exception& e) - { - throw RuntimeException(OUSTR("[automation bridge] unexpected exception in IUnknownWrapper_Impl::initialiase() error message: \n") + - e.Message, Reference()); + catch ( BridgeRuntimeError & e ) + { + throw RuntimeException( e.message, Reference() ); + } + catch( Exception& e ) + { + throw RuntimeException( + OUSTR("[automation bridge] unexpected exception in IUnknownWrapper_Impl::initialiase() error message: \n") + e.Message, + Reference() ); + } } } -- cgit From 627f5293a95a31a3b90632c01116eeb8c78829d5 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 8 Jul 2010 21:33:48 +0200 Subject: mib17: #162917# let basic byte use one byte, let olebridge convert sequence to safearray correctly --- extensions/source/ole/unoconversionutilities.hxx | 52 +++++++++++++++--------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'extensions/source') diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx index 9eb47166ca82..da95b9950427 100644 --- a/extensions/source/ole/unoconversionutilities.hxx +++ b/extensions/source/ole/unoconversionutilities.hxx @@ -1324,33 +1324,47 @@ SAFEARRAY* UnoConversionUtilities::createUnoSequenceWrapper(const Any& rSeq) typelib_TypeDescription* pSeqElementDesc= NULL; TYPELIB_DANGER_GET( &pSeqElementDesc, pSeqElementTypeRef); - sal_Int32 nElementSize= pSeqElementDesc->nSize; - n= punoSeq->nElements; - SAFEARRAYBOUND rgsabound[1]; - rgsabound[0].lLbound = 0; - rgsabound[0].cElements = n; - VARIANT oleElement; - long safeI[1]; + // try to find VARIANT type that is related to the UNO type of the sequence elements + // the sequence as a sequence element should be handled in a special way + VARTYPE eTargetElementType = VT_EMPTY; + if ( pSeqElementDesc->eTypeClass != TypeClass_SEQUENCE ) + eTargetElementType = mapTypeClassToVartype( static_cast< TypeClass >( pSeqElementDesc->eTypeClass ) ); - pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound); + if ( eTargetElementType != VT_EMPTY ) + pArray = createUnoSequenceWrapper( rSeq, eTargetElementType ); - Any unoElement; - // sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements; - sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements; - - for (sal_uInt32 i = 0; i < n; i++) + if ( !pArray ) { - unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc); - VariantInit(&oleElement); + sal_Int32 nElementSize= pSeqElementDesc->nSize; + n= punoSeq->nElements; + + SAFEARRAYBOUND rgsabound[1]; + rgsabound[0].lLbound = 0; + rgsabound[0].cElements = n; + VARIANT oleElement; + long safeI[1]; + + pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound); + + Any unoElement; + // sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements; + sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements; - anyToVariant(&oleElement, unoElement); + for (sal_uInt32 i = 0; i < n; i++) + { + unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc); + VariantInit(&oleElement); + + anyToVariant(&oleElement, unoElement); - safeI[0] = i; - SafeArrayPutElement(pArray, safeI, &oleElement); + safeI[0] = i; + SafeArrayPutElement(pArray, safeI, &oleElement); - VariantClear(&oleElement); + VariantClear(&oleElement); + } } + TYPELIB_DANGER_RELEASE( pSeqElementDesc); return pArray; -- cgit From f76803566b9a1476a1e7c8672a54ee1060d123d6 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 27 Jul 2010 12:16:05 +0200 Subject: mib17: #i110822# Fixed named parameter handling in automation bridge --- extensions/source/ole/oleobjw.cxx | 3 +++ 1 file changed, 3 insertions(+) mode change 100644 => 100755 extensions/source/ole/oleobjw.cxx (limited to 'extensions/source') diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx old mode 100644 new mode 100755 index 2d83d695be72..89cb5625bca3 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -1506,6 +1506,9 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, arDispidNamedArgs.reset(new DISPID[nSizeAr]); HRESULT hr = getTypeInfo()->GetIDsOfNames(arNames, nSizeAr, arDispidNamedArgs.get()); + if ( hr == E_NOTIMPL ) + hr = m_spDispatch->GetIDsOfNames(IID_NULL, arNames, nSizeAr, LOCALE_USER_DEFAULT, arDispidNamedArgs.get() ); + if (hr == S_OK) { // In a "property put" operation, the property value is a named param with the -- cgit