nss: upgrade to release 3.73
[LibreOffice.git] / ucbhelper / source / provider / cancelcommandexecution.cxx
blobf700c8a4afc1dfa13be7fd01c94bbb9a191dc0e8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 /**************************************************************************
22 TODO
23 **************************************************************************
25 *************************************************************************/
26 #include <osl/diagnose.h>
27 #include <rtl/ref.hxx>
28 #include <cppuhelper/exc_hlp.hxx>
29 #include <com/sun/star/ucb/CommandFailedException.hpp>
30 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
31 #include <ucbhelper/interactionrequest.hxx>
32 #include <ucbhelper/cancelcommandexecution.hxx>
33 #include "simpleioerrorrequest.hxx"
35 using namespace com::sun::star;
37 namespace ucbhelper
41 void cancelCommandExecution( const uno::Any & rException,
42 const uno::Reference<
43 ucb::XCommandEnvironment > & xEnv )
45 if ( xEnv.is() )
47 uno::Reference<
48 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
49 if ( xIH.is() )
51 rtl::Reference< ucbhelper::InteractionRequest > xRequest
52 = new ucbhelper::InteractionRequest( rException );
54 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
55 aContinuations( 1 );
56 aContinuations[ 0 ]
57 = new ucbhelper::InteractionAbort( xRequest.get() );
59 xRequest->setContinuations( aContinuations );
61 xIH->handle( xRequest.get() );
63 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
64 = xRequest->getSelection();
66 if ( xSelection.is() )
67 throw ucb::CommandFailedException(
68 OUString(),
69 uno::Reference< uno::XInterface >(),
70 rException );
74 cppu::throwException( rException );
75 OSL_FAIL( "Return from cppu::throwException call!!!" );
76 throw uno::RuntimeException();
80 void cancelCommandExecution( const ucb::IOErrorCode eError,
81 const uno::Sequence< uno::Any > & rArgs,
82 const uno::Reference<
83 ucb::XCommandEnvironment > & xEnv,
84 const OUString & rMessage,
85 const uno::Reference<
86 ucb::XCommandProcessor > & xContext )
88 rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest
89 = new ucbhelper::SimpleIOErrorRequest(
90 eError, rArgs, rMessage, xContext );
91 if ( xEnv.is() )
93 uno::Reference<
94 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
95 if ( xIH.is() )
97 xIH->handle( xRequest.get() );
99 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
100 = xRequest->getSelection();
102 if ( xSelection.is() )
103 throw ucb::CommandFailedException( OUString(),
104 xContext,
105 xRequest->getRequest() );
109 cppu::throwException( xRequest->getRequest() );
111 OSL_FAIL( "Return from cppu::throwException call!!!" );
112 throw uno::RuntimeException();
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */