diff options
author | Kai Sommerfeld <kso@openoffice.org> | 2001-06-25 06:10:16 +0000 |
---|---|---|
committer | Kai Sommerfeld <kso@openoffice.org> | 2001-06-25 06:10:16 +0000 |
commit | 6314962c0571550efa591e4533f94bfc59f7d53e (patch) | |
tree | 134ff92fca1707d78d0cd218057a8ac470874f26 /ucbhelper | |
parent | 2df155f2b77ec6c41f6a3ecb35f0d81b7700e0ab (diff) |
#87187# - Introduced function for IO errors, that transports two string
arguments.
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/inc/ucbhelper/cancelcommandexecution.hxx | 50 | ||||
-rw-r--r-- | ucbhelper/source/provider/cancelcommandexecution.cxx | 91 |
2 files changed, 129 insertions, 12 deletions
diff --git a/ucbhelper/inc/ucbhelper/cancelcommandexecution.hxx b/ucbhelper/inc/ucbhelper/cancelcommandexecution.hxx index d7bc231be40d..5b90924bae79 100644 --- a/ucbhelper/inc/ucbhelper/cancelcommandexecution.hxx +++ b/ucbhelper/inc/ucbhelper/cancelcommandexecution.hxx @@ -2,9 +2,9 @@ * * $RCSfile: cancelcommandexecution.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: kso $ $Date: 2001-06-19 09:16:41 $ + * last change: $Author: kso $ $Date: 2001-06-25 07:07:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -158,6 +158,52 @@ void cancelCommandExecution( const com::sun::star::ucb::IOErrorCode eError, @param eError is an IO error code. + @param rArg1 is a string to pass as the first argument with the resulting + InteractivAugmentedIOException. Each IO error code can be combined + with one or more additional arguments. Refer to + com/sun/star/ucb/IOErroprCode.idl for details. + + @param rArg2 is a string to pass as the second argument with the resulting + InteractivAugmentedIOException. Each IO error code can be combined + with one or more additional arguments. Refer to + com/sun/star/ucb/IOErroprCode.idl for details. + + @param xEnv is the command environment that may contain an Interaction + Handler to use before throwing the appropriate exception. + + @param rMessage is a text containing additional error information. + Used as debugging aid only. Passed to the member 'Message' of the + uno::Exception thrown by this function. + + @param xContext is the command processor executing the command to cancel. + Used as debugging aid only. Passed to the member 'Context' of the + uno::Exception thrown by this function. + */ +void cancelCommandExecution( const com::sun::star::ucb::IOErrorCode eError, + const rtl::OUString & rArg1, + const rtl::OUString & rArg2, + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandEnvironment > & + xEnv, + const rtl::OUString & rMessage = rtl::OUString(), + const com::sun::star::uno::Reference< + com::sun::star::ucb::XCommandProcessor > & + xContext = 0 ) + throw( com::sun::star::uno::Exception ); + +/** Cancel the execution of a command by throwing the appropriate exception. + If an Interaction Handler is given with the command environment and the + handler handles the exception by selecting the supplied continuation, + then this function will put the original exception supplied into a + com::sun::star::ucb::CommandFailedException and throw the + CommandFailedException. If no handler was given or the handler was not + able to handle the exception, then the given exception will be thrown + directly. + + NOTE THAT THIS FUNCTION NEVER RETURNS! IT ALWAYS THROWS AN EXCEPTION! + + @param eError is an IO error code. + @param rArgs is a sequeence containing the arguments to pass along with the exception. Each IO error code can be combined with one or more additional arguments. Refer to com/sun/star/ucb/IOErroprCode.idl diff --git a/ucbhelper/source/provider/cancelcommandexecution.cxx b/ucbhelper/source/provider/cancelcommandexecution.cxx index 7f292fc491f6..0852999b5f72 100644 --- a/ucbhelper/source/provider/cancelcommandexecution.cxx +++ b/ucbhelper/source/provider/cancelcommandexecution.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cancelcommandexecution.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: kso $ $Date: 2001-06-19 09:18:27 $ + * last change: $Author: kso $ $Date: 2001-06-25 07:10:16 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -59,6 +59,8 @@ * ************************************************************************/ +//#define OLD_UCB_ERROR_HANDLING + /************************************************************************** TODO ************************************************************************** @@ -87,6 +89,15 @@ #include <ucbhelper/simpleioerrorrequest.hxx> #endif +#ifdef OLD_UCB_ERROR_HANDLING +#ifndef _COM_SUN_STAR_UCB_COMMANDABORTEDEXCEPTION_HPP_ +#include <com/sun/star/ucb/CommandAbortedException.hpp> +#endif +#ifndef _COM_SUN_STAR_UCB_INTERACTIVEBADTRANSFERURLEXCEPTION_HPP_ +#include <com/sun/star/ucb/InteractiveBadTransferURLException.hpp> +#endif +#endif + using namespace com::sun::star; namespace ucbhelper @@ -98,6 +109,13 @@ void cancelCommandExecution( const uno::Any & rException, ucb::XCommandEnvironment > & xEnv ) throw( uno::Exception ) { +#ifdef OLD_UCB_ERROR_HANDLING + ucb::InteractiveBadTransferURLException e; + if ( rException >>= e ) + throw e; + + throw ucb::CommandAbortedException(); +#else if ( xEnv.is() ) { uno::Reference< @@ -131,6 +149,7 @@ void cancelCommandExecution( const uno::Any & rException, OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" ); throw uno::RuntimeException(); +#endif } //========================================================================= @@ -143,6 +162,9 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, ucb::XCommandProcessor > & xContext ) throw( uno::Exception ) { +#ifdef OLD_UCB_ERROR_HANDLING + throw ucb::CommandAbortedException(); +#else uno::Sequence< uno::Any > aArgs( 1 ); aArgs[ 0 ] <<= rArg; @@ -161,10 +183,55 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, = xRequest->getSelection(); if ( xSelection.is() ) - throw ucb::CommandFailedException( - rtl::OUString(), - xContext, - xRequest->getRequest() ); + throw ucb::CommandFailedException( rtl::OUString(), + xContext, + xRequest->getRequest() ); + } + } + + cppu::throwException( xRequest->getRequest() ); + + OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" ); + throw uno::RuntimeException(); +#endif +} + +//========================================================================= +void cancelCommandExecution( const ucb::IOErrorCode eError, + const rtl::OUString & rArg1, + const rtl::OUString & rArg2, + const uno::Reference< + ucb::XCommandEnvironment > & xEnv, + const rtl::OUString & rMessage, + const uno::Reference< + ucb::XCommandProcessor > & xContext ) + throw( uno::Exception ) +{ +#ifdef OLD_UCB_ERROR_HANDLING + throw ucb::CommandAbortedException(); +#else + uno::Sequence< uno::Any > aArgs( 2 ); + aArgs[ 0 ] <<= rArg1; + aArgs[ 1 ] <<= rArg2; + + rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest + = new ucbhelper::SimpleIOErrorRequest( + eError, aArgs, rMessage, xContext ); + if ( xEnv.is() ) + { + uno::Reference< + task::XInteractionHandler > xIH = xEnv->getInteractionHandler(); + if ( xIH.is() ) + { + xIH->handle( xRequest.get() ); + + rtl::Reference< ucbhelper::InteractionContinuation > xSelection + = xRequest->getSelection(); + + if ( xSelection.is() ) + throw ucb::CommandFailedException( rtl::OUString(), + xContext, + xRequest->getRequest() ); } } @@ -172,6 +239,7 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" ); throw uno::RuntimeException(); +#endif } //========================================================================= @@ -184,6 +252,9 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, ucb::XCommandProcessor > & xContext ) throw( uno::Exception ) { +#ifdef OLD_UCB_ERROR_HANDLING + throw ucb::CommandAbortedException(); +#else rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest = new ucbhelper::SimpleIOErrorRequest( eError, rArgs, rMessage, xContext ); @@ -199,10 +270,9 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, = xRequest->getSelection(); if ( xSelection.is() ) - throw ucb::CommandFailedException( - rtl::OUString(), - xContext, - xRequest->getRequest() ); + throw ucb::CommandFailedException( rtl::OUString(), + xContext, + xRequest->getRequest() ); } } @@ -210,6 +280,7 @@ void cancelCommandExecution( const ucb::IOErrorCode eError, OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" ); throw uno::RuntimeException(); +#endif } } |