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#include <osl/diagnose.h>
21#include <rtl/ref.hxx>
23#include <com/sun/star/ucb/CommandFailedException.hpp>
24#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
25#include <com/sun/star/ucb/XCommandEnvironment.hpp>
26#include <com/sun/star/ucb/XCommandProcessor.hpp>
30
31using namespace com::sun::star;
32
33namespace ucbhelper
34{
35
36
37void cancelCommandExecution( const uno::Any & rException,
38 const uno::Reference<
39 ucb::XCommandEnvironment > & xEnv )
40{
41 if ( xEnv.is() )
42 {
43 uno::Reference<
44 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
45 if ( xIH.is() )
46 {
48 = new ucbhelper::InteractionRequest( rException );
49
50 xRequest->setContinuations({ new ucbhelper::InteractionAbort(xRequest.get()) });
51
52 xIH->handle( xRequest );
53
55 = xRequest->getSelection();
56
57 if ( xSelection.is() )
58 throw ucb::CommandFailedException(
59 OUString(),
60 uno::Reference< uno::XInterface >(),
61 rException );
62 }
63 }
64
65 cppu::throwException( rException );
66 OSL_FAIL( "Return from cppu::throwException call!!!" );
67 throw uno::RuntimeException();
68}
69
70
71void cancelCommandExecution( const ucb::IOErrorCode eError,
72 const uno::Sequence< uno::Any > & rArgs,
73 const uno::Reference<
74 ucb::XCommandEnvironment > & xEnv,
75 const OUString & rMessage,
76 const uno::Reference<
77 ucb::XCommandProcessor > & xContext )
78{
79 if ( !xEnv )
80 {
81 // Fast path
82
83 ucb::InteractiveAugmentedIOException aRequest;
84 aRequest.Message = rMessage;
85 aRequest.Context = xContext;
86 aRequest.Classification = task::InteractionClassification_ERROR;
87 aRequest.Code = eError;
88 aRequest.Arguments = rArgs;
89 cppu::throwException( uno::Any( aRequest ) );
90 }
91 else
92 {
95 eError, rArgs, rMessage, xContext );
96 uno::Reference<
97 task::XInteractionHandler > xIH = xEnv->getInteractionHandler();
98 if ( xIH.is() )
99 {
100 xIH->handle( xRequest );
101
103 = xRequest->getSelection();
104
105 if ( xSelection.is() )
106 throw ucb::CommandFailedException( OUString(),
107 xContext,
108 xRequest->getRequest() );
109 }
110 cppu::throwException( xRequest->getRequest() );
111 }
112
113 OSL_FAIL( "Return from cppu::throwException call!!!" );
114 throw uno::RuntimeException();
115}
116
117}
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class implements a standard interaction continuation, namely the interface XInteractionAbort.
This class implements the interface XInteractionRequest.
This class implements a simple IO error interaction request.
void SAL_CALL throwException(Any const &exc)
void cancelCommandExecution(const uno::Any &rException, const uno::Reference< ucb::XCommandEnvironment > &xEnv)