1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
25 #define _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
26 
27 #include <com/sun/star/uno/Reference.hxx>
28 #include <com/sun/star/uno/Exception.hpp>
29 #include <com/sun/star/ucb/IOErrorCode.hpp>
30 #include <com/sun/star/ucb/XCommandProcessor.hpp>
31 #include "ucbhelper/ucbhelperdllapi.h"
32 
33 namespace com { namespace sun { namespace star {
34     namespace uno { class Any; }
35     namespace ucb { class XCommandEnvironment; }
36 } } }
37 
38 namespace ucbhelper
39 {
40 
41 //============================================================================
42 /** Cancel the execution of a command by throwing the appropriate exception.
43     If an Interaction Handler is given with the command environment and the
44     handler handles the exception by selecting the supplied continuation,
45     then this function will put the original exception supplied into a
46     com::sun::star::ucb::CommandFailedException and throw the
47     CommandFailedException. If no handler was given or the handler was not
48     able to handle the exception, then the given exception will be thrown
49     directly.
50 
51     NOTE THAT THIS FUNCTION NEVER RETURNS! IT ALWAYS THROWS AN EXCEPTION!
52 
53     @param rException is the exception describing the error to handle.
54 
55     @param xEnv is the command environment that may contain an Interaction
56            Handler to use before throwing the appropriate exception.
57  */
58 UCBHELPER_DLLPUBLIC void cancelCommandExecution( const com::sun::star::uno::Any & rException,
59                              const com::sun::star::uno::Reference<
60                                 com::sun::star::ucb::XCommandEnvironment > &
61                                     xEnv )
62     throw( com::sun::star::uno::Exception );
63 
64 /** Cancel the execution of a command by throwing the appropriate exception.
65     If an Interaction Handler is given with the command environment and the
66     handler handles the exception by selecting the supplied continuation,
67     then this function will put the original exception supplied into a
68     com::sun::star::ucb::CommandFailedException and throw the
69     CommandFailedException. If no handler was given or the handler was not
70     able to handle the exception, then the given exception will be thrown
71     directly.
72 
73     NOTE THAT THIS FUNCTION NEVER RETURNS! IT ALWAYS THROWS AN EXCEPTION!
74 
75     @param eError is an IO error code.
76 
77     @param rArgs is a sequeence containing the arguments to pass along with
78            the exception. Each IO error code can be combined with one or
79            more additional arguments. Refer to com/sun/star/ucb/IOErroprCode.idl
80            for details.
81 
82     @param xEnv is the command environment that may contain an Interaction
83            Handler to use before throwing the appropriate exception.
84 
85     @param rMessage is a text containing additional error information.
86            Used as debugging aid only. Passed to the member 'Message' of the
87            uno::Exception thrown by this function.
88 
89     @param xContext is the command processor executing the command to cancel.
90            Used as debugging aid only. Passed to the member 'Context' of the
91            uno::Exception thrown by this function.
92  */
93 UCBHELPER_DLLPUBLIC void cancelCommandExecution( const com::sun::star::ucb::IOErrorCode eError,
94                              const com::sun::star::uno::Sequence<
95                                 com::sun::star::uno::Any > & rArgs,
96                              const com::sun::star::uno::Reference<
97                                 com::sun::star::ucb::XCommandEnvironment > &
98                                     xEnv,
99                              const rtl::OUString & rMessage = rtl::OUString(),
100                              const com::sun::star::uno::Reference<
101                                 com::sun::star::ucb::XCommandProcessor > &
102                                     xContext = 0 )
103     throw( com::sun::star::uno::Exception );
104 }
105 
106 #endif // _UCBHELPER_CANCELCOMMANDEXECUTION_HXX_
107