Kaydet (Commit) dc1a7187 authored tarafından Ivo Hinkelmann's avatar Ivo Hinkelmann

CWS-TOOLING: integrate CWS mib17

...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#include <tools/diagnose_ex.h> #include <tools/diagnose_ex.h>
#include <sfx2/sfxdefs.hxx> #include <sfx2/sfxdefs.hxx>
#include <sfx2/signaturestate.hxx> #include <sfx2/signaturestate.hxx>
#include <com/sun/star/script/XVBAModuleInfo.hpp>
#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
......
...@@ -52,9 +52,8 @@ ...@@ -52,9 +52,8 @@
#include <comphelper/componentcontext.hxx> #include <comphelper/componentcontext.hxx>
#include <map> #include <map>
#include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/ModuleType.hpp>
#include <com/sun/star/script/XVBAModuleInfo.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
#include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/script/XVBAModuleInfo.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/container/XNamed.hpp> #include <com/sun/star/container/XNamed.hpp>
...@@ -65,7 +64,7 @@ void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameCont ...@@ -65,7 +64,7 @@ void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameCont
{ {
try try
{ {
uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) )
{ {
script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName );
...@@ -86,8 +85,8 @@ void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameCont ...@@ -86,8 +85,8 @@ void ModuleInfoHelper::getObjectName( const uno::Reference< container::XNameCont
sal_Int32 ModuleInfoHelper::getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName ) sal_Int32 ModuleInfoHelper::getModuleType( const uno::Reference< container::XNameContainer >& rLib, const String& rModName )
{ {
sal_Int32 nType = com::sun::star::script::ModuleType::NORMAL; sal_Int32 nType = script::ModuleType::NORMAL;
uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY ); uno::Reference< script::vba::XVBAModuleInfo > xVBAModuleInfo( rLib, uno::UNO_QUERY );
if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) ) if ( xVBAModuleInfo.is() && xVBAModuleInfo->hasModuleInfo( rModName ) )
{ {
script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName ); script::ModuleInfo aModuleInfo = xVBAModuleInfo->getModuleInfo( rModName );
......
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
#include <com/sun/star/frame/XModel2.hpp> #include <com/sun/star/frame/XModel2.hpp>
#include <com/sun/star/awt/XWindow2.hpp> #include <com/sun/star/awt/XWindow2.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp> #include <com/sun/star/document/XEmbeddedScripts.hpp>
#include <com/sun/star/script/XVBAModuleInfo.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp>
#include <com/sun/star/script/XVBACompat.hpp> #include <com/sun/star/script/vba/XVBAModuleInfo.hpp>
/** === end UNO includes === **/ /** === end UNO includes === **/
#include <sfx2/objsh.hxx> #include <sfx2/objsh.hxx>
...@@ -142,8 +142,8 @@ namespace basctl ...@@ -142,8 +142,8 @@ namespace basctl
using ::com::sun::star::document::XEventBroadcaster; using ::com::sun::star::document::XEventBroadcaster;
using ::com::sun::star::document::XEmbeddedScripts; using ::com::sun::star::document::XEmbeddedScripts;
using ::com::sun::star::script::ModuleInfo; using ::com::sun::star::script::ModuleInfo;
using ::com::sun::star::script::XVBAModuleInfo; using ::com::sun::star::script::vba::XVBACompatibility;
using ::com::sun::star::script::XVBACompat; using ::com::sun::star::script::vba::XVBAModuleInfo;
/** === end UNO using === **/ /** === end UNO using === **/
namespace MacroExecMode = ::com::sun::star::document::MacroExecMode; namespace MacroExecMode = ::com::sun::star::document::MacroExecMode;
namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag; namespace FrameSearchFlag = ::com::sun::star::frame::FrameSearchFlag;
...@@ -456,9 +456,9 @@ namespace basctl ...@@ -456,9 +456,9 @@ namespace basctl
#ifdef FUTURE_VBA_CWS #ifdef FUTURE_VBA_CWS
if ( !isApplication() ) if ( !isApplication() )
{ {
Reference< XVBACompat > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY ); Reference< XVBACompatibility > xVBACompat( getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
if ( xVBACompat.is() ) if ( xVBACompat.is() )
bResult = xVBACompat->getVBACompatModeOn(); bResult = xVBACompat->getVBACompatibilityMode();
} }
#endif #endif
return bResult; return bResult;
......
...@@ -69,6 +69,7 @@ using namespace boost; ...@@ -69,6 +69,7 @@ using namespace boost;
using namespace osl; using namespace osl;
using namespace rtl; using namespace rtl;
using namespace cppu; using namespace cppu;
using namespace com::sun::star::script;
using namespace com::sun::star::lang; using namespace com::sun::star::lang;
using namespace com::sun::star::bridge; using namespace com::sun::star::bridge;
using namespace com::sun::star::bridge::oleautomation; using namespace com::sun::star::bridge::oleautomation;
...@@ -108,7 +109,7 @@ IUnknownWrapper_Impl::IUnknownWrapper_Impl( Reference<XMultiServiceFactory>& xFa ...@@ -108,7 +109,7 @@ IUnknownWrapper_Impl::IUnknownWrapper_Impl( Reference<XMultiServiceFactory>& xFa
sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass): sal_uInt8 unoWrapperClass, sal_uInt8 comWrapperClass):
UnoConversionUtilities<IUnknownWrapper_Impl>( xFactory, unoWrapperClass, comWrapperClass), UnoConversionUtilities<IUnknownWrapper_Impl>( xFactory, unoWrapperClass, comWrapperClass),
m_pxIdlClass( NULL), m_eJScript( JScriptUndefined), 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() ...@@ -147,17 +148,15 @@ IUnknownWrapper_Impl::~IUnknownWrapper_Impl()
Any IUnknownWrapper_Impl::queryInterface(const Type& t) Any IUnknownWrapper_Impl::queryInterface(const Type& t)
throw (RuntimeException) throw (RuntimeException)
{ {
if (t == getCppuType(static_cast<Reference<XInvocation>*>( 0))) if (t == getCppuType(static_cast<Reference<XDefaultMethod>*>( 0)) && !m_bHasDfltMethod )
{ return Any();
if (m_spDispatch) if (t == getCppuType(static_cast<Reference<XDefaultProperty>*>( 0)) && !m_bHasDfltProperty )
return WeakImplHelper4<XInvocation, XBridgeSupplier2, return Any();
XInitialization, XAutomationObject>::queryInterface(t); if (t == getCppuType(static_cast<Reference<XInvocation>*>( 0)) && !m_spDispatch)
else return Any();
return Any();
} return WeakImplHelper6<XInvocation, XBridgeSupplier2,
XInitialization, XAutomationObject, XDefaultProperty, XDefaultMethod>::queryInterface(t);
return WeakImplHelper4<XInvocation, XBridgeSupplier2,
XInitialization, XAutomationObject>::queryInterface(t);
} }
Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection(void) Reference<XIntrospectionAccess> SAL_CALL IUnknownWrapper_Impl::getIntrospection(void)
...@@ -1194,6 +1193,68 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument ...@@ -1194,6 +1193,68 @@ void SAL_CALL IUnknownWrapper_Impl::initialize( const Sequence< Any >& aArgument
aArguments[1] >>= m_bOriginalDispatch; aArguments[1] >>= m_bOriginalDispatch;
aArguments[2] >>= m_seqTypes; 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 -------------------------------------------------------------------------------- // UnoConversionUtilities --------------------------------------------------------------------------------
...@@ -1445,6 +1506,9 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName, ...@@ -1445,6 +1506,9 @@ Any IUnknownWrapper_Impl::invokeWithDispIdComTlb(const OUString& sFuncName,
arDispidNamedArgs.reset(new DISPID[nSizeAr]); arDispidNamedArgs.reset(new DISPID[nSizeAr]);
HRESULT hr = getTypeInfo()->GetIDsOfNames(arNames, nSizeAr, HRESULT hr = getTypeInfo()->GetIDsOfNames(arNames, nSizeAr,
arDispidNamedArgs.get()); arDispidNamedArgs.get());
if ( hr == E_NOTIMPL )
hr = m_spDispatch->GetIDsOfNames(IID_NULL, arNames, nSizeAr, LOCALE_USER_DEFAULT, arDispidNamedArgs.get() );
if (hr == S_OK) if (hr == S_OK)
{ {
// In a "property put" operation, the property value is a named param with the // In a "property put" operation, the property value is a named param with the
......
...@@ -50,11 +50,14 @@ ...@@ -50,11 +50,14 @@
#endif #endif
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase6.hxx>
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp> #include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <com/sun/star/script/XDefaultProperty.hpp>
#include <com/sun/star/script/XDefaultMethod.hpp>
#include <typelib/typedescription.hxx> #include <typelib/typedescription.hxx>
#include "unoconversionutilities.hxx" #include "unoconversionutilities.hxx"
...@@ -78,7 +81,8 @@ typedef hash_multimap<OUString, unsigned int, hashOUString_Impl, equalOUString_I ...@@ -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. // 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. // 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. // 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> public UnoConversionUtilities<IUnknownWrapper_Impl>
{ {
...@@ -126,7 +130,9 @@ public: ...@@ -126,7 +130,9 @@ public:
// XInitialization // XInitialization
virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) virtual void SAL_CALL initialize( const Sequence< Any >& aArguments )
throw(Exception, RuntimeException); throw(Exception, RuntimeException);
virtual ::rtl::OUString SAL_CALL getDefaultPropertyName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; }
protected: protected:
virtual ::rtl::OUString SAL_CALL getDefaultMethodName( ) throw (::com::sun::star::uno::RuntimeException) { return m_sDefaultMember; }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName, virtual Any invokeWithDispIdUnoTlb(const OUString& sFunctionName,
...@@ -253,6 +259,9 @@ protected: ...@@ -253,6 +259,9 @@ protected:
bool m_bComTlbIndexInit; bool m_bComTlbIndexInit;
// Keeps the ITypeInfo obtained from IDispatch::GetTypeInfo // Keeps the ITypeInfo obtained from IDispatch::GetTypeInfo
CComPtr< ITypeInfo > m_spTypeInfo; CComPtr< ITypeInfo > m_spTypeInfo;
rtl::OUString m_sDefaultMember;
bool m_bHasDfltMethod;
bool m_bHasDfltProperty;
}; };
} // end namespace } // end namespace
......
...@@ -1324,33 +1324,47 @@ SAFEARRAY* UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq) ...@@ -1324,33 +1324,47 @@ SAFEARRAY* UnoConversionUtilities<T>::createUnoSequenceWrapper(const Any& rSeq)
typelib_TypeDescription* pSeqElementDesc= NULL; typelib_TypeDescription* pSeqElementDesc= NULL;
TYPELIB_DANGER_GET( &pSeqElementDesc, pSeqElementTypeRef); TYPELIB_DANGER_GET( &pSeqElementDesc, pSeqElementTypeRef);
sal_Int32 nElementSize= pSeqElementDesc->nSize;
n= punoSeq->nElements;
SAFEARRAYBOUND rgsabound[1]; // try to find VARIANT type that is related to the UNO type of the sequence elements
rgsabound[0].lLbound = 0; // the sequence as a sequence element should be handled in a special way
rgsabound[0].cElements = n; VARTYPE eTargetElementType = VT_EMPTY;
VARIANT oleElement; if ( pSeqElementDesc->eTypeClass != TypeClass_SEQUENCE )
long safeI[1]; eTargetElementType = mapTypeClassToVartype( static_cast< TypeClass >( pSeqElementDesc->eTypeClass ) );
pArray = SafeArrayCreate(VT_VARIANT, 1, rgsabound); if ( eTargetElementType != VT_EMPTY )
pArray = createUnoSequenceWrapper( rSeq, eTargetElementType );
Any unoElement; if ( !pArray )
// 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); sal_Int32 nElementSize= pSeqElementDesc->nSize;
VariantInit(&oleElement); 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; safeI[0] = i;
SafeArrayPutElement(pArray, safeI, &oleElement); SafeArrayPutElement(pArray, safeI, &oleElement);
VariantClear(&oleElement); VariantClear(&oleElement);
}
} }
TYPELIB_DANGER_RELEASE( pSeqElementDesc); TYPELIB_DANGER_RELEASE( pSeqElementDesc);
return pArray; return pArray;
......
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