diff options
author | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-12-07 14:44:27 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@sun.com> | 2009-12-07 14:44:27 +0100 |
commit | 450e9828544de8988c3bec93850029bfa8df2e1f (patch) | |
tree | 04ae30f2711acd490ff619130dbaf4f1d1a3cfe0 | |
parent | 2a55dd7ed275480560f1fc95c34d82027d1c6dc1 (diff) |
autorecovery: also implement XInteractionHandler2, if our delegator supports it
-rw-r--r-- | framework/inc/interaction/preventduplicateinteraction.hxx | 28 | ||||
-rw-r--r-- | framework/source/interaction/preventduplicateinteraction.cxx | 73 |
2 files changed, 99 insertions, 2 deletions
diff --git a/framework/inc/interaction/preventduplicateinteraction.hxx b/framework/inc/interaction/preventduplicateinteraction.hxx index 2b43ab02fcdc..e069d3e4c146 100644 --- a/framework/inc/interaction/preventduplicateinteraction.hxx +++ b/framework/inc/interaction/preventduplicateinteraction.hxx @@ -40,7 +40,7 @@ //_________________________________________________________________________________________________________________ // interface includes //_________________________________________________________________________________________________________________ -#include <com/sun/star/task/XInteractionHandler.hpp> +#include <com/sun/star/task/XInteractionHandler2.hpp> #include <com/sun/star/task/XInteractionRequest.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> @@ -86,7 +86,7 @@ struct ThreadHelpBase2 }; class PreventDuplicateInteraction : private ThreadHelpBase2 - ,public ::cppu::WeakImplHelper1< css::task::XInteractionHandler > + ,public ::cppu::WeakImplHelper1< css::task::XInteractionHandler2 > { //_____________________________________ // structs, types etcp. @@ -158,6 +158,30 @@ class PreventDuplicateInteraction : private ThreadHelpBase2 virtual void SAL_CALL handle(const css::uno::Reference< css::task::XInteractionRequest >& xRequest) throw(css::uno::RuntimeException); + //_________________________________ + /** + @interface XInteractionHandler2 + @short called from outside to handle a problem + @descr We filter the incoming interactions. some of them + will be forwarded to the generic UI interaction handler. + So we must not implement it twice. Some other ones + will be aborted only. + + @threadsafe yes + */ + virtual ::sal_Bool SAL_CALL handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& xRequest ) + throw (::com::sun::star::uno::RuntimeException); + + //_________________________________ + /** + @interface XInterface + @short called to query another interface of the component + @descr Will allow to query for XInteractionHandler2 if and only if m_xHandler supports this interface, too. + + @threadsafe yes + */ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) + throw (::com::sun::star::uno::RuntimeException); //_____________________________________ // c++ interface public: diff --git a/framework/source/interaction/preventduplicateinteraction.cxx b/framework/source/interaction/preventduplicateinteraction.cxx index 4e30da90e25b..e005bdf7d627 100644 --- a/framework/source/interaction/preventduplicateinteraction.cxx +++ b/framework/source/interaction/preventduplicateinteraction.cxx @@ -112,6 +112,20 @@ void PreventDuplicateInteraction::useDefaultUUIHandler() } //_________________________________________________________________________________________________________________ +css::uno::Any SAL_CALL PreventDuplicateInteraction::queryInterface( const css::uno::Type& aType ) + throw (css::uno::RuntimeException) +{ + if ( aType.equals( XInteractionHandler2::static_type() ) ) + { + ::osl::ResettableMutexGuard aLock(m_aLock); + css::uno::Reference< css::task::XInteractionHandler2 > xHandler( m_xHandler, css::uno::UNO_QUERY ); + if ( !xHandler.is() ) + return css::uno::Any(); + } + return ::cppu::WeakImplHelper1< css::task::XInteractionHandler2 >::queryInterface( aType ); +} + +//_________________________________________________________________________________________________________________ void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css::task::XInteractionRequest >& xRequest) throw(css::uno::RuntimeException) @@ -169,6 +183,65 @@ void SAL_CALL PreventDuplicateInteraction::handle(const css::uno::Reference< css //_________________________________________________________________________________________________________________ +::sal_Bool SAL_CALL PreventDuplicateInteraction::handleInteractionRequest( const css::uno::Reference< css::task::XInteractionRequest >& xRequest ) + throw (css::uno::RuntimeException) +{ + css::uno::Any aRequest = xRequest->getRequest(); + sal_Bool bHandleIt = sal_True; + + // SAFE -> + ::osl::ResettableMutexGuard aLock(m_aLock); + + InteractionList::iterator pIt; + for ( pIt = m_lInteractionRules.begin(); + pIt != m_lInteractionRules.end() ; + ++pIt ) + { + InteractionInfo& rInfo = *pIt; + + if (aRequest.isExtractableTo(rInfo.m_aInteraction)) + { + ++rInfo.m_nCallCount; + rInfo.m_xRequest = xRequest; + bHandleIt = (rInfo.m_nCallCount <= rInfo.m_nMaxCount); + break; + } + } + + css::uno::Reference< css::task::XInteractionHandler2 > xHandler( m_xHandler, css::uno::UNO_QUERY ); + OSL_ENSURE( xHandler.is() || !m_xHandler.is(), + "PreventDuplicateInteraction::handleInteractionRequest: inconsistency!" ); + + aLock.clear(); + // <- SAFE + + if ( + (bHandleIt ) && + (xHandler.is()) + ) + { + return xHandler->handleInteractionRequest(xRequest); + } + else + { + const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > > lContinuations = xRequest->getContinuations(); + sal_Int32 c = lContinuations.getLength(); + sal_Int32 i = 0; + for (i=0; i<c; ++i) + { + css::uno::Reference< css::task::XInteractionAbort > xAbort(lContinuations[i], css::uno::UNO_QUERY); + if (xAbort.is()) + { + xAbort->select(); + break; + } + } + } + return false; +} + +//_________________________________________________________________________________________________________________ + void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInteraction::InteractionInfo& aInteractionInfo) { // SAFE -> |