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