diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2010-08-03 11:54:45 +0200 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2010-08-03 11:54:45 +0200 |
commit | 80200b927554fbf3ad79b89255accc87c0306263 (patch) | |
tree | 525ba70059ff8e6a50650051db4f8f2f1d0594ce | |
parent | c1bf1dc2a21319f57e24f0ca48ddb94f128e12bd (diff) | |
parent | f4ce9d6adedfc15c1c38e25fd498b9b8977d8e47 (diff) |
CWS-TOOLING: integrate CWS mib17ooo/OOO330_m3
-rw-r--r-- | sw/inc/doc.hxx | 11 | ||||
-rw-r--r--[-rwxr-xr-x] | sw/source/core/doc/doc.cxx | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | sw/source/filter/ww8/wrtww8.cxx | 2 | ||||
-rw-r--r-- | sw/source/ui/app/docsh2.cxx | 44 | ||||
-rw-r--r-- | sw/source/ui/vba/makefile.mk | 1 | ||||
-rw-r--r-- | sw/source/ui/vba/service.cxx | 9 | ||||
-rw-r--r-- | sw/source/ui/vba/vbabookmarks.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/vba/vbadocuments.cxx | 4 | ||||
-rwxr-xr-x | sw/source/ui/vba/vbaeventshelper.cxx | 108 | ||||
-rwxr-xr-x | sw/source/ui/vba/vbaeventshelper.hxx | 54 | ||||
-rw-r--r-- | sw/source/ui/vba/vbasections.cxx | 5 | ||||
-rw-r--r-- | sw/util/makefile.mk | 2 |
12 files changed, 254 insertions, 15 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx index ab413e18fd..14e25abd0a 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -79,6 +79,9 @@ class SwList; #include "comphelper/implementationreference.hxx" #include <com/sun/star/chart2/data/XDataProvider.hpp> #include <com/sun/star/linguistic2/XProofreadingIterator.hpp> +#ifdef FUTURE_VBA +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#endif #include <hash_map> #include <stringhash.hxx> @@ -405,7 +408,9 @@ class SW_DLLPUBLIC SwDoc : // table of forbidden characters of this document vos::ORef<SvxForbiddenCharactersTable> xForbiddenCharsTable; - +#ifdef FUTURE_VBA + com::sun::star::uno::Reference< com::sun::star::script::vba::XVBAEventProcessor > 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::XVBAEventProcessor > 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 index d25e4bd169..a414c8fb9b 100755..100644 --- a/sw/source/core/doc/doc.cxx +++ b/sw/source/core/doc/doc.cxx @@ -119,6 +119,9 @@ #include <osl/diagnose.h> #include <osl/interlck.h> +#ifdef FUTURE_VBA +#include <vbahelper/vbaaccesshelper.hxx> +#endif /* @@@MAINTAINABILITY-HORROR@@@ Probably unwanted dependency on SwDocShell @@ -2721,6 +2724,27 @@ void SwDoc::ChkCondColls() } } +#ifdef FUTURE_VBA +uno::Reference< script::vba::XVBAEventProcessor > +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.VBATextEventProcessor" , 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 f541d57b93..2cf3a421e2 100644..100755 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -3804,9 +3804,11 @@ void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer void MSWordExportBase::OutputStartNode( const SwStartNode & rNode) { +#if 0 #ifdef DEBUG ::std::clog << "<OutWW8_SwStartNode>" << dbg_out(&rNode) << ::std::endl; #endif +#endif ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode ); diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx index cea9d745d7..b0ae69370f 100644 --- a/sw/source/ui/app/docsh2.cxx +++ b/sw/source/ui/app/docsh2.cxx @@ -119,7 +119,10 @@ #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp> #include <com/sun/star/ui/dialogs/CommonFilePickerElementIds.hpp> #include "com/sun/star/ui/dialogs/TemplateDescription.hpp" - +#ifdef FUTURE_VBA +#include <com/sun/star/script/vba/XVBAEventProcessor.hpp> +#include <com/sun/star/script/vba/VBAEventId.hpp> +#endif #include <editeng/acorrcfg.hxx> #include <SwStyleNameMapper.hxx> @@ -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::XVBAEventProcessor >& xVbaEvents, const SfxHint& rHint ) +{ + using namespace com::sun::star::script::vba::VBAEventId; + 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::XVBAEventProcessor > 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::XVBAEventProcessor > xVbaEvents = pDoc->GetVbaEventProcessor(); + if( xVbaEvents.is() ) + { + using namespace com::sun::star::script::vba::VBAEventId; + 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 c09f813200..b6d0d79942 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 fee2847650..8200e323b8 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/vbabookmarks.cxx b/sw/source/ui/vba/vbabookmarks.cxx index 17d1741ce8..bccfeeff0e 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 dc8a592f9e..094dde4c0d 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/vbaeventshelper.cxx b/sw/source/ui/vba/vbaeventshelper.cxx new file mode 100755 index 0000000000..abe4abb6e7 --- /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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "vbaeventshelper.hxx" +#include <com/sun/star/script/vba/VBAEventId.hpp> +#include <vbahelper/helperdecl.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::script::vba::VBAEventId; +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_<SwVbaEventsHelper, sdecl::with_args<true> > serviceImpl; +extern sdecl::ServiceDecl const serviceDecl( + serviceImpl, + "SwVbaEventsHelper", + "com.sun.star.document.vba.VBATextEventProcessor" ); +} + +// ============================================================================ diff --git a/sw/source/ui/vba/vbaeventshelper.hxx b/sw/source/ui/vba/vbaeventshelper.hxx new file mode 100755 index 0000000000..af1c06c034 --- /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 + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef SW_VBAEVENTS_HXX +#define SW_VBAEVENTS_HXX + +#include <vbahelper/vbaeventshelperbase.hxx> + +// ============================================================================ + +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/source/ui/vba/vbasections.cxx b/sw/source/ui/vba/vbasections.cxx index 8e6cbee60e..6a4ae0e45e 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 ) ) ); } }; diff --git a/sw/util/makefile.mk b/sw/util/makefile.mk index 2907264d89..ce1419b340 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 |