From 450e9828544de8988c3bec93850029bfa8df2e1f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 7 Dec 2009 14:44:27 +0100 Subject: autorecovery: also implement XInteractionHandler2, if our delegator supports it --- .../interaction/preventduplicateinteraction.cxx | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'framework/source/interaction') 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 @@ -111,6 +111,20 @@ void PreventDuplicateInteraction::useDefaultUUIHandler() // <- SAFE } +//_________________________________________________________________________________________________________________ +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) @@ -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 xAbort(lContinuations[i], css::uno::UNO_QUERY); + if (xAbort.is()) + { + xAbort->select(); + break; + } + } + } + return false; +} + +//_________________________________________________________________________________________________________________ + void PreventDuplicateInteraction::addInteractionRule(const PreventDuplicateInteraction::InteractionInfo& aInteractionInfo) { // SAFE -> -- cgit v1.2.3