Update ooo320-m1
[ooovba.git] / ucbhelper / source / provider / cancelcommandexecution.cxx
blob8000eac6bfdc1154871bfa8606e9229a3a85e4cc
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cancelcommandexecution.cxx,v $
10 * $Revision: 1.14 $
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 /**************************************************************************
35 TODO
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>
45 #endif
46 #include <ucbhelper/cancelcommandexecution.hxx>
47 #include <ucbhelper/simpleioerrorrequest.hxx>
49 using namespace com::sun::star;
51 namespace ucbhelper
54 //=========================================================================
55 void cancelCommandExecution( const uno::Any & rException,
56 const uno::Reference<
57 ucb::XCommandEnvironment > & xEnv )
58 throw( uno::Exception )
60 if ( xEnv.is() )
62 uno::Reference<
63 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
64 if ( xIH.is() )
66 rtl::Reference< ucbhelper::InteractionRequest > xRequest
67 = new ucbhelper::InteractionRequest( rException );
69 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
70 aContinuations( 1 );
71 aContinuations[ 0 ]
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(
83 rtl::OUString(),
84 uno::Reference< uno::XInterface >(),
85 rException );
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,
99 const uno::Reference<
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 );
109 if ( xEnv.is() )
111 uno::Reference<
112 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
113 if ( xIH.is() )
115 xIH->handle( xRequest.get() );
117 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
118 = xRequest->getSelection();
120 if ( xSelection.is() )
121 throw ucb::CommandFailedException( rtl::OUString(),
122 xContext,
123 xRequest->getRequest() );
127 cppu::throwException( xRequest->getRequest() );
129 OSL_ENSURE( sal_False, "Return from cppu::throwException call!!!" );
130 throw uno::RuntimeException();