diff -u -r ./old/sc/source/ui/vba/vbaapplication.cxx ./new/sc/source/ui/vba/vbaapplication.cxx --- ./old/sc/source/ui/vba/vbaapplication.cxx 2009-12-26 11:03:32.000000000 +0800 +++ ./new/sc/source/ui/vba/vbaapplication.cxx 2010-01-19 15:44:02.000000000 +0800 @@ -2,7 +2,7 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2008, 2010 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * @@ -140,6 +140,7 @@ ScVbaApplication::ScVbaApplication( const uno::Reference& xContext ): ScVbaApplication_BASE( xContext ), m_xCalculation( excel::XlCalculation::xlCalculationAutomatic ) { + m_bEnableEvents = sal_True; } ScVbaApplication::~ScVbaApplication() @@ -685,28 +686,27 @@ //VBA by minz@cn.ibm.com. Add Application.EnableEvents. void SAL_CALL -ScVbaApplication::setEnableEvents(sal_Bool /*bEnable*/) throw (uno::RuntimeException) +ScVbaApplication::setEnableEvents(sal_Bool bEnable) throw (uno::RuntimeException) { - //TODO. + m_bEnableEvents = bEnable; } sal_Bool SAL_CALL ScVbaApplication::getEnableEvents() throw (uno::RuntimeException) { - //TODO. - return sal_True; + return m_bEnableEvents; } -sal_Bool SAL_CALL -ScVbaApplication::getVisible() throw (uno::RuntimeException) -{ - sal_Bool bVisible = sal_True; - return bVisible; -} - -void SAL_CALL -ScVbaApplication::setVisible(sal_Bool bVisible) throw (uno::RuntimeException) -{ +sal_Bool SAL_CALL +ScVbaApplication::getVisible() throw (uno::RuntimeException) +{ + sal_Bool bVisible = sal_True; + return bVisible; +} + +void SAL_CALL +ScVbaApplication::setVisible(sal_Bool bVisible) throw (uno::RuntimeException) +{ } void SAL_CALL diff -u -r ./old/sc/source/ui/vba/vbaapplication.hxx ./new/sc/source/ui/vba/vbaapplication.hxx --- ./old/sc/source/ui/vba/vbaapplication.hxx 2009-12-26 11:03:32.000000000 +0800 +++ ./new/sc/source/ui/vba/vbaapplication.hxx 2010-01-19 15:44:34.000000000 +0800 @@ -2,7 +2,7 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2008 by Sun Microsystems, Inc. + * Copyright 2008, 2010 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * @@ -46,6 +46,7 @@ { private: sal_Int32 m_xCalculation; + sal_Bool m_bEnableEvents; rtl::OUString getOfficePath( const rtl::OUString& sPath ) throw ( css::uno::RuntimeException ); css::uno::Reference< ov::XFileSearch > m_xFileSearch; // protected: @@ -94,7 +95,7 @@ virtual sal_Bool SAL_CALL getEnableEvents() throw (css::uno::RuntimeException); virtual void SAL_CALL setEnableEvents( sal_Bool bEnable ) throw (css::uno::RuntimeException); - virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); + virtual sal_Bool SAL_CALL getVisible() throw (css::uno::RuntimeException); virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw (css::uno::RuntimeException); virtual double SAL_CALL CountA( const css::uno::Any& arg1 ) throw (css::uno::RuntimeException) ; diff -u -r ./old/sc/source/ui/vba/vbaeventshelper.cxx ./new/sc/source/ui/vba/vbaeventshelper.cxx --- ./old/sc/source/ui/vba/vbaeventshelper.cxx 2009-12-26 11:03:32.000000000 +0800 +++ ./new/sc/source/ui/vba/vbaeventshelper.cxx 2010-01-19 15:48:12.000000000 +0800 @@ -14,7 +14,7 @@ * * GNU Lesser General Public License Version 2.1 * ============================================= - * Copyright 2005 by Sun Microsystems, Inc. + * Copyright 2005, 2010 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or @@ -64,6 +64,8 @@ #include #include #include +#include +#include using namespace std; using namespace com::sun::star; @@ -843,8 +845,23 @@ sal_Bool SAL_CALL ScVbaEventsHelper::ProcessCompatibleVbaEvent( sal_Int32 nEventId, const uno::Sequence< uno::Any >& aArgs ) throw (uno::RuntimeException) { + // Get Application Object. + if ( !m_xApplication.is() ) + { + if ( pDocShell ) + { + uno::Any aVBAGlobals; + pDocShell->GetBasicManager()->GetGlobalUNOConstant( "VBAGlobals", aVBAGlobals ); + uno::Reference< ::ooo::vba::XHelperInterface > xHelperInterface( aVBAGlobals, uno::UNO_QUERY ); + if ( xHelperInterface.is() ) + { + m_xApplication = uno::Reference< ::ooo::vba::excel::XApplication >( xHelperInterface->Application(), uno::UNO_QUERY ); + } + } + } + SfxObjectShell* pShell = pDoc->GetDocumentShell(); - if( !pShell || mbIgnoreEvents || mbDocDisposed ) + if( !pShell || mbIgnoreEvents || ( m_xApplication.is() && !m_xApplication->getEnableEvents() ) ) return sal_False; // In order to better support "withevents" in the future, diff -u -r ./old/sc/source/ui/vba/vbaeventshelper.hxx ./new/sc/source/ui/vba/vbaeventshelper.hxx --- ./old/sc/source/ui/vba/vbaeventshelper.hxx 2009-12-26 11:03:32.000000000 +0800 +++ ./new/sc/source/ui/vba/vbaeventshelper.hxx 2010-01-19 15:45:48.000000000 +0800 @@ -14,7 +14,7 @@ * * GNU Lesser General Public License Version 2.1 * ============================================= - * Copyright 2005 by Sun Microsystems, Inc. + * Copyright 2005, 2010 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or @@ -43,6 +43,7 @@ #include #include #include +#include #include "excelvbahelper.hxx" #include @@ -61,6 +62,7 @@ css::uno::Reference< css::awt::XWindowListener > m_xVbaEventsListener; sal_Bool mbOpened; sal_Bool mbDocDisposed; + css::uno::Reference< ::ooo::vba::excel::XApplication > m_xApplication; String getSheetModuleName( SCTAB nTab ); css::uno::Any createWorkSheet( SfxObjectShell* pShell, SCTAB nTab );