xref: /aoo41x/main/uui/source/iahndl.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef UUI_IAHNDL_HXX
29 #define UUI_IAHNDL_HXX
30 
31 #include <vector>
32 
33 #include "osl/mutex.hxx"
34 #include "rtl/ustring.hxx"
35 
36 #include "com/sun/star/uno/Reference.hxx"
37 #include "com/sun/star/uno/Sequence.hxx"
38 
39 #include "com/sun/star/beans/Optional.hpp"
40 #include "com/sun/star/task/InteractionClassification.hpp"
41 
42 #include "tools/solar.h" // sal_uInt16
43 #include "tools/errcode.hxx" // ErrCode
44 #include "tools/rc.hxx" // Resource
45 #include "tools/wintypes.hxx" // WinBits
46 
47 namespace com { namespace sun { namespace star {
48     namespace awt {
49         class XWindow;
50     }
51     namespace embed {
52         class XStorage;
53     }
54     namespace lang {
55         class XMultiServiceFactory;
56     }
57     namespace security {
58         class DocumentSignatureInformation;
59     }
60     namespace task {
61         class FutureDocumentVersionProductUpdateRequest;
62         class XInteractionContinuation;
63         class XInteractionHandler;
64         class XInteractionRequest;
65     }
66     namespace ucb {
67         class NameClashResolveRequest;
68     }
69 } } }
70 
71 #include <hash_map>
72 
73 class Window;
74 
75 //============================================================================
76 struct InteractionHandlerData
77 {
78     /** The UNO service name to use to instanciate the content provider.
79      */
80     rtl::OUString ServiceName;
81 
82     InteractionHandlerData() {};
83     InteractionHandlerData(const rtl::OUString & rService)
84     : ServiceName( rService ){}
85 };
86 
87 typedef std::vector< InteractionHandlerData > InteractionHandlerDataList;
88 
89 typedef ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > Continuations;
90 
91 typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >    StringHashMap;
92 
93 //============================================================================
94 class UUIInteractionHelper
95 {
96 private:
97     mutable osl::Mutex                                                                      m_aPropertyMutex;
98             ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >  m_xServiceFactory;
99             ::com::sun::star::uno::Sequence< com::sun::star::uno::Any >                     m_aProperties;
100             StringHashMap                                                                   m_aTypedCustomHandlers;
101     UUIInteractionHelper(UUIInteractionHelper &); // not implemented
102     void operator =(UUIInteractionHelper); // not implemented
103 
104 public:
105     UUIInteractionHelper(
106         com::sun::star::uno::Reference<
107             com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory,
108         com::sun::star::uno::Sequence<
109             com::sun::star::uno::Any > const & rArguments)
110         SAL_THROW(());
111     UUIInteractionHelper(
112         com::sun::star::uno::Reference<
113             com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory)
114         SAL_THROW(());
115 
116     ~UUIInteractionHelper() SAL_THROW(());
117 
118     bool
119     handleRequest(
120         com::sun::star::uno::Reference<
121             com::sun::star::task::XInteractionRequest > const & rRequest)
122         SAL_THROW((com::sun::star::uno::RuntimeException));
123 
124     com::sun::star::beans::Optional< rtl::OUString >
125     getStringFromRequest(
126         com::sun::star::uno::Reference<
127             com::sun::star::task::XInteractionRequest > const & rRequest)
128         SAL_THROW((com::sun::star::uno::RuntimeException));
129 
130     // Helper.
131     static ::rtl::OUString
132     replaceMessageWithArguments(
133         ::rtl::OUString aMessage,
134             std::vector< rtl::OUString > const & rArguments );
135 
136 private:
137     bool
138     handleRequest_impl(
139         com::sun::star::uno::Reference<
140             com::sun::star::task::XInteractionRequest > const & rRequest,
141         bool bObtainErrorStringOnly,
142         bool & bHasErrorString,
143         rtl::OUString & rErrorString)
144         SAL_THROW((com::sun::star::uno::RuntimeException));
145 
146     static long
147     handlerequest(void* pHandleData, void* pInteractionHandler);
148 
149     com::sun::star::beans::Optional< rtl::OUString >
150     getStringFromRequest_impl(
151         com::sun::star::uno::Reference<
152             com::sun::star::task::XInteractionRequest > const & rRequest)
153         SAL_THROW((com::sun::star::uno::RuntimeException));
154 
155     static long
156     getstringfromrequest(void* pHandleData, void* pInteractionHandler);
157 
158     Window *
159     getParentProperty()
160         SAL_THROW(());
161 
162     ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>
163     getParentXWindow() const
164         SAL_THROW(());
165 
166     rtl::OUString
167     getContextProperty()
168         SAL_THROW(());
169 
170     com::sun::star::uno::Reference< com::sun::star::task::XInteractionHandler >
171     getInteractionHandler()
172         SAL_THROW((com::sun::star::uno::RuntimeException));
173 
174     bool    handleTypedHandlerImplementations(
175                 ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const &  rRequest
176             );
177 
178     bool
179     tryOtherInteractionHandler(
180         com::sun::star::uno::Reference<
181             com::sun::star::task::XInteractionRequest > const & rRequest)
182         SAL_THROW((com::sun::star::uno::RuntimeException));
183 
184     void
185     getInteractionHandlerList(InteractionHandlerDataList &rdataList)
186         SAL_THROW((com::sun::star::uno::RuntimeException));
187 
188     static bool
189     isInformationalErrorMessageRequest(
190         com::sun::star::uno::Sequence<
191             com::sun::star::uno::Reference<
192                 com::sun::star::task::XInteractionContinuation > > const &
193             rContinuations);
194 
195     //=====================================================================
196 
197     bool
198     handleInteractiveIOException(
199         com::sun::star::uno::Reference<
200             com::sun::star::task::XInteractionRequest > const & rRequest,
201         bool bObtainErrorStringOnly,
202         bool & bHasErrorString,
203         rtl::OUString & rErrorString)
204         SAL_THROW((com::sun::star::uno::RuntimeException));
205 
206     bool
207     handleAuthenticationRequest(
208         com::sun::star::uno::Reference<
209             com::sun::star::task::XInteractionRequest > const & rRequest)
210         SAL_THROW((com::sun::star::uno::RuntimeException));
211 
212     bool
213     handleCertificateValidationRequest(
214         com::sun::star::uno::Reference<
215             com::sun::star::task::XInteractionRequest > const & rRequest)
216         SAL_THROW((com::sun::star::uno::RuntimeException));
217 
218     void
219     handleNameClashResolveRequest(
220         com::sun::star::ucb::NameClashResolveRequest const & rRequest,
221         com::sun::star::uno::Sequence<
222             com::sun::star::uno::Reference<
223                 com::sun::star::task::XInteractionContinuation > > const &
224                     rContinuations)
225         SAL_THROW((com::sun::star::uno::RuntimeException));
226 
227     bool
228     handleMasterPasswordRequest(
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     handlePasswordRequest(
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     handleCookiesRequest(
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     handleNoSuchFilterRequest(
247         com::sun::star::uno::Reference<
248             com::sun::star::task::XInteractionRequest > const & rRequest)
249         SAL_THROW((com::sun::star::uno::RuntimeException));
250 
251     bool
252     handleAmbigousFilterRequest(
253         com::sun::star::uno::Reference<
254             com::sun::star::task::XInteractionRequest > const & rRequest)
255         SAL_THROW((com::sun::star::uno::RuntimeException));
256 
257     bool
258     handleFilterOptionsRequest(
259         com::sun::star::uno::Reference<
260             com::sun::star::task::XInteractionRequest > const & rRequest)
261         SAL_THROW((com::sun::star::uno::RuntimeException));
262 
263     void
264     handleErrorHandlerRequest(
265         com::sun::star::task::InteractionClassification eClassification,
266         ErrCode nErrorCode,
267         std::vector< rtl::OUString > const & rArguments,
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     handleGenericErrorRequest(
279         sal_Int32 nErrorCode,
280         com::sun::star::uno::Sequence<
281             com::sun::star::uno::Reference<
282                 com::sun::star::task::XInteractionContinuation > > const &
283                     rContinuations,
284         bool bObtainErrorStringOnly,
285         bool & bHasErrorString,
286         rtl::OUString & rErrorString)
287         SAL_THROW((com::sun::star::uno::RuntimeException));
288 
289     void
290     handleMacroConfirmRequest(
291         const ::rtl::OUString& aDocumentURL,
292         const ::com::sun::star::uno::Reference<
293             ::com::sun::star::embed::XStorage >& xZipStorage,
294         const ::rtl::OUString& aDocumentVersion,
295         const ::com::sun::star::uno::Sequence<
296             ::com::sun::star::security::DocumentSignatureInformation >
297                 aSignInfo,
298         com::sun::star::uno::Sequence<
299             com::sun::star::uno::Reference<
300                 com::sun::star::task::XInteractionContinuation > > const &
301                     rContinuations)
302         SAL_THROW((com::sun::star::uno::RuntimeException));
303 
304     void
305     handleFutureDocumentVersionUpdateRequest(
306         const ::com::sun::star::task::FutureDocumentVersionProductUpdateRequest&
307             _rRequest,
308         com::sun::star::uno::Sequence<
309             com::sun::star::uno::Reference<
310                 com::sun::star::task::XInteractionContinuation > > const &
311                     rContinuations)
312         SAL_THROW((com::sun::star::uno::RuntimeException));
313 
314     void
315     handleBrokenPackageRequest(
316         std::vector< rtl::OUString > const & rArguments,
317         ::com::sun::star::uno::Sequence<
318             ::com::sun::star::uno::Reference<
319                 ::com::sun::star::task::XInteractionContinuation > > const &
320                     rContinuations,
321         bool bObtainErrorStringOnly,
322         bool & bHasErrorString,
323         rtl::OUString & rErrorString)
324         SAL_THROW((::com::sun::star::uno::RuntimeException));
325 
326     bool handleLockedDocumentRequest(
327         com::sun::star::uno::Reference<
328             com::sun::star::task::XInteractionRequest > const & rRequest)
329         SAL_THROW((::com::sun::star::uno::RuntimeException));
330 
331     bool handleChangedByOthersRequest(
332         com::sun::star::uno::Reference<
333             com::sun::star::task::XInteractionRequest > const & rRequest)
334         SAL_THROW((::com::sun::star::uno::RuntimeException));
335 
336     bool handleLockFileIgnoreRequest(
337         com::sun::star::uno::Reference<
338             com::sun::star::task::XInteractionRequest > const & rRequest)
339         SAL_THROW((::com::sun::star::uno::RuntimeException));
340 
341 	bool    handleCustomRequest(
342                 const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest >& i_rRequest,
343                 const ::rtl::OUString& i_rServiceName
344             ) const;
345 };
346 
347 class ErrorResource: private Resource
348 {
349 public:
350     inline ErrorResource(ResId & rResId) SAL_THROW(()): Resource(rResId) {}
351 
352     inline ~ErrorResource() SAL_THROW(()) { FreeResource(); }
353 
354     bool getString(ErrCode nErrorCode, rtl::OUString * pString) const
355         SAL_THROW(());
356 };
357 
358 /*
359 class InteractionRequest
360 {
361 public:
362     InteractionRequest(
363         com::sun::star::uno::Reference<
364             com::sun::star::task::XInteractionRequest > const & rRequest)
365     : m_aRequest( rRequest ) {}
366 
367     virtual bool toString( rtl::OUString & rString ) = 0;
368     virtual bool handle( rtl::OUString & rString ) = 0;
369 
370 private:
371     com::sun::star::uno::Reference<
372         com::sun::star::task::XInteractionRequest > m_aRequest;
373 };
374 */
375 
376 #endif // UUI_IAHNDL_HXX
377