nss: upgrade to release 3.73
[LibreOffice.git] / include / ucbhelper / interceptedinteraction.hxx
blobb6a410ca3dba3aa5dcc07cad2f1c70f5261bd04f
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 .
20 #ifndef INCLUDED_UCBHELPER_INTERCEPTEDINTERACTION_HXX
21 #define INCLUDED_UCBHELPER_INTERCEPTEDINTERACTION_HXX
23 #include <vector>
25 #include <com/sun/star/task/XInteractionHandler.hpp>
27 #include <cppuhelper/implbase.hxx>
28 #include <ucbhelper/ucbhelperdllapi.h>
30 namespace com::sun::star::task { class XInteractionRequest; }
33 namespace ucbhelper{
36 /** @short it wraps any other interaction handler and intercept
37 its handle() requests.
39 @descr This class can be used as:
40 - instance if special interactions must be suppressed
41 only
42 - or as base class if interactions must be modified.
44 class UCBHELPER_DLLPUBLIC InterceptedInteraction : public ::cppu::WeakImplHelper< css::task::XInteractionHandler >
47 // types
48 public:
50 struct InterceptedRequest
53 /** @short marks an Handle as invalid.
55 static const sal_Int32 INVALID_HANDLE = -1;
58 /** @short contains the interaction request, which should be intercepted. */
59 css::uno::Any Request;
62 /** @short specify the fix continuation, which must be selected, if the
63 interaction could be intercepted successfully.
65 css::uno::Type Continuation;
68 /** @short it's a unique identifier, which must be managed by the outside code.
70 @descr If there is a derived class, which overwrites the InterceptedInteraction::intercepted()
71 method, it will be called with a reference to an InterceptedRequest struct.
72 Then it can use the handle to react without checking the request type again.
74 sal_Int32 Handle;
77 /** @short default ctor.
79 @descr Such constructed object can't be used really.
80 Might it will crash if it's used!
81 Don't forget to initialize all(!) members...
83 InterceptedRequest()
85 Handle = INVALID_HANDLE;
91 /** @short represent the different states, which can occur
92 as result of an interception.
94 @see impl_interceptRequest()
96 enum EInterceptionState
98 /** none of the specified interceptions match the incoming request */
99 E_NOT_INTERCEPTED,
100 /** the request could be intercepted - but the specified continuation could not be located.
101 That's normally an error of the programmer. May be the interaction request does not use
102 the right set of continuations ... or the interception list contains the wrong continuation. */
103 E_NO_CONTINUATION_FOUND,
104 /** the request could be intercepted and the specified continuation could be selected successfully. */
105 E_INTERCEPTED
109 // member
110 protected:
113 /** @short reference to the intercepted interaction handler.
115 @descr NULL is allowed for this member!
116 All interaction will be aborted then ...
117 expecting th handle() was overwritten by
118 a derived class.
120 css::uno::Reference< css::task::XInteractionHandler > m_xInterceptedHandler;
123 /** @short these list contains the requests, which should be intercepted.
125 ::std::vector< InterceptedRequest > m_lInterceptions;
128 // native interface
129 public:
132 /** @short initialize a new instance with default values.
134 InterceptedInteraction();
137 /** @short initialize a new instance with the interaction handler,
138 which should be intercepted.
140 @attention If such interaction handler isn't set here,
141 all incoming requests will be aborted ...
142 if the right continuation is available!
144 @param xInterceptedHandler
145 the outside interaction handler, which should
146 be intercepted here.
148 void setInterceptedHandler(const css::uno::Reference< css::task::XInteractionHandler >& xInterceptedHandler);
151 /** @short set a new list of intercepted interactions.
153 @attention If the interface method handle() will be overwritten by
154 a derived class, the functionality behind these static list
155 can't be used.
157 @param lInterceptions
158 the list of intercepted requests.
160 void setInterceptions(const ::std::vector< InterceptedRequest >& lInterceptions);
163 /** @short extract a requested continuation from the list of available ones.
165 @param lContinuations
166 the list of available continuations.
168 @param aType
169 is used to locate the right continuation,
170 by checking its interface type.
172 @return A valid reference to the continuation, if it could be located...
173 or an empty reference otherwise.
175 static css::uno::Reference< css::task::XInteractionContinuation > extractContinuation(
176 const css::uno::Sequence< css::uno::Reference< css::task::XInteractionContinuation > >& lContinuations,
177 const css::uno::Type& aType );
180 // usable for derived classes
181 protected:
184 /** @short can be overwritten by a derived class to handle interceptions
185 outside.
187 @descr This base implementation checks, if the request could be intercepted
188 successfully. Then this method intercepted() is called.
189 The default implementation returns "NOT_INTERCEPTED" every time.
190 So the method impl_interceptRequest() uses the right continuation automatically.
192 If this method was overwritten and something different "NO_INTERCEPTED"
193 is returned, the method impl_interceptRequest() will return immediately with
194 the result, which is returned by this intercepted() method.
195 Then the continuations must be selected inside the intercepted() call!
197 @param rRequest
198 it points to the intercepted request (means the item of the
199 set interception list). e.g. its "Handle" member can be used
200 to identify it and react very easy, without the need to check the
201 type of the exception ...
203 @param xOrgRequest
204 points to the original interaction, which was intercepted.
205 It provides access to the exception and the list of possible
206 continuations.
208 @return The result of this operation.
209 Note: If E_NOT_INTERCEPTED is returned the default handling of the base class
210 will be used automatically for this request!
212 virtual EInterceptionState intercepted(const InterceptedRequest& rRequest ,
213 const css::uno::Reference< css::task::XInteractionRequest >& xOrgRequest);
216 // uno interface
217 public:
220 /** @short implements the default handling of this class...
221 or can be overwritten by any derived class.
223 @descr If no further class is derived from this one
224 -> the default implementation is used. Then the
225 internal list of requests is used to handle different
226 interactions automatically.
227 (see impl_interceptRequest())
229 If this method was overwritten by a derived implementation
230 -> the new implementation has to do everything by itself.
231 Of course it can access all members/helpers and work with it.
232 But the default implementation is not used automatically then.
234 @param xRequest
235 the interaction request, which should be intercepted.
237 virtual void SAL_CALL handle(const css::uno::Reference< css::task::XInteractionRequest >& xRequest) override;
240 // helper
241 private:
244 /** @short implements the default handling:
245 - intercept or forward to internal handler.
247 UCBHELPER_DLLPRIVATE void impl_handleDefault(const css::uno::Reference< css::task::XInteractionRequest >& xRequest);
250 /** @short implements the interception of requests.
252 @descr The incoming request will be analyzed, if it match
253 any request of the m_lIntercepions list.
254 If an interception could be found, its continuation will be
255 searched and selected.
257 The method return the state of that operation.
258 But it doesn't call the intercepted and here set
259 interaction handler. That has to be done in the outside method.
261 @param xRequest
262 the interaction request, which should be intercepted.
264 @return A identifier, which indicates if the request was intercepted,
265 the continuation was found and selected... or not.
267 UCBHELPER_DLLPRIVATE EInterceptionState impl_interceptRequest(const css::uno::Reference< css::task::XInteractionRequest >& xRequest);
270 } // namespace ucbhelper
272 #endif // INCLUDED_UCBHELPER_INTERCEPTEDINTERACTION_HXX
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */