diff options
author | Noel Power <noel.power@novell.com> | 2010-10-06 10:16:13 +0100 |
---|---|---|
committer | Noel Power <noel.power@novell.com> | 2010-10-06 10:16:13 +0100 |
commit | e31e563d728078ea564a3d398b74d3467e0ba56a (patch) | |
tree | d102e9168d7511047dc6f6ed33fb3a1986795159 /extensions/source | |
parent | eedd208284e201e25b983a2371f8666d392c904f (diff) |
initial commit for vba blob ( not including container_control stuff )
Diffstat (limited to 'extensions/source')
-rwxr-xr-x | extensions/source/ole/oleobjw.cxx | 195 | ||||
-rw-r--r-- | extensions/source/ole/oleobjw.hxx | 15 | ||||
-rw-r--r-- | extensions/source/propctrlr/defaultforminspection.cxx | 2 | ||||
-rw-r--r-- | extensions/source/propctrlr/formmetadata.cxx | 1 | ||||
-rw-r--r-- | extensions/source/propctrlr/formmetadata.hxx | 1 | ||||
-rw-r--r-- | extensions/source/propctrlr/formres.src | 4 | ||||
-rw-r--r-- | extensions/source/propctrlr/formresid.hrc | 1 | ||||
-rw-r--r-- | extensions/source/propctrlr/formstrings.hxx | 1 |
8 files changed, 173 insertions, 47 deletions
diff --git a/extensions/source/ole/oleobjw.cxx b/extensions/source/ole/oleobjw.cxx index 89cb5625bca3..9a95c30ec645 100755 --- a/extensions/source/ole/oleobjw.cxx +++ b/extensions/source/ole/oleobjw.cxx @@ -49,6 +49,7 @@ #include <com/sun/star/script/XEngine.hpp> #include <com/sun/star/script/InterruptEngineEvent.hpp> #include <com/sun/star/script/XLibraryAccess.hpp> +#include <com/sun/star/script/BasicErrorException.hpp> #include <com/sun/star/bridge/ModelDependent.hpp> #include "com/sun/star/bridge/oleautomation/NamedArgument.hpp" @@ -152,10 +153,10 @@ Any IUnknownWrapper_Impl::queryInterface(const Type& t) return Any(); if (t == getCppuType(static_cast<Reference<XDefaultProperty>*>( 0)) && !m_bHasDfltProperty ) return Any(); - if (t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) && !m_spDispatch) + if ( ( t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) || t == getCppuType(static_cast<Reference<XAutomationInvocation>*>( 0)) ) && !m_spDispatch) return Any(); - return WeakImplHelper6<XInvocation, XBridgeSupplier2, + return WeakImplHelper6<XAutomationInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>::queryInterface(t); } @@ -167,6 +168,61 @@ Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection( return ret; } +Any SAL_CALL IUnknownWrapper_Impl::invokeGetProperty( const OUString& aPropertyName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) +{ + Any aResult; + try + { + o2u_attachCurrentThread(); + ITypeInfo * pInfo = getTypeInfo(); + FuncDesc aDescGet(pInfo); + FuncDesc aDescPut(pInfo); + VarDesc aVarDesc(pInfo); + getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc); + if ( !aDescGet ) + { + OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName + + OUSTR("\" is not supported")); + throw UnknownPropertyException(msg, Reference<XInterface>()); + } + aResult = invokeWithDispIdComTlb( aDescGet, aPropertyName, aParams, aOutParamIndex, aOutParam ); + } + catch ( Exception& e ) + { + throw RuntimeException(OUSTR("[automation bridge] unexpected exception in " + "IUnknownWrapper_Impl::invokeGetProperty ! Message : \n") + + e.Message, Reference<XInterface>()); + } + return aResult; +} + +Any SAL_CALL IUnknownWrapper_Impl::invokePutProperty( const OUString& aPropertyName, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) +{ + Any aResult; + try + { + o2u_attachCurrentThread(); + ITypeInfo * pInfo = getTypeInfo(); + FuncDesc aDescGet(pInfo); + FuncDesc aDescPut(pInfo); + VarDesc aVarDesc(pInfo); + getPropDesc(aPropertyName, & aDescGet, & aDescPut, & aVarDesc); + if ( !aDescPut ) + { + OUString msg(OUSTR("[automation bridge]Property \"") + aPropertyName + + OUSTR("\" is not supported")); + throw UnknownPropertyException(msg, Reference<XInterface>()); + } + aResult = invokeWithDispIdComTlb( aDescPut, aPropertyName, aParams, aOutParamIndex, aOutParam ); + } + catch ( Exception& e ) + { + throw RuntimeException(OUSTR("[automation bridge] unexpected exception in " + "IUnknownWrapper_Impl::invokePutProperty ! Message : \n") + + e.Message, Reference<XInterface>()); + } + return aResult; +} Any SAL_CALL IUnknownWrapper_Impl::invoke( const OUString& aFunctionName, @@ -213,6 +269,10 @@ Any SAL_CALL IUnknownWrapper_Impl::invoke( const OUString& aFunctionName, { throw; } + catch (InvocationTargetException &) + { + throw; + } catch (BridgeRuntimeError & e) { throw RuntimeException(e.message, Reference<XInterface>()); @@ -658,12 +718,16 @@ sal_Bool SAL_CALL IUnknownWrapper_Impl::hasProperty( const OUString& aName ) FuncDesc aDescPut(pInfo); VarDesc aVarDesc(pInfo); getPropDesc(aName, & aDescGet, & aDescPut, & aVarDesc); - // Automation properties can have parameters. If so, we access them through - // XInvocation::invoke. Thas is, hasProperty must return false for such a - // property + + // we should probably just check the funckind + // basic has been modified to handle properties ( 'get' ) props at + // least with paramaters + // additionally you can call invoke(Get|Set)Property on the bridge + // you can determine if a property has parameter is hasMethod + // returns true for the name if (aVarDesc - || aDescPut && aDescPut->cParams == 0 - || aDescGet && aDescGet->cParams == 0) + || aDescPut + || aDescGet ) { ret = sal_True; } @@ -1392,6 +1456,19 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam) { + // Get type info for the call. It can be a method call or property put or + // property get operation. + FuncDesc aFuncDesc(getTypeInfo()); + getFuncDescForInvoke(sFuncName, Params, & aFuncDesc); + return invokeWithDispIdComTlb( aFuncDesc, sFuncName, Params, OutParamIndex, OutParam ); +} + +Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, + const OUString& sFuncName, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam) +{ Any ret; HRESULT result; @@ -1410,10 +1487,6 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, sal_Int32 revIndex = 0; bool bVarargParam = false; - // Get type info for the call. It can be a method call or property put or - // property get operation. - FuncDesc aFuncDesc(getTypeInfo()); - getFuncDescForInvoke(sFuncName, Params, & aFuncDesc); //Set the array of DISPIDs for named args if it is a property put operation. //If there are other named arguments another array is set later on. @@ -1832,11 +1905,24 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, "DISP_E_BADVARTYPE."), 0); break; case DISP_E_EXCEPTION: + { message = OUSTR("[automation bridge]: "); message += OUString(reinterpret_cast<const sal_Unicode*>(excepinfo.bstrDescription), ::SysStringLen(excepinfo.bstrDescription)); - throw InvocationTargetException(message, Reference<XInterface>(), Any()); + + // Add for VBA, to throw an exception with the correct error code and message. + sal_Int32 nErrorCode = excepinfo.wCode; + if ( nErrorCode == 0 ) + { + // The low 16-bit of scode describing the error or warning. + nErrorCode = ( excepinfo.scode & 0xFFFF ); + } + BasicErrorException aBasicErrExp(message, Reference<XInterface>(), nErrorCode, message); + throw InvocationTargetException(message, Reference<XInterface>(), makeAny(aBasicErrExp)); + // End add + break; + } case DISP_E_MEMBERNOTFOUND: message = OUSTR("[automation bridge]: A function with the name \"") + sFuncName + OUSTR("\" is not supported. Object returned " @@ -1969,11 +2055,17 @@ void IUnknownWrapper_Impl::getFuncDesc(const OUString & sFuncName, FUNCDESC ** p //get the associated index and add an entry to the map //with the name sFuncName which differs in the casing of the letters to //the actual name as obtained from ITypeInfo - cit itOrg = m_mapComFunc.find(OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName)))); + OUString sRealName(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(memberName))); + cit itOrg = m_mapComFunc.find(sRealName); OSL_ASSERT(itOrg != m_mapComFunc.end()); + // maybe this is a property, if so we need + // to store either both id's ( put/get ) or + // just the get. Storing both is more consistent + pair<cit, cit> pItems = m_mapComFunc.equal_range( sRealName ); + for ( ;pItems.first != pItems.second; ++pItems.first ) + m_mapComFunc.insert( TLBFuncIndexMap::value_type ( make_pair(sFuncName, pItems.first->second ) )); itIndex = - m_mapComFunc.insert( TLBFuncIndexMap::value_type - ( make_pair(sFuncName, itOrg->second ) )); + m_mapComFunc.find( sFuncName ); } } } @@ -2080,56 +2172,69 @@ void IUnknownWrapper_Impl::getPropDesc(const OUString & sFuncName, FUNCDESC ** p //else no entry for sFuncName, pFuncDesc will not be filled in } -VARTYPE IUnknownWrapper_Impl::getElementTypeDesc(const TYPEDESC *desc) +VARTYPE IUnknownWrapper_Impl::getUserDefinedElementType( ITypeInfo* pTypeInfo, const DWORD nHrefType ) { VARTYPE _type( VT_NULL ); - - if (desc->vt == VT_PTR) - { - _type = getElementTypeDesc(desc->lptdesc); - _type |= VT_BYREF; - } - else if (desc->vt == VT_SAFEARRAY) - { - _type = getElementTypeDesc(desc->lptdesc); - _type |= VT_ARRAY; - } - else if (desc->vt == VT_USERDEFINED) + if ( pTypeInfo ) { - ITypeInfo* thisInfo = getTypeInfo(); //kept by this instance - CComPtr<ITypeInfo> spRefInfo; - thisInfo->GetRefTypeInfo(desc->hreftype, & spRefInfo.p); - if (spRefInfo) + CComPtr<ITypeInfo> spRefInfo; + pTypeInfo->GetRefTypeInfo( nHrefType, &spRefInfo.p ); + if ( spRefInfo ) { - TypeAttr attr(spRefInfo); - spRefInfo->GetTypeAttr( & attr); - if (attr->typekind == TKIND_ENUM) + TypeAttr attr( spRefInfo ); + spRefInfo->GetTypeAttr( &attr ); + if ( attr->typekind == TKIND_ENUM ) { - //We use the type of the first enum value. - if (attr->cVars == 0) + // We use the type of the first enum value. + if ( attr->cVars == 0 ) { - throw BridgeRuntimeError(OUSTR("[automation bridge] Could " - "not obtain type description")); + throw BridgeRuntimeError(OUSTR("[automation bridge] Could not obtain type description")); } - VarDesc var(spRefInfo); - spRefInfo->GetVarDesc(0, & var); + VarDesc var( spRefInfo ); + spRefInfo->GetVarDesc( 0, &var ); _type = var->lpvarValue->vt; } - else if (attr->typekind == TKIND_INTERFACE) + else if ( attr->typekind == TKIND_INTERFACE ) { _type = VT_UNKNOWN; } - else if (attr->typekind == TKIND_DISPATCH) + else if ( attr->typekind == TKIND_DISPATCH ) { _type = VT_DISPATCH; } + else if ( attr->typekind == TKIND_ALIAS ) + { + // TKIND_ALIAS is a type that is an alias for another type. So get that alias type. + _type = getUserDefinedElementType( pTypeInfo, attr->tdescAlias.hreftype ); + } else { - throw BridgeRuntimeError(OUSTR("[automation bridge] " - "Unhandled user defined type.")); + throw BridgeRuntimeError( OUSTR("[automation bridge] Unhandled user defined type.") ); } } } + return _type; +} + +VARTYPE IUnknownWrapper_Impl::getElementTypeDesc(const TYPEDESC *desc) +{ + VARTYPE _type( VT_NULL ); + + if (desc->vt == VT_PTR) + { + _type = getElementTypeDesc(desc->lptdesc); + _type |= VT_BYREF; + } + else if (desc->vt == VT_SAFEARRAY) + { + _type = getElementTypeDesc(desc->lptdesc); + _type |= VT_ARRAY; + } + else if (desc->vt == VT_USERDEFINED) + { + ITypeInfo* thisInfo = getTypeInfo(); //kept by this instance + _type = getUserDefinedElementType( thisInfo, desc->hreftype ); + } else { _type = desc->vt; diff --git a/extensions/source/ole/oleobjw.hxx b/extensions/source/ole/oleobjw.hxx index b990ac3af17d..3c184472c20f 100644 --- a/extensions/source/ole/oleobjw.hxx +++ b/extensions/source/ole/oleobjw.hxx @@ -54,6 +54,7 @@ #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp> +#include <com/sun/star/script//XAutomationInvocation.hpp> #include <rtl/ustring.hxx> #include <com/sun/star/script/XDefaultProperty.hpp> @@ -81,7 +82,7 @@ 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 WeakImplHelper6<XInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>, +class IUnknownWrapper_Impl : public WeakImplHelper6<XAutomationInvocation, XBridgeSupplier2, XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>, public UnoConversionUtilities<IUnknownWrapper_Impl> @@ -134,6 +135,9 @@ public: protected: virtual ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; } + virtual ::com::sun::star::uno::Any SAL_CALL invokeGetProperty( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL invokePutProperty( const ::rtl::OUString& aFunctionName, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< ::sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException); + // ---------------------------------------------------------------------------- virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName, const Sequence< Any >& Params, @@ -145,6 +149,12 @@ protected: Sequence< sal_Int16 >& OutParamIndex, Sequence< Any >& OutParam); + Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(FuncDesc& aFuncDesc, + const OUString& sFuncName, + const Sequence< Any >& Params, + Sequence< sal_Int16 >& OutParamIndex, + Sequence< Any >& OutParam); + // virtual void setValueWithDispId(DISPID dispID, const Any& Value); // virtual Any getValueWithDispId(const OUString& sName, DISPID dispID); @@ -188,8 +198,11 @@ protected: /** Returns the DISPID for a function or property name. If true is returned then id contains a valid DISPID. */ + bool getDispid(const OUString& sFuncName, DISPID * id); + VARTYPE getUserDefinedElementType( ITypeInfo* pTypeInfo, const DWORD nHrefType ); + /** Gets the element type in a VARIANT like style. E.g. if desc->lptdesc contains a VT_PTR than it is replaced by VT_BYREF and VT_SAFEARRAY is replaced by VT_ARRAY If the TYPEDESC describes an SAFEARRAY then varType is a combination of VT_ARRAY diff --git a/extensions/source/propctrlr/defaultforminspection.cxx b/extensions/source/propctrlr/defaultforminspection.cxx index f477c4deaa1e..2fffb43951ce 100644 --- a/extensions/source/propctrlr/defaultforminspection.cxx +++ b/extensions/source/propctrlr/defaultforminspection.cxx @@ -149,7 +149,7 @@ namespace pcr { "com.sun.star.form.inspection.EventHandler", false }, // a handler which introduces virtual properties for binding controls to spreadsheet cells - { "com.sun.star.form.inspection.CellBindingPropertyHandler", true }, + { "com.sun.star.form.inspection.CellBindingPropertyHandler", false }, // properties related to binding to an XForms DOM node { "com.sun.star.form.inspection.XMLFormsPropertyHandler", true }, diff --git a/extensions/source/propctrlr/formmetadata.cxx b/extensions/source/propctrlr/formmetadata.cxx index 9d8becfbd923..0e63f360f9a0 100644 --- a/extensions/source/propctrlr/formmetadata.cxx +++ b/extensions/source/propctrlr/formmetadata.cxx @@ -138,6 +138,7 @@ namespace pcr DEF_INFO_3( LABEL, LABEL, LABEL, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_2( CONTROLLABEL, LABELCONTROL, CONTROLLABEL, FORM_VISIBLE, COMPOSEABLE ), DEF_INFO_3( WRITING_MODE, WRITING_MODE, WRITING_MODE, FORM_VISIBLE, ENUM, COMPOSEABLE ), + DEF_INFO_3( GROUP_NAME, GROUP_NAME, GROUP_NAME, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_2( TEXT, TEXT, TEXT, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_3( MAXTEXTLEN, MAXTEXTLEN, MAXTEXTLEN, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), DEF_INFO_3( EDITMASK, EDITMASK, EDITMASK, FORM_VISIBLE, DIALOG_VISIBLE, COMPOSEABLE ), diff --git a/extensions/source/propctrlr/formmetadata.hxx b/extensions/source/propctrlr/formmetadata.hxx index 294a43e4a9e7..3eb7f0e29d56 100644 --- a/extensions/source/propctrlr/formmetadata.hxx +++ b/extensions/source/propctrlr/formmetadata.hxx @@ -163,6 +163,7 @@ namespace pcr #define PROPERTY_ID_ALLOWADDITIONS 20 #define PROPERTY_ID_ALLOWEDITS 21 #define PROPERTY_ID_ALLOWDELETIONS 22 + #define PROPERTY_ID_GROUP_NAME 23 #define PROPERTY_ID_NAVIGATION 24 #define PROPERTY_ID_CYCLE 25 #define PROPERTY_ID_HIDDEN_VALUE 26 diff --git a/extensions/source/propctrlr/formres.src b/extensions/source/propctrlr/formres.src index 1daadd6e0f01..a1ac9fe2c0c4 100644 --- a/extensions/source/propctrlr/formres.src +++ b/extensions/source/propctrlr/formres.src @@ -231,6 +231,10 @@ String RID_STR_NAME { Text [ en-US ] = "Name" ; }; +String RID_STR_GROUP_NAME +{ + Text [ en-US ] = "Group name" ; +}; String RID_STR_TABINDEX { Text [ en-US ] = "Tab order" ; diff --git a/extensions/source/propctrlr/formresid.hrc b/extensions/source/propctrlr/formresid.hrc index f2de0c252d8b..0aeab5306da9 100644 --- a/extensions/source/propctrlr/formresid.hrc +++ b/extensions/source/propctrlr/formresid.hrc @@ -149,6 +149,7 @@ #define RID_STR_CURSOR_TYPE ( RID_FORMBROWSER_START + 121 ) #define RID_STR_ENABLE_VISIBLE ( RID_FORMBROWSER_START + 122 ) #define RID_STR_WHEEL_BEHAVIOR ( RID_FORMBROWSER_START + 123 ) +#define RID_STR_GROUP_NAME ( RID_FORMBROWSER_START + 124 ) // FREE // FREE // FREE diff --git a/extensions/source/propctrlr/formstrings.hxx b/extensions/source/propctrlr/formstrings.hxx index 20b0dd34b2cd..aed09d4fcbf0 100644 --- a/extensions/source/propctrlr/formstrings.hxx +++ b/extensions/source/propctrlr/formstrings.hxx @@ -48,6 +48,7 @@ namespace pcr PCR_CONSTASCII_STRING( PROPERTY_WHEEL_BEHAVIOR, "MouseWheelBehavior"); PCR_CONSTASCII_STRING( PROPERTY_TAG, "Tag"); PCR_CONSTASCII_STRING( PROPERTY_NAME, "Name"); + PCR_CONSTASCII_STRING( PROPERTY_GROUP_NAME, "GroupName"); PCR_CONSTASCII_STRING( PROPERTY_VALUE, "Value"); PCR_CONSTASCII_STRING( PROPERTY_TEXT, "Text"); PCR_CONSTASCII_STRING( PROPERTY_NAVIGATION, "NavigationBarMode"); |