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