lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / ucbhelper / source / provider / cancelcommandexecution.cxx
blobb55c50fd4f80f20716b20a446c184990edc23c25
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/lang/IllegalArgumentException.hpp>
30 #include <com/sun/star/ucb/CommandFailedException.hpp>
31 #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
32 #include <com/sun/star/ucb/NameClashException.hpp>
33 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
34 #include <ucbhelper/interactionrequest.hxx>
35 #include <ucbhelper/cancelcommandexecution.hxx>
36 #include <ucbhelper/simpleioerrorrequest.hxx>
38 using namespace com::sun::star;
40 namespace ucbhelper
44 void cancelCommandExecution( const uno::Any & rException,
45 const uno::Reference<
46 ucb::XCommandEnvironment > & xEnv )
48 if ( xEnv.is() )
50 uno::Reference<
51 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
52 if ( xIH.is() )
54 rtl::Reference< ucbhelper::InteractionRequest > xRequest
55 = new ucbhelper::InteractionRequest( rException );
57 uno::Sequence< uno::Reference< task::XInteractionContinuation > >
58 aContinuations( 1 );
59 aContinuations[ 0 ]
60 = new ucbhelper::InteractionAbort( xRequest.get() );
62 xRequest->setContinuations( aContinuations );
64 xIH->handle( xRequest.get() );
66 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
67 = xRequest->getSelection();
69 if ( xSelection.is() )
70 throw ucb::CommandFailedException(
71 OUString(),
72 uno::Reference< uno::XInterface >(),
73 rException );
77 cppu::throwException( rException );
78 OSL_FAIL( "Return from cppu::throwException call!!!" );
79 throw uno::RuntimeException();
83 void cancelCommandExecution( const ucb::IOErrorCode eError,
84 const uno::Sequence< uno::Any > & rArgs,
85 const uno::Reference<
86 ucb::XCommandEnvironment > & xEnv,
87 const OUString & rMessage,
88 const uno::Reference<
89 ucb::XCommandProcessor > & xContext )
91 rtl::Reference< ucbhelper::SimpleIOErrorRequest > xRequest
92 = new ucbhelper::SimpleIOErrorRequest(
93 eError, rArgs, rMessage, xContext );
94 if ( xEnv.is() )
96 uno::Reference<
97 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
98 if ( xIH.is() )
100 xIH->handle( xRequest.get() );
102 rtl::Reference< ucbhelper::InteractionContinuation > xSelection
103 = xRequest->getSelection();
105 if ( xSelection.is() )
106 throw ucb::CommandFailedException( OUString(),
107 xContext,
108 xRequest->getRequest() );
112 cppu::throwException( xRequest->getRequest() );
114 OSL_FAIL( "Return from cppu::throwException call!!!" );
115 throw uno::RuntimeException();
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */