diff options
25 files changed, 227 insertions, 120 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 86850d9991c6..094568e7f0b2 100644..100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -54,6 +54,7 @@ #include "sb.hrc" #include <basrid.hxx> #include <vos/mutex.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> // #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE ) @@ -63,11 +64,34 @@ TYPEINIT1(StarBASIC,SbxObject) #define RTLNAME "@SBRTL" // i#i68894# +using com::sun::star::uno::Reference; +using com::sun::star::uno::Any; +using com::sun::star::uno::UNO_QUERY; +using com::sun::star::lang::XMultiServiceFactory; SbxObject* StarBASIC::getVBAGlobals( ) { if ( !pVBAGlobals ) - pVBAGlobals = (SbUnoObject*)Find( String(RTL_CONSTASCII_USTRINGPARAM("VBAGlobals")), SbxCLASS_DONTCARE ); +// pVBAGlobals = (SbUnoObject*)Find( String(RTL_CONSTASCII_USTRINGPARAM("VBAGlobals")), SbxCLASS_DONTCARE ); + { + Any aThisDoc; + if ( GetUNOConstant("ThisComponent", aThisDoc) ) + { + Reference< XMultiServiceFactory > xDocFac( aThisDoc, UNO_QUERY ); + if ( xDocFac.is() ) + { + try + { + xDocFac->createInstance( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); + } + catch( Exception& ) + { + // Ignore + } + } + } + pVBAGlobals = (SbUnoObject*)Find( aVBAHook , SbxCLASS_DONTCARE ); + } return pVBAGlobals; } diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 0e8928bc6c1a..1c95b4f30de6 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -139,16 +139,19 @@ bool SbUnoObject::getDefaultPropName( SbUnoObject* pUnoObj, String& sDfltProp ) SbxVariable* getDefaultProp( SbxVariable* pRef ) { SbxVariable* pDefaultProp = NULL; - SbxObject* pObj = PTR_CAST(SbxObject,(SbxVariable*) pRef); - if ( !pObj ) + if ( pRef->GetType() == SbxOBJECT ) { - SbxBase* pObjVarObj = pRef->GetObject(); - pObj = PTR_CAST(SbxObject,pObjVarObj); - } - if ( pObj && pObj->ISA(SbUnoObject) ) - { - SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*)pObj); - pDefaultProp = pUnoObj->GetDfltProperty(); + SbxObject* pObj = PTR_CAST(SbxObject,(SbxVariable*) pRef); + if ( !pObj ) + { + SbxBase* pObjVarObj = pRef->GetObject(); + pObj = PTR_CAST(SbxObject,pObjVarObj); + } + if ( pObj && pObj->ISA(SbUnoObject) ) + { + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*)pObj); + pDefaultProp = pUnoObj->GetDfltProperty(); + } } return pDefaultProp; } @@ -1601,6 +1604,23 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, break; } ::rtl::OUString sClassName = xClass->getName(); + if ( sClassName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.oleautomation.XAutomationObject" ) ) ) ) + { + // there is a hack in the extensions/source/ole/oleobj.cxx to return the typename of the automation object, lets check if it + // matches + Reference< XInvocation > xInv( aToInspectObj, UNO_QUERY ); + if ( xInv.is() ) + { + rtl::OUString sTypeName; + xInv->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$GetTypeName") ) ) >>= sTypeName; + if ( sTypeName.getLength() == 0 || sTypeName.equals( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IDispatch") ) ) ) + // can't check type, leave it pass + result = true; + else + result = sTypeName.equals( aClass ); + } + break; // finished checking automation object + } OSL_TRACE("Checking if object implements %s", OUStringToOString( defaultNameSpace + aClass, RTL_TEXTENCODING_UTF8 ).getStr() ); diff --git a/oovbaapi/genconstidl/makefile.mk b/oovbaapi/genconstidl/makefile.mk index be9fc931f30a..078f4d09049e 100644 --- a/oovbaapi/genconstidl/makefile.mk +++ b/oovbaapi/genconstidl/makefile.mk @@ -34,11 +34,6 @@ PRJNAME=oovbaapi .IF "$(L10N_framework)"=="" -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - # symbol files of Microsoft API MYSYMFILES = access.api vba.api adodb.api msforms.api word.api dao.api powerpoint.api excel.api stdole.api diff --git a/oovbaapi/ooo/vba/constants/makefile.mk b/oovbaapi/ooo/vba/constants/makefile.mk index a41f6e98a2ba..a731574363be 100644 --- a/oovbaapi/ooo/vba/constants/makefile.mk +++ b/oovbaapi/ooo/vba/constants/makefile.mk @@ -35,11 +35,6 @@ PACKAGE=org$/vba$/constants .INCLUDE : $(PRJ)$/util$/makefile.pmk -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ELSE - .IF "$(L10N_framework)"=="" # ------------------------------------------------------------------------ # I tried to use the IDLFILES target but it failed dismally @@ -64,4 +59,3 @@ $(MYDBTARGET) : $(MYURDFILES) $(MYIDLFILES) $(REGMERGE) $(OUT)$/ucr/constants.db /UCR @$(mktmp $(MYURDFILES)) .ENDIF -.ENDIF diff --git a/oovbaapi/ooo/vba/excel/makefile.mk b/oovbaapi/ooo/vba/excel/makefile.mk index c31531af8349..01e26d4cb19b 100644 --- a/oovbaapi/ooo/vba/excel/makefile.mk +++ b/oovbaapi/ooo/vba/excel/makefile.mk @@ -34,11 +34,6 @@ PACKAGE=ooo$/vba$/Excel # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - # ------------------------------------------------------------------------ diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index e79d3481169c..7fc70303d942 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -34,11 +34,6 @@ PACKAGE=ooo$/vba # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ELSE - # ------------------------------------------------------------------------ .IF "$(L10N_framework)"="" IDLFILES=\ @@ -71,4 +66,3 @@ IDLFILES=\ # ------------------------------------------------------------------ .ENDIF .INCLUDE : target.mk -.ENDIF diff --git a/oovbaapi/ooo/vba/msforms/makefile.mk b/oovbaapi/ooo/vba/msforms/makefile.mk index 61d2675af7fc..56ac4caf87cb 100644 --- a/oovbaapi/ooo/vba/msforms/makefile.mk +++ b/oovbaapi/ooo/vba/msforms/makefile.mk @@ -34,11 +34,6 @@ PACKAGE=ooo$/vba$/msforms # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - # ------------------------------------------------------------------------ IDLFILES=\ diff --git a/oovbaapi/util/makefile.mk b/oovbaapi/util/makefile.mk index 9c33577abfa9..5100327b4b7d 100644 --- a/oovbaapi/util/makefile.mk +++ b/oovbaapi/util/makefile.mk @@ -36,11 +36,6 @@ TARGET=oovbaapi_db .INCLUDE : makefile.pmk -.IF "$(ENABLE_VBA)"!="YES" -dummy: - @echo "not building vba..." -.ENDIF - .IF "$(L10N_framework)"=="" # ------------------------------------------------------------------ UNOIDLDBFILES= \ diff --git a/scripting/prj/build.lst b/scripting/prj/build.lst index fc332384e047..7d5162173eae 100644..100755 --- a/scripting/prj/build.lst +++ b/scripting/prj/build.lst @@ -1,4 +1,4 @@ -tc scripting : oovbaapi bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL +tc scripting : oovbaapi vbahelper bridges rdbmaker vcl xmlscript basic sfx2 rhino BSH:beanshell javaunohelper NULL tc scripting usr1 - all tc1_mkout NULL tc scripting\inc nmake - all tc1_inc NULL tc scripting\source\provider nmake - all tc1_scriptingprovider tc1_inc NULL diff --git a/scripting/source/dlgprov/dlgevtatt.cxx b/scripting/source/dlgprov/dlgevtatt.cxx index fedbce79b218..6c3694ea237d 100644 --- a/scripting/source/dlgprov/dlgevtatt.cxx +++ b/scripting/source/dlgprov/dlgevtatt.cxx @@ -50,9 +50,9 @@ #include <com/sun/star/beans/MethodConcept.hpp> #include <com/sun/star/beans/XMaterialHolder.hpp> -#ifdef FAKE_VBA_EVENT_SUPPORT #include <ooo/vba/XVBAToOOEventDescGen.hpp> -#endif +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <vbahelper/vbaaccesshelper.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::awt; @@ -104,7 +104,6 @@ namespace dlgprov }; -#ifdef FAKE_VBA_EVENT_SUPPORT class DialogVBAScriptListenerImpl : public DialogScriptListenerImpl { protected: @@ -157,7 +156,6 @@ namespace dlgprov } } } -#endif //......................................................................... @@ -166,7 +164,7 @@ namespace dlgprov // ============================================================================= DialogEventsAttacherImpl::DialogEventsAttacherImpl( const Reference< XComponentContext >& rxContext, const Reference< frame::XModel >& rxModel, const Reference< awt::XControl >& rxControl, const Reference< XInterface >& rxHandler, const Reference< beans::XIntrospectionAccess >& rxIntrospect, bool bProviderMode, const Reference< script::XScriptListener >& rxRTLListener ) - :m_xContext( rxContext ) + :mbUseFakeVBAEvents( false ), m_xContext( rxContext ) { // key listeners by protocol when ScriptType = 'Script' // otherwise key is the ScriptType e.g. StarBasic @@ -177,9 +175,22 @@ namespace dlgprov // handler for Script & ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" ) listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.UNO") ] = new DialogUnoScriptListenerImpl( rxContext, rxModel, rxControl, rxHandler, rxIntrospect, bProviderMode ); listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.script") ] = new DialogSFScriptListenerImpl( rxContext, rxModel ); -#ifdef FAKE_VBA_EVENT_SUPPORT - listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel ); -#endif + // Note: in a future cws ( npower13_ObjectModule ) it will be possible + // to determine the vba mode from the basiclibrary container, the tunnel hack + // below can then be replaced + SfxObjectShell* pFoundShell = NULL; + if ( rxModel.is() ) + { + uno::Reference< lang::XUnoTunnel > xObjShellTunnel( rxModel, uno::UNO_QUERY ); + if ( xObjShellTunnel.is() ) + { + pFoundShell = reinterpret_cast<SfxObjectShell*>( xObjShellTunnel->getSomething(SfxObjectShell::getUnoTunnelId())); + if ( pFoundShell ) + mbUseFakeVBAEvents = ooo::vba::isAlienExcelDoc( *pFoundShell ); + } + } + if ( mbUseFakeVBAEvents ) + listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel ); } // ----------------------------------------------------------------------------- @@ -197,7 +208,6 @@ namespace dlgprov throw RuntimeException(); // more text info here please return it->second; } -#ifdef FAKE_VBA_EVENT_SUPPORT Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl, rtl::OUString& sControlName ) { Reference< XScriptEventsSupplier > xEventsSupplier; @@ -210,7 +220,6 @@ namespace dlgprov } return xEventsSupplier; } -#endif // ----------------------------------------------------------------------------- void SAL_CALL DialogEventsAttacherImpl::attachEventsToControl( const Reference< XControl>& xControl, const Reference< XScriptEventsSupplier >& xEventsSupplier, const Any& Helper ) @@ -312,7 +321,6 @@ namespace dlgprov // go over all objects const Reference< XInterface >* pObjects = Objects.getConstArray(); sal_Int32 nObjCount = Objects.getLength(); -#ifdef FAKE_VBA_EVENT_SUPPORT Reference< awt::XControl > xDlgControl( Objects[ nObjCount - 1 ], uno::UNO_QUERY ); // last object is the dialog rtl::OUString sDialogCodeName; if ( xDlgControl.is() ) @@ -324,7 +332,6 @@ namespace dlgprov } catch( Exception& ){} } -#endif for ( sal_Int32 i = 0; i < nObjCount; ++i ) { @@ -339,10 +346,11 @@ namespace dlgprov Reference< XControlModel > xControlModel = xControl->getModel(); Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY ); attachEventsToControl( xControl, xEventsSupplier, Helper ); -#ifdef FAKE_VBA_EVENT_SUPPORT - xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); - attachEventsToControl( xControl, xEventsSupplier, Helper ); -#endif + if ( mbUseFakeVBAEvents ) + { + xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) ); + attachEventsToControl( xControl, xEventsSupplier, Helper ); + } } } diff --git a/scripting/source/dlgprov/dlgevtatt.hxx b/scripting/source/dlgprov/dlgevtatt.hxx index 4b9028718a55..85b0bfcd087d 100644 --- a/scripting/source/dlgprov/dlgevtatt.hxx +++ b/scripting/source/dlgprov/dlgevtatt.hxx @@ -44,8 +44,6 @@ #include <hash_map> -#define FAKE_VBA_EVENT_SUPPORT 1 - //......................................................................... namespace dlgprov { @@ -66,13 +64,12 @@ namespace dlgprov class DialogEventsAttacherImpl : public DialogEventsAttacherImpl_BASE { private: + bool mbUseFakeVBAEvents; ListenerHash listernersForTypes; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacher > m_xEventAttacher; ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptListener > getScriptListenerForKey( const rtl::OUString& sScriptName ) throw ( ::com::sun::star::uno::RuntimeException ); -#ifdef FAKE_VBA_EVENT_SUPPORT ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier > getFakeVbaEventsSupplier( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, rtl::OUString& sCodeName ); -#endif void SAL_CALL attachEventsToControl( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& xControl, const ::com::sun::star::uno::Reference< ::com::sun::star::script::XScriptEventsSupplier >& events, const ::com::sun::star::uno::Any& Helper ); public: DialogEventsAttacherImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext, diff --git a/scripting/source/dlgprov/makefile.mk b/scripting/source/dlgprov/makefile.mk index 455423412784..6c8ec298c760 100644 --- a/scripting/source/dlgprov/makefile.mk +++ b/scripting/source/dlgprov/makefile.mk @@ -59,6 +59,7 @@ SHL1STDLIBS= \ $(COMPHELPERLIB) \ $(UCBHELPERLIB) \ $(CPPULIB) \ + $(BASICLIB) \ $(SALLIB) SHL1DEPN= diff --git a/scripting/source/vbaevents/eventhelper.cxx b/scripting/source/vbaevents/eventhelper.cxx index 7e4626e31c00..838d89d49c89 100755..100644 --- a/scripting/source/vbaevents/eventhelper.cxx +++ b/scripting/source/vbaevents/eventhelper.cxx @@ -349,8 +349,8 @@ static TranslatePropMap aTranslatePropMap_Impl[] = { MAP_CHAR_LEN("mouseDragged"), { MAP_CHAR_LEN("_MouseMove"), ooMouseEvtToVBAMouseEvt, DenyMouseDrag, NULL } }, //liuchen, add to support VBA MouseMove event when the "Shift" key is pressed // keyPressed ooo event - { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyDown"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } }, - { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyUpDown, ApproveAll, NULL } } + { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyDown"), ooKeyPressedToVBAKeyPressed, ApproveAll, NULL } }, + { MAP_CHAR_LEN("keyPressed"), { MAP_CHAR_LEN("_KeyPress"), ooKeyPressedToVBAKeyPressed, ApproveAll, NULL } } }; EventInfoHash& getEventTransInfo() @@ -929,9 +929,12 @@ EventListener::firing_Impl(const ScriptEvent& evt, Any* /*pRet*/ ) throw(Runtime Sequence< Any > aOutArgs; try { - uno::Reference< script::provider::XScript > xScript = xScriptProvider->getScript( url ); - if ( xScript.is() ) - xScript->invoke( aArguments, aOutArgsIndex, aOutArgs ); + if ( mpShell ) + { + uno::Any aRet; + mpShell->CallXScript( url, + aArguments, aRet, aOutArgsIndex, aOutArgs, false ); + } } catch ( uno::Exception& e ) { diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 5fc5a641fd44..d514235cbfa2 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -398,7 +398,8 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Any& aRet, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam, + bool bRaiseError = true ); static ErrCode CallXScript( @@ -407,7 +408,8 @@ public: const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Any& aRet, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam, + bool bRaiseError = true ); /** adjusts the internal macro mode, according to the current security settings diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index 7d931cb6c640..628c3b020c08 100644..100755 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1681,7 +1681,7 @@ namespace } ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptContext, const ::rtl::OUString& _rScriptURL, - const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) + const Sequence< Any >& aParams, Any& aRet, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam, bool bRaiseError ) { OSL_TRACE( "in CallXScript" ); ErrCode nErr = ERRCODE_NONE; @@ -1722,7 +1722,7 @@ ErrCode SfxObjectShell::CallXScript( const Reference< XInterface >& _rxScriptCon nErr = ERRCODE_BASIC_INTERNAL_ERROR; } - if ( bCaughtException ) + if ( bCaughtException && bRaiseError ) { ::std::auto_ptr< VclAbstractDialog > pScriptErrDlg; SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); @@ -1745,10 +1745,10 @@ ErrCode SfxObjectShell::CallXScript( const String& rScriptURL, aParams, ::com::sun::star::uno::Any& aRet, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, - ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& - aOutParam) + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam + , bool bRaiseError ) { - return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam ); + return CallXScript( GetModel(), rScriptURL, aParams, aRet, aOutParamIndex, aOutParam, bRaiseError ); } //------------------------------------------------------------------------- diff --git a/svx/source/form/fmundo.cxx b/svx/source/form/fmundo.cxx index ba7ba492c2fb..e6559850ea5d 100644 --- a/svx/source/form/fmundo.cxx +++ b/svx/source/form/fmundo.cxx @@ -90,25 +90,7 @@ class ScriptEventListenerWrapper : public ScriptEventListener_BASE public: ScriptEventListenerWrapper( FmFormModel& _rModel) throw ( RuntimeException ) : pModel(&_rModel) { - Reference < XPropertySet > xProps( - ::comphelper::getProcessServiceFactory(), UNO_QUERY ); - if ( xProps.is() ) - { - Reference< XComponentContext > xCtx( xProps->getPropertyValue( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY ); - if ( xCtx.is() ) - { - Reference< XMultiComponentFactory > xMFac( - xCtx->getServiceManager(), UNO_QUERY ); - if ( xMFac.is() ) - { - m_vbaListener.set( xMFac->createInstanceWithContext( - rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( - "ooo.vba.EventListener" ) ), xCtx ), - UNO_QUERY_THROW ); - } - } - } + } // XEventListener virtual void SAL_CALL disposing(const EventObject& ) throw( RuntimeException ){} @@ -136,6 +118,33 @@ public: private: void setModel() { + if ( !m_vbaListener.is() ) + { + Reference < XPropertySet > xProps( + ::comphelper::getProcessServiceFactory(), UNO_QUERY ); + if ( xProps.is() ) + { + Reference< XComponentContext > xCtx( xProps->getPropertyValue( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY ); + if ( xCtx.is() ) + { + Reference< XMultiComponentFactory > xMFac( + xCtx->getServiceManager(), UNO_QUERY ); + SfxObjectShellRef xObjSh = pModel->GetObjectShell(); + Reference< XMultiServiceFactory > xDocFac; + if ( xObjSh.Is() ) + xDocFac.set( xObjSh->GetModel(), UNO_QUERY ); + + if ( xMFac.is() ) + { + m_vbaListener.set( xMFac->createInstanceWithContext( + rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + "ooo.vba.EventListener" ) ), xCtx ), + UNO_QUERY_THROW ); + } + } + } + } Reference< XPropertySet > xProps( m_vbaListener, UNO_QUERY ); if ( xProps.is() ) { diff --git a/vbahelper/inc/vbahelper/vbaaccesshelper.hxx b/vbahelper/inc/vbahelper/vbaaccesshelper.hxx new file mode 100644 index 000000000000..79bb44ce30a4 --- /dev/null +++ b/vbahelper/inc/vbahelper/vbaaccesshelper.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: vbahelper.hxx,v $ + * $Revision: 1.5.32.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef OOVBAAPI_VBA_ACCESS_HELPER_HXX +#define OOVBAAPI_VBA_ACCESS_HELPER_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <basic/basmgr.hxx> +#include <sfx2/objsh.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/docfile.hxx> +#define VBAHELPER_DLLIMPLEMENTATION +#include <vbahelper/vbadllapi.h> +#include <memory> +namespace css = ::com::sun::star; +namespace ooo +{ + namespace vba + { + + VBAHELPER_DLLPRIVATE inline css::uno::Reference< css::lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell ) + { + css::uno::Any aUnoVar; + if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) + throw css::lang::IllegalArgumentException(); + css::uno::Reference< css::lang::XMultiServiceFactory > xVBAFactory( aUnoVar, css::uno::UNO_QUERY_THROW ); + return xVBAFactory; + } + + VBAHELPER_DLLPUBLIC inline css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException) + { + OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" ); + ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); + css::uno::Reference< css::uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs ); + return xIf; + } + + + VBAHELPER_DLLPRIVATE inline bool isAlienDoc( SfxObjectShell& rDocShell, const char* pMimeType ) + { + bool bRes( false ); + const SfxFilter *pFilt = rDocShell.GetMedium()->GetFilter(); + if ( pFilt && pFilt->IsAlienFormat() ) + bRes = ( pFilt->GetMimeType().CompareToAscii( pMimeType ) == 0 ); + return bRes; + } + VBAHELPER_DLLPUBLIC inline bool isAlienExcelDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-excel" ); } + VBAHELPER_DLLPUBLIC inline bool isAlienWordDoc( SfxObjectShell& rDocShell ) { return isAlienDoc( rDocShell, "application/vnd.ms-word" ); } + + } // openoffice +} // org + +#endif diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 315ddb19b7ca..aa7ff9b292a7 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -35,17 +35,19 @@ #include <com/sun/star/lang/IllegalArgumentException.hpp> #include <com/sun/star/awt/XControl.hpp> #include <com/sun/star/awt/XDevice.hpp> +#include <basic/basmgr.hxx> #include <basic/sberrors.hxx> #include <cppuhelper/implbase1.hxx> #include <com/sun/star/frame/XModel.hpp> #include <sfx2/dispatch.hxx> -//#include <ooo/vba/msforms/XShape.hpp> +#include <sfx2/objsh.hxx> +#include <sfx2/docfilt.hxx> +#include <sfx2/docfile.hxx> #include <vcl/pointr.hxx> -#define VBAHELPER_DLLIMPLEMENTATION -#include <vbahelper/vbadllapi.h> #include <memory> -namespace css = ::com::sun::star; +#include "vbaaccesshelper.hxx" +namespace css = ::com::sun::star; namespace ooo { namespace vba @@ -62,7 +64,7 @@ namespace ooo } VBAHELPER_DLLPUBLIC SfxObjectShell* getSfxObjShell( const css::uno::Reference< css::frame::XModel >& xModel ) throw ( css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException); - VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const css::uno::Sequence< css::uno::Any >& aArgs ) throw (css::uno::RuntimeException); + css::uno::Reference< css::frame::XModel > getCurrentDoc( const rtl::OUString& sKey ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentExcelDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); VBAHELPER_DLLPUBLIC css::uno::Reference< css::frame::XModel > getCurrentWordDoc( const css::uno::Reference< css::uno::XComponentContext >& xContext ) throw (css::uno::RuntimeException); diff --git a/vbahelper/prj/d.lst b/vbahelper/prj/d.lst index d7b61d1e5a61..d683e97c8b90 100644 --- a/vbahelper/prj/d.lst +++ b/vbahelper/prj/d.lst @@ -8,6 +8,7 @@ mkdir: %_DEST%\inc%_EXT%\basic ..\inc\vbahelper\vbacollectionimpl.hxx %_DEST%\inc%_EXT%\vbahelper\vbacollectionimpl.hxx ..\inc\vbahelper\vbahelper.hxx %_DEST%\inc%_EXT%\vbahelper\vbahelper.hxx +..\inc\vbahelper\vbaaccesshelper.hxx %_DEST%\inc%_EXT%\vbahelper\vbaaccesshelper.hxx ..\inc\vbahelper\helperdecl.hxx %_DEST%\inc%_EXT%\vbahelper\helperdecl.hxx ..\inc\vbahelper\vbahelperinterface.hxx %_DEST%\inc%_EXT%\vbahelper\vbahelperinterface.hxx ..\inc\vbahelper\vbaapplicationbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbaapplicationbase.hxx diff --git a/vbahelper/source/msforms/makefile.mk b/vbahelper/source/msforms/makefile.mk index 9c24c77f8009..7c61e4302b7f 100644 --- a/vbahelper/source/msforms/makefile.mk +++ b/vbahelper/source/msforms/makefile.mk @@ -34,6 +34,11 @@ VISIBILITY_HIDDEN=TRUE # --- Settings ----------------------------------------------------- +.IF "$(ENABLE_VBA)" == "NO" +dummy: + @echo "Nothing to build" +.ENDIF + .INCLUDE : settings.mk SLOFILES=\ diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx index 8cf00748c278..2ff12b145824 100644 --- a/vbahelper/source/msforms/vbacontrol.cxx +++ b/vbahelper/source/msforms/vbacontrol.cxx @@ -374,10 +374,6 @@ ScVbaControlFactory::ScVbaControlFactory( const uno::Reference< uno::XComponentC { } -ScVbaControl* ScVbaControlFactory::createControl() throw (uno::RuntimeException) -{ - return createControl( m_xModel ); -} ScVbaControl* ScVbaControlFactory::createControl( const uno::Reference< uno::XInterface >& xParent ) throw (uno::RuntimeException) { uno::Reference< drawing::XControlShape > xControlShape( m_xControl, uno::UNO_QUERY ); diff --git a/vbahelper/source/msforms/vbacontrol.hxx b/vbahelper/source/msforms/vbacontrol.hxx index b0db3c476186..1a8ed063548b 100644 --- a/vbahelper/source/msforms/vbacontrol.hxx +++ b/vbahelper/source/msforms/vbacontrol.hxx @@ -98,7 +98,6 @@ class ScVbaControlFactory public: ScVbaControlFactory( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::uno::XInterface >& xControl, const css::uno::Reference< css::frame::XModel >& xModel ); - ScVbaControl* createControl() throw ( css::uno::RuntimeException ); ScVbaControl* createControl( const css::uno::Reference< css::uno::XInterface >& xParent ) throw ( css::uno::RuntimeException ); private: ScVbaControl* createControl( const css::uno::Reference< css::awt::XControl >&, const css::uno::Reference< css::uno::XInterface >& ) throw ( css::uno::RuntimeException ); diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index 88f8f53bd5bf..3284ec5cec9d 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -33,6 +33,11 @@ ENABLE_EXCEPTIONS := TRUE VISIBILITY_HIDDEN=TRUE # --- Settings ----------------------------------------------------- +.IF "$(ENABLE_VBA)" == "NO" +dummy: + @echo "Nothing to build" +.ENDIF + .INCLUDE : settings.mk SLOFILES=\ diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index a99b3fd47e00..a7921da9a4f7 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -98,15 +98,6 @@ namespace ooo namespace vba { -uno::Reference< lang::XMultiServiceFactory > getVBAServiceFactory( SfxObjectShell* pShell ) -{ - uno::Any aUnoVar; - if ( !pShell || ! pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) - throw lang::IllegalArgumentException(); - uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW ); - return xVBAFactory; -} - css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShell* pShell, const sal_Char* _pAsciiName ) throw (css::uno::RuntimeException) { OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" ); @@ -114,13 +105,6 @@ css::uno::Reference< css::uno::XInterface > createVBAUnoAPIService( SfxObjectShe return getVBAServiceFactory( pShell )->createInstance( sVarName ); } -css::uno::Reference< css::uno::XInterface > createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw ( css::uno::RuntimeException ) -{ - OSL_PRECOND( pShell, "createVBAUnoAPIService: no shell!" ); - ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); - uno::Reference< uno::XInterface > xIf = getVBAServiceFactory( pShell )->createInstanceWithArguments( sVarName, aArgs ); - return xIf; -} // helper method to determine if the view ( calc ) is in print-preview mode bool isInPrintPreview( SfxViewFrame* pView ) { diff --git a/vbahelper/util/makefile.mk b/vbahelper/util/makefile.mk index 98adae420ed9..49bc8e7d39b0 100644 --- a/vbahelper/util/makefile.mk +++ b/vbahelper/util/makefile.mk @@ -34,6 +34,10 @@ TARGET=vbahelper .INCLUDE : settings.mk +.IF "$(ENABLE_VBA)" == "NO" +dummy: + @echo "Nothing to build" +.ENDIF TARGET_HELPER=vbahelper |