diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2008-11-19 17:43:08 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2008-11-19 17:43:08 +0000 |
commit | c41efc6d0b2740be4243fd696385f8dbcec0aefe (patch) | |
tree | 2caf4d37a6cfe59a14f2ac565aca279c8cdb981c /uui/source/iahndl.cxx | |
parent | a29935a32d0daddde35a60c853f7606b61c86262 (diff) |
CWS-TOOLING: integrate CWS dba301a_DEV300
Diffstat (limited to 'uui/source/iahndl.cxx')
-rw-r--r-- | uui/source/iahndl.cxx | 114 |
1 files changed, 99 insertions, 15 deletions
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx index b9ab2bfc6baf..aad5487d3276 100644 --- a/uui/source/iahndl.cxx +++ b/uui/source/iahndl.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: iahndl.cxx,v $ - * $Revision: 1.67 $ + * $Revision: 1.67.22.1 $ * * This file is part of OpenOffice.org. * @@ -55,7 +55,6 @@ #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/script/ModuleSizeExceededRequest.hpp" #include "com/sun/star/sync2/BadPartnershipException.hpp" -#include "com/sun/star/task/DocumentMacroConfirmationRequest.hpp" #include "com/sun/star/task/DocumentPasswordRequest.hpp" #include "com/sun/star/task/ErrorCodeIOException.hpp" #include "com/sun/star/task/ErrorCodeRequest.hpp" @@ -68,6 +67,7 @@ #include "com/sun/star/task/XInteractionRequest.hpp" #include "com/sun/star/task/XInteractionRetry.hpp" #include "com/sun/star/task/XPasswordContainer.hpp" +#include "com/sun/star/task/XInteractionAskLater.hpp" #include "com/sun/star/ucb/AuthenticationRequest.hpp" #include "com/sun/star/ucb/CertificateValidationRequest.hpp" #include "com/sun/star/ucb/HandleCookiesRequest.hpp" @@ -117,12 +117,21 @@ #include "unknownauthdlg.hxx" #include "sslwarndlg.hxx" #include "openlocked.hxx" +#include "newerverwarn.hxx" #include <comphelper/processfactory.hxx> #include <svtools/zforlist.hxx> using namespace com::sun; namespace csss = ::com::sun::star::security; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::UNO_QUERY; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::task::XInteractionContinuation; +using ::com::sun::star::task::XInteractionAbort; +using ::com::sun::star::task::XInteractionApprove; +using ::com::sun::star::task::XInteractionAskLater; +using ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest; namespace { @@ -1182,6 +1191,16 @@ void UUIInteractionHelper::handleErrorHandlerRequests( return; } + FutureDocumentVersionProductUpdateRequest aProductUpdateRequest; + if (aAnyRequest >>= aProductUpdateRequest) + { + handleFutureDocumentVersionUpdateRequest( + aProductUpdateRequest, + rRequest->getContinuations() + ); + return; + } + star::task::ErrorCodeIOException aErrorCodeIOException; if (aAnyRequest >>= aErrorCodeIOException) { @@ -2786,6 +2805,23 @@ UUIInteractionHelper::handleGenericErrorRequest( } } +namespace +{ + template< class INTERACTION_TYPE > + bool lcl_findContinuation( const Sequence< Reference< XInteractionContinuation > >& _rContinuations, + Reference< INTERACTION_TYPE >& _rContinuation ) + { + const Reference< XInteractionContinuation >* pContinuation = _rContinuations.getConstArray(); + const Reference< XInteractionContinuation >* pContinuationEnd = _rContinuations.getConstArray() + _rContinuations.getLength(); + while ( pContinuation != pContinuationEnd ) + { + if ( _rContinuation.set( *pContinuation++, UNO_QUERY ) ) + return true; + } + return false; + } +} + void UUIInteractionHelper::handleMacroConfirmRequest( const star::task::DocumentMacroConfirmationRequest& _rRequest, @@ -2794,18 +2830,8 @@ UUIInteractionHelper::handleMacroConfirmRequest( ) SAL_THROW((star::uno::RuntimeException)) { - star::uno::Reference< star::task::XInteractionAbort > xAbort; - star::uno::Reference< star::task::XInteractionApprove > xApprove; - - sal_Int32 nCount = rContinuations.getLength(); - for( sal_Int32 nStep=0; nStep<nCount; ++nStep ) - { - if( !xAbort.is() ) - xAbort = star::uno::Reference< star::task::XInteractionAbort >( rContinuations[nStep], star::uno::UNO_QUERY ); - - if( !xApprove.is() ) - xApprove = star::uno::Reference< star::task::XInteractionApprove >( rContinuations[nStep], star::uno::UNO_QUERY ); - } + Reference< XInteractionAbort > xAbort; lcl_findContinuation( rContinuations, xAbort ); + Reference< XInteractionApprove > xApprove; lcl_findContinuation( rContinuations, xApprove ); bool bApprove = false; @@ -2831,7 +2857,65 @@ UUIInteractionHelper::handleMacroConfirmRequest( if ( bApprove && xApprove.is() ) xApprove->select(); else if ( xAbort.is() ) - xAbort->select(); + xAbort->select(); +} + +void +UUIInteractionHelper::handleFutureDocumentVersionUpdateRequest( + const FutureDocumentVersionProductUpdateRequest& _rRequest, + Sequence< Reference< XInteractionContinuation > > const & rContinuations +) + SAL_THROW((star::uno::RuntimeException)) +{ + Reference< XInteractionAbort > xAbort; lcl_findContinuation( rContinuations, xAbort ); + Reference< XInteractionApprove > xApprove; lcl_findContinuation( rContinuations, xApprove ); + Reference< XInteractionApprove > xAskLater; lcl_findContinuation( rContinuations, xAskLater ); + + short nResult = RET_CANCEL; + + static bool s_bDeferredToNextSession = false; + // TODO: this static variable is somewhat hacky. Formerly (before the dialog was moved from SFX2 to the + // interaction handler implementation), this was stored in SFX_APP()'s impl structure, in member + // bODFVersionWarningLater. Of course, we do not have access to it here. + // + // A proper solution which I would envision would be: + // - There's a central implementation (this one here) of css.task.InteractionHandler + // - There's a configuration which maps UNO names to service names + // - If the handler is confronted with a request, it tries to find the name of the UNO structure describing + // the request in the said configuration. + // - If an entry is found, then + // - the respective service is instantiated + // - the component is queried for css.task.XInteractionHandler, and the request is delegated + // - if no entry is found, then the request is silenced (with calling the AbortContinuation, if possible) + // This way, the FutureDocumentVersionProductUpdateRequest could be handled in SFX (or any other + // suitable place), again, and we would only have one place where we remember the s_bDeferredToNextSession + // flag. + // + // The side effect (well, actually the more important effect) would be that we do not need to burden + // this central implementation with all interactions which are possible. Instead, separate parts of OOo + // can define/implement different requests. (for instance, everything which today is done in the + // css.sdb.InteractionHandler can then be routed through a "normal" interaction handler, where today we + // always need to tell people to instantiate the SDB-version of the handler, not the normal one.) + + if ( !s_bDeferredToNextSession ) + { + std::auto_ptr< ResMgr > pResMgr( ResMgr::CreateResMgr( CREATEVERSIONRESMGR_NAME( uui ) ) ); + if ( pResMgr.get() ) + { + ::uui::NewerVersionWarningDialog aDialog( getParentProperty(), _rRequest.DocumentODFVersion, *pResMgr.get() ); + nResult = aDialog.Execute(); + } + } + + switch ( nResult ) + { + case RET_OK: if ( xApprove.is() ) xApprove->select(); break; + case RET_CANCEL: if ( xAbort.is() ) xAbort->select(); break; + case RET_ASK_LATER: if ( xAskLater.is() ) xAskLater->select(); s_bDeferredToNextSession = true; break; + default: + OSL_ENSURE( false, "UUIInteractionHelper::handleFutureDocumentVersionUpdateRequest: unexpected dialog return value!" ); + break; + } } void |