Branch data 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 XInteractionHandler;
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::Sequence< com::sun::star::uno::Any > m_aProperties;
92 : : StringHashMap m_aTypedCustomHandlers;
93 : : UUIInteractionHelper(UUIInteractionHelper &); // not implemented
94 : : void operator =(UUIInteractionHelper); // not implemented
95 : :
96 : : public:
97 : : UUIInteractionHelper(
98 : : com::sun::star::uno::Reference<
99 : : com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory,
100 : : com::sun::star::uno::Sequence<
101 : : com::sun::star::uno::Any > const & rArguments)
102 : : SAL_THROW(());
103 : : UUIInteractionHelper(
104 : : com::sun::star::uno::Reference<
105 : : com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory)
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< rtl::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 ::rtl::OUString
124 : : replaceMessageWithArguments(
125 : : ::rtl::OUString aMessage,
126 : : std::vector< rtl::OUString > const & rArguments );
127 : :
128 : : private:
129 : : bool
130 : : handleRequest_impl(
131 : : com::sun::star::uno::Reference<
132 : : com::sun::star::task::XInteractionRequest > const & rRequest,
133 : : bool bObtainErrorStringOnly,
134 : : bool & bHasErrorString,
135 : : rtl::OUString & rErrorString)
136 : : SAL_THROW((com::sun::star::uno::RuntimeException));
137 : :
138 : : static long
139 : : handlerequest(void* pHandleData, void* pInteractionHandler);
140 : :
141 : : com::sun::star::beans::Optional< rtl::OUString >
142 : : getStringFromRequest_impl(
143 : : com::sun::star::uno::Reference<
144 : : com::sun::star::task::XInteractionRequest > const & rRequest)
145 : : SAL_THROW((com::sun::star::uno::RuntimeException));
146 : :
147 : : static long
148 : : getstringfromrequest(void* pHandleData, void* pInteractionHandler);
149 : :
150 : : Window *
151 : : getParentProperty()
152 : : SAL_THROW(());
153 : :
154 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>
155 : : getParentXWindow() const
156 : : SAL_THROW(());
157 : :
158 : : rtl::OUString
159 : : getContextProperty()
160 : : SAL_THROW(());
161 : :
162 : : com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >
163 : : getInteractionHandler()
164 : : SAL_THROW((com::sun::star::uno::RuntimeException));
165 : :
166 : : bool handleTypedHandlerImplementations(
167 : : ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & rRequest
168 : : );
169 : :
170 : : bool
171 : : tryOtherInteractionHandler(
172 : : com::sun::star::uno::Reference<
173 : : com::sun::star::task::XInteractionRequest > const & rRequest)
174 : : SAL_THROW((com::sun::star::uno::RuntimeException));
175 : :
176 : : void
177 : : getInteractionHandlerList(InteractionHandlerDataList &rdataList)
178 : : SAL_THROW((com::sun::star::uno::RuntimeException));
179 : :
180 : : static bool
181 : : isInformationalErrorMessageRequest(
182 : : com::sun::star::uno::Sequence<
183 : : com::sun::star::uno::Reference<
184 : : com::sun::star::task::XInteractionContinuation > > const &
185 : : rContinuations);
186 : :
187 : : //=====================================================================
188 : :
189 : : bool
190 : : handleInteractiveIOException(
191 : : com::sun::star::uno::Reference<
192 : : com::sun::star::task::XInteractionRequest > const & rRequest,
193 : : bool bObtainErrorStringOnly,
194 : : bool & bHasErrorString,
195 : : rtl::OUString & rErrorString)
196 : : SAL_THROW((com::sun::star::uno::RuntimeException));
197 : :
198 : : bool
199 : : handleAuthenticationRequest(
200 : : com::sun::star::uno::Reference<
201 : : com::sun::star::task::XInteractionRequest > const & rRequest)
202 : : SAL_THROW((com::sun::star::uno::RuntimeException));
203 : :
204 : : bool
205 : : handleCertificateValidationRequest(
206 : : com::sun::star::uno::Reference<
207 : : com::sun::star::task::XInteractionRequest > const & rRequest)
208 : : SAL_THROW((com::sun::star::uno::RuntimeException));
209 : :
210 : : void
211 : : handleNameClashResolveRequest(
212 : : com::sun::star::ucb::NameClashResolveRequest const & rRequest,
213 : : com::sun::star::uno::Sequence<
214 : : com::sun::star::uno::Reference<
215 : : com::sun::star::task::XInteractionContinuation > > const &
216 : : rContinuations)
217 : : SAL_THROW((com::sun::star::uno::RuntimeException));
218 : :
219 : : bool
220 : : handleMasterPasswordRequest(
221 : : com::sun::star::uno::Reference<
222 : : com::sun::star::task::XInteractionRequest > const & rRequest)
223 : : SAL_THROW((com::sun::star::uno::RuntimeException));
224 : :
225 : : bool
226 : : handlePasswordRequest(
227 : : com::sun::star::uno::Reference<
228 : : com::sun::star::task::XInteractionRequest > const & rRequest)
229 : : SAL_THROW((com::sun::star::uno::RuntimeException));
230 : :
231 : : bool
232 : : handleNoSuchFilterRequest(
233 : : com::sun::star::uno::Reference<
234 : : com::sun::star::task::XInteractionRequest > const & rRequest)
235 : : SAL_THROW((com::sun::star::uno::RuntimeException));
236 : :
237 : : bool
238 : : handleAmbigousFilterRequest(
239 : : com::sun::star::uno::Reference<
240 : : com::sun::star::task::XInteractionRequest > const & rRequest)
241 : : SAL_THROW((com::sun::star::uno::RuntimeException));
242 : :
243 : : bool
244 : : handleFilterOptionsRequest(
245 : : com::sun::star::uno::Reference<
246 : : com::sun::star::task::XInteractionRequest > const & rRequest)
247 : : SAL_THROW((com::sun::star::uno::RuntimeException));
248 : :
249 : : void
250 : : handleErrorHandlerRequest(
251 : : com::sun::star::task::InteractionClassification eClassification,
252 : : ErrCode nErrorCode,
253 : : std::vector< rtl::OUString > const & rArguments,
254 : : com::sun::star::uno::Sequence<
255 : : com::sun::star::uno::Reference<
256 : : com::sun::star::task::XInteractionContinuation > > const &
257 : : rContinuations,
258 : : bool bObtainErrorStringOnly,
259 : : bool & bHasErrorString,
260 : : rtl::OUString & rErrorString)
261 : : SAL_THROW((com::sun::star::uno::RuntimeException));
262 : :
263 : : void
264 : : handleGenericErrorRequest(
265 : : sal_Int32 nErrorCode,
266 : : com::sun::star::uno::Sequence<
267 : : com::sun::star::uno::Reference<
268 : : com::sun::star::task::XInteractionContinuation > > const &
269 : : rContinuations,
270 : : bool bObtainErrorStringOnly,
271 : : bool & bHasErrorString,
272 : : rtl::OUString & rErrorString)
273 : : SAL_THROW((com::sun::star::uno::RuntimeException));
274 : :
275 : : void
276 : : handleMacroConfirmRequest(
277 : : const ::rtl::OUString& aDocumentURL,
278 : : const ::com::sun::star::uno::Reference<
279 : : ::com::sun::star::embed::XStorage >& xZipStorage,
280 : : const ::rtl::OUString& aDocumentVersion,
281 : : const ::com::sun::star::uno::Sequence<
282 : : ::com::sun::star::security::DocumentSignatureInformation >
283 : : aSignInfo,
284 : : com::sun::star::uno::Sequence<
285 : : com::sun::star::uno::Reference<
286 : : com::sun::star::task::XInteractionContinuation > > const &
287 : : rContinuations)
288 : : SAL_THROW((com::sun::star::uno::RuntimeException));
289 : :
290 : : void
291 : : handleFutureDocumentVersionUpdateRequest(
292 : : const ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest&
293 : : _rRequest,
294 : : com::sun::star::uno::Sequence<
295 : : com::sun::star::uno::Reference<
296 : : com::sun::star::task::XInteractionContinuation > > const &
297 : : rContinuations)
298 : : SAL_THROW((com::sun::star::uno::RuntimeException));
299 : :
300 : : void
301 : : handleBrokenPackageRequest(
302 : : std::vector< rtl::OUString > const & rArguments,
303 : : ::com::sun::star::uno::Sequence<
304 : : ::com::sun::star::uno::Reference<
305 : : ::com::sun::star::task::XInteractionContinuation > > const &
306 : : rContinuations,
307 : : bool bObtainErrorStringOnly,
308 : : bool & bHasErrorString,
309 : : rtl::OUString & rErrorString)
310 : : SAL_THROW((::com::sun::star::uno::RuntimeException));
311 : :
312 : : bool handleLockedDocumentRequest(
313 : : com::sun::star::uno::Reference<
314 : : com::sun::star::task::XInteractionRequest > const & rRequest)
315 : : SAL_THROW((::com::sun::star::uno::RuntimeException));
316 : :
317 : : bool handleChangedByOthersRequest(
318 : : com::sun::star::uno::Reference<
319 : : com::sun::star::task::XInteractionRequest > const & rRequest)
320 : : SAL_THROW((::com::sun::star::uno::RuntimeException));
321 : :
322 : : bool handleLockFileIgnoreRequest(
323 : : com::sun::star::uno::Reference<
324 : : com::sun::star::task::XInteractionRequest > const & rRequest)
325 : : SAL_THROW((::com::sun::star::uno::RuntimeException));
326 : :
327 : : bool handleCustomRequest(
328 : : const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_rRequest,
329 : : const ::rtl::OUString& i_rServiceName
330 : : ) const;
331 : : };
332 : :
333 : : class ErrorResource: private Resource
334 : : {
335 : : public:
336 : 0 : inline ErrorResource(ResId & rResId) SAL_THROW(()): Resource(rResId) {}
337 : :
338 [ # # ]: 0 : inline ~ErrorResource() SAL_THROW(()) { FreeResource(); }
339 : :
340 : : bool getString(ErrCode nErrorCode, rtl::OUString &rString) const
341 : : SAL_THROW(());
342 : : };
343 : :
344 : : #endif // UUI_IAHNDL_HXX
345 : :
346 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|