diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-10-30 11:38:26 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-10-30 11:38:26 +0100 |
commit | 29275473927ad7944c34c22394ccd4ffea79ed36 (patch) | |
tree | 4863431c34aa5648320852f10d8d11f3c2c13136 | |
parent | 97b267dea22695eb9a0d12a97dcc3dbffe1ab419 (diff) |
further isolated the FormController implementation from the SVX code (not yet finally there, though)
20 files changed, 516 insertions, 486 deletions
diff --git a/svx/source/form/confirmdelete.cxx b/svx/source/form/confirmdelete.cxx index 819677c3f495..9bb4ab7ede49 100644 --- a/svx/source/form/confirmdelete.cxx +++ b/svx/source/form/confirmdelete.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: confirmdelete.cxx,v $ - * $Revision: 1.10 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/delayedevent.cxx b/svx/source/form/delayedevent.cxx index c6bce8efec98..a185ef04d389 100644 --- a/svx/source/form/delayedevent.cxx +++ b/svx/source/form/delayedevent.cxx @@ -5,10 +5,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * -* $RCSfile: delayedevent.cxx,v $ -* -* $Revision: 1.1.2.1 $ -* * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmcontrolbordermanager.cxx b/svx/source/form/fmcontrolbordermanager.cxx index 17bd10346302..5c6397662844 100644 --- a/svx/source/form/fmcontrolbordermanager.cxx +++ b/svx/source/form/fmcontrolbordermanager.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrolbordermanager.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmcontrollayout.cxx b/svx/source/form/fmcontrollayout.cxx index 92e987db796c..bc0e15cd9647 100644 --- a/svx/source/form/fmcontrollayout.cxx +++ b/svx/source/form/fmcontrollayout.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrollayout.cxx,v $ - * $Revision: 1.8 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx index 8d71cfb4ce24..0f6894cb5ac8 100644 --- a/svx/source/form/fmshimp.cxx +++ b/svx/source/form/fmshimp.cxx @@ -43,7 +43,6 @@ #include "fmundo.hxx" #include "fmurl.hxx" #include "fmvwimp.hxx" -#include "formcontrolling.hxx" #include "formtoolbars.hxx" #include "gridcols.hxx" #include "svditer.hxx" @@ -502,7 +501,6 @@ FmXFormShell::FmXFormShell( FmFormShell& _rShell, SfxViewFrame* _pViewFrame ) ,m_pTextShell( new ::svx::FmTextControlShell( _pViewFrame ) ) ,m_aActiveControllerFeatures( ::comphelper::getProcessServiceFactory(), this ) ,m_aNavControllerFeatures( ::comphelper::getProcessServiceFactory(), this ) - ,m_pExternalViewInterceptor( NULL ) ,m_eDocumentType( eUnknownDocumentType ) ,m_nLockSlotInvalidation( 0 ) ,m_bHadPropertyBrowserInDesignMode( sal_False ) @@ -797,14 +795,6 @@ void FmXFormShell::disposing() // are still uncommitted changes, the user explicitly wanted this. // 2002-11-11 - 104702 - fs@openoffice.org - // dispose our interceptor helpers - if (m_pExternalViewInterceptor) - { - m_pExternalViewInterceptor->dispose(); - m_pExternalViewInterceptor->release(); - m_pExternalViewInterceptor = NULL; - } - m_pTextShell->dispose(); m_xAttachedFrame = NULL; @@ -2941,7 +2931,7 @@ void FmXFormShell::startFiltering() { Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); if (xModeSelector.is()) - xModeSelector->setMode(FILTER_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); } } @@ -3048,7 +3038,7 @@ void FmXFormShell::stopFiltering(sal_Bool bSave) Reference< XModeSelector> xModeSelector(*j, UNO_QUERY); if (xModeSelector.is()) - xModeSelector->setMode(DATA_MODE); + xModeSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ); } if (bSave) // execute the filter { @@ -3564,28 +3554,8 @@ void FmXFormShell::CreateExternalView() xClear->dispatch(aClearURL, Sequence< PropertyValue>()); } - // interception of slots of the external view - if (m_pExternalViewInterceptor) - { // already intercepting ... - if (m_pExternalViewInterceptor->getIntercepted() != xExternalViewFrame) - { // ... but another frame -> create a new interceptor - m_pExternalViewInterceptor->dispose(); - m_pExternalViewInterceptor->release(); - m_pExternalViewInterceptor = NULL; - } - } - - if (!m_pExternalViewInterceptor) - { - Reference< ::com::sun::star::frame::XDispatchProviderInterception> xSupplier(xExternalViewFrame, UNO_QUERY); - ::rtl::OUString sInterceptorScheme = FMURL_FORMSLOTS_PREFIX; - sInterceptorScheme += ::rtl::OUString::createFromAscii("*"); -// m_pExternalViewInterceptor = new FmXDispatchInterceptorImpl(xSupplier, this, 1, Sequence< ::rtl::OUString >(&sInterceptorScheme, 1)); -// m_pExternalViewInterceptor->acquire(); - // TODO: re-implement this in a easier way than before: We need an interceptor at the xSupplier, which - // forwards all queryDispatch requests to the FormController instance for which this "external view" - // was triggered - } + // TODO: We need an interceptor at the xSupplier, which forwards all queryDispatch requests to the FormController + // instance for which this "external view" was triggered // get the dispatch interface of the frame so we can communicate (interceptable) with the controller Reference< ::com::sun::star::frame::XDispatchProvider> xCommLink(xExternalViewFrame, UNO_QUERY); diff --git a/svx/source/form/fmtools.cxx b/svx/source/form/fmtools.cxx index df8b51b8b82f..03dd6f97021d 100644 --- a/svx/source/form/fmtools.cxx +++ b/svx/source/form/fmtools.cxx @@ -884,176 +884,6 @@ sal_Int16 GridView2ModelPos(const Reference< ::com::sun::star::container::XInd return (sal_Int16)-1; } -//======================================================================== -//= FmXDispatchInterceptorImpl -//======================================================================== - -DBG_NAME(FmXDispatchInterceptorImpl); -//------------------------------------------------------------------------ -FmXDispatchInterceptorImpl::FmXDispatchInterceptorImpl( - const Reference< XDispatchProviderInterception >& _rxToIntercept, FmDispatchInterceptor* _pMaster, - sal_Int16 _nId, Sequence< ::rtl::OUString > _rInterceptedSchemes) - :FmXDispatchInterceptorImpl_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback) - ,m_xIntercepted(_rxToIntercept) - ,m_bListening(sal_False) - ,m_pMaster(_pMaster) - ,m_nId(_nId) - ,m_aInterceptedURLSchemes(_rInterceptedSchemes) -{ - DBG_CTOR(FmXDispatchInterceptorImpl,NULL); - - ::osl::MutexGuard aGuard(getAccessSafety()); - ::comphelper::increment(m_refCount); - if (_rxToIntercept.is()) - { - _rxToIntercept->registerDispatchProviderInterceptor((::com::sun::star::frame::XDispatchProviderInterceptor*)this); - // this should make us the top-level dispatch-provider for the component, via a call to our - // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill - Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY); - if (xInterceptedComponent.is()) - { - xInterceptedComponent->addEventListener(this); - m_bListening = sal_True; - } - } - ::comphelper::decrement(m_refCount); -} - -//------------------------------------------------------------------------ -FmXDispatchInterceptorImpl::~FmXDispatchInterceptorImpl() -{ - if (!rBHelper.bDisposed) - dispose(); - - DBG_DTOR(FmXDispatchInterceptorImpl,NULL); -} - -//------------------------------------------------------------------------------ -Sequence< sal_Int8 > SAL_CALL FmXDispatchInterceptorImpl::getImplementationId() throw(RuntimeException) -{ - static ::cppu::OImplementationId* pId = 0; - if (! pId) - { - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if (! pId) - { - static ::cppu::OImplementationId aId; - pId = &aId; - } - } - return pId->getImplementationId(); -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatch > SAL_CALL FmXDispatchInterceptorImpl::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - Reference< ::com::sun::star::frame::XDispatch> xResult; - // ask our 'real' interceptor - if (m_pMaster) - xResult = m_pMaster->interceptedQueryDispatch(m_nId, aURL, aTargetFrameName, nSearchFlags); - - // ask our slave provider - if (!xResult.is() && m_xSlaveDispatcher.is()) - xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); - - return xResult; -} - -//------------------------------------------------------------------------------ -Sequence< Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL -FmXDispatchInterceptorImpl::queryDispatches( const Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - Sequence< Reference< ::com::sun::star::frame::XDispatch> > aReturn(aDescripts.getLength()); - Reference< ::com::sun::star::frame::XDispatch>* pReturn = aReturn.getArray(); - const ::com::sun::star::frame::DispatchDescriptor* pDescripts = aDescripts.getConstArray(); - for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts) - { - *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); - } - return aReturn; -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL FmXDispatchInterceptorImpl::getSlaveDispatchProvider( ) throw(RuntimeException) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - return m_xSlaveDispatcher; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::setSlaveDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - m_xSlaveDispatcher = xNewDispatchProvider; -} - -//------------------------------------------------------------------------------ -Reference< ::com::sun::star::frame::XDispatchProvider> SAL_CALL FmXDispatchInterceptorImpl::getMasterDispatchProvider(void) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - return m_xMasterDispatcher; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::setMasterDispatchProvider(const Reference< ::com::sun::star::frame::XDispatchProvider>& xNewSupplier) throw( RuntimeException ) -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - m_xMasterDispatcher = xNewSupplier; -} - -//------------------------------------------------------------------------------ -Sequence< ::rtl::OUString > SAL_CALL FmXDispatchInterceptorImpl::getInterceptedURLs( ) throw(RuntimeException) -{ - return m_aInterceptedURLSchemes; -} - -//------------------------------------------------------------------------------ -void SAL_CALL FmXDispatchInterceptorImpl::disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException ) -{ - if (m_bListening) - { - Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); - if (Source.Source == xIntercepted) - ImplDetach(); - } -} - -//------------------------------------------------------------------------------ -void FmXDispatchInterceptorImpl::ImplDetach() -{ - ::osl::MutexGuard aGuard(getAccessSafety()); - OSL_ENSURE(m_bListening, "FmXDispatchInterceptorImpl::ImplDetach: invalid call!"); - - // deregister ourself from the interception component - Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); - if (xIntercepted.is()) - xIntercepted->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this)); - -// m_xIntercepted = Reference< XDispatchProviderInterception >(); - // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were - // responsible. As we hold the object with a weak reference only, this should be no problem. - // 88936 - 23.07.2001 - frank.schoenheit@sun.com - m_pMaster = NULL; - m_bListening = sal_False; -} - -//------------------------------------------------------------------------------ -void FmXDispatchInterceptorImpl::disposing() -{ - // remove ourself as event listener from the interception component - if (m_bListening) - { - Reference< ::com::sun::star::lang::XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY); - if (xInterceptedComponent.is()) - xInterceptedComponent->removeEventListener(static_cast<XEventListener*>(this)); - - // detach from the interception component - ImplDetach(); - } -} - //============================================================================== //============================================================================== diff --git a/svx/source/form/fmctrler.cxx b/svx/source/form/formcontroller.cxx index cc3855518889..bc50ee0de517 100644 --- a/svx/source/form/fmctrler.cxx +++ b/svx/source/form/formcontroller.cxx @@ -31,21 +31,16 @@ #include "confirmdelete.hxx" #include "fmcontrolbordermanager.hxx" #include "fmcontrollayout.hxx" -#include "fmctrler.hxx" -#include "fmdispatch.hxx" +#include "formcontroller.hxx" +#include "formfeaturedispatcher.hxx" #include "fmdocumentclassification.hxx" +#include "formcontrolling.hxx" #include "fmprop.hrc" +#include "svx/dialmgr.hxx" #include "fmresids.hrc" #include "fmservs.hxx" -#include "fmshimp.hxx" -#include "fmtools.hxx" #include "fmurl.hxx" -#include "svx/dialmgr.hxx" -#include "svx/fmshell.hxx" -#include "svx/fmview.hxx" -#include "svx/sdrpagewindow.hxx" -#include "svx/svdpagv.hxx" -#include "trace.hxx" +#include "fmtools.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/FocusChangeReason.hpp> @@ -69,6 +64,13 @@ #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> #include <com/sun/star/sdbc/ColumnValue.hpp> #include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/form/runtime/FormOperations.hpp> +#include <com/sun/star/form/runtime/FormFeature.hpp> +#include <com/sun/star/container/XContainer.hpp> +#include <com/sun/star/sdbcx/XColumnsSupplier.hpp> +#include <com/sun/star/util/XNumberFormatter.hpp> +#include <com/sun/star/sdb/SQLContext.hpp> +#include <com/sun/star/sdb/XColumn.hpp> /** === end UNO includes === **/ #include <comphelper/enumhelper.hxx> @@ -81,9 +83,6 @@ #include <comphelper/uno3.hxx> #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/typeprovider.hxx> -#include <sfx2/bindings.hxx> -#include <sfx2/viewfrm.hxx> -#include <sfx2/viewsh.hxx> #include <toolkit/controls/unocontrol.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <tools/debug.hxx> @@ -91,6 +90,7 @@ #include <tools/shl.hxx> #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> +#include <vos/mutex.hxx> #include <rtl/logfile.hxx> #include <algorithm> @@ -121,7 +121,6 @@ namespace svxform using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::uno::UNO_SET_THROW; using ::com::sun::star::uno::UNO_QUERY_THROW; - using ::com::sun::star::sdbcx::XColumnsSupplier; using ::com::sun::star::container::XIndexAccess; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::XInterface; @@ -167,7 +166,6 @@ namespace svxform using ::com::sun::star::form::validation::XValidatableFormComponent; using ::com::sun::star::form::XLoadable; using ::com::sun::star::script::XEventAttacherManager; - using ::com::sun::star::container::XContainer; using ::com::sun::star::form::XBoundControl; using ::com::sun::star::beans::XPropertyChangeListener; using ::com::sun::star::awt::TextEvent; @@ -202,11 +200,14 @@ namespace svxform using ::com::sun::star::frame::FeatureStateEvent; using ::com::sun::star::form::runtime::XFormControllerContext; using ::com::sun::star::task::XInteractionHandler; + using ::com::sun::star::form::runtime::FormOperations; + using ::com::sun::star::container::XContainer; /** === end UNO using === **/ namespace ColumnValue = ::com::sun::star::sdbc::ColumnValue; namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute; namespace FocusChangeReason = ::com::sun::star::awt::FocusChangeReason; namespace RowChangeAction = ::com::sun::star::sdb::RowChangeAction; + namespace FormFeature = ::com::sun::star::form::runtime::FormFeature; //============================================================================== // ColumnInfo @@ -528,7 +529,7 @@ struct UpdateAllListeners : public ::std::unary_function< Reference< XDispatch > IMPL_LINK( FormController, OnInvalidateFeatures, void*, /*_pNotInterestedInThisParam*/ ) { ::osl::MutexGuard aGuard( m_aMutex ); - for ( ::std::set< sal_Int32 >::const_iterator aLoop = m_aInvalidFeatures.begin(); + for ( ::std::set< sal_Int16 >::const_iterator aLoop = m_aInvalidFeatures.begin(); aLoop != m_aInvalidFeatures.end(); ++aLoop ) @@ -551,8 +552,8 @@ DBG_NAME( FormController ) FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ) :FormController_BASE( m_aMutex ) ,OPropertySetHelper( FormController_BASE::rBHelper ) - ,OSQLParserClient(_rxORB) - ,m_xORB(_rxORB) + ,OSQLParserClient( _rxORB ) + ,m_aContext( _rxORB ) ,m_aActivateListeners(m_aMutex) ,m_aModifyListeners(m_aMutex) ,m_aErrorListeners(m_aMutex) @@ -561,8 +562,8 @@ FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB ,m_aParameterListeners(m_aMutex) ,m_aFilterListeners(m_aMutex) ,m_pControlBorderManager( new ::svxform::ControlBorderManager ) - ,m_aControllerFeatures( _rxORB, this ) - ,m_aMode( DATA_MODE ) + ,m_xFormOperations() + ,m_aMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ) ,m_aLoadEvent( LINK( this, FormController, OnLoad ) ) ,m_aToggleEvent( LINK( this, FormController, OnToggleAutoFields ) ) ,m_aActivationEvent( LINK( this, FormController, OnActivated ) ) @@ -589,7 +590,7 @@ FormController::FormController(const Reference< XMultiServiceFactory > & _rxORB { { m_xAggregate = Reference< XAggregation >( - m_xORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.awt.TabController" ) ), + m_aContext.createComponent( "com.sun.star.awt.TabController" ), UNO_QUERY ); DBG_ASSERT( m_xAggregate.is(), "FormController::FormController : could not create my aggregate !" ); @@ -628,6 +629,10 @@ FormController::~FormController() disposeAllFeaturesAndDispatchers(); + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + // Freigeben der Aggregation if ( m_xAggregate.is() ) { @@ -831,9 +836,8 @@ void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) cons if (xConnection.is()) { Reference< XDatabaseMetaData> xMetaData(xConnection->getMetaData()); - Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); - Reference< XNumberFormatter> xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats( xConnection, sal_True ) ); + Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY_THROW ); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); Reference< XColumnsSupplier> xSupplyCols(m_xModelAsIndex, UNO_QUERY); @@ -890,7 +894,7 @@ void FormController::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) cons break; case FM_ATTR_FORM_OPERATIONS: - rValue <<= m_aControllerFeatures->getFormOperations(); + rValue <<= m_xFormOperations; break; } } @@ -1185,7 +1189,6 @@ void FormController::disposeAllFeaturesAndDispatchers() SAL_THROW(()) } } m_aFeatureDispatchers.clear(); - m_aControllerFeatures.dispose(); } //----------------------------------------------------------------------------- @@ -1243,6 +1246,10 @@ void FormController::disposing(void) disposeAllFeaturesAndDispatchers(); + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + if (m_bDBConnection) unload(); @@ -1252,7 +1259,6 @@ void FormController::disposing(void) ::comphelper::disposeComponent( m_xComposer ); - m_xORB = NULL; m_bDBConnection = sal_False; } @@ -1462,7 +1468,7 @@ void FormController::toggleAutoFields(sal_Bool bAutoFields) { ::rtl::OUString sServiceName; OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); - Reference< XControl > xNewControl( m_xORB->createInstance( sServiceName ), UNO_QUERY ); + Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY ); replaceControl( xControl, xNewControl ); } } @@ -1656,8 +1662,6 @@ sal_Bool FormController::determineLockState() const //------------------------------------------------------------------------------ void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) { - TRACE_RANGE( "FormController::focusGained" ); - // SYNCHRONIZED --> ::osl::ClearableMutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); @@ -1725,22 +1729,33 @@ void FormController::focusGained(const FocusEvent& e) throw( RuntimeException ) if (!m_bFiltering && m_bCycle && (e.FocusFlags & FocusChangeReason::AROUND) && m_xCurrentControl.is()) { - if ( e.FocusFlags & FocusChangeReason::FORWARD ) + SQLErrorEvent aErrorEvent; + OSL_ENSURE( m_xFormOperations.is(), "FormController::focusGained: hmm?" ); + // should have been created in setModel + try { - if ( m_aControllerFeatures->isEnabled( SID_FM_RECORD_NEXT ) ) - m_aControllerFeatures->moveRight(); + if ( e.FocusFlags & FocusChangeReason::FORWARD ) + { + if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToNext ) ) + m_xFormOperations->execute( FormFeature::MoveToNext ); + } + else // backward + { + if ( m_xFormOperations.is() && m_xFormOperations->isEnabled( FormFeature::MoveToPrevious ) ) + m_xFormOperations->execute( FormFeature::MoveToPrevious ); + } } - else // backward + catch ( const Exception& ) { - if ( m_aControllerFeatures->isEnabled( SID_FM_RECORD_PREV ) ) - m_aControllerFeatures->moveLeft(); + // don't handle this any further. That's an ... admissible error. + DBG_UNHANDLED_EXCEPTION(); } } } // Immer noch ein und dasselbe Control - if ( (m_xActiveControl.get() == xControl.get()) - && (xControl.get() == m_xCurrentControl.get()) + if ( ( m_xActiveControl == xControl ) + && ( xControl == m_xCurrentControl ) ) { DBG_ASSERT(m_xCurrentControl.is(), "Kein CurrentControl selektiert"); @@ -1885,10 +1900,15 @@ void FormController::setModel(const Reference< XTabControllerModel > & Model) th Reference< XDatabaseParameterBroadcaster > xParamBroadcaster(m_xModelAsIndex, UNO_QUERY); if (xParamBroadcaster.is()) xParamBroadcaster->removeParameterListener(this); + } disposeAllFeaturesAndDispatchers(); + if ( m_xFormOperations.is() ) + m_xFormOperations->dispose(); + m_xFormOperations.clear(); + // set the new model wait for the load event if (m_xTabController.is()) m_xTabController->setModel(Model); @@ -1904,7 +1924,9 @@ void FormController::setModel(const Reference< XTabControllerModel > & Model) th if (m_xModelAsIndex.is()) { - m_aControllerFeatures.assign( this ); + // re-create m_xFormOperations + m_xFormOperations.set( FormOperations::createWithFormController( m_aContext.getUNOContext(), this ), UNO_SET_THROW ); + m_xFormOperations->setFeatureInvalidation( this ); // adding load and ui interaction listeners Reference< XLoadable > xForm(Model, UNO_QUERY); @@ -2971,7 +2993,7 @@ Reference< XFormOperations > SAL_CALL FormController::getFormOperations() throw ::osl::MutexGuard aGuard( m_aMutex ); impl_checkDisposed_throw(); - return m_aControllerFeatures->getFormOperations(); + return m_xFormOperations; } //------------------------------------------------------------------------------ @@ -3125,11 +3147,10 @@ void FormController::setFilter(::std::vector<FmFieldInfo>& rFieldInfos) // need to parse criteria localized OStaticDataAccessTools aStaticTools; Reference< XNumberFormatsSupplier> xFormatSupplier( aStaticTools.getNumberFormats(xConnection, sal_True)); - Reference< XNumberFormatter> xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + Reference< XNumberFormatter> xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY ); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); Locale aAppLocale = Application::GetSettings().GetUILocale(); - LocaleDataWrapper aLocaleWrapper(m_xORB,aAppLocale); + LocaleDataWrapper aLocaleWrapper( m_aContext.getLegacyServiceFactory(), aAppLocale ); // retrieving the filter const Sequence < PropertyValue >* pRow = aFilterRows.getConstArray(); @@ -3271,8 +3292,7 @@ void FormController::startFiltering() // the control we have to activate after replacement Reference< XDatabaseMetaData > xMetaData(xConnection->getMetaData()); Reference< XNumberFormatsSupplier > xFormatSupplier = aStaticTools.getNumberFormats(xConnection, sal_True); - Reference< XNumberFormatter > xFormatter(m_xORB - ->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")), UNO_QUERY); + Reference< XNumberFormatter > xFormatter( m_aContext.createComponent( "com.sun.star.util.NumberFormatter" ), UNO_QUERY ); xFormatter->attachNumberFormatsSupplier(xFormatSupplier); // structure for storing the field info @@ -3290,7 +3310,7 @@ void FormController::startFiltering() Reference< XModeSelector > xSelector(xControl, UNO_QUERY); if (xSelector.is()) { - xSelector->setMode(FILTER_MODE); + xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) ); // listening for new controls of the selector Reference< XContainer > xContainer(xSelector, UNO_QUERY); @@ -3350,10 +3370,7 @@ void FormController::startFiltering() aCreationArgs[ 1 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "NumberFormatter" ), makeAny( xFormatter ) ); aCreationArgs[ 2 ] <<= NamedValue( ::rtl::OUString::createFromAscii( "ControlModel" ), makeAny( xModel ) ); Reference< XControl > xFilterControl( - m_xORB->createInstanceWithArguments( - ::rtl::OUString::createFromAscii( "com.sun.star.form.control.FilterControl" ), - aCreationArgs - ), + m_aContext.createComponentWithArguments( "com.sun.star.form.control.FilterControl", aCreationArgs ), UNO_QUERY ); DBG_ASSERT( xFilterControl.is(), "FormController::startFiltering: could not create a filter control!" ); @@ -3423,7 +3440,7 @@ void FormController::stopFiltering() Reference< XModeSelector > xSelector(xControl, UNO_QUERY); if (xSelector.is()) { - xSelector->setMode(DATA_MODE); + xSelector->setMode( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) ); // listening for new controls of the selector Reference< XContainer > xContainer(xSelector, UNO_QUERY); @@ -3447,7 +3464,7 @@ void FormController::stopFiltering() { ::rtl::OUString sServiceName; OSL_VERIFY( xSet->getPropertyValue( FM_PROP_DEFAULTCONTROL ) >>= sServiceName ); - Reference< XControl > xNewControl( m_xORB->createInstance( sServiceName ), UNO_QUERY ); + Reference< XControl > xNewControl( m_aContext.createComponent( sServiceName ), UNO_QUERY ); replaceControl( xControl, xNewControl ); } } @@ -3488,7 +3505,7 @@ void FormController::setMode(const ::rtl::OUString& Mode) throw( NoSupportExcept m_aMode = Mode; - if (Mode == FILTER_MODE) + if ( Mode.equalsAscii( "FilterMode" ) ) startFiltering(); else stopFiltering(); @@ -3522,8 +3539,8 @@ Sequence< ::rtl::OUString > SAL_CALL FormController::getSupportedModes(void) thr { aModes.realloc(2); ::rtl::OUString* pModes = aModes.getArray(); - pModes[0] = DATA_MODE; - pModes[1] = FILTER_MODE; + pModes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ); + pModes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ); } return aModes; } @@ -4035,12 +4052,12 @@ sal_Bool SAL_CALL FormController::confirmDelete(const RowChangeEvent& aEvent) th } //------------------------------------------------------------------------------ -void FormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ) +void SAL_CALL FormController::invalidateFeatures( const Sequence< ::sal_Int16 >& _Features ) throw (RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); // for now, just copy the ids of the features, because .... - ::std::copy( _rFeatures.begin(), _rFeatures.end(), - ::std::insert_iterator< ::std::set< sal_Int32 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() ) + ::std::copy( _Features.getConstArray(), _Features.getConstArray() + _Features.getLength(), + ::std::insert_iterator< ::std::set< sal_Int16 > >( m_aInvalidFeatures, m_aInvalidFeatures.begin() ) ); // ... we will do the real invalidation asynchronously @@ -4049,8 +4066,26 @@ void FormController::invalidateFeatures( const ::std::vector< sal_Int32 >& _rFea } //------------------------------------------------------------------------------ +void SAL_CALL FormController::invalidateAllFeatures( ) throw (RuntimeException) +{ + ::osl::ClearableMutexGuard aGuard( m_aMutex ); + + Sequence< sal_Int16 > aInterceptedFeatures( m_aFeatureDispatchers.size() ); + ::std::transform( + m_aFeatureDispatchers.begin(), + m_aFeatureDispatchers.end(), + aInterceptedFeatures.getArray(), + ::std::select1st< DispatcherContainer::value_type >() + ); + + aGuard.clear(); + if ( aInterceptedFeatures.getLength() ) + invalidateFeatures( aInterceptedFeatures ); +} + +//------------------------------------------------------------------------------ Reference< XDispatch > -FormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL, +FormController::interceptedQueryDispatch( const URL& aURL, const ::rtl::OUString& /*aTargetFrameName*/, sal_Int32 /*nSearchFlags*/) throw( RuntimeException ) { @@ -4065,18 +4100,19 @@ FormController::interceptedQueryDispatch(sal_uInt16 /*_nId*/, const URL& aURL, xReturn = static_cast< XDispatch* >( this ); // dispatches of FormSlot-URLs we have to translate - if ( !xReturn.is() && m_aControllerFeatures.isAssigned() ) + if ( !xReturn.is() && m_xFormOperations.is() ) { // find the slot id which corresponds to the URL - sal_Int32 nFeatureId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main ); - if ( nFeatureId > 0 ) + sal_Int32 nFeatureSlotId = ::svx::FeatureSlotTranslation::getControllerFeatureSlotIdForURL( aURL.Main ); + sal_Int16 nFormFeature = ( nFeatureSlotId != -1 ) ? ::svx::FeatureSlotTranslation::getFormFeatureForSlotId( nFeatureSlotId ) : -1; + if ( nFormFeature > 0 ) { // get the dispatcher for this feature, create if necessary - DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFeatureId ); + DispatcherContainer::const_iterator aDispatcherPos = m_aFeatureDispatchers.find( nFormFeature ); if ( aDispatcherPos == m_aFeatureDispatchers.end() ) { aDispatcherPos = m_aFeatureDispatchers.insert( - DispatcherContainer::value_type( nFeatureId, new ::svx::OSingleFeatureDispatcher( aURL, nFeatureId, *m_aControllerFeatures, m_aMutex ) ) + DispatcherContainer::value_type( nFormFeature, new ::svx::OSingleFeatureDispatcher( aURL, nFormFeature, m_xFormOperations, m_aMutex ) ) ).first; } @@ -4171,12 +4207,11 @@ Reference< XDispatchProviderInterceptor > FormController::createInterceptor(con } #endif - ::rtl::OUString sInterceptorScheme(RTL_CONSTASCII_USTRINGPARAM("*")); - FmXDispatchInterceptorImpl* pInterceptor = new FmXDispatchInterceptorImpl(_xInterception, this, 0, Sequence< ::rtl::OUString >(&sInterceptorScheme, 1)); + DispatchInterceptionMultiplexer* pInterceptor = new DispatchInterceptionMultiplexer( _xInterception, this ); pInterceptor->acquire(); - m_aControlDispatchInterceptors.insert(m_aControlDispatchInterceptors.end(), pInterceptor); + m_aControlDispatchInterceptors.insert( m_aControlDispatchInterceptors.end(), pInterceptor ); - return (XDispatchProviderInterceptor*)pInterceptor; + return pInterceptor; } //------------------------------------------------------------------------------ @@ -4187,10 +4222,8 @@ bool FormController::ensureInteractionHandler() if ( m_bAttemptedHandlerCreation ) return false; m_bAttemptedHandlerCreation = true; - if ( !m_xORB.is() ) - return false; - m_xInteractionHandler.set( m_xORB->createInstance( SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); + m_xInteractionHandler.set( m_aContext.createComponent( (::rtl::OUString)SRV_SDB_INTERACTION_HANDLER ), UNO_QUERY ); OSL_ENSURE( m_xInteractionHandler.is(), "FormController::ensureInteractionHandler: could not create an interaction handler!" ); return m_xInteractionHandler.is(); } @@ -4223,7 +4256,7 @@ void FormController::deleteInterceptor(const Reference< XDispatchProviderInterce } // log off the interception from it's interception object - FmXDispatchInterceptorImpl* pInterceptorImpl = *aIter; + DispatchInterceptionMultiplexer* pInterceptorImpl = *aIter; pInterceptorImpl->dispose(); pInterceptorImpl->release(); @@ -4234,12 +4267,12 @@ void FormController::deleteInterceptor(const Reference< XDispatchProviderInterce //-------------------------------------------------------------------- void FormController::implInvalidateCurrentControlDependentFeatures() { - ::std::vector< sal_Int32 > aCurrentControlDependentFeatures; + Sequence< sal_Int16 > aCurrentControlDependentFeatures(4); - aCurrentControlDependentFeatures.push_back( SID_FM_SORTUP ); - aCurrentControlDependentFeatures.push_back( SID_FM_SORTDOWN ); - aCurrentControlDependentFeatures.push_back( SID_FM_AUTOFILTER ); - aCurrentControlDependentFeatures.push_back( SID_FM_REFRESH_FORM_CONTROL ); + aCurrentControlDependentFeatures[0] = FormFeature::SortAscending; + aCurrentControlDependentFeatures[1] = FormFeature::SortDescending; + aCurrentControlDependentFeatures[2] = FormFeature::AutoFilter; + aCurrentControlDependentFeatures[3] = FormFeature::RefreshCurrentControl; invalidateFeatures( aCurrentControlDependentFeatures ); } diff --git a/svx/source/form/formdispatchinterceptor.cxx b/svx/source/form/formdispatchinterceptor.cxx new file mode 100644 index 000000000000..903d27d6e650 --- /dev/null +++ b/svx/source/form/formdispatchinterceptor.cxx @@ -0,0 +1,213 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svx.hxx" + +#include "formdispatchinterceptor.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +#include <tools/debug.hxx> + +//........................................................................ +namespace svxform +{ +//........................................................................ + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::frame::XDispatchProviderInterception; + using ::com::sun::star::frame::XDispatchProviderInterceptor; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::util::URL; + using ::com::sun::star::frame::XDispatch; + using ::com::sun::star::frame::DispatchDescriptor; + using ::com::sun::star::frame::XDispatchProvider; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //======================================================================== + //= DispatchInterceptionMultiplexer + //======================================================================== + + DBG_NAME(DispatchInterceptionMultiplexer); + //------------------------------------------------------------------------ + DispatchInterceptionMultiplexer::DispatchInterceptionMultiplexer( + const Reference< XDispatchProviderInterception >& _rxToIntercept, DispatchInterceptor* _pMaster ) + :DispatchInterceptionMultiplexer_BASE(_pMaster && _pMaster->getInterceptorMutex() ? *_pMaster->getInterceptorMutex() : m_aFallback) + ,m_aFallback() + ,m_pMutex( _pMaster && _pMaster->getInterceptorMutex() ? _pMaster->getInterceptorMutex() : &m_aFallback ) + ,m_xIntercepted(_rxToIntercept) + ,m_bListening(sal_False) + ,m_pMaster(_pMaster) + { + DBG_CTOR(DispatchInterceptionMultiplexer,NULL); + + ::osl::MutexGuard aGuard( *m_pMutex ); + ::comphelper::increment(m_refCount); + if (_rxToIntercept.is()) + { + _rxToIntercept->registerDispatchProviderInterceptor((XDispatchProviderInterceptor*)this); + // this should make us the top-level dispatch-provider for the component, via a call to our + // setDispatchProvider we should have got an fallback for requests we (i.e. our master) cannot fullfill + Reference< XComponent> xInterceptedComponent(_rxToIntercept, UNO_QUERY); + if (xInterceptedComponent.is()) + { + xInterceptedComponent->addEventListener(this); + m_bListening = sal_True; + } + } + ::comphelper::decrement(m_refCount); + } + + //------------------------------------------------------------------------ + DispatchInterceptionMultiplexer::~DispatchInterceptionMultiplexer() + { + if (!rBHelper.bDisposed) + dispose(); + + DBG_DTOR(DispatchInterceptionMultiplexer,NULL); + } + + //------------------------------------------------------------------------------ + Reference< XDispatch > SAL_CALL DispatchInterceptionMultiplexer::queryDispatch( const URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + Reference< XDispatch> xResult; + // ask our 'real' interceptor + if (m_pMaster) + xResult = m_pMaster->interceptedQueryDispatch( aURL, aTargetFrameName, nSearchFlags); + + // ask our slave provider + if (!xResult.is() && m_xSlaveDispatcher.is()) + xResult = m_xSlaveDispatcher->queryDispatch(aURL, aTargetFrameName, nSearchFlags); + + return xResult; + } + + //------------------------------------------------------------------------------ + Sequence< Reference< XDispatch > > SAL_CALL + DispatchInterceptionMultiplexer::queryDispatches( const Sequence< DispatchDescriptor >& aDescripts ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + Sequence< Reference< XDispatch> > aReturn(aDescripts.getLength()); + Reference< XDispatch>* pReturn = aReturn.getArray(); + const DispatchDescriptor* pDescripts = aDescripts.getConstArray(); + for (sal_Int16 i=0; i<aDescripts.getLength(); ++i, ++pReturn, ++pDescripts) + { + *pReturn = queryDispatch(pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags); + } + return aReturn; + } + + //------------------------------------------------------------------------------ + Reference< XDispatchProvider > SAL_CALL DispatchInterceptionMultiplexer::getSlaveDispatchProvider( ) throw(RuntimeException) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + return m_xSlaveDispatcher; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::setSlaveDispatchProvider(const Reference< XDispatchProvider>& xNewDispatchProvider) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + m_xSlaveDispatcher = xNewDispatchProvider; + } + + //------------------------------------------------------------------------------ + Reference< XDispatchProvider> SAL_CALL DispatchInterceptionMultiplexer::getMasterDispatchProvider(void) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + return m_xMasterDispatcher; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::setMasterDispatchProvider(const Reference< XDispatchProvider>& xNewSupplier) throw( RuntimeException ) + { + ::osl::MutexGuard aGuard( *m_pMutex ); + m_xMasterDispatcher = xNewSupplier; + } + + //------------------------------------------------------------------------------ + void SAL_CALL DispatchInterceptionMultiplexer::disposing(const EventObject& Source) throw( RuntimeException ) + { + if (m_bListening) + { + Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); + if (Source.Source == xIntercepted) + ImplDetach(); + } + } + + //------------------------------------------------------------------------------ + void DispatchInterceptionMultiplexer::ImplDetach() + { + ::osl::MutexGuard aGuard( *m_pMutex ); + OSL_ENSURE(m_bListening, "DispatchInterceptionMultiplexer::ImplDetach: invalid call!"); + + // deregister ourself from the interception component + Reference< XDispatchProviderInterception > xIntercepted(m_xIntercepted.get(), UNO_QUERY); + if (xIntercepted.is()) + xIntercepted->releaseDispatchProviderInterceptor(static_cast<XDispatchProviderInterceptor*>(this)); + + // m_xIntercepted = Reference< XDispatchProviderInterception >(); + // Don't reset m_xIntercepted: It may be needed by our owner to check for which object we were + // responsible. As we hold the object with a weak reference only, this should be no problem. + // 88936 - 23.07.2001 - frank.schoenheit@sun.com + m_pMaster = NULL; + m_pMutex = &m_aFallback; + m_bListening = sal_False; + } + + //------------------------------------------------------------------------------ + void DispatchInterceptionMultiplexer::disposing() + { + // remove ourself as event listener from the interception component + if (m_bListening) + { + Reference< XComponent> xInterceptedComponent(m_xIntercepted.get(), UNO_QUERY); + if (xInterceptedComponent.is()) + xInterceptedComponent->removeEventListener(static_cast<XEventListener*>(this)); + + // detach from the interception component + ImplDetach(); + } + } + +//........................................................................ +} // namespace svxform +//........................................................................ diff --git a/svx/source/form/fmdispatch.cxx b/svx/source/form/formfeaturedispatcher.cxx index 154063409bef..82ca17812562 100644 --- a/svx/source/form/fmdispatch.cxx +++ b/svx/source/form/formfeaturedispatcher.cxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmdispatch.cxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -30,8 +27,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_svx.hxx" -#include "fmdispatch.hxx" -#include "formcontrolling.hxx" + +#include "formfeaturedispatcher.hxx" + +#include <comphelper/namedvaluecollection.hxx> +#include <tools/diagnose_ex.h> //........................................................................ namespace svx @@ -49,13 +49,13 @@ namespace svx //= OSingleFeatureDispatcher //==================================================================== //-------------------------------------------------------------------- - OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, sal_Int32 _nFeatureId, - const FormControllerHelper& _rController, ::osl::Mutex& _rMutex ) + OSingleFeatureDispatcher::OSingleFeatureDispatcher( const URL& _rFeatureURL, const sal_Int16 _nFormFeature, + const Reference< XFormOperations >& _rxFormOperations, ::osl::Mutex& _rMutex ) :m_rMutex( _rMutex ) ,m_aStatusListeners( _rMutex ) - ,m_rController( _rController ) + ,m_xFormOperations( _rxFormOperations ) ,m_aFeatureURL( _rFeatureURL ) - ,m_nFeatureId( _nFeatureId ) + ,m_nFormFeature( _nFormFeature ) ,m_bLastKnownEnabled( sal_False ) ,m_bDisposed( sal_False ) { @@ -82,10 +82,9 @@ namespace svx //-------------------------------------------------------------------- void OSingleFeatureDispatcher::getUnoState( FeatureStateEvent& /* [out] */ _rState ) const { - FeatureState aState; _rState.Source = *const_cast< OSingleFeatureDispatcher* >( this ); - m_rController.getState( m_nFeatureId, aState ); + FeatureState aState( m_xFormOperations->getState( m_nFormFeature ) ); _rState.FeatureURL = m_aFeatureURL; _rState.IsEnabled = aState.Enabled; @@ -161,21 +160,34 @@ namespace svx OSL_ENSURE( _rURL.Complete == m_aFeatureURL.Complete, "OSingleFeatureDispatcher::dispatch: not responsible for this URL!" ); (void)_rURL; - if ( m_rController.isEnabled( m_nFeatureId ) ) - { - // release our mutex before executing the slot? - sal_Int32 nFeatureId( m_nFeatureId ); - aGuard.clear(); + if ( !m_xFormOperations->isEnabled( m_nFormFeature ) ) + return; + // release our mutex before executing the command + sal_Int16 nFormFeature( m_nFormFeature ); + Reference< XFormOperations > xFormOperations( m_xFormOperations ); + aGuard.clear(); + + try + { if ( !_rArguments.getLength() ) { - m_rController.execute( nFeatureId ); + xFormOperations->execute( nFormFeature ); } else { // at the moment we only support one parameter - m_rController.execute( nFeatureId, _rArguments[0].Name, _rArguments[0].Value ); + ::comphelper::NamedValueCollection aArgs( _rArguments ); + xFormOperations->executeWithArguments( nFormFeature, aArgs.getNamedValues() ); } } + catch( const RuntimeException& ) + { + throw; + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } //-------------------------------------------------------------------- diff --git a/svx/source/form/makefile.mk b/svx/source/form/makefile.mk index fc6963d22b74..3c86a36c2685 100644 --- a/svx/source/form/makefile.mk +++ b/svx/source/form/makefile.mk @@ -75,7 +75,7 @@ LIB1OBJFILES= \ $(SLO)$/navigatortree.obj \ $(SLO)$/navigatortreemodel.obj \ $(SLO)$/fmexpl.obj \ - $(SLO)$/fmctrler.obj \ + $(SLO)$/formcontroller.obj \ $(SLO)$/fmpgeimp.obj \ $(SLO)$/fmvwimp.obj \ $(SLO)$/fmdpage.obj \ @@ -91,7 +91,8 @@ LIB1OBJFILES= \ $(SLO)$/fmview.obj \ $(SLO)$/sdbdatacolumn.obj \ $(SLO)$/formcontrolling.obj \ - $(SLO)$/fmdispatch.obj \ + $(SLO)$/formfeaturedispatcher.obj \ + $(SLO)$/formdispatchinterceptor.obj \ $(SLO)$/datanavi.obj \ $(SLO)$/xfm_addcondition.obj \ $(SLO)$/datalistener.obj \ diff --git a/svx/source/inc/confirmdelete.hxx b/svx/source/inc/confirmdelete.hxx index a06e297a8748..049f60e08f02 100644 --- a/svx/source/inc/confirmdelete.hxx +++ b/svx/source/inc/confirmdelete.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: confirmdelete.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/delayedevent.hxx b/svx/source/inc/delayedevent.hxx index 151b998f2f8c..bd8194a00c82 100644 --- a/svx/source/inc/delayedevent.hxx +++ b/svx/source/inc/delayedevent.hxx @@ -5,10 +5,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * -* $RCSfile: delayedevent.hxx,v $ -* -* $Revision: 1.1.2.1 $ -* * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmcontrolbordermanager.hxx b/svx/source/inc/fmcontrolbordermanager.hxx index 34dc8d86fb0b..a9e605873940 100644 --- a/svx/source/inc/fmcontrolbordermanager.hxx +++ b/svx/source/inc/fmcontrolbordermanager.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrolbordermanager.hxx,v $ - * $Revision: 1.6 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmcontrollayout.hxx b/svx/source/inc/fmcontrollayout.hxx index 1110c274b9f8..fdaa5e17bc7e 100644 --- a/svx/source/inc/fmcontrollayout.hxx +++ b/svx/source/inc/fmcontrollayout.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmcontrollayout.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/fmshimp.hxx b/svx/source/inc/fmshimp.hxx index 7d60e60f6d0e..434f13a177d0 100644 --- a/svx/source/inc/fmshimp.hxx +++ b/svx/source/inc/fmshimp.hxx @@ -270,8 +270,6 @@ class SAL_DLLPRIVATE FmXFormShell :public FmXFormShell_BASE ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormController > m_xExtViewTriggerController; // the nav controller at the time the external display was triggered ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > m_xExternalDisplayedForm; // the form which the external view is based on - FmXDispatchInterceptorImpl* m_pExternalViewInterceptor; - mutable ::svxform::DocumentType m_eDocumentType; /// the type of document we're living in sal_Int16 m_nLockSlotInvalidation; diff --git a/svx/source/inc/fmtools.hxx b/svx/source/inc/fmtools.hxx index 935e84c6448e..9e9e892ef6cc 100644 --- a/svx/source/inc/fmtools.hxx +++ b/svx/source/inc/fmtools.hxx @@ -48,7 +48,6 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XDispatchProviderInterception.hpp> #include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> -#include <com/sun/star/frame/XInterceptorInfo.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/frame/XStatusListener.hpp> @@ -93,8 +92,6 @@ #include <comphelper/uno3.hxx> #include <comphelper/stl_types.hxx> #include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> #include <cppuhelper/component.hxx> #include <svx/svxdllapi.h> @@ -114,9 +111,6 @@ SVX_DLLPUBLIC void displayException(const ::com::sun::star::sdb::SQLContext&, Wi void displayException(const ::com::sun::star::sdb::SQLErrorEvent&, Window* _pParent = NULL); void displayException(const ::com::sun::star::uno::Any&, Window* _pParent = NULL); -#define DATA_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DataMode" ) ) -#define FILTER_MODE rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterMode" ) ) - // Kopieren von Persistenten Objecten ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> cloneUsingProperties(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XPersistObject>& _xObj); @@ -258,107 +252,6 @@ public: // ================================================================== -//======================================================================== -//= dispatch interception helper classes -//======================================================================== - -//------------------------------------------------------------------------ -//- FmDispatchInterceptor -//------------------------------------------------------------------------ -class FmDispatchInterceptor -{ -public: - FmDispatchInterceptor() { } - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch(sal_uInt16 _nId, - const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0; - - virtual ::osl::Mutex* getInterceptorMutex() = 0; -}; - -//------------------------------------------------------------------------ -//- FmXDispatchInterceptorImpl -//------------------------------------------------------------------------ -typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::frame::XDispatchProviderInterceptor - , ::com::sun::star::lang::XEventListener - , ::com::sun::star::frame::XInterceptorInfo - > FmXDispatchInterceptorImpl_BASE; - -class FmXDispatchInterceptorImpl : public FmXDispatchInterceptorImpl_BASE -{ - ::osl::Mutex m_aFallback; - - // the component which's dispatches we're intercepting - ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception> - m_xIntercepted; - sal_Bool m_bListening; - - // the real interceptor - FmDispatchInterceptor* m_pMaster; - - // chaining - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; - - // our id - sal_Int16 m_nId; - - ::com::sun::star::uno::Sequence< ::rtl::OUString > - m_aInterceptedURLSchemes; - - virtual ~FmXDispatchInterceptorImpl(); - -public: - ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } - -public: - FmXDispatchInterceptorImpl( - const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept, - FmDispatchInterceptor* _pMaster, - sal_Int16 _nId, - ::com::sun::star::uno::Sequence< ::rtl::OUString > _rInterceptedSchemes /// if not empty, this will be used for getInterceptedURLs - ); - - // StarOne - DECLARE_UNO3_DEFAULTS(FmXDispatchInterceptorImpl, FmXDispatchInterceptorImpl_BASE); - // virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& type) throw ( ::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); - // ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException); - - - // ::com::sun::star::frame::XDispatchProvider - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::frame::XDispatchProviderInterceptor - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::frame::XInterceptorInfo - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getInterceptedURLs( ) throw(::com::sun::star::uno::RuntimeException); - - // ::com::sun::star::lang::XEventListener - virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); - - // OComponentHelper - virtual void SAL_CALL disposing(); - -protected: - void ImplDetach(); - - ::osl::Mutex& getAccessSafety() - { - if (m_pMaster && m_pMaster->getInterceptorMutex()) - return *m_pMaster->getInterceptorMutex(); - return m_aFallback; - } -}; - -//================================================================== -// ... -//================================================================== ::rtl::OUString getServiceNameByControlType(sal_Int16 nType); // get a service name to create a model of the given type (OBJ_FM_...) sal_Int16 getControlTypeByObject(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject); diff --git a/svx/source/inc/fmctrler.hxx b/svx/source/inc/formcontroller.hxx index 550bce611c73..4c4ba187187d 100644 --- a/svx/source/inc/fmctrler.hxx +++ b/svx/source/inc/formcontroller.hxx @@ -27,30 +27,18 @@ #ifndef _SVX_FMCTRLER_HXX #define _SVX_FMCTRLER_HXX -#include "fmtools.hxx" -#include "formcontrolling.hxx" -#include "sqlparserclient.hxx" #include "delayedevent.hxx" +#include "formdispatchinterceptor.hxx" +#include "sqlparserclient.hxx" /** === begin UNO includes === **/ #include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/awt/XControlContainer.hpp> #include <com/sun/star/awt/XControlModel.hpp> #include <com/sun/star/awt/XFocusListener.hpp> #include <com/sun/star/awt/XItemListener.hpp> #include <com/sun/star/awt/XMouseListener.hpp> #include <com/sun/star/awt/XTabController.hpp> -#include <com/sun/star/awt/XTabControllerModel.hpp> #include <com/sun/star/awt/XTextComponent.hpp> -#include <com/sun/star/awt/XTextListener.hpp> -#include <com/sun/star/beans/PropertyChangeEvent.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/container/ContainerEvent.hpp> -#include <com/sun/star/container/XChild.hpp> -#include <com/sun/star/container/XContainer.hpp> #include <com/sun/star/container/XContainerListener.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/container/XIndexContainer.hpp> @@ -90,6 +78,7 @@ /** === end UNO includes === **/ #include <comphelper/broadcasthelper.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/proparrhlp.hxx> #include <comphelper/stl_types.hxx> #include <connectivity/sqlparse.hxx> @@ -97,9 +86,9 @@ #include <tools/debug.hxx> #include <vcl/timer.hxx> -#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21) -#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_21 -#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 21 +#if ! defined(INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22) +#define INCLUDED_COMPHELPER_IMPLBASE_VAR_HXX_22 +#define COMPHELPER_IMPLBASE_INTERFACE_NUMBER 22 #include <comphelper/implbase_var.hxx> #endif @@ -124,7 +113,7 @@ namespace svxform class ControlBorderManager; struct FmFieldInfo; - typedef ::comphelper::WeakComponentImplHelper21 < ::com::sun::star::form::runtime::XFormController + typedef ::comphelper::WeakComponentImplHelper22 < ::com::sun::star::form::runtime::XFormController , ::com::sun::star::form::runtime::XFilterController , ::com::sun::star::awt::XFocusListener , ::com::sun::star::form::XLoadListener @@ -145,6 +134,7 @@ namespace svxform , ::com::sun::star::form::validation::XFormComponentValidityListener , ::com::sun::star::task::XInteractionHandler , ::com::sun::star::form::XGridControlListener + , ::com::sun::star::form::runtime::XFeatureInvalidation > FormController_BASE; //================================================================== @@ -154,12 +144,11 @@ namespace svxform class SAL_DLLPRIVATE FormController :public ::comphelper::OBaseMutex ,public FormController_BASE ,public ::cppu::OPropertySetHelper - ,public FmDispatchInterceptor + ,public DispatchInterceptor ,public ::comphelper::OAggregationArrayUsageHelper< FormController > ,public ::svxform::OSQLParserClient - ,public ::svx::IControllerFeatureInvalidation { - typedef ::std::map < sal_Int32, + typedef ::std::map < sal_Int16, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > DispatcherContainer; @@ -169,7 +158,7 @@ namespace svxform ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xModelAsIndex; ::com::sun::star::uno::Reference< ::com::sun::star::script::XEventAttacherManager> m_xModelAsManager; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xParent; - ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xORB; + ::comphelper::ComponentContext m_aContext; // Composer used for checking filter conditions ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > m_xComposer; ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > m_xInteractionHandler; @@ -195,9 +184,10 @@ namespace svxform ::svxform::ControlBorderManager* m_pControlBorderManager; - ::svx::ControllerFeatures m_aControllerFeatures; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > + m_xFormOperations; DispatcherContainer m_aFeatureDispatchers; - ::std::set< sal_Int32 > m_aInvalidFeatures; // for asynchronous feature invalidation + ::std::set< sal_Int16 > m_aInvalidFeatures; // for asynchronous feature invalidation ::rtl::OUString m_aMode; @@ -228,7 +218,7 @@ namespace svxform // as we want to intercept dispatches of _all_ controls we're responsible for, and an object implementing // the ::com::sun::star::frame::XDispatchProviderInterceptor interface can intercept only _one_ objects dispatches, we need a helper class - DECLARE_STL_VECTOR(FmXDispatchInterceptorImpl*, Interceptors); + DECLARE_STL_VECTOR(DispatchInterceptionMultiplexer*, Interceptors); Interceptors m_aControlDispatchInterceptors; public: @@ -426,7 +416,11 @@ namespace svxform virtual sal_Bool SAL_CALL approveReset(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); virtual void SAL_CALL resetted(const ::com::sun::star::lang::EventObject& rEvent) throw( ::com::sun::star::uno::RuntimeException ); - // method for registration + // XFeatureInvalidation + virtual void SAL_CALL invalidateFeatures( const ::com::sun::star::uno::Sequence< ::sal_Int16 >& Features ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL invalidateAllFeatures( ) throw (::com::sun::star::uno::RuntimeException); + +// method for registration static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); // comphelper::OPropertyArrayUsageHelper @@ -436,22 +430,20 @@ namespace svxform ) const; protected: - // FmDispatchInterceptor + // DispatchInterceptor virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> - interceptedQueryDispatch(sal_uInt16 _nId,const ::com::sun::star::util::URL& aURL, - const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) - throw( ::com::sun::star::uno::RuntimeException ); - - // IControllerFeatureInvalidation - virtual void invalidateFeatures( const ::std::vector< sal_Int32 >& _rFeatures ); + interceptedQueryDispatch( + const ::com::sun::star::util::URL& aURL, + const ::rtl::OUString& aTargetFrameName, + sal_Int32 nSearchFlags + ) throw( ::com::sun::star::uno::RuntimeException ); virtual ::osl::Mutex* getInterceptorMutex() { return &m_aMutex; } /// update all our dispatchers void updateAllDispatchers() const; - /** disposes all dispatchers in m_aFeatureDispatchers, empties m_aFeatureDispatchers, - and disposes m_aControllerFeatures + /** disposes all dispatchers in m_aFeatureDispatchers, and empties m_aFeatureDispatchers */ void disposeAllFeaturesAndDispatchers() SAL_THROW(()); diff --git a/svx/source/inc/formcontrolling.hxx b/svx/source/inc/formcontrolling.hxx index 2b5b64db262d..f818ced85189 100644 --- a/svx/source/inc/formcontrolling.hxx +++ b/svx/source/inc/formcontrolling.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: formcontrolling.hxx,v $ - * $Revision: 1.7 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify diff --git a/svx/source/inc/formdispatchinterceptor.hxx b/svx/source/inc/formdispatchinterceptor.hxx new file mode 100644 index 000000000000..5bcfc1726ad0 --- /dev/null +++ b/svx/source/inc/formdispatchinterceptor.hxx @@ -0,0 +1,118 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2009 by Sun Microsystems, Inc. +* +* 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 SVX_FORMDISPATCHINTERCEPTOR_HXX +#define SVX_FORMDISPATCHINTERCEPTOR_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/frame/XDispatchProviderInterceptor.hpp> +#include <com/sun/star/frame/XDispatchProviderInterception.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/compbase2.hxx> +#include <comphelper/uno3.hxx> + +//........................................................................ +namespace svxform +{ +//........................................................................ + + //==================================================================== + //= DispatchInterceptor + //==================================================================== + class DispatchInterceptor + { + public: + DispatchInterceptor() { } + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch> interceptedQueryDispatch( + const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags) throw( ::com::sun::star::uno::RuntimeException ) = 0; + + virtual ::osl::Mutex* getInterceptorMutex() = 0; + }; + + //==================================================================== + //= + //==================================================================== + typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::frame::XDispatchProviderInterceptor + , ::com::sun::star::lang::XEventListener + > DispatchInterceptionMultiplexer_BASE; + + class DispatchInterceptionMultiplexer : public DispatchInterceptionMultiplexer_BASE + { + ::osl::Mutex m_aFallback; + ::osl::Mutex* m_pMutex; + + // the component which's dispatches we're intercepting + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XDispatchProviderInterception > + m_xIntercepted; + sal_Bool m_bListening; + + // the real interceptor + DispatchInterceptor* m_pMaster; + + // chaining + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xSlaveDispatcher; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider> m_xMasterDispatcher; + + virtual ~DispatchInterceptionMultiplexer(); + + public: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception> getIntercepted() const { return m_xIntercepted; } + + public: + DispatchInterceptionMultiplexer( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProviderInterception>& _rToIntercept, + DispatchInterceptor* _pMaster + ); + + // UNO + DECLARE_UNO3_DEFAULTS(DispatchInterceptionMultiplexer, DispatchInterceptionMultiplexer_BASE); + + // ::com::sun::star::frame::XDispatchProvider + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& aTargetFrameName, sal_Int32 nSearchFlags ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& aDescripts ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::frame::XDispatchProviderInterceptor + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getSlaveDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSlaveDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewDispatchProvider ) throw(::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > SAL_CALL getMasterDispatchProvider( ) throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setMasterDispatchProvider( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& xNewSupplier ) throw(::com::sun::star::uno::RuntimeException); + + // ::com::sun::star::lang::XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + + protected: + void ImplDetach(); + }; + +//........................................................................ +} // namespace svxform +//........................................................................ + +#endif // SVX_FORMDISPATCHINTERCEPTOR_HXX diff --git a/svx/source/inc/fmdispatch.hxx b/svx/source/inc/formfeaturedispatcher.hxx index 90480afc4609..32316d52b922 100644 --- a/svx/source/inc/fmdispatch.hxx +++ b/svx/source/inc/formfeaturedispatcher.hxx @@ -6,9 +6,6 @@ * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: fmdispatch.hxx,v $ - * $Revision: 1.4 $ - * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -31,19 +28,20 @@ #ifndef SVX_FMDISPATCH_HXX #define SVX_FMDISPATCH_HXX -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/interfacecontainer.hxx> +/** === begin UNO includes === **/ #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/form/runtime/XFormOperations.hpp> +/** === end UNO includes === **/ +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/interfacecontainer.hxx> //........................................................................ namespace svx { //........................................................................ - class FormControllerHelper; - //==================================================================== //= OSingleFeatureDispatcher //==================================================================== @@ -55,10 +53,11 @@ namespace svx private: ::osl::Mutex& m_rMutex; ::cppu::OInterfaceContainerHelper m_aStatusListeners; - const FormControllerHelper& m_rController; + ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations > + m_xFormOperations; const ::com::sun::star::util::URL m_aFeatureURL; ::com::sun::star::uno::Any m_aLastKnownState; - const sal_Int32 m_nFeatureId; + const sal_Int16 m_nFormFeature; sal_Bool m_bLastKnownEnabled; sal_Bool m_bDisposed; @@ -80,9 +79,9 @@ namespace svx */ OSingleFeatureDispatcher( const ::com::sun::star::util::URL& _rFeatureURL, - sal_Int32 _nFeatureId, - const FormControllerHelper& _rController, - ::osl::Mutex& _rMutex + const sal_Int16 _nFormFeature, + const ::com::sun::star::uno::Reference< ::com::sun::star::form::runtime::XFormOperations >& _rxFormOperations, + ::osl::Mutex& _rMutex ); /** disposes the dispatcher instance |