merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / dispatch / interaction.hxx
blob69e58549573da93f65c92d4b93fc725169269ba4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: interaction.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_DISPATCH_INTERACTION_HXX_
32 #define __FRAMEWORK_DISPATCH_INTERACTION_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 //_________________________________________________________________________________________________________________
39 // interface includes
40 //_________________________________________________________________________________________________________________
42 #include <com/sun/star/task/XInteractionRequest.hpp>
43 #include <com/sun/star/task/XInteractionContinuation.hpp>
44 #include <com/sun/star/task/XInteractionAbort.hpp>
45 #include <com/sun/star/task/XInteractionApprove.hpp>
46 #include <com/sun/star/task/XInteractionDisapprove.hpp>
47 #include <com/sun/star/task/XInteractionRetry.hpp>
48 #include <com/sun/star/document/XInteractionFilterSelect.hpp>
49 #include <com/sun/star/document/NoSuchFilterRequest.hpp>
50 #include <com/sun/star/document/AmbigousFilterRequest.hpp>
51 #include <com/sun/star/uno/RuntimeException.hpp>
53 //_________________________________________________________________________________________________________________
54 // includes of other projects
55 //_________________________________________________________________________________________________________________
56 #include <rtl/ustring.hxx>
57 #include <cppuhelper/implbase1.hxx>
58 #include <com/sun/star/uno/Reference.hxx>
59 #include <com/sun/star/uno/Sequence.hxx>
61 //_________________________________________________________________________________________________________________
62 // namespace
63 //_________________________________________________________________________________________________________________
65 namespace framework{
67 //_________________________________________________________________________________________________________________
68 // non exported const
69 //_________________________________________________________________________________________________________________
71 //_________________________________________________________________________________________________________________
72 // non exported definitions
73 //_________________________________________________________________________________________________________________
75 //_________________________________________________________________________________________________________________
76 // declarations
77 //_________________________________________________________________________________________________________________
79 /*-************************************************************************************************************//**
80 @short base for continuation classes
81 @descr An interaction continuation could be used on XInteractionHandler/XInteractionRequest
82 to abort or react for it.
83 Base functionality is everytime the same - handler mark right continuation by calling
84 interface method "select()". User of interaction can detect it by testing c++ method "isSelected()"!
85 Superclasses can add additional interfaces or methods to support additional features ...
86 but selection of it is supported here!
88 @implements XInterface
89 XTypeProvider (supported by WeakImplHelper!)
90 XInteractionContinuation
92 @base WeakImplHelper1
94 @devstatus ready to use
95 @threadsafe no (used on once position only!)
96 *//*-*************************************************************************************************************/
97 template< class TContinuationType >
98 class ContinuationBase : public ::cppu::WeakImplHelper1< TContinuationType >
100 // c++ interface
101 public:
103 //---------------------------------------------------------------------------------------------------------
104 // initialize continuation with right start values
105 //---------------------------------------------------------------------------------------------------------
106 ContinuationBase()
107 : m_bSelected( sal_False )
111 //---------------------------------------------------------------------------------------------------------
112 // was continuation selected by handler?
113 //---------------------------------------------------------------------------------------------------------
114 sal_Bool isSelected() const
116 return m_bSelected;
119 //---------------------------------------------------------------------------------------------------------
120 // make using more then once possible
121 //---------------------------------------------------------------------------------------------------------
122 void reset()
124 m_bSelected = sal_False;
127 // uno interface
128 public:
130 //---------------------------------------------------------------------------------------------------------
131 // called by handler to mark continuation as the only possible solution for started interaction
132 //---------------------------------------------------------------------------------------------------------
133 virtual void SAL_CALL select() throw( ::com::sun::star::uno::RuntimeException )
135 m_bSelected = sal_True;
138 // member
139 private:
141 sal_Bool m_bSelected;
143 }; // class ContinuationBase
145 /*-************************************************************************************************************//**
146 @short declaration of some simple continuations
147 @descr These derived classes implements some simple continuations, which doesnt need and additional
148 interfaces or methods. Her selected state is the only neccessary feature. User of it can
149 distinguish by type between different functionality!
151 @implements -
153 @base ContinuationBase
155 @devstatus ready to use
156 @threadsafe no (used on once position only!)
157 *//*-*************************************************************************************************************/
158 typedef ContinuationBase< ::com::sun::star::task::XInteractionAbort > ContinuationAbort;
159 typedef ContinuationBase< ::com::sun::star::task::XInteractionApprove > ContinuationApprove;
160 typedef ContinuationBase< ::com::sun::star::task::XInteractionDisapprove > ContinuationDisapprove;
161 typedef ContinuationBase< ::com::sun::star::task::XInteractionRetry > ContinuationRetry;
163 /*-************************************************************************************************************//**
164 @short declaration of special continuation for filter selection
165 @descr Sometimes filter detection during loading document failed. Then we need a possibility
166 to ask user for his decision. These continuation transport selected filter by user to
167 code user of interaction.
169 @attention This implementation could be used one times only. We don't support a resetable continuation yet!
170 Why? Normaly interaction should show a filter selection dialog and ask user for his decision.
171 He can select any filter - then instances of these class will be called by handler ... or user
172 close dialog without any selection. Then another continuation should be slected by handler to
173 abort continuations ... Retrying isn't very usefull here ... I think.
175 @implements XInteractionFilterSelect
177 @base ImplInheritanceHelper1
178 ContinuationBase
180 @devstatus ready to use
181 @threadsafe no (used on once position only!)
182 *//*-*************************************************************************************************************/
183 class ContinuationFilterSelect : public ContinuationBase< ::com::sun::star::document::XInteractionFilterSelect >
185 // c++ interface
186 public:
187 ContinuationFilterSelect();
189 // uno interface
190 public:
191 virtual void SAL_CALL setFilter( const ::rtl::OUString& sFilter ) throw( ::com::sun::star::uno::RuntimeException );
192 virtual ::rtl::OUString SAL_CALL getFilter( ) throw( ::com::sun::star::uno::RuntimeException );
194 // member
195 private:
196 ::rtl::OUString m_sFilter;
198 }; // class ContinuationFilterSelect
200 /*-************************************************************************************************************//**
201 @short special request for interaction to ask user for right filter
202 @descr These helper can be used to ask user for right filter, if filter detection failed.
203 It capsulate communication with any interaction handler and supports an easy
204 access on interaction results for user of these class.
205 Use it and forget complex mechanism of interaction ...
207 @example RequestFilterSelect* pRequest = new RequestFilterSelect;
208 Reference< XInteractionRequest > xRequest ( pRequest );
209 xInteractionHandler->handle( xRequest );
210 if( ! pRequest.isAbort() )
212 OUString sFilter = pRequest->getFilter();
215 @implements XInteractionRequest
217 @base WeakImplHelper1
219 @devstatus ready to use
220 @threadsafe no (used on once position only!)
221 *//*-*************************************************************************************************************/
222 class RequestFilterSelect : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
224 // c++ interface
225 public:
226 RequestFilterSelect( const ::rtl::OUString& sURL );
227 sal_Bool isAbort () const;
228 ::rtl::OUString getFilter() const;
230 // uno interface
231 public:
232 virtual ::com::sun::star::uno::Any SAL_CALL getRequest () throw( ::com::sun::star::uno::RuntimeException );
233 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( ::com::sun::star::uno::RuntimeException );
235 // member
236 private:
237 ::com::sun::star::uno::Any m_aRequest ;
238 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
239 ContinuationAbort* m_pAbort ;
240 ContinuationFilterSelect* m_pFilter ;
242 }; // class RequestFilterSelect
244 /*-************************************************************************************************************//**
245 @short special request for interaction
246 @descr User must decide between a preselected and another detected filter.
247 It capsulate communication with any interaction handler and supports an easy
248 access on interaction results for user of these class.
250 @implements XInteractionRequest
252 @base WeakImplHelper1
254 @devstatus ready to use
255 @threadsafe no (used on once position only!)
256 *//*-*************************************************************************************************************/
257 class RequestAmbigousFilter : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
259 // c++ interface
260 public:
261 RequestAmbigousFilter( const ::rtl::OUString& sURL ,
262 const ::rtl::OUString& sSelectedFilter ,
263 const ::rtl::OUString& sDetectedFilter );
264 sal_Bool isAbort () const;
265 ::rtl::OUString getFilter() const;
267 // uno interface
268 public:
269 virtual ::com::sun::star::uno::Any SAL_CALL getRequest () throw( ::com::sun::star::uno::RuntimeException );
270 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations() throw( ::com::sun::star::uno::RuntimeException );
272 // member
273 private:
274 ::com::sun::star::uno::Any m_aRequest ;
275 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
276 ContinuationAbort* m_pAbort ;
277 ContinuationFilterSelect* m_pFilter ;
279 }; // class RequestFilterSelect
281 /*-************************************************************************************************************//**
282 @short special request for interaction
283 @descr User must decide between a preselected and another detected filter.
284 It capsulate communication with any interaction handler and supports an easy
285 access on interaction results for user of these class.
287 @implements XInteractionRequest
289 @base WeakImplHelper1
291 @devstatus ready to use
292 @threadsafe no (used on once position only!)
293 *//*-*************************************************************************************************************/
294 class InteractionRequest : public ::cppu::WeakImplHelper1< ::com::sun::star::task::XInteractionRequest >
296 // c++ interface
297 public:
298 InteractionRequest( const ::com::sun::star::uno::Any& aRequest ,
299 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > lContinuations )
301 m_aRequest = aRequest ;
302 m_lContinuations = lContinuations;
305 // uno interface
306 public:
307 virtual ::com::sun::star::uno::Any SAL_CALL getRequest()
308 throw( ::com::sun::star::uno::RuntimeException )
310 return m_aRequest;
313 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > SAL_CALL getContinuations()
314 throw( ::com::sun::star::uno::RuntimeException )
316 return m_lContinuations;
319 // member
320 private:
321 ::com::sun::star::uno::Any m_aRequest ;
322 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > > m_lContinuations;
324 }; // class RequestFilterSelect
326 } // namespace framework
328 #endif // #define __FRAMEWORK_DISPATCH_INTERACTION_HXX_