1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cancelcommandexecution.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucbhelper.hxx"
34 /**************************************************************************
36 **************************************************************************
38 *************************************************************************/
39 #include <osl/diagnose.h>
40 #include <cppuhelper/exc_hlp.hxx>
41 #include <com/sun/star/ucb/CommandFailedException.hpp>
42 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
43 #ifndef _UCBHELPER_INTERACTIONREQUEST_HXX
44 #include <ucbhelper/interactionrequest.hxx>
46 #include <ucbhelper/cancelcommandexecution.hxx>
47 #include <ucbhelper/simpleioerrorrequest.hxx>
49 using namespace com::sun::star
;
54 //=========================================================================
55 void cancelCommandExecution( const uno::Any
& rException
,
57 ucb::XCommandEnvironment
> & xEnv
)
58 throw( uno::Exception
)
63 task::XInteractionHandler
> xIH
= xEnv
->getInteractionHandler();
66 rtl::Reference
< ucbhelper::InteractionRequest
> xRequest
67 = new ucbhelper::InteractionRequest( rException
);
69 uno::Sequence
< uno::Reference
< task::XInteractionContinuation
> >
72 = new ucbhelper::InteractionAbort( xRequest
.get() );
74 xRequest
->setContinuations( aContinuations
);
76 xIH
->handle( xRequest
.get() );
78 rtl::Reference
< ucbhelper::InteractionContinuation
> xSelection
79 = xRequest
->getSelection();
81 if ( xSelection
.is() )
82 throw ucb::CommandFailedException(
84 uno::Reference
< uno::XInterface
>(),
89 cppu::throwException( rException
);
91 OSL_ENSURE( sal_False
, "Return from cppu::throwException call!!!" );
92 throw uno::RuntimeException();
96 //=========================================================================
97 void cancelCommandExecution( const ucb::IOErrorCode eError
,
98 const uno::Sequence
< uno::Any
> & rArgs
,
100 ucb::XCommandEnvironment
> & xEnv
,
101 const rtl::OUString
& rMessage
,
102 const uno::Reference
<
103 ucb::XCommandProcessor
> & xContext
)
104 throw( uno::Exception
)
106 rtl::Reference
< ucbhelper::SimpleIOErrorRequest
> xRequest
107 = new ucbhelper::SimpleIOErrorRequest(
108 eError
, rArgs
, rMessage
, xContext
);
112 task::XInteractionHandler
> xIH
= xEnv
->getInteractionHandler();
115 xIH
->handle( xRequest
.get() );
117 rtl::Reference
< ucbhelper::InteractionContinuation
> xSelection
118 = xRequest
->getSelection();
120 if ( xSelection
.is() )
121 throw ucb::CommandFailedException( rtl::OUString(),
123 xRequest
->getRequest() );
127 cppu::throwException( xRequest
->getRequest() );
129 OSL_ENSURE( sal_False
, "Return from cppu::throwException call!!!" );
130 throw uno::RuntimeException();