summaryrefslogtreecommitdiff
path: root/extensions/source
diff options
context:
space:
mode:
authorIvo Hinkelmann <ihi@openoffice.org>2010-08-03 11:54:45 +0200
committerIvo Hinkelmann <ihi@openoffice.org>2010-08-03 11:54:45 +0200
commit50493840e2f973d56540b826420fe52b0cf0dd5f (patch)
tree856081756b79c3e90765f3ce7f4b5226fa94d13f /extensions/source
parentb45ea9fcb49c5d12507e6e08724830e55d33b27a (diff)
parent8f28b3c61f002a5a59953526a6465ef43d72f03d (diff)
CWS-TOOLING: integrate CWS mib17
Diffstat (limited to 'extensions/source')
-rwxr-xr-x[-rw-r--r--]extensions/source/ole/oleobjw.cxx88
-rw-r--r--extensions/source/ole/oleobjw.hxx13
-rw-r--r--extensions/source/ole/unoconversionutilities.hxx58
3 files changed, 123 insertions, 36 deletions
diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx
index 1aadd37b2..7a73ed7e6 100644..100755
--- 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<XMultiServiceFactory>& xFa
sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass):
UnoConversionUtilities<IUnknownWrapper_Impl>( 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<Reference<XInvocation>*>( 0)))
- {
- if (m_spDispatch)
- return WeakImplHelper4<XInvocation, XBridgeSupplier2,
- XInitialization, XAutomationObject>::queryInterface(t);
- else
- return Any();
- }
-
- return WeakImplHelper4<XInvocation, XBridgeSupplier2,
- XInitialization, XAutomationObject>::queryInterface(t);
+ if (t == getCppuType(static_cast<Reference<XDefaultMethod>*>( 0)) && !m_bHasDfltMethod )
+ return Any();
+ if (t == getCppuType(static_cast<Reference<XDefaultProperty>*>( 0)) && !m_bHasDfltProperty )
+ return Any();
+ if (t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) && !m_spDispatch)
+ return Any();
+
+ return WeakImplHelper6<XInvocation, XBridgeSupplier2,
+ XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>::queryInterface(t);
}
Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection(void)
@@ -1194,6 +1193,68 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument
aArguments[1] >>= m_bOriginalDispatch;
aArguments[2] >>= m_seqTypes;
+
+ ITypeInfo* pType = NULL;
+ try
+ {
+ // 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
+ {
+ // Get Default member
+ CComBSTR defaultMemberName;
+ if ( SUCCEEDED( pType->GetDocumentation(0, &defaultMemberName, 0, 0, 0 ) ) )
+ {
+ OUString usName(reinterpret_cast<const sal_Unicode*>(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<XInterface>() );
+ }
+ catch( Exception& e )
+ {
+ throw RuntimeException(
+ OUSTR("[automation bridge] unexpected exception in IUnknownWrapper_Impl::initialiase() error message: \n") + e.Message,
+ Reference<XInterface>() );
+ }
+ }
}
// UnoConversionUtilities --------------------------------------------------------------------------------
@@ -1445,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
diff --git a/extensions/source/ole/oleobjw.hxx b/extensions/source/ole/oleobjw.hxx
index dfc88a50c..334fb18e5 100644
--- a/extensions/source/ole/oleobjw.hxx
+++ b/extensions/source/ole/oleobjw.hxx
@@ -50,11 +50,14 @@
#endif
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx>
+#include <cppuhelper/implbase6.hxx>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
#include <rtl/ustring.hxx>
+#include <com/sun/star/script/XDefaultProperty.hpp>
+#include <com/sun/star/script/XDefaultMethod.hpp>
#include <typelib/typedescription.hxx>
#include "unoconversionutilities.hxx"
@@ -78,7 +81,8 @@ typedef hash_multimap<OUString, unsigned int, hashOUString_Impl, equalOUString_I
// This class wraps an IDispatch and maps XInvocation calls to IDispatch calls on the wrapped object.
// If m_TypeDescription is set then this class represents an UNO interface implemented in a COM component.
// The interface is not a real interface in terms of an abstract class but is realized through IDispatch.
-class IUnknownWrapper_Impl : public WeakImplHelper4<XInvocation, XBridgeSupplier2, XInitialization, XAutomationObject>,
+class IUnknownWrapper_Impl : public WeakImplHelper6<XInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>,
+
public UnoConversionUtilities<IUnknownWrapper_Impl>
{
@@ -126,8 +130,10 @@ 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,
const Sequence< Any >& Params,
@@ -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
diff --git a/extensions/source/ole/unoconversionutilities.hxx b/extensions/source/ole/unoconversionutilities.hxx
index e8eb3ad6f..1fec67353 100644
--- a/extensions/source/ole/unoconversionutilities.hxx
+++ b/extensions/source/ole/unoconversionutilities.hxx
@@ -1324,33 +1324,47 @@ SAFEARRAY* UnoConversionUtilities<T>::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];
-
- pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
-
- Any unoElement;
- // sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements;
- sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements;
-
- for (sal_uInt32 i = 0; i < n; i++)
+
+ // 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 ) );
+
+ if ( eTargetElementType != VT_EMPTY )
+ pArray = createUnoSequenceWrapper( rSeq, eTargetElementType );
+
+ if ( !pArray )
{
- unoElement.setValue( pSeqData + i * nElementSize, pSeqElementDesc);
- VariantInit(&oleElement);
+ sal_Int32 nElementSize= pSeqElementDesc->nSize;
+ n= punoSeq->nElements;
- anyToVariant(&oleElement, unoElement);
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = n;
+ VARIANT oleElement;
+ long safeI[1];
- safeI[0] = i;
- SafeArrayPutElement(pArray, safeI, &oleElement);
+ pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound);
- VariantClear(&oleElement);
+ Any unoElement;
+ // sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->pElements;
+ sal_uInt8 * pSeqData= (sal_uInt8*) punoSeq->elements;
+
+ 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);
+
+ VariantClear(&oleElement);
+ }
}
+
TYPELIB_DANGER_RELEASE( pSeqElementDesc);
return pArray;