LibreOffice Module ucbhelper (master)  1
cancelcommandexecution.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
21 /**************************************************************************
22  TODO
23  **************************************************************************
24 
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>
33 #include "simpleioerrorrequest.hxx"
34 
35 using namespace com::sun::star;
36 
37 namespace ucbhelper
38 {
39 
40 
41 void cancelCommandExecution( const uno::Any & rException,
42  const uno::Reference<
43  ucb::XCommandEnvironment > & xEnv )
44 {
45  if ( xEnv.is() )
46  {
47  uno::Reference<
48  task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
49  if ( xIH.is() )
50  {
52  = new ucbhelper::InteractionRequest( rException );
53 
54  uno::Sequence< uno::Reference< task::XInteractionContinuation > >
55  aContinuations( 1 );
56  aContinuations[ 0 ]
57  = new ucbhelper::InteractionAbort( xRequest.get() );
58 
59  xRequest->setContinuations( aContinuations );
60 
61  xIH->handle( xRequest.get() );
62 
64  = xRequest->getSelection();
65 
66  if ( xSelection.is() )
67  throw ucb::CommandFailedException(
68  OUString(),
69  uno::Reference< uno::XInterface >(),
70  rException );
71  }
72  }
73 
74  cppu::throwException( rException );
75  OSL_FAIL( "Return from cppu::throwException call!!!" );
76  throw uno::RuntimeException();
77 }
78 
79 
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 )
87 {
90  eError, rArgs, rMessage, xContext );
91  if ( xEnv.is() )
92  {
93  uno::Reference<
94  task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
95  if ( xIH.is() )
96  {
97  xIH->handle( xRequest.get() );
98 
100  = xRequest->getSelection();
101 
102  if ( xSelection.is() )
103  throw ucb::CommandFailedException( OUString(),
104  xContext,
105  xRequest->getRequest() );
106  }
107  }
108 
109  cppu::throwException( xRequest->getRequest() );
110 
111  OSL_FAIL( "Return from cppu::throwException call!!!" );
112  throw uno::RuntimeException();
113 }
114 
115 }
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SAL_CALL throwException(Any const &exc)
This class implements the interface XInteractionRequest.
void cancelCommandExecution(const ucb::IOErrorCode eError, const uno::Sequence< uno::Any > &rArgs, const uno::Reference< ucb::XCommandEnvironment > &xEnv, const OUString &rMessage, const uno::Reference< ucb::XCommandProcessor > &xContext)
This class implements a simple IO error interaction request.
This class implements a standard interaction continuation, namely the interface XInteractionAbort.