From 98b532d57687b171a4770ac9d738a9e6ef4b85dd Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 22 Jun 2010 18:16:32 +0200 Subject: mib17: remove unused/needless code --- oovbaapi/ooo/vba/XVBAAppService.idl | 72 ----------------- oovbaapi/ooo/vba/XVBADocService.idl | 72 ----------------- oovbaapi/ooo/vba/makefile.mk | 5 +- vbahelper/inc/vbahelper/vbaapplicationbase.hxx | 5 +- vbahelper/inc/vbahelper/vbadocumentbase.hxx | 4 +- vbahelper/inc/vbahelper/vbahelperinterface.hxx | 30 ++++++- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 95 ++++++++++------------- vbahelper/source/vbahelper/vbadocumentbase.cxx | 51 +++++------- 8 files changed, 89 insertions(+), 245 deletions(-) delete mode 100755 oovbaapi/ooo/vba/XVBAAppService.idl delete mode 100755 oovbaapi/ooo/vba/XVBADocService.idl diff --git a/oovbaapi/ooo/vba/XVBAAppService.idl b/oovbaapi/ooo/vba/XVBAAppService.idl deleted file mode 100755 index 1c4a0920fbf8..000000000000 --- a/oovbaapi/ooo/vba/XVBAAppService.idl +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * - * 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: XWorkbook.idl,v $ - * $Revision: 1.4 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef __ooo_vba_appservice_idl__ -#define __ooo_vba_appservice_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __com_sun_star_uno_XComponentContext_idl__ -#include -#endif - -#ifndef __com_sun_star_frame_XModel_idl__ -#include -#endif - -#ifndef __com_sun_star_script_XLibraryContainer_idl__ -#include -#endif - -//============================================================================= - -module ooo { module vba { - -//============================================================================= - - -interface XHelperInterface; -interface XComponentContext; -interface XModel; - -interface XVBAAppService -{ - interface ::com::sun::star::uno::XInterface; - - any getVBE([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel); - any getVBProjects([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer); - - -}; - - }; }; - -#endif diff --git a/oovbaapi/ooo/vba/XVBADocService.idl b/oovbaapi/ooo/vba/XVBADocService.idl deleted file mode 100755 index 6500f028934b..000000000000 --- a/oovbaapi/ooo/vba/XVBADocService.idl +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************* - * - * 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: XVBADocService.idl,v $ - * $Revision: 1.4 $ - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef __ooo_vba_socservice_idl__ -#define __ooo_vba_appservice_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include -#endif - -#ifndef __com_sun_star_uno_XComponentContext_idl__ -#include -#endif - -#ifndef __com_sun_star_frame_XModel_idl__ -#include -#endif - -#ifndef __com_sun_star_script_XLibraryContainer_idl__ -#include -#endif - -//============================================================================= - -module ooo { module vba { - -//============================================================================= - - -interface XHelperInterface; -interface XComponentContext; -interface XModel; - -interface XVBADocService -{ - interface ::com::sun::star::uno::XInterface; - - - any getVBProject([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer); - - -}; - - }; }; - -#endif diff --git a/oovbaapi/ooo/vba/makefile.mk b/oovbaapi/ooo/vba/makefile.mk index 75f6465bf4c0..4f6d378cfe3f 100644 --- a/oovbaapi/ooo/vba/makefile.mk +++ b/oovbaapi/ooo/vba/makefile.mk @@ -61,9 +61,8 @@ IDLFILES=\ XFontBase.idl\ XDialogsBase.idl\ XDialogBase.idl\ - XPageSetupBase.idl \ - XVBAAppService.idl\ - XVBADocService.idl\ + XPageSetupBase.idl + # ------------------------------------------------------------------ .ENDIF .INCLUDE : target.mk diff --git a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx index e2a5a3bff5da..73c1aa0d94e7 100644 --- a/vbahelper/inc/vbahelper/vbaapplicationbase.hxx +++ b/vbahelper/inc/vbahelper/vbaapplicationbase.hxx @@ -57,13 +57,14 @@ public: virtual void SAL_CALL setInteractive( ::sal_Bool bInteractive ) throw (::com::sun::star::uno::RuntimeException); virtual css::uno::Any SAL_CALL CommandBars( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getVersion() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL getVBProjects() throw (css::uno::RuntimeException); + virtual void SAL_CALL Run( const ::rtl::OUString& MacroName, const css::uno::Any& varg1, const css::uno::Any& varg2, const css::uno::Any& varg3, const css::uno::Any& varg4, const css::uno::Any& varg5, const css::uno::Any& varg6, const css::uno::Any& varg7, const css::uno::Any& varg8, const css::uno::Any& varg9, const css::uno::Any& varg10, const css::uno::Any& varg11, const css::uno::Any& varg12, const css::uno::Any& varg13, const css::uno::Any& varg14, const css::uno::Any& varg15, const css::uno::Any& varg16, const css::uno::Any& varg17, const css::uno::Any& varg18, const css::uno::Any& varg19, const css::uno::Any& varg20, const css::uno::Any& varg21, const css::uno::Any& varg22, const css::uno::Any& varg23, const css::uno::Any& varg24, const css::uno::Any& varg25, const css::uno::Any& varg26, const css::uno::Any& varg27, const css::uno::Any& varg28, const css::uno::Any& varg29, const css::uno::Any& varg30 ) throw (css::uno::RuntimeException); virtual void SAL_CALL OnTime( const ::com::sun::star::uno::Any& aEarliestTime, const ::rtl::OUString& aFunction, const ::com::sun::star::uno::Any& aLatestTime, const ::com::sun::star::uno::Any& aSchedule ) throw (::com::sun::star::uno::RuntimeException); virtual float SAL_CALL CentimetersToPoints( float _Centimeters ) throw (css::uno::RuntimeException); virtual void SAL_CALL Undo( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL Quit( ) throw (::com::sun::star::uno::RuntimeException); - virtual css::uno::Any SAL_CALL getVBE() throw (css::uno::RuntimeException); - virtual css::uno::Any SAL_CALL SAL_CALL getVBProjects() throw (css::uno::RuntimeException); // XHelperInterface virtual rtl::OUString& getServiceImplName(); diff --git a/vbahelper/inc/vbahelper/vbadocumentbase.hxx b/vbahelper/inc/vbahelper/vbadocumentbase.hxx index 7131e1963b26..2588b7da1720 100644 --- a/vbahelper/inc/vbahelper/vbadocumentbase.hxx +++ b/vbahelper/inc/vbahelper/vbadocumentbase.hxx @@ -52,9 +52,7 @@ public: virtual ::rtl::OUString SAL_CALL getFullName() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getSaved() throw (css::uno::RuntimeException); virtual void SAL_CALL setSaved( sal_Bool bSave ) throw (css::uno::RuntimeException); - - virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Michhael E. Bohn - + virtual css::uno::Any SAL_CALL getVBProject() throw (css::uno::RuntimeException); // Methods virtual void SAL_CALL Close( const css::uno::Any &bSaveChanges, diff --git a/vbahelper/inc/vbahelper/vbahelperinterface.hxx b/vbahelper/inc/vbahelper/vbahelperinterface.hxx index 21339631e1ed..b095b5cd2823 100644 --- a/vbahelper/inc/vbahelper/vbahelperinterface.hxx +++ b/vbahelper/inc/vbahelper/vbahelperinterface.hxx @@ -28,6 +28,8 @@ #define OOVBAAPI_VBA_HELPERINTERFACE_HXX #include +#include +#include #include #include #include @@ -68,6 +70,7 @@ protected: css::uno::Reference< css::uno::XComponentContext > mxContext; public: InheritedHelperInterfaceImpl() {} + InheritedHelperInterfaceImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxContext( xContext ) {} InheritedHelperInterfaceImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : mxParent( xParent ), mxContext( xContext ) {} virtual rtl::OUString& getServiceImplName() = 0; virtual css::uno::Sequence getServiceNames() = 0; @@ -86,7 +89,6 @@ public: return xNameAccess->getByName( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Application" ) ) ); } - // XServiceInfo Methods virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (css::uno::RuntimeException) { return getServiceImplName(); } virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (css::uno::RuntimeException) @@ -101,19 +103,39 @@ public: } virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (css::uno::RuntimeException) { - css::uno::Sequence< rtl::OUString > aNames = getServiceNames();; + css::uno::Sequence< rtl::OUString > aNames = getServiceNames(); return aNames; } }; template< typename Ifc1 > class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl1 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; +public: + InheritedHelperInterfaceImpl1< Ifc1 >() {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl1< Ifc1 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; +template< typename Ifc1, typename Ifc2 > +class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl2 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > { -typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper1< Ifc1 > > Base; + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper2< Ifc1, Ifc2 > > Base; public: - InheritedHelperInterfaceImpl1< Ifc1 > ( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >() {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl2< Ifc1, Ifc2 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} +}; +template< typename Ifc1, typename Ifc2, typename Ifc3 > +class VBAHELPER_DLLPUBLIC InheritedHelperInterfaceImpl3 : public InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > +{ + typedef InheritedHelperInterfaceImpl< ::cppu::WeakImplHelper3< Ifc1, Ifc2, Ifc3 > > Base; +public: + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >() {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xContext ) {} + InheritedHelperInterfaceImpl3< Ifc1, Ifc2, Ifc3 >( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext ) : Base( xParent, xContext ) {} }; // ============================================================================ diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 6d2c51066ca2..213133998def 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -24,39 +24,36 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ + #include "vbahelper/vbaapplicationbase.hxx" + #include -#include //Michael E. Bohn -#include //Michael E. Bohn -#include //Michael E. Bohn -#include //Michael E. Bohn +#include +#include +#include +#include #include #include #include #include #include #include -#include //Michael E. Bohn -#include //Michael E. Bohn +#include #include - -#include "vbacommandbars.hxx" +#include #include #include - -// start basic includes #include #include #include #include #include -// end basic includes -#include +#include "vbacommandbars.hxx" -using namespace com::sun::star; -using namespace ooo::vba; +using namespace ::com::sun::star; +using namespace ::ooo::vba; #define OFFICEVERSION "11.0" @@ -407,57 +404,43 @@ float SAL_CALL VbaApplicationBase::CentimetersToPoints( float _Centimeters ) thr return ( _Centimeters * rate ); } -// inserted by Michael E. Bohn uno::Any SAL_CALL VbaApplicationBase::getVBE() throw (uno::RuntimeException) { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); - uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBAAppService.is()){ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - return xVBAAppService->getVBE( this, mxContext, xModel); - } - - }catch(uno::Exception* e) - { - } - return aAny; + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= getCurrentDocument(); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBE = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBE" ) ), aArgs, mxContext ); + return uno::Any( xVBE ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } uno::Any SAL_CALL VbaApplicationBase::getVBProjects() throw (uno::RuntimeException) { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAAppService" )),mxContext); - uno::Reference < ::ooo::vba::XVBAAppService > xVBAAppService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBAAppService.is()){ - uno::Reference< frame::XModel > xModel( getCurrentDocument(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); - uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); - uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - return xVBAAppService->getVBProjects(this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer); - } - - }catch(uno::Exception* e) - { - } - return aAny; - - - + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= getCurrentDocument(); + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProjects" ) ), aArgs, mxContext ); + return uno::Any( xVBProjects ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } - - - rtl::OUString& VbaApplicationBase::getServiceImplName() { diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx index f27f2de53c8a..65f7f4bcfbeb 100644 --- a/vbahelper/source/vbahelper/vbadocumentbase.cxx +++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx @@ -24,9 +24,9 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#include -#include -#include + +#include "vbahelper/vbadocumentbase.hxx" +#include "vbahelper/helperdecl.hxx" #include #include @@ -35,8 +35,8 @@ #include #include //Michael E. Bohn #include -#include +#include #include #include @@ -206,40 +206,25 @@ VbaDocumentBase::Activate() throw (uno::RuntimeException) xFrame->activate(); } -// ---- Michael E.Bohn Start----- - uno::Any SAL_CALL VbaDocumentBase::getVBProject() throw (uno::RuntimeException) - { - uno::Any aAny; - uno::Reference< ::lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager(); - try - { - uno::Reference < ::uno::XInterface > xInterface = xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBADocService" )),mxContext); - uno::Reference < ::ooo::vba::XVBADocService > xVBADocService (xInterface, ::uno::UNO_QUERY_THROW ); - if (xVBADocService.is()){ - uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_QUERY_THROW ); - uno::Reference< document::XEmbeddedScripts > xEnbeddedScripts ( xModel, uno::UNO_QUERY_THROW ); - uno::Reference< script::XStorageBasedLibraryContainer > xMacroStorageBasedLibraryContainer = xEnbeddedScripts->getBasicLibraries(); - uno::Reference< script::XStorageBasedLibraryContainer > xDialogStorageBasedLibraryContainer = xEnbeddedScripts->getDialogLibraries(); - uno::Reference< script::XLibraryContainer > xMacroLibraryContainer ( xMacroStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - uno::Reference< script::XLibraryContainer > xDialogLibraryContainer( xDialogStorageBasedLibraryContainer, uno::UNO_QUERY_THROW ); - - return xVBADocService->getVBProject( this, mxContext, xModel, xMacroLibraryContainer, xDialogLibraryContainer ); - } - - }catch(uno::Exception* e) - { - } - return aAny; - + try // return empty object on error + { + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this ); + aArgs[ 1 ] <<= mxModel; + uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW ); + uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext ); + return uno::Any( xVBProjects ); + } + catch( uno::Exception& ) + { + } + return uno::Any(); } - -// ---- Michael E.Bohn End ----- - - rtl::OUString& VbaDocumentBase::getServiceImplName() { -- cgit v1.2.3 From 64994694589f6706b6d48356859555381ab7b76a Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 23 Jun 2010 19:44:37 +0200 Subject: mib17: #i109119 add Events menu entry --- .../registry/data/org/openoffice/Office/UI/CalcCommands.xcu | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu index d3db05206a6a..2d887c084317 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu @@ -1,4 +1,4 @@ - + @@ -160,6 +160,14 @@ ~Select... + + + Sheet ~Events... + + + ~Events... + + DataPilot Filter -- cgit v1.2.3 From 0dd0ceb57dd68715477c1f3e50ee4a4eaf975e6c Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 23 Jun 2010 19:44:37 +0200 Subject: mib17: #i109119 add Events menu entry --- sc/uiconfig/scalc/menubar/menubar.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/sc/uiconfig/scalc/menubar/menubar.xml b/sc/uiconfig/scalc/menubar/menubar.xml index da8e6efdad55..dbdba59e8a82 100644 --- a/sc/uiconfig/scalc/menubar/menubar.xml +++ b/sc/uiconfig/scalc/menubar/menubar.xml @@ -92,6 +92,7 @@ + -- cgit v1.2.3 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(-) 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 v1.2.3 From 5db01bbf8f1ef192cbd7c35695f517e3622e3913 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 --- basic/source/classes/sb.cxx | 4 +++- basic/source/runtime/step2.cxx | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 79c5f78601ea..924a3ef2807f 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -569,11 +569,13 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) } } SetModuleType( ModuleType::CLASS ); + mbVBACompat = pClassModule->mbVBACompat; } SbClassModuleObject::~SbClassModuleObject() { - triggerTerminateEvent(); + if( StarBASIC::IsRunning() ) + triggerTerminateEvent(); // Must be deleted by base class dtor because this data // is not owned by the SbClassModuleObject object diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 72ea67dd8db4..8e72fd2ac3c6 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -263,8 +263,10 @@ SbxVariable* SbiRuntime::FindElement pElem = pNew; } // Index-Access bei UnoObjekten beruecksichtigen - /* - else if( pElem->ISA(SbUnoProperty) ) + // definitely we want this for VBA where properties are often + // collections ( which need index access ), but lets only do + // this if we actually have params following + else if( bVBAEnabled && pElem->ISA(SbUnoProperty) && pElem->GetParameters() ) { // pElem auf eine Ref zuweisen, um ggf. eine Temp-Var zu loeschen SbxVariableRef refTemp = pElem; @@ -274,7 +276,6 @@ SbxVariable* SbiRuntime::FindElement pElem->SetParameters( NULL ); // sonst bleibt Ref auf sich selbst pElem = pNew; } - */ } return CheckArray( pElem ); } -- cgit v1.2.3 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(-) 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 v1.2.3 From 7e018ced84bd8a4400bf8c7ede4e1cb33e90aec9 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Thu, 1 Jul 2010 16:23:26 +0200 Subject: mib17: #111144# Enable calls to module function via Sheet object --- basic/inc/basic/sbmod.hxx | 3 + basic/source/classes/sbxmod.cxx | 359 ++++++++++++++++++++++++++ vbahelper/inc/vbahelper/vbacollectionimpl.hxx | 3 +- vbahelper/inc/vbahelper/vbahelper.hxx | 1 + vbahelper/source/vbahelper/vbaglobalbase.cxx | 24 +- vbahelper/source/vbahelper/vbahelper.cxx | 20 ++ 6 files changed, 404 insertions(+), 6 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index cf888adf9dcf..aeed4c2b6347 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -28,6 +28,7 @@ #ifndef _SB_SBMOD_HXX #define _SB_SBMOD_HXX +#include #include #include #include @@ -57,6 +58,7 @@ class SbModule : public SbxObject SbModuleImpl* mpSbModuleImpl; // Impl data protected: + com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; ::rtl::OUString aOUSource; String aComment; SbiImage* pImage; // the Image @@ -131,6 +133,7 @@ public: INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } + ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 1b49a376c9bd..254e99c69da9 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -76,7 +76,20 @@ using namespace com::sun::star; #include #include #include +#include +#include +#include +#include +#include +#include +#include + using namespace ::com::sun::star; +using namespace com::sun::star::lang; +using namespace com::sun::star::reflection; +using namespace com::sun::star::beans; +using namespace com::sun::star::script; + #include #include @@ -85,6 +98,340 @@ using namespace com::sun::star; #include #include #include +#include + +typedef ::cppu::WeakImplHelper1< XInvocation > DocObjectWrapper_BASE; +typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; +::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); +void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); + +class DocObjectWrapper : public DocObjectWrapper_BASE +{ + Reference< XAggregation > m_xAggProxy; + Reference< XInvocation > m_xAggInv; + Reference< XTypeProvider > m_xAggregateTypeProv; + Sequence< Type > m_Types; + SbModule* m_pMod; + SbMethodRef getMethod( const rtl::OUString& aName ) throw (RuntimeException); + SbPropertyRef getProperty( const rtl::OUString& aName ) throw (RuntimeException); + String mName; // for debugging + +public: + DocObjectWrapper( SbModule* pMod ); + ~DocObjectWrapper(); + + virtual void SAL_CALL acquire() throw(); + virtual void SAL_CALL release() throw(); + + virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw ( com::sun::star::uno::RuntimeException ) + { + return m_xAggregateTypeProv->getImplementationId(); + + } + + virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection( ) throw (RuntimeException); + + virtual Any SAL_CALL invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException); + virtual Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException); + virtual ::sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException); + virtual ::sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException); + virtual Any SAL_CALL queryInterface( const Type& aType ) throw ( RuntimeException ); + + virtual Sequence< Type > SAL_CALL getTypes() throw ( RuntimeException ); +}; + +DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pVar->GetName() ) +{ + SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); + if ( pMod ) + { + sal_Int16 nType = pMod->GetModuleType(); + if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) + { + Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + // Use proxy factory service to create aggregatable proxy. + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pMod->GetObject() ); + Reference< XInterface > xIf; + if ( pUnoObj ) + { + Any aObj = pUnoObj->getUnoAny(); + aObj >>= xIf; + if ( xIf.is() ) + { + m_xAggregateTypeProv.set( xIf, UNO_QUERY ); + m_xAggInv.set( xIf, UNO_QUERY ); + } + } + if ( xIf.is() ) + { + try + { + Reference< XMultiComponentFactory > xMFac( xFactory, UNO_QUERY_THROW ); + Reference< XPropertySet> xPSMPropertySet( xMFac, UNO_QUERY_THROW ); + Reference< XComponentContext > xCtx; + xPSMPropertySet->getPropertyValue( + String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xCtx; + Reference< XProxyFactory > xProxyFac( xMFac->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.reflection.ProxyFactory" ) ), xCtx ), UNO_QUERY_THROW ); + m_xAggProxy = xProxyFac->createProxy( xIf ); + } + catch( Exception& ) + { + OSL_ENSURE( false, "DocObjectWrapper::DocObjectWrapper: Caught exception!" ); + } + } + + if ( m_xAggProxy.is() ) + { + osl_incrementInterlockedCount( &m_refCount ); + + /* i35609 - Fix crash on Solaris. The setDelegator call needs + to be in its own block to ensure that all temporary Reference + instances that are acquired during the call are released + before m_refCount is decremented again */ + { + m_xAggProxy->setDelegator( static_cast< cppu::OWeakObject * >( this ) ); + } + + osl_decrementInterlockedCount( &m_refCount ); + } + } + } +} + +void SAL_CALL +DocObjectWrapper::acquire() throw () +{ + osl_incrementInterlockedCount( &m_refCount ); + OSL_TRACE("DocObjectWrapper::acquire(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); +} +void SAL_CALL +DocObjectWrapper::release() throw () +{ + if ( osl_decrementInterlockedCount( &m_refCount ) == 0 ) + { + OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); + delete this; + } + else + OSL_TRACE("DocObjectWrapper::release(%s) 0x%x refcount is now %d", rtl::OUStringToOString( mName, RTL_TEXTENCODING_UTF8 ).getStr(), this, m_refCount ); +} + +DocObjectWrapper::~DocObjectWrapper() +{ +} + +Sequence< Type > SAL_CALL DocObjectWrapper::getTypes() + throw ( RuntimeException ) +{ + if ( m_Types.getLength() == 0 ) + { + Sequence< Type > sTypes; + if ( m_xAggregateTypeProv.is() ) + sTypes = m_xAggregateTypeProv->getTypes(); + m_Types.realloc( sTypes.getLength() + 1 ); + Type* pPtr = m_Types.getArray(); + for ( int i=0; i SAL_CALL +DocObjectWrapper::getIntrospection( ) throw (RuntimeException) +{ + return NULL; +} + +Any SAL_CALL +DocObjectWrapper::invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams, Sequence< ::sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (IllegalArgumentException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasMethod( aFunctionName ) ) + return m_xAggInv->invoke( aFunctionName, aParams, aOutParamIndex, aOutParam ); + SbMethodRef pMethod = getMethod( aFunctionName ); + if ( !pMethod ) + throw RuntimeException(); + // check number of parameters + sal_Int32 nParamsCount = aParams.getLength(); + SbxInfo* pInfo = pMethod->GetInfo(); + if ( pInfo ) + { + sal_Int32 nSbxOptional = 0; + USHORT n = 1; + for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) ) + { + if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 ) + ++nSbxOptional; + else + nSbxOptional = 0; + } + sal_Int32 nSbxCount = n - 1; + if ( nParamsCount < nSbxCount - nSbxOptional ) + { + throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "wrong number of parameters!" ) ), Reference< XInterface >() ); + } + } + // set parameters + SbxArrayRef xSbxParams; + if ( nParamsCount > 0 ) + { + xSbxParams = new SbxArray; + const Any* pParams = aParams.getConstArray(); + for ( sal_Int32 i = 0; i < nParamsCount; ++i ) + { + SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( static_cast< SbxVariable* >( xSbxVar ), pParams[i] ); + xSbxParams->Put( xSbxVar, static_cast< USHORT >( i ) + 1 ); + + // Enable passing by ref + if ( xSbxVar->GetType() != SbxVARIANT ) + xSbxVar->SetFlag( SBX_FIXED ); + } + } + if ( xSbxParams.Is() ) + pMethod->SetParameters( xSbxParams ); + + // call method + SbxVariableRef xReturn = new SbxVariable; + ErrCode nErr = SbxERR_OK; + + nErr = pMethod->Call( xReturn ); + Any aReturn; + // get output parameters + if ( xSbxParams.Is() ) + { + SbxInfo* pInfo_ = pMethod->GetInfo(); + if ( pInfo_ ) + { + OutParamMap aOutParamMap; + for ( USHORT n = 1, nCount = xSbxParams->Count(); n < nCount; ++n ) + { + const SbxParamInfo* pParamInfo = pInfo_->GetParam( n ); + if ( pParamInfo && ( pParamInfo->eType & SbxBYREF ) != 0 ) + { + SbxVariable* pVar = xSbxParams->Get( n ); + if ( pVar ) + { + SbxVariableRef xVar = pVar; + aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar ) ) ); + } + } + } + sal_Int32 nOutParamCount = aOutParamMap.size(); + aOutParamIndex.realloc( nOutParamCount ); + aOutParam.realloc( nOutParamCount ); + sal_Int16* pOutParamIndex = aOutParamIndex.getArray(); + Any* pOutParam = aOutParam.getArray(); + for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam ) + { + *pOutParamIndex = aIt->first; + *pOutParam = aIt->second; + } + } + } + + // get return value + aReturn = sbxToUnoValue( xReturn ); + + pMethod->SetParameters( NULL ); + + return aReturn; +} + +void SAL_CALL +DocObjectWrapper::setValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (UnknownPropertyException, CannotConvertException, InvocationTargetException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aPropertyName ) ) + return m_xAggInv->setValue( aPropertyName, aValue ); + + SbPropertyRef pProperty = getProperty( aPropertyName ); + if ( !pProperty.Is() ) + throw UnknownPropertyException(); + unoToSbxValue( (SbxVariable*) pProperty, aValue ); +} + +Any SAL_CALL +DocObjectWrapper::getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aPropertyName ) ) + return m_xAggInv->getValue( aPropertyName ); + + SbPropertyRef pProperty = getProperty( aPropertyName ); + if ( !pProperty.Is() ) + throw UnknownPropertyException(); + + SbxVariable* pProp = ( SbxVariable* ) pProperty; + if ( pProp->GetType() == SbxEMPTY ) + pProperty->Broadcast( SBX_HINT_DATAWANTED ); + + Any aRet = sbxToUnoValue( pProp ); + return aRet; +} + +::sal_Bool SAL_CALL +DocObjectWrapper::hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + if ( m_xAggInv.is() && m_xAggInv->hasMethod( aName ) ) + return sal_True; + return getMethod( aName ).Is(); +} + +::sal_Bool SAL_CALL +DocObjectWrapper::hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException) +{ + sal_Bool bRes = sal_False; + if ( m_xAggInv.is() && m_xAggInv->hasProperty( aName ) ) + bRes = sal_True; + else bRes = getProperty( aName ).Is(); + return bRes; +} + +Any SAL_CALL DocObjectWrapper::queryInterface( const Type& aType ) + throw ( RuntimeException ) +{ + Any aRet = DocObjectWrapper_BASE::queryInterface( aType ); + if ( aRet.hasValue() ) + return aRet; + else if ( m_xAggProxy.is() ) + aRet = m_xAggProxy->queryAggregation( aType ); + return aRet; +} + +SbMethodRef DocObjectWrapper::getMethod( const rtl::OUString& aName ) throw (RuntimeException) +{ + SbMethodRef pMethod = NULL; + if ( m_pMod ) + { + USHORT nSaveFlgs = m_pMod->GetFlags(); + // Limit search to this module + m_pMod->ResetFlag( SBX_GBLSEARCH ); + pMethod = (SbMethod*) m_pMod->SbModule::Find( aName, SbxCLASS_METHOD ); + m_pMod->SetFlags( nSaveFlgs ); + } + + return pMethod; +} + +SbPropertyRef DocObjectWrapper::getProperty( const rtl::OUString& aName ) throw (RuntimeException) +{ + SbPropertyRef pProperty = NULL; + if ( m_pMod ) + { + USHORT nSaveFlgs = m_pMod->GetFlags(); + // Limit search to this module. + m_pMod->ResetFlag( SBX_GBLSEARCH ); + pProperty = (SbProperty*)m_pMod->SbModule::Find( aName, SbxCLASS_PROPERTY ); + m_pMod->SetFlag( nSaveFlgs ); + } + + return pProperty; +} TYPEINIT1(SbModule,SbxObject) TYPEINIT1(SbMethod,SbxMethod) @@ -199,12 +546,24 @@ SbModule::SbModule( const String& rName, BOOL bVBACompat ) SbModule::~SbModule() { + OSL_TRACE("Module named %s is destructing", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr() ); if( pImage ) delete pImage; if( pBreaks ) delete pBreaks; if( pClassData ) delete pClassData; + mxWrapper = NULL; +} + +uno::Reference< script::XInvocation > +SbModule::GetUnoModule() +{ + if ( !mxWrapper.is() ) + mxWrapper = new DocObjectWrapper( this ); + + OSL_TRACE("Module named %s returning wrapper mxWrapper (0x%x)", rtl::OUStringToOString( GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mxWrapper.get() ); + return mxWrapper; } BOOL SbModule::IsCompiled() const diff --git a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx index 36102116c7b3..5bd58b44adaf 100644 --- a/vbahelper/inc/vbahelper/vbacollectionimpl.hxx +++ b/vbahelper/inc/vbahelper/vbacollectionimpl.hxx @@ -133,11 +133,12 @@ protected: class VBAHELPER_DLLPUBLIC EnumerationHelperImpl : public EnumerationHelper_BASE { protected: + css::uno::WeakReference< ov::XHelperInterface > m_xParent; css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::container::XEnumeration > m_xEnumeration; public: - EnumerationHelperImpl( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } + EnumerationHelperImpl( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::container::XEnumeration >& xEnumeration ) throw ( css::uno::RuntimeException ) : m_xParent( xParent ), m_xContext( xContext ), m_xEnumeration( xEnumeration ) { } virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (css::uno::RuntimeException) { return m_xEnumeration->hasMoreElements(); } }; diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx index 33613bb76091..a1eca84bbdf8 100644 --- a/vbahelper/inc/vbahelper/vbahelper.hxx +++ b/vbahelper/inc/vbahelper/vbahelper.hxx @@ -63,6 +63,7 @@ namespace ooo throw css::lang::IllegalArgumentException(); return aSomething; } + VBAHELPER_DLLPUBLIC css::uno::Reference< css::uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ); 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); diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index c7c33b93b1a3..b4b39344fd61 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -35,6 +35,9 @@ using namespace ooo::vba; rtl::OUString sApplication( RTL_CONSTASCII_USTRINGPARAM("Application") ); +// special key to return the Application +rtl::OUString sAppService( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.Application") ); + VbaGlobalsBase::VbaGlobalsBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ) @@ -74,19 +77,30 @@ uno::Reference< uno::XInterface > SAL_CALL VbaGlobalsBase::createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (uno::Exception, uno::RuntimeException) { uno::Reference< uno::XInterface > xReturn; - - if ( hasServiceName( aServiceSpecifier ) ) + if ( aServiceSpecifier.equals( sAppService ) ) + { + // try to extract the Application from the context + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + xNameContainer->getByName( sApplication ) >>= xReturn; + } + else if ( hasServiceName( aServiceSpecifier ) ) xReturn = mxContext->getServiceManager()->createInstanceWithContext( aServiceSpecifier, mxContext ); return xReturn; } uno::Reference< uno::XInterface > SAL_CALL -VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException) +VbaGlobalsBase::createInstanceWithArguments( const ::rtl::OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& Arguments ) throw (uno::Exception, uno::RuntimeException) { uno::Reference< uno::XInterface > xReturn; - if ( hasServiceName( ServiceSpecifier ) ) - xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( ServiceSpecifier, Arguments, mxContext ); + if ( aServiceSpecifier.equals( sAppService ) ) + { + // try to extract the Application from the context + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + xNameContainer->getByName( sApplication ) >>= xReturn; + } + else if ( hasServiceName( aServiceSpecifier ) ) + xReturn = mxContext->getServiceManager()->createInstanceWithArgumentsAndContext( aServiceSpecifier, Arguments, mxContext ); return xReturn; } diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx index 1953d0772f3c..7cd82dff9536 100644 --- a/vbahelper/source/vbahelper/vbahelper.cxx +++ b/vbahelper/source/vbahelper/vbahelper.cxx @@ -1404,6 +1404,26 @@ void UserFormGeometryHelper::setHeight( double nHeight ) return points; } + uno::Reference< uno::XInterface > getUnoDocModule( const String& aModName, SfxObjectShell* pShell ) + { + uno::Reference< uno::XInterface > xIf; + if ( pShell ) + { + rtl::OUString sProj( RTL_CONSTASCII_USTRINGPARAM("Standard") ); + BasicManager* pBasMgr = pShell->GetBasicManager(); + if ( pBasMgr && pBasMgr->GetName().Len() ) + sProj = pShell->GetBasicManager()->GetName(); + StarBASIC* pBasic = pShell->GetBasicManager()->GetLib( sProj ); + if ( pBasic ) + { + SbModule* pMod = pBasic->FindModule( aModName ); + if ( pMod ) + xIf = pMod->GetUnoModule(); + } + } + return xIf; + } + SfxObjectShell* getSfxObjShell( const uno::Reference< frame::XModel >& xModel ) throw (uno::RuntimeException) { SfxObjectShell* pFoundShell = NULL; -- cgit v1.2.3 From bee21111f8c0d5974031722236ae52bdb0d65b97 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Thu, 1 Jul 2010 16:23:26 +0200 Subject: mib17: #111144# Enable calls to module function via Sheet object --- sc/source/ui/unoobj/servuno.cxx | 32 +++------ sc/source/ui/vba/excelvbahelper.cxx | 50 +++++++++++++ sc/source/ui/vba/excelvbahelper.hxx | 8 +++ sc/source/ui/vba/vbaapplication.cxx | 61 +++++++++++----- sc/source/ui/vba/vbachartobjects.cxx | 5 +- sc/source/ui/vba/vbacomments.cxx | 5 +- sc/source/ui/vba/vbaformatconditions.cxx | 4 +- sc/source/ui/vba/vbaname.cxx | 4 +- sc/source/ui/vba/vbanames.cxx | 2 +- sc/source/ui/vba/vbapivottables.cxx | 4 +- sc/source/ui/vba/vbarange.cxx | 120 +++++++++++++++---------------- sc/source/ui/vba/vbarange.hxx | 1 - sc/source/ui/vba/vbaworkbooks.cxx | 101 +++++++++++++++++++++++--- sc/source/ui/vba/vbaworksheets.cxx | 51 +++++++++++-- 14 files changed, 324 insertions(+), 124 deletions(-) mode change 100644 => 100755 sc/source/ui/vba/vbarange.cxx diff --git a/sc/source/ui/unoobj/servuno.cxx b/sc/source/ui/unoobj/servuno.cxx index 0b3a6f01f9ea..768fe3d461d3 100644 --- a/sc/source/ui/unoobj/servuno.cxx +++ b/sc/source/ui/unoobj/servuno.cxx @@ -61,10 +61,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -72,18 +74,14 @@ using namespace ::com::sun::star; -#ifndef CWS_NPOWER14MISCFIXES -uno::Reference< uno::XInterface > lcl_createVBAUnoAPIServiceWithArgs( SfxObjectShell* pShell, const sal_Char* _pAsciiName, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException) +bool isInVBAMode( ScDocShell& rDocSh ) { - uno::Any aUnoVar; - if ( !pShell || !pShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aUnoVar ) ) - throw lang::IllegalArgumentException(); - uno::Reference< lang::XMultiServiceFactory > xVBAFactory( aUnoVar, uno::UNO_QUERY_THROW ); - ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( _pAsciiName ) ); - uno::Reference< uno::XInterface > xIf = xVBAFactory->createInstanceWithArguments( sVarName, aArgs ); - return xIf; + uno::Reference xLibContainer = rDocSh.GetBasicContainer(); + uno::Reference xVBACompat( xLibContainer, uno::UNO_QUERY ); + if ( xVBACompat.is() ) + return xVBACompat->getVBACompatModeOn(); + return false; } -#endif class ScVbaObjectForCodeNameProvider : public ::cppu::WeakImplHelper1< container::XNameAccess > { @@ -98,13 +96,10 @@ public: throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")), uno::Reference< uno::XInterface >() ); uno::Sequence< uno::Any > aArgs(2); - aArgs[0] = uno::Any( uno::Reference< uno::XInterface >() ); + // access the application object ( parent for workbook ) + aArgs[0] = uno::Any( ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.Application", uno::Sequence< uno::Any >() ) ); aArgs[1] = uno::Any( mpDocShell->GetModel() ); -#ifdef CWS_NPOWER14MISCFIXES maWorkbook <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); -#else - maWorkbook <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Workbook", aArgs ); -#endif } virtual ::sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw (::com::sun::star::uno::RuntimeException ) @@ -139,13 +134,8 @@ public: aArgs[0] = maWorkbook; aArgs[1] = uno::Any( xModel ); aArgs[2] = uno::Any( rtl::OUString( sSheetName ) ); -#ifdef CWS_NPOWER14MISCFIXES // use the convience function maCachedObject <<= ooo::vba::createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); -#else - // use the temp function - maCachedObject <<= lcl_createVBAUnoAPIServiceWithArgs( mpDocShell, "ooo.vba.excel.Worksheet", aArgs ); -#endif break; } } @@ -576,7 +566,7 @@ uno::Reference ScServiceProvider::MakeInstance( { // Only create the excel faking service for excel docs const SfxFilter *pFilt = pDocShell->GetMedium()->GetFilter(); - if ( pFilt && pFilt->IsAlienFormat() ) + if ( pFilt && pFilt->IsAlienFormat() && isInVBAMode( *pDocShell ) ) { // application/vnd.ms-excel is the mime type for Excel static const rtl::OUString sExcelMimeType( RTL_CONSTASCII_USTRINGPARAM( "application/vnd.ms-excel" ) ); diff --git a/sc/source/ui/vba/excelvbahelper.cxx b/sc/source/ui/vba/excelvbahelper.cxx index b1c4db637434..2c39d7154b4b 100644 --- a/sc/source/ui/vba/excelvbahelper.cxx +++ b/sc/source/ui/vba/excelvbahelper.cxx @@ -31,6 +31,7 @@ #include "scmod.hxx" #include "cellsuno.hxx" #include +#include using namespace ::com::sun::star; using namespace ::ooo::vba; @@ -41,6 +42,27 @@ namespace vba { namespace excel { + +ScDocShell* GetDocShellFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException ) +{ + ScCellRangesBase* pScCellRangesBase = ScCellRangesBase::getImplementation( xRange ); + if ( !pScCellRangesBase ) + { + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying doc shell uno range object" ) ), uno::Reference< uno::XInterface >() ); + } + return pScCellRangesBase->GetDocShell(); +} + +ScDocument* GetDocumentFromRange( const uno::Reference< uno::XInterface >& xRange ) throw ( uno::RuntimeException ) +{ + ScDocShell* pDocShell = GetDocShellFromRange( xRange ); + if ( !pDocShell ) + { + throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Failed to access underlying document from uno range object" ) ), uno::Reference< uno::XInterface >() ); + } + return pDocShell->GetDocument(); +} + void implSetZoom( const uno::Reference< frame::XModel >& xModel, sal_Int16 nZoom, std::vector< SCTAB >& nTabs ) { ScTabViewShell* pViewSh = excel::getBestViewShell( xModel ); @@ -207,12 +229,40 @@ getViewFrame( const uno::Reference< frame::XModel >& xModel ) return NULL; } +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) +{ + uno::Reference< sheet::XSheetCellRange > xSheetRange( xRange, uno::UNO_QUERY_THROW ); + uno::Reference< beans::XPropertySet > xProps( xSheetRange->getSpreadsheet(), uno::UNO_QUERY_THROW ); + rtl::OUString sCodeName; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("CodeName") ) ) >>= sCodeName; + // #TODO #FIXME ideally we should 'throw' here if we don't get a valid parent, but... it is possible + // to create a module ( and use 'Option VBASupport 1' ) for a calc document, in this scenario there + // are *NO* special document module objects ( of course being able to switch between vba/non vba mode at + // the document in the future could fix this, especially IF the switching of the vba mode takes care to + // create the special document module objects if they don't exist. + uno::Reference< XHelperInterface > xParent( ov::getUnoDocModule( sCodeName, GetDocShellFromRange( xRange ) ), uno::UNO_QUERY ); + + return xParent; +} + +uno::Reference< XHelperInterface > +getUnoSheetModuleObj( const uno::Reference< sheet::XSheetCellRangeContainer >& xRanges ) throw ( uno::RuntimeException ) +{ + uno::Reference< container::XEnumerationAccess > xEnumAccess( xRanges, uno::UNO_QUERY_THROW ); + uno::Reference< container::XEnumeration > xEnum = xEnumAccess->createEnumeration(); + uno::Reference< table::XCellRange > xRange( xEnum->nextElement(), uno::UNO_QUERY_THROW ); + + return getUnoSheetModuleObj( xRange ); +} + SfxItemSet* ScVbaCellRangeAccess::GetDataSet( ScCellRangesBase* pRangeObj ) { return pRangeObj ? pRangeObj->GetCurrentDataSet( true ) : 0; } + } //excel } //vba } //ooo diff --git a/sc/source/ui/vba/excelvbahelper.hxx b/sc/source/ui/vba/excelvbahelper.hxx index 9af804ab169f..da0474e6ceb0 100644 --- a/sc/source/ui/vba/excelvbahelper.hxx +++ b/sc/source/ui/vba/excelvbahelper.hxx @@ -29,6 +29,9 @@ #include #include +#include +#include +#include class ScCellRangesBase; @@ -48,6 +51,11 @@ namespace ooo ScDocShell* getDocShell( const css::uno::Reference< css::frame::XModel>& xModel ) ; ScTabViewShell* getCurrentBestViewShell( const css::uno::Reference< css::uno::XComponentContext >& xContext ); SfxViewFrame* getViewFrame( const css::uno::Reference< css::frame::XModel >& xModel ); + css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::sheet::XSheetCellRangeContainer >& xRanges ) throw ( css::uno::RuntimeException ); + css::uno::Reference< ooo::vba::XHelperInterface > getUnoSheetModuleObj( const css::uno::Reference< css::table::XCellRange >& xRange ) throw ( css::uno::RuntimeException ); + ScDocShell* GetDocShellFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); + ScDocument* GetDocumentFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); + css::uno::Reference< css::frame::XModel > GetModelFromRange( const css::uno::Reference< css::uno::XInterface >& xRange ) throw ( css::uno::RuntimeException ); class ScVbaCellRangeAccess { public: diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index aea8d8bc11d4..1ed63ff39125 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -193,18 +193,47 @@ ScVbaApplication::hasProperty( const ::rtl::OUString& Name ) throw(uno::RuntimeE uno::Reference< excel::XWorkbook > ScVbaApplication::getActiveWorkbook() throw (uno::RuntimeException) { - return new ActiveWorkbook( this, mxContext ); + uno::Reference< excel::XWorkbook > xWrkbk; + ScDocShell* pShell = excel::getDocShell( getCurrentExcelDoc( mxContext ) ); + if ( pShell ) + { + String aName; + if ( pShell->GetDocument() ) + { + aName = pShell->GetDocument()->GetCodeName(); + xWrkbk.set( getUnoDocModule( aName, pShell ), uno::UNO_QUERY ); + // fallback ( e.g. it's possible a new document was created via the api ) + // in that case the document will not have the appropriate Document Modules + // #TODO #FIXME ( needs to be fixes as part of providing support for an overall document + // vba mode etc. ) + if ( !xWrkbk.is() ) + return new ActiveWorkbook( this, mxContext ); + } + } + return xWrkbk; } uno::Reference< excel::XWorkbook > SAL_CALL ScVbaApplication::getThisWorkbook() throw (uno::RuntimeException) { - uno::Reference< frame::XModel > xModel = getThisExcelDoc(mxContext); - if( !xModel.is() ) - return uno::Reference< excel::XWorkbook >(); - - ScVbaWorkbook *pWb = new ScVbaWorkbook( this, mxContext, xModel ); - return uno::Reference< excel::XWorkbook > (pWb); + uno::Reference< excel::XWorkbook > xWrkbk; + ScDocShell* pShell = excel::getDocShell( getThisExcelDoc( mxContext ) ); + if ( pShell ) + { + String aName; + if ( pShell->GetDocument() ) + { + aName = pShell->GetDocument()->GetCodeName(); + xWrkbk.set( getUnoDocModule( aName, pShell ), uno::UNO_QUERY ); + // fallback ( e.g. it's possible a new document was created via the api ) + // in that case the document will not have the appropriate Document Modules + // #TODO #FIXME ( needs to be fixes as part of providing support for an overall document + // vba mode etc. ) + if ( !xWrkbk.is() ) + return new ActiveWorkbook( this, mxContext ); + } + } + return xWrkbk; } uno::Reference< XAssistant > SAL_CALL @@ -246,10 +275,10 @@ ScVbaApplication::getSelection() throw (uno::RuntimeException) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( getCurrentDocument()->getCurrentSelection(), ::uno::UNO_QUERY); if ( xRanges.is() ) - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( this, mxContext, xRanges ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges ) ) ); } - return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( this, mxContext, xRange ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >(new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange ) ) ); } else { @@ -531,10 +560,8 @@ ScVbaApplication::GoTo( const uno::Any& Reference, const uno::Any& Scroll ) thro ScGridWindow* gridWindow = (ScGridWindow*)pShell->GetWindow(); try { - // FIXME: pass proper Worksheet parent uno::Reference< excel::XRange > xVbaSheetRange = ScVbaRange::getRangeObjectForName( - uno::Reference< XHelperInterface >(), mxContext, sRangeName, - excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); + mxContext, sRangeName, excel::getDocShell( xModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); if( bScroll ) { @@ -1068,12 +1095,13 @@ ScVbaApplication::Intersect( const uno::Reference< excel::XRange >& Arg1, const ScDocShell* pDocShell = excel::getDocShell( xModel ); if ( aCellRanges.Count() == 1 ) { - xRefRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); + uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() )); + xRefRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), mxContext, xRange ); } else if ( aCellRanges.Count() > 1 ) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) ); - xRefRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xRanges ); + xRefRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ) , mxContext, xRanges ); } return xRefRange; @@ -1158,12 +1186,13 @@ ScVbaApplication::Union( const uno::Reference< excel::XRange >& Arg1, const uno: if ( aCellRanges.Count() == 1 ) { // normal range - xRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); + uno::Reference< table::XCellRange > xCalcRange( new ScCellRangeObj( pDocShell, *aCellRanges.First() ) ); + xRange = new ScVbaRange( excel::getUnoSheetModuleObj( xCalcRange ), mxContext, xCalcRange ); } else if ( aCellRanges.Count() > 1 ) // Multi-Area { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocShell, aCellRanges ) ); - xRange = new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xRanges ); + xRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRanges ), mxContext, xRanges ); } // #FIXME need proper (WorkSheet) parent diff --git a/sc/source/ui/vba/vbachartobjects.cxx b/sc/source/ui/vba/vbachartobjects.cxx index 41b26501f4ad..5117cfd75858 100644 --- a/sc/source/ui/vba/vbachartobjects.cxx +++ b/sc/source/ui/vba/vbachartobjects.cxx @@ -47,16 +47,15 @@ using namespace ::ooo::vba; class ChartObjectEnumerationImpl : public EnumerationHelperImpl { uno::Reference< drawing::XDrawPageSupplier > xDrawPageSupplier; - uno::Reference< XHelperInterface > xParent; public: - ChartObjectEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< drawing::XDrawPageSupplier >& _xDrawPageSupplier, const uno::Reference< XHelperInterface >& _xParent ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), xDrawPageSupplier( _xDrawPageSupplier ), xParent( _xParent ) {} + ChartObjectEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< drawing::XDrawPageSupplier >& _xDrawPageSupplier, const uno::Reference< XHelperInterface >& _xParent ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( _xParent, xContext, xEnumeration ), xDrawPageSupplier( _xDrawPageSupplier ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< table::XTableChart > xTableChart( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); // parent Object is sheet - return uno::makeAny( uno::Reference< excel::XChartObject > ( new ScVbaChartObject( xParent, m_xContext, xTableChart, xDrawPageSupplier ) ) ); + return uno::makeAny( uno::Reference< excel::XChartObject > ( new ScVbaChartObject( m_xParent, m_xContext, xTableChart, xDrawPageSupplier ) ) ); } }; diff --git a/sc/source/ui/vba/vbacomments.cxx b/sc/source/ui/vba/vbacomments.cxx index a68dd4245741..93ba4ae84293 100644 --- a/sc/source/ui/vba/vbacomments.cxx +++ b/sc/source/ui/vba/vbacomments.cxx @@ -50,10 +50,11 @@ class CommentEnumeration : public EnumerationHelperImpl css::uno::Reference< css::frame::XModel > mxModel; public: CommentEnumeration( + const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : - EnumerationHelperImpl( xContext, xEnumeration ), + EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel( xModel, uno::UNO_SET_THROW ) {} @@ -81,7 +82,7 @@ ScVbaComments::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new CommentEnumeration( mxContext, xEnumAccess->createEnumeration(), mxModel ); + return new CommentEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration(), mxModel ); } uno::Any diff --git a/sc/source/ui/vba/vbaformatconditions.cxx b/sc/source/ui/vba/vbaformatconditions.cxx index 91d0429326dd..b79129d18387 100644 --- a/sc/source/ui/vba/vbaformatconditions.cxx +++ b/sc/source/ui/vba/vbaformatconditions.cxx @@ -48,8 +48,8 @@ static rtl::OUString sStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM("Excel_CondFo ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& xModel ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries ) { mxRangeParent.set( xParent, uno::UNO_QUERY_THROW ); - uno::Reference< excel::XWorkbook > xWorkbook = new ScVbaWorkbook( uno::Reference< XHelperInterface >( Application(), uno::UNO_QUERY_THROW ), xContext, xModel ); - mxStyles.set( xWorkbook->Styles( uno::Any() ), uno::UNO_QUERY_THROW ); + uno::Reference< excel::XApplication> xApp( Application(), uno::UNO_QUERY_THROW ); + mxStyles.set( xApp->getThisWorkbook()->Styles( uno::Any() ), uno::UNO_QUERY_THROW ); uno::Reference< sheet::XCellRangeAddressable > xCellRange( mxRangeParent->getCellRange(), uno::UNO_QUERY_THROW ); mxParentRangePropertySet.set( xCellRange, uno::UNO_QUERY_THROW ); diff --git a/sc/source/ui/vba/vbaname.cxx b/sc/source/ui/vba/vbaname.cxx index a6e8a402425f..464b167df250 100644 --- a/sc/source/ui/vba/vbaname.cxx +++ b/sc/source/ui/vba/vbaname.cxx @@ -232,10 +232,8 @@ ScVbaName::setRefersToR1C1Local( const ::rtl::OUString & rRefersTo ) throw (css: css::uno::Reference< ov::excel::XRange > ScVbaName::getRefersToRange() throw (css::uno::RuntimeException) { - // FIXME: pass proper Worksheet parent uno::Reference< ov::excel::XRange > xRange = ScVbaRange::getRangeObjectForName( - uno::Reference< XHelperInterface >(), mxContext, - mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); + mxContext, mxNamedRange->getName(), excel::getDocShell( mxModel ), formula::FormulaGrammar::CONV_XL_R1C1 ); return xRange; } diff --git a/sc/source/ui/vba/vbanames.cxx b/sc/source/ui/vba/vbanames.cxx index d074f32b689d..2304874bdb1b 100644 --- a/sc/source/ui/vba/vbanames.cxx +++ b/sc/source/ui/vba/vbanames.cxx @@ -48,7 +48,7 @@ class NamesEnumeration : public EnumerationHelperImpl uno::WeakReference< XHelperInterface > m_xParent; uno::Reference< sheet::XNamedRanges > m_xNames; public: - NamesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel , const uno::Reference< sheet::XNamedRanges >& xNames ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ), m_xNames( xNames ) {} + NamesEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel , const uno::Reference< sheet::XNamedRanges >& xNames ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ), m_xNames( xNames ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { diff --git a/sc/source/ui/vba/vbapivottables.cxx b/sc/source/ui/vba/vbapivottables.cxx index 05a4201da977..fcbf347a3cd4 100644 --- a/sc/source/ui/vba/vbapivottables.cxx +++ b/sc/source/ui/vba/vbapivottables.cxx @@ -42,7 +42,7 @@ uno::Any DataPilotToPivotTable( const uno::Any& aSource, uno::Reference< uno::XC class PivotTableEnumeration : public EnumerationHelperImpl { public: - PivotTableEnumeration( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ) {} + PivotTableEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { @@ -59,7 +59,7 @@ uno::Reference< container::XEnumeration > ScVbaPivotTables::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new PivotTableEnumeration( mxContext, xEnumAccess->createEnumeration() ); + return new PivotTableEnumeration( mxParent, mxContext, xEnumAccess->createEnumeration() ); } uno::Any diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx old mode 100644 new mode 100755 index 71d29734fc76..a973e28b76b0 --- a/sc/source/ui/vba/vbarange.cxx +++ b/sc/source/ui/vba/vbarange.cxx @@ -202,11 +202,10 @@ double lcl_Round2DecPlaces( double nVal ) return nVal; } -uno::Any lcl_makeRange( uno::Reference< uno::XComponentContext >& xContext, const uno::Any aAny, bool bIsRows, bool bIsColumns ) +uno::Any lcl_makeRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Any aAny, bool bIsRows, bool bIsColumns ) { uno::Reference< table::XCellRange > xCellRange( aAny, uno::UNO_QUERY_THROW ); - // #FIXME need proper (WorkSheet) parent - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xCellRange, bIsRows, bIsColumns ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xCellRange, bIsRows, bIsColumns ) ) ); } uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSheetCellRanges >& xLocSheetCellRanges, ScDocShell* pDoc ) @@ -227,13 +226,11 @@ uno::Reference< excel::XRange > lcl_makeXRangeFromSheetCellRanges( const uno::Re if ( aCellRanges.First() == aCellRanges.Last() ) { uno::Reference< table::XCellRange > xTmpRange( new ScCellRangeObj( pDoc, *aCellRanges.First() ) ); - // #FIXME need proper (WorkSheet) parent xRange = new ScVbaRange( xParent, xContext, xTmpRange ); } else { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDoc, aCellRanges ) ); - // #FIXME need proper (WorkSheet) parent xRange = new ScVbaRange( xParent, xContext, xRanges ); } } @@ -269,12 +266,13 @@ SfxItemSet* ScVbaRange::getCurrentDataSet( ) throw ( uno::RuntimeException ) class SingleRangeEnumeration : public EnumerationHelper_BASE { + uno::Reference< XHelperInterface > m_xParent; uno::Reference< table::XCellRange > m_xRange; uno::Reference< uno::XComponentContext > mxContext; bool bHasMore; public: - SingleRangeEnumeration( const uno::Reference< css::uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) : m_xRange( xRange ), mxContext( xContext ), bHasMore( true ) { } + SingleRangeEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< css::uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ) throw ( uno::RuntimeException ) : m_xParent( xParent ), m_xRange( xRange ), mxContext( xContext ), bHasMore( true ) { } virtual ::sal_Bool SAL_CALL hasMoreElements( ) throw (uno::RuntimeException) { return bHasMore; } virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { @@ -292,11 +290,12 @@ typedef ::cppu::WeakImplHelper2< container::XIndexAccess, container::XEnumeratio class SingleRangeIndexAccess : public SingleRange_BASE { private: + uno::Reference< XHelperInterface > mxParent; uno::Reference< table::XCellRange > m_xRange; uno::Reference< uno::XComponentContext > mxContext; SingleRangeIndexAccess(); // not defined public: - SingleRangeIndexAccess( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ):m_xRange( xRange ), mxContext( xContext ) {} + SingleRangeIndexAccess( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange ):mxParent( xParent ), m_xRange( xRange ), mxContext( xContext ) {} // XIndexAccess virtual ::sal_Int32 SAL_CALL getCount() throw (::uno::RuntimeException) { return 1; } virtual uno::Any SAL_CALL getByIndex( ::sal_Int32 Index ) throw (lang::IndexOutOfBoundsException, lang::WrappedTargetException, uno::RuntimeException) @@ -310,7 +309,7 @@ public: virtual ::sal_Bool SAL_CALL hasElements() throw (uno::RuntimeException) { return sal_True; } // XEnumerationAccess - virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException) { return new SingleRangeEnumeration( mxContext, m_xRange ); } + virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException) { return new SingleRangeEnumeration( mxParent, mxContext, m_xRange ); } }; @@ -322,10 +321,10 @@ class RangesEnumerationImpl : public EnumerationHelperImpl bool mbIsColumns; public: - RangesEnumerationImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, bool bIsRows, bool bIsColumns ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} + RangesEnumerationImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, bool bIsRows, bool bIsColumns ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { - return lcl_makeRange( m_xContext, m_xEnumeration->nextElement(), mbIsRows, mbIsColumns ); + return lcl_makeRange( m_xParent, m_xContext, m_xEnumeration->nextElement(), mbIsRows, mbIsColumns ); } }; @@ -335,7 +334,7 @@ class ScVbaRangeAreas : public ScVbaCollectionBaseImpl bool mbIsRows; bool mbIsColumns; public: - ScVbaRangeAreas( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, bool bIsRows, bool bIsColumns ) : ScVbaCollectionBaseImpl( uno::Reference< XHelperInterface >(), xContext, xIndexAccess ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} + ScVbaRangeAreas( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XIndexAccess >& xIndexAccess, bool bIsRows, bool bIsColumns ) : ScVbaCollectionBaseImpl( xParent, xContext, xIndexAccess ), mbIsRows( bIsRows ), mbIsColumns( bIsColumns ) {} // XEnumerationAccess virtual uno::Reference< container::XEnumeration > SAL_CALL createEnumeration() throw (uno::RuntimeException); @@ -355,14 +354,14 @@ uno::Reference< container::XEnumeration > SAL_CALL ScVbaRangeAreas::createEnumeration() throw (uno::RuntimeException) { uno::Reference< container::XEnumerationAccess > xEnumAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new RangesEnumerationImpl( mxContext, xEnumAccess->createEnumeration(), mbIsRows, mbIsColumns ); + return new RangesEnumerationImpl( mxParent, mxContext, xEnumAccess->createEnumeration(), mbIsRows, mbIsColumns ); } uno::Any ScVbaRangeAreas::createCollectionObject( const uno::Any& aSource ) { - return lcl_makeRange( mxContext, aSource, mbIsRows, mbIsColumns ); + return lcl_makeRange( mxParent, mxContext, aSource, mbIsRows, mbIsColumns ); } // assume that xIf is infact a ScCellRangesBase @@ -618,6 +617,7 @@ public: class CellsEnumeration : public CellsEnumeration_BASE { + uno::WeakReference< XHelperInterface > mxParent; uno::Reference< uno::XComponentContext > mxContext; uno::Reference< XCollection > m_xAreas; vCellPos m_CellPositions; @@ -645,7 +645,7 @@ class CellsEnumeration : public CellsEnumeration_BASE } } public: - CellsEnumeration( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCollection >& xAreas ): mxContext( xContext ), m_xAreas( xAreas ) + CellsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< XCollection >& xAreas ): mxParent( xParent ), mxContext( xContext ), m_xAreas( xAreas ) { sal_Int32 nItems = m_xAreas->getCount(); for ( sal_Int32 index=1; index <= nItems; ++index ) @@ -664,8 +664,7 @@ public: uno::Reference< table::XCellRange > xRangeArea = getArea( aPos.m_nArea ); uno::Reference< table::XCellRange > xCellRange( xRangeArea->getCellByPosition( aPos.m_nCol, aPos.m_nRow ), uno::UNO_QUERY_THROW ); - // #FIXME need proper (WorkSheet) parent - return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, xCellRange ) ) ); + return uno::makeAny( uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, xCellRange ) ) ); } }; @@ -1088,11 +1087,11 @@ public: return uno::Reference< sheet::XSheetCellCursor >( getSpreadSheet()->createCursorByRange( getSheetCellRange() ), uno::UNO_QUERY_THROW ); } - static uno::Reference< excel::XRange > createRangeFromRange( const uno::Reference& xContext, const uno::Reference< table::XCellRange >& xRange, const uno::Reference< sheet::XCellRangeAddressable >& xCellRangeAddressable, sal_Int32 nStartColOffset = 0, sal_Int32 nStartRowOffset = 0, - sal_Int32 nEndColOffset = 0, sal_Int32 nEndRowOffset = 0 ) + static uno::Reference< excel::XRange > createRangeFromRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference& xContext, + const uno::Reference< table::XCellRange >& xRange, const uno::Reference< sheet::XCellRangeAddressable >& xCellRangeAddressable, + sal_Int32 nStartColOffset = 0, sal_Int32 nStartRowOffset = 0, sal_Int32 nEndColOffset = 0, sal_Int32 nEndRowOffset = 0 ) { - // #FIXME need proper (WorkSheet) parent - return uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, + return uno::Reference< excel::XRange >( new ScVbaRange( xParent, xContext, xRange->getCellRangeByPosition( xCellRangeAddressable->getRangeAddress().StartColumn + nStartColOffset, xCellRangeAddressable->getRangeAddress().StartRow + nStartRowOffset, @@ -1178,7 +1177,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S ScVbaRange* -getRangeForName( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) +getRangeForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sName, ScDocShell* pDocSh, table::CellRangeAddress& pAddr, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( uno::RuntimeException ) { ScRangeList aCellRanges; ScRange refRange; @@ -1189,10 +1188,13 @@ getRangeForName( const uno::Reference< XHelperInterface >& xParent, const uno::R if ( aCellRanges.First() == aCellRanges.Last() ) { uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pDocSh, *aCellRanges.First() ) ); - return new ScVbaRange( xParent, xContext, xRange ); + uno::Reference< XHelperInterface > xFixThisParent = excel::getUnoSheetModuleObj( xRange ); + return new ScVbaRange( xFixThisParent, xContext, xRange ); } uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pDocSh, aCellRanges ) ); - return new ScVbaRange( xParent, xContext, xRanges ); + + uno::Reference< XHelperInterface > xFixThisParent = excel::getUnoSheetModuleObj( xRanges ); + return new ScVbaRange( xFixThisParent, xContext, xRanges ); } // ---------------------------------------------------------------------------- @@ -1284,12 +1286,12 @@ util::TriState lclGetMergedState( const uno::Reference< table::XCellRange >& rxC // ---------------------------------------------------------------------------- css::uno::Reference< excel::XRange > -ScVbaRange::getRangeObjectForName( const css::uno::Reference< ov::XHelperInterface >& xParent, +ScVbaRange::getRangeObjectForName( const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv ) throw ( uno::RuntimeException ) { table::CellRangeAddress refAddr; - return getRangeForName( xParent, xContext, sRangeName, pDocSh, refAddr, eConv ); + return getRangeForName( xContext, sRangeName, pDocSh, refAddr, eConv ); } @@ -1348,13 +1350,13 @@ ScVbaRange::ScVbaRange( uno::Sequence< uno::Any> const & args, uno::Reference< container::XIndexAccess > xIndex; if ( mxRange.is() ) { - xIndex = new SingleRangeIndexAccess( mxContext, mxRange ); + xIndex = new SingleRangeIndexAccess( mxParent, mxContext, mxRange ); } else if ( mxRanges.is() ) { xIndex.set( mxRanges, uno::UNO_QUERY_THROW ); } - m_Areas = new ScVbaRangeAreas( mxContext, xIndex, mbIsRows, mbIsColumns ); + m_Areas = new ScVbaRangeAreas( mxParent, mxContext, xIndex, mbIsRows, mbIsColumns ); } ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< table::XCellRange >& xRange, sal_Bool bIsRows, sal_Bool bIsColumns ) throw( lang::IllegalArgumentException ) @@ -1367,8 +1369,8 @@ ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const if ( !xRange.is() ) throw lang::IllegalArgumentException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "range is not set " ) ), uno::Reference< uno::XInterface >() , 1 ); - uno::Reference< container::XIndexAccess > xIndex( new SingleRangeIndexAccess( mxContext, xRange ) ); - m_Areas = new ScVbaRangeAreas( mxContext, xIndex, mbIsRows, mbIsColumns ); + uno::Reference< container::XIndexAccess > xIndex( new SingleRangeIndexAccess( mxParent, mxContext, xRange ) ); + m_Areas = new ScVbaRangeAreas( mxParent, mxContext, xIndex, mbIsRows, mbIsColumns ); } @@ -1377,7 +1379,7 @@ ScVbaRange::ScVbaRange( const uno::Reference< XHelperInterface >& xParent, const { uno::Reference< container::XIndexAccess > xIndex( mxRanges, uno::UNO_QUERY_THROW ); - m_Areas = new ScVbaRangeAreas( mxContext, xIndex, mbIsRows, mbIsColumns ); + m_Areas = new ScVbaRangeAreas( xParent, mxContext, xIndex, mbIsRows, mbIsColumns ); } @@ -1806,11 +1808,11 @@ ScVbaRange::Offset( const ::uno::Any &nRowOff, const uno::Any &nColOff ) throw ( if ( aCellRanges.Count() > 1 ) // Multi-Area { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pUnoRangesBase->GetDocShell(), aCellRanges ) ); - return new ScVbaRange( getParent(), mxContext, xRanges ); + return new ScVbaRange( mxParent, mxContext, xRanges ); } // normal range uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), *aCellRanges.First() ) ); - return new ScVbaRange( getParent(), mxContext, xRange ); + return new ScVbaRange( mxParent, mxContext, xRange ); } uno::Reference< excel::XRange > @@ -1831,7 +1833,7 @@ ScVbaRange::CurrentRegion() throw (uno::RuntimeException) helper.getSheetCellCursor(); xSheetCellCursor->collapseToCurrentRegion(); uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW); - return RangeHelper::createRangeFromRange( mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); + return RangeHelper::createRangeFromRange( mxParent, mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); } uno::Reference< excel::XRange > @@ -1851,7 +1853,7 @@ ScVbaRange::CurrentArray() throw (uno::RuntimeException) helper.getSheetCellCursor(); xSheetCellCursor->collapseToCurrentArray(); uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xSheetCellCursor, uno::UNO_QUERY_THROW); - return RangeHelper::createRangeFromRange( mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); + return RangeHelper::createRangeFromRange( mxParent, mxContext, helper.getCellRangeFromSheet(), xCellRangeAddressable ); } uno::Any @@ -2069,7 +2071,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr uno::Reference< table::XCellRange > xSheetRange = thisRange.getCellRangeFromSheet(); if( !bIsIndex && !bIsColumnIndex ) // .Cells // #FIXE needs proper parent ( Worksheet ) - return uno::Reference< excel::XRange >( new ScVbaRange( uno::Reference< XHelperInterface >(), mxContext, mxRange ) ); + return uno::Reference< excel::XRange >( new ScVbaRange( mxParent, mxContext, mxRange ) ); sal_Int32 nIndex = --nRow; if( bIsIndex && !bIsColumnIndex ) // .Cells(n) @@ -2087,7 +2089,7 @@ ScVbaRange::Cells( const uno::Any &nRowIndex, const uno::Any &nColumnIndex ) thr --nColumn; nRow = nRow + thisRangeAddress.StartRow; nColumn = nColumn + thisRangeAddress.StartColumn; - return new ScVbaRange( getParent(), mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); + return new ScVbaRange( mxParent, mxContext, xSheetRange->getCellRangeByPosition( nColumn, nRow, nColumn, nRow ) ); } void @@ -2239,12 +2241,12 @@ ScVbaRange::Rows(const uno::Any& aIndex ) throw (uno::RuntimeException) throw uno::RuntimeException( rtl::OUString::createFromAscii("Internal failure, illegal param"), uno::Reference< uno::XInterface >() ); // return a normal range ( even for multi-selection uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), aRange ) ); - return new ScVbaRange( getParent(), mxContext, xRange, true ); + return new ScVbaRange( mxParent, mxContext, xRange, true ); } // Rows() - no params if ( m_Areas->getCount() > 1 ) - return new ScVbaRange( getParent(), mxContext, mxRanges, true ); - return new ScVbaRange( getParent(), mxContext, mxRange, true ); + return new ScVbaRange( mxParent, mxContext, mxRanges, true ); + return new ScVbaRange( mxParent, mxContext, mxRange, true ); } uno::Reference< excel::XRange > @@ -2286,9 +2288,8 @@ ScVbaRange::Columns(const uno::Any& aIndex ) throw (uno::RuntimeException) throw uno::RuntimeException( rtl::OUString::createFromAscii("Internal failure, illegal param"), uno::Reference< uno::XInterface >() ); } // Columns() - no params - //return new ScVbaRange( getParent(), mxContext, mxRange, false, true ); uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), aRange ) ); - return new ScVbaRange( getParent(), mxContext, xRange, false, true ); + return new ScVbaRange( mxParent, mxContext, xRange, false, true ); } void @@ -2473,7 +2474,7 @@ ScVbaRange::Resize( const uno::Any &RowSize, const uno::Any &ColumnSize ) throw xCursor->collapseToSize( nColumnSize, nRowSize ); uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable(xCursor, ::uno::UNO_QUERY_THROW ); uno::Reference< table::XCellRange > xRange( xSheetRange->getSpreadsheet(), ::uno::UNO_QUERY_THROW ); - return new ScVbaRange( getParent(), mxContext,xRange->getCellRangeByPosition( + return new ScVbaRange( mxParent, mxContext,xRange->getCellRangeByPosition( xCellRangeAddressable->getRangeAddress().StartColumn, xCellRangeAddressable->getRangeAddress().StartRow, xCellRangeAddressable->getRangeAddress().EndColumn, @@ -2580,7 +2581,7 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI Cell1 >>= sName; RangeHelper referRange( xReferrer ); table::CellRangeAddress referAddress = referRange.getCellRangeAddressable()->getRangeAddress(); - return getRangeForName( getParent(), mxContext, sName, getScDocShell(), referAddress ); + return getRangeForName( mxContext, sName, getScDocShell(), referAddress ); } else @@ -2637,7 +2638,7 @@ ScVbaRange::Range( const uno::Any &Cell1, const uno::Any &Cell2, bool bForceUseI } } - return new ScVbaRange( getParent(), mxContext, xCellRange ); + return new ScVbaRange( mxParent, mxContext, xCellRange ); } @@ -2772,10 +2773,10 @@ ScVbaRange::getEntireColumnOrRow( bool bColumn ) throw (uno::RuntimeException) { uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( pUnoRangesBase->GetDocShell(), aCellRanges ) ); - return new ScVbaRange( getParent(), mxContext, xRanges, !bColumn, bColumn ); + return new ScVbaRange( mxParent, mxContext, xRanges, !bColumn, bColumn ); } uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( pUnoRangesBase->GetDocShell(), *aCellRanges.First() ) ); - return new ScVbaRange( getParent(), mxContext, xRange, !bColumn, bColumn ); + return new ScVbaRange( mxParent, mxContext, xRange, !bColumn, bColumn ); } uno::Reference< excel::XRange > SAL_CALL @@ -3121,7 +3122,7 @@ ScVbaRange::Find( const uno::Any& What, const uno::Any& After, const uno::Any& L uno::Reference< table::XCellRange > xCellRange( xInterface, uno::UNO_QUERY ); if ( xCellRange.is() ) { - uno::Reference< excel::XRange > xResultRange = new ScVbaRange( this, mxContext, xCellRange ); + uno::Reference< excel::XRange > xResultRange = new ScVbaRange( mxParent, mxContext, xCellRange ); if( xResultRange.is() ) { xResultRange->Select(); @@ -3148,7 +3149,7 @@ uno::Reference< table::XCellRange > processKey( const uno::Any& Key, uno::Refere table::CellRangeAddress aRefAddr; if ( !pDocSh ) throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort no docshell to calculate key param")), uno::Reference< uno::XInterface >() ); - xKeyRange = getRangeForName( uno::Reference< XHelperInterface >(), xContext, sRangeName, pDocSh, aRefAddr ); + xKeyRange = getRangeForName( xContext, sRangeName, pDocSh, aRefAddr ); } else throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Range::Sort illegal type value for key param")), uno::Reference< uno::XInterface >() ); @@ -3582,7 +3583,7 @@ ScVbaRange::createEnumeration() throw (uno::RuntimeException) return new ColumnsRowEnumeration( mxContext, xRange, nElems ); } - return new CellsEnumeration( mxContext, m_Areas ); + return new CellsEnumeration( mxParent, mxContext, m_Areas ); } ::rtl::OUString SAL_CALL @@ -4073,15 +4074,14 @@ ScVbaRange::ApplicationRange( const uno::Reference< uno::XComponentContext >& xC uno::Reference< table::XCellRange > xRange = xReferrer->getReferredCells(); if ( xRange.is() ) { - // #FIXME need proper (WorkSheet) parent - uno::Reference< excel::XRange > xVbRange = new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xRange ); + uno::Reference< excel::XRange > xVbRange = new ScVbaRange( excel::getUnoSheetModuleObj( xRange ), xContext, xRange ); return xVbRange; } } } uno::Reference< sheet::XSpreadsheetView > xView( getCurrentExcelDoc(xContext)->getCurrentController(), uno::UNO_QUERY ); uno::Reference< table::XCellRange > xSheetRange( xView->getActiveSheet(), uno::UNO_QUERY_THROW ); - ScVbaRange* pRange = new ScVbaRange( uno::Reference< XHelperInterface >(), xContext, xSheetRange ); + ScVbaRange* pRange = new ScVbaRange( excel::getUnoSheetModuleObj( xSheetRange ), xContext, xSheetRange ); uno::Reference< excel::XRange > xVbSheetRange( pRange ); return pRange->Range( Cell1, Cell2, true ); } @@ -4569,7 +4569,7 @@ ScVbaRange::Insert( const uno::Any& Shift, const uno::Any& CopyOrigin ) throw (u // After the insert ( this range ) actually has moved ScRange aRange( static_cast< SCCOL >( thisAddress.StartColumn ), static_cast< SCROW >( thisAddress.StartRow ), static_cast< SCTAB >( thisAddress.Sheet ), static_cast< SCCOL >( thisAddress.EndColumn ), static_cast< SCROW >( thisAddress.EndRow ), static_cast< SCTAB >( thisAddress.Sheet ) ); uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getDocShellFromRange( mxRange ) , aRange ) ); - uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( getParent(), mxContext, xRange, mbIsRows, mbIsColumns ) ); + uno::Reference< excel::XRange > xVbaRange( new ScVbaRange( mxParent, mxContext, xRange, mbIsRows, mbIsColumns ) ); xVbaRange->PasteSpecial( uno::Any(), uno::Any(), uno::Any(), uno::Any() ); } } @@ -4955,18 +4955,18 @@ ScVbaRange::MergeArea() throw (script::BasicErrorException, uno::RuntimeExceptio if( aCellAddress.StartColumn ==0 && aCellAddress.EndColumn==0 && aCellAddress.StartRow==0 && aCellAddress.EndRow==0) { - return new ScVbaRange( getParent(),mxContext,mxRange ); + return new ScVbaRange( mxParent,mxContext,mxRange ); } else { ScRange refRange( static_cast< SCCOL >( aCellAddress.StartColumn ), static_cast< SCROW >( aCellAddress.StartRow ), static_cast< SCTAB >( aCellAddress.Sheet ), static_cast< SCCOL >( aCellAddress.EndColumn ), static_cast< SCROW >( aCellAddress.EndRow ), static_cast< SCTAB >( aCellAddress.Sheet ) ); uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell() , refRange ) ); - return new ScVbaRange( getParent(),mxContext,xRange ); + return new ScVbaRange( mxParent, mxContext,xRange ); } } } - return new ScVbaRange( getParent(),mxContext,mxRange ); + return new ScVbaRange( mxParent, mxContext, mxRange ); } void SAL_CALL @@ -5359,7 +5359,7 @@ ScVbaRange::PreviousNext( bool bIsPrevious ) uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell() , refRange ) ); - return new ScVbaRange( getParent(), mxContext, xRange ); + return new ScVbaRange( mxParent, mxContext, xRange ); } uno::Reference< excel::XRange > SAL_CALL @@ -5442,13 +5442,11 @@ ScVbaRange::SpecialCells( const uno::Any& _oType, const uno::Any& _oValue) throw if ( aCellRanges.First() == aCellRanges.Last() ) { uno::Reference< table::XCellRange > xRange( new ScCellRangeObj( getScDocShell(), *aCellRanges.First() ) ); - // #FIXME need proper (WorkSheet) parent - return new ScVbaRange( getParent(), mxContext, xRange ); + return new ScVbaRange( mxParent, mxContext, xRange ); } uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( getScDocShell(), aCellRanges ) ); - // #FIXME need proper (WorkSheet) parent - return new ScVbaRange( getParent(), mxContext, xRanges ); + return new ScVbaRange( mxParent, mxContext, xRanges ); } else if ( bIsSingleCell ) { diff --git a/sc/source/ui/vba/vbarange.hxx b/sc/source/ui/vba/vbarange.hxx index a9147a0d7840..e7488e434f30 100644 --- a/sc/source/ui/vba/vbarange.hxx +++ b/sc/source/ui/vba/vbarange.hxx @@ -145,7 +145,6 @@ public: bool isSingleCellRange(); static css::uno::Reference< ov::excel::XRange > getRangeObjectForName( - const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sRangeName, ScDocShell* pDocSh, formula::FormulaGrammar::AddressConvention eConv = formula::FormulaGrammar::CONV_XL_A1 ) throw ( css::uno::RuntimeException ); diff --git a/sc/source/ui/vba/vbaworkbooks.cxx b/sc/source/ui/vba/vbaworkbooks.cxx index 9f9c5dacd796..3e1e91c62f19 100644 --- a/sc/source/ui/vba/vbaworkbooks.cxx +++ b/sc/source/ui/vba/vbaworkbooks.cxx @@ -46,6 +46,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -56,21 +60,100 @@ #include #include +#include #include using namespace ::ooo::vba; using namespace ::com::sun::star; const sal_Int16 CUSTOM_CHAR = 5; +void setUpDocumentModules( const uno::Reference< sheet::XSpreadsheetDocument >& xDoc ) +{ + uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); + ScDocShell* pShell = excel::getDocShell( xModel ); + if ( pShell ) + { + uno::Reference xLibContainer = pShell->GetBasicContainer(); + uno::Reference xVBACompat( xLibContainer, uno::UNO_QUERY_THROW ); + xVBACompat->setVBACompatModeOn( sal_True ); + String aPrjName( RTL_CONSTASCII_USTRINGPARAM( "VBAProject" ) ); + pShell->GetBasicManager()->SetName( aPrjName ); + + if( xLibContainer.is() ) + { + if( !xLibContainer->hasByName( aPrjName ) ) + xLibContainer->createLibrary( aPrjName ); + uno::Any aLibAny = xLibContainer->getByName( aPrjName ); + uno::Reference< container::XNameContainer > xLib; + aLibAny >>= xLib; + if( xLib.is() ) + { + uno::Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib, uno::UNO_QUERY_THROW ); + uno::Reference< lang::XMultiServiceFactory> xSF( pShell->GetModel(), uno::UNO_QUERY_THROW); + // bootstrap vbaglobals + xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals"))); + uno::Reference< container::XNameAccess > xVBACodeNamedObjectAccess( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider"))), uno::UNO_QUERY_THROW ); + // set up the module info for the workbook and sheets in the nealy created + // spreadsheet + ScDocument* pDoc = pShell->GetDocument(); + String sCodeName = pDoc->GetCodeName(); + if ( sCodeName.Len() == 0 ) + { + sCodeName = String( RTL_CONSTASCII_USTRINGPARAM("ThisWorkbook") ); + pDoc->SetCodeName( sCodeName ); + } + + std::vector< rtl::OUString > sDocModuleNames; + sDocModuleNames.push_back( sCodeName ); + + uno::Reference xSheets( xDoc->getSheets(), uno::UNO_QUERY_THROW ); + uno::Sequence< rtl::OUString > sSheets( xSheets->getElementNames() ); + + for ( sal_Int32 index=0; index < sSheets.getLength() ; ++index ) + { + sDocModuleNames.push_back( sSheets[ index ] ); + } + + std::vector::iterator it_end = sDocModuleNames.end(); + + for ( std::vector::iterator it = sDocModuleNames.begin(); it != it_end; ++it ) + { + script::ModuleInfo sModuleInfo; + + sModuleInfo.ModuleObject.set( xVBACodeNamedObjectAccess->getByName( *it ), uno::UNO_QUERY ); + sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; + xVBAModuleInfo->insertModuleInfo( *it, sModuleInfo ); + if( xLib->hasByName( *it ) ) + xLib->replaceByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n") ) ) ); + else + xLib->insertByName( *it, uno::makeAny( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Option VBASupport 1\n" ) ) ) ); + } + } + } + } +} + static uno::Any -getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Any& aApplication ) +getWorkbook( uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< sheet::XSpreadsheetDocument > &xDoc, const uno::Reference< XHelperInterface >& xParent ) { // FIXME: fine as long as ScVbaWorkbook is stateless ... uno::Reference< frame::XModel > xModel( xDoc, uno::UNO_QUERY ); if( !xModel.is() ) return uno::Any(); - ScVbaWorkbook *pWb = new ScVbaWorkbook( uno::Reference< XHelperInterface >( aApplication, uno::UNO_QUERY_THROW ), xContext, xModel ); + ScDocShell* pShell = excel::getDocShell( xModel ); + if ( pShell ) + { + String sCodeName = pShell->GetDocument()->GetCodeName(); + uno::Reference< uno::XInterface > xIf = getUnoDocModule( sCodeName, pShell ); + if ( xIf.is() ) + { + OSL_TRACE(" *** Returning Module uno Object *** "); + return uno::makeAny( xIf ); + } + } + + ScVbaWorkbook *pWb = new ScVbaWorkbook( xParent, xContext, xModel ); return uno::Any( uno::Reference< excel::XWorkbook > (pWb) ); } @@ -78,12 +161,12 @@ class WorkBookEnumImpl : public EnumerationHelperImpl { uno::Any m_aApplication; public: - WorkBookEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_aApplication( aApplication ) {} + WorkBookEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< sheet::XSpreadsheetDocument > xDoc( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return getWorkbook( m_xContext, xDoc, m_aApplication ); + return getWorkbook( m_xContext, xDoc, m_xParent ); } }; @@ -105,14 +188,14 @@ ScVbaWorkbooks::createEnumeration() throw (uno::RuntimeException) // safer to create an enumeration based on this objects state // rather than one effectively based of the desktop component uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new WorkBookEnumImpl( mxContext, xEnumerationAccess->createEnumeration(), Application() ); + return new WorkBookEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() ); } uno::Any ScVbaWorkbooks::createCollectionObject( const css::uno::Any& aSource ) { uno::Reference< sheet::XSpreadsheetDocument > xDoc( aSource, uno::UNO_QUERY_THROW ); - return getWorkbook( mxContext, xDoc, Application() ); + return getWorkbook( mxContext, xDoc, mxParent ); } @@ -121,8 +204,10 @@ ScVbaWorkbooks::Add() throw (uno::RuntimeException) { uno::Reference xSpreadDoc( VbaDocumentsBase::Add() , uno::UNO_QUERY_THROW ); + // need to set up the document modules ( and vba mode ) here + setUpDocumentModules( xSpreadDoc ); if( xSpreadDoc.is() ) - return getWorkbook( mxContext, xSpreadDoc, Application() ); + return getWorkbook( mxContext, xSpreadDoc, mxParent ); return uno::Any(); } @@ -249,7 +334,7 @@ ScVbaWorkbooks::Open( const rtl::OUString& rFileName, const uno::Any& /*UpdateLi throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Bad Format")), uno::Reference< uno::XInterface >() ); uno::Reference xSpreadDoc( VbaDocumentsBase::Open( rFileName, ReadOnly, sProps ), uno::UNO_QUERY_THROW ); - uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, Application() ); + uno::Any aRet = getWorkbook( mxContext, xSpreadDoc, mxParent ); uno::Reference< excel::XWorkbook > xWBook( aRet, uno::UNO_QUERY ); if ( xWBook.is() ) xWBook->Activate(); diff --git a/sc/source/ui/vba/vbaworksheets.cxx b/sc/source/ui/vba/vbaworksheets.cxx index 60cf7b904026..5344e6b3a9be 100644 --- a/sc/source/ui/vba/vbaworksheets.cxx +++ b/sc/source/ui/vba/vbaworksheets.cxx @@ -52,6 +52,7 @@ #include "vbaglobals.hxx" #include "vbaworksheet.hxx" #include "vbaworkbook.hxx" +#include using namespace ::ooo::vba; using namespace ::com::sun::star; @@ -63,6 +64,27 @@ typedef ::cppu::WeakImplHelper3< container::XNameAccess, container::XIndexAccess // (as added ) of the items typedef std::vector< uno::Reference< sheet::XSpreadsheet > > SheetMap; + +// #FIXME #TODO the implementation of the Sheets collections sucks, +// e.g. there is no support for tracking sheets added/removed from the collection + +uno::Reference< uno::XInterface > +lcl_getModulAsUnoObject( const uno::Reference< sheet::XSpreadsheet >& xSheet, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) +{ + uno::Reference< uno::XInterface > xRet; + if ( !xSheet.is() ) + throw uno::RuntimeException(); + uno::Reference< beans::XPropertySet > xProps( xSheet, uno::UNO_QUERY_THROW ); + rtl::OUString sName; + xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SC_UNO_CODENAME ) ) ) >>= sName; + + ScDocShell* pShell = excel::getDocShell( xModel ); + + if ( pShell ) + xRet = getUnoDocModule( sName, pShell ); + return xRet; +} + class WorkSheetsEnumeration : public SheetEnumeration_BASE { SheetMap mSheetMap; @@ -145,14 +167,24 @@ public: class SheetsEnumeration : public EnumerationHelperImpl { uno::Reference< frame::XModel > m_xModel; - uno::WeakReference< XHelperInterface > m_xParent; public: - SheetsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_xModel( xModel ), m_xParent( xParent ) {} + SheetsEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_xModel( xModel ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< sheet::XSpreadsheet > xSheet( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( m_xParent, m_xContext, xSheet, m_xModel ) ) ); + uno::Reference< uno::XInterface > xIf = lcl_getModulAsUnoObject( xSheet, m_xModel ); + uno::Any aRet; + if ( !xIf.is() ) + { + // if the Sheet is in a document created by the api unfortunately ( at the + // moment, it actually wont have the special Document modules + uno::Reference< excel::XWorksheet > xNewSheet( new ScVbaWorksheet( m_xParent, m_xContext, xSheet, m_xModel ) ); + aRet <<= xNewSheet; + } + else + aRet <<= xIf; + return aRet; } }; @@ -188,7 +220,18 @@ uno::Any ScVbaWorksheets::createCollectionObject( const uno::Any& aSource ) { uno::Reference< sheet::XSpreadsheet > xSheet( aSource, uno::UNO_QUERY ); - return uno::makeAny( uno::Reference< excel::XWorksheet > ( new ScVbaWorksheet( getParent(), mxContext, xSheet, mxModel ) ) ); + uno::Reference< XInterface > xIf = lcl_getModulAsUnoObject( xSheet, mxModel ); + uno::Any aRet; + if ( !xIf.is() ) + { + // if the Sheet is in a document created by the api unfortunately ( at the + // moment, it actually wont have the special Document modules + uno::Reference< excel::XWorksheet > xNewSheet( new ScVbaWorksheet( getParent(), mxContext, xSheet, mxModel ) ); + aRet <<= xNewSheet; + } + else + aRet <<= xIf; + return aRet; } // XWorksheets -- cgit v1.2.3 From 3ffd1ec05a64175f404aad0b9e92b2906070c7bd Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Thu, 1 Jul 2010 16:23:26 +0200 Subject: mib17: #111144# Enable calls to module function via Sheet object --- sw/source/ui/vba/vbabookmarks.cxx | 5 ++--- sw/source/ui/vba/vbadocuments.cxx | 4 ++-- sw/source/ui/vba/vbasections.cxx | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sw/source/ui/vba/vbabookmarks.cxx b/sw/source/ui/vba/vbabookmarks.cxx index c17c9f50f422..609b8f9df767 100644 --- a/sw/source/ui/vba/vbabookmarks.cxx +++ b/sw/source/ui/vba/vbabookmarks.cxx @@ -41,15 +41,14 @@ using namespace ::com::sun::star; class BookmarksEnumeration : public EnumerationHelperImpl { uno::Reference< frame::XModel > mxModel; - uno::WeakReference< XHelperInterface > mxParent; public: - BookmarksEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), mxModel( xModel ), mxParent( xParent ) {} + BookmarksEnumeration( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel( xModel ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< container::XNamed > xNamed( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); rtl::OUString aName = xNamed->getName(); - return uno::makeAny( uno::Reference< word::XBookmark > ( new SwVbaBookmark( mxParent, m_xContext, mxModel, aName ) ) ); + return uno::makeAny( uno::Reference< word::XBookmark > ( new SwVbaBookmark( m_xParent, m_xContext, mxModel, aName ) ) ); } }; diff --git a/sw/source/ui/vba/vbadocuments.cxx b/sw/source/ui/vba/vbadocuments.cxx index 8ee1e9880b7a..41a7e607533e 100644 --- a/sw/source/ui/vba/vbadocuments.cxx +++ b/sw/source/ui/vba/vbadocuments.cxx @@ -76,7 +76,7 @@ class DocumentEnumImpl : public EnumerationHelperImpl { uno::Any m_aApplication; public: - DocumentEnumImpl( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), m_aApplication( aApplication ) {} + DocumentEnumImpl( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Any& aApplication ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), m_aApplication( aApplication ) {} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { @@ -102,7 +102,7 @@ SwVbaDocuments::createEnumeration() throw (uno::RuntimeException) // safer to create an enumeration based on this objects state // rather than one effectively based of the desktop component uno::Reference< container::XEnumerationAccess > xEnumerationAccess( m_xIndexAccess, uno::UNO_QUERY_THROW ); - return new DocumentEnumImpl( mxContext, xEnumerationAccess->createEnumeration(), Application() ); + return new DocumentEnumImpl( mxParent, mxContext, xEnumerationAccess->createEnumeration(), Application() ); } uno::Any diff --git a/sw/source/ui/vba/vbasections.cxx b/sw/source/ui/vba/vbasections.cxx index faa53fa657b5..c0f887f0f249 100644 --- a/sw/source/ui/vba/vbasections.cxx +++ b/sw/source/ui/vba/vbasections.cxx @@ -120,14 +120,13 @@ public: class SectionsEnumWrapper : public EnumerationHelperImpl { uno::Reference< frame::XModel > mxModel; - uno::WeakReference< XHelperInterface > mxParent; public: - SectionsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xContext, xEnumeration ), mxModel( xModel ), mxParent( xParent ) {} + SectionsEnumWrapper( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< container::XEnumeration >& xEnumeration, const uno::Reference< frame::XModel >& xModel ) throw ( uno::RuntimeException ) : EnumerationHelperImpl( xParent, xContext, xEnumeration ), mxModel( xModel ){} virtual uno::Any SAL_CALL nextElement( ) throw (container::NoSuchElementException, lang::WrappedTargetException, uno::RuntimeException) { uno::Reference< beans::XPropertySet > xPageProps( m_xEnumeration->nextElement(), uno::UNO_QUERY_THROW ); - return uno::makeAny( uno::Reference< word::XSection > ( new SwVbaSection( mxParent, m_xContext, mxModel, xPageProps ) ) ); + return uno::makeAny( uno::Reference< word::XSection > ( new SwVbaSection( m_xParent, m_xContext, mxModel, xPageProps ) ) ); } }; -- cgit v1.2.3 From a2c4fece04b6aa8d8163986f3dffbbf86bd9bfb2 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 1 Jul 2010 17:39:28 +0200 Subject: #i112436# use InterpretDirtyCells instead of SetDirty for charts in xls import --- sc/source/core/data/document.cxx | 13 +++++++++++++ sc/source/filter/excel/xiescher.cxx | 6 ++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index bef4cbf87396..eee87317c258 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3061,6 +3061,19 @@ void ScDocument::CalcAfterLoad() bCalcingAfterLoad = FALSE; SetDetectiveDirty(FALSE); // noch keine wirklichen Aenderungen + + // #i112436# If formula cells are already dirty, they don't broadcast further changes. + // So the source ranges of charts must be interpreted even if they are not visible, + // similar to ScMyShapeResizer::CreateChartListener for loading own files (i104899). + if (pChartListenerCollection) + { + sal_uInt16 nChartCount = pChartListenerCollection->GetCount(); + for ( sal_uInt16 nIndex = 0; nIndex < nChartCount; nIndex++ ) + { + ScChartListener* pChartListener = static_cast(pChartListenerCollection->At(nIndex)); + InterpretDirtyCells(*pChartListener->GetRangeList()); + } + } } diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx index dc87bba4c050..8d09cae60941 100644 --- a/sc/source/filter/excel/xiescher.cxx +++ b/sc/source/filter/excel/xiescher.cxx @@ -98,7 +98,6 @@ #include "convuno.hxx" #include "postit.hxx" #include "globstr.hrc" -#include "chartlis.hxx" #include "fprogressbar.hxx" #include "xltracer.hxx" @@ -4056,9 +4055,8 @@ void XclImpObjectManager::ConvertObjects() for( XclImpSheetDrawingMap::iterator aIt = maSheetDrawings.begin(), aEnd = maSheetDrawings.end(); aIt != aEnd; ++aIt ) aIt->second->ConvertObjects( aDffConv ); - ScChartListenerCollection* pChartListeners = GetDoc().GetChartListenerCollection(); - if( pChartListeners && (pChartListeners->GetCount() > 0) ) - pChartListeners->SetDirty(); + // #i112436# don't call ScChartListenerCollection::SetDirty here, + // instead use InterpretDirtyCells in ScDocument::CalcAfterLoad. } String XclImpObjectManager::GetDefaultObjName( const XclImpDrawObjBase& rDrawObj ) const -- cgit v1.2.3 From df61240acdb6cf89e2b2c1895ba293eb78e0d973 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 1 Jul 2010 20:09:06 +0200 Subject: #i112858# don't access invalid resources in ScTabBgColorDlg --- sc/source/ui/inc/miscdlgs.hrc | 1 - sc/source/ui/inc/tabbgcolordlg.hxx | 2 -- sc/source/ui/miscdlgs/tabbgcolordlg.cxx | 21 ++++++++++----------- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc index becd05165a4e..00b1658849d6 100644 --- a/sc/source/ui/inc/miscdlgs.hrc +++ b/sc/source/ui/inc/miscdlgs.hrc @@ -185,5 +185,4 @@ // Tab Bg Color #define TAB_BG_COLOR_CT_BORDER 1 #define TAB_BG_COLOR_SET_BGDCOLOR 2 -#define TAB_BG_COLOR_GB_BGDCOLOR 3 diff --git a/sc/source/ui/inc/tabbgcolordlg.hxx b/sc/source/ui/inc/tabbgcolordlg.hxx index 241fc806022d..338609ae0e4d 100644 --- a/sc/source/ui/inc/tabbgcolordlg.hxx +++ b/sc/source/ui/inc/tabbgcolordlg.hxx @@ -32,7 +32,6 @@ #define SC_TABBGCOLORDLG_HXX #include -#include #include #include @@ -63,7 +62,6 @@ private: Control aBorderWin; ScTabBgColorValueSet aTabBgColorSet; - FixedLine aTabBgColorBox; OKButton aBtnOk; CancelButton aBtnCancel; HelpButton aBtnHelp; diff --git a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx index fdc4c9fd34bf..463c06d76712 100644 --- a/sc/source/ui/miscdlgs/tabbgcolordlg.cxx +++ b/sc/source/ui/miscdlgs/tabbgcolordlg.cxx @@ -39,14 +39,15 @@ #include "scresid.hxx" #include "miscdlgs.hrc" -#include "tools/debug.hxx" -#include "tools/color.hxx" -#include "sfx2/objsh.hxx" -#include "svx/xtable.hxx" -#include "svx/drawitem.hxx" -#include "unotools/pathoptions.hxx" -#include "tools/resid.hxx" -#include "editeng/editrids.hrc" +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -62,7 +63,6 @@ ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, ModalDialog ( pParent, ScResId( RID_SCDLG_TAB_BG_COLOR ) ), aBorderWin ( this, ScResId( TAB_BG_COLOR_CT_BORDER ) ), aTabBgColorSet ( &aBorderWin, ScResId( TAB_BG_COLOR_SET_BGDCOLOR ), this ), - aTabBgColorBox ( this, ScResId( TAB_BG_COLOR_GB_BGDCOLOR ) ), aBtnOk ( this, ScResId( BTN_OK ) ), aBtnCancel ( this, ScResId( BTN_CANCEL ) ), aBtnHelp ( this, ScResId( BTN_HELP ) ), @@ -75,7 +75,6 @@ ScTabBgColorDlg::ScTabBgColorDlg( Window* pParent, this->SetText( rTitle ); this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE); - aTabBgColorBox.SetText(rTitle); FillColorValueSets_Impl(); aTabBgColorSet.SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) ); aBtnOk.SetClickHdl( HDL(TabBgColorOKHdl_Impl) ); @@ -120,7 +119,7 @@ void ScTabBgColorDlg::FillColorValueSets_Impl() long nCount = pColorTable->Count(); XColorEntry* pEntry = NULL; Color aColWhite( COL_WHITE ); - String aStrWhite( ScResId( RID_SVXITEMS_COLOR_WHITE ) ); + String aStrWhite( EditResId( RID_SVXITEMS_COLOR_WHITE ) ); WinBits nBits = ( aTabBgColorSet.GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS); aTabBgColorSet.SetText( aTabBgColorNoColorText ); aTabBgColorSet.SetStyle( nBits ); -- cgit v1.2.3 From 1f3d1cba85b041abc7a0211effa099b68747b66f Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 2 Jul 2010 08:26:18 +0200 Subject: mib17: #111144# Fixed warning --- basic/source/classes/sbxmod.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 254e99c69da9..52076be8eece 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,7 +147,6 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { - sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); -- cgit v1.2.3 From da291caaae96e0e46cd6891746587528cbbdd925 Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Fri, 2 Jul 2010 13:51:34 +0200 Subject: calc56: #i112849# Prevent hash from accessing dangling pointers --- sc/source/core/data/bcaslot.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/sc/source/core/data/bcaslot.cxx b/sc/source/core/data/bcaslot.cxx index 95482b1c624b..540fb577a79b 100644 --- a/sc/source/core/data/bcaslot.cxx +++ b/sc/source/core/data/bcaslot.cxx @@ -136,10 +136,16 @@ ScBroadcastAreaSlot::ScBroadcastAreaSlot( ScDocument* pDocument, ScBroadcastAreaSlot::~ScBroadcastAreaSlot() { for ( ScBroadcastAreas::iterator aIter( aBroadcastAreaTbl.begin()); - aIter != aBroadcastAreaTbl.end(); ++aIter) + aIter != aBroadcastAreaTbl.end(); /* none */) { - if (!(*aIter)->DecRef()) - delete *aIter; + // Prevent hash from accessing dangling pointer in case area is + // deleted. + ScBroadcastArea* pArea = *aIter; + // Erase all so no hash will be accessed upon destruction of the + // hash_set. + aBroadcastAreaTbl.erase( aIter++); + if (!pArea->DecRef()) + delete pArea; } } -- cgit v1.2.3 From c4fc6f85c50c08f6e493b04845603cdfbe1f4681 Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 2 Jul 2010 16:17:22 +0200 Subject: calc56: #i112666# broken UNO API tests due to broken method XDiagram::setPosition() and wrongly flagged properties --- .../controller/chartapiwrapper/ChartDocumentWrapper.cxx | 8 ++++---- .../source/controller/chartapiwrapper/DiagramWrapper.cxx | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index edf8ad2b6209..d6487d425657 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -239,14 +239,14 @@ void lcl_AddPropertiesToVector( Property( C2U( "DisableComplexChartTypes" ), PROP_DOCUMENT_DISABLE_COMPLEX_CHARTTYPES, ::getBooleanCppuType(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ) ); + //#i112666# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT ) ); rOutProperties.push_back( Property( C2U( "DisableDataTableDialog" ), PROP_DOCUMENT_DISABLE_DATATABLE_DIALOG, ::getBooleanCppuType(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ) ); + //#i112666# no PropertyChangeEvent is fired on change so far + beans::PropertyAttribute::MAYBEDEFAULT ) ); } const uno::Sequence< Property > & lcl_GetPropertySequence() diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index eb3c76dd2c40..c0be0ddcbf0d 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -749,20 +749,19 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); if( xProp.is() ) { - if( aPosition.X < 0 || aPosition.Y < 0 || aPosition.X > 1 || aPosition.Y > 1 ) - { - DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); - uno::Any aEmpty; - xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); - return; - } - awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); chart2::RelativePosition aRelativePosition; aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + if( aRelativePosition.Primary < 0 || aRelativePosition.Secondary < 0 || aRelativePosition.Primary > 1 || aRelativePosition.Secondary > 1 ) + { + DBG_ERROR("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); + return; + } xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); xProp->setPropertyValue( C2U( "PosSizeExcludeAxes" ), uno::makeAny(false) ); } -- cgit v1.2.3 From a7b51f6bb8ed3360323e9ca691b847526fec762c Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 2 Jul 2010 16:37:45 +0200 Subject: calc56: #i112385# loosing 3D scheme settings --- chart2/source/controller/dialogs/DialogModel.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index f104045727bb..6a5a3ff6dfe7 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -41,6 +41,7 @@ #include "CommonFunctors.hxx" #include "ControllerLockGuard.hxx" #include "ChartTypeHelper.hxx" +#include "ThreeDHelper.hxx" #include #include @@ -694,14 +695,19 @@ bool DialogModel::setData( m_xTemplate->getDataInterpreter()); if( xInterpreter.is()) { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); + ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + ::std::vector< Reference< XDataSeries > > aSeriesToReUse( - DiagramHelper::getDataSeriesFromDiagram( m_xChartDocument->getFirstDiagram())); + DiagramHelper::getDataSeriesFromDiagram( xDiagram )); applyInterpretedData( xInterpreter->interpretDataSource( xDataSource, rArguments, ContainerToSequence( aSeriesToReUse )), aSeriesToReUse, true /* bSetStyles */); + + ThreeDHelper::setScheme( xDiagram, e3DScheme ); } } catch( uno::Exception & ex ) -- cgit v1.2.3 From fca98cb9bfa845afe078ec08dafc558526e8055d Mon Sep 17 00:00:00 2001 From: Ingrid Halama Date: Fri, 2 Jul 2010 17:04:32 +0200 Subject: calc56: #i112501# remove unused method --- .../source/controller/chartapiwrapper/Chart2ModelContact.cxx | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index ffc1e95ca796..1b0d8fb4889c 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -52,17 +52,6 @@ namespace chart namespace wrapper { -namespace -{ - -rtl::OUString lcl_getCIDForDiagram( const Reference< frame::XModel >& xChartModel ) -{ - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - return ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xChartModel ); -} - -} //anonymous namespace - Chart2ModelContact::Chart2ModelContact( const Reference< uno::XComponentContext > & xContext ) : m_xContext( xContext ), -- cgit v1.2.3 From ba994212ea43ea8f0e93a038646ca960221ad16d Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Mon, 5 Jul 2010 13:58:36 +0200 Subject: mib17: #i100659# Changed module variable handling --- basic/inc/basic/sbmod.hxx | 5 ++++- basic/source/classes/sbxmod.cxx | 28 ++++++++++++++++++++++++++++ basic/source/comp/sbcomp.cxx | 1 + basic/source/runtime/step2.cxx | 23 +++++++++++++++++------ 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index aeed4c2b6347..932a828ac753 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -33,6 +33,7 @@ #include #include #include +#include class SbMethod; class SbProperty; @@ -56,6 +57,7 @@ class SbModule : public SbxObject friend class SbClassModuleObject; SbModuleImpl* mpSbModuleImpl; // Impl data + std::vector< String > mModuleVariableNames; protected: com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper; @@ -133,7 +135,8 @@ public: INT32 GetModuleType() { return mnType; } void SetModuleType( INT32 nType ) { mnType = nType; } bool GetIsProxyModule() { return bIsProxyModule; } - ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); + void AddVarName( const String& aName ); + void RemoveVars(); ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > GetUnoModule(); bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject ); }; diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 52076be8eece..de8071dacfa7 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,6 +147,7 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { + sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); @@ -1242,6 +1243,33 @@ void SbModule::RunInit() } // Mit private/dim deklarierte Variablen loeschen + +void SbModule::AddVarName( const String& aName ) +{ + // see if the name is added allready + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + if ( aName == *it ) + return; + } + mModuleVariableNames.push_back( aName ); +} + +void SbModule::RemoveVars() +{ + std::vector< String >::iterator it_end = mModuleVariableNames.end(); + for ( std::vector< String >::iterator it = mModuleVariableNames.begin(); it != it_end; ++it ) + { + // We don't want a Find being called in a derived class ( e.g. + // SbUserform because it could trigger say an initialise event + // which would cause basic to be re-run in the middle of the init ( and remember RemoveVars is called from compile and we don't want code to run as part of the compile ) + SbxVariableRef p = SbModule::Find( *it, SbxCLASS_PROPERTY ); + if( p.Is() ) + Remove (p); + } +} + void SbModule::ClearPrivateVars() { for( USHORT i = 0 ; i < pProps->Count() ; i++ ) diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 6e4f7ddf126e..50dc6f847076 100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -131,6 +131,7 @@ BOOL SbModule::Compile() if( bRet ) { pBasic->ClearAllModuleVars(); + RemoveVars(); // remove 'this' Modules variables // clear all method statics for( USHORT i = 0; i < pMethods->Count(); i++ ) { diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 8e72fd2ac3c6..c9f344c57d32 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -1158,15 +1158,26 @@ void SbiRuntime::StepGLOBAL( UINT32 nOp1, UINT32 nOp2 ) StepPUBLIC_Impl( nOp1, nOp2, true ); String aName( pImg->GetString( static_cast( nOp1 ) ) ); - SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; - BOOL bFlag = rBasic.IsSet( SBX_NO_MODIFY ); + SbxDataType t = (SbxDataType)(nOp2 & 0xffff);; + + // Store module scope variables at module scope + // in non vba mode these are stored at the library level :/ + // not sure if this really should not be enabled for ALL basic + SbxObject* pStorage = &rBasic; + if ( SbiRuntime::isVBAEnabled() ) + { + pStorage = pMod; + pMod->AddVarName( aName ); + } + + BOOL bFlag = pStorage->IsSet( SBX_NO_MODIFY ); rBasic.SetFlag( SBX_NO_MODIFY ); - SbxVariableRef p = rBasic.Find( aName, SbxCLASS_PROPERTY ); + SbxVariableRef p = pStorage->Find( aName, SbxCLASS_PROPERTY ); if( p.Is() ) - rBasic.Remove (p); - p = rBasic.Make( aName, SbxCLASS_PROPERTY, t ); + pStorage->Remove (p); + p = pStorage->Make( aName, SbxCLASS_PROPERTY, t ); if( !bFlag ) - rBasic.ResetFlag( SBX_NO_MODIFY ); + pStorage->ResetFlag( SBX_NO_MODIFY ); if( p ) { p->SetFlag( SBX_DONTSTORE ); -- cgit v1.2.3 From 50727c4ef2058ed886493876f016fee1f2db5dcd Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 5 Jul 2010 19:52:39 +0200 Subject: #i112745# get the right font size for ScDPFieldButton, clip text to bounding box --- sc/source/ui/cctrl/dpcontrol.cxx | 36 ++++++++++++++++++++++++++---------- sc/source/ui/inc/dpcontrol.hxx | 4 +++- sc/source/ui/view/gridwin2.cxx | 2 +- sc/source/ui/view/gridwin4.cxx | 4 ++-- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/sc/source/ui/cctrl/dpcontrol.cxx b/sc/source/ui/cctrl/dpcontrol.cxx index 52aae575b7d7..11f9cb197363 100644 --- a/sc/source/ui/cctrl/dpcontrol.cxx +++ b/sc/source/ui/cctrl/dpcontrol.cxx @@ -33,12 +33,16 @@ #include "dpcontrol.hxx" #include "dpcontrol.hrc" -#include "vcl/outdev.hxx" -#include "vcl/settings.hxx" -#include "vcl/wintypes.hxx" -#include "vcl/decoview.hxx" +#include +#include +#include +#include #include "strload.hxx" #include "global.hxx" +#include "scitems.hxx" +#include "document.hxx" +#include "docpool.hxx" +#include "patattr.hxx" #include "AccessibleFilterMenu.hxx" #include "AccessibleFilterTopWindow.hxx" @@ -55,7 +59,8 @@ using ::std::vector; using ::std::hash_map; using ::std::auto_ptr; -ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY) : +ScDPFieldButton::ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX, const Fraction* pZoomY, ScDocument* pDoc) : + mpDoc(pDoc), mpOutDev(pOutDev), mpStyle(pStyle), mbBaseButton(true), @@ -135,17 +140,28 @@ void ScDPFieldButton::draw() Point(maPos.X()+maSize.Width()-1, maPos.Y()+maSize.Height()-1)); // Field name. - Font aTextFont( mpStyle->GetLabelFont() ); - double fFontHeight = 12.0; - fFontHeight *= static_cast(maZoomY.GetNumerator()) / static_cast(maZoomY.GetDenominator()); - aTextFont.SetHeight(static_cast(fFontHeight)); + // Get the font and size the same way as in scenario selection (lcl_DrawOneFrame in gridwin4.cxx) + Font aTextFont( mpStyle->GetAppFont() ); + if ( mpDoc ) + { + // use ScPatternAttr::GetFont only for font size + Font aAttrFont; + static_cast(mpDoc->GetPool()->GetDefaultItem(ATTR_PATTERN)). + GetFont( aAttrFont, SC_AUTOCOL_BLACK, mpOutDev, &maZoomY ); + aTextFont.SetSize( aAttrFont.GetSize() ); + } mpOutDev->SetFont(aTextFont); + mpOutDev->SetTextColor(mpStyle->GetButtonTextColor()); Point aTextPos = maPos; - long nTHeight = static_cast(fFontHeight); + long nTHeight = mpOutDev->GetTextHeight(); aTextPos.setX(maPos.getX() + nMargin); aTextPos.setY(maPos.getY() + (maSize.Height()-nTHeight)/2); + + mpOutDev->Push(PUSH_CLIPREGION); + mpOutDev->IntersectClipRegion(aRect); mpOutDev->DrawText(aTextPos, maText); + mpOutDev->Pop(); } if (mbPopupButton) diff --git a/sc/source/ui/inc/dpcontrol.hxx b/sc/source/ui/inc/dpcontrol.hxx index 15f0c9174cc8..45badf0c88fd 100644 --- a/sc/source/ui/inc/dpcontrol.hxx +++ b/sc/source/ui/inc/dpcontrol.hxx @@ -64,7 +64,8 @@ class ScAccessibleFilterMenu; class ScDPFieldButton { public: - ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL); + ScDPFieldButton(OutputDevice* pOutDev, const StyleSettings* pStyle, const Fraction* pZoomX = NULL, const Fraction* pZoomY = NULL, + ScDocument* pDoc = NULL); ~ScDPFieldButton(); void setText(const ::rtl::OUString& rText); @@ -86,6 +87,7 @@ private: ::rtl::OUString maText; Fraction maZoomX; Fraction maZoomY; + ScDocument* mpDoc; OutputDevice* mpOutDev; const StyleSettings* mpStyle; bool mbBaseButton; diff --git a/sc/source/ui/view/gridwin2.cxx b/sc/source/ui/view/gridwin2.cxx index f8b5c25c4a70..a64814d952ef 100644 --- a/sc/source/ui/view/gridwin2.cxx +++ b/sc/source/ui/view/gridwin2.cxx @@ -144,7 +144,7 @@ bool ScGridWindow::DoAutoFilterButton( SCCOL nCol, SCROW nRow, const MouseEvent& Size aScrSize(nSizeX-1, nSizeY-1); // Check if the mouse cursor is clicking on the popup arrow box. - mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY())); + mpFilterButton.reset(new ScDPFieldButton(this, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc)); mpFilterButton->setBoundingBox(aScrPos, aScrSize); Point aPopupPos; Size aPopupSize; diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index d8024e439173..4e1a19caae6d 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -1208,14 +1208,14 @@ void ScGridWindow::DrawButtons( SCCOL nX1, SCROW /*nY1*/, SCCOL nX2, SCROW /*nY2 { aComboButton.SetOutputDevice( pContentDev ); - ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY()); + ScDocument* pDoc = pViewData->GetDocument(); + ScDPFieldButton aCellBtn(pContentDev, &GetSettings().GetStyleSettings(), &pViewData->GetZoomX(), &pViewData->GetZoomY(), pDoc); SCCOL nCol; SCROW nRow; SCSIZE nArrY; SCSIZE nQuery; SCTAB nTab = pViewData->GetTabNo(); - ScDocument* pDoc = pViewData->GetDocument(); ScDBData* pDBData = NULL; ScQueryParam* pQueryParam = NULL; -- cgit v1.2.3 From bb09a0aa845e46c538bd62d0c7d95a57e4d1a7d9 Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 6 Jul 2010 08:08:39 +0200 Subject: mib17: #i100659# Removed warning --- basic/source/classes/sbxmod.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index de8071dacfa7..51af5685d888 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -147,7 +147,6 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV SbObjModule* pMod = PTR_CAST(SbObjModule,pVar); if ( pMod ) { - sal_Int16 nType = pMod->GetModuleType(); if ( pMod->GetModuleType() == ModuleType::DOCUMENT ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); -- cgit v1.2.3 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(-) 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 v1.2.3 From dba973219b95c52db4fd632ab642628d36084bdd Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Tue, 6 Jul 2010 15:59:41 +0200 Subject: mib17: #162898# Special handling for ByVal followed by StrPtr --- basic/source/comp/exprtree.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 0cf0d9870378..9b6f419e15ce 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -971,11 +971,16 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else { bool bByVal = false; + bool bByValBlockLValueError = false; if( eTok == BYVAL ) { bByVal = true; pParser->Next(); eTok = pParser->Peek(); + + // Special handling for VBA function "StrPtr" that's accepted as lvalue + if( eTok == SYMBOL && pParser->GetSym().EqualsIgnoreCaseAscii( "StrPtr" ) ) + bByValBlockLValueError = true; } if( bAssumeExprLParenMode ) @@ -1011,7 +1016,7 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa if( bByVal ) { - if( !pExpr->IsLvalue() ) + if( !pExpr->IsLvalue() && !bByValBlockLValueError ) pParser->Error( SbERR_LVALUE_EXPECTED ); else pExpr->SetByVal(); -- cgit v1.2.3 From b687b636115b17970db28c389a8d28040ace86d1 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 18:07:29 +0200 Subject: mib17: #162576# handle VBA UserForm_Resize and UserForm_Layout events --- basic/inc/basic/sbobjmod.hxx | 12 ++- basic/source/classes/sb.cxx | 21 ++---- basic/source/classes/sbxmod.cxx | 158 +++++++++++++++++++++++++++------------ basic/source/runtime/methods.cxx | 3 +- 4 files changed, 127 insertions(+), 67 deletions(-) diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx index 3d638a475f9a..9ff46d1931f3 100644 --- a/basic/inc/basic/sbobjmod.hxx +++ b/basic/inc/basic/sbobjmod.hxx @@ -36,6 +36,7 @@ #ifndef _SB_OBJMOD_HXX #define _SB_OBJMOD_HXX +#include #include #include #include @@ -60,10 +61,12 @@ public: void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ; }; +class FormObjEventListenerImpl; + class SbUserFormModule : public SbObjModule { com::sun::star::script::ModuleInfo m_mInfo; - css::uno::Reference m_DialogListener; + ::rtl::Reference< FormObjEventListenerImpl > m_DialogListener; css::uno::Reference m_xDialog; css::uno::Reference m_xModel; String sFormName; @@ -76,16 +79,19 @@ class SbUserFormModule : public SbObjModule public: TYPEINFO(); SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat ); + virtual ~SbUserFormModule(); virtual SbxVariable* Find( const XubString& rName, SbxClassType t ); void ResetApiObj(); void Unload(); - void load(); + void Load(); void triggerMethod( const String& ); void triggerMethod( const String&, css::uno::Sequence< css::uno::Any >& ); void triggerActivateEvent(); - void triggerDeActivateEvent(); + void triggerDeactivateEvent(); void triggerInitializeEvent(); void triggerTerminateEvent(); + void triggerLayoutEvent(); + void triggerResizeEvent(); class SbUserFormModuleInstance* CreateInstance(); }; diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 924a3ef2807f..9012471cac0a 100755 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -339,27 +339,18 @@ SbxBase* SbFormFactory::Create( UINT16, UINT32 ) SbxObject* SbFormFactory::CreateObject( const String& rClassName ) { - static String aLoadMethodName( RTL_CONSTASCII_USTRINGPARAM("load") ); - - SbxObject* pRet = NULL; - SbModule* pMod = pMOD; - if( pMod ) + if( SbModule* pMod = pMOD ) { - SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ); - if( pVar ) + if( SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT ) ) { - SbxBase* pObj = pVar->GetObject(); - SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pObj ); - - if( pFormModule != NULL ) + if( SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pVar->GetObject() ) ) { - pFormModule->load(); - SbUserFormModuleInstance* pFormInstance = pFormModule->CreateInstance(); - pRet = pFormInstance; + pFormModule->Load(); + return pFormModule->CreateInstance(); } } } - return pRet; + return 0; } diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 51af5685d888..30d856fda40e 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -95,6 +96,7 @@ using namespace com::sun::star::script; #include #include #include +#include #include #include #include @@ -1985,9 +1987,9 @@ SbObjModule::Find( const XubString& rName, SbxClassType t ) return pVar; } -typedef ::cppu::WeakImplHelper1< awt::XTopWindowListener > EventListener_BASE; +typedef ::cppu::WeakImplHelper2< awt::XTopWindowListener, awt::XWindowListener > FormObjEventListener_BASE; -class FormObjEventListenerImpl : public EventListener_BASE +class FormObjEventListenerImpl : public FormObjEventListener_BASE { SbUserFormModule* mpUserForm; uno::Reference< lang::XComponent > mxComponent; @@ -1997,39 +1999,57 @@ class FormObjEventListenerImpl : public EventListener_BASE sal_Bool mbShowing; FormObjEventListenerImpl(); // not defined FormObjEventListenerImpl(const FormObjEventListenerImpl&); // not defined + public: - FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : mpUserForm( pUserForm ), mxComponent( xComponent) , mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) + FormObjEventListenerImpl( SbUserFormModule* pUserForm, const uno::Reference< lang::XComponent >& xComponent ) : + mpUserForm( pUserForm ), mxComponent( xComponent) , + mbDisposed( false ), mbOpened( sal_False ), mbActivated( sal_False ), mbShowing( sal_False ) { if ( mxComponent.is() ) { - uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - OSL_TRACE("*********** Registering the listener"); - xList->addTopWindowListener( this ); + OSL_TRACE("*********** Registering the listeners"); + try + { + uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->addTopWindowListener( this ); + } + catch( uno::Exception& ) {} + try + { + uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->addWindowListener( this ); + } + catch( uno::Exception& ) {} } } - ~FormObjEventListenerImpl() + virtual ~FormObjEventListenerImpl() { removeListener(); } - sal_Bool isShowing() { return mbShowing; } + + sal_Bool isShowing() const { return mbShowing; } + void removeListener() { - try + if ( mxComponent.is() && !mbDisposed ) { - if ( mxComponent.is() && !mbDisposed ) + OSL_TRACE("*********** Removing the listeners"); + try { - uno::Reference< awt::XTopWindow > xList( mxComponent, uno::UNO_QUERY_THROW );; - OSL_TRACE("*********** Removing the listener"); - xList->removeTopWindowListener( this ); - mxComponent = NULL; + uno::Reference< awt::XTopWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeTopWindowListener( this ); } + catch( uno::Exception& ) {} + try + { + uno::Reference< awt::XWindow >( mxComponent, uno::UNO_QUERY_THROW )->removeWindowListener( this ); + } + catch( uno::Exception& ) {} } - catch( uno::Exception& ) {} + mxComponent.clear(); } + virtual void SAL_CALL windowOpened( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) + if ( mpUserForm ) { mbOpened = sal_True; mbShowing = sal_True; @@ -2076,12 +2096,23 @@ public: } //liuchen 2009-7-21 - virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { mbOpened = sal_False; mbShowing = sal_False; } - virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) {} - virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException){} + virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + mbOpened = sal_False; + mbShowing = sal_False; + } + + virtual void SAL_CALL windowMinimized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + + virtual void SAL_CALL windowNormalized( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + virtual void SAL_CALL windowActivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) + if ( mpUserForm ) { mbActivated = sal_True; if ( mbOpened ) @@ -2094,18 +2125,38 @@ public: virtual void SAL_CALL windowDeactivated( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { - if ( mpUserForm ) - mpUserForm->triggerDeActivateEvent(); + if ( mpUserForm ) + mpUserForm->triggerDeactivateEvent(); } + virtual void SAL_CALL windowResized( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + { + mpUserForm->triggerResizeEvent(); + mpUserForm->triggerLayoutEvent(); + } + } + + virtual void SAL_CALL windowMoved( const awt::WindowEvent& /*e*/ ) throw (uno::RuntimeException) + { + if ( mpUserForm ) + mpUserForm->triggerLayoutEvent(); + } + + virtual void SAL_CALL windowShown( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } + + virtual void SAL_CALL windowHidden( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + { + } - virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw (uno::RuntimeException) + virtual void SAL_CALL disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) { OSL_TRACE("** Userform/Dialog disposing"); mbDisposed = true; - uno::Any aSource; - aSource <<= Source; - mxComponent = NULL; + mxComponent.clear(); if ( mpUserForm ) mpUserForm->ResetApiObj(); } @@ -2119,6 +2170,10 @@ SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::s m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW ); } +SbUserFormModule::~SbUserFormModule() +{ +} + void SbUserFormModule::ResetApiObj() { if ( m_xDialog.is() ) // probably someone close the dialog window @@ -2181,23 +2236,22 @@ void SbUserFormModule::triggerMethod( const String& aMethodToRun, Sequence< Any void SbUserFormModule::triggerActivateEvent( void ) { - OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); - triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_activate") ) ); - OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); + OSL_TRACE("**** entering SbUserFormModule::triggerActivate"); + triggerMethod( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("UserForm_Activate") ) ); + OSL_TRACE("**** leaving SbUserFormModule::triggerActivate"); } -void SbUserFormModule::triggerDeActivateEvent( void ) +void SbUserFormModule::triggerDeactivateEvent( void ) { - OSL_TRACE("**** SbUserFormModule::triggerDeActivate"); - triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_DeActivate") ) ); + OSL_TRACE("**** SbUserFormModule::triggerDeactivate"); + triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_Deactivate") ) ); } void SbUserFormModule::triggerInitializeEvent( void ) - { if ( mbInit ) return; - OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); + OSL_TRACE("**** SbUserFormModule::triggerInitializeEvent"); static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Initialize") ); triggerMethod( aInitMethodName ); mbInit = true; @@ -2205,12 +2259,24 @@ void SbUserFormModule::triggerInitializeEvent( void ) void SbUserFormModule::triggerTerminateEvent( void ) { - OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); + OSL_TRACE("**** SbUserFormModule::triggerTerminateEvent"); static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Terminate") ); triggerMethod( aTermMethodName ); mbInit=false; } +void SbUserFormModule::triggerLayoutEvent( void ) +{ + static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Layout") ); + triggerMethod( aMethodName ); +} + +void SbUserFormModule::triggerResizeEvent( void ) +{ + static String aMethodName( RTL_CONSTASCII_USTRINGPARAM("Userform_Resize") ); + triggerMethod( aMethodName ); +} + SbUserFormModuleInstance* SbUserFormModule::CreateInstance() { SbUserFormModuleInstance* pInstance = new SbUserFormModuleInstance( this, GetName(), m_mInfo, IsVBACompat() ); @@ -2238,7 +2304,7 @@ SbxVariable* SbUserFormModuleInstance::Find( const XubString& rName, SbxClassTyp } -void SbUserFormModule::load() +void SbUserFormModule::Load() { OSL_TRACE("** load() "); // forces a load @@ -2276,21 +2342,20 @@ void SbUserFormModule::Unload() if( pMeth ) { OSL_TRACE("Attempting too run the UnloadObjectMethod"); - m_xDialog = NULL; //release ref to the uno object + m_xDialog.clear(); //release ref to the uno object SbxValues aVals; - FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); bool bWaitForDispose = true; // assume dialog is showing - if ( pFormListener ) + if ( m_DialogListener.get() ) { - bWaitForDispose = pFormListener->isShowing(); + bWaitForDispose = m_DialogListener->isShowing(); OSL_TRACE("Showing %d", bWaitForDispose ); } pMeth->Get( aVals); - if ( !bWaitForDispose ) - { - // we've either already got a dispose or we'er never going to get one + if ( !bWaitForDispose ) + { + // we've either already got a dispose or we'er never going to get one ResetApiObj(); - } // else wait for dispose + } // else wait for dispose OSL_TRACE("UnloadObject completed ( we hope )"); } } @@ -2328,9 +2393,8 @@ void SbUserFormModule::InitObject() pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs ) ) ); uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW ); // remove old listener if it exists - FormObjEventListenerImpl* pFormListener = dynamic_cast< FormObjEventListenerImpl* >( m_DialogListener.get() ); - if ( pFormListener ) - pFormListener->removeListener(); + if ( m_DialogListener.get() ) + m_DialogListener->removeListener(); m_DialogListener = new FormObjEventListenerImpl( this, xComponent ); triggerInitializeEvent(); diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 36fbda5c9097..1a60a5d79a45 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -4134,8 +4134,7 @@ RTLFUNC(Load) { if( pObj->IsA( TYPE( SbUserFormModule ) ) ) { - SbUserFormModule* pFormModule = ( SbUserFormModule* )pObj; - pFormModule->load(); + ((SbUserFormModule*)pObj)->Load(); } else if( pObj->IsA( TYPE( SbxObject ) ) ) { -- cgit v1.2.3 From 19d399fdda8f8e2b124e00bff54ecea476a3592e Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 19:34:53 +0200 Subject: mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power --- filter/source/msfilter/msvbahelper.cxx | 83 +++++++------ oox/inc/oox/xls/excelvbaproject.hxx | 73 ----------- oox/source/xls/excelvbaproject.cxx | 214 --------------------------------- oox/source/xls/makefile.mk | 1 - oox/source/xls/workbookhelper.cxx | 8 +- 5 files changed, 50 insertions(+), 329 deletions(-) delete mode 100755 oox/inc/oox/xls/excelvbaproject.hxx delete mode 100755 oox/source/xls/excelvbaproject.cxx diff --git a/filter/source/msfilter/msvbahelper.cxx b/filter/source/msfilter/msvbahelper.cxx index 18ecc5ae6530..19e93dbb791a 100644 --- a/filter/source/msfilter/msvbahelper.cxx +++ b/filter/source/msfilter/msvbahelper.cxx @@ -38,6 +38,7 @@ #include #include #include +#include using namespace ::com::sun::star; @@ -108,7 +109,24 @@ SfxObjectShell* findShellForUrl( const rtl::OUString& sMacroURLOrPath ) } else { - if ( aURL.equals( xModel->getURL() ) ) + // sometimes just the name of the document ( without the path + // is used + bool bDocNameNoPathMatch = false; + if ( aURL.getLength() && aURL.indexOf( '/' ) == -1 ) + { + sal_Int32 lastSlashIndex = xModel->getURL().lastIndexOf( '/' ); + if ( lastSlashIndex > -1 ) + { + bDocNameNoPathMatch = xModel->getURL().copy( lastSlashIndex + 1 ).equals( aURL ); + if ( !bDocNameNoPathMatch ) + { + rtl::OUString aTmpName = rtl::OUString::createFromAscii("'") + xModel->getURL().copy( lastSlashIndex + 1 ) + rtl::OUString::createFromAscii("'"); + bDocNameNoPathMatch = aTmpName.equals( aURL ); + } + } + } + + if ( aURL.equals( xModel->getURL() ) || bDocNameNoPathMatch ) { pFoundShell = pShell; break; @@ -221,9 +239,19 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin String sDocUrlOrPath = sMacroUrl.copy( 0, nDocSepIndex ); sMacroUrl = sMacroUrl.copy( nDocSepIndex + 1 ); OSL_TRACE("doc search, current shell is 0x%x", pShell ); - SfxObjectShell* pFoundShell = findShellForUrl( sDocUrlOrPath ); + SfxObjectShell* pFoundShell = NULL; + if( bSearchGlobalTemplates ) + { + SvtPathOptions aPathOpt; + String aAddinPath = aPathOpt.GetAddinPath(); + if( rtl::OUString( sDocUrlOrPath ).indexOf( aAddinPath ) == 0 ) + pFoundShell = pShell; + } + if( pFoundShell == NULL ) + pFoundShell = findShellForUrl( sDocUrlOrPath ); OSL_TRACE("doc search, after find, found shell is 0x%x", pFoundShell ); - aRes = resolveVBAMacro( pFoundShell, sMacroUrl ); + aRes = resolveVBAMacro( pFoundShell, sMacroUrl, bSearchGlobalTemplates ); + return aRes; } else { @@ -337,14 +365,14 @@ VBAMacroResolvedInfo resolveVBAMacro( SfxObjectShell* pShell, const rtl::OUStrin break; } } + aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); } - aRes.SetResolvedMacro( sProcedure.Insert( '.', 0 ).Insert( sModule, 0).Insert( '.', 0 ).Insert( sContainer, 0 ) ); return aRes; } // Treat the args as possible inouts ( convertion at bottom of method ) -sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& /*aRet*/, const uno::Any& aCaller ) +sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Sequence< uno::Any >& aArgs, uno::Any& aRet, const uno::Any& /*aCaller*/) { sal_Bool bRes = sal_False; if ( !pShell ) @@ -355,42 +383,25 @@ sal_Bool executeMacro( SfxObjectShell* pShell, const String& sMacroName, uno::Se uno::Sequence< uno::Any > aOutArgs; try - { - uno::Reference< script::provider::XScriptProvider > xScriptProvider; - uno::Reference< script::provider::XScriptProviderSupplier > xSPS( pShell->GetModel(), uno::UNO_QUERY_THROW ); - - xScriptProvider.set( xSPS->getScriptProvider(), uno::UNO_QUERY_THROW ); - - uno::Reference< script::provider::XScript > xScript( xScriptProvider->getScript( sUrl ), uno::UNO_QUERY_THROW ); - - if ( aCaller.hasValue() ) + { ErrCode nErr( ERRCODE_BASIC_INTERNAL_ERROR ); + if ( pShell ) { - uno::Reference< beans::XPropertySet > xProps( xScript, uno::UNO_QUERY ); - if ( xProps.is() ) + nErr = pShell->CallXScript( sUrl, + aArgs, aRet, aOutArgsIndex, aOutArgs, false ); + sal_Int32 nLen = aOutArgs.getLength(); + // convert any out params to seem like they were inouts + if ( nLen ) { - uno::Sequence< uno::Any > aCallerHack(1); - aCallerHack[ 0 ] = aCaller; - xProps->setPropertyValue( rtl::OUString::createFromAscii( "Caller" ), uno::makeAny( aCallerHack ) ); + for ( sal_Int32 index=0; index < nLen; ++index ) + { + sal_Int32 nOutIndex = aOutArgsIndex[ index ]; + aArgs[ nOutIndex ] = aOutArgs[ index ]; + } } } - - - xScript->invoke( aArgs, aOutArgsIndex, aOutArgs ); - - sal_Int32 nLen = aOutArgs.getLength(); - // convert any out params to seem like they were inouts - if ( nLen ) - { - for ( sal_Int32 index=0; index < nLen; ++index ) - { - sal_Int32 nOutIndex = aOutArgsIndex[ index ]; - aArgs[ nOutIndex ] = aOutArgs[ index ]; - } - } - - bRes = sal_True; + bRes = ( nErr == ERRCODE_NONE ); } - catch ( uno::Exception& e ) + catch ( uno::Exception& ) { bRes = sal_False; } diff --git a/oox/inc/oox/xls/excelvbaproject.hxx b/oox/inc/oox/xls/excelvbaproject.hxx deleted file mode 100755 index 6a517d13cd88..000000000000 --- a/oox/inc/oox/xls/excelvbaproject.hxx +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef OOX_XLS_EXCELVBAPROJECT_HXX -#define OOX_XLS_EXCELVBAPROJECT_HXX - -#include "oox/ole/vbaproject.hxx" -#include "oox/dllapi.h" - -namespace com { namespace sun { namespace star { - namespace sheet { class XSpreadsheetDocument; } -} } } - -namespace oox { -namespace xls { - -// ============================================================================ - -/** Special implementation of the VBA project for the Excel filters. */ -class OOX_DLLPUBLIC VbaProject : public ::oox::ole::VbaProject -{ -public: - explicit VbaProject( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory, - const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument >& rxDocument ); - - /** Attaches all document and sheet events to existing VBA macros. */ - void attachToEvents(); - -private: - /** Attaches VBA macros to all supported document events. */ - void attachToDocumentEvents( const ::rtl::OUString& rCodeName ); - - /** Attaches VBA macros to all supported sheet events. */ - void attachToSheetEvents( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rCodeName ); - -private: - ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheetDocument > - mxDocument; -}; - -// ============================================================================ - -} // namespace xls -} // namespace oox - -#endif diff --git a/oox/source/xls/excelvbaproject.cxx b/oox/source/xls/excelvbaproject.cxx deleted file mode 100755 index fc3caf7e59aa..000000000000 --- a/oox/source/xls/excelvbaproject.cxx +++ /dev/null @@ -1,214 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "oox/xls/excelvbaproject.hxx" -#include -#include -#include -#include -#include -#include "properties.hxx" -#include "oox/helper/helper.hxx" -#include "oox/helper/propertyset.hxx" - -using ::rtl::OUString; -using ::com::sun::star::container::XEnumeration; -using ::com::sun::star::container::XEnumerationAccess; -using ::com::sun::star::document::XEventsSupplier; -using ::com::sun::star::frame::XModel; -using ::com::sun::star::lang::XMultiServiceFactory; -using ::com::sun::star::sheet::XSpreadsheetDocument; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_QUERY; -using ::com::sun::star::uno::UNO_QUERY_THROW; -using ::com::sun::star::uno::UNO_SET_THROW; - -namespace oox { -namespace xls { - -// ============================================================================ - -VbaProject::VbaProject( const Reference< XMultiServiceFactory >& rxGlobalFactory, const Reference< XSpreadsheetDocument >& rxDocument ) : - ::oox::ole::VbaProject( rxGlobalFactory, Reference< XModel >( rxDocument, UNO_QUERY ), CREATE_OUSTRING( "Calc" ) ), - mxDocument( rxDocument ) -{ -} - -void VbaProject::attachToEvents() -{ - // do nothing is code is not executable - if( !isImportVbaExecutable() ) - return; - - // document events - PropertySet aDocProp( mxDocument ); - OUString aCodeName; - aDocProp.getProperty( aCodeName, PROP_CodeName ); - attachToDocumentEvents( aCodeName ); - - // sheet events - if( mxDocument.is() ) try - { - Reference< XEnumerationAccess > xSheetsEA( mxDocument->getSheets(), UNO_QUERY_THROW ); - Reference< XEnumeration > xSheetsEnum( xSheetsEA->createEnumeration(), UNO_SET_THROW ); - // own try/catch for every sheet - while( xSheetsEnum->hasMoreElements() ) try - { - // TODO: once we have chart sheets we need a switch/case on sheet type - Reference< XEventsSupplier > xEventsSupp( xSheetsEnum->nextElement(), UNO_QUERY_THROW ); - PropertySet aSheetProp( xEventsSupp ); - aSheetProp.getProperty( aCodeName, PROP_CodeName ); - attachToSheetEvents( xEventsSupp, aCodeName ); - } - catch( Exception& ) - { - } - } - catch( Exception& ) - { - } -} - -// private -------------------------------------------------------------------- - -void VbaProject::attachToDocumentEvents( const OUString& rCodeName ) -{ - if( (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) - return; - - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnLoad" ), rCodeName, CREATE_OUSTRING( "Workbook_Open" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Activate" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Workbook_Deactivate" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSave" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False, False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAs" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True, False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsDone" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO True" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnSaveAsFailed" ), rCodeName, CREATE_OUSTRING( "Workbook_AfterSave" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrint" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforePrint" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); - attachMacroToDocumentEvent( CREATE_OUSTRING( "OnPrepareUnload" ), rCodeName, CREATE_OUSTRING( "Workbook_BeforeClose" ), OUString(), OUString(), CREATE_OUSTRING( "\t$MACRO False" ) ); -} - -void VbaProject::attachToSheetEvents( const Reference< XEventsSupplier >& rxEventsSupp, const OUString& rCodeName ) -{ - if( !rxEventsSupp.is() || (rCodeName.getLength() == 0) || !hasModule( rCodeName ) ) - return; - - // attach macros to simple sheet events directly - attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnFocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Activate" ) ); - attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnUnfocus" ), rCodeName, CREATE_OUSTRING( "Worksheet_Deactivate" ) ); - attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnCalculate" ), rCodeName, CREATE_OUSTRING( "Worksheet_Calculate" ) ); - - /* Attach macros to complex sheet events. The events pass a cell range or - a collection of cell ranges depending on the event type and sheet - selection. The generated proxy macros need to convert these UNO renges - to VBA compatible ranges. - */ - -#define VBA_MACRONAME_RANGECONV "Local_GetVbaRangeFromUnoRange" -#define VBA_MACRONAME_TARGETCONV "Local_GetVbaTargetFromUnoTarget" - - /* If this variable turns to true, the macros that convert UNO cell ranges - to VBA Range objects have to be inserted. - */ - bool bNeedsTargetHelper = false; - - /* Insert the proxy macros attached to sheet events that notify something - has changed (changed selection and changed cell contents). These events - cannot be cancelled. The proxy macro converts the passed UNO cell range - or collection of cell ranges to a VBA Range object, and calls the VBA - event handler. - */ - OUString aChangeProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); - OUString aChangeProxyCode = CREATE_OUSTRING( - "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" - "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget" ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnChange" ), rCodeName, CREATE_OUSTRING( "Worksheet_Change" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnSelect" ), rCodeName, CREATE_OUSTRING( "Worksheet_SelectionChange" ), aChangeProxyArgs, OUString(), aChangeProxyCode ); - - /* Insert the proxy macros attached to sheet events that notify an ongoing - mouse click event (double click and right click). These events can be - cancelled by returning false (in VBA: as a Boolean output parameter, in - UNO: as return value of the Basic function). The proxy macro converts - the passed UNO cell range or collection of cell ranges to a VBA Range - object, calls the VBA event handler, and returns the Boolean value - provided by the VBA event handler. - */ - OUString aClickProxyArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); - OUString aClickProxyRetT = CREATE_OUSTRING( "Boolean" ); - OUString aClickProxyCode = CREATE_OUSTRING( - "\tDim Cancel As Boolean : Cancel = False\n" - "\tDim vbaTarget As Range : Set vbaTarget = " VBA_MACRONAME_TARGETCONV "( unoTarget )\n" - "\tIf Not vbaTarget Is Nothing Then $MACRO vbaTarget, Cancel\n" - "\t$PROXY = Cancel" ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnDoubleClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeDoubleClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); - bNeedsTargetHelper |= attachMacroToEvent( rxEventsSupp, CREATE_OUSTRING( "OnRightClick" ), rCodeName, CREATE_OUSTRING( "Worksheet_BeforeRightClick" ), aClickProxyArgs, aClickProxyRetT, aClickProxyCode ); - - if( bNeedsTargetHelper ) - { - /* Generate a helper function that converts a - com.sun.star.sheet.SheetCellRange object to a VBA Range object. - */ - OUString aRangeConvName = CREATE_OUSTRING( VBA_MACRONAME_RANGECONV ); - OUString aRangeConvArgs = CREATE_OUSTRING( "ByVal unoRange As com.sun.star.sheet.SheetCellRange" ); - OUString aRangeConvRetT = CREATE_OUSTRING( "Range" ); - OUString aRangeConvCode = CREATE_OUSTRING( - "\tDim unoAddress As com.sun.star.table.CellRangeAddress : Set unoAddress = unoRange.RangeAddress\n" - "\tDim vbaSheet As Worksheet : Set vbaSheet = Application.ThisWorkbook.Sheets( unoAddress.Sheet + 1 )\n" - "\tSet $MACRO = vbaSheet.Range( vbaSheet.Cells( unoAddress.StartRow + 1, unoAddress.StartColumn + 1 ), vbaSheet.Cells( unoAddress.EndRow + 1, unoAddress.EndColumn + 1 ) )" ); - insertMacro( rCodeName, aRangeConvName, aRangeConvArgs, aRangeConvRetT, aRangeConvCode ); - - /* Generate a helper function that converts a generic range selection - object (com.sun.star.sheet.SheetCellRange or - com.sun.star.sheet.SheetCellRanges) to a VBA Range object. - */ - OUString aTargetConvName = CREATE_OUSTRING( VBA_MACRONAME_TARGETCONV ); - OUString aTargetConvArgs = CREATE_OUSTRING( "ByVal unoTarget As Object" ); - OUString aTargetConvRetT = CREATE_OUSTRING( "Range" ); - OUString aTargetConvCode = CREATE_OUSTRING( - "\tDim vbaTarget As Range\n" - "\tIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRange\" ) Then\n" - "\t\tSet vbaTarget = " VBA_MACRONAME_RANGECONV "( unoTarget )\n" - "\tElseIf unoTarget.supportsService( \"com.sun.star.sheet.SheetCellRanges\" ) Then\n" - "\t\tDim unoRangeEnum As Object : Set unoRangeEnum = unoTarget.createEnumeration\n" - "\t\tIf unoRangeEnum.hasMoreElements Then Set vbaTarget = " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement )\n" - "\t\tWhile unoRangeEnum.hasMoreElements\n" - "\t\t\tSet vbaTarget = Application.Union( vbaTarget, " VBA_MACRONAME_RANGECONV "( unoRangeEnum.nextElement ) )\n" - "\t\tWend\n" - "\tEnd If\n" - "\tSet $MACRO = vbaTarget" ); - insertMacro( rCodeName, aTargetConvName, aTargetConvArgs, aTargetConvRetT, aTargetConvCode ); - } -#undef VBA_MACRONAME_RANGECONV -#undef VBA_MACRONAME_TARGETCONV -} - -// ============================================================================ - -} // namespace xls -} // namespace oox diff --git a/oox/source/xls/makefile.mk b/oox/source/xls/makefile.mk index b5ede953bbfe..cdb2e18c262d 100644 --- a/oox/source/xls/makefile.mk +++ b/oox/source/xls/makefile.mk @@ -59,7 +59,6 @@ SLOFILES = \ $(SLO)$/excelchartconverter.obj \ $(SLO)$/excelfilter.obj \ $(SLO)$/excelhandlers.obj \ - $(SLO)$/excelvbaproject.obj \ $(SLO)$/externallinkbuffer.obj \ $(SLO)$/externallinkfragment.obj \ $(SLO)$/formulabase.obj \ diff --git a/oox/source/xls/workbookhelper.cxx b/oox/source/xls/workbookhelper.cxx index afeed95accca..5684fbd8ae75 100644 --- a/oox/source/xls/workbookhelper.cxx +++ b/oox/source/xls/workbookhelper.cxx @@ -43,6 +43,7 @@ #include "properties.hxx" #include "oox/helper/progressbar.hxx" #include "oox/helper/propertyset.hxx" +#include "oox/ole/vbaproject.hxx" #include "oox/drawingml/theme.hxx" #include "oox/xls/addressconverter.hxx" #include "oox/xls/biffinputstream.hxx" @@ -50,7 +51,6 @@ #include "oox/xls/defnamesbuffer.hxx" #include "oox/xls/excelchartconverter.hxx" #include "oox/xls/excelfilter.hxx" -#include "oox/xls/excelvbaproject.hxx" #include "oox/xls/externallinkbuffer.hxx" #include "oox/xls/formulaparser.hxx" #include "oox/xls/pagesettings.hxx" @@ -687,14 +687,12 @@ void WorkbookHelper::finalizeWorkbookImport() aDefPageStyle.setProperty< sal_Int16 >( PROP_FirstPageNumber, 0 ); /* Import the VBA project (after finalizing workbook settings which - contains the workbook code name), and attach VBA macros to document and - sheet events. */ + contains the workbook code name). */ StorageRef xVbaPrjStrg = mrBookData.getVbaProjectStorage(); if( xVbaPrjStrg.get() && xVbaPrjStrg->isStorage() ) { - VbaProject aVbaProject( getGlobalFactory(), getDocument() ); + ::oox::ole::VbaProject aVbaProject( getGlobalFactory(), getBaseFilter().getModel(), CREATE_OUSTRING( "Calc" ) ); aVbaProject.importVbaProject( *xVbaPrjStrg, getBaseFilter().getGraphicHelper() ); - aVbaProject.attachToEvents(); } } -- cgit v1.2.3 From d5bbb90b33416ad70987ab6725e41c1ce673ab93 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 19:34:53 +0200 Subject: mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power --- sc/inc/document.hxx | 13 +- sc/inc/docuno.hxx | 9 + sc/inc/sheetevents.hxx | 2 + sc/source/core/data/documen2.cxx | 30 +- sc/source/core/data/documen3.cxx | 38 +- sc/source/core/data/documen7.cxx | 2 +- sc/source/core/data/sheetevents.cxx | 35 +- sc/source/filter/excel/excimp8.cxx | 18 - sc/source/filter/inc/excimp8.hxx | 1 - sc/source/ui/docshell/docsh.cxx | 108 ++++- sc/source/ui/docshell/docsh4.cxx | 2 +- sc/source/ui/unoobj/docuno.cxx | 108 +++-- sc/source/ui/unoobj/viewuno.cxx | 140 ++++--- sc/source/ui/vba/makefile.mk | 2 + sc/source/ui/vba/service.cxx | 12 +- sc/source/ui/vba/vbaapplication.cxx | 20 +- sc/source/ui/vba/vbaapplication.hxx | 7 +- sc/source/ui/vba/vbaeventshelper.cxx | 775 +++++++++++++++++++++++++++++++++++ sc/source/ui/vba/vbaeventshelper.hxx | 86 ++++ sc/source/ui/vba/vbaglobals.cxx | 1 + sc/source/ui/view/gridwin.cxx | 76 +++- sc/source/ui/view/makefile.mk | 1 + 22 files changed, 1330 insertions(+), 156 deletions(-) mode change 100755 => 100644 sc/source/core/data/documen2.cxx create mode 100755 sc/source/ui/vba/vbaeventshelper.cxx create mode 100755 sc/source/ui/vba/vbaeventshelper.hxx diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 0f22b40eef1d..a829787aac2f 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -159,6 +159,9 @@ namespace com { namespace sun { namespace star { namespace embed { class XEmbeddedObject; } + namespace script { namespace vba { + class XEventProcessor; + } } } } } #include @@ -329,6 +332,10 @@ private: Timer aTrackTimer; + // mutable for lazy construction + mutable com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > + mxVbaEvents; + public: ScTabOpList aTableOpList; // list of ScInterpreterTableOpParams currently in use ScInterpreterTableOpParams aLastTableOpParams; // remember last params @@ -733,7 +740,8 @@ public: const ScSheetEvents* GetSheetEvents( SCTAB nTab ) const; void SetSheetEvents( SCTAB nTab, const ScSheetEvents* pNew ); - bool HasSheetEventScript( sal_Int32 nEvent ) const; // on any sheet + bool HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVbaEvents = false ) const; + bool HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents = false ) const; // on any sheet BOOL HasCalcNotification( SCTAB nTab ) const; void SetCalcNotification( SCTAB nTab ); @@ -1751,6 +1759,9 @@ public: void GetSortParam( ScSortParam& rParam, SCTAB nTab ); void SetSortParam( ScSortParam& rParam, SCTAB nTab ); + com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > + GetVbaEventProcessor() const; + /** Should only be GRAM_PODF or GRAM_ODFF. */ void SetStorageGrammar( formula::FormulaGrammar::Grammar eGrammar ); formula::FormulaGrammar::Grammar GetStorageGrammar() const diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 2c3ecee39e32..fd2d9a706556 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,7 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel, public com::sun::star::view::XRenderable, public com::sun::star::document::XLinkTargetSupplier, public com::sun::star::beans::XPropertySet, + public com::sun::star::script::vba::XCoreEventProcessor, public SvxFmMSFactory, // derived from XMultiServiceFactory public com::sun::star::lang::XServiceInfo, public ::com::sun::star::util::XChangesNotifier @@ -321,6 +323,13 @@ public: virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); + + // XCoreEventProcessor + virtual void SAL_CALL processCoreVbaEvent( sal_Int32 nSlotId ) + throw (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::script::provider::ScriptFrameworkErrorException, + ::com::sun::star::util::VetoException, + ::com::sun::star::uno::RuntimeException); }; diff --git a/sc/inc/sheetevents.hxx b/sc/inc/sheetevents.hxx index 8f52efb990f7..bb27f5cf2068 100755 --- a/sc/inc/sheetevents.hxx +++ b/sc/inc/sheetevents.hxx @@ -59,6 +59,8 @@ public: void SetScript(sal_Int32 nEvent, const rtl::OUString* pNew); static rtl::OUString GetEventName(sal_Int32 nEvent); + static sal_Int32 GetVbaSheetEventId(sal_Int32 nEvent); + static sal_Int32 GetVbaDocumentEventId(sal_Int32 nEvent); }; #endif diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx old mode 100755 new mode 100644 index c5922aa88dcc..4cd23ca66353 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -50,6 +50,9 @@ #include #include #include +#include +#include +#include #include "document.hxx" #include "table.hxx" @@ -93,7 +96,8 @@ #include "tabprotection.hxx" #include "formulaparserpool.hxx" #include "clipparam.hxx" -#include + +using namespace com::sun::star; // pImpl because including lookupcache.hxx in document.hxx isn't wanted, and // dtor plus helpers are convenient. @@ -1116,11 +1120,11 @@ ULONG ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos, String sCodeName; String sSource; - com::sun::star::uno::Reference< com::sun::star::script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); - com::sun::star::uno::Reference< com::sun::star::container::XNameContainer > xLib; + uno::Reference< script::XLibraryContainer > xLibContainer = pSrcShell->GetBasicContainer(); + uno::Reference< container::XNameContainer > xLib; if( xLibContainer.is() ) { - com::sun::star::uno::Any aLibAny = xLibContainer->getByName( aLibName ); + uno::Any aLibAny = xLibContainer->getByName( aLibName ); aLibAny >>= xLib; } @@ -1289,6 +1293,24 @@ void ScDocument::RemoveLookupCache( ScLookupCache & rCache ) } } +uno::Reference< script::vba::XEventProcessor > ScDocument::GetVbaEventProcessor() const +{ + if( !mxVbaEvents.is() && pShell && ooo::vba::isAlienExcelDoc( *pShell ) ) + { + try + { + uno::Reference< frame::XModel > xModel( pShell->GetModel(), uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xModel; + mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pShell, "com.sun.star.script.vba.SpreadsheetEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); + } + catch( uno::Exception& ) + { + } + } + return mxVbaEvents; +} + void ScDocument::ClearLookupCaches() { if( pLookupCacheMapImpl ) diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 8fb9e764259d..a27e5b0a13d5 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -30,6 +30,7 @@ // INCLUDE --------------------------------------------------------------- +#include #include "scitems.hxx" #include #include @@ -88,7 +89,6 @@ #include using namespace com::sun::star; -using ::std::auto_ptr; //------------------------------------------------------------------------ @@ -492,15 +492,39 @@ void ScDocument::SetSheetEvents( SCTAB nTab, const ScSheetEvents* pNew ) pTab[nTab]->SetSheetEvents( pNew ); } -bool ScDocument::HasSheetEventScript( sal_Int32 nEvent ) const +bool ScDocument::HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVbaEvents ) const { - for (SCTAB nTab = 0; nTab <= MAXTAB; nTab++) - if (pTab[nTab]) + if (pTab[nTab]) + { + // check if any event handler script has been configured + const ScSheetEvents* pEvents = pTab[nTab]->GetSheetEvents(); + if ( pEvents && pEvents->GetScript( nEvent ) ) + return true; + // check if VBA event handlers exist + if (bWithVbaEvents) { - const ScSheetEvents* pEvents = pTab[nTab]->GetSheetEvents(); - if ( pEvents && pEvents->GetScript( nEvent ) ) - return true; + uno::Reference< script::vba::XEventProcessor > xVbaEvents = GetVbaEventProcessor(); + if ( xVbaEvents.is() ) try + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= nTab; + if (xVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ) || + xVbaEvents->hasVbaEventHandler( ScSheetEvents::GetVbaDocumentEventId( nEvent ), uno::Sequence< uno::Any >() )) + return true; + } + catch( uno::Exception& ) + { + } } + } + return false; +} + +bool ScDocument::HasAnySheetEventScript( sal_Int32 nEvent, bool bWithVbaEvents ) const +{ + for (SCTAB nTab = 0; nTab <= MAXTAB; nTab++) + if (HasSheetEventScript( nTab, nEvent, bWithVbaEvents )) + return true; return false; } diff --git a/sc/source/core/data/documen7.cxx b/sc/source/core/data/documen7.cxx index 97aae44f1a7b..d77dc1041d9c 100644 --- a/sc/source/core/data/documen7.cxx +++ b/sc/source/core/data/documen7.cxx @@ -454,7 +454,7 @@ void ScDocument::TrackFormulas( ULONG nHintId ) { erBEEPER(); // outside the loop, check if any sheet has a "calculate" event script - bool bCalcEvent = HasSheetEventScript( SC_SHEETEVENT_CALCULATE ); + bool bCalcEvent = HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ); SvtBroadcaster* pBC; ScFormulaCell* pTrack; ScFormulaCell* pNext; diff --git a/sc/source/core/data/sheetevents.cxx b/sc/source/core/data/sheetevents.cxx index e9e430ef85d9..6086eb84dcbb 100755 --- a/sc/source/core/data/sheetevents.cxx +++ b/sc/source/core/data/sheetevents.cxx @@ -33,9 +33,9 @@ // INCLUDE --------------------------------------------------------------- -#include - #include "sheetevents.hxx" +#include +#include // ----------------------------------------------------------------------- @@ -61,6 +61,37 @@ rtl::OUString ScSheetEvents::GetEventName(sal_Int32 nEvent) return rtl::OUString::createFromAscii(aEventNames[nEvent]); } +// static +sal_Int32 ScSheetEvents::GetVbaSheetEventId(sal_Int32 nEvent) +{ + using namespace ::com::sun::star::script::vba::EventIdentifier; + if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT) + { + DBG_ERRORFILE("invalid event number"); + return NO_EVENT; + } + + static const sal_Int32 nVbaEventIds[] = + { + WORKSHEET_ACTIVATE, // SC_SHEETEVENT_FOCUS + WORKSHEET_DEACTIVATE, // SC_SHEETEVENT_UNFOCUS + WORKSHEET_SELECTIONCHANGE, // SC_SHEETEVENT_SELECT + WORKSHEET_BEFOREDOUBLECLICK, // SC_SHEETEVENT_DOUBLECLICK + WORKSHEET_BEFORERIGHTCLICK, // SC_SHEETEVENT_RIGHTCLICK + WORKSHEET_CHANGE, // SC_SHEETEVENT_CHANGE + WORKSHEET_CALCULATE // SC_SHEETEVENT_CALCULATE + }; + return nVbaEventIds[nEvent]; +} + +// static +sal_Int32 ScSheetEvents::GetVbaDocumentEventId(sal_Int32 nEvent) +{ + using namespace ::com::sun::star::script::vba::EventIdentifier; + sal_Int32 nSheetEventId = GetVbaSheetEventId(nEvent); + return (nSheetEventId != NO_EVENT) ? (nSheetEventId + USERDEFINED_START) : NO_EVENT; +} + // ----------------------------------------------------------------------- ScSheetEvents::ScSheetEvents() : diff --git a/sc/source/filter/excel/excimp8.cxx b/sc/source/filter/excel/excimp8.cxx index 9608804da9f9..378df4704faa 100644 --- a/sc/source/filter/excel/excimp8.cxx +++ b/sc/source/filter/excel/excimp8.cxx @@ -56,7 +56,6 @@ #include #include #include -#include #include #include @@ -292,8 +291,6 @@ void ImportExcel8::PostDocLoad( void ) // read doc info (no docshell while pasting from clipboard) LoadDocumentProperties(); - // attach document events to VBA macros - AttachDocumentEvents(); // #i45843# Pivot tables are now handled outside of PostDocLoad, so they are available // when formula cells are calculated, for the GETPIVOTDATA function. @@ -318,21 +315,6 @@ void ImportExcel8::LoadDocumentProperties() } } -void ImportExcel8::AttachDocumentEvents() -{ - SfxObjectShell* pShell = GetDocShell(); - if( HasBasic() && pShell ) - { - uno::Reference< lang::XMultiServiceFactory > xGlobalFactory = ::comphelper::getProcessServiceFactory(); - uno::Reference< sheet::XSpreadsheetDocument > xDocument( pShell->GetModel(), uno::UNO_QUERY ); - if( xGlobalFactory.is() && xDocument.is() ) - { - ::oox::xls::VbaProject aVbaProject( xGlobalFactory, xDocument ); - aVbaProject.attachToEvents(); - } - } -} - //___________________________________________________________________ // autofilter diff --git a/sc/source/filter/inc/excimp8.hxx b/sc/source/filter/inc/excimp8.hxx index 5b2bbe2e7b5d..7e4cca15dfe1 100644 --- a/sc/source/filter/inc/excimp8.hxx +++ b/sc/source/filter/inc/excimp8.hxx @@ -81,7 +81,6 @@ protected: private: void LoadDocumentProperties(); - void AttachDocumentEvents(); }; diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 135bbcdace49..9dd754bbc555 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -29,15 +29,11 @@ #include "precompiled_sc.hxx" // System - Includes ----------------------------------------------------- - - #include "scitems.hxx" #include #include #include - - #include #include #include @@ -68,7 +64,10 @@ #include "chgviset.hxx" #include #include - +#include +#include +#include +#include #include "scabstdlg.hxx" //CHINA001 #include @@ -123,8 +122,9 @@ #include #include -#include -#include +#include "uiitems.hxx" +#include "cellsuno.hxx" + using namespace com::sun::star; using ::rtl::OUString; using ::rtl::OUStringBuffer; @@ -272,6 +272,11 @@ void ScDocShell::BeforeXMLLoading() { aDocument.DisableIdle( TRUE ); + // suppress VBA events when loading the xml + uno::Reference< script::vba::XEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + if( xVbaEvents.is() ) + xVbaEvents->setIgnoreEvents( sal_True ); + // prevent unnecessary broadcasts and updates DBG_ASSERT(pModificator == NULL, "The Modificator should not exist"); pModificator = new ScDocShellModificator( *this ); @@ -377,6 +382,12 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) BasicManager* pAppMgr = SFX_APP()->GetBasicManager(); if ( pAppMgr ) pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); +#if 0 // this should be controlled by a compatibility mode + // suppress VBA events when loading the xml + uno::Reference< script::vba::XEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + if( xVbaEvents.is() ) + xVbaEvents->setIgnoreEvents( sal_False ); +#endif #endif aDocument.SetImportingXML( FALSE ); aDocument.EnableExecuteLink( true ); @@ -499,9 +510,70 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium ) return bRet; } - void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { + uno::Reference< script::vba::XEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + if ( xVbaEvents.is() ) try + { + using namespace ::com::sun::star::script::vba::EventIdentifier; + if (rHint.ISA(ScTablesHint) ) + { + const ScTablesHint& rScHint = static_cast< const ScTablesHint& >( rHint ); + if (rScHint.GetId() == SC_TAB_INSERTED) + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[0] <<= rScHint.GetTab1(); + xVbaEvents->processVbaEvent( WORKBOOK_NEWSHEET, aArgs ); + } + } + else if ( rHint.ISA( SfxEventHint ) ) + { + ULONG nEventId = static_cast< const SfxEventHint& >( rHint ).GetEventId(); + switch ( nEventId ) + { + case SFX_EVENT_ACTIVATEDOC: + { + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( WORKBOOK_ACTIVATE, aArgs ); + } + break; + case SFX_EVENT_DEACTIVATEDOC: + { + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( WORKBOOK_DEACTIVATE, aArgs ); + } + break; + case SFX_EVENT_OPENDOC: + { + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( WORKBOOK_OPEN, aArgs ); + } + break; + case SFX_EVENT_SAVEDOCDONE: + case SFX_EVENT_SAVEASDOCDONE: + case SFX_EVENT_SAVETODOCDONE: + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= true; + xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs ); + } + break; + case SFX_EVENT_SAVEASDOCFAILED: + case SFX_EVENT_SAVEDOCFAILED: + case SFX_EVENT_SAVETODOCFAILED: + { + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= false; + xVbaEvents->processVbaEvent( WORKBOOK_AFTERSAVE, aArgs ); + } + break; + } + } + } + catch( uno::Exception& ) + { + } + if (rHint.ISA(SfxSimpleHint)) // ohne Parameter { ULONG nSlot = ((const SfxSimpleHint&)rHint).GetId(); @@ -2197,6 +2269,26 @@ USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) DoEnterHandler(); + // start 'Workbook_BeforeClose' VBA event handler for possible veto + if( !IsInPrepareClose() ) + { + try + { + uno::Reference< script::vba::XEventProcessor > xVbaEvents( aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( script::vba::EventIdentifier::WORKBOOK_BEFORECLOSE, aArgs ); + } + catch( util::VetoException& ) + { + // if event processor throws VetoException, macro has vetoed close + return sal_False; + } + catch( uno::Exception& ) + { + } + } + // end handler code + USHORT nRet = SfxObjectShell::PrepareClose( bUI, bForBrowsing ); if (nRet == TRUE) // TRUE = schliessen aDocument.DisableIdle(TRUE); // nicht mehr drin rumpfuschen !!! diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx index f7bcb3ea9f44..a9c92a4b8dbd 100644 --- a/sc/source/ui/docshell/docsh4.cxx +++ b/sc/source/ui/docshell/docsh4.cxx @@ -1295,7 +1295,7 @@ void ScDocShell::DoHardRecalc( BOOL /* bApi */ ) // (might check for the presence of any formulas on each sheet) SCTAB nTabCount = aDocument.GetTableCount(); SCTAB nTab; - if (aDocument.HasSheetEventScript( SC_SHEETEVENT_CALCULATE )) + if (aDocument.HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true )) // search also for VBA hendler for (nTab=0; nTab #include #include #include #include +#include #include #include @@ -49,6 +48,7 @@ #include #include #include + #include #include // DBL_MAX @@ -60,6 +60,8 @@ #include #include #include +#include +#include #include #include #include @@ -100,12 +102,10 @@ #include "sc.hrc" #include "scresid.hxx" -#ifndef _SVX_UNOSHAPE_HXX -#include -#endif - using namespace com::sun::star; +#define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ? + //------------------------------------------------------------------------ // alles ohne Which-ID, Map nur fuer PropertySetInfo @@ -120,6 +120,7 @@ const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, + {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ), 0, &getCppuType((beans::PropertyValue*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, @@ -468,6 +469,7 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) SC_QUERYINTERFACE( view::XRenderable ) SC_QUERYINTERFACE( document::XLinkTargetSupplier ) SC_QUERYINTERFACE( beans::XPropertySet ) + SC_QUERYINTERFACE( script::vba::XCoreEventProcessor ) SC_QUERYINTERFACE( lang::XMultiServiceFactory ) SC_QUERYINTERFACE( lang::XServiceInfo ) SC_QUERYINTERFACE( util::XChangesNotifier ) @@ -593,8 +595,8 @@ void ScModelObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) DELETEZ( pPrintFuncCache ); - // handle "OnCalculate" sheet events - if ( pDocShell && pDocShell->GetDocument()->HasSheetEventScript( SC_SHEETEVENT_CALCULATE ) ) + // handle "OnCalculate" sheet events (search also for VBA event handlers) + if ( pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript( SC_SHEETEVENT_CALCULATE, true ) ) HandleCalculateEvents(); } } @@ -1885,6 +1887,18 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa { aRet <<= pDocShell->GetDialogContainer(); } + else if ( aString.EqualsAscii( SC_UNO_VBADOCOBJ ) ) + { + // PropertyValue seems extreme because we store + // the model ( as the value member ) of the PropertyValue that is + // itself a property of the model ( the intention however is to + // store something like a Workbook object... but we don't do that ) + // yet + beans::PropertyValue aProp; + aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") ); + aProp.Value <<= pDocShell->GetModel(); + aRet <<= aProp; + } else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) ) { aRet <<= getRuntimeUID(); @@ -2058,6 +2072,38 @@ uno::Sequence SAL_CALL ScModelObj::getAvailableServiceNames() return concatServiceNames( aMyServices, aDrawServices ); } +// XCoreEventProcessor + +void SAL_CALL ScModelObj::processCoreVbaEvent( sal_Int32 nSlotId ) + throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException) +{ + using namespace ::com::sun::star::script::vba; + + sal_Int32 nVbaEventId = EventIdentifier::NO_EVENT; + uno::Sequence< uno::Any > aArgs; + switch( nSlotId ) + { + case SID_SAVEDOC: + case SID_SAVEASDOC: + nVbaEventId = EventIdentifier::WORKBOOK_BEFORESAVE; + aArgs.realloc( 1 ); + aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC); + break; + case SID_PRINTDOC: + case SID_PRINTDOCDIRECT: + nVbaEventId = EventIdentifier::WORKBOOK_BEFOREPRINT; + break; + default: + throw lang::IllegalArgumentException(); + } + + uno::Reference< XEventProcessor > xEventProcessor( GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY ); + if( !xEventProcessor.is() ) + throw script::provider::ScriptFrameworkErrorException(); + + xEventProcessor->processVbaEvent( nVbaEventId, aArgs ); +} + // XServiceInfo rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException) @@ -2173,20 +2219,8 @@ bool ScModelObj::HasChangesListeners() const if ( maChangesListeners.getLength() > 0 ) return true; - if ( pDocShell ) - { - // "change" event set in any sheet? - ScDocument* pDoc = pDocShell->GetDocument(); - SCTAB nTabCount = pDoc->GetTableCount(); - for (SCTAB nTab = 0; nTab < nTabCount; nTab++) - { - const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); - if (pEvents && pEvents->GetScript(SC_SHEETEVENT_CHANGE)) - return true; - } - } - - return false; + // "change" event set in any sheet? + return pDocShell && pDocShell->GetDocument()->HasAnySheetEventScript(SC_SHEETEVENT_CHANGE); } void ScModelObj::NotifyChanges( const ::rtl::OUString& rOperation, const ScRangeList& rRanges, @@ -2300,17 +2334,29 @@ void ScModelObj::HandleCalculateEvents() SCTAB nTabCount = pDoc->GetTableCount(); for (SCTAB nTab = 0; nTab < nTabCount; nTab++) { - const ScSheetEvents* pEvents = pDoc->GetSheetEvents(nTab); - if (pEvents) + if (pDoc->HasCalcNotification(nTab)) { - const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE); - if (pScript && pDoc->HasCalcNotification(nTab)) + if (const ScSheetEvents* pEvents = pDoc->GetSheetEvents( nTab )) + { + if (const rtl::OUString* pScript = pEvents->GetScript(SC_SHEETEVENT_CALCULATE)) + { + uno::Any aRet; + uno::Sequence aParams; + uno::Sequence aOutArgsIndex; + uno::Sequence aOutArgs; + pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); + } + } + + try + { + uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= nTab; + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_CALCULATE ), aArgs ); + } + catch( uno::Exception& ) { - uno::Any aRet; - uno::Sequence aParams; - uno::Sequence aOutArgsIndex; - uno::Sequence aOutArgs; - pDocShell->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } } diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index d10d3ba54f86..025e699552e1 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -28,6 +28,10 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include +#include +#include +#include #include #include @@ -67,8 +71,6 @@ #include "appoptio.hxx" #include "gridwin.hxx" #include "sheetevents.hxx" -#include -#include #include "AccessibilityHints.hxx" #include @@ -468,7 +470,8 @@ void SAL_CALL ScViewPaneObj::release() throw() //UNUSED2008-05 aPropSet( lcl_GetViewOptPropertyMap() ), //UNUSED2008-05 aMouseClickHandlers( 0 ), //UNUSED2008-05 aActivationListeners( 0 ), -//UNUSED2008-05 bDrawSelModeSet(sal_False) +//UNUSED2008-05 bDrawSelModeSet(sal_False), +//UNUSED2008-05 bFilteredRangeSelection(sal_True) //UNUSED2008-05 { //UNUSED2008-05 } @@ -551,10 +554,22 @@ void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent ) uno::Sequence aParams; uno::Sequence aOutArgsIndex; uno::Sequence aOutArgs; - /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } + + // execute VBA event handlers + try + { + uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + // the parameter is the clicked object, as in the mousePressed call above + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= nTab; + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ); + } + catch( uno::Exception& ) + { + } } void ScTabViewObj::SheetChanged() @@ -1242,14 +1257,12 @@ bool ScTabViewObj::IsMouseListening() const return true; // also include sheet events, because MousePressed must be called for them - ScTabViewShell* pViewSh = GetViewShell(); - ScViewData* pViewData = pViewSh->GetViewData(); - const ScSheetEvents* pEvents = pViewData->GetDocument()->GetSheetEvents(pViewData->GetTabNo()); - if ( pEvents && ( pEvents->GetScript(SC_SHEETEVENT_RIGHTCLICK) != NULL || - pEvents->GetScript(SC_SHEETEVENT_DOUBLECLICK) != NULL ) ) - return true; - - return false; + ScViewData* pViewData = GetViewShell()->GetViewData(); + ScDocument* pDoc = pViewData->GetDocument(); + SCTAB nTab = pViewData->GetTabNo(); + return + pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_RIGHTCLICK, true ) || + pDoc->HasSheetEventScript( nTab, SC_SHEETEVENT_DOUBLECLICK, true ); } sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) @@ -1257,33 +1270,29 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) { sal_Bool bReturn(sal_False); - if (aMouseClickHandlers.Count()) + uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); + if (aMouseClickHandlers.Count() && xTarget.is()) { - uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); + awt::EnhancedMouseEvent aMouseEvent; - if (xTarget.is()) - { - awt::EnhancedMouseEvent aMouseEvent; + aMouseEvent.Buttons = e.Buttons; + aMouseEvent.X = e.X; + aMouseEvent.Y = e.Y; + aMouseEvent.ClickCount = e.ClickCount; + aMouseEvent.PopupTrigger = e.PopupTrigger; + aMouseEvent.Target = xTarget; - aMouseEvent.Buttons = e.Buttons; - aMouseEvent.X = e.X; - aMouseEvent.Y = e.Y; - aMouseEvent.ClickCount = e.ClickCount; - aMouseEvent.PopupTrigger = e.PopupTrigger; - aMouseEvent.Target = xTarget; - - for ( USHORT n=0; nmousePressed( aMouseEvent )) - bReturn = sal_True; - } - catch ( uno::Exception& ) - { - aMouseClickHandlers.DeleteAndDestroy(n); - --n; // because it will be increased again in the loop - } + if (!(*aMouseClickHandlers[n])->mousePressed( aMouseEvent )) + bReturn = sal_True; + } + catch ( uno::Exception& ) + { + aMouseClickHandlers.DeleteAndDestroy(n); + --n; // because it will be increased again in the loop } } } @@ -1291,7 +1300,7 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) // handle sheet events bool bDoubleClick = ( e.Buttons == awt::MouseButton::LEFT && e.ClickCount == 2 ); bool bRightClick = ( e.Buttons == awt::MouseButton::RIGHT && e.ClickCount == 1 ); - if ( ( bDoubleClick || bRightClick ) && !bReturn ) + if ( ( bDoubleClick || bRightClick ) && !bReturn && xTarget.is()) { sal_Int32 nEvent = bDoubleClick ? SC_SHEETEVENT_DOUBLECLICK : SC_SHEETEVENT_RIGHTCLICK; @@ -1307,28 +1316,41 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) if (pScript) { // the macro parameter is the clicked object, as in the mousePressed call above - uno::Reference< uno::XInterface > xTarget = GetClickedObject(Point(e.X, e.Y)); - if (xTarget.is()) - { - uno::Sequence aParams(1); - aParams[0] <<= xTarget; + uno::Sequence aParams(1); + aParams[0] <<= xTarget; - uno::Any aRet; - uno::Sequence aOutArgsIndex; - uno::Sequence aOutArgs; + uno::Any aRet; + uno::Sequence aOutArgsIndex; + uno::Sequence aOutArgs; - /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); + /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); - // look for a boolean return value of true - sal_Bool bRetValue = sal_False; - if (aRet >>= bRetValue) - { - if (bRetValue) - bReturn = sal_True; - } + // look for a boolean return value of true + sal_Bool bRetValue = sal_False; + if (aRet >>= bRetValue) + { + if (bRetValue) + bReturn = sal_True; } } } + + // execute VBA event handler + if (!bReturn && xTarget.is()) try + { + uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + // the parameter is the clicked object, as in the mousePressed call above + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= xTarget; + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( nEvent ), aArgs ); + } + catch( util::VetoException& ) + { + bReturn = sal_True; + } + catch( uno::Exception& ) + { + } } return bReturn; @@ -1820,14 +1842,24 @@ void ScTabViewObj::SelectionChanged() // the macro parameter is the selection as returned by getSelection uno::Sequence aParams(1); aParams[0] = getSelection(); - uno::Any aRet; uno::Sequence aOutArgsIndex; uno::Sequence aOutArgs; - /*ErrCode eRet =*/ pDocSh->CallXScript( *pScript, aParams, aRet, aOutArgsIndex, aOutArgs ); } } + // execute VBA event handler + try + { + uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + // the parameter is the clicked object, as in the mousePressed call above + uno::Sequence< uno::Any > aArgs( 1 ); + aArgs[ 0 ] <<= getSelection(); + xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_SELECT ), aArgs ); + } + catch( uno::Exception& ) + { + } } diff --git a/sc/source/ui/vba/makefile.mk b/sc/source/ui/vba/makefile.mk index 0a84b8dd12a5..4cb7e3eb064b 100644 --- a/sc/source/ui/vba/makefile.mk +++ b/sc/source/ui/vba/makefile.mk @@ -102,7 +102,9 @@ SLOFILES= \ $(SLO)$/vbapagesetup.obj \ $(SLO)$/vbapagebreak.obj \ $(SLO)$/vbapagebreaks.obj \ + $(SLO)$/vbaeventshelper.obj \ $(SLO)$/service.obj + .ENDIF # --- Targets ------------------------------------------------------ diff --git a/sc/source/ui/vba/service.cxx b/sc/source/ui/vba/service.cxx index 8be0f6d9f726..2b1f14cf154a 100644 --- a/sc/source/ui/vba/service.cxx +++ b/sc/source/ui/vba/service.cxx @@ -66,6 +66,10 @@ namespace application { extern sdecl::ServiceDecl const serviceDecl; } +namespace vbaeventshelper +{ +extern sdecl::ServiceDecl const serviceDecl; +} namespace textframe { extern sdecl::ServiceDecl const serviceDecl; @@ -87,7 +91,7 @@ extern "C" #if 0 // Component registration if ( component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) ) + range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) ) { // Singleton registration try @@ -110,7 +114,7 @@ extern "C" #else // Component registration return component_writeInfoHelper( pServiceManager, pRegistryKey, - range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, textframe::serviceDecl ); + range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); #endif } @@ -122,8 +126,8 @@ extern "C" OSL_TRACE("In component_getFactory for %s", pImplName ); void* pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ); - if( !pRet ) - pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, textframe::serviceDecl ); + if( !pRet ) + pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl ); OSL_TRACE("Ret is 0x%x", pRet); return pRet; } diff --git a/sc/source/ui/vba/vbaapplication.cxx b/sc/source/ui/vba/vbaapplication.cxx index 1ed63ff39125..8006292331b6 100644 --- a/sc/source/ui/vba/vbaapplication.cxx +++ b/sc/source/ui/vba/vbaapplication.cxx @@ -117,7 +117,8 @@ public: ScVbaApplication::ScVbaApplication( const uno::Reference& xContext ) : ScVbaApplication_BASE( xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ), - m_xDisplayAlerts( sal_True) + m_bDisplayAlerts( sal_True ), + m_bEnableEvents( sal_True ) { } @@ -708,14 +709,27 @@ ScVbaApplication::getName() throw (uno::RuntimeException) void SAL_CALL ScVbaApplication::setDisplayAlerts(sal_Bool displayAlerts) throw (uno::RuntimeException) { - m_xDisplayAlerts = displayAlerts; + m_bDisplayAlerts = displayAlerts; } sal_Bool SAL_CALL ScVbaApplication::getDisplayAlerts() throw (uno::RuntimeException) { - return m_xDisplayAlerts; + return m_bDisplayAlerts; } + +void SAL_CALL +ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException) +{ + m_bEnableEvents = bEnable; +} + +sal_Bool SAL_CALL +ScVbaApplication::getEnableEvents() throw (uno::RuntimeException) +{ + return m_bEnableEvents; +} + void SAL_CALL ScVbaApplication::Calculate() throw( script::BasicErrorException , uno::RuntimeException ) { diff --git a/sc/source/ui/vba/vbaapplication.hxx b/sc/source/ui/vba/vbaapplication.hxx index 96638651bcd1..ff391b9187b8 100644 --- a/sc/source/ui/vba/vbaapplication.hxx +++ b/sc/source/ui/vba/vbaapplication.hxx @@ -43,7 +43,9 @@ class ScVbaApplication : public ScVbaApplication_BASE { private: sal_Int32 m_xCalculation; - sal_Bool m_xDisplayAlerts; + sal_Bool m_bDisplayAlerts; + sal_Bool m_bEnableEvents; + rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); protected: @@ -100,6 +102,9 @@ public: virtual ::sal_Int32 SAL_CALL getCursor() throw (css::uno::RuntimeException); virtual void SAL_CALL setCursor( ::sal_Int32 _cursor ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException); + virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException); + virtual css::uno::Any SAL_CALL Windows( const css::uno::Any& aIndex ) throw (css::uno::RuntimeException); virtual void SAL_CALL wait( double time ) throw (css::uno::RuntimeException); virtual css::uno::Any SAL_CALL Range( const css::uno::Any& Cell1, const css::uno::Any& Cell2 ) throw (css::uno::RuntimeException); diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx new file mode 100755 index 000000000000..c9e92a218877 --- /dev/null +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -0,0 +1,775 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vbaeventshelper.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include "cellsuno.hxx" +#include "convuno.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::script::vba::EventIdentifier; +using namespace ::ooo::vba; + +// ============================================================================ + +typedef ::cppu::WeakImplHelper1< util::XChangesListener > ScVbaChangesListener_BASE; + +class ScVbaChangesListener : public ScVbaChangesListener_BASE +{ +public: + ScVbaChangesListener( ScVbaEventsHelper* pHelper, ScDocShell* pDocShell ); + + virtual void SAL_CALL changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL disposing( const lang::EventObject& aSource ) throw (uno::RuntimeException); + +private: + ScVbaEventsHelper* mpVbaEvents; + ScDocShell* mpDocShell; +}; + +// ---------------------------------------------------------------------------- + +ScVbaChangesListener::ScVbaChangesListener( ScVbaEventsHelper* pHelper, ScDocShell* pDocShell ) : + mpVbaEvents( pHelper ), + mpDocShell( pDocShell ) +{ +} + +void SAL_CALL ScVbaChangesListener::changesOccurred( const util::ChangesEvent& aEvent ) throw (uno::RuntimeException) +{ + sal_Int32 nCount = aEvent.Changes.getLength(); + if( nCount == 0 ) + return; + + util::ElementChange aChange = aEvent.Changes[ 0 ]; + rtl::OUString sOperation; + aChange.Accessor >>= sOperation; + if( !sOperation.equalsIgnoreAsciiCaseAscii("cell-change") ) + return; + + if( nCount == 1 ) + { + uno::Reference< table::XCellRange > xRangeObj; + aChange.ReplacedElement >>= xRangeObj; + if( xRangeObj.is() ) + { + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xRangeObj; + mpVbaEvents->processVbaEvent( WORKSHEET_CHANGE, aArgs ); + } + return; + } + + ScRangeList aRangeList; + for( sal_Int32 nIndex = 0; nIndex < nCount; ++nIndex ) + { + aChange = aEvent.Changes[ nIndex ]; + aChange.Accessor >>= sOperation; + uno::Reference< table::XCellRange > xRangeObj; + aChange.ReplacedElement >>= xRangeObj; + if( xRangeObj.is() && sOperation.equalsIgnoreAsciiCaseAscii("cell-change") ) + { + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable( xRangeObj, uno::UNO_QUERY ); + if( xCellRangeAddressable.is() ) + { + ScRange aRange; + ScUnoConversion::FillScRange( aRange, xCellRangeAddressable->getRangeAddress() ); + aRangeList.Append( aRange ); + } + } + } + + if( (aRangeList.Count() > 0) && mpDocShell ) + { + uno::Reference< sheet::XSheetCellRangeContainer > xRanges( new ScCellRangesObj( mpDocShell, aRangeList ) ); + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xRanges; + mpVbaEvents->processVbaEvent( WORKSHEET_CHANGE, aArgs ); + } +} + +void SAL_CALL ScVbaChangesListener::disposing( const lang::EventObject& /*aSource*/ ) throw(uno::RuntimeException) +{ +} + +// ============================================================================ + +typedef ::cppu::WeakImplHelper3< + awt::XWindowListener, util::XCloseListener, frame::XBorderResizeListener > ScVbaWindowListener_BASE; + +// This class is to process Workbook window related event +class ScVbaWindowListener : public ScVbaWindowListener_BASE +{ +public : + ScVbaWindowListener( ScVbaEventsHelper* pHelper, const uno::Reference< frame::XModel >& rxModel ); + virtual ~ScVbaWindowListener(); + + void startListening(); + void stopListening(); + + // XWindowListener + virtual void SAL_CALL windowResized( const awt::WindowEvent& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL windowMoved( const awt::WindowEvent& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL windowShown( const lang::EventObject& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL windowHidden( const lang::EventObject& aEvent ) throw (uno::RuntimeException); + virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw (uno::RuntimeException); + + // XCloseListener + virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException); + virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException); + + // XBorderResizeListener + virtual void SAL_CALL borderWidthsChanged( const uno::Reference< uno::XInterface >& aObject, const frame::BorderWidths& aNewSize ) throw (uno::RuntimeException); + +private: + uno::Reference< frame::XFrame > getFrame(); + uno::Reference< awt::XWindow > getContainerWindow(); + bool isMouseReleased(); + DECL_LINK( fireResizeMacro, void* ); + void processWindowResizeMacro(); + +private: + ::osl::Mutex maMutex; + ScVbaEventsHelper* mpVbaEvents; + uno::Reference< frame::XModel > mxModel; + bool mbWindowResized; + bool mbBorderChanged; +}; + +// ---------------------------------------------------------------------------- + +ScVbaWindowListener::ScVbaWindowListener( ScVbaEventsHelper* pHelper, const uno::Reference< frame::XModel >& rxModel ) : + mpVbaEvents( pHelper ), + mxModel( rxModel ), + mbWindowResized( sal_False ), + mbBorderChanged( sal_False ) +{ + OSL_TRACE( "ScVbaWindowListener::ScVbaWindowListener( 0x%x ) - ctor ", this ); +} + +ScVbaWindowListener::~ScVbaWindowListener() +{ + OSL_TRACE( "ScVbaWindowListener::~ScVbaWindowListener( 0x%x ) - dtor ", this ); +} + +void ScVbaWindowListener::startListening() +{ + if( mxModel.is() ) + { + // add window listener + try + { + uno::Reference< awt::XWindow > xWindow( getContainerWindow(), uno::UNO_QUERY_THROW ); + xWindow->addWindowListener( this ); + } + catch( uno::Exception& ) + { + } + // add close listener + try + { + uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( mxModel, uno::UNO_QUERY_THROW ); + xCloseBroadcaster->addCloseListener( this ); + } + catch( uno::Exception& ) + { + } + // add Border resize listener + try + { + uno::Reference< frame::XControllerBorder > xControllerBorder( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); + xControllerBorder->addBorderResizeListener( this ); + } + catch( uno::Exception& ) + { + } + } +} + +void ScVbaWindowListener::stopListening() +{ + if( mxModel.is() ) + { + try + { + uno::Reference< awt::XWindow > xWindow( getContainerWindow(), uno::UNO_QUERY_THROW ); + xWindow->removeWindowListener( this ); + } + catch( uno::Exception& ) + { + } + try + { + uno::Reference< util::XCloseBroadcaster > xCloseBroadcaster( mxModel, uno::UNO_QUERY_THROW ); + xCloseBroadcaster->removeCloseListener( this ); + } + catch( uno::Exception& ) + { + } + try + { + uno::Reference< frame::XControllerBorder > xControllerBorder( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); + xControllerBorder->removeBorderResizeListener( this ); + } + catch( uno::Exception& ) + { + } + } + mpVbaEvents = 0; +} + +void SAL_CALL ScVbaWindowListener::windowResized( const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( maMutex ); + // Workbook_window_resize event + mbWindowResized = true; + if( mbBorderChanged ) + { + if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) ) + { + mbBorderChanged = mbWindowResized = false; + acquire(); // ensure we don't get deleted before the event is handled + Application::PostUserEvent( LINK( this, ScVbaWindowListener, fireResizeMacro ), 0 ); + } + } +} + +void SAL_CALL ScVbaWindowListener::windowMoved( const awt::WindowEvent& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + // not interest this time +} + +void SAL_CALL ScVbaWindowListener::windowShown( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + // not interest this time +} + +void SAL_CALL ScVbaWindowListener::windowHidden( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + // not interest this time +} + +void SAL_CALL ScVbaWindowListener::disposing( const lang::EventObject& /*aEvent*/ ) throw ( uno::RuntimeException ) +{ + ::osl::MutexGuard aGuard( maMutex ); + OSL_TRACE( "ScVbaWindowListener::disposing( 0x%x )", this ); + mpVbaEvents = 0; +} + +void SAL_CALL ScVbaWindowListener::queryClosing( const lang::EventObject& /*Source*/, sal_Bool /*GetsOwnership*/ ) throw (util::CloseVetoException, uno::RuntimeException) +{ + // it can cancel the close, but need to throw a CloseVetoException, and it will be transmit to caller. +} + +void SAL_CALL ScVbaWindowListener::notifyClosing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + stopListening(); +} + +void SAL_CALL ScVbaWindowListener::borderWidthsChanged( const uno::Reference< uno::XInterface >& /*aObject*/, const frame::BorderWidths& /*aNewSize*/ ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( maMutex ); + // work with WindowResized event to guard Window Resize event. + mbBorderChanged = true; + if( mbWindowResized ) + { + if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) ) + { + mbWindowResized = mbBorderChanged = false; + acquire(); // ensure we don't get deleted before the timer fires. + Application::PostUserEvent( LINK( this, ScVbaWindowListener, fireResizeMacro ), 0 ); + } + } +} + +// ---------------------------------------------------------------------------- + +uno::Reference< frame::XFrame > ScVbaWindowListener::getFrame() +{ + if( mpVbaEvents && mxModel.is() ) try + { + uno::Reference< frame::XController > xController( mxModel->getCurrentController(), uno::UNO_QUERY_THROW ); + return xController->getFrame(); + } + catch( uno::Exception& ) + { + } + return uno::Reference< frame::XFrame >(); +} + +uno::Reference< awt::XWindow > ScVbaWindowListener::getContainerWindow() +{ + try + { + uno::Reference< frame::XFrame > xFrame( getFrame(), uno::UNO_SET_THROW ); + return xFrame->getContainerWindow(); + } + catch( uno::Exception& ) + { + } + return uno::Reference< awt::XWindow >(); +} + +bool ScVbaWindowListener::isMouseReleased() +{ + if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) ) + { + Window::PointerState aPointerState = pWindow->GetPointerState(); + return (aPointerState.mnState & ( MOUSE_LEFT | MOUSE_MIDDLE | MOUSE_RIGHT )) == 0; + } + return false; +} + +IMPL_LINK( ScVbaWindowListener, fireResizeMacro, void*, EMPTY_ARGS ) +{ + if( mpVbaEvents && isMouseReleased() ) + processWindowResizeMacro(); + release(); + return 0; +} + +void ScVbaWindowListener::processWindowResizeMacro() +{ + OSL_TRACE( "**** Attempt to FIRE MACRO **** " ); + if( mpVbaEvents ) + mpVbaEvents->processVbaEvent( WORKBOOK_WINDOWRESIZE, uno::Sequence< uno::Any >() ); +} + +// ============================================================================ + +ScVbaEventsHelper::ScVbaEventsHelper( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& xContext ) : + VbaEventsHelperBase( rArgs, xContext ), + mbOpened( false ), + mbClosed( false ) +{ + mpDocShell = dynamic_cast< ScDocShell* >( mpShell ); // mpShell from base class + mpDoc = mpDocShell ? mpDocShell->GetDocument() : 0; + + if( !mxModel.is() || !mpDocShell || !mpDoc ) + return; + + // add worksheet change listener + try + { + uno::Reference< util::XChangesNotifier > xChangesNotifier( mxModel, uno::UNO_QUERY_THROW ); + uno::Reference< util::XChangesListener > xChangesListener( new ScVbaChangesListener( this, mpDocShell ) ); + xChangesNotifier->addChangesListener( xChangesListener ); + } + catch( uno::Exception& ) + { + } + +#define REGISTER_EVENT( eventid, eventname, type, cancelindex, worksheet ) \ + registerEventHandler( eventid, eventname, type, cancelindex, uno::Any( worksheet ) ) + +#define REGISTER_WORKBOOK_EVENT( eventid, eventname, cancelindex ) \ + REGISTER_EVENT( WORKBOOK_##eventid, "Workbook_" eventname, EVENTHANDLER_DOCUMENT, cancelindex, false ) + +#define REGISTER_WORKSHEET_EVENT( eventid, eventname, cancelindex ) \ + REGISTER_EVENT( WORKSHEET_##eventid, "Worksheet_" eventname, EVENTHANDLER_DOCUMENT, cancelindex, true ); \ + REGISTER_EVENT( (USERDEFINED_START + WORKSHEET_##eventid), "Workbook_Sheet" eventname, EVENTHANDLER_DOCUMENT, (((cancelindex) >= 0) ? ((cancelindex) + 1) : -1), false ) + + // global + REGISTER_EVENT( AUTO_OPEN, "Auto_Open", EVENTHANDLER_GLOBAL, -1, false ); + REGISTER_EVENT( AUTO_CLOSE, "Auto_Close", EVENTHANDLER_GLOBAL, -1, false ); + + // Workbook + REGISTER_WORKBOOK_EVENT( ACTIVATE, "Activate", -1 ); + REGISTER_WORKBOOK_EVENT( DEACTIVATE, "Deactivate", -1 ); + REGISTER_WORKBOOK_EVENT( OPEN, "Open", -1 ); + REGISTER_WORKBOOK_EVENT( BEFORECLOSE, "BeforeClose", 0 ); + REGISTER_WORKBOOK_EVENT( BEFOREPRINT, "BeforePrint", 0 ); + REGISTER_WORKBOOK_EVENT( BEFORESAVE, "BeforeSave", 1 ); + REGISTER_WORKBOOK_EVENT( AFTERSAVE, "AfterSave", -1 ); + REGISTER_WORKBOOK_EVENT( NEWSHEET, "NewSheet", -1 ); + REGISTER_WORKBOOK_EVENT( WINDOWACTIVATE, "WindowActivate", -1 ); + REGISTER_WORKBOOK_EVENT( WINDOWDEACTIVATE, "WindowDeactivate", -1 ); + REGISTER_WORKBOOK_EVENT( WINDOWRESIZE, "WindowResize", -1 ); + + // Worksheet events. All events have a corresponding workbook event. + REGISTER_WORKSHEET_EVENT( ACTIVATE, "Activate", -1 ); + REGISTER_WORKSHEET_EVENT( DEACTIVATE, "Deactivate", -1 ); + REGISTER_WORKSHEET_EVENT( BEFOREDOUBLECLICK, "BeforeDoubleClick", 1 ); + REGISTER_WORKSHEET_EVENT( BEFORERIGHTCLICK, "BeforeRightClick", 1 ); + REGISTER_WORKSHEET_EVENT( CALCULATE, "Calculate", -1 ); + REGISTER_WORKSHEET_EVENT( CHANGE, "Change", -1 ); + REGISTER_WORKSHEET_EVENT( SELECTIONCHANGE, "SelectionChange", -1 ); + REGISTER_WORKSHEET_EVENT( FOLLOWHYPERLINK, "FollowHyperlink", -1 ); + +#undef REGISTER_EVENT +#undef REGISTER_WORKBOOK_EVENT +#undef REGISTER_WORKSHEET_EVENT +} + +ScVbaEventsHelper::~ScVbaEventsHelper() +{ +} + +// protected ------------------------------------------------------------------ + +bool ScVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) +{ + // document and document shell are needed during event processing + if( !mpDocShell || !mpDoc ) + throw uno::RuntimeException(); + + // get Application object and check if events are enabled (this is an Excel-only attribute) + uno::Reference< excel::XApplication > xApplication( mxApplication.get(), uno::UNO_QUERY ); + if( !xApplication.is() && mpShell ) + { + uno::Any aVBAGlobals; + mpShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); + uno::Reference< XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY ); + if( xHelperInterface.is() ) + { + xApplication.set( xHelperInterface->Application(), uno::UNO_QUERY ); + mxApplication = xApplication; + } + } + if( !xApplication.is() ) + throw uno::RuntimeException(); + + // return whether event processing is enabled + return xApplication->getEnableEvents(); +} + +bool ScVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& rArgs ) throw (uno::RuntimeException) +{ + // check preconditions for some events, add more events if needed + bool bExecuteEvent = true; + switch( rInfo.mnEventId ) + { + case WORKBOOK_ACTIVATE: + // while loading, framework fires this before 'opened' event, delay it + bExecuteEvent = mbOpened; + break; + case WORKBOOK_OPEN: + bExecuteEvent = !mbOpened; + if( bExecuteEvent ) + { + // execute delayed Activate event too (see above) + rEventQueue.push_back( WORKBOOK_ACTIVATE ); + rEventQueue.push_back( WORKBOOK_WINDOWACTIVATE ); + rEventQueue.push_back( AUTO_OPEN ); + } + break; + case WORKBOOK_DEACTIVATE: + if( mbClosed ) + rEventQueue.push_back( WORKBOOK_WINDOWDEACTIVATE ); + break; + case WORKSHEET_SELECTIONCHANGE: + // if selection is not changed, then do not fire the event + bExecuteEvent = mbOpened && !mbClosed && isSelectionChanged( rArgs, 0 ); + break; + } + + // add workbook event associated to a sheet event + bool bSheetEvent = false; + rInfo.maUserData >>= bSheetEvent; + if( bSheetEvent && bExecuteEvent ) + rEventQueue.push_back( EventQueueEntry( rInfo.mnEventId + USERDEFINED_START, rArgs ) ); + + return bExecuteEvent; +} + +uno::Sequence< uno::Any > ScVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) throw (lang::IllegalArgumentException) +{ + // fill arguments for workbook events associated to sheet events according to sheet events, sheet will be added below + bool bSheetEventAsBookEvent = rInfo.mnEventId > USERDEFINED_START; + sal_Int32 nEventId = bSheetEventAsBookEvent ? (rInfo.mnEventId - USERDEFINED_START) : rInfo.mnEventId; + + uno::Sequence< uno::Any > aVbaArgs; + switch( nEventId ) + { + // *** Workbook *** + + // no arguments + case WORKBOOK_ACTIVATE: + case WORKBOOK_DEACTIVATE: + case WORKBOOK_OPEN: + break; + // 1 arg: cancel + case WORKBOOK_BEFORECLOSE: + case WORKBOOK_BEFOREPRINT: + aVbaArgs.realloc( 1 ); + // current cancel state will be inserted by caller + break; + // 2 args: saveAs, cancel + case WORKBOOK_BEFORESAVE: + aVbaArgs.realloc( 2 ); + checkArgumentType< bool >( rArgs, 0 ); + aVbaArgs[ 0 ] = rArgs[ 0 ]; + // current cancel state will be inserted by caller + break; + // 1 arg: success + case WORKBOOK_AFTERSAVE: + aVbaArgs.realloc( 1 ); + checkArgumentType< bool >( rArgs, 0 ); + aVbaArgs[ 0 ] = rArgs[ 0 ]; + break; + // 1 arg: window + case WORKBOOK_WINDOWACTIVATE: + case WORKBOOK_WINDOWDEACTIVATE: + case WORKBOOK_WINDOWRESIZE: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createWindow(); + break; + // 1 arg: worksheet + case WORKBOOK_NEWSHEET: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createWorksheet( rArgs, 0 ); + break; + + // *** Worksheet *** + + // no arguments + case WORKSHEET_ACTIVATE: + case WORKSHEET_CALCULATE: + case WORKSHEET_DEACTIVATE: + break; + // 1 arg: range + case WORKSHEET_CHANGE: + case WORKSHEET_SELECTIONCHANGE: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createRange( rArgs, 0 ); + break; + // 2 args: range, cancel + case WORKSHEET_BEFOREDOUBLECLICK: + case WORKSHEET_BEFORERIGHTCLICK: + aVbaArgs.realloc( 2 ); + aVbaArgs[ 0 ] = createRange( rArgs, 0 ); + // current cancel state will be inserted by caller + break; + // 1 arg: hyperlink + case WORKSHEET_FOLLOWHYPERLINK: + aVbaArgs.realloc( 1 ); + aVbaArgs[ 0 ] = createHyperlink( rArgs, 0 ); + break; + } + + /* For workbook events associated to sheet events, the workbook event gets + the same arguments but with a Worksheet object in front of them. */ + if( bSheetEventAsBookEvent ) + { + sal_Int32 nLength = aVbaArgs.getLength(); + uno::Sequence< uno::Any > aVbaArgs2( nLength + 1 ); + aVbaArgs2[ 0 ] = createWorksheet( rArgs, 0 ); + for( sal_Int32 nIndex = 0; nIndex < nLength; ++nIndex ) + aVbaArgs2[ nIndex + 1 ] = aVbaArgs[ nIndex ]; + aVbaArgs = aVbaArgs2; + } + + return aVbaArgs; +} + +void ScVbaEventsHelper::implPostProcessEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, bool /*bSuccess*/, bool bCancel ) throw (uno::RuntimeException) +{ + switch( rInfo.mnEventId ) + { + case WORKBOOK_OPEN: + mbOpened = true; + // register the window listener + if( !mxWindowListener.is() ) + { + mxWindowListener = new ScVbaWindowListener( this, mxModel ); + mxWindowListener->startListening(); + } + break; + case WORKBOOK_BEFORECLOSE: + mbClosed = !bCancel; + if( mbClosed ) + { + // execute Auto_Close if not cancelled + rEventQueue.push_back( AUTO_CLOSE ); + if( mxWindowListener.is() ) + { + mxWindowListener->stopListening(); + mxWindowListener.clear(); + } + } + break; + } +} + +::rtl::OUString ScVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) +{ + bool bSheetEvent = false; + rInfo.maUserData >>= bSheetEvent; + SCTAB nTab = bSheetEvent ? getTabFromArgs( rArgs, 0 ) : -1; + if( bSheetEvent && (nTab < 0) ) + throw lang::IllegalArgumentException(); + + String aCodeName; + if( bSheetEvent ) + mpDoc->GetCodeName( nTab, aCodeName ); + else + aCodeName = mpDoc->GetCodeName(); + return aCodeName; +} + +// private -------------------------------------------------------------------- + +SCTAB ScVbaEventsHelper::getTabFromArgs( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException) +{ + checkArgument( rArgs, nIndex ); + + // first try to extract a sheet index + SCTAB nTab = -1; + if( rArgs[ nIndex ] >>= nTab ) + return nTab; + + // next, try single range object + uno::Reference< sheet::XCellRangeAddressable > xCellRangeAddressable = getXSomethingFromArgs< sheet::XCellRangeAddressable >( rArgs, nIndex ); + if( xCellRangeAddressable.is() ) + return xCellRangeAddressable->getRangeAddress().Sheet; + + // at last, try range list + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + if( xRanges.is() ) + { + uno::Sequence< table::CellRangeAddress > aRangeAddresses = xRanges->getRangeAddresses(); + if( aRangeAddresses.getLength() > 0 ) + return aRangeAddresses[ 0 ].Sheet; + } + + throw lang::IllegalArgumentException(); +} + +bool ScVbaEventsHelper::isSelectionChanged( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xNewSelection = getXSomethingFromArgs< uno::XInterface >( rArgs, nIndex, false ); + if( ScCellRangesBase* pNewCellRanges = ScCellRangesBase::getImplementation( xNewSelection ) ) + { + bool bChanged = maOldSelection != pNewCellRanges->GetRangeList(); + maOldSelection = pNewCellRanges->GetRangeList(); + return bChanged; + } + maOldSelection.Clear(); + return true; +} + +uno::Any ScVbaEventsHelper::createWorksheet( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + // Eventually we will be able to pull the Workbook/Worksheet objects + // directly from basic and register them as listeners + + // extract sheet index, will throw, if parameter is invalid + SCTAB nTab = getTabFromArgs( rArgs, nIndex ); + + // create Workbook + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); + aArgs[ 1 ] <<= mxModel; + uno::Reference< uno::XInterface > xWorkbook( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Workbook", aArgs ), uno::UNO_SET_THROW ); + + // create WorkSheet + String aSheetName; + mpDoc->GetName( nTab, aSheetName ); + aArgs = uno::Sequence< uno::Any >( 3 ); + aArgs[ 0 ] <<= xWorkbook; + aArgs[ 1 ] <<= mxModel; + aArgs[ 2 ] <<= ::rtl::OUString( aSheetName ); + uno::Reference< uno::XInterface > xWorksheet( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Worksheet", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xWorksheet ); +} + +uno::Any ScVbaEventsHelper::createRange( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + uno::Reference< sheet::XSheetCellRangeContainer > xRanges = getXSomethingFromArgs< sheet::XSheetCellRangeContainer >( rArgs, nIndex ); + uno::Reference< table::XCellRange > xRange = getXSomethingFromArgs< table::XCellRange >( rArgs, nIndex ); + if ( !xRanges.is() && !xRange.is() ) + throw lang::IllegalArgumentException(); + + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent + if ( xRanges.is() ) + aArgs[ 1 ] <<= xRanges; + else + aArgs[ 1 ] <<= xRange; + uno::Reference< uno::XInterface > xVbaRange( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Range", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xVbaRange ); +} + +uno::Any ScVbaEventsHelper::createHyperlink( const uno::Sequence< uno::Any >& rArgs, sal_Int32 nIndex ) const + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= uno::Reference< uno::XInterface >(); // dummy parent + aArgs[ 1 ] <<= getXSomethingFromArgs< table::XCell >( rArgs, nIndex, false ); + uno::Reference< uno::XInterface > xHyperlink( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Hyperlink", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xHyperlink ); +} + +uno::Any ScVbaEventsHelper::createWindow() const throw (uno::RuntimeException) +{ + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= createVBAUnoAPIService( mpShell, "ooo.vba.Application" ); + aArgs[ 1 ] <<= mxModel; + uno::Reference< uno::XInterface > xWindow( createVBAUnoAPIServiceWithArgs( mpShell, "ooo.vba.excel.Window", aArgs ), uno::UNO_SET_THROW ); + return uno::Any( xWindow ); +} + +// ============================================================================ + +namespace vbaeventshelper +{ +namespace sdecl = comphelper::service_decl; +sdecl::class_ > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "ScVbaEventsHelper", + "com.sun.star.script.vba.SpreadsheetEventProcessor" ); +} + +// ============================================================================ diff --git a/sc/source/ui/vba/vbaeventshelper.hxx b/sc/source/ui/vba/vbaeventshelper.hxx new file mode 100755 index 000000000000..b859d9db6d23 --- /dev/null +++ b/sc/source/ui/vba/vbaeventshelper.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SC_VBAEVENTS_HXX +#define SC_VBAEVENTS_HXX + +#include +#include +#include "excelvbahelper.hxx" +#include "rangelst.hxx" + +namespace ooo { namespace vba { namespace excel { class XApplication; } } } + +class ScVbaWindowListener; + +// ============================================================================ + +class ScVbaEventsHelper : public VbaEventsHelperBase +{ +public: + ScVbaEventsHelper( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~ScVbaEventsHelper(); + +protected: + virtual bool implEventsEnabled() throw (css::uno::RuntimeException); + virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException); + virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException); + virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); + +private: + /** Extracts a sheet index from the first element of the passed sequence. The + element may be an integer, or a Calc range or ranges object. */ + static SCTAB getTabFromArgs( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException); + /** Checks if selection has been changed compared to selection of last call. + @return true, if the selection has been changed. */ + bool isSelectionChanged( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + + /** Creates a VBA Worksheet object (the argument must contain a sheet index). */ + css::uno::Any createWorksheet( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + /** Creates a VBA Range object (the argument must contain a UNO range or UNO range list). */ + css::uno::Any createRange( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + /** Creates a VBA Hyperlink object (the argument must contain a UNO cell). */ + css::uno::Any createHyperlink( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) const throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + /** Creates a VBA Window object. */ + css::uno::Any createWindow() const throw (css::uno::RuntimeException); + +private: + mutable css::uno::WeakReference< ov::excel::XApplication > mxApplication; + ::rtl::Reference< ScVbaWindowListener > mxWindowListener; + ScDocShell* mpDocShell; + ScDocument* mpDoc; + ScRangeList maOldSelection; + bool mbOpened; + bool mbClosed; +}; + +// ============================================================================ + +#endif diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx index 0cddacafd194..178ee85ef068 100644 --- a/sc/source/ui/vba/vbaglobals.cxx +++ b/sc/source/ui/vba/vbaglobals.cxx @@ -233,6 +233,7 @@ ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.SpreadsheetEventProcessor" ) ) }; sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) ); sal_Int32 startIndex = serviceNames.getLength(); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index ff40bdeb7390..2d7f883ea852 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -69,6 +69,8 @@ #include #include #include +#include +#include #include "gridwin.hxx" #include "tabvwsh.hxx" @@ -119,6 +121,7 @@ #include "tabprotection.hxx" #include "postit.hxx" #include "dpcontrol.hxx" +#include "cellsuno.hxx" #include "drawview.hxx" #include @@ -354,6 +357,32 @@ void lcl_UnLockComment( ScDrawView* pView, SdrPageView* pPV, SdrModel* pDrDoc, c } } +sal_Bool lcl_GetHyperlinkCell(ScDocument* pDoc, SCCOL& rPosX, SCROW& rPosY, SCTAB nTab, ScBaseCell*& rpCell ) +{ + BOOL bFound = FALSE; + do + { + pDoc->GetCell( rPosX, rPosY, nTab, rpCell ); + if ( !rpCell || rpCell->GetCellType() == CELLTYPE_NOTE ) + { + if ( rPosX <= 0 ) + return FALSE; // alles leer bis links + else + --rPosX; // weitersuchen + } + else if ( rpCell->GetCellType() == CELLTYPE_EDIT) + bFound = TRUE; + else if (rpCell->GetCellType() == CELLTYPE_FORMULA && + static_cast(rpCell)->IsHyperLinkCell()) + bFound = TRUE; + else + return FALSE; // andere Zelle + } + while ( !bFound ); + + return bFound; +} + // --------------------------------------------------------------------------- // WB_DIALOGCONTROL noetig fuer UNO-Controls ScGridWindow::ScGridWindow( Window* pParent, ScViewData* pData, ScSplitPos eWhichPos ) @@ -2101,6 +2130,30 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) { nMouseStatus = SC_GM_NONE; // keinen Doppelklick anfangen ScGlobal::OpenURL( aUrl, aTarget ); + + // fire worksheet_followhyperlink event + uno::Reference< script::vba::XEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + if( xVbaEvents.is() ) try + { + Point aPos = rMEvt.GetPosPixel(); + SCsCOL nPosX; + SCsROW nPosY; + SCTAB nTab = pViewData->GetTabNo(); + pViewData->GetPosFromPixel( aPos.X(), aPos.Y(), eWhich, nPosX, nPosY ); + ScBaseCell* pCell = NULL; + if( lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ) ) + { + ScAddress aCellPos( nPosX, nPosY, nTab ); + uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) ); + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xCell; + xVbaEvents->processVbaEvent( script::vba::EventIdentifier::WORKSHEET_FOLLOWHYPERLINK, aArgs ); + } + } + catch( uno::Exception& ) + { + } + return; } } @@ -4821,26 +4874,9 @@ BOOL ScGridWindow::GetEditUrlOrError( BOOL bSpellErr, const Point& rPos, ScDocument* pDoc = pDocSh->GetDocument(); ScBaseCell* pCell = NULL; - BOOL bFound = FALSE; - do - { - pDoc->GetCell( nPosX, nPosY, nTab, pCell ); - if ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE ) - { - if ( nPosX <= 0 ) - return FALSE; // alles leer bis links - else - --nPosX; // weitersuchen - } - else if ( pCell->GetCellType() == CELLTYPE_EDIT) - bFound = TRUE; - else if (pCell->GetCellType() == CELLTYPE_FORMULA && - static_cast(pCell)->IsHyperLinkCell()) - bFound = TRUE; - else - return FALSE; // andere Zelle - } - while ( !bFound ); + BOOL bFound = lcl_GetHyperlinkCell( pDoc, nPosX, nPosY, nTab, pCell ); + if( !bFound ) + return FALSE; ScHideTextCursor aHideCursor( pViewData, eWhich ); // before GetEditArea (MapMode is changed) diff --git a/sc/source/ui/view/makefile.mk b/sc/source/ui/view/makefile.mk index feeacc865fba..525f108aff5f 100644 --- a/sc/source/ui/view/makefile.mk +++ b/sc/source/ui/view/makefile.mk @@ -154,6 +154,7 @@ EXCEPTIONSFILES= \ $(SLO)$/formatsh.obj \ $(SLO)$/gridwin2.obj \ $(SLO)$/scextopt.obj \ + $(SLO)$/tabview3.obj \ $(SLO)$/tabvwshb.obj \ $(SLO)$/viewdata.obj \ $(SLO)$/viewfunc.obj \ -- cgit v1.2.3 From b103addffc04b4ac0072992f2ec077135150d3ba Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 19:34:53 +0200 Subject: mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power --- offapi/com/sun/star/script/vba/EventIdentifier.idl | 140 +++++++++++++++++++++ offapi/com/sun/star/script/vba/EventProcessor.idl | 51 ++++++++ .../star/script/vba/SpreadsheetEventProcessor.idl | 50 ++++++++ .../com/sun/star/script/vba/TextEventProcessor.idl | 50 ++++++++ .../sun/star/script/vba/XCoreEventProcessor.idl | 79 ++++++++++++ offapi/com/sun/star/script/vba/XEventProcessor.idl | 114 +++++++++++++++++ offapi/com/sun/star/script/vba/makefile.mk | 51 ++++++++ offapi/prj/build.lst | 5 +- offapi/prj/d.lst | 2 + offapi/util/makefile.mk | 1 + offuh/prj/d.lst | 3 + 11 files changed, 544 insertions(+), 2 deletions(-) create mode 100755 offapi/com/sun/star/script/vba/EventIdentifier.idl create mode 100755 offapi/com/sun/star/script/vba/EventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/TextEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/XCoreEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/XEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/makefile.mk diff --git a/offapi/com/sun/star/script/vba/EventIdentifier.idl b/offapi/com/sun/star/script/vba/EventIdentifier.idl new file mode 100755 index 000000000000..ea200c858c30 --- /dev/null +++ b/offapi/com/sun/star/script/vba/EventIdentifier.idl @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_EventIdentifier_idl__ +#define __com_sun_star_script_vba_EventIdentifier_idl__ + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +/** Constants used to identify VBA document events. + +

If one of these events is fired, a specific VBA macro in a specific + document code module will be executed.

+ +

Each event expects some specific arguments to be passed to + XEventProcessor::processVbaEvent.

+ + @see XEventProcessor + */ +constants EventIdentifier +{ + //========================================================================= + + /** An identifier not corresponding to any VBA document event. */ + const long NO_EVENT = -1; + + //========================================================================= + // Global events (identifiers from 1 to 999) + + /** New document opened from template. No arguments. */ + const long AUTO_NEW = 1; + /** Document opened (loaded). No arguments. */ + const long AUTO_OPEN = 2; + /** Document about to be closed. No arguments. */ + const long AUTO_CLOSE = 3; + /** Application start. No arguments. */ + const long AUTO_EXEC = 4; + /** Application exit. No arguments. */ + const long AUTO_EXIT = 5; + + //========================================================================= + // MS Word (identifiers from 1001 to 1999) + + /** New text document opened from template. No arguments. */ + const long DOCUMENT_NEW = 1001; + /** Text document opened (loaded). No arguments. */ + const long DOCUMENT_OPEN = 1002; + /** Document about to be closed. No arguments. */ + const long DOCUMENT_CLOSE = 1003; + + //========================================================================= + // MS Excel (identifiers from 2001 to 2999) + + //------------------------------------------------------------------------- + // document events (2001-2099) + + /** Document activated. No arguments. */ + const long WORKBOOK_ACTIVATE = 2001; + /** Document deactivated. No arguments. */ + const long WORKBOOK_DEACTIVATE = 2002; + /** Document opened (loaded). No arguments. */ + const long WORKBOOK_OPEN = 2003; + /** Document about to be closed. No arguments. Cancellable. */ + const long WORKBOOK_BEFORECLOSE = 2004; + /** Document about to be printed. No arguments. Cancellable. */ + const long WORKBOOK_BEFOREPRINT = 2005; + /** Document about to be saved. Arguments: boolean bSaveAs. Cancellable. */ + const long WORKBOOK_BEFORESAVE = 2006; + /** Document has been saved. Arguments: boolean bSuccess. */ + const long WORKBOOK_AFTERSAVE = 2007; + /** New sheet inserted. Arguments: short nSheet. */ + const long WORKBOOK_NEWSHEET = 2008; + /** Document window has been activated. No arguments. */ + const long WORKBOOK_WINDOWACTIVATE = 2009; + /** Document window has been deactivated. No arguments. */ + const long WORKBOOK_WINDOWDEACTIVATE = 2010; + /** Document window has been resized. No arguments. */ + const long WORKBOOK_WINDOWRESIZE = 2011; + + //------------------------------------------------------------------------- + // sheet events (2101-2199) + + /** Worksheet has been activated (made visible). Arguments: short nSheet. */ + const long WORKSHEET_ACTIVATE = 2101; + /** Worksheet has been activated (made visible). Arguments: short nSheet. */ + const long WORKSHEET_DEACTIVATE = 2102; + /** Double click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. */ + const long WORKSHEET_BEFOREDOUBLECLICK = 2103; + /** Right click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. */ + const long WORKSHEET_BEFORERIGHTCLICK = 2104; + /** Cells in sheet have been recalculated. Arguments: short nSheet. */ + const long WORKSHEET_CALCULATE = 2105; + /** Cells in sheet have been changed. Arguments: XRange/XSheetCellRangeContainer aRange. */ + const long WORKSHEET_CHANGE = 2106; + /** Selection in sheet has been changed. Arguments: XRange/XSheetCellRangeContainer aRange. */ + const long WORKSHEET_SELECTIONCHANGE = 2107; + /** Hyperlink has been clicked. Arguments: XCell aCell. */ + const long WORKSHEET_FOLLOWHYPERLINK = 2108; + + //========================================================================= + + /** Implementations are allowed to use identifiers above this value for any + internal purpose. */ + const long USERDEFINED_START = 1000000; +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/EventProcessor.idl b/offapi/com/sun/star/script/vba/EventProcessor.idl new file mode 100755 index 000000000000..78b2d9c23fdb --- /dev/null +++ b/offapi/com/sun/star/script/vba/EventProcessor.idl @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_EventProcessor_idl__ +#define __com_sun_star_script_vba_EventProcessor_idl__ + +#include + +module com { module sun { module star { module frame { interface XModel; }; }; }; }; + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +service EventProcessor : XEventProcessor +{ +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl b/offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl new file mode 100755 index 000000000000..680a0e1069aa --- /dev/null +++ b/offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_SpreadsheetEventProcessor_idl__ +#define __com_sun_star_script_vba_SpreadsheetEventProcessor_idl__ + +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +service SpreadsheetEventProcessor +{ + service EventProcessor; +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/TextEventProcessor.idl b/offapi/com/sun/star/script/vba/TextEventProcessor.idl new file mode 100755 index 000000000000..ae2d36a223c6 --- /dev/null +++ b/offapi/com/sun/star/script/vba/TextEventProcessor.idl @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_TextEventProcessor_idl__ +#define __com_sun_star_script_vba_TextEventProcessor_idl__ + +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +service TextEventProcessor +{ + service EventProcessor; +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl b/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl new file mode 100755 index 000000000000..be152a8ba7fd --- /dev/null +++ b/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_XCoreEventProcessor_idl__ +#define __com_sun_star_script_vba_XCoreEventProcessor_idl__ + +#include +#include +#include +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +/** Executes VBA event handlers based on a specific core model event. + */ +interface XCoreEventProcessor +{ + //------------------------------------------------------------------------- + + /** Executes a VBA compatible event handler for a core event. + + @param nSlotId + The implementation defined identifier of the core event. + + @throws IllegalArgumentException + if the passed slot identifier is not supported. + + @throws ScriptFrameworkErrorException + if the VBA event handler could not be invoked. Reasons may be, that + handling of VBA events is not enabled, that the VBA event handler + macro has not been found, or that the execution of the macro has + been aborted with an error. + + @throws VetoException + if the VBA event handler has indicated to veto the event. + **/ + void processCoreVbaEvent( [in] long nSlotId ) + raises (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::script::provider::ScriptFrameworkErrorException, + ::com::sun::star::util::VetoException); + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/XEventProcessor.idl b/offapi/com/sun/star/script/vba/XEventProcessor.idl new file mode 100755 index 000000000000..579cdf881963 --- /dev/null +++ b/offapi/com/sun/star/script/vba/XEventProcessor.idl @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_XEventProcessor_idl__ +#define __com_sun_star_script_vba_XEventProcessor_idl__ + +#include +#include +#include +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +/** Executes VBA event handlers. + */ +interface XEventProcessor +{ + //------------------------------------------------------------------------- + + /** Specifies whether VBA event handling is currently disabled. + */ + [attribute] boolean IgnoreEvents; + + //------------------------------------------------------------------------- + + /** Returns whether a VBA event handler exists. + + @param nEventId + The identifier of the event. Must be a constant from + EventIdentifier. + + @param aArgs + Additional arguments needed to identify some event handlers, e.g. a + sheet index for spreadsheet events. + + @return + , if the VBA event handler exists. + + @throws IllegalArgumentException + if the passed event identifier is not supported, or if the passed + specifier is required but invalid. + **/ + boolean hasVbaEventHandler( [in] long nEventId, [in] sequence< any > aArgs ) + raises (::com::sun::star::lang::IllegalArgumentException); + + //------------------------------------------------------------------------- + + /** Executes a VBA event handler. + + @param nEventId + The identifier of the event. Must be a constant from + EventIdentifier. + + @param aArgs + The input arguments needed to create the argument list of the VBA + event handler. + + @throws IllegalArgumentException + if the passed event identifier is not supported, or if the passed + arguments do not conform to the arguments expected by the specified + event. + + @throws ScriptFrameworkErrorException + if the VBA event handler could not be invoked. Reasons may be, that + handling of VBA events is not enabled, that the VBA event handler + macro has not been found, or that the execution of the macro has + been aborted with an error. + + @throws VetoException + if the VBA event handler has indicated to veto the event. + **/ + void processVbaEvent( [in] long nEventId, [in] sequence< any > aArgs ) + raises (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::script::provider::ScriptFrameworkErrorException, + ::com::sun::star::util::VetoException); + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/makefile.mk b/offapi/com/sun/star/script/vba/makefile.mk new file mode 100755 index 000000000000..c9526d86b070 --- /dev/null +++ b/offapi/com/sun/star/script/vba/makefile.mk @@ -0,0 +1,51 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# 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 +# +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/..$/..$/.. + +PRJNAME=offapi + +TARGET=cssscriptvba +PACKAGE=com$/sun$/star$/script$/vba + +# --- Settings ----------------------------------------------------- +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# ------------------------------------------------------------------------ + +IDLFILES=\ + EventIdentifier.idl \ + EventProcessor.idl \ + SpreadsheetEventProcessor.idl \ + TextEventProcessor.idl \ + XCoreEventProcessor.idl \ + XEventProcessor.idl + +# ------------------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/offapi/prj/build.lst b/offapi/prj/build.lst index a0be2398f429..bc6dda566031 100644 --- a/offapi/prj/build.lst +++ b/offapi/prj/build.lst @@ -3,6 +3,7 @@ oa offapi usr1 - all oa_mkout NULL oa offapi\com\sun\star\script nmake - all oa_script oa_embed NULL oa offapi\com\sun\star\script\browse nmake - all oa_sfbrowse NULL oa offapi\com\sun\star\script\provider nmake - all oa_sfprovider NULL +oa offapi\com\sun\star\script\vba nmake - all oa_script_vba NULL oa offapi\com\sun\star\auth nmake - all oa_auth NULL oa offapi\com\sun\star\accessibility nmake - all oa_accessibility oa_awt NULL oa offapi\com\sun\star\awt nmake - all oa_awt NULL @@ -21,10 +22,10 @@ oa offapi\com\sun\star\datatransfer\dnd nmake - all oa_datatrans_dnd oa_awt NULL oa offapi\com\sun\star\deployment nmake - all oa_deployment oa_ucb oa_xml_input NULL oa offapi\com\sun\star\deployment\test nmake - all oa_deploymenttest oa_ucb NULL oa offapi\com\sun\star\deployment\ui nmake - all oa_deployment_ui oa_awt oa_ui_dialogs NULL -oa offapi\com\sun\star\embed nmake - all oa_embed NULL oa offapi\com\sun\star\document nmake - all oa_docu oa_embed NULL oa offapi\com\sun\star\drawing nmake - all oa_draw NULL oa offapi\com\sun\star\drawing\framework nmake - all oa_draw_framework NULL +oa offapi\com\sun\star\embed nmake - all oa_embed NULL oa offapi\com\sun\star\form nmake - all oa_form oa_inspection NULL oa offapi\com\sun\star\form\component nmake - all oa_fcomp oa_form oa_form_submission NULL oa offapi\com\sun\star\form\inspection nmake - all oa_finsp oa_fcomp oa_inspection NULL @@ -105,4 +106,4 @@ oa offapi\com\sun\star\rendering nmake - all oa_rendering oa_geometry NU oa offapi\com\sun\star\rdf nmake - all oa_rdf oa_datatransfer oa_text NULL oa offapi\com\sun\star\office nmake - all oa_office oa_text NULL oa offapi\drafts\com\sun\star\form nmake - all oa_drafts_form NULL -oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement oa_office oa_prestextfield oa_starme NULL +oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_script_vba oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement oa_office oa_prestextfield oa_starme NULL diff --git a/offapi/prj/d.lst b/offapi/prj/d.lst index 9532cd773c6f..764521f3e944 100644 --- a/offapi/prj/d.lst +++ b/offapi/prj/d.lst @@ -69,6 +69,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\scanner mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\script mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\script\browse mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\script\provider +mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\script\vba mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\sdb mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\sdb\application mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\sdb\tools @@ -185,6 +186,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\drafts\com\sun\star\form ..\com\sun\star\script\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\script ..\com\sun\star\script\browse\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\script\browse ..\com\sun\star\script\provider\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\script\provider +..\com\sun\star\script\vba\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\script\vba ..\com\sun\star\sdb\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\sdb ..\com\sun\star\sdb\application\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\sdb\application ..\com\sun\star\sdb\tools\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\sdb\tools diff --git a/offapi/util/makefile.mk b/offapi/util/makefile.mk index 0ed4feba57b6..016180d7765c 100644 --- a/offapi/util/makefile.mk +++ b/offapi/util/makefile.mk @@ -95,6 +95,7 @@ UNOIDLDBFILES= \ $(UCR)$/cssdomevents.db \ $(UCR)$/cssscanner.db \ $(UCR)$/cssscript.db \ + $(UCR)$/cssscriptvba.db \ $(UCR)$/csssdb.db \ $(UCR)$/csssdbc.db \ $(UCR)$/csssdbcx.db \ diff --git a/offuh/prj/d.lst b/offuh/prj/d.lst index ba7343039eae..a88257dc695d 100644 --- a/offuh/prj/d.lst +++ b/offuh/prj/d.lst @@ -72,6 +72,7 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\sdbc mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\sdbcx mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\scanner mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\script +mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\script\vba mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\sheet mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\smarttags mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\style @@ -271,6 +272,8 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf ..\%__SRC%\inc\offuh\com\sun\star\scanner\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\scanner\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\script\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\script\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\script\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\script\*.hpp +..\%__SRC%\inc\offuh\com\sun\star\script\vba\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\script\vba\*.hdl +..\%__SRC%\inc\offuh\com\sun\star\script\vba\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\script\vba\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\sheet\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\sheet\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\sheet\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\sheet\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\smarttags\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\smarttags\*.hdl -- cgit v1.2.3 From c449069c0608be9f263392589cb2c91e44bc9e8b Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 19:34:53 +0200 Subject: mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power --- oovbaapi/ooo/vba/excel/XApplication.idl | 1 + oovbaapi/ooo/vba/excel/makefile.mk | 2 +- oovbaapi/ooo/vba/word/makefile.mk | 2 +- sfx2/inc/sfx2/objsh.hxx | 1 + sfx2/source/doc/objserv.cxx | 24 +++ sfx2/source/view/viewprn.cxx | 18 ++ vbahelper/inc/vbahelper/vbaeventshelperbase.hxx | 165 +++++++++++++++ vbahelper/prj/d.lst | 1 + vbahelper/source/vbahelper/makefile.mk | 2 + vbahelper/source/vbahelper/vbaeventshelperbase.cxx | 229 +++++++++++++++++++++ 10 files changed, 443 insertions(+), 2 deletions(-) create mode 100755 vbahelper/inc/vbahelper/vbaeventshelperbase.hxx create mode 100755 vbahelper/source/vbahelper/vbaeventshelperbase.cxx diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl index 39693a37511c..6f513ae64577 100644 --- a/oovbaapi/ooo/vba/excel/XApplication.idl +++ b/oovbaapi/ooo/vba/excel/XApplication.idl @@ -64,6 +64,7 @@ interface XApplication [attribute] any CutCopyMode; [attribute] any StatusBar; [attribute] long Cursor; + [attribute] boolean EnableEvents; void setDefaultFilePath([in] string DefaultFilePath) raises(com::sun::star::script::BasicErrorException); diff --git a/oovbaapi/ooo/vba/excel/makefile.mk b/oovbaapi/ooo/vba/excel/makefile.mk index 12dcf025e489..251588086701 100644 --- a/oovbaapi/ooo/vba/excel/makefile.mk +++ b/oovbaapi/ooo/vba/excel/makefile.mk @@ -29,7 +29,7 @@ PRJ=..$/..$/.. PRJNAME=oovapi TARGET=excel -PACKAGE=ooo$/vba$/Excel +PACKAGE=ooo$/vba$/excel # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk diff --git a/oovbaapi/ooo/vba/word/makefile.mk b/oovbaapi/ooo/vba/word/makefile.mk index e3a19e678414..543e99f7c538 100644 --- a/oovbaapi/ooo/vba/word/makefile.mk +++ b/oovbaapi/ooo/vba/word/makefile.mk @@ -29,7 +29,7 @@ PRJ=..$/..$/.. PRJNAME=oovapi TARGET=word -PACKAGE=ooo$/vba$/Word +PACKAGE=ooo$/vba$/word # --- Settings ----------------------------------------------------- .INCLUDE : $(PRJ)$/util$/makefile.pmk diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index d514235cbfa2..49223c23de75 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -292,6 +292,7 @@ public: sal_Bool IsReadOnlyUI() const; void SetNoName(); sal_Bool IsInModalMode() const; + sal_Bool IsInPrepareClose() const; //Added by PengYunQuan for Validity Cell Range Picker diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index c063546da1c7..ae3b527ff7a6 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -100,6 +100,7 @@ #include #include #include +#include #include "helpid.hrc" @@ -489,6 +490,22 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_SAVEASDOC: case SID_SAVEDOC: { + // ask VBA emulation at document model whether to save the document + if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC ) try + { + Reference< script::vba::XCoreEventProcessor > xEventProcessor( GetModel(), UNO_QUERY_THROW ); + xEventProcessor->processCoreVbaEvent( nId ); + } + catch( util::VetoException& ) + { + // VBA event handler indicates to cancel saving the document + rReq.SetReturnValue( SfxBoolItem( 0, TRUE ) ); + return; + } + catch( Exception& ) + { + } + //!! detaillierte Auswertung eines Fehlercodes SfxObjectShellRef xLock( this ); @@ -895,6 +912,13 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) rReq.Done(); } +//------------------------------------------------------------------------- + +sal_Bool SfxObjectShell::IsInPrepareClose() const +{ + return pImp->bInPrepareClose; +} + //-------------------------------------------------------------------- void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index f62ae4c1ddc7..faf392c90f32 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -29,6 +29,7 @@ #include "precompiled_sfx2.hxx" #include +#include #include #include "com/sun/star/view/XRenderable.hpp" @@ -697,6 +698,23 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) case SID_PRINTDOCDIRECT: { SfxObjectShell* pDoc = GetObjectShell(); + + // ask VBA emulation at document model whether to print the document + try + { + uno::Reference< script::vba::XCoreEventProcessor > xEventProcessor( pDoc->GetModel(), uno::UNO_QUERY_THROW ); + xEventProcessor->processCoreVbaEvent( nId ); + } + catch( util::VetoException& ) + { + // VBA event handler indicates to cancel printing the document + rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); + return; + } + catch( uno::Exception& ) + { + } + bool bDetectHidden = ( !bSilent && pDoc ); if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) break; diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx new file mode 100755 index 000000000000..a84b0e28f9db --- /dev/null +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef VBAHELPER_VBAEVENTSHELPERBASE_HXX +#define VBAHELPER_VBAEVENTSHELPERBASE_HXX + +#include +#include +#include +#include +#include +#include "vbahelper/vbahelper.hxx" + +namespace com { namespace sun { namespace star { + namespace uno { class XComponentContext; } +} } } + +// ============================================================================ + +typedef ::cppu::WeakImplHelper2< css::script::vba::XEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; + +class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE +{ +public: + VbaEventsHelperBase( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& xContext ); + virtual ~VbaEventsHelperBase(); + + // XEventProcessor + virtual void SAL_CALL setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); + virtual void SAL_CALL processVbaEvent( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::script::provider::ScriptFrameworkErrorException, css::util::VetoException, css::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException); + +protected: + // ------------------------------------------------------------------------ + + enum EventHandlerType { EVENTHANDLER_GLOBAL, EVENTHANDLER_DOCUMENT }; + struct EventHandlerInfo + { + sal_Int32 mnEventId; + ::rtl::OUString maMacroName; + EventHandlerType meType; + sal_Int32 mnCancelIndex; + css::uno::Any maUserData; + }; + + /** Registers a supported event handler. + + @param nEventId Event identifier from com.sun.star.script.vba.EventIdentifier. + @param pcMacroName Name of the associated VBA event handler macro. + @param eType Document event or global event. + @param nCancelIndex 0-based index of Cancel parameter, or -1. + @param rUserData User data for free usage in derived implementations. */ + void registerEventHandler( + sal_Int32 nEventId, + const sal_Char* pcMacroName, + EventHandlerType eType = EVENTHANDLER_DOCUMENT, + sal_Int32 nCancelIndex = -1, + const css::uno::Any& rUserData = css::uno::Any() ); + + /** Throws, if the passed sequence does not contain a value at the specified index. */ + static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { if( rArgs.getLength() <= nIndex ) throw css::lang::IllegalArgumentException(); } + + /** Throws, if the passed sequence does not contain a value of a specific at the specified index. */ + template< typename Type > + static inline void checkArgumentType( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException) + { if( (rArgs.getLength() <= nIndex) || !rArgs[ nIndex ].has< Type >() ) throw css::lang::IllegalArgumentException(); } + + // ------------------------------------------------------------------------ + + struct EventQueueEntry + { + sal_Int32 mnEventId; + css::uno::Sequence< css::uno::Any > maArgs; + inline /*implicit*/ EventQueueEntry( sal_Int32 nEventId ) : mnEventId( nEventId ) {} + inline EventQueueEntry( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) : mnEventId( nEventId ), maArgs( rArgs ) {} + }; + typedef ::std::deque< EventQueueEntry > EventQueue; + + /** Derived classes return whether event processing is enabled. Throws if + the instance is in an invalid state. */ + virtual bool implEventsEnabled() throw (css::uno::RuntimeException) = 0; + + /** Derived classes do additional prpeparations and return whether the + event handler has to be called. */ + virtual bool implPrepareEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the argument list for the specified VBA event handler. */ + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException) = 0; + + /** Derived classes may do additional postprocessing. Called even if the + event handler does not exist, or if an error occured during execution. */ + virtual void implPostProcessEvent( + EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, + bool bSuccess, + bool bCancel ) throw (css::uno::RuntimeException) = 0; + + /** Derived classes have to return the name of the Basic document module. */ + virtual ::rtl::OUString implGetDocumentModuleName( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException) = 0; + +private: + /** Returns the event handler info struct for the specified event, or throws. */ + const EventHandlerInfo& getEventHandlerInfo( sal_Int32 nEventId ) const throw (css::lang::IllegalArgumentException); + + /** Searches the event handler in the document and returns its full script path. */ + ::rtl::OUString getEventHandlerPath( + const EventHandlerInfo& rInfo, + const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); + + /** Removes this instance from all broadcasters. */ + void stopListening(); + +protected: + css::uno::Reference< css::frame::XModel > mxModel; + SfxObjectShell* mpShell; + +private: + typedef ::std::map< sal_Int32, EventHandlerInfo > EventHandlerMap; + + EventHandlerMap maEvents; + bool mbIgnoreEvents; + bool mbDisposed; +}; + +// ============================================================================ + +#endif diff --git a/vbahelper/prj/d.lst b/vbahelper/prj/d.lst index d683e97c8b90..2d20ab1f982d 100644 --- a/vbahelper/prj/d.lst +++ b/vbahelper/prj/d.lst @@ -26,3 +26,4 @@ mkdir: %_DEST%\inc%_EXT%\basic ..\inc\vbahelper\vbatextframe.hxx %_DEST%\inc%_EXT%\vbahelper\vbatextframe.hxx ..\inc\vbahelper\vbashaperange.hxx %_DEST%\inc%_EXT%\vbahelper\vbashaperange.hxx ..\inc\vbahelper\vbapagesetupbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbapagesetupbase.hxx +..\inc\vbahelper\vbaeventshelperbase.hxx %_DEST%\inc%_EXT%\vbahelper\vbaeventshelperbase.hxx diff --git a/vbahelper/source/vbahelper/makefile.mk b/vbahelper/source/vbahelper/makefile.mk index 47ad44b3d0ed..22ed40a3adfa 100644 --- a/vbahelper/source/vbahelper/makefile.mk +++ b/vbahelper/source/vbahelper/makefile.mk @@ -65,6 +65,8 @@ SLOFILES=\ $(SLO)$/vbashaperange.obj \ $(SLO)$/vbatextframe.obj \ $(SLO)$/vbapagesetupbase.obj \ + $(SLO)$/vbaeventshelperbase.obj + # --- Targets ------------------------------------------------------- .INCLUDE : target.mk diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx new file mode 100755 index 000000000000..ea5448482a89 --- /dev/null +++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vbahelper/vbaeventshelperbase.hxx" +#include + +using namespace ::com::sun::star; +using namespace ::ooo::vba; + +// ============================================================================ + +VbaEventsHelperBase::VbaEventsHelperBase( const uno::Sequence< uno::Any >& rArgs, const uno::Reference< uno::XComponentContext >& /*xContext*/ ) : + mpShell( 0 ), + mbIgnoreEvents( false ), + mbDisposed( false ) +{ + try + { + mxModel = getXSomethingFromArgs< frame::XModel >( rArgs, 0, false ); + mpShell = getSfxObjShell( mxModel ); + + // add dispose listener + uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); + xComponent->addEventListener( this ); + } + catch( uno::Exception& ) + { + } +} + +VbaEventsHelperBase::~VbaEventsHelperBase() +{ + stopListening(); +} + +void SAL_CALL VbaEventsHelperBase::setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (uno::RuntimeException) +{ + mbIgnoreEvents = bIgnoreEvents; +} + +sal_Bool SAL_CALL VbaEventsHelperBase::getIgnoreEvents() throw (uno::RuntimeException) +{ + return mbIgnoreEvents; +} + +sal_Bool SAL_CALL VbaEventsHelperBase::hasVbaEventHandler( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, uno::RuntimeException) +{ + // getEventHandlerInfo() throws, if unknown event dentifier has been passed + const EventHandlerInfo& rInfo = getEventHandlerInfo( nEventId ); + // getEventHandlerPath() searches for the macro in the document + return getEventHandlerPath( rInfo, rArgs ).getLength() > 0; +} + +void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& rArgs ) + throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException) +{ + /* Derived classes may add new event identifiers to be processed while + processing the original event. All unprocessed events are collected in + a queue. First element in the queue is the next event to be processed. */ + EventQueue aEventQueue; + aEventQueue.push_back( EventQueueEntry( nEventId, rArgs ) ); + + /* bEnabled will track if event processing is enabled. Every event handler + may disable handling of other events. */ + bool bEnabled = !mbIgnoreEvents; + + /* bCancel will contain the current Cancel value. It is possible that + multiple events will try to modify the Cancel value. Every event + handler receives the Cancel value of the previous event handler. */ + bool bCancel = false; + + /* bSuccess will change to true if at least one event handler has been + executed successfully. */ + bool bSuccess = false; + + /* Loop as long as there are more events to be processed, and as event + handling is still enabled. Derived classes may add new events to be + processed in the virtual implPrepareEvent() function. */ + while( bEnabled && !aEventQueue.empty() ) + { + /* Check that all class members are available, and that we are not + disposed (this may have happened at any time during execution of + the last event handler). */ + if( mbDisposed || !mxModel.is() || !mpShell ) + throw uno::RuntimeException(); + + // get info for next event + const EventHandlerInfo& rInfo = getEventHandlerInfo( aEventQueue.front().mnEventId ); + uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs; + aEventQueue.pop_front(); + + // let derived classes decide whether event processing is still enabled + bEnabled = implEventsEnabled(); + // let derived classes prepare the event, they may add new events for next iteration + if( bEnabled && implPrepareEvent( aEventQueue, rInfo, aEventArgs ) ) + { + // search the event handler macro in the document + ::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs ); + bool bEventSuccess = false; + if( aMacroPath.getLength() > 0 ) + { + // build the argument list + uno::Sequence< uno::Any > aVbaArgs = implBuildArgumentList( rInfo, aEventArgs ); + // insert current cancel value + if( rInfo.mnCancelIndex >= 0 ) + { + if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) + throw lang::IllegalArgumentException(); + aVbaArgs[ rInfo.mnCancelIndex ] <<= bCancel; + } + // execute the event handler + uno::Any aRet, aCaller; + bEventSuccess = executeMacro( mpShell, aMacroPath, aVbaArgs, aRet, aCaller ); + // extract new cancel value + if( rInfo.mnCancelIndex >= 0 ) + { + if( rInfo.mnCancelIndex >= aVbaArgs.getLength() ) + throw lang::IllegalArgumentException(); + // cancel value may be boolean or any integer type, Any(bool) does not extract to sal_Int32 + bool bNewCancel = false; + sal_Int32 nNewCancel = 0; + if( aVbaArgs[ rInfo.mnCancelIndex ] >>= bNewCancel ) + bCancel = bNewCancel; + else if( aVbaArgs[ rInfo.mnCancelIndex ] >>= nNewCancel ) + bCancel = nNewCancel != 0; + } + } + // post processing (also, if event handler does not exist, or on error + implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel ); + // global success, if at least one event handler succeeded + bSuccess |= bEventSuccess; + } + } + + // if event handlers want to cancel the event, do so regardless of any errors + if( bCancel ) + throw util::VetoException(); + + // if no event handler finished successfully, throw + if( !bSuccess ) + throw script::provider::ScriptFrameworkErrorException(); +} + +void SAL_CALL VbaEventsHelperBase::disposing( const lang::EventObject& /*aSource*/ ) throw (uno::RuntimeException) +{ + OSL_TRACE( "VbaEventsHelperBase::disposing" ); + stopListening(); + mbDisposed = true; +} + +// protected ------------------------------------------------------------------ + +void VbaEventsHelperBase::registerEventHandler( sal_Int32 nEventId, + const sal_Char* pcMacroName, EventHandlerType eType, sal_Int32 nCancelIndex, const uno::Any& rUserData ) +{ + EventHandlerInfo& rInfo = maEvents[ nEventId ]; + rInfo.mnEventId = nEventId; + rInfo.maMacroName = ::rtl::OUString::createFromAscii( pcMacroName ); + rInfo.meType = eType; + rInfo.mnCancelIndex = nCancelIndex; + rInfo.maUserData = rUserData; +} + +// private -------------------------------------------------------------------- + +const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandlerInfo( + sal_Int32 nEventId ) const throw (lang::IllegalArgumentException) +{ + EventHandlerMap::const_iterator aIt = maEvents.find( nEventId ); + if( aIt == maEvents.end() ) + throw lang::IllegalArgumentException(); + return aIt->second; +} + +::rtl::OUString VbaEventsHelperBase::getEventHandlerPath( const EventHandlerInfo& rInfo, + const uno::Sequence< uno::Any >& rArgs ) const throw (lang::IllegalArgumentException) +{ + ::rtl::OUString aMacroName; + switch( rInfo.meType ) + { + case EVENTHANDLER_GLOBAL: + aMacroName = rInfo.maMacroName; + break; + case EVENTHANDLER_DOCUMENT: + aMacroName = ::rtl::OUStringBuffer( implGetDocumentModuleName( rInfo, rArgs ) ). + append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear(); + break; + } + return resolveVBAMacro( mpShell, aMacroName ).ResolvedMacro(); +} + +void VbaEventsHelperBase::stopListening() +{ + if( !mbDisposed ) try + { + uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY_THROW ); + xComponent->removeEventListener( this ); + } + catch( uno::Exception& ) + { + } +} + +// ============================================================================ -- cgit v1.2.3 From fc135411fa926f4d89e98378d113f597af79e2a2 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Tue, 6 Jul 2010 19:34:53 +0200 Subject: mib17: #i112634# add VBA sheet event handling, based on a patch from Noel Power --- sw/inc/doc.hxx | 11 +++- sw/source/core/doc/doc.cxx | 24 ++++++++ sw/source/filter/ww8/wrtww8.cxx | 2 + sw/source/ui/app/docsh2.cxx | 44 +++++++++++++- sw/source/ui/vba/makefile.mk | 1 + sw/source/ui/vba/service.cxx | 9 ++- sw/source/ui/vba/vbaeventshelper.cxx | 108 +++++++++++++++++++++++++++++++++++ sw/source/ui/vba/vbaeventshelper.hxx | 54 ++++++++++++++++++ sw/util/makefile.mk | 2 +- 9 files changed, 248 insertions(+), 7 deletions(-) mode change 100755 => 100644 sw/source/core/doc/doc.cxx create mode 100755 sw/source/ui/vba/vbaeventshelper.cxx create mode 100755 sw/source/ui/vba/vbaeventshelper.hxx diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index 10befb703b96..ff6a1f97709e 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -79,6 +79,9 @@ class SwList; #include "comphelper/implementationreference.hxx" #include #include +#ifdef FUTURE_VBA +#include +#endif #include #include @@ -405,7 +408,9 @@ class SW_DLLPUBLIC SwDoc : // table of forbidden characters of this document vos::ORef xForbiddenCharsTable; - +#ifdef FUTURE_VBA + com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > mxVbaEvents; +#endif // --> OD 2007-10-26 #i83479# public: struct lessThanNodeNum @@ -2128,7 +2133,9 @@ public: { return n32DummyCompatabilityOptions2; } - +#ifdef FUTURE_VBA + com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > GetVbaEventProcessor(); +#endif ::sfx2::IXmlIdRegistry& GetXmlIdRegistry(); ::sw::MetaFieldManager & GetMetaFieldManager(); SfxObjectShell* CreateCopy(bool bCallInitNew) const; diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx old mode 100755 new mode 100644 index f1ae3e241b1b..6979d13fbb62 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -119,6 +119,9 @@ #include #include +#ifdef FUTURE_VBA +#include +#endif /* @@@MAINTAINABILITY-HORROR@@@ Probably unwanted dependency on SwDocShell @@ -2721,6 +2724,27 @@ void SwDoc::ChkCondColls() } } +#ifdef FUTURE_VBA +uno::Reference< script::vba::XEventProcessor > +SwDoc::GetVbaEventProcessor() +{ + if( !mxVbaEvents.is() && pDocShell && ooo::vba::isAlienWordDoc( *pDocShell ) ) + { + try + { + uno::Reference< frame::XModel > xModel( pDocShell->GetModel(), uno::UNO_SET_THROW ); + uno::Sequence< uno::Any > aArgs(1); + aArgs[0] <<= xModel; + mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.TextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); + } + catch( uno::Exception& ) + { + } + } + return mxVbaEvents; +} +#endif + void SwDoc::setExternalData(::sw::tExternalDataType eType, ::sw::tExternalDataPointer pPayload) { diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index 2e992335598e..253957dac35b 100755 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3788,8 +3788,10 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer void MSWordExportBase::OutputStartNode( const SwStartNode & rNode) { +#if 0 #ifdef DEBUG ::std::clog << "" << dbg_out(&rNode) << ::std::endl; +#endif #endif ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 9cb3caffa7cc..501c070e6d6b 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -119,7 +119,10 @@ #include #include #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" - +#ifdef FUTURE_VBA +#include +#include +#endif #include #include @@ -137,7 +140,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star; using ::rtl::OUString; using namespace ::sfx2; - extern BOOL FindPhyStyle( SwDoc& , const String& , SfxStyleFamily ); /*-------------------------------------------------------------------- @@ -188,6 +190,26 @@ void SwDocShell::DoFlushDocInfo() } } +#ifdef FUTURE_VBA +void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XEventProcessor >& xVbaEvents, const SfxHint& rHint ) +{ + using namespace com::sun::star::script::vba::EventIdentifier; + if ( rHint.ISA( SfxEventHint ) ) + { + uno::Sequence< uno::Any > aArgs; + ULONG nEventId = ((SfxEventHint&)rHint).GetEventId(); + switch( nEventId ) + { + case SFX_EVENT_CREATEDOC: + xVbaEvents->processVbaEvent( DOCUMENT_NEW, aArgs ); + break; + case SFX_EVENT_OPENDOC: + xVbaEvents->processVbaEvent( DOCUMENT_OPEN, aArgs ); + break; + } + } +} +#endif /*-------------------------------------------------------------------- Beschreibung: Benachrichtigung bei geaenderter DocInfo @@ -202,6 +224,12 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) return ; } +#ifdef FUTURE_VBA + uno::Reference< script::vba::XEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + if( xVbaEvents.is() ) + lcl_processCompatibleSfxHint( xVbaEvents, rHint ); +#endif + USHORT nAction = 0; if( rHint.ISA(SfxSimpleHint) ) { @@ -283,6 +311,18 @@ USHORT SwDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) if( TRUE == nRet ) //Unbedingt auf TRUE abfragen! (RET_NEWTASK) EndListening( *this ); +#ifdef FUTURE_VBA + if( pDoc && IsInPrepareClose() ) + { + uno::Reference< script::vba::XEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + if( xVbaEvents.is() ) + { + using namespace com::sun::star::script::vba::EventIdentifier; + uno::Sequence< uno::Any > aArgs; + xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aArgs ); + } + } +#endif return nRet; } diff --git a/sw/source/ui/vba/makefile.mk b/sw/source/ui/vba/makefile.mk index c09f81320040..b6d0d7994295 100644 --- a/sw/source/ui/vba/makefile.mk +++ b/sw/source/ui/vba/makefile.mk @@ -91,6 +91,7 @@ SLOFILES= \ $(SLO)$/vbapagesetup.obj \ $(SLO)$/vbasection.obj \ $(SLO)$/vbasections.obj \ + $(SLO)$/vbaeventshelper.obj \ # --- Targets ------------------------------------------------------ diff --git a/sw/source/ui/vba/service.cxx b/sw/source/ui/vba/service.cxx index c21e8de37b5e..9f9cbff204dd 100644 --- a/sw/source/ui/vba/service.cxx +++ b/sw/source/ui/vba/service.cxx @@ -52,6 +52,11 @@ namespace wrapformat extern sdecl::ServiceDecl const serviceDecl; } +namespace vbaeventshelper +{ +extern sdecl::ServiceDecl const serviceDecl; +} + extern "C" { void SAL_CALL component_getImplementationEnvironment( @@ -68,7 +73,7 @@ extern "C" // Component registration return component_writeInfoHelper( pServiceManager, pRegistryKey, - globals::serviceDecl, document::serviceDecl, wrapformat::serviceDecl ); + globals::serviceDecl, document::serviceDecl, wrapformat::serviceDecl, vbaeventshelper::serviceDecl ); } void * SAL_CALL component_getFactory( @@ -77,7 +82,7 @@ extern "C" { OSL_TRACE("In component_getFactory for %s", pImplName ); void* pRet = component_getFactoryHelper( - pImplName, pServiceManager, pRegistryKey, globals::serviceDecl, document::serviceDecl, wrapformat::serviceDecl ); + pImplName, pServiceManager, pRegistryKey, globals::serviceDecl, document::serviceDecl, wrapformat::serviceDecl, vbaeventshelper::serviceDecl ); OSL_TRACE("Ret is 0x%x", pRet); return pRet; } diff --git a/sw/source/ui/vba/vbaeventshelper.cxx b/sw/source/ui/vba/vbaeventshelper.cxx new file mode 100755 index 000000000000..66d72315987e --- /dev/null +++ b/sw/source/ui/vba/vbaeventshelper.cxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vbaeventshelper.hxx" +#include +#include + +using namespace ::com::sun::star; +using namespace ::com::sun::star::script::vba::EventIdentifier; +using namespace ::ooo::vba; + +// ============================================================================ + +SwVbaEventsHelper::SwVbaEventsHelper( uno::Sequence< css::uno::Any > const& aArgs, uno::Reference< uno::XComponentContext > const& xContext ) : + VbaEventsHelperBase( aArgs, xContext ) +{ + registerEventHandler( DOCUMENT_NEW, "Document_New", EVENTHANDLER_DOCUMENT ); + registerEventHandler( AUTO_NEW, "AutoNew", EVENTHANDLER_GLOBAL ); + registerEventHandler( DOCUMENT_OPEN, "Document_Open", EVENTHANDLER_DOCUMENT ); + registerEventHandler( AUTO_OPEN, "AutoOpen", EVENTHANDLER_GLOBAL ); + registerEventHandler( DOCUMENT_CLOSE, "Document_Close", EVENTHANDLER_DOCUMENT ); + registerEventHandler( AUTO_CLOSE, "AutoClose", EVENTHANDLER_GLOBAL ); +} + +SwVbaEventsHelper::~SwVbaEventsHelper() +{ +} + +bool SwVbaEventsHelper::implEventsEnabled() throw (uno::RuntimeException) +{ + return true; +} + +bool SwVbaEventsHelper::implPrepareEvent( EventQueue& rEventQueue, + const EventHandlerInfo& rInfo, const uno::Sequence< uno::Any >& /*rArgs*/ ) throw (uno::RuntimeException) +{ + switch( rInfo.mnEventId ) + { + case DOCUMENT_NEW: + rEventQueue.push_back( AUTO_NEW ); + break; + case DOCUMENT_OPEN: + rEventQueue.push_back( AUTO_OPEN ); + break; + case DOCUMENT_CLOSE: + rEventQueue.push_back( AUTO_CLOSE ); + break; + } + return true; +} + +uno::Sequence< uno::Any > SwVbaEventsHelper::implBuildArgumentList( const EventHandlerInfo& /*rInfo*/, + const uno::Sequence< uno::Any >& /*rArgs*/ ) throw (lang::IllegalArgumentException) +{ + // no event handler expects any arguments + return uno::Sequence< uno::Any >(); +} + +void SwVbaEventsHelper::implPostProcessEvent( EventQueue& /*rEventQueue*/, + const EventHandlerInfo& /*rInfo*/, bool /*bSuccess*/, bool /*bCancel*/ ) throw (uno::RuntimeException) +{ + // nothing to do after any event +} + +::rtl::OUString SwVbaEventsHelper::implGetDocumentModuleName( const EventHandlerInfo& /*rInfo*/, + const uno::Sequence< uno::Any >& /*rArgs*/ ) const throw (lang::IllegalArgumentException) +{ + // TODO: get actual codename from document + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisDocument" ) ); +} + +// ============================================================================ + +namespace vbaeventshelper +{ +namespace sdecl = comphelper::service_decl; +sdecl::class_ > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "SwVbaEventsHelper", + "com.sun.star.document.vba.TextEventProcessor" ); +} + +// ============================================================================ diff --git a/sw/source/ui/vba/vbaeventshelper.hxx b/sw/source/ui/vba/vbaeventshelper.hxx new file mode 100755 index 000000000000..af1c06c0341f --- /dev/null +++ b/sw/source/ui/vba/vbaeventshelper.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_VBAEVENTS_HXX +#define SW_VBAEVENTS_HXX + +#include + +// ============================================================================ + +class SwVbaEventsHelper : public VbaEventsHelperBase +{ +public: + SwVbaEventsHelper( + const css::uno::Sequence< css::uno::Any >& rArgs, + const css::uno::Reference< css::uno::XComponentContext >& rxContext ); + virtual ~SwVbaEventsHelper(); + +protected: + virtual bool implEventsEnabled() throw (css::uno::RuntimeException); + virtual bool implPrepareEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::uno::RuntimeException); + virtual css::uno::Sequence< css::uno::Any > implBuildArgumentList( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException); + virtual void implPostProcessEvent( EventQueue& rEventQueue, const EventHandlerInfo& rInfo, bool bSuccess, bool bCancel ) throw (css::uno::RuntimeException); + virtual ::rtl::OUString implGetDocumentModuleName( const EventHandlerInfo& rInfo, const css::uno::Sequence< css::uno::Any >& rArgs ) const throw (css::lang::IllegalArgumentException); +}; + +// ============================================================================ + +#endif + diff --git a/sw/util/makefile.mk b/sw/util/makefile.mk index 2907264d89cf..ce1419b34065 100644 --- a/sw/util/makefile.mk +++ b/sw/util/makefile.mk @@ -367,7 +367,7 @@ SHL5STDLIBS= \ $(I18NISOLANGLIB) \ $(EDITENGLIB) \ $(SVXCORELIB) \ - $(SVXMSFILTERLIB) + $(MSFILTERLIB) SHL5DEPN=$(SHL1TARGETN) SHL5LIBS=$(SLB)$/$(TARGET_VBA).lib -- cgit v1.2.3 From b8d18edc25262dcd77c160d2910ac77e2d683a18 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Wed, 7 Jul 2010 09:32:11 +0200 Subject: mib17: #162901# fix Remove --- vbahelper/source/msforms/vbacontrols.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index 1284b36be463..b7fad7d9372d 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -349,13 +349,16 @@ void SAL_CALL ScVbaControls::Remove( const uno::Any& StringKeyOrIndex ) } catch( uno::RuntimeException& ) { - throw; + // the exceptions are not rethrown, impossibility to find or remove the control is currently not reported + // since in most cases it means just that the controls is already not there, the VBA seems to do it in the same way + + // throw; } catch( uno::Exception& e ) { - throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), - uno::Reference< uno::XInterface >(), - uno::makeAny( e ) ); + // throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not create AXControl!" ) ), + // uno::Reference< uno::XInterface >(), + // uno::makeAny( e ) ); } } -- cgit v1.2.3 From cbd90787ccc28ff36fb439ae3e012d28688b2ecd Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Wed, 7 Jul 2010 14:58:53 +0200 Subject: mib17: #162916# No error if byval in calls isn't followed by lvalue --- basic/source/classes/disas.cxx | 2 ++ basic/source/comp/exprtree.cxx | 14 ++------------ basic/source/comp/sbcomp.cxx | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx index 7317005d74fe..87b4cad4e94b 100644 --- a/basic/source/classes/disas.cxx +++ b/basic/source/classes/disas.cxx @@ -153,6 +153,7 @@ static const char* pOp3[] = { "DCREATE_REDIMP", // Change dimensions of a user defined Object-Array (+StringId+StringId) "FIND_CM", // Search inside a class module (CM) to enable global search in time "PUBLIC_P", // Module global Variable (persisted between calls)(+StringID+Typ) + "FIND_STATIC", // local static var lookup (+StringID+Typ) }; static const char** pOps[3] = { pOp1, pOp2, pOp3 }; @@ -220,6 +221,7 @@ static const Func pOperand3[] = { &SbiDisas::Str2Op, // Redimensionate User defined Object-Array (+StringId+StringId) &SbiDisas::VarOp, // FIND_CM &SbiDisas::VarDefOp, // PUBLIC_P + &SbiDisas::VarOp, // FIND_STATIC }; // TODO: Why as method? Isn't a simple define sufficient? diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 9b6f419e15ce..42969b98d0d8 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -971,16 +971,11 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else { bool bByVal = false; - bool bByValBlockLValueError = false; if( eTok == BYVAL ) { bByVal = true; pParser->Next(); eTok = pParser->Peek(); - - // Special handling for VBA function "StrPtr" that's accepted as lvalue - if( eTok == SYMBOL && pParser->GetSym().EqualsIgnoreCaseAscii( "StrPtr" ) ) - bByValBlockLValueError = true; } if( bAssumeExprLParenMode ) @@ -1014,13 +1009,8 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa else pExpr = new SbiExpression( pParser ); - if( bByVal ) - { - if( !pExpr->IsLvalue() && !bByValBlockLValueError ) - pParser->Error( SbERR_LVALUE_EXPECTED ); - else - pExpr->SetByVal(); - } + if( bByVal && pExpr->IsLvalue() ) + pExpr->SetByVal(); //pExpr = bConst ? new SbiConstExpression( pParser ) // : new SbiExpression( pParser ); diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 50dc6f847076..faabba046c99 100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -67,7 +67,7 @@ void dbg_SaveDisassembly( SbModule* pModule ) ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); if( xSFI.is() ) { - String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/BasicAsm_") ); + String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/zBasic.Asm/Asm_") ); StarBASIC* pBasic = (StarBASIC*)pModule->GetParent(); if( pBasic ) { -- cgit v1.2.3 From e674baba51bdbe489e9c8617e5ed45840d6bfbd4 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 7 Jul 2010 17:28:29 +0200 Subject: #i112250# #i113022# better handling of automatic decimals for small values or equal cells --- sc/source/ui/view/output2.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index b0b040f9b5e0..8e4a3e6b2ec9 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -565,6 +565,12 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) else if (c == sal_Unicode('E')) ++nExpCount; } + + // #i112250# A small value might be formatted as "0" when only counting the digits, + // but fit into the column when considering the smaller width of the decimal separator. + if (aString.EqualsAscii("0") && fVal != 0.0) + nDecimalCount = 1; + if (nDecimalCount) nWidth += (nMaxDigit - GetDotWidth()) * nDecimalCount; if (nSignCount) @@ -594,6 +600,7 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) } TextChanged(); + pLastCell = NULL; // #i113022# equal cell and format in another column may give different string } void ScDrawStringsVars::SetAutoText( const String& rAutoText ) -- cgit v1.2.3 From bcd4bc56c93dd815da6b5d0e22348dabbc75ca9f Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Wed, 7 Jul 2010 17:28:29 +0200 Subject: #i112250# #i113022# better handling of automatic decimals for small values or equal cells --- svl/source/numbers/zformat.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 707b2362f0ed..2d0909c8782b 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -2086,7 +2086,9 @@ BOOL SvNumberformat::GetOutputString(double fNumber, if (!nLen) return false; - if (nLen > 11) + // #i112250# With the 10-decimal limit, small numbers are formatted as "0". + // Switch to scientific in that case, too: + if (nLen > 11 || (OutString.EqualsAscii("0") && fNumber != 0.0)) { sal_uInt16 nStandardPrec = rScan.GetStandardPrec(); nStandardPrec = ::std::min(nStandardPrec, static_cast(14)); // limits to 14 decimals -- cgit v1.2.3 From 4232a54805f36dcfcb05b980ac9b6df2ed381fef Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 7 Jul 2010 19:27:51 +0200 Subject: mib17: remove unused code --- oox/inc/oox/ole/vbahelper.hxx | 123 ----------------------------- oox/inc/oox/ole/vbaproject.hxx | 151 ------------------------------------ oox/source/core/filterbase.cxx | 32 ++++---- oox/source/ole/vbacontrol.cxx | 28 ++++++- oox/source/ole/vbahelper.cxx | 171 +---------------------------------------- oox/source/ole/vbaproject.cxx | 64 --------------- oox/source/xls/excelfilter.cxx | 45 +++++------ 7 files changed, 70 insertions(+), 544 deletions(-) mode change 100755 => 100644 oox/source/core/filterbase.cxx diff --git a/oox/inc/oox/ole/vbahelper.hxx b/oox/inc/oox/ole/vbahelper.hxx index 76dc1c736025..c1e7297d0c5b 100755 --- a/oox/inc/oox/ole/vbahelper.hxx +++ b/oox/inc/oox/ole/vbahelper.hxx @@ -30,11 +30,6 @@ #include "oox/helper/binarystreambase.hxx" -namespace com { namespace sun { namespace star { - namespace container { class XNameContainer; } - namespace document { class XEventsSupplier; } -} } } - namespace oox { class BinaryInputStream; } namespace oox { @@ -102,124 +97,6 @@ public: ::rtl::OUString& rValue, const ::rtl::OUString& rKeyValue ); - /** Removes whitespace characters from the beginning of the passed string. - - @param rCodeLine (in/out parameter) The string to be modified. - - @return True = at least one whitespace character found and removed - from rCodeLine. False = rCodeLine is empty or does not start with - a whitespace character. - */ - static bool eatWhitespace( ::rtl::OUString& rCodeLine ); - - /** Removes the passed keyword from the beginning of the passed string. - - @param rCodeLine (in/out parameter) The string to be modified. - - @param rKeyword The keyword to be removed from the beginning of the - rCodeLine string. - - @return True = rCodeLine starts with the passed keyword (case - insensitive), and is followed by whitespace characters, or it ends - right after the keyword. The keyword and the following whitespace - characters have been removed from rCodeLine. False = rCodeLine is - empty or does not start with the specified keyword, or the keyword - is not followed by whitespace characters. - */ - static bool eatKeyword( ::rtl::OUString& rCodeLine, const ::rtl::OUString& rKeyword ); - - /** Returns the VBA source code of the specified module, or an empty - string, if the module does not exist. - - @param rxBasicLib The container for all VBA code modules. - @param rModuleName The name of the VBA code module. - */ - static ::rtl::OUString getSourceCode( - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, - const ::rtl::OUString& rModuleName ); - - /** Checks, if a macro with the specified name exists in the passed VBA - source code. - - @param rSourceCode The VBA source code. - @param rMacroName The name of the macro. - */ - static bool hasMacro( - const ::rtl::OUString& rSourceCode, - const ::rtl::OUString& rMacroName ); - - /** Checks, if a macro with the specified name exists in the specified - module. - - @param rxBasicLib The container for all VBA code modules. - @param rModuleName The name of the VBA module to check for the macro. - @param rMacroName The name of the macro. - */ - static bool hasMacro( - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - - /** Tries to insert a VBA macro into the specified code module. - - @descr If the specified macro does not exist, it will be generated as - following, using the passed parameters. If the parameter rMacroType - is left empty, a sub procedure macro will be generated: - - Private Sub ( ) - - End Sub - - If the parameter rMacroType is not empty, a function macro - will be generated. Note that the parameter rMacroCode has to - provide the code that returns the function value. - - Private Function ( ) As - - End Function - - The source code in rMacroCode may contain a special placeholder - $MACRO that will be replaced by the macro name passed in rMacroName - before the macro will be inserted into the module. - - @param rModuleName The name of the VBA module to be used. - @param rMacroName The name of the VBA macro to be inserted. - @param rMacroArgs The argument list of the VBA macro. - @param rMacroType Macro return type (empty for sub procedure). - @param rMacroCode The VBA source code for the macro. - - @return True, if the specified VBA macro has been inserted. False, if - there already exists a macro with the specified name, or if any - error has occurred, for example, Office configuration forbids to - generate executable VBA code or the specified module does not - exist. - */ - static bool insertMacro( - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxBasicLib, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rMacroArgs, - const ::rtl::OUString& rMacroType, - const ::rtl::OUString& rMacroCode ); - - /** Tries to attach a VBA macro to an event of the passed events supplier. - - @descr The function checks if the specified macro exists and attaches - it to the event of the passed events supplier. - - @param rxEventsSupp The events supplier for the event to be attached. - @param rEventName The event name used in the office API. - @param rLibraryName The name of the Basic library containing the macro. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - */ - static bool attachMacroToEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rLibraryName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - private: VbaHelper(); ~VbaHelper(); diff --git a/oox/inc/oox/ole/vbaproject.hxx b/oox/inc/oox/ole/vbaproject.hxx index 0422ccbd0cf8..1d2fca29dbab 100755 --- a/oox/inc/oox/ole/vbaproject.hxx +++ b/oox/inc/oox/ole/vbaproject.hxx @@ -97,157 +97,6 @@ public: /** Returns true, if the document contains the specified dialog. */ bool hasDialog( const ::rtl::OUString& rDialogName ) const; - // Insert VBA code modules and VBA macros into modules -------------------- - - /** Tries to insert a VBA macro into the specified code module. - - @descr If the specified macro does not exist, it will be generated as - following, using the passed parameters. If the parameter rMacroType - is left empty, a sub procedure macro will be generated: - - Private Sub ( ) - - End Sub - - If the parameter rMacroType is not empty, a function macro - will be generated. Note that the parameter rMacroCode has to - provide the code that returns the function value. - - Private Function ( ) As - - End Function - - The source code in rMacroCode may contain a special placeholder - $MACRO that will be replaced by the macro name passed in rMacroName - before the macro will be inserted into the module. - - @param rModuleName The name of the VBA module to be used. - @param rMacroName The name of the VBA macro to be inserted. - @param rMacroArgs The argument list of the VBA macro. - @param rMacroType Macro return type (empty for sub procedure). - @param rMacroCode The VBA source code for the macro. - - @return True, if the specified VBA macro has been inserted. False, if - there already exists a macro with the specified name, or if any - error has occurred, for example, Office configuration forbids to - generate executable VBA code or the specified module does not - exist. - */ - bool insertMacro( - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rMacroArgs, - const ::rtl::OUString& rMacroType, - const ::rtl::OUString& rMacroCode ); - - // Attach VBA macros to generic or document events ------------------------ - - /** Tries to attach the specified VBA macro to an event directly. - - @descr The function checks if the specified macro exists and attaches - it to the event of the passed events supplier. - - @param rxEventsSupp The events supplier for the event to be attached. - @param rEventName The event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - - @return True, if the specified VBA macro exists and could be attached - to the specified event. - */ - bool attachMacroToEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - - /** Tries to attach the specified VBA macro to a document event directly. - - @descr The function checks if the specified macro exists and attaches - it to the document event. - - @param rEventName The document event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - - @return True, if the specified VBA macro exists and could be attached - to the specified document event. - */ - bool attachMacroToDocumentEvent( - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName ); - - /** Tries to attach the specified VBA macro to an event via a generated - proxy macro that implements necessary conversion between VBA and UNO. - - @descr The function checks if the specified VBA macro exists, then it - tries to generate a proxy macro using the parameters passed to this - function, appends it to the code module, and attaches it to the - event. - - The proxy macro will execute the code specified in the rProxyCode - parameter. This code may contain special placeholders that will be - replaced before the proxy macro will be inserted into the module: - - $MACRO will be replaced by the original VBA macro name passed - in the rMacroName parameter. - - $PROXY will be replaced by the name of the proxy macro - generated by this function. - - @param rxEventsSupp The events supplier for the event to be attached. - @param rEventName The event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - @param rProxyArgs The argument list of the generated proxy macro. - @param rProxyType Proxy macro return type (empty for procedure). - @param rProxyCode Proxy macro source code. - - @return True, if the specified VBA macro exists and could be attached - to the specified event. - */ - bool attachMacroToEvent( - const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventsSupplier >& rxEventsSupp, - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rProxyArgs, - const ::rtl::OUString& rProxyType, - const ::rtl::OUString& rProxyCode ); - - /** Tries to attach the specified VBA macro to a document event via a - proxy macro that implements necessary conversion between VBA and UNO. - - @descr The function checks if the specified VBA macro exists, then it - tries to generate a proxy macro using the parameters passed to this - function, appends it to the code module, and attaches it to the - document event. - - The proxy macro will execute the code specified in the rProxyCode - parameter. This code may contain special placeholders that will be - replaced before the proxy macro will be inserted into the module: - - $MACRO will be replaced by the original VBA macro name passed - in the rMacroName parameter. - - $PROXY will be replaced by the name of the proxy macro - generated by this function. - - @param rEventName The document event name used in the office API. - @param rModuleName The name of the VBA module containing the macro. - @param rMacroName The name of the VBA macro to attach to the event. - @param rProxyArgs The argument list of the generated proxy macro. - @param rProxyType Proxy macro return type (empty for procedure). - @param rProxyCode Proxy macro source code. - - @return True, if the specified VBA macro exists and could be attached - to the specified event. - */ - bool attachMacroToDocumentEvent( - const ::rtl::OUString& rEventName, - const ::rtl::OUString& rModuleName, - const ::rtl::OUString& rMacroName, - const ::rtl::OUString& rProxyArgs, - const ::rtl::OUString& rProxyType, - const ::rtl::OUString& rProxyCode ); - private: VbaProject( const VbaProject& ); VbaProject& operator=( const VbaProject& ); diff --git a/oox/source/core/filterbase.cxx b/oox/source/core/filterbase.cxx old mode 100755 new mode 100644 index 902784cafe80..dfa898026dd8 --- a/oox/source/core/filterbase.cxx +++ b/oox/source/core/filterbase.cxx @@ -74,8 +74,18 @@ namespace core { namespace { +struct UrlPool +{ + ::osl::Mutex maMutex; + ::std::set< OUString > maUrls; +}; + +struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {}; + +// ---------------------------------------------------------------------------- + /** This guard prevents recursive loading/saving of the same document. */ -class DocumentOpenedGuard : public ::osl::Mutex +class DocumentOpenedGuard { public: explicit DocumentOpenedGuard( const OUString& rUrl ); @@ -87,31 +97,28 @@ private: DocumentOpenedGuard( const DocumentOpenedGuard& ); DocumentOpenedGuard& operator=( const DocumentOpenedGuard& ); - typedef ::std::set< OUString > UrlSet; - struct UrlPool : public ::rtl::Static< UrlSet, UrlPool > {}; - - UrlSet& mrUrls; OUString maUrl; bool mbValid; }; -DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl ) : - mrUrls( UrlPool::get() ) +DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl ) { - ::osl::MutexGuard aGuard( *this ); - mbValid = (rUrl.getLength() == 0) || (mrUrls.count( rUrl ) == 0); + UrlPool& rUrlPool = StaticUrlPool::get(); + ::osl::MutexGuard aGuard( rUrlPool.maMutex ); + mbValid = (rUrl.getLength() == 0) || (rUrlPool.maUrls.count( rUrl ) == 0); if( mbValid && (rUrl.getLength() > 0) ) { - mrUrls.insert( rUrl ); + rUrlPool.maUrls.insert( rUrl ); maUrl = rUrl; } } DocumentOpenedGuard::~DocumentOpenedGuard() { - ::osl::MutexGuard aGuard( *this ); + UrlPool& rUrlPool = StaticUrlPool::get(); + ::osl::MutexGuard aGuard( rUrlPool.maMutex ); if( maUrl.getLength() > 0 ) - mrUrls.erase( maUrl ); + rUrlPool.maUrls.erase( maUrl ); } } // namespace @@ -594,4 +601,3 @@ GraphicHelper* FilterBase::implCreateGraphicHelper() const } // namespace core } // namespace oox - diff --git a/oox/source/ole/vbacontrol.cxx b/oox/source/ole/vbacontrol.cxx index 4952b956bae4..e9ea87d98a58 100755 --- a/oox/source/ole/vbacontrol.cxx +++ b/oox/source/ole/vbacontrol.cxx @@ -722,6 +722,30 @@ OUString lclGetQuotedString( const OUString& rCodeLine ) return aBuffer.makeStringAndClear(); } +bool lclEatWhitespace( OUString& rCodeLine ) +{ + sal_Int32 nIndex = 0; + while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) ) + ++nIndex; + if( nIndex > 0 ) + { + rCodeLine = rCodeLine.copy( nIndex ); + return true; + } + return false; +} + +bool lclEatKeyword( OUString& rCodeLine, const OUString& rKeyword ) +{ + if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) ) + { + rCodeLine = rCodeLine.copy( rKeyword.getLength() ); + // success, if code line ends after keyword, or if whitespace follows + return (rCodeLine.getLength() == 0) || lclEatWhitespace( rCodeLine ); + } + return false; +} + } // namespace // ---------------------------------------------------------------------------- @@ -755,10 +779,10 @@ void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib, while( !bBeginFound && !aFrameTextStrm.isEof() ) { aLine = aFrameTextStrm.readLine().trim(); - bBeginFound = VbaHelper::eatKeyword( aLine, aBegin ); + bBeginFound = lclEatKeyword( aLine, aBegin ); } // check for the specific GUID that represents VBA forms - if( !bBeginFound || !VbaHelper::eatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) ) + if( !bBeginFound || !lclEatKeyword( aLine, CREATE_OUSTRING( "{C62A69F0-16DC-11CE-9E98-00AA00574A4F}" ) ) ) return; // remaining line is the form name diff --git a/oox/source/ole/vbahelper.cxx b/oox/source/ole/vbahelper.cxx index 7293e357e746..3bf72d30bfa5 100755 --- a/oox/source/ole/vbahelper.cxx +++ b/oox/source/ole/vbahelper.cxx @@ -27,27 +27,15 @@ #include "oox/ole/vbahelper.hxx" #include -#include -#include -#include -#include #include "oox/helper/binaryinputstream.hxx" -using ::rtl::OUString; -using ::rtl::OUStringBuffer; -using ::com::sun::star::beans::PropertyValue; -using ::com::sun::star::container::XNameContainer; -using ::com::sun::star::container::XNameReplace; -using ::com::sun::star::document::XEventsSupplier; -using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Exception; -using ::com::sun::star::uno::Sequence; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::UNO_SET_THROW; - namespace oox { namespace ole { +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using namespace ::com::sun::star::uno; + // ============================================================================ /*static*/ OUString VbaHelper::getBasicScriptUrl( @@ -91,157 +79,6 @@ namespace ole { return false; } -/*static*/ bool VbaHelper::eatWhitespace( OUString& rCodeLine ) -{ - sal_Int32 nIndex = 0; - while( (nIndex < rCodeLine.getLength()) && ((rCodeLine[ nIndex ] == ' ') || (rCodeLine[ nIndex ] == '\t')) ) - ++nIndex; - if( nIndex > 0 ) - { - rCodeLine = rCodeLine.copy( nIndex ); - return true; - } - return false; -} - -/*static*/ bool VbaHelper::eatKeyword( OUString& rCodeLine, const OUString& rKeyword ) -{ - if( rCodeLine.matchIgnoreAsciiCase( rKeyword ) ) - { - rCodeLine = rCodeLine.copy( rKeyword.getLength() ); - // success, if code line ends after keyword, or if whitespace follows - return (rCodeLine.getLength() == 0) || eatWhitespace( rCodeLine ); - } - return false; -} - -/*static*/ OUString VbaHelper::getSourceCode( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName ) -{ - OUString aSourceCode; - if( rxBasicLib.is() ) try - { - rxBasicLib->getByName( rModuleName ) >>= aSourceCode; - } - catch( Exception& ) - { - } - return aSourceCode; -} - -namespace { - -bool lclGetLine( OUString& rCodeLine, sal_Int32& rnIndex, const OUString& rSourceCode ) -{ - if( rnIndex < rSourceCode.getLength() ) - { - sal_Int32 nPosLF = rSourceCode.indexOf( '\n', rnIndex ); - if( nPosLF >= rnIndex ) - { - rCodeLine = rSourceCode.copy( rnIndex, nPosLF - rnIndex ).trim(); - rnIndex = nPosLF + 1; - return true; - } - } - return false; -} - -} // namespace - -/*static*/ bool VbaHelper::hasMacro( const OUString& rSourceCode, const OUString& rMacroName ) -{ - // scan all text lines for '[Public|Private] [Static] Sub (...)' - const OUString aPublic = CREATE_OUSTRING( "Public" ); - const OUString aPrivate = CREATE_OUSTRING( "Private" ); - const OUString aStatic = CREATE_OUSTRING( "Static" ); - const OUString aSub = CREATE_OUSTRING( "Sub" ); - - OUString aCodeLine; - sal_Int32 nIndex = 0; - while( lclGetLine( aCodeLine, nIndex, rSourceCode ) ) - { - // eat optional 'Private' or 'Public', but do not accept both keywords in a row (therefore the ||) - eatKeyword( aCodeLine, aPublic ) || eatKeyword( aCodeLine, aPrivate ); - // eat optional 'Static' - eatKeyword( aCodeLine, aStatic ); - // eat 'Sub' keyword, check if macro name follows - if( eatKeyword( aCodeLine, aSub ) && aCodeLine.matchIgnoreAsciiCase( rMacroName ) ) - { - // eat macro name and following whitespace - aCodeLine = aCodeLine.copy( rMacroName.getLength() ); - eatWhitespace( aCodeLine ); - // opening bracket must follow the macro name - if( (aCodeLine.getLength() >= 2) && (aCodeLine[ 0 ] == '(') ) - return true; - } - } - return false; -} - -/*static*/ bool VbaHelper::hasMacro( const Reference< XNameContainer >& rxBasicLib, - const OUString& rModuleName, const OUString& rMacroName ) -{ - return hasMacro( getSourceCode( rxBasicLib, rModuleName ), rMacroName ); -} - -/*static*/ bool VbaHelper::insertMacro( const Reference< XNameContainer >& rxBasicLib, const OUString& rModuleName, - const OUString& rMacroName, const OUString& rMacroArgs, const OUString& rMacroType, const OUString& rMacroCode ) -{ - if( rxBasicLib.is() ) try - { - // receive module source code and check that the specified macro does not exist - OUString aSourceCode = getSourceCode( rxBasicLib, rModuleName ); - if( !hasMacro( aSourceCode, rMacroName ) ) - { - bool bFunction = rMacroType.getLength() > 0; - const sal_Char* pcSubFunc = bFunction ? "Function" : "Sub"; - OUStringBuffer aBuffer( aSourceCode ); - // generate the source code for the new macro - aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "\nPrivate " ) ). - appendAscii( pcSubFunc ).append( sal_Unicode( ' ' ) ). - append( rMacroName ).append( sal_Unicode( '(' ) ); - if( rMacroArgs.getLength() > 0 ) - aBuffer.append( sal_Unicode( ' ' ) ).append( rMacroArgs ).append( sal_Unicode( ' ' ) ); - aBuffer.append( sal_Unicode( ')' ) ); - if( bFunction ) - aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( " As " ) ).append( rMacroType ); - aBuffer.append( sal_Unicode( '\n' ) ); - // replace all $MACRO placeholders with macro name - if( rMacroCode.getLength() > 0 ) - { - OUString aMacroCode = ::comphelper::string::searchAndReplaceAsciiL( rMacroCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); - aBuffer.append( aMacroCode ).append( sal_Unicode( '\n' ) ); - } - aBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "End " ) ).appendAscii( pcSubFunc ).append( sal_Unicode( '\n' ) ); - rxBasicLib->replaceByName( rModuleName, Any( aBuffer.makeStringAndClear() ) ); - return true; - } - } - catch( Exception& ) - { - } - return false; -} - -/*static*/ bool VbaHelper::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, - const OUString& rEventName, const OUString& rLibraryName, const OUString& rModuleName, const OUString& rMacroName ) -{ - if( rxEventsSupp.is() ) try - { - Reference< XNameReplace > xEvents( rxEventsSupp->getEvents(), UNO_SET_THROW ); - Sequence< PropertyValue > aEvent( 2 ); - aEvent[ 0 ].Name = CREATE_OUSTRING( "EventType" ); - aEvent[ 0 ].Value <<= CREATE_OUSTRING( "Script" ); - aEvent[ 1 ].Name = CREATE_OUSTRING( "Script" ); - aEvent[ 1 ].Value <<= getBasicScriptUrl( rLibraryName, rModuleName, rMacroName ); - xEvents->replaceByName( rEventName, Any( aEvent ) ); - return true; - } - catch( Exception& ) - { - } - return false; -} - // ============================================================================ } // namespace ole diff --git a/oox/source/ole/vbaproject.cxx b/oox/source/ole/vbaproject.cxx index a370fb3d168e..04f3eb49d35d 100755 --- a/oox/source/ole/vbaproject.cxx +++ b/oox/source/ole/vbaproject.cxx @@ -184,70 +184,6 @@ bool VbaProject::hasDialog( const OUString& rDialogName ) const return mxDialogLib.is() && mxDialogLib->hasByName( rDialogName ); } -// Insert VBA code modules and VBA macros into modules ------------------------ - -bool VbaProject::insertMacro( const OUString& rModuleName, - const OUString& rMacroName, const OUString& rMacroArgs, - const OUString& rMacroType, const OUString& rMacroCode ) -{ - return - // do nothing if macros are imported as comments - isImportVbaExecutable() && - // try to insert the macro (will check that the macro does not exist yet) - VbaHelper::insertMacro( mxBasicLib, rModuleName, rMacroName, rMacroArgs, rMacroType, rMacroCode ); -} - -// Attach VBA macros to generic or document events ---------------------------- - -bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, - const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName ) -{ - return - // do not attach if macros are imported as comments - isImportVbaExecutable() && - // check that the specified macro exists in the module - VbaHelper::hasMacro( mxBasicLib, rModuleName, rMacroName ) && - // attach the macro to the events supplier - VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, rMacroName ); -} - -bool VbaProject::attachMacroToDocumentEvent( const OUString& rEventName, - const OUString& rModuleName, const OUString& rMacroName ) -{ - Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); - return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName ); -} - -bool VbaProject::attachMacroToEvent( const Reference< XEventsSupplier >& rxEventsSupp, - const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, - const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) -{ - // receive module source code, and check that the specified macro exists in the module - OUString aSourceCode = VbaHelper::getSourceCode( mxBasicLib, rModuleName ); - if( isImportVbaExecutable() && VbaHelper::hasMacro( aSourceCode, rMacroName ) ) - { - // create the name of the proxy macro, and the macro source code - OUString aProxyName = OUStringBuffer( rMacroName ).append( sal_Unicode( '_' ) ). - append( rEventName ).appendAscii( "_Proxy" ).makeStringAndClear(); - // replace $MACRO and $PROXY placeholders in proxy source code - OUString aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( rProxyCode, RTL_CONSTASCII_STRINGPARAM( "$MACRO" ), rMacroName ); - aProxyCode = ::comphelper::string::searchAndReplaceAsciiL( aProxyCode, RTL_CONSTASCII_STRINGPARAM( "$PROXY" ), aProxyName ); - // insert the new macro into the code module and attach it to the event - return - VbaHelper::insertMacro( mxBasicLib, rModuleName, aProxyName, rProxyArgs, rProxyType, aProxyCode ) && - VbaHelper::attachMacroToEvent( rxEventsSupp, rEventName, maLibName, rModuleName, aProxyName ); - } - return false; -} - -bool VbaProject::attachMacroToDocumentEvent( - const OUString& rEventName, const OUString& rModuleName, const OUString& rMacroName, - const OUString& rProxyArgs, const OUString& rProxyType, const OUString& rProxyCode ) -{ - Reference< XEventsSupplier > xEventsSupp( mxDocModel, UNO_QUERY ); - return attachMacroToEvent( xEventsSupp, rEventName, rModuleName, rMacroName, rProxyArgs, rProxyType, rProxyCode ); -} - // private -------------------------------------------------------------------- Reference< XLibraryContainer > VbaProject::getLibraryContainer( sal_Int32 nPropId ) diff --git a/oox/source/xls/excelfilter.cxx b/oox/source/xls/excelfilter.cxx index 71475790851f..5affbfff44a7 100644 --- a/oox/source/xls/excelfilter.cxx +++ b/oox/source/xls/excelfilter.cxx @@ -115,19 +115,18 @@ ExcelFilter::~ExcelFilter() bool ExcelFilter::importDocument() throw() { - /* to activate the XLSX/XLSB dumper, define the environment variable - OOO_XLSBDUMPER and insert the full path to the file - file:////source/dump/xlsbdumper.ini. */ + /* To activate the XLSX/XLSB dumper, insert the full path to the file + file:////source/dump/xlsbdumper.ini + into the environment variable OOO_XLSBDUMPER and start the office with + this variable (nonpro only). */ OOX_DUMP_FILE( ::oox::dump::xlsb::Dumper ); - bool bRet = false; OUString aWorkbookPath = getFragmentPathFromFirstType( CREATE_OFFICEDOC_RELATIONSTYPE( "officeDocument" ) ); - if( aWorkbookPath.getLength() > 0 ) - { - WorkbookHelperRoot aHelper( *this ); - bRet = aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); - } - return bRet; + if( aWorkbookPath.getLength() == 0 ) + return false; + + WorkbookHelperRoot aHelper( *this ); + return aHelper.isValid() && importFragment( new OoxWorkbookFragment( aHelper, aWorkbookPath ) ); } bool ExcelFilter::exportDocument() throw() @@ -198,31 +197,30 @@ ExcelBiffFilter::~ExcelBiffFilter() bool ExcelBiffFilter::importDocument() throw() { - /* to activate the BIFF dumper, define the environment variable - OOO_BIFFDUMPER and insert the full path to the file - file:////source/dump/biffdumper.ini. */ + /* To activate the BIFF dumper, insert the full path to the file + file:////source/dump/biffdumper.ini + into the environment variable OOO_BIFFDUMPER and start the office with + this variable (nonpro only). */ OOX_DUMP_FILE( ::oox::dump::biff::Dumper ); /* The boolean argument "UseBiffFilter" passed through XInitialisation - decides whether to use the BIFF file dumper implemented in this filter - only (false or missing), or to import/export the document (true). */ + decides whether to import/export the document with this filter (true), + or to only use the BIFF file dumper implemented in this filter (false + or missing) */ Any aUseBiffFilter = getArgument( CREATE_OUSTRING( "UseBiffFilter" ) ); bool bUseBiffFilter = false; if( !(aUseBiffFilter >>= bUseBiffFilter) || !bUseBiffFilter ) return true; - bool bRet = false; - // detect BIFF version and workbook stream name OUString aWorkbookName; BiffType eBiff = BiffDetector::detectStorageBiffVersion( aWorkbookName, getStorage() ); OSL_ENSURE( eBiff != BIFF_UNKNOWN, "ExcelBiffFilter::ExcelBiffFilter - invalid file format" ); - if( eBiff != BIFF_UNKNOWN ) - { - WorkbookHelperRoot aHelper( *this, eBiff ); - bRet = aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); - } - return bRet; + if( eBiff == BIFF_UNKNOWN ) + return false; + + WorkbookHelperRoot aHelper( *this, eBiff ); + return aHelper.isValid() && BiffWorkbookFragment( aHelper, aWorkbookName ).importFragment(); } bool ExcelBiffFilter::exportDocument() throw() @@ -244,4 +242,3 @@ OUString ExcelBiffFilter::implGetImplementationName() const } // namespace xls } // namespace oox - -- cgit v1.2.3 From 708cbbebc8483e2c2044d409d4503fdccc558969 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 7 Jul 2010 19:44:06 +0200 Subject: mib17: adjusted codename handling in xls filter, do not restrict vba event handling to xls files --- sc/inc/scextopt.hxx | 8 +++----- sc/source/core/data/documen2.cxx | 2 +- sc/source/filter/excel/xiroot.cxx | 2 +- sc/source/ui/view/scextopt.cxx | 21 ++++++++++++++------- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/sc/inc/scextopt.hxx b/sc/inc/scextopt.hxx index b02df9816ef4..d4a845040010 100644 --- a/sc/inc/scextopt.hxx +++ b/sc/inc/scextopt.hxx @@ -116,13 +116,11 @@ public: ScExtTabSettings& GetOrCreateTabSettings( SCTAB nTab ); /** Returns the number of sheet codenames. */ - size_t GetCodeNameCount() const; + SCTAB GetCodeNameCount() const; /** Returns the specified codename (empty string = no codename). */ - const String& GetCodeName( size_t nIdx ) const; + const String& GetCodeName( SCTAB nTab ) const; /** Appends a codename for a sheet. */ - void AppendCodeName( const String& rCodeName ); - void SetCodeName( const String& rCodeName, size_t nIdx ); - void DeleteCodeName( size_t nIdx ); + void SetCodeName( SCTAB nTab, const String& rCodeName ); private: ::std::auto_ptr< ScExtDocOptionsImpl > mxImpl; diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 4cd23ca66353..9c932df05c28 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -1295,7 +1295,7 @@ void ScDocument::RemoveLookupCache( ScLookupCache & rCache ) uno::Reference< script::vba::XEventProcessor > ScDocument::GetVbaEventProcessor() const { - if( !mxVbaEvents.is() && pShell && ooo::vba::isAlienExcelDoc( *pShell ) ) + if( !mxVbaEvents.is() && pShell && IsInVBAMode() ) { try { diff --git a/sc/source/filter/excel/xiroot.cxx b/sc/source/filter/excel/xiroot.cxx index 3fd2650cf2ff..5f8bcbd481e5 100644 --- a/sc/source/filter/excel/xiroot.cxx +++ b/sc/source/filter/excel/xiroot.cxx @@ -289,7 +289,7 @@ void XclImpRoot::ReadCodeName( XclImpStream& rStrm, bool bGlobals ) } else { - GetExtDocOptions().AppendCodeName( aName ); + GetExtDocOptions().SetCodeName( GetCurrScTab(), aName ); GetDoc().SetCodeName( GetCurrScTab(), aName ); } } diff --git a/sc/source/ui/view/scextopt.cxx b/sc/source/ui/view/scextopt.cxx index bead62419bb3..53852a127937 100644 --- a/sc/source/ui/view/scextopt.cxx +++ b/sc/source/ui/view/scextopt.cxx @@ -198,20 +198,27 @@ ScExtTabSettings& ScExtDocOptions::GetOrCreateTabSettings( SCTAB nTab ) return mxImpl->maTabSett.GetOrCreateTabSettings( nTab ); } -size_t ScExtDocOptions::GetCodeNameCount() const +SCTAB ScExtDocOptions::GetCodeNameCount() const { - return mxImpl->maCodeNames.size(); + return static_cast< SCTAB >( mxImpl->maCodeNames.size() ); } -const String& ScExtDocOptions::GetCodeName( size_t nIdx ) const +const String& ScExtDocOptions::GetCodeName( SCTAB nTab ) const { - DBG_ASSERT( nIdx < GetCodeNameCount(), "ScExtDocOptions::GetCodeName - invalid index" ); - return (nIdx < GetCodeNameCount()) ? mxImpl->maCodeNames[ nIdx ] : EMPTY_STRING; + DBG_ASSERT( (0 <= nTab) && (nTab < GetCodeNameCount()), "ScExtDocOptions::GetCodeName - invalid sheet index" ); + return ((0 <= nTab) && (nTab < GetCodeNameCount())) ? mxImpl->maCodeNames[ static_cast< size_t >( nTab ) ] : EMPTY_STRING; } -void ScExtDocOptions::AppendCodeName( const String& rCodeName ) +void ScExtDocOptions::SetCodeName( SCTAB nTab, const String& rCodeName ) { - mxImpl->maCodeNames.push_back( rCodeName ); + DBG_ASSERT( nTab >= 0, "ScExtDocOptions::SetCodeName - invalid sheet index" ); + if( nTab >= 0 ) + { + size_t nIndex = static_cast< size_t >( nTab ); + if( nIndex >= mxImpl->maCodeNames.size() ) + mxImpl->maCodeNames.resize( nIndex + 1 ); + mxImpl->maCodeNames[ nIndex ] = rCodeName; + } } // ============================================================================ -- cgit v1.2.3 From ecc8b1ae1dd2ca82d37c7e660dd5949caefe37f6 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Wed, 7 Jul 2010 19:44:06 +0200 Subject: mib17: adjusted codename handling in xls filter, do not restrict vba event handling to xls files --- offapi/com/sun/star/script/vba/EventIdentifier.idl | 10 +++++----- offapi/com/sun/star/script/vba/XCoreEventProcessor.idl | 1 - offapi/com/sun/star/script/vba/XEventProcessor.idl | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/offapi/com/sun/star/script/vba/EventIdentifier.idl b/offapi/com/sun/star/script/vba/EventIdentifier.idl index ea200c858c30..f70a84d9ace8 100755 --- a/offapi/com/sun/star/script/vba/EventIdentifier.idl +++ b/offapi/com/sun/star/script/vba/EventIdentifier.idl @@ -87,11 +87,11 @@ constants EventIdentifier const long WORKBOOK_DEACTIVATE = 2002; /** Document opened (loaded). No arguments. */ const long WORKBOOK_OPEN = 2003; - /** Document about to be closed. No arguments. Cancellable. */ + /** Document about to be closed. Arguments: [out] boolean bCancel. */ const long WORKBOOK_BEFORECLOSE = 2004; - /** Document about to be printed. No arguments. Cancellable. */ + /** Document about to be printed. Arguments: [out] boolean bCancel. */ const long WORKBOOK_BEFOREPRINT = 2005; - /** Document about to be saved. Arguments: boolean bSaveAs. Cancellable. */ + /** Document about to be saved. Arguments: boolean bSaveAs, [out] boolean bCancel. */ const long WORKBOOK_BEFORESAVE = 2006; /** Document has been saved. Arguments: boolean bSuccess. */ const long WORKBOOK_AFTERSAVE = 2007; @@ -111,9 +111,9 @@ constants EventIdentifier const long WORKSHEET_ACTIVATE = 2101; /** Worksheet has been activated (made visible). Arguments: short nSheet. */ const long WORKSHEET_DEACTIVATE = 2102; - /** Double click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. */ + /** Double click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. [out] boolean bCancel. */ const long WORKSHEET_BEFOREDOUBLECLICK = 2103; - /** Right click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. */ + /** Right click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. [out] boolean bCancel. */ const long WORKSHEET_BEFORERIGHTCLICK = 2104; /** Cells in sheet have been recalculated. Arguments: short nSheet. */ const long WORKSHEET_CALCULATE = 2105; diff --git a/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl b/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl index be152a8ba7fd..989b1f4039cb 100755 --- a/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl +++ b/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl @@ -30,7 +30,6 @@ #include #include -#include #include //============================================================================= diff --git a/offapi/com/sun/star/script/vba/XEventProcessor.idl b/offapi/com/sun/star/script/vba/XEventProcessor.idl index 579cdf881963..d856aeaa0a99 100755 --- a/offapi/com/sun/star/script/vba/XEventProcessor.idl +++ b/offapi/com/sun/star/script/vba/XEventProcessor.idl @@ -30,7 +30,6 @@ #include #include -#include #include //============================================================================= -- cgit v1.2.3 From dd6ba6b64aec20d37a402bee233e742e29285e88 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 --- basic/source/classes/sbunoobj.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 basic/source/classes/sbunoobj.cxx diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx old mode 100644 new mode 100755 index e51a0c09270b..df13bc7ec571 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -911,7 +911,7 @@ Type getUnoTypeForSbxBaseType( SbxDataType eType ) case SbxVARIANT: aRetType = ::getCppuType( (Any*)0 ); break; //case SbxDATAOBJECT: break; case SbxCHAR: aRetType = ::getCppuType( (sal_Unicode*)0 ); break; - case SbxBYTE: aRetType = ::getCppuType( (sal_Int16*)0 ); break; + case SbxBYTE: aRetType = ::getCppuType( (sal_Int8*)0 ); break; case SbxUSHORT: aRetType = ::getCppuType( (sal_uInt16*)0 ); break; case SbxULONG: aRetType = ::getCppuType( (sal_uInt32*)0 ); break; //case SbxLONG64: break; -- cgit v1.2.3 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(-) 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 v1.2.3 From 47ad9825590f931c574f83602b0745a122a79485 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Thu, 8 Jul 2010 22:10:20 +0200 Subject: hg commig -mmib17: --- vbahelper/source/msforms/vbacontrols.cxx | 20 ++++++++++++++------ vbahelper/source/msforms/vbauserform.cxx | 4 +++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/vbahelper/source/msforms/vbacontrols.cxx b/vbahelper/source/msforms/vbacontrols.cxx index b7fad7d9372d..8d01687ef905 100644 --- a/vbahelper/source/msforms/vbacontrols.cxx +++ b/vbahelper/source/msforms/vbacontrols.cxx @@ -74,12 +74,20 @@ private: public: ControlArrayWrapper( const uno::Reference< awt::XControl >& xDialog ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); - uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); + try + { + mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + uno::Sequence< uno::Reference< awt::XControl > > sXControls = mxDialog->getControls(); - msNames.realloc( sXControls.getLength() ); - for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) - SetArrayElementTo( sXControls[ i ], i ); + msNames.realloc( sXControls.getLength() ); + for ( sal_Int32 i = 0; i < sXControls.getLength(); ++i ) + SetArrayElementTo( sXControls[ i ], i ); + } + catch( uno::Exception& ) + { + // accept the case when the dialog already does not exist + // in this case the wrapper should work in dummy mode + } } static rtl::OUString getControlName( const uno::Reference< awt::XControl >& xCtrl ) @@ -186,7 +194,7 @@ ScVbaControls::ScVbaControls( const uno::Reference< XHelperInterface >& xParent, const css::uno::Reference< awt::XControl >& xDialog ) : ControlsImpl_BASE( xParent, xContext, lcl_controlsWrapper( xDialog ) ) { - mxDialog.set( xDialog, uno::UNO_QUERY_THROW ); + mxDialog.set( xDialog, uno::UNO_QUERY ); } uno::Reference< container::XEnumeration > diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx index 1ce403fc19c3..2a4cecfc2338 100644 --- a/vbahelper/source/msforms/vbauserform.cxx +++ b/vbahelper/source/msforms/vbauserform.cxx @@ -185,7 +185,9 @@ ScVbaUserForm::hasMethod( const ::rtl::OUString& /*aName*/ ) throw (uno::Runtime uno::Any SAL_CALL ScVbaUserForm::Controls( const uno::Any& index ) throw (uno::RuntimeException) { - uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW ); + // if the dialog already closed we should do nothing, but the VBA will call methods of the Controls objects + // thus we have to provide a dummy object in this case + uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY ); uno::Reference< XCollection > xControls( new ScVbaControls( this, mxContext, xDialogControl ) ); if ( index.hasValue() ) return uno::makeAny( xControls->Item( index, uno::Any() ) ); -- cgit v1.2.3 From f801707b085ea0356749a79588ab00ef13d3ac48 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 9 Jul 2010 09:58:50 +0200 Subject: #i113045# SetTextToWidthOrHash: do the single-character width calculations in logic units --- sc/source/ui/view/output2.cxx | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 8e4a3e6b2ec9..6d40d304fb13 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -171,12 +171,11 @@ public: private: void SetHashText(); - long GetMaxDigitWidth(); + long GetMaxDigitWidth(); // in logic units long GetSignWidth(); long GetDotWidth(); long GetExpWidth(); void TextChanged(); - long ConvertWidthLogicToPixel( long nWidth ) const; }; //================================================================== @@ -518,6 +517,10 @@ void ScDrawStringsVars::SetHashText() void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) { + // #i113045# do the single-character width calculations in logic units + if (bPixelToLogic) + nWidth = pOutput->pRefDevice->PixelToLogic(Size(nWidth,0)).Width(); + if (!pCell) return; @@ -588,10 +591,6 @@ void ScDrawStringsVars::SetTextToWidthOrHash( ScBaseCell* pCell, long nWidth ) } long nActualTextWidth = pOutput->pFmtDevice->GetTextWidth(aString); - - if (bPixelToLogic) - nActualTextWidth = ConvertWidthLogicToPixel(nActualTextWidth); - if (nActualTextWidth > nWidth) { // Even after the decimal adjustment the text doesn't fit. Give up. @@ -645,9 +644,6 @@ long ScDrawStringsVars::GetMaxDigitWidth() long n = pOutput->pFmtDevice->GetTextWidth(String(cDigit)); nMaxDigitWidth = ::std::max(nMaxDigitWidth, n); } - - if (bPixelToLogic) - nMaxDigitWidth = ConvertWidthLogicToPixel(nMaxDigitWidth); return nMaxDigitWidth; } @@ -657,8 +653,6 @@ long ScDrawStringsVars::GetSignWidth() return nSignWidth; nSignWidth = pOutput->pFmtDevice->GetTextWidth(String('-')); - if (bPixelToLogic) - nSignWidth = ConvertWidthLogicToPixel(nSignWidth); return nSignWidth; } @@ -669,8 +663,6 @@ long ScDrawStringsVars::GetDotWidth() const ::rtl::OUString& sep = ScGlobal::GetpLocaleData()->getLocaleItem().decimalSeparator; nDotWidth = pOutput->pFmtDevice->GetTextWidth(sep); - if (bPixelToLogic) - nDotWidth = ConvertWidthLogicToPixel(nDotWidth); return nDotWidth; } @@ -680,8 +672,6 @@ long ScDrawStringsVars::GetExpWidth() return nExpWidth; nExpWidth = pOutput->pFmtDevice->GetTextWidth(String('E')); - if (bPixelToLogic) - nExpWidth = ConvertWidthLogicToPixel(nExpWidth); return nExpWidth; } @@ -711,13 +701,6 @@ void ScDrawStringsVars::TextChanged() aTextSize = pRefDevice->LogicToPixel( aTextSize ); } -long ScDrawStringsVars::ConvertWidthLogicToPixel( long nWidth ) const -{ - Size aSize(nWidth, pOutput->pFmtDevice->GetTextHeight()); - aSize = pOutput->pRefDevice->LogicToPixel(aSize); - return aSize.Width(); -} - BOOL ScDrawStringsVars::HasEditCharacters() const { static const sal_Unicode pChars[] = -- cgit v1.2.3 From 122a13f1cbe9f43d04c082d40d0a672b5814b4c1 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 9 Jul 2010 16:46:39 +0200 Subject: mib17: compiler warnings --- sc/source/filter/excel/excdoc.cxx | 8 ++++---- sc/source/filter/inc/excdoc.hxx | 6 +++--- sc/source/ui/vba/vbaeventshelper.cxx | 6 +++--- sc/source/ui/vba/vbaformatconditions.cxx | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/sc/source/filter/excel/excdoc.cxx b/sc/source/filter/excel/excdoc.cxx index 5534f8e775a9..3523c272291d 100644 --- a/sc/source/filter/excel/excdoc.cxx +++ b/sc/source/filter/excel/excdoc.cxx @@ -425,7 +425,7 @@ void ExcTable::FillAsHeader( ExcBoundsheetList& rBoundsheetList ) } -void ExcTable::FillAsTable( size_t nCodeNameIdx ) +void ExcTable::FillAsTable( SCTAB nCodeNameIdx ) { InitializeTable( mnScTab ); @@ -555,7 +555,7 @@ void ExcTable::FillAsTable( size_t nCodeNameIdx ) Add( new ExcEof ); } -void ExcTable::FillAsXmlTable( size_t nCodeNameIdx ) +void ExcTable::FillAsXmlTable( SCTAB nCodeNameIdx ) { RootData& rR = GetOldRoot(); @@ -645,7 +645,7 @@ void ExcTable::FillAsXmlTable( size_t nCodeNameIdx ) } -void ExcTable::FillAsEmptyTable( size_t nCodeNameIdx ) +void ExcTable::FillAsEmptyTable( SCTAB nCodeNameIdx ) { InitializeTable( mnScTab ); @@ -728,7 +728,7 @@ void ExcDocument::ReadDoc( void ) aHeader.FillAsHeader( maBoundsheetList ); SCTAB nScTab = 0, nScTabCount = GetTabInfo().GetScTabCount(); - size_t nCodeNameIdx = 0, nCodeNameCount = GetExtDocOptions().GetCodeNameCount(); + SCTAB nCodeNameIdx = 0, nCodeNameCount = GetExtDocOptions().GetCodeNameCount(); for( ; nScTab < nScTabCount; ++nScTab ) { diff --git a/sc/source/filter/inc/excdoc.hxx b/sc/source/filter/inc/excdoc.hxx index f00e8d091590..5da6a5d38d83 100644 --- a/sc/source/filter/inc/excdoc.hxx +++ b/sc/source/filter/inc/excdoc.hxx @@ -69,7 +69,7 @@ private: // pRec mit new anlegen und vergessen, delete macht ExcTable selber! void Add( XclExpRecordBase* pRec ); - void FillAsXmlTable( size_t nCodeNameIdx ); + void FillAsXmlTable( SCTAB nCodeNameIdx ); public: ExcTable( const XclExpRoot& rRoot ); @@ -77,8 +77,8 @@ public: ~ExcTable(); void FillAsHeader( ExcBoundsheetList& rBoundsheetList ); - void FillAsTable( size_t nCodeNameIdx ); - void FillAsEmptyTable( size_t nCodeNameIdx ); + void FillAsTable( SCTAB nCodeNameIdx ); + void FillAsEmptyTable( SCTAB nCodeNameIdx ); void Write( XclExpStream& ); void WriteXml( XclExpXmlStream& ); diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index c9e92a218877..6b5c80b12884 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -269,7 +269,7 @@ void SAL_CALL ScVbaWindowListener::windowResized( const awt::WindowEvent& /*aEv mbWindowResized = true; if( mbBorderChanged ) { - if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) ) + if( /*Window* pWindow =*/ VCLUnoHelper::GetWindow( getContainerWindow() ) ) { mbBorderChanged = mbWindowResized = false; acquire(); // ensure we don't get deleted before the event is handled @@ -318,7 +318,7 @@ void SAL_CALL ScVbaWindowListener::borderWidthsChanged( const uno::Reference< un mbBorderChanged = true; if( mbWindowResized ) { - if( Window* pWindow = VCLUnoHelper::GetWindow( getContainerWindow() ) ) + if( /*Window* pWindow =*/ VCLUnoHelper::GetWindow( getContainerWindow() ) ) { mbWindowResized = mbBorderChanged = false; acquire(); // ensure we don't get deleted before the timer fires. @@ -365,7 +365,7 @@ bool ScVbaWindowListener::isMouseReleased() return false; } -IMPL_LINK( ScVbaWindowListener, fireResizeMacro, void*, EMPTY_ARGS ) +IMPL_LINK( ScVbaWindowListener, fireResizeMacro, void*, EMPTYARG ) { if( mpVbaEvents && isMouseReleased() ) processWindowResizeMacro(); diff --git a/sc/source/ui/vba/vbaformatconditions.cxx b/sc/source/ui/vba/vbaformatconditions.cxx index b79129d18387..8dd67843ec00 100644 --- a/sc/source/ui/vba/vbaformatconditions.cxx +++ b/sc/source/ui/vba/vbaformatconditions.cxx @@ -45,7 +45,7 @@ static rtl::OUString FORMULA2( RTL_CONSTASCII_USTRINGPARAM("Formula2") ); static rtl::OUString STYLENAME( RTL_CONSTASCII_USTRINGPARAM("StyleName") ); static rtl::OUString sStyleNamePrefix( RTL_CONSTASCII_USTRINGPARAM("Excel_CondFormat") ); -ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& xModel ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries ) +ScVbaFormatConditions::ScVbaFormatConditions( const uno::Reference< XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< sheet::XSheetConditionalEntries >& _xSheetConditionalEntries, const uno::Reference< frame::XModel >& /*xModel*/ ) : ScVbaFormatConditions_BASE( xParent, xContext, uno::Reference< container::XIndexAccess >( _xSheetConditionalEntries, uno::UNO_QUERY_THROW ) ), mxSheetConditionalEntries( _xSheetConditionalEntries ) { mxRangeParent.set( xParent, uno::UNO_QUERY_THROW ); uno::Reference< excel::XApplication> xApp( Application(), uno::UNO_QUERY_THROW ); -- cgit v1.2.3 From aaf48ef999ab4345af109d6c4ff25ea0f986a238 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Fri, 9 Jul 2010 18:57:49 +0200 Subject: calc56: #i112745# draw edit cells and printer-metrics text before DataPilot buttons --- sc/source/ui/view/gridwin4.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index 4e1a19caae6d..6bf27387314a 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -750,6 +750,15 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( !bLogicText ) aOutputData.DrawStrings(FALSE); // in pixel MapMode + // edit cells and printer-metrics text must be before the buttons + // (DataPilot buttons contain labels in UI font) + + pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich)); + if ( bLogicText ) + aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set + aOutputData.DrawEdit(TRUE); + pContentDev->SetMapMode(MAP_PIXEL); + // Autofilter- und Pivot-Buttons DrawButtons( nX1, nY1, nX2, nY2, aTabInfo, pContentDev ); // Pixel @@ -759,14 +768,6 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, ScUpdateMod if ( rOpts.GetOption( VOPT_NOTES ) ) aOutputData.DrawNoteMarks(); - // Edit-Zellen - - pContentDev->SetMapMode(pViewData->GetLogicMode(eWhich)); - if ( bLogicText ) - aOutputData.DrawStrings(TRUE); // in logic MapMode if bTextWysiwyg is set - aOutputData.DrawEdit(TRUE); - - pContentDev->SetMapMode(MAP_PIXEL); if ( !bGridFirst && ( bGrid || bPage ) ) { aOutputData.DrawGrid( bGrid, bPage ); -- cgit v1.2.3 From 59665af0c094f4b0ecbf63f0ba532fa2fccbb2f0 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 9 Jul 2010 19:36:11 +0200 Subject: mib17: remove unused static var --- sc/source/ui/docshell/docfunc.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx index 8004fb80f7ed..b9aa21363a64 100644 --- a/sc/source/ui/docshell/docfunc.cxx +++ b/sc/source/ui/docshell/docfunc.cxx @@ -2605,7 +2605,6 @@ uno::Reference< uno::XInterface > GetDocModuleObject( SfxObjectShell& rDocSh, St script::ModuleInfo lcl_InitModuleInfo( SfxObjectShell& rDocSh, String& sModule ) { - ::rtl::OUString sVbaOption( RTL_CONSTASCII_USTRINGPARAM( "Rem Attribute VBA_ModuleType=VBADocumentModule\nOption VBASupport 1\n" )); script::ModuleInfo sModuleInfo; sModuleInfo.ModuleType = script::ModuleType::DOCUMENT; sModuleInfo.ModuleObject = GetDocModuleObject( rDocSh, sModule ); -- cgit v1.2.3 From d51b5501b66fd73252a4788ba0e2e215156c5488 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Fri, 9 Jul 2010 19:36:57 +0200 Subject: mib17: restrict export of codenames to ODF to VBA enabled documents --- sc/source/filter/xml/xmlexprt.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index f7822c753308..f5a4b3648ebb 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -4301,7 +4301,7 @@ void ScXMLExport::GetConfigurationSettings(uno::Sequence& uno::Reference xCodeNameAccess; DBG_ASSERT( pDoc, "ScXMLExport::GetConfigurationSettings - no ScDocument!" ); - if( pDoc ) + if( pDoc && pDoc->IsInVBAMode() ) { xCodeNameAccess = new XMLCodeNameProvider( pDoc ); if( xCodeNameAccess.is() && xCodeNameAccess->hasElements() ) -- cgit v1.2.3 From 366a18ae5698f759c3f463294d69abee41d1f8a3 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Sat, 10 Jul 2010 17:12:56 +0200 Subject: mib17: #i113070# WaE: wrong return values --- oox/source/drawingml/chart/titlecontext.cxx | 2 +- oox/source/vml/vmlshapecontext.cxx | 2 +- oox/source/xls/externallinkfragment.cxx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oox/source/drawingml/chart/titlecontext.cxx b/oox/source/drawingml/chart/titlecontext.cxx index 963ccdad595a..5ff71109b710 100644 --- a/oox/source/drawingml/chart/titlecontext.cxx +++ b/oox/source/drawingml/chart/titlecontext.cxx @@ -68,7 +68,7 @@ ContextHandlerRef TextContext::onCreateContext( sal_Int32 nElement, const Attrib } break; } - return false; + return 0; } void TextContext::onEndElement( const OUString& rChars ) diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 09aa19902366..2fc64fc8b275 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -170,7 +170,7 @@ ShapeContextBase::ShapeContextBase( ContextHandler2Helper& rParent ) : case VML_TOKEN( image ): return new ShapeContext( rParent, rAttribs, rShapes.createShape< ComplexShape >() ); } - return false; + return 0; } // ============================================================================ diff --git a/oox/source/xls/externallinkfragment.cxx b/oox/source/xls/externallinkfragment.cxx index 15aaf8bc5412..e1bff95ff724 100644 --- a/oox/source/xls/externallinkfragment.cxx +++ b/oox/source/xls/externallinkfragment.cxx @@ -255,7 +255,7 @@ ContextHandlerRef OoxExternalLinkFragment::onCreateContext( sal_Int32 nElement, if( nElement == XLS_TOKEN( oleItem ) ) mxExtName = mrExtLink.importOleItem( rAttribs ); break; } - return false; + return 0; } void OoxExternalLinkFragment::onEndElement( const OUString& rChars ) -- cgit v1.2.3 From bb51dc29f50476471308159c97c25fa059dcd17a Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Sat, 10 Jul 2010 17:13:52 +0200 Subject: mib17: #i110746# fixed memory leaks --- vbahelper/inc/vbahelper/vbaglobalbase.hxx | 4 +-- vbahelper/source/vbahelper/vbaapplicationbase.cxx | 1 - vbahelper/source/vbahelper/vbaglobalbase.cxx | 33 ++++++++++++++++++++--- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/vbahelper/inc/vbahelper/vbaglobalbase.hxx b/vbahelper/inc/vbahelper/vbaglobalbase.hxx index e75cbb7e7af8..61aaa1d65657 100644 --- a/vbahelper/inc/vbahelper/vbaglobalbase.hxx +++ b/vbahelper/inc/vbahelper/vbaglobalbase.hxx @@ -32,16 +32,16 @@ typedef InheritedHelperInterfaceImpl1< ov::XGlobalsBase > Globals_BASE; class VBAHELPER_DLLPUBLIC VbaGlobalsBase : public Globals_BASE - { protected: + rtl::OUString msDocCtxName; bool hasServiceName( const rtl::OUString& serviceName ); void init( const css::uno::Sequence< css::beans::PropertyValue >& aInitArgs ); public: VbaGlobalsBase( const css::uno::Reference< ov::XHelperInterface >& xParent, const css::uno::Reference< css::uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ); - virtual ~VbaGlobalsBase(){}; + virtual ~VbaGlobalsBase(); // XMultiServiceFactory virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) throw (css::uno::Exception, css::uno::RuntimeException); virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, const css::uno::Sequence< css::uno::Any >& Arguments ) throw (css::uno::Exception, css::uno::RuntimeException); diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx index 213133998def..8af75a6bd043 100644 --- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx +++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx @@ -182,7 +182,6 @@ VbaApplicationBase::VbaApplicationBase( const uno::Reference< uno::XComponentCon VbaApplicationBase::~VbaApplicationBase() { - m_pImpl = 0; delete m_pImpl; } diff --git a/vbahelper/source/vbahelper/vbaglobalbase.cxx b/vbahelper/source/vbahelper/vbaglobalbase.cxx index b4b39344fd61..e0df37583df5 100644 --- a/vbahelper/source/vbahelper/vbaglobalbase.cxx +++ b/vbahelper/source/vbahelper/vbaglobalbase.cxx @@ -41,19 +41,44 @@ rtl::OUString sAppService( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.Application") ); VbaGlobalsBase::VbaGlobalsBase( const uno::Reference< ov::XHelperInterface >& xParent, const uno::Reference< uno::XComponentContext >& xContext, const rtl::OUString& sDocCtxName ) -: Globals_BASE( xParent, xContext ) +: Globals_BASE( xParent, xContext ), msDocCtxName( sDocCtxName ) { // overwrite context with custom one ( that contains the application ) + // wrap the service manager as we don't want the disposing context to tear down the 'normal' ServiceManager ( or at least thats what the code appears like it wants to do ) + uno::Any aSrvMgr; + if ( xContext.is() && xContext->getServiceManager().is() ) + { + aSrvMgr = uno::makeAny( xContext->getServiceManager()->createInstanceWithContext( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.OServiceManagerWrapper") ), xContext ) ); + } + ::cppu::ContextEntry_Init aHandlerContextInfo[] = { ::cppu::ContextEntry_Init( sApplication, uno::Any() ), ::cppu::ContextEntry_Init( sDocCtxName, uno::Any() ), + ::cppu::ContextEntry_Init( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.lang.theServiceManager" ) ), aSrvMgr ) }; - - mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), xContext ); - + // don't pass a delegate, this seems to introduce yet another cyclic dependency ( and + // some strange behavior + mxContext = ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), NULL ); } +VbaGlobalsBase::~VbaGlobalsBase() +{ + try + { + uno::Reference< container::XNameContainer > xNameContainer( mxContext, uno::UNO_QUERY ); + if ( xNameContainer.is() ) + { + // release document reference ( we don't wan't the component context trying to dispose that ) + xNameContainer->removeByName( msDocCtxName ); + // release application reference, as it is holding onto the context + xNameContainer->removeByName( sApplication ); + } + } + catch ( const uno::Exception& ) + { + } +} void VbaGlobalsBase::init( const uno::Sequence< beans::PropertyValue >& aInitArgs ) -- cgit v1.2.3 From 7aa177e87e43d6db6134cd08282181f905a4dcf1 Mon Sep 17 00:00:00 2001 From: Mikhail Voytenko Date: Mon, 12 Jul 2010 09:09:07 +0200 Subject: mib17: #162973# implementation of 'Empty' symbol from AB --- basic/source/runtime/props.cxx | 7 +++++++ basic/source/runtime/rtlproto.hxx | 1 + basic/source/runtime/stdobj.cxx | 1 + 3 files changed, 9 insertions(+) diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx index cec74444e7a2..663d12fbcd72 100644 --- a/basic/source/runtime/props.cxx +++ b/basic/source/runtime/props.cxx @@ -76,6 +76,13 @@ RTLFUNC(False) rPar.Get(0)->PutBool( FALSE ); } +RTLFUNC(Empty) +{ + (void)pBasic; + (void)bWrite; + (void)rPar; +} + RTLFUNC(Nothing) { (void)pBasic; diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index 1a1ae4f32283..5437654f69a0 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -38,6 +38,7 @@ extern RTLFUNC(Date); extern RTLFUNC(Err); extern RTLFUNC(Erl); extern RTLFUNC(False); +extern RTLFUNC(Empty); extern RTLFUNC(Nothing); extern RTLFUNC(Null); extern RTLFUNC(True); diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 60d2e9cf448d..4455901bfeba 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -221,6 +221,7 @@ static Methods aMethods[] = { { "FileSpec", SbxSTRING, 0,NULL,0 }, { "DumpAll", SbxINTEGER, _OPT, NULL,0 }, +{ "Empty", SbxVARIANT, _CPROP, RTLNAME(Empty),0 }, { "EqualUnoObjects",SbxBOOL, 2 | _FUNCTION, RTLNAME(EqualUnoObjects),0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, -- cgit v1.2.3 From adf3c10549e3a755f8705e3b97939f4488ee7381 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 12 Jul 2010 11:17:00 +0200 Subject: mib17: #i112634# API changes --- vbahelper/inc/vbahelper/vbaeventshelperbase.hxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx index a84b0e28f9db..b7216746c81d 100755 --- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx +++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx @@ -29,7 +29,7 @@ #define VBAHELPER_VBAEVENTSHELPERBASE_HXX #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ namespace com { namespace sun { namespace star { // ============================================================================ -typedef ::cppu::WeakImplHelper2< css::script::vba::XEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; +typedef ::cppu::WeakImplHelper2< css::script::vba::XVBAEventProcessor, css::lang::XEventListener > VbaEventsHelperBase_BASE; class VBAHELPER_DLLPUBLIC VbaEventsHelperBase : public VbaEventsHelperBase_BASE { @@ -51,7 +51,7 @@ public: const css::uno::Reference< css::uno::XComponentContext >& xContext ); virtual ~VbaEventsHelperBase(); - // XEventProcessor + // XVBAEventProcessor virtual void SAL_CALL setIgnoreEvents( sal_Bool bIgnoreEvents ) throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL getIgnoreEvents() throw (css::uno::RuntimeException); virtual sal_Bool SAL_CALL hasVbaEventHandler( sal_Int32 nEventId, const css::uno::Sequence< css::uno::Any >& rArgs ) throw (css::lang::IllegalArgumentException, css::uno::RuntimeException); -- cgit v1.2.3 From 365321d410148c44f5310bdbd21c79edc7551597 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 12 Jul 2010 11:17:00 +0200 Subject: mib17: #i112634# API changes --- sc/inc/document.hxx | 6 +++--- sc/source/core/data/documen2.cxx | 6 +++--- sc/source/core/data/documen3.cxx | 4 ++-- sc/source/core/data/sheetevents.cxx | 6 +++--- sc/source/ui/docshell/docsh.cxx | 16 ++++++++-------- sc/source/ui/unoobj/docuno.cxx | 14 +++++++------- sc/source/ui/unoobj/viewuno.cxx | 10 +++++----- sc/source/ui/vba/vbaeventshelper.cxx | 6 +++--- sc/source/ui/vba/vbaglobals.cxx | 2 +- sc/source/ui/view/gridwin.cxx | 8 ++++---- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index a829787aac2f..870c95864158 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -160,7 +160,7 @@ namespace com { namespace sun { namespace star { class XEmbeddedObject; } namespace script { namespace vba { - class XEventProcessor; + class XVBAEventProcessor; } } } } } @@ -333,7 +333,7 @@ private: Timer aTrackTimer; // mutable for lazy construction - mutable com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > + mutable com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > mxVbaEvents; public: @@ -1759,7 +1759,7 @@ public: void GetSortParam( ScSortParam& rParam, SCTAB nTab ); void SetSortParam( ScSortParam& rParam, SCTAB nTab ); - com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > GetVbaEventProcessor() const; /** Should only be GRAM_PODF or GRAM_ODFF. */ diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 9c932df05c28..07f25282f0f3 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include "document.hxx" @@ -1293,7 +1293,7 @@ void ScDocument::RemoveLookupCache( ScLookupCache & rCache ) } } -uno::Reference< script::vba::XEventProcessor > ScDocument::GetVbaEventProcessor() const +uno::Reference< script::vba::XVBAEventProcessor > ScDocument::GetVbaEventProcessor() const { if( !mxVbaEvents.is() && pShell && IsInVBAMode() ) { @@ -1302,7 +1302,7 @@ uno::Reference< script::vba::XEventProcessor > ScDocument::GetVbaEventProcessor( uno::Reference< frame::XModel > xModel( pShell->GetModel(), uno::UNO_QUERY_THROW ); uno::Sequence< uno::Any > aArgs(1); aArgs[0] <<= xModel; - mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pShell, "com.sun.star.script.vba.SpreadsheetEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); + mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pShell, "com.sun.star.script.vba.VBASpreadsheetEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); } catch( uno::Exception& ) { diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index a27e5b0a13d5..661eca58ad6f 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -30,7 +30,7 @@ // INCLUDE --------------------------------------------------------------- -#include +#include #include "scitems.hxx" #include #include @@ -503,7 +503,7 @@ bool ScDocument::HasSheetEventScript( SCTAB nTab, sal_Int32 nEvent, bool bWithVb // check if VBA event handlers exist if (bWithVbaEvents) { - uno::Reference< script::vba::XEventProcessor > xVbaEvents = GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = GetVbaEventProcessor(); if ( xVbaEvents.is() ) try { uno::Sequence< uno::Any > aArgs( 1 ); diff --git a/sc/source/core/data/sheetevents.cxx b/sc/source/core/data/sheetevents.cxx index 6086eb84dcbb..e1875b5db15b 100755 --- a/sc/source/core/data/sheetevents.cxx +++ b/sc/source/core/data/sheetevents.cxx @@ -34,7 +34,7 @@ // INCLUDE --------------------------------------------------------------- #include "sheetevents.hxx" -#include +#include #include // ----------------------------------------------------------------------- @@ -64,7 +64,7 @@ rtl::OUString ScSheetEvents::GetEventName(sal_Int32 nEvent) // static sal_Int32 ScSheetEvents::GetVbaSheetEventId(sal_Int32 nEvent) { - using namespace ::com::sun::star::script::vba::EventIdentifier; + using namespace ::com::sun::star::script::vba::VBAEventId; if (nEvent<0 || nEvent>=SC_SHEETEVENT_COUNT) { DBG_ERRORFILE("invalid event number"); @@ -87,7 +87,7 @@ sal_Int32 ScSheetEvents::GetVbaSheetEventId(sal_Int32 nEvent) // static sal_Int32 ScSheetEvents::GetVbaDocumentEventId(sal_Int32 nEvent) { - using namespace ::com::sun::star::script::vba::EventIdentifier; + using namespace ::com::sun::star::script::vba::VBAEventId; sal_Int32 nSheetEventId = GetVbaSheetEventId(nEvent); return (nSheetEventId != NO_EVENT) ? (nSheetEventId + USERDEFINED_START) : NO_EVENT; } diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 9dd754bbc555..7c468bde34e4 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -64,8 +64,8 @@ #include "chgviset.hxx" #include #include -#include -#include +#include +#include #include #include @@ -273,7 +273,7 @@ void ScDocShell::BeforeXMLLoading() aDocument.DisableIdle( TRUE ); // suppress VBA events when loading the xml - uno::Reference< script::vba::XEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); if( xVbaEvents.is() ) xVbaEvents->setIgnoreEvents( sal_True ); @@ -384,7 +384,7 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) pAppMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[ 0 ] ); #if 0 // this should be controlled by a compatibility mode // suppress VBA events when loading the xml - uno::Reference< script::vba::XEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); if( xVbaEvents.is() ) xVbaEvents->setIgnoreEvents( sal_False ); #endif @@ -512,10 +512,10 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium ) void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) { - uno::Reference< script::vba::XEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = aDocument.GetVbaEventProcessor(); if ( xVbaEvents.is() ) try { - using namespace ::com::sun::star::script::vba::EventIdentifier; + using namespace ::com::sun::star::script::vba::VBAEventId; if (rHint.ISA(ScTablesHint) ) { const ScTablesHint& rScHint = static_cast< const ScTablesHint& >( rHint ); @@ -2274,9 +2274,9 @@ USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) { try { - uno::Reference< script::vba::XEventProcessor > xVbaEvents( aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( aDocument.GetVbaEventProcessor(), uno::UNO_SET_THROW ); uno::Sequence< uno::Any > aArgs; - xVbaEvents->processVbaEvent( script::vba::EventIdentifier::WORKBOOK_BEFORECLOSE, aArgs ); + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKBOOK_BEFORECLOSE, aArgs ); } catch( util::VetoException& ) { diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index e3572f0bf598..618648f0f0f6 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -60,8 +60,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -2079,25 +2079,25 @@ void SAL_CALL ScModelObj::processCoreVbaEvent( sal_Int32 nSlotId ) { using namespace ::com::sun::star::script::vba; - sal_Int32 nVbaEventId = EventIdentifier::NO_EVENT; + sal_Int32 nVbaEventId = VBAEventId::NO_EVENT; uno::Sequence< uno::Any > aArgs; switch( nSlotId ) { case SID_SAVEDOC: case SID_SAVEASDOC: - nVbaEventId = EventIdentifier::WORKBOOK_BEFORESAVE; + nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE; aArgs.realloc( 1 ); aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC); break; case SID_PRINTDOC: case SID_PRINTDOCDIRECT: - nVbaEventId = EventIdentifier::WORKBOOK_BEFOREPRINT; + nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT; break; default: throw lang::IllegalArgumentException(); } - uno::Reference< XEventProcessor > xEventProcessor( GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY ); + uno::Reference< XVBAEventProcessor > xEventProcessor( GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY ); if( !xEventProcessor.is() ) throw script::provider::ScriptFrameworkErrorException(); @@ -2350,7 +2350,7 @@ void ScModelObj::HandleCalculateEvents() try { - uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); uno::Sequence< uno::Any > aArgs( 1 ); aArgs[ 0 ] <<= nTab; xVbaEvents->processVbaEvent( ScSheetEvents::GetVbaSheetEventId( SC_SHEETEVENT_CALCULATE ), aArgs ); diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 025e699552e1..b82de19b783f 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -29,8 +29,8 @@ #include "precompiled_sc.hxx" #include -#include -#include +#include +#include #include #include @@ -561,7 +561,7 @@ void lcl_CallActivate( ScDocShell* pDocSh, SCTAB nTab, sal_Int32 nEvent ) // execute VBA event handlers try { - uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); // the parameter is the clicked object, as in the mousePressed call above uno::Sequence< uno::Any > aArgs( 1 ); aArgs[ 0 ] <<= nTab; @@ -1338,7 +1338,7 @@ sal_Bool ScTabViewObj::MousePressed( const awt::MouseEvent& e ) // execute VBA event handler if (!bReturn && xTarget.is()) try { - uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); // the parameter is the clicked object, as in the mousePressed call above uno::Sequence< uno::Any > aArgs( 1 ); aArgs[ 0 ] <<= xTarget; @@ -1851,7 +1851,7 @@ void ScTabViewObj::SelectionChanged() // execute VBA event handler try { - uno::Reference< script::vba::XEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents( pDoc->GetVbaEventProcessor(), uno::UNO_SET_THROW ); // the parameter is the clicked object, as in the mousePressed call above uno::Sequence< uno::Any > aArgs( 1 ); aArgs[ 0 ] <<= getSelection(); diff --git a/sc/source/ui/vba/vbaeventshelper.cxx b/sc/source/ui/vba/vbaeventshelper.cxx index 6b5c80b12884..115ef934adff 100755 --- a/sc/source/ui/vba/vbaeventshelper.cxx +++ b/sc/source/ui/vba/vbaeventshelper.cxx @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,7 +51,7 @@ #include "convuno.hxx" using namespace ::com::sun::star; -using namespace ::com::sun::star::script::vba::EventIdentifier; +using namespace ::com::sun::star::script::vba::VBAEventId; using namespace ::ooo::vba; // ============================================================================ @@ -769,7 +769,7 @@ sdecl::class_ > serviceImpl; extern sdecl::ServiceDecl const serviceDecl( serviceImpl, "ScVbaEventsHelper", - "com.sun.star.script.vba.SpreadsheetEventProcessor" ); + "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ); } // ============================================================================ diff --git a/sc/source/ui/vba/vbaglobals.cxx b/sc/source/ui/vba/vbaglobals.cxx index 178ee85ef068..03f3ecd3c50c 100644 --- a/sc/source/ui/vba/vbaglobals.cxx +++ b/sc/source/ui/vba/vbaglobals.cxx @@ -233,7 +233,7 @@ ScVbaGlobals::getAvailableServiceNames( ) throw (uno::RuntimeException) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Worksheet" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Application" ) ), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "ooo.vba.excel.Hyperlink" ) ), - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.SpreadsheetEventProcessor" ) ) + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.script.vba.VBASpreadsheetEventProcessor" ) ) }; sal_Int32 nExcelServices = ( sizeof( names )/ sizeof( names[0] ) ); sal_Int32 startIndex = serviceNames.getLength(); diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 2d7f883ea852..a7d2203197d4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -69,8 +69,8 @@ #include #include #include -#include -#include +#include +#include #include "gridwin.hxx" #include "tabvwsh.hxx" @@ -2132,7 +2132,7 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) ScGlobal::OpenURL( aUrl, aTarget ); // fire worksheet_followhyperlink event - uno::Reference< script::vba::XEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); if( xVbaEvents.is() ) try { Point aPos = rMEvt.GetPosPixel(); @@ -2147,7 +2147,7 @@ void __EXPORT ScGridWindow::MouseButtonUp( const MouseEvent& rMEvt ) uno::Reference< table::XCell > xCell( new ScCellObj( pViewData->GetDocShell(), aCellPos ) ); uno::Sequence< uno::Any > aArgs(1); aArgs[0] <<= xCell; - xVbaEvents->processVbaEvent( script::vba::EventIdentifier::WORKSHEET_FOLLOWHYPERLINK, aArgs ); + xVbaEvents->processVbaEvent( script::vba::VBAEventId::WORKSHEET_FOLLOWHYPERLINK, aArgs ); } } catch( uno::Exception& ) -- cgit v1.2.3 From 9eaf48be9b8a9317459383caf11b98e68b038955 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 12 Jul 2010 11:17:00 +0200 Subject: mib17: #i112634# API changes --- offapi/com/sun/star/script/vba/EventIdentifier.idl | 140 --------------------- offapi/com/sun/star/script/vba/EventProcessor.idl | 51 -------- .../star/script/vba/SpreadsheetEventProcessor.idl | 50 -------- .../com/sun/star/script/vba/TextEventProcessor.idl | 50 -------- offapi/com/sun/star/script/vba/VBAEventId.idl | 140 +++++++++++++++++++++ .../com/sun/star/script/vba/VBAEventProcessor.idl | 49 ++++++++ .../script/vba/VBASpreadsheetEventProcessor.idl | 50 ++++++++ .../sun/star/script/vba/VBATextEventProcessor.idl | 50 ++++++++ offapi/com/sun/star/script/vba/XEventProcessor.idl | 113 ----------------- .../com/sun/star/script/vba/XVBAEventProcessor.idl | 111 ++++++++++++++++ offapi/com/sun/star/script/vba/makefile.mk | 10 +- 11 files changed, 405 insertions(+), 409 deletions(-) delete mode 100755 offapi/com/sun/star/script/vba/EventIdentifier.idl delete mode 100755 offapi/com/sun/star/script/vba/EventProcessor.idl delete mode 100755 offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl delete mode 100755 offapi/com/sun/star/script/vba/TextEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/VBAEventId.idl create mode 100755 offapi/com/sun/star/script/vba/VBAEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/VBASpreadsheetEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/VBATextEventProcessor.idl delete mode 100755 offapi/com/sun/star/script/vba/XEventProcessor.idl create mode 100755 offapi/com/sun/star/script/vba/XVBAEventProcessor.idl diff --git a/offapi/com/sun/star/script/vba/EventIdentifier.idl b/offapi/com/sun/star/script/vba/EventIdentifier.idl deleted file mode 100755 index f70a84d9ace8..000000000000 --- a/offapi/com/sun/star/script/vba/EventIdentifier.idl +++ /dev/null @@ -1,140 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __com_sun_star_script_vba_EventIdentifier_idl__ -#define __com_sun_star_script_vba_EventIdentifier_idl__ - -//============================================================================= - -module com { module sun { module star { module script { module vba { - -//============================================================================= - -/** Constants used to identify VBA document events. - -

If one of these events is fired, a specific VBA macro in a specific - document code module will be executed.

- -

Each event expects some specific arguments to be passed to - XEventProcessor::processVbaEvent.

- - @see XEventProcessor - */ -constants EventIdentifier -{ - //========================================================================= - - /** An identifier not corresponding to any VBA document event. */ - const long NO_EVENT = -1; - - //========================================================================= - // Global events (identifiers from 1 to 999) - - /** New document opened from template. No arguments. */ - const long AUTO_NEW = 1; - /** Document opened (loaded). No arguments. */ - const long AUTO_OPEN = 2; - /** Document about to be closed. No arguments. */ - const long AUTO_CLOSE = 3; - /** Application start. No arguments. */ - const long AUTO_EXEC = 4; - /** Application exit. No arguments. */ - const long AUTO_EXIT = 5; - - //========================================================================= - // MS Word (identifiers from 1001 to 1999) - - /** New text document opened from template. No arguments. */ - const long DOCUMENT_NEW = 1001; - /** Text document opened (loaded). No arguments. */ - const long DOCUMENT_OPEN = 1002; - /** Document about to be closed. No arguments. */ - const long DOCUMENT_CLOSE = 1003; - - //========================================================================= - // MS Excel (identifiers from 2001 to 2999) - - //------------------------------------------------------------------------- - // document events (2001-2099) - - /** Document activated. No arguments. */ - const long WORKBOOK_ACTIVATE = 2001; - /** Document deactivated. No arguments. */ - const long WORKBOOK_DEACTIVATE = 2002; - /** Document opened (loaded). No arguments. */ - const long WORKBOOK_OPEN = 2003; - /** Document about to be closed. Arguments: [out] boolean bCancel. */ - const long WORKBOOK_BEFORECLOSE = 2004; - /** Document about to be printed. Arguments: [out] boolean bCancel. */ - const long WORKBOOK_BEFOREPRINT = 2005; - /** Document about to be saved. Arguments: boolean bSaveAs, [out] boolean bCancel. */ - const long WORKBOOK_BEFORESAVE = 2006; - /** Document has been saved. Arguments: boolean bSuccess. */ - const long WORKBOOK_AFTERSAVE = 2007; - /** New sheet inserted. Arguments: short nSheet. */ - const long WORKBOOK_NEWSHEET = 2008; - /** Document window has been activated. No arguments. */ - const long WORKBOOK_WINDOWACTIVATE = 2009; - /** Document window has been deactivated. No arguments. */ - const long WORKBOOK_WINDOWDEACTIVATE = 2010; - /** Document window has been resized. No arguments. */ - const long WORKBOOK_WINDOWRESIZE = 2011; - - //------------------------------------------------------------------------- - // sheet events (2101-2199) - - /** Worksheet has been activated (made visible). Arguments: short nSheet. */ - const long WORKSHEET_ACTIVATE = 2101; - /** Worksheet has been activated (made visible). Arguments: short nSheet. */ - const long WORKSHEET_DEACTIVATE = 2102; - /** Double click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. [out] boolean bCancel. */ - const long WORKSHEET_BEFOREDOUBLECLICK = 2103; - /** Right click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange. [out] boolean bCancel. */ - const long WORKSHEET_BEFORERIGHTCLICK = 2104; - /** Cells in sheet have been recalculated. Arguments: short nSheet. */ - const long WORKSHEET_CALCULATE = 2105; - /** Cells in sheet have been changed. Arguments: XRange/XSheetCellRangeContainer aRange. */ - const long WORKSHEET_CHANGE = 2106; - /** Selection in sheet has been changed. Arguments: XRange/XSheetCellRangeContainer aRange. */ - const long WORKSHEET_SELECTIONCHANGE = 2107; - /** Hyperlink has been clicked. Arguments: XCell aCell. */ - const long WORKSHEET_FOLLOWHYPERLINK = 2108; - - //========================================================================= - - /** Implementations are allowed to use identifiers above this value for any - internal purpose. */ - const long USERDEFINED_START = 1000000; -}; - -//============================================================================= - -}; }; }; }; }; - -//============================================================================= - -#endif diff --git a/offapi/com/sun/star/script/vba/EventProcessor.idl b/offapi/com/sun/star/script/vba/EventProcessor.idl deleted file mode 100755 index 78b2d9c23fdb..000000000000 --- a/offapi/com/sun/star/script/vba/EventProcessor.idl +++ /dev/null @@ -1,51 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __com_sun_star_script_vba_EventProcessor_idl__ -#define __com_sun_star_script_vba_EventProcessor_idl__ - -#include - -module com { module sun { module star { module frame { interface XModel; }; }; }; }; - -//============================================================================= - -module com { module sun { module star { module script { module vba { - -//============================================================================= - -service EventProcessor : XEventProcessor -{ -}; - -//============================================================================= - -}; }; }; }; }; - -//============================================================================= - -#endif diff --git a/offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl b/offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl deleted file mode 100755 index 680a0e1069aa..000000000000 --- a/offapi/com/sun/star/script/vba/SpreadsheetEventProcessor.idl +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __com_sun_star_script_vba_SpreadsheetEventProcessor_idl__ -#define __com_sun_star_script_vba_SpreadsheetEventProcessor_idl__ - -#include - -//============================================================================= - -module com { module sun { module star { module script { module vba { - -//============================================================================= - -service SpreadsheetEventProcessor -{ - service EventProcessor; -}; - -//============================================================================= - -}; }; }; }; }; - -//============================================================================= - -#endif diff --git a/offapi/com/sun/star/script/vba/TextEventProcessor.idl b/offapi/com/sun/star/script/vba/TextEventProcessor.idl deleted file mode 100755 index ae2d36a223c6..000000000000 --- a/offapi/com/sun/star/script/vba/TextEventProcessor.idl +++ /dev/null @@ -1,50 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __com_sun_star_script_vba_TextEventProcessor_idl__ -#define __com_sun_star_script_vba_TextEventProcessor_idl__ - -#include - -//============================================================================= - -module com { module sun { module star { module script { module vba { - -//============================================================================= - -service TextEventProcessor -{ - service EventProcessor; -}; - -//============================================================================= - -}; }; }; }; }; - -//============================================================================= - -#endif diff --git a/offapi/com/sun/star/script/vba/VBAEventId.idl b/offapi/com/sun/star/script/vba/VBAEventId.idl new file mode 100755 index 000000000000..fda83a18d495 --- /dev/null +++ b/offapi/com/sun/star/script/vba/VBAEventId.idl @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_VBAEventId_idl__ +#define __com_sun_star_script_vba_VBAEventId_idl__ + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +/** Constants used to identify VBA document events. + +

If one of these events is fired, a specific VBA macro in a specific + document code module will be executed.

+ +

Each event expects some specific arguments to be passed to + XVBAEventProcessor::processVbaEvent.

+ + @see XVBAEventProcessor + */ +constants VBAEventId +{ + //========================================================================= + + /** An identifier not corresponding to any VBA document event. */ + const long NO_EVENT = -1; + + //========================================================================= + // Global events (identifiers from 1 to 999) + + /** New document opened from template. No arguments. */ + const long AUTO_NEW = 1; + /** Document opened (loaded). No arguments. */ + const long AUTO_OPEN = 2; + /** Document about to be closed. No arguments. */ + const long AUTO_CLOSE = 3; + /** Application start. No arguments. */ + const long AUTO_EXEC = 4; + /** Application exit. No arguments. */ + const long AUTO_EXIT = 5; + + //========================================================================= + // MS Word (identifiers from 1001 to 1999) + + /** New text document opened from template. No arguments. */ + const long DOCUMENT_NEW = 1001; + /** Text document opened (loaded). No arguments. */ + const long DOCUMENT_OPEN = 1002; + /** Document about to be closed. No arguments. */ + const long DOCUMENT_CLOSE = 1003; + + //========================================================================= + // MS Excel (identifiers from 2001 to 2999) + + //------------------------------------------------------------------------- + // document events (2001-2099) + + /** Document activated. No arguments. */ + const long WORKBOOK_ACTIVATE = 2001; + /** Document deactivated. No arguments. */ + const long WORKBOOK_DEACTIVATE = 2002; + /** Document opened (loaded). No arguments. */ + const long WORKBOOK_OPEN = 2003; + /** Document about to be closed. Arguments: [out] boolean bCancel. */ + const long WORKBOOK_BEFORECLOSE = 2004; + /** Document about to be printed. Arguments: [out] boolean bCancel. */ + const long WORKBOOK_BEFOREPRINT = 2005; + /** Document about to be saved. Arguments: boolean bSaveAs, [out] boolean bCancel. */ + const long WORKBOOK_BEFORESAVE = 2006; + /** Document has been saved. Arguments: boolean bSuccess. */ + const long WORKBOOK_AFTERSAVE = 2007; + /** New sheet inserted. Arguments: short nSheet. */ + const long WORKBOOK_NEWSHEET = 2008; + /** Document window has been activated. No arguments. */ + const long WORKBOOK_WINDOWACTIVATE = 2009; + /** Document window has been deactivated. No arguments. */ + const long WORKBOOK_WINDOWDEACTIVATE = 2010; + /** Document window has been resized. No arguments. */ + const long WORKBOOK_WINDOWRESIZE = 2011; + + //------------------------------------------------------------------------- + // sheet events (2101-2199) + + /** Worksheet has been activated (made visible). Arguments: short nSheet. */ + const long WORKSHEET_ACTIVATE = 2101; + /** Worksheet has been activated (made visible). Arguments: short nSheet. */ + const long WORKSHEET_DEACTIVATE = 2102; + /** Double click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange, [out] boolean bCancel. */ + const long WORKSHEET_BEFOREDOUBLECLICK = 2103; + /** Right click in the sheet. Arguments: XRange/XSheetCellRangeContainer aRange, [out] boolean bCancel. */ + const long WORKSHEET_BEFORERIGHTCLICK = 2104; + /** Cells in sheet have been recalculated. Arguments: short nSheet. */ + const long WORKSHEET_CALCULATE = 2105; + /** Cells in sheet have been changed. Arguments: XRange/XSheetCellRangeContainer aRange. */ + const long WORKSHEET_CHANGE = 2106; + /** Selection in sheet has been changed. Arguments: XRange/XSheetCellRangeContainer aRange. */ + const long WORKSHEET_SELECTIONCHANGE = 2107; + /** Hyperlink has been clicked. Arguments: XCell aCell. */ + const long WORKSHEET_FOLLOWHYPERLINK = 2108; + + //========================================================================= + + /** Implementations are allowed to use identifiers above this value for any + internal purpose. */ + const long USERDEFINED_START = 1000000; +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/VBAEventProcessor.idl b/offapi/com/sun/star/script/vba/VBAEventProcessor.idl new file mode 100755 index 000000000000..d993b37ae250 --- /dev/null +++ b/offapi/com/sun/star/script/vba/VBAEventProcessor.idl @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_VBAEventProcessor_idl__ +#define __com_sun_star_script_vba_VBAEventProcessor_idl__ + +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +service VBAEventProcessor : XVBAEventProcessor +{ +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/VBASpreadsheetEventProcessor.idl b/offapi/com/sun/star/script/vba/VBASpreadsheetEventProcessor.idl new file mode 100755 index 000000000000..ce202da4f54c --- /dev/null +++ b/offapi/com/sun/star/script/vba/VBASpreadsheetEventProcessor.idl @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_VBASpreadsheetEventProcessor_idl__ +#define __com_sun_star_script_vba_VBASpreadsheetEventProcessor_idl__ + +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +service VBASpreadsheetEventProcessor +{ + service VBAEventProcessor; +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/VBATextEventProcessor.idl b/offapi/com/sun/star/script/vba/VBATextEventProcessor.idl new file mode 100755 index 000000000000..fd3c7f895d8d --- /dev/null +++ b/offapi/com/sun/star/script/vba/VBATextEventProcessor.idl @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_VBATextEventProcessor_idl__ +#define __com_sun_star_script_vba_VBATextEventProcessor_idl__ + +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +service VBATextEventProcessor +{ + service VBAEventProcessor; +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/XEventProcessor.idl b/offapi/com/sun/star/script/vba/XEventProcessor.idl deleted file mode 100755 index d856aeaa0a99..000000000000 --- a/offapi/com/sun/star/script/vba/XEventProcessor.idl +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __com_sun_star_script_vba_XEventProcessor_idl__ -#define __com_sun_star_script_vba_XEventProcessor_idl__ - -#include -#include -#include - -//============================================================================= - -module com { module sun { module star { module script { module vba { - -//============================================================================= - -/** Executes VBA event handlers. - */ -interface XEventProcessor -{ - //------------------------------------------------------------------------- - - /** Specifies whether VBA event handling is currently disabled. - */ - [attribute] boolean IgnoreEvents; - - //------------------------------------------------------------------------- - - /** Returns whether a VBA event handler exists. - - @param nEventId - The identifier of the event. Must be a constant from - EventIdentifier. - - @param aArgs - Additional arguments needed to identify some event handlers, e.g. a - sheet index for spreadsheet events. - - @return - , if the VBA event handler exists. - - @throws IllegalArgumentException - if the passed event identifier is not supported, or if the passed - specifier is required but invalid. - **/ - boolean hasVbaEventHandler( [in] long nEventId, [in] sequence< any > aArgs ) - raises (::com::sun::star::lang::IllegalArgumentException); - - //------------------------------------------------------------------------- - - /** Executes a VBA event handler. - - @param nEventId - The identifier of the event. Must be a constant from - EventIdentifier. - - @param aArgs - The input arguments needed to create the argument list of the VBA - event handler. - - @throws IllegalArgumentException - if the passed event identifier is not supported, or if the passed - arguments do not conform to the arguments expected by the specified - event. - - @throws ScriptFrameworkErrorException - if the VBA event handler could not be invoked. Reasons may be, that - handling of VBA events is not enabled, that the VBA event handler - macro has not been found, or that the execution of the macro has - been aborted with an error. - - @throws VetoException - if the VBA event handler has indicated to veto the event. - **/ - void processVbaEvent( [in] long nEventId, [in] sequence< any > aArgs ) - raises (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::script::provider::ScriptFrameworkErrorException, - ::com::sun::star::util::VetoException); - - //------------------------------------------------------------------------- -}; - -//============================================================================= - -}; }; }; }; }; - -//============================================================================= - -#endif diff --git a/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl b/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl new file mode 100755 index 000000000000..7853d71d65ac --- /dev/null +++ b/offapi/com/sun/star/script/vba/XVBAEventProcessor.idl @@ -0,0 +1,111 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * 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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_XVBAEventProcessor_idl__ +#define __com_sun_star_script_vba_XVBAEventProcessor_idl__ + +#include +#include +#include + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +/** Executes VBA event handlers. + */ +interface XVBAEventProcessor +{ + //------------------------------------------------------------------------- + + /** Specifies whether VBA event handling is currently disabled. + */ + [attribute] boolean IgnoreEvents; + + //------------------------------------------------------------------------- + + /** Returns whether a VBA event handler exists. + + @param nEventId + The identifier of the event. Must be a constant from VBAEventId. + + @param aArgs + Additional arguments needed to identify some event handlers, e.g. a + sheet index for spreadsheet events. + + @return + , if the VBA event handler exists. + + @throws IllegalArgumentException + if the passed event identifier is not supported, or if the passed + specifier is required but invalid. + **/ + boolean hasVbaEventHandler( [in] long nEventId, [in] sequence< any > aArgs ) + raises (::com::sun::star::lang::IllegalArgumentException); + + //------------------------------------------------------------------------- + + /** Executes a VBA event handler. + + @param nEventId + The identifier of the event. Must be a constant from VBAEventId. + + @param aArgs + The input arguments needed to create the argument list of the VBA + event handler. + + @throws IllegalArgumentException + if the passed event identifier is not supported, or if the passed + arguments do not conform to the arguments expected by the specified + event. + + @throws ScriptFrameworkErrorException + if the VBA event handler could not be invoked. Reasons may be, that + handling of VBA events is not enabled, that the VBA event handler + macro has not been found, or that the execution of the macro has + been aborted with an error. + + @throws VetoException + if the VBA event handler has indicated to veto the event. + **/ + void processVbaEvent( [in] long nEventId, [in] sequence< any > aArgs ) + raises (::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::script::provider::ScriptFrameworkErrorException, + ::com::sun::star::util::VetoException); + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/makefile.mk b/offapi/com/sun/star/script/vba/makefile.mk index c9526d86b070..857df4f9bf63 100755 --- a/offapi/com/sun/star/script/vba/makefile.mk +++ b/offapi/com/sun/star/script/vba/makefile.mk @@ -38,12 +38,12 @@ PACKAGE=com$/sun$/star$/script$/vba # ------------------------------------------------------------------------ IDLFILES=\ - EventIdentifier.idl \ - EventProcessor.idl \ - SpreadsheetEventProcessor.idl \ - TextEventProcessor.idl \ + VBAEventId.idl \ + VBAEventProcessor.idl \ + VBASpreadsheetEventProcessor.idl \ + VBATextEventProcessor.idl \ XCoreEventProcessor.idl \ - XEventProcessor.idl + XVBAEventProcessor.idl # ------------------------------------------------------------------ -- cgit v1.2.3 From f2562cf3027626b269caf4dd74731b69c207febb Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Mon, 12 Jul 2010 11:17:00 +0200 Subject: mib17: #i112634# API changes --- sw/inc/doc.hxx | 6 +++--- sw/source/core/doc/doc.cxx | 4 ++-- sw/source/ui/app/docsh2.cxx | 14 +++++++------- sw/source/ui/vba/vbaeventshelper.cxx | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ff6a1f97709e..1e26b0f0e2bd 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -80,7 +80,7 @@ class SwList; #include #include #ifdef FUTURE_VBA -#include +#include #endif #include @@ -409,7 +409,7 @@ class SW_DLLPUBLIC SwDoc : // table of forbidden characters of this document vos::ORef xForbiddenCharsTable; #ifdef FUTURE_VBA - com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > mxVbaEvents; + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > mxVbaEvents; #endif // --> OD 2007-10-26 #i83479# public: @@ -2134,7 +2134,7 @@ public: return n32DummyCompatabilityOptions2; } #ifdef FUTURE_VBA - com::sun::star::uno::Reference< com::sun::star::script::vba::XEventProcessor > GetVbaEventProcessor(); + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > GetVbaEventProcessor(); #endif ::sfx2::IXmlIdRegistry& GetXmlIdRegistry(); ::sw::MetaFieldManager & GetMetaFieldManager(); diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx index 6979d13fbb62..fd45279d4d13 100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -2725,7 +2725,7 @@ void SwDoc::ChkCondColls() } #ifdef FUTURE_VBA -uno::Reference< script::vba::XEventProcessor > +uno::Reference< script::vba::XVBAEventProcessor > SwDoc::GetVbaEventProcessor() { if( !mxVbaEvents.is() && pDocShell && ooo::vba::isAlienWordDoc( *pDocShell ) ) @@ -2735,7 +2735,7 @@ SwDoc::GetVbaEventProcessor() uno::Reference< frame::XModel > xModel( pDocShell->GetModel(), uno::UNO_SET_THROW ); uno::Sequence< uno::Any > aArgs(1); aArgs[0] <<= xModel; - mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.TextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); + mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW ); } catch( uno::Exception& ) { diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index 501c070e6d6b..c84a0eb2d035 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -120,8 +120,8 @@ #include #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" #ifdef FUTURE_VBA -#include -#include +#include +#include #endif #include #include @@ -191,9 +191,9 @@ void SwDocShell::DoFlushDocInfo() } #ifdef FUTURE_VBA -void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XEventProcessor >& xVbaEvents, const SfxHint& rHint ) +void lcl_processCompatibleSfxHint( const uno::Reference< script::vba::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint ) { - using namespace com::sun::star::script::vba::EventIdentifier; + using namespace com::sun::star::script::vba::VBAEventId; if ( rHint.ISA( SfxEventHint ) ) { uno::Sequence< uno::Any > aArgs; @@ -225,7 +225,7 @@ void SwDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) } #ifdef FUTURE_VBA - uno::Reference< script::vba::XEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); if( xVbaEvents.is() ) lcl_processCompatibleSfxHint( xVbaEvents, rHint ); #endif @@ -314,10 +314,10 @@ USHORT SwDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) #ifdef FUTURE_VBA if( pDoc && IsInPrepareClose() ) { - uno::Reference< script::vba::XEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + uno::Reference< script::vba::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); if( xVbaEvents.is() ) { - using namespace com::sun::star::script::vba::EventIdentifier; + using namespace com::sun::star::script::vba::VBAEventId; uno::Sequence< uno::Any > aArgs; xVbaEvents->processVbaEvent( DOCUMENT_CLOSE, aArgs ); } diff --git a/sw/source/ui/vba/vbaeventshelper.cxx b/sw/source/ui/vba/vbaeventshelper.cxx index 66d72315987e..abe4abb6e757 100755 --- a/sw/source/ui/vba/vbaeventshelper.cxx +++ b/sw/source/ui/vba/vbaeventshelper.cxx @@ -26,11 +26,11 @@ ************************************************************************/ #include "vbaeventshelper.hxx" -#include +#include #include using namespace ::com::sun::star; -using namespace ::com::sun::star::script::vba::EventIdentifier; +using namespace ::com::sun::star::script::vba::VBAEventId; using namespace ::ooo::vba; // ============================================================================ @@ -102,7 +102,7 @@ sdecl::class_ > serviceImpl; extern sdecl::ServiceDecl const serviceDecl( serviceImpl, "SwVbaEventsHelper", - "com.sun.star.document.vba.TextEventProcessor" ); + "com.sun.star.document.vba.VBATextEventProcessor" ); } // ============================================================================ -- cgit v1.2.3 From 8c7337513fc86371edcdf9fcddc8d1fef8efc329 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 12 Jul 2010 19:32:20 +0200 Subject: calc56: #i102690# correct attribute names diagonal-bl-tr-widths and diagonal-tl-br-widths --- sc/source/filter/xml/xmlstyle.cxx | 18 ++++++++++++++++-- sc/source/filter/xml/xmlstyle.hxx | 2 ++ sc/source/filter/xml/xmlstyli.cxx | 19 ++++++++++++++----- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/sc/source/filter/xml/xmlstyle.cxx b/sc/source/filter/xml/xmlstyle.cxx index 4127f5246428..d061ea24b194 100644 --- a/sc/source/filter/xml/xmlstyle.cxx +++ b/sc/source/filter/xml/xmlstyle.cxx @@ -81,9 +81,11 @@ const XMLPropertyMapEntry aXMLScCellStylesProperties[] = MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_IMPORT_MAP ), MAP( "ConditionalFormatXML", XML_NAMESPACE_STYLE, XML_MAP, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_STRING|MID_FLAG_SPECIAL_ITEM, CTF_SC_MAP ), MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER, CTF_SC_DIAGONALBLTR ), - MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTH ), + MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTH ), // #i102690# for old files + MAP( "DiagonalBLTR", XML_NAMESPACE_STYLE, XML_DIAGONAL_BL_TR_WIDTHS, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALBLTRWIDTHS ), MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER, CTF_SC_DIAGONALTLBR ), - MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTH ), + MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTH, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTH ), // #i102690# for old files + MAP( "DiagonalTLBR", XML_NAMESPACE_STYLE, XML_DIAGONAL_TL_BR_WIDTHS, XML_TYPE_PROP_TABLE_CELL|XML_TYPE_BORDER_WIDTH, CTF_SC_DIAGONALTLBRWIDTHS ), MAP( "HoriJustify", XML_NAMESPACE_FO, XML_TEXT_ALIGN, XML_TYPE_PROP_PARAGRAPH|XML_SC_TYPE_HORIJUSTIFY|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_TEXT_ALIGN_SOURCE, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYSOURCE|MID_FLAG_MERGE_PROPERTY, 0 ), MAP( "HoriJustify", XML_NAMESPACE_STYLE, XML_REPEAT_CONTENT, XML_TYPE_PROP_TABLE_CELL|XML_SC_TYPE_HORIJUSTIFYREPEAT|MID_FLAG_MERGE_PROPERTY, 0 ), @@ -490,6 +492,18 @@ void ScXMLCellExportPropertyMapper::ContextFilter( pParaMarginBottomRel->maValue.clear(); } + // #i102690# old diagonal line attribute names without "s" are only read, not written + if (pDiagonalTLBRWidthState) + { + pDiagonalTLBRWidthState->mnIndex = -1; + pDiagonalTLBRWidthState->maValue.clear(); + } + if (pDiagonalBLTRWidthState) + { + pDiagonalBLTRWidthState->mnIndex = -1; + pDiagonalBLTRWidthState->maValue.clear(); + } + SvXMLExportPropertyMapper::ContextFilter(rProperties, rPropSet); } diff --git a/sc/source/filter/xml/xmlstyle.hxx b/sc/source/filter/xml/xmlstyle.hxx index 07e7138afc71..f8abf5e6443d 100644 --- a/sc/source/filter/xml/xmlstyle.hxx +++ b/sc/source/filter/xml/xmlstyle.hxx @@ -90,6 +90,8 @@ extern const XMLPropertyMapEntry aXMLScTableStylesImportProperties[]; #define CTF_SC_DIAGONALTLBRWIDTH (XML_SC_CTF_START + 26) #define CTF_SC_DIAGONALBLTR (XML_SC_CTF_START + 27) #define CTF_SC_DIAGONALBLTRWIDTH (XML_SC_CTF_START + 28) +#define CTF_SC_DIAGONALTLBRWIDTHS (XML_SC_CTF_START + 29) +#define CTF_SC_DIAGONALBLTRWIDTHS (XML_SC_CTF_START + 30) #define CTF_SC_ROWHEIGHT (XML_SC_CTF_START + 50) #define CTF_SC_ROWOPTIMALHEIGHT (XML_SC_CTF_START + 51) diff --git a/sc/source/filter/xml/xmlstyli.cxx b/sc/source/filter/xml/xmlstyli.cxx index 9a04e284bf45..3866bba63239 100644 --- a/sc/source/filter/xml/xmlstyli.cxx +++ b/sc/source/filter/xml/xmlstyli.cxx @@ -105,6 +105,7 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& XMLPropertyState* pAllBorderWidthProperty = NULL; XMLPropertyState* pBorderWidths[4] = { NULL, NULL, NULL, NULL }; XMLPropertyState* pDiagBorders[2] = { 0 }; + XMLPropertyState* pOldDiagBorderWidths[2] = { 0 }; // old attribute names without "s" XMLPropertyState* pDiagBorderWidths[2] = { 0 }; ::std::vector< XMLPropertyState >::iterator endproperty(rProperties.end()); @@ -134,8 +135,10 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& case CTF_SC_BOTTOMBORDERWIDTH : pBorderWidths[XML_LINE_BOTTOM] = &*property; break; case CTF_SC_DIAGONALTLBR : pDiagBorders[XML_LINE_TLBR] = &*property; break; case CTF_SC_DIAGONALBLTR : pDiagBorders[XML_LINE_BLTR] = &*property; break; - case CTF_SC_DIAGONALTLBRWIDTH : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break; - case CTF_SC_DIAGONALBLTRWIDTH : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break; + case CTF_SC_DIAGONALTLBRWIDTH : pOldDiagBorderWidths[XML_LINE_TLBR] = &*property; break; + case CTF_SC_DIAGONALTLBRWIDTHS : pDiagBorderWidths[XML_LINE_TLBR] = &*property; break; + case CTF_SC_DIAGONALBLTRWIDTH : pOldDiagBorderWidths[XML_LINE_BLTR] = &*property; break; + case CTF_SC_DIAGONALBLTRWIDTHS : pDiagBorderWidths[XML_LINE_BLTR] = &*property; break; } } } @@ -179,17 +182,23 @@ void ScXMLCellImportPropertyMapper::finished(::std::vector< XMLPropertyState >& } for( i = 0; i < 2; ++i ) { - if( pDiagBorders[i] && pDiagBorderWidths[i] ) + if( pDiagBorders[i] && ( pDiagBorderWidths[i] || pOldDiagBorderWidths[i] ) ) { table::BorderLine aBorderLine; pDiagBorders[i]->maValue >>= aBorderLine; table::BorderLine aBorderLineWidth; - pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; + if (pDiagBorderWidths[i]) + pDiagBorderWidths[i]->maValue >>= aBorderLineWidth; // prefer new attribute + else + pOldDiagBorderWidths[i]->maValue >>= aBorderLineWidth; aBorderLine.OuterLineWidth = aBorderLineWidth.OuterLineWidth; aBorderLine.InnerLineWidth = aBorderLineWidth.InnerLineWidth; aBorderLine.LineDistance = aBorderLineWidth.LineDistance; pDiagBorders[i]->maValue <<= aBorderLine; - pDiagBorderWidths[i]->mnIndex = -1; + if (pDiagBorderWidths[i]) + pDiagBorderWidths[i]->mnIndex = -1; + if (pOldDiagBorderWidths[i]) + pOldDiagBorderWidths[i]->mnIndex = -1; // reset mnIndex for old and new attribute if both are present } } -- cgit v1.2.3 From 59e208d9037efc74525de69c2a892a30e61648c5 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Mon, 12 Jul 2010 19:32:20 +0200 Subject: calc56: #i102690# correct attribute names diagonal-bl-tr-widths and diagonal-tl-br-widths --- xmloff/inc/xmloff/xmltoken.hxx | 3 +++ xmloff/source/core/xmltoken.cxx | 3 +++ 2 files changed, 6 insertions(+) diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index d892c10f4f5d..f4843d54ace1 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -3107,6 +3107,9 @@ namespace xmloff { namespace token { XML_N_CHART_EXT, XML_COORDINATE_REGION, + XML_DIAGONAL_BL_TR_WIDTHS, + XML_DIAGONAL_TL_BR_WIDTHS, + XML_TOKEN_END }; diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 2e92c4a6a97d..a3d4a0c48d02 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -3107,6 +3107,9 @@ namespace xmloff { namespace token { TOKEN( "http://openoffice.org/2010/chart", XML_N_CHART_EXT ), TOKEN( "coordinate-region", XML_COORDINATE_REGION ), + TOKEN( "diagonal-bl-tr-widths", XML_DIAGONAL_BL_TR_WIDTHS ), + TOKEN( "diagonal-tl-br-widths", XML_DIAGONAL_TL_BR_WIDTHS ), + #if OSL_DEBUG_LEVEL > 0 { 0, NULL, NULL, XML_TOKEN_END } #else -- cgit v1.2.3 From b6a2eaed5b6b9ab8b2e957efc63229968e0023c6 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 15 Jul 2010 11:38:31 +0200 Subject: calc56: #i113160# use XSingleComponentFactory to load external DataPilotSource implementation --- sc/source/core/data/dpobject.cxx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx index a2a10329cf68..739b6a47d1a2 100755 --- a/sc/source/core/data/dpobject.cxx +++ b/sc/source/core/data/dpobject.cxx @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -2277,6 +2278,9 @@ uno::Sequence ScDPObject::GetRegisteredSources() return aSeq; } +// use getContext from addincol.cxx +uno::Reference getContext(uno::Reference xMSF); + // static uno::Reference ScDPObject::CreateSource( const ScDPServiceDesc& rDesc ) { @@ -2301,12 +2305,26 @@ uno::Reference ScDPObject::CreateSource( const ScDPS if ( xIntFac.is() ) { uno::Reference xInfo( xIntFac, uno::UNO_QUERY ); - uno::Reference xFac( xIntFac, uno::UNO_QUERY ); - if ( xFac.is() && xInfo.is() && xInfo->getImplementationName() == aImplName ) + if ( xInfo.is() && xInfo->getImplementationName() == aImplName ) { try { - uno::Reference xInterface = xFac->createInstance(); + // #i113160# try XSingleComponentFactory in addition to (old) XSingleServiceFactory, + // passing the context to the component (see ScUnoAddInCollection::Initialize) + + uno::Reference xInterface; + uno::Reference xCtx = getContext(xManager); + uno::Reference xCFac( xIntFac, uno::UNO_QUERY ); + if (xCtx.is() && xCFac.is()) + xInterface = xCFac->createInstanceWithContext(xCtx); + + if (!xInterface.is()) + { + uno::Reference xFac( xIntFac, uno::UNO_QUERY ); + if ( xFac.is() ) + xInterface = xFac->createInstance(); + } + uno::Reference xInit( xInterface, uno::UNO_QUERY ); if (xInit.is()) { -- cgit v1.2.3 From d5d147219645771f745d46db17d6fd2c31347aae Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 15 Jul 2010 14:11:48 +0200 Subject: calc56: #i113159# check if GetTextEditOutlinerView is null in thesaurus state method --- sc/source/ui/drawfunc/drtxtob.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sc/source/ui/drawfunc/drtxtob.cxx b/sc/source/ui/drawfunc/drtxtob.cxx index bfbeba2d1302..a5159d8a8043 100644 --- a/sc/source/ui/drawfunc/drtxtob.cxx +++ b/sc/source/ui/drawfunc/drtxtob.cxx @@ -486,11 +486,16 @@ void __EXPORT ScDrawTextObjectBar::GetState( SfxItemSet& rSet ) rSet.GetItemState( SID_THESAURUS ) != SFX_ITEM_UNKNOWN ) { SdrView * pView = pViewData->GetScDrawView(); - EditView & rEditView = pView->GetTextEditOutlinerView()->GetEditView(); + OutlinerView* pOutView = pView->GetTextEditOutlinerView(); String aStatusVal; LanguageType nLang = LANGUAGE_NONE; - bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + bool bIsLookUpWord = false; + if ( pOutView ) + { + EditView& rEditView = pOutView->GetEditView(); + bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + } rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); // disable thesaurus main menu and context menu entry if there is nothing to look up -- cgit v1.2.3 From 95552ecffeef703eac55e1095c27962795b55b82 Mon Sep 17 00:00:00 2001 From: Niklas Nebel Date: Thu, 15 Jul 2010 14:11:48 +0200 Subject: calc56: #i113159# check if GetTextEditOutlinerView is null in thesaurus state method --- sd/source/ui/view/drtxtob.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx index 8b88be3682e3..0b99201c611a 100755 --- a/sd/source/ui/view/drtxtob.cxx +++ b/sd/source/ui/view/drtxtob.cxx @@ -384,10 +384,15 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet ) case SID_THES: { - EditView & rEditView = mpView->GetTextEditOutlinerView()->GetEditView();; + OutlinerView* pOLV = mpView->GetTextEditOutlinerView(); String aStatusVal; LanguageType nLang = LANGUAGE_NONE; - bool bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + bool bIsLookUpWord = false; + if ( pOLV ) + { + EditView& rEditView = pOLV->GetEditView(); + bIsLookUpWord = GetStatusValueForThesaurusFromContext( aStatusVal, nLang, rEditView ); + } rSet.Put( SfxStringItem( SID_THES, aStatusVal ) ); // disable "Thesaurus" context menu entry if there is nothing to look up -- cgit v1.2.3 From dfb885a53b8e92b766f13b8f67660f0b58882761 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 15 Jul 2010 14:30:44 +0200 Subject: mib17: #i112634# do not use an UNO interface to handle VBA BeforeSave and BeforePrint events --- sfx2/inc/sfx2/objsh.hxx | 3 +++ sfx2/source/doc/objserv.cxx | 23 +++-------------------- sfx2/source/doc/objstor.cxx | 7 +++++++ sfx2/source/doc/objxtor.cxx | 7 +++++++ sfx2/source/view/viewprn.cxx | 14 ++------------ 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/sfx2/inc/sfx2/objsh.hxx b/sfx2/inc/sfx2/objsh.hxx index 49223c23de75..abe6a8068513 100644 --- a/sfx2/inc/sfx2/objsh.hxx +++ b/sfx2/inc/sfx2/objsh.hxx @@ -346,6 +346,9 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStorage ); virtual void UpdateLinks(); + // called for a few slots like SID_SAVE[AS]DOC, SID_PRINTDOC[DIRECT], derived classes may abort the action + virtual sal_Bool QuerySlotExecutable( USHORT nSlotId ); + sal_Bool SaveChildren(BOOL bObjectsOnly=FALSE); sal_Bool SaveAsChildren( SfxMedium &rMedium ); sal_Bool SwitchChildrenPersistance( diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx index ae3b527ff7a6..066f366b09bd 100644 --- a/sfx2/source/doc/objserv.cxx +++ b/sfx2/source/doc/objserv.cxx @@ -100,7 +100,6 @@ #include #include #include -#include #include "helpid.hrc" @@ -490,21 +489,12 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) case SID_SAVEASDOC: case SID_SAVEDOC: { - // ask VBA emulation at document model whether to save the document - if( nId == SID_SAVEDOC || nId == SID_SAVEASDOC ) try + // derived class may decide to abort this + if( !QuerySlotExecutable( nId ) ) { - Reference< script::vba::XCoreEventProcessor > xEventProcessor( GetModel(), UNO_QUERY_THROW ); - xEventProcessor->processCoreVbaEvent( nId ); - } - catch( util::VetoException& ) - { - // VBA event handler indicates to cancel saving the document - rReq.SetReturnValue( SfxBoolItem( 0, TRUE ) ); + rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); return; } - catch( Exception& ) - { - } //!! detaillierte Auswertung eines Fehlercodes SfxObjectShellRef xLock( this ); @@ -914,13 +904,6 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq) //------------------------------------------------------------------------- -sal_Bool SfxObjectShell::IsInPrepareClose() const -{ - return pImp->bInPrepareClose; -} - -//-------------------------------------------------------------------- - void SfxObjectShell::GetState_Impl(SfxItemSet &rSet) { DBG_CHKTHIS(SfxObjectShell, 0); diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 6e1d89f2a8cd..e1b22ca26a22 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -195,6 +195,13 @@ sal_Bool SfxObjectShell::SaveAs( SfxMedium& rMedium ) //------------------------------------------------------------------------- +sal_Bool SfxObjectShell::QuerySlotExecutable( USHORT /*nSlotId*/ ) +{ + return sal_True; +} + +//------------------------------------------------------------------------- + sal_Bool GetPasswd_Impl( const SfxItemSet* pSet, ::rtl::OUString& rPasswd ) { const SfxPoolItem* pItem = NULL; diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx index 6502eeaeb78c..f8b6cfe44407 100644 --- a/sfx2/source/doc/objxtor.cxx +++ b/sfx2/source/doc/objxtor.cxx @@ -524,6 +524,13 @@ SfxObjectShell* SfxObjectShell::Current() return pFrame ? pFrame->GetObjectShell() : 0; } +//------------------------------------------------------------------------- + +sal_Bool SfxObjectShell::IsInPrepareClose() const +{ + return pImp->bInPrepareClose; +} + //------------------------------------------------------------------------ struct BoolEnv_Impl diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx index faf392c90f32..227099e7d783 100644 --- a/sfx2/source/view/viewprn.cxx +++ b/sfx2/source/view/viewprn.cxx @@ -29,7 +29,6 @@ #include "precompiled_sfx2.hxx" #include -#include #include #include "com/sun/star/view/XRenderable.hpp" @@ -699,21 +698,12 @@ void SfxViewShell::ExecPrint_Impl( SfxRequest &rReq ) { SfxObjectShell* pDoc = GetObjectShell(); - // ask VBA emulation at document model whether to print the document - try + // derived class may decide to abort this + if( !pDoc->QuerySlotExecutable( nId ) ) { - uno::Reference< script::vba::XCoreEventProcessor > xEventProcessor( pDoc->GetModel(), uno::UNO_QUERY_THROW ); - xEventProcessor->processCoreVbaEvent( nId ); - } - catch( util::VetoException& ) - { - // VBA event handler indicates to cancel printing the document rReq.SetReturnValue( SfxBoolItem( 0, FALSE ) ); return; } - catch( uno::Exception& ) - { - } bool bDetectHidden = ( !bSilent && pDoc ); if ( bDetectHidden && pDoc->QueryHiddenInformation( WhenPrinting, NULL ) != RET_YES ) -- cgit v1.2.3 From b49326a5ab03a072cc7d221c3f5a8faa21526018 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 15 Jul 2010 14:30:44 +0200 Subject: mib17: #i112634# do not use an UNO interface to handle VBA BeforeSave and BeforePrint events --- sc/inc/docuno.hxx | 9 -------- sc/source/ui/docshell/docsh.cxx | 39 +++++++++++++++++++++++++++++++ sc/source/ui/inc/docsh.hxx | 1 + sc/source/ui/unoobj/docuno.cxx | 51 +---------------------------------------- 4 files changed, 41 insertions(+), 59 deletions(-) diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index fd2d9a706556..2c3ecee39e32 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -89,7 +88,6 @@ class SC_DLLPUBLIC ScModelObj : public SfxBaseModel, public com::sun::star::view::XRenderable, public com::sun::star::document::XLinkTargetSupplier, public com::sun::star::beans::XPropertySet, - public com::sun::star::script::vba::XCoreEventProcessor, public SvxFmMSFactory, // derived from XMultiServiceFactory public com::sun::star::lang::XServiceInfo, public ::com::sun::star::util::XChangesNotifier @@ -323,13 +321,6 @@ public: virtual void SAL_CALL removeChangesListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XChangesListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); - - // XCoreEventProcessor - virtual void SAL_CALL processCoreVbaEvent( sal_Int32 nSlotId ) - throw (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::script::provider::ScriptFrameworkErrorException, - ::com::sun::star::util::VetoException, - ::com::sun::star::uno::RuntimeException); }; diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 7c468bde34e4..6b2322b43322 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -2243,6 +2243,45 @@ BOOL __EXPORT ScDocShell::DoSaveCompleted( SfxMedium * pNewStor ) } +sal_Bool ScDocShell::QuerySlotExecutable( USHORT nSlotId ) +{ + // #i112634# ask VBA event handlers whether to save or print the document + + using namespace ::com::sun::star::script::vba; + + sal_Int32 nVbaEventId = VBAEventId::NO_EVENT; + uno::Sequence< uno::Any > aArgs; + switch( nSlotId ) + { + case SID_SAVEDOC: + case SID_SAVEASDOC: + nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE; + aArgs.realloc( 1 ); + aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC); + break; + case SID_PRINTDOC: + case SID_PRINTDOCDIRECT: + nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT; + break; + } + + sal_Bool bSlotExecutable = sal_True; + if( nVbaEventId != VBAEventId::NO_EVENT ) try + { + uno::Reference< XVBAEventProcessor > xEventProcessor( aDocument.GetVbaEventProcessor(), uno::UNO_QUERY_THROW ); + xEventProcessor->processVbaEvent( nVbaEventId, aArgs ); + } + catch( util::VetoException& ) + { + bSlotExecutable = sal_False; + } + catch( uno::Exception& ) + { + } + return bSlotExecutable; +} + + USHORT __EXPORT ScDocShell::PrepareClose( BOOL bUI, BOOL bForBrowsing ) { if(SC_MOD()->GetCurRefDlgId()>0) diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 09d34c661995..6c65772c4969 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -215,6 +215,7 @@ public: virtual BOOL SaveCompleted( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& ); // SfxInPlaceObject virtual BOOL DoSaveCompleted( SfxMedium * pNewStor); // SfxObjectShell + virtual sal_Bool QuerySlotExecutable( USHORT nSlotId ); virtual void Draw( OutputDevice *, const JobSetup & rSetup, USHORT nAspect = ASPECT_CONTENT ); diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 618648f0f0f6..28d2a0520f74 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -60,9 +60,8 @@ #include #include #include -#include -#include #include +#include #include #include @@ -104,8 +103,6 @@ using namespace com::sun::star; -#define SC_UNO_VBADOCOBJ "ThisVBADocObj" // perhaps we want to actually make this ThisWorkbook ? - //------------------------------------------------------------------------ // alles ohne Which-ID, Map nur fuer PropertySetInfo @@ -120,7 +117,6 @@ const SfxItemPropertyMapEntry* lcl_GetDocOptPropertyMap() {MAP_CHAR_LEN(SC_UNO_AUTOCONTFOC), 0, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNO_BASICLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN(SC_UNO_DIALOGLIBRARIES), 0, &getCppuType((uno::Reference< script::XLibraryContainer >*)0), beans::PropertyAttribute::READONLY, 0}, - {MAP_CHAR_LEN(SC_UNO_VBADOCOBJ), 0, &getCppuType((beans::PropertyValue*)0), beans::PropertyAttribute::READONLY, 0}, {MAP_CHAR_LEN(SC_UNO_CALCASSHOWN), PROP_UNO_CALCASSHOWN, &getBooleanCppuType(), 0, 0}, {MAP_CHAR_LEN(SC_UNONAME_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, {MAP_CHAR_LEN(SC_UNO_CJK_CLOCAL), 0, &getCppuType((lang::Locale*)0), 0, 0}, @@ -469,7 +465,6 @@ uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) SC_QUERYINTERFACE( view::XRenderable ) SC_QUERYINTERFACE( document::XLinkTargetSupplier ) SC_QUERYINTERFACE( beans::XPropertySet ) - SC_QUERYINTERFACE( script::vba::XCoreEventProcessor ) SC_QUERYINTERFACE( lang::XMultiServiceFactory ) SC_QUERYINTERFACE( lang::XServiceInfo ) SC_QUERYINTERFACE( util::XChangesNotifier ) @@ -1887,18 +1882,6 @@ uno::Any SAL_CALL ScModelObj::getPropertyValue( const rtl::OUString& aPropertyNa { aRet <<= pDocShell->GetDialogContainer(); } - else if ( aString.EqualsAscii( SC_UNO_VBADOCOBJ ) ) - { - // PropertyValue seems extreme because we store - // the model ( as the value member ) of the PropertyValue that is - // itself a property of the model ( the intention however is to - // store something like a Workbook object... but we don't do that ) - // yet - beans::PropertyValue aProp; - aProp.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ThisExcelDoc") ); - aProp.Value <<= pDocShell->GetModel(); - aRet <<= aProp; - } else if ( aString.EqualsAscii( SC_UNO_RUNTIMEUID ) ) { aRet <<= getRuntimeUID(); @@ -2072,38 +2055,6 @@ uno::Sequence SAL_CALL ScModelObj::getAvailableServiceNames() return concatServiceNames( aMyServices, aDrawServices ); } -// XCoreEventProcessor - -void SAL_CALL ScModelObj::processCoreVbaEvent( sal_Int32 nSlotId ) - throw (lang::IllegalArgumentException, script::provider::ScriptFrameworkErrorException, util::VetoException, uno::RuntimeException) -{ - using namespace ::com::sun::star::script::vba; - - sal_Int32 nVbaEventId = VBAEventId::NO_EVENT; - uno::Sequence< uno::Any > aArgs; - switch( nSlotId ) - { - case SID_SAVEDOC: - case SID_SAVEASDOC: - nVbaEventId = VBAEventId::WORKBOOK_BEFORESAVE; - aArgs.realloc( 1 ); - aArgs[ 0 ] <<= (nSlotId == SID_SAVEASDOC); - break; - case SID_PRINTDOC: - case SID_PRINTDOCDIRECT: - nVbaEventId = VBAEventId::WORKBOOK_BEFOREPRINT; - break; - default: - throw lang::IllegalArgumentException(); - } - - uno::Reference< XVBAEventProcessor > xEventProcessor( GetDocument()->GetVbaEventProcessor(), uno::UNO_QUERY ); - if( !xEventProcessor.is() ) - throw script::provider::ScriptFrameworkErrorException(); - - xEventProcessor->processVbaEvent( nVbaEventId, aArgs ); -} - // XServiceInfo rtl::OUString SAL_CALL ScModelObj::getImplementationName() throw(uno::RuntimeException) -- cgit v1.2.3 From 5e171284bb76b6fc12478ceeb6ce7da243d795b6 Mon Sep 17 00:00:00 2001 From: Daniel Rentz Date: Thu, 15 Jul 2010 14:30:44 +0200 Subject: mib17: #i112634# do not use an UNO interface to handle VBA BeforeSave and BeforePrint events --- .../sun/star/script/vba/XCoreEventProcessor.idl | 78 ---------------------- offapi/com/sun/star/script/vba/makefile.mk | 1 - 2 files changed, 79 deletions(-) delete mode 100755 offapi/com/sun/star/script/vba/XCoreEventProcessor.idl diff --git a/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl b/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl deleted file mode 100755 index 989b1f4039cb..000000000000 --- a/offapi/com/sun/star/script/vba/XCoreEventProcessor.idl +++ /dev/null @@ -1,78 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * 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 - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef __com_sun_star_script_vba_XCoreEventProcessor_idl__ -#define __com_sun_star_script_vba_XCoreEventProcessor_idl__ - -#include -#include -#include - -//============================================================================= - -module com { module sun { module star { module script { module vba { - -//============================================================================= - -/** Executes VBA event handlers based on a specific core model event. - */ -interface XCoreEventProcessor -{ - //------------------------------------------------------------------------- - - /** Executes a VBA compatible event handler for a core event. - - @param nSlotId - The implementation defined identifier of the core event. - - @throws IllegalArgumentException - if the passed slot identifier is not supported. - - @throws ScriptFrameworkErrorException - if the VBA event handler could not be invoked. Reasons may be, that - handling of VBA events is not enabled, that the VBA event handler - macro has not been found, or that the execution of the macro has - been aborted with an error. - - @throws VetoException - if the VBA event handler has indicated to veto the event. - **/ - void processCoreVbaEvent( [in] long nSlotId ) - raises (::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::script::provider::ScriptFrameworkErrorException, - ::com::sun::star::util::VetoException); - - //------------------------------------------------------------------------- -}; - -//============================================================================= - -}; }; }; }; }; - -//============================================================================= - -#endif diff --git a/offapi/com/sun/star/script/vba/makefile.mk b/offapi/com/sun/star/script/vba/makefile.mk index 857df4f9bf63..2cb93401ae00 100755 --- a/offapi/com/sun/star/script/vba/makefile.mk +++ b/offapi/com/sun/star/script/vba/makefile.mk @@ -42,7 +42,6 @@ IDLFILES=\ VBAEventProcessor.idl \ VBASpreadsheetEventProcessor.idl \ VBATextEventProcessor.idl \ - XCoreEventProcessor.idl \ XVBAEventProcessor.idl # ------------------------------------------------------------------ -- cgit v1.2.3 From 3ceb8dd77e9750449f20e01966b1b466741a922f Mon Sep 17 00:00:00 2001 From: Andreas Bregas Date: Fri, 16 Jul 2010 11:06:18 +0200 Subject: mib17: #162980# Force Broadcast in StepIS for SbxEmpty --- basic/source/runtime/step0.cxx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 1d9333ff7555..bdbb22678bf3 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -312,9 +312,21 @@ void SbiRuntime::StepIS() { SbxVariableRef refVar1 = PopVar(); SbxVariableRef refVar2 = PopVar(); - BOOL bRes = BOOL( - refVar1->GetType() == SbxOBJECT - && refVar2->GetType() == SbxOBJECT ); + + SbxDataType eType1 = refVar1->GetType(); + SbxDataType eType2 = refVar2->GetType(); + if ( eType1 == SbxEMPTY ) + { + refVar1->Broadcast( SBX_HINT_DATAWANTED ); + eType1 = refVar1->GetType(); + } + if ( eType2 == SbxEMPTY ) + { + refVar2->Broadcast( SBX_HINT_DATAWANTED ); + eType2 = refVar2->GetType(); + } + + BOOL bRes = BOOL( eType1 == SbxOBJECT && eType2 == SbxOBJECT ); if ( bVBAEnabled && !bRes ) Error( SbERR_INVALID_USAGE_OBJECT ); bRes = ( bRes && refVar1->GetObject() == refVar2->GetObject() ); -- cgit v1.2.3 From 98cdf3324314ebf7ee69605af2a8fc28be092528 Mon Sep 17 00:00:00 2001 From: "Eike Rathke [er]" Date: Fri, 16 Jul 2010 15:58:36 +0200 Subject: calc56: #i113139# various performance improvements for 1MB rows, especially with large hidden segments --- sc/inc/document.hxx | 1 + sc/inc/table.hxx | 46 +++---- sc/source/core/data/documen3.cxx | 83 ++++++++----- sc/source/core/data/document.cxx | 54 ++++++--- sc/source/core/data/fillinfo.cxx | 20 ++- sc/source/core/data/markdata.cxx | 60 ++++++--- sc/source/core/data/table2.cxx | 38 ++++-- sc/source/core/data/table5.cxx | 52 +++++--- sc/source/filter/xml/XMLStylesExportHelper.cxx | 27 ++++- sc/source/filter/xml/XMLStylesExportHelper.hxx | 1 + sc/source/filter/xml/xmlexprt.cxx | 7 +- sc/source/ui/inc/viewdata.hxx | 18 +++ sc/source/ui/undo/undoblk.cxx | 2 +- sc/source/ui/view/gridwin4.cxx | 12 +- sc/source/ui/view/output.cxx | 14 ++- sc/source/ui/view/viewdata.cxx | 161 +++++++++++++++++-------- 16 files changed, 398 insertions(+), 198 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index f7ae5e63f165..304a9d1df0f7 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -1276,6 +1276,7 @@ public: SC_DLLPUBLIC USHORT GetColWidth( SCCOL nCol, SCTAB nTab ) const; SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, bool bHiddenAsZero = true ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCTAB nTab, SCROW* pStartRow, SCROW* pEndRow, bool bHiddenAsZero = true ) const; SC_DLLPUBLIC ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab ) const; SCROW GetRowForHeight( SCTAB nTab, ULONG nHeight ) const; ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, SCTAB nTab, double fScale ) const; diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx index 78e5875b6879..5f42a2f37247 100644 --- a/sc/inc/table.hxx +++ b/sc/inc/table.hxx @@ -628,12 +628,12 @@ public: // nPPT fuer Test auf Veraenderung void SetManualHeight( SCROW nStartRow, SCROW nEndRow, BOOL bManual ); - USHORT GetColWidth( SCCOL nCol ); - SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ); - ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ); - ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ); - ULONG GetColOffset( SCCOL nCol ); - ULONG GetRowOffset( SCROW nRow ); + USHORT GetColWidth( SCCOL nCol ) const; + SC_DLLPUBLIC USHORT GetRowHeight( SCROW nRow, SCROW* pStartRow = NULL, SCROW* pEndRow = NULL, bool bHiddenAsZero = true ) const; + ULONG GetRowHeight( SCROW nStartRow, SCROW nEndRow ) const; + ULONG GetScaledRowHeight( SCROW nStartRow, SCROW nEndRow, double fScale ) const; + ULONG GetColOffset( SCCOL nCol ) const; + ULONG GetRowOffset( SCROW nRow ) const; /** * Get the last row such that the height of row 0 to the end row is as @@ -643,7 +643,7 @@ public: * * @return SCROW last row of the range within specified height. */ - SCROW GetRowForHeight(ULONG nHeight); + SCROW GetRowForHeight(ULONG nHeight) const; USHORT GetOriginalWidth( SCCOL nCol ) const; USHORT GetOriginalHeight( SCROW nRow ) const; @@ -711,33 +711,33 @@ public: ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::TablePageBreakData> GetRowBreakData() const; - bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); - bool RowHidden(SCROW nRow, SCROW& rLastRow); - bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow); - bool ColHidden(SCCOL nCol, SCCOL& rLastCol); - bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); + bool RowHidden(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const; + bool RowHidden(SCROW nRow, SCROW& rLastRow) const; + bool HasHiddenRows(SCROW nStartRow, SCROW nEndRow) const; + bool ColHidden(SCCOL nCol, SCCOL& rLastCol) const; + bool ColHidden(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const; void SetRowHidden(SCROW nStartRow, SCROW nEndRow, bool bHidden); void SetColHidden(SCCOL nStartCol, SCCOL nEndCol, bool bHidden); void CopyColHidden(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); void CopyRowHidden(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); void CopyRowHeight(ScTable& rSrcTable, SCROW nStartRow, SCROW nEndRow, SCROW nSrcOffset); - SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow); - SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow); - SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow); - sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow); + SCROW FirstVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow) const; + sal_uInt32 GetTotalRowHeight(SCROW nStartRow, SCROW nEndRow) const; - SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol); + SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const; - bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL); - bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL); - bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow); + bool RowFiltered(SCROW nRow, SCROW* pFirstRow = NULL, SCROW* pLastRow = NULL) const; + bool ColFiltered(SCCOL nCol, SCCOL* pFirstCol = NULL, SCCOL* pLastCol = NULL) const; + bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow) const; void CopyColFiltered(ScTable& rTable, SCCOL nStartCol, SCCOL nEndCol); void CopyRowFiltered(ScTable& rTable, SCROW nStartRow, SCROW nEndRow); void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, bool bFiltered); void SetColFiltered(SCCOL nStartCol, SCCOL nEndCol, bool bFiltered); - SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow); - SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow); - SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow); + SCROW FirstNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW LastNonFilteredRow(SCROW nStartRow, SCROW nEndRow) const; + SCROW CountNonFilteredRows(SCROW nStartRow, SCROW nEndRow) const; void SyncColRowFlags(); diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx index 1861988d78aa..29f59352695d 100644 --- a/sc/source/core/data/documen3.cxx +++ b/sc/source/core/data/documen3.cxx @@ -1546,6 +1546,48 @@ void ScDocument::ResetEmbedded() aEmbedRange = ScRange(); } + +/** Similar to ScViewData::AddPixelsWhile(), but add height twips and only + while result is less than nStopTwips. + */ +void lcl_AddTwipsWhile( long & rTwips, long nStopTwips, SCROW & rPosY, SCROW nEndRow, const ScTable * pTable ) +{ + SCROW nRow = rPosY; + bool bStop = false; + while (rTwips < nStopTwips && nRow <= nEndRow && !bStop) + { + SCROW nHeightEndRow; + USHORT nHeight = pTable->GetRowHeight( nRow, NULL, &nHeightEndRow); + if (nHeightEndRow > nEndRow) + nHeightEndRow = nEndRow; + if (!nHeight) + nRow = nHeightEndRow + 1; + else + { + SCROW nRows = nHeightEndRow - nRow + 1; + sal_Int64 nAdd = static_cast(nHeight) * nRows; + if (nAdd + rTwips >= nStopTwips) + { + sal_Int64 nDiff = nAdd + rTwips - nStopTwips; + nRows -= nDiff / nHeight; + nAdd = nHeight * nRows; + // We're looking for a value that satisfies loop condition. + if (nAdd + rTwips >= nStopTwips) + { + --nRows; + nAdd -= nHeight; + } + bStop = true; + } + rTwips += static_cast(nAdd); + nRow += nRows; + } + } + if (nRow > rPosY) + --nRow; + rPosY = nRow; +} + ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) { ScTable* pTable = pTab[nTab]; @@ -1602,43 +1644,18 @@ ScRange ScDocument::GetRange( SCTAB nTab, const Rectangle& rMMRect ) nTwips = (long) (aPosRect.Top() / HMM_PER_TWIPS); SCROW nY1 = 0; - bEnd = FALSE; - for (SCROW i = nY1; i <= MAXROW && !bEnd; ++i) - { - if (pTable->RowHidden(i)) - continue; - - nY1 = i; - nAdd = static_cast(pTable->GetRowHeight(i)); - if (nSize+nAdd <= nTwips+1 && nY1