#87187# - Introduced function for IO errors, that transports two string

arguments.
This commit is contained in:
Kai Sommerfeld 2001-06-25 06:10:16 +00:00
parent 2df155f2b7
commit 6314962c05
2 changed files with 129 additions and 12 deletions

View file

@ -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
@ -145,6 +145,52 @@ void cancelCommandExecution( const com::sun::star::ucb::IOErrorCode eError,
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 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,

View file

@ -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,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() );
}
}
@ -172,6 +193,53 @@ void cancelCommandExecution( const ucb::IOErrorCode eError,
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() );
}
}
cppu::throwException( xRequest->getRequest() );
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
}
}