Line data Source code
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 : #ifndef UUI_IAHNDL_HXX
21 : #define UUI_IAHNDL_HXX
22 :
23 : #include <vector>
24 :
25 : #include "osl/mutex.hxx"
26 : #include "rtl/ustring.hxx"
27 :
28 : #include "com/sun/star/uno/Reference.hxx"
29 : #include "com/sun/star/uno/Sequence.hxx"
30 : #include "com/sun/star/uno/XComponentContext.hpp"
31 :
32 : #include "com/sun/star/beans/Optional.hpp"
33 : #include "com/sun/star/task/InteractionClassification.hpp"
34 :
35 : #include "tools/errcode.hxx"
36 : #include "tools/rc.hxx"
37 : #include "tools/wintypes.hxx"
38 :
39 : namespace com { namespace sun { namespace star {
40 : namespace awt {
41 : class XWindow;
42 : }
43 : namespace embed {
44 : class XStorage;
45 : }
46 : namespace lang {
47 : class XMultiServiceFactory;
48 : }
49 : namespace security {
50 : struct DocumentSignatureInformation;
51 : }
52 : namespace task {
53 : class FutureDocumentVersionProductUpdateRequest;
54 : class XInteractionContinuation;
55 : class XInteractionHandler2;
56 : class XInteractionRequest;
57 : }
58 : namespace ucb {
59 : class NameClashResolveRequest;
60 : }
61 : } } }
62 :
63 : #include <boost/unordered_map.hpp>
64 :
65 : class Window;
66 :
67 0 : struct InteractionHandlerData
68 : {
69 : /** The UNO service name to use to instanciate the content provider.
70 : */
71 : OUString ServiceName;
72 :
73 0 : InteractionHandlerData() {};
74 : InteractionHandlerData(const OUString & rService)
75 : : ServiceName( rService ){}
76 : };
77 :
78 : typedef std::vector< InteractionHandlerData > InteractionHandlerDataList;
79 :
80 : typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > Continuations;
81 :
82 : typedef ::boost::unordered_map< OUString, OUString, OUStringHash > StringHashMap;
83 :
84 : class UUIInteractionHelper
85 : {
86 : private:
87 : mutable osl::Mutex m_aPropertyMutex;
88 : ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > m_xContext;
89 : ::com::sun::star::uno::Reference< com::sun::star::awt::XWindow > m_xWindowParam;
90 : const OUString m_aContextParam;
91 : StringHashMap m_aTypedCustomHandlers;
92 : UUIInteractionHelper(UUIInteractionHelper &); // not implemented
93 : void operator =(UUIInteractionHelper); // not implemented
94 :
95 : public:
96 : UUIInteractionHelper(
97 : com::sun::star::uno::Reference<
98 : com::sun::star::uno::XComponentContext > const & rxContext,
99 : com::sun::star::uno::Reference<
100 : com::sun::star::awt::XWindow > const & rxWindow,
101 : const OUString & rContextParam)
102 : SAL_THROW(());
103 : UUIInteractionHelper(
104 : com::sun::star::uno::Reference<
105 : com::sun::star::uno::XComponentContext > const & rxContext)
106 : SAL_THROW(());
107 :
108 : ~UUIInteractionHelper() SAL_THROW(());
109 :
110 : bool
111 : handleRequest(
112 : com::sun::star::uno::Reference<
113 : com::sun::star::task::XInteractionRequest > const & rRequest)
114 : SAL_THROW((com::sun::star::uno::RuntimeException));
115 :
116 : com::sun::star::beans::Optional< OUString >
117 : getStringFromRequest(
118 : com::sun::star::uno::Reference<
119 : com::sun::star::task::XInteractionRequest > const & rRequest)
120 : SAL_THROW((com::sun::star::uno::RuntimeException));
121 :
122 : // Helper.
123 : static OUString
124 : replaceMessageWithArguments(
125 : const OUString& aMessage,
126 : std::vector< OUString > const & rArguments );
127 :
128 : ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
129 0 : getORB() const
130 0 : { return m_xContext; }
131 : private:
132 : bool
133 : handleRequest_impl(
134 : com::sun::star::uno::Reference<
135 : com::sun::star::task::XInteractionRequest > const & rRequest,
136 : bool bObtainErrorStringOnly,
137 : bool & bHasErrorString,
138 : OUString & rErrorString)
139 : SAL_THROW((com::sun::star::uno::RuntimeException));
140 :
141 : static long
142 : handlerequest(void* pHandleData, void* pInteractionHandler);
143 :
144 : com::sun::star::beans::Optional< OUString >
145 : getStringFromRequest_impl(
146 : com::sun::star::uno::Reference<
147 : com::sun::star::task::XInteractionRequest > const & rRequest)
148 : SAL_THROW((com::sun::star::uno::RuntimeException));
149 :
150 : static long
151 : getstringfromrequest(void* pHandleData, void* pInteractionHandler);
152 :
153 : Window *
154 : getParentProperty()
155 : SAL_THROW(());
156 :
157 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>
158 : getParentXWindow() const
159 : SAL_THROW(());
160 :
161 : OUString
162 : getContextProperty()
163 : SAL_THROW(());
164 :
165 : com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler2 >
166 : getInteractionHandler()
167 : SAL_THROW((com::sun::star::uno::RuntimeException));
168 :
169 : bool handleTypedHandlerImplementations(
170 : ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & rRequest
171 : );
172 :
173 : bool
174 : tryOtherInteractionHandler(
175 : com::sun::star::uno::Reference<
176 : com::sun::star::task::XInteractionRequest > const & rRequest)
177 : SAL_THROW((com::sun::star::uno::RuntimeException));
178 :
179 : void
180 : getInteractionHandlerList(InteractionHandlerDataList &rdataList)
181 : SAL_THROW((com::sun::star::uno::RuntimeException));
182 :
183 : static bool
184 : isInformationalErrorMessageRequest(
185 : com::sun::star::uno::Sequence<
186 : com::sun::star::uno::Reference<
187 : com::sun::star::task::XInteractionContinuation > > const &
188 : rContinuations);
189 :
190 : bool
191 : handleInteractiveIOException(
192 : com::sun::star::uno::Reference<
193 : com::sun::star::task::XInteractionRequest > const & rRequest,
194 : bool bObtainErrorStringOnly,
195 : bool & bHasErrorString,
196 : OUString & rErrorString)
197 : SAL_THROW((com::sun::star::uno::RuntimeException));
198 :
199 : bool
200 : handleAuthenticationRequest(
201 : com::sun::star::uno::Reference<
202 : com::sun::star::task::XInteractionRequest > const & rRequest)
203 : SAL_THROW((com::sun::star::uno::RuntimeException));
204 :
205 : bool
206 : handleCertificateValidationRequest(
207 : com::sun::star::uno::Reference<
208 : com::sun::star::task::XInteractionRequest > const & rRequest)
209 : SAL_THROW((com::sun::star::uno::RuntimeException));
210 :
211 : void
212 : handleNameClashResolveRequest(
213 : com::sun::star::ucb::NameClashResolveRequest const & rRequest,
214 : com::sun::star::uno::Sequence<
215 : com::sun::star::uno::Reference<
216 : com::sun::star::task::XInteractionContinuation > > const &
217 : rContinuations)
218 : SAL_THROW((com::sun::star::uno::RuntimeException));
219 :
220 : bool
221 : handleMasterPasswordRequest(
222 : com::sun::star::uno::Reference<
223 : com::sun::star::task::XInteractionRequest > const & rRequest)
224 : SAL_THROW((com::sun::star::uno::RuntimeException));
225 :
226 : bool
227 : handlePasswordRequest(
228 : com::sun::star::uno::Reference<
229 : com::sun::star::task::XInteractionRequest > const & rRequest)
230 : SAL_THROW((com::sun::star::uno::RuntimeException));
231 :
232 : bool
233 : handleNoSuchFilterRequest(
234 : com::sun::star::uno::Reference<
235 : com::sun::star::task::XInteractionRequest > const & rRequest)
236 : SAL_THROW((com::sun::star::uno::RuntimeException));
237 :
238 : bool
239 : handleAmbigousFilterRequest(
240 : com::sun::star::uno::Reference<
241 : com::sun::star::task::XInteractionRequest > const & rRequest)
242 : SAL_THROW((com::sun::star::uno::RuntimeException));
243 :
244 : bool
245 : handleFilterOptionsRequest(
246 : com::sun::star::uno::Reference<
247 : com::sun::star::task::XInteractionRequest > const & rRequest)
248 : SAL_THROW((com::sun::star::uno::RuntimeException));
249 :
250 : void
251 : handleErrorHandlerRequest(
252 : com::sun::star::task::InteractionClassification eClassification,
253 : ErrCode nErrorCode,
254 : std::vector< OUString > const & rArguments,
255 : com::sun::star::uno::Sequence<
256 : com::sun::star::uno::Reference<
257 : com::sun::star::task::XInteractionContinuation > > const &
258 : rContinuations,
259 : bool bObtainErrorStringOnly,
260 : bool & bHasErrorString,
261 : OUString & rErrorString)
262 : SAL_THROW((com::sun::star::uno::RuntimeException));
263 :
264 : void
265 : handleGenericErrorRequest(
266 : sal_Int32 nErrorCode,
267 : com::sun::star::uno::Sequence<
268 : com::sun::star::uno::Reference<
269 : com::sun::star::task::XInteractionContinuation > > const &
270 : rContinuations,
271 : bool bObtainErrorStringOnly,
272 : bool & bHasErrorString,
273 : OUString & rErrorString)
274 : SAL_THROW((com::sun::star::uno::RuntimeException));
275 :
276 : void
277 : handleMacroConfirmRequest(
278 : const OUString& aDocumentURL,
279 : const ::com::sun::star::uno::Reference<
280 : ::com::sun::star::embed::XStorage >& xZipStorage,
281 : const OUString& aDocumentVersion,
282 : const ::com::sun::star::uno::Sequence<
283 : ::com::sun::star::security::DocumentSignatureInformation >
284 : aSignInfo,
285 : com::sun::star::uno::Sequence<
286 : com::sun::star::uno::Reference<
287 : com::sun::star::task::XInteractionContinuation > > const &
288 : rContinuations)
289 : SAL_THROW((com::sun::star::uno::RuntimeException));
290 :
291 : void
292 : handleFutureDocumentVersionUpdateRequest(
293 : const ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest&
294 : _rRequest,
295 : com::sun::star::uno::Sequence<
296 : com::sun::star::uno::Reference<
297 : com::sun::star::task::XInteractionContinuation > > const &
298 : rContinuations)
299 : SAL_THROW((com::sun::star::uno::RuntimeException));
300 :
301 : void
302 : handleBrokenPackageRequest(
303 : std::vector< OUString > const & rArguments,
304 : ::com::sun::star::uno::Sequence<
305 : ::com::sun::star::uno::Reference<
306 : ::com::sun::star::task::XInteractionContinuation > > const &
307 : rContinuations,
308 : bool bObtainErrorStringOnly,
309 : bool & bHasErrorString,
310 : OUString & rErrorString)
311 : SAL_THROW((::com::sun::star::uno::RuntimeException));
312 :
313 : bool handleLockedDocumentRequest(
314 : com::sun::star::uno::Reference<
315 : com::sun::star::task::XInteractionRequest > const & rRequest)
316 : SAL_THROW((::com::sun::star::uno::RuntimeException));
317 :
318 : bool handleChangedByOthersRequest(
319 : com::sun::star::uno::Reference<
320 : com::sun::star::task::XInteractionRequest > const & rRequest)
321 : SAL_THROW((::com::sun::star::uno::RuntimeException));
322 :
323 : bool handleLockFileIgnoreRequest(
324 : com::sun::star::uno::Reference<
325 : com::sun::star::task::XInteractionRequest > const & rRequest)
326 : SAL_THROW((::com::sun::star::uno::RuntimeException));
327 :
328 : bool handleCustomRequest(
329 : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_rRequest,
330 : const OUString& i_rServiceName
331 : ) const;
332 : };
333 :
334 : class ErrorResource: private Resource
335 : {
336 : public:
337 0 : inline ErrorResource(ResId & rResId) SAL_THROW(()): Resource(rResId) {}
338 :
339 0 : inline ~ErrorResource() SAL_THROW(()) { FreeResource(); }
340 :
341 : bool getString(ErrCode nErrorCode, OUString &rString) const
342 : SAL_THROW(());
343 : };
344 :
345 : #endif // UUI_IAHNDL_HXX
346 :
347 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|