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