19877b273SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39877b273SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49877b273SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59877b273SAndrew Rist  * distributed with this work for additional information
69877b273SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79877b273SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89877b273SAndrew Rist  * "License"); you may not use this file except in compliance
99877b273SAndrew Rist  * with the License.  You may obtain a copy of the License at
109877b273SAndrew Rist  *
119877b273SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
129877b273SAndrew Rist  *
139877b273SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149877b273SAndrew Rist  * software distributed under the License is distributed on an
159877b273SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169877b273SAndrew Rist  * KIND, either express or implied.  See the License for the
179877b273SAndrew Rist  * specific language governing permissions and limitations
189877b273SAndrew Rist  * under the License.
199877b273SAndrew Rist  *
209877b273SAndrew Rist  *************************************************************/
219877b273SAndrew Rist 
229877b273SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _COMPHELPER_INTERACTION_HXX_
25cdf0e10cSrcweir #define _COMPHELPER_INTERACTION_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <comphelper/uno3.hxx>
28cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
29cdf0e10cSrcweir #include <com/sun/star/task/XInteractionApprove.hpp>
30cdf0e10cSrcweir #include <com/sun/star/task/XInteractionDisapprove.hpp>
31cdf0e10cSrcweir #include <com/sun/star/task/XInteractionAbort.hpp>
32cdf0e10cSrcweir #include <com/sun/star/task/XInteractionRetry.hpp>
33cdf0e10cSrcweir #include <com/sun/star/task/XInteractionPassword.hpp>
34cdf0e10cSrcweir #include <com/sun/star/task/XInteractionRequest.hpp>
35cdf0e10cSrcweir #include "comphelper/comphelperdllapi.h"
36cdf0e10cSrcweir 
37cdf0e10cSrcweir //.........................................................................
38cdf0e10cSrcweir namespace comphelper
39cdf0e10cSrcweir {
40cdf0e10cSrcweir //.........................................................................
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 	//=========================================================================
43cdf0e10cSrcweir 	//= OInteractionSelect
44cdf0e10cSrcweir 	//=========================================================================
45cdf0e10cSrcweir 	/** base class for concrete XInteractionContinuation implementations.<p/>
46cdf0e10cSrcweir 		Instances of the classes maintain a flag indicating if the handler was called.
47cdf0e10cSrcweir 	*/
48cdf0e10cSrcweir 	class OInteractionSelect
49cdf0e10cSrcweir 	{
50*07a3d7f1SPedro Giffuni 		sal_Bool	m_bSelected : 1;	/// indicates if the select event occurred
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	protected:
OInteractionSelect()53cdf0e10cSrcweir 		OInteractionSelect() : m_bSelected(sal_False) { }
54cdf0e10cSrcweir 
55cdf0e10cSrcweir 	public:
56cdf0e10cSrcweir 		/// determines whether or not this handler was selected
wasSelected() const57cdf0e10cSrcweir 		sal_Bool	wasSelected() const { return m_bSelected; }
58cdf0e10cSrcweir 		/// resets the state to "not selected", so you may reuse the handler
reset()59cdf0e10cSrcweir 		void		reset() { m_bSelected = sal_False; }
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 	protected:
implSelected()62cdf0e10cSrcweir 		void	implSelected() { m_bSelected = sal_True; }
63cdf0e10cSrcweir 	};
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	//=========================================================================
66cdf0e10cSrcweir 	//= OInteraction
67cdf0e10cSrcweir 	//=========================================================================
68cdf0e10cSrcweir 	/** template for instantiating concret interaction handlers<p/>
69cdf0e10cSrcweir 		the template argument must eb an interface derived from XInteractionContinuation
70cdf0e10cSrcweir 	*/
71cdf0e10cSrcweir 	template <class INTERACTION>
72cdf0e10cSrcweir 	class OInteraction
73cdf0e10cSrcweir 			:public ::cppu::WeakImplHelper1< INTERACTION >
74cdf0e10cSrcweir 			,public OInteractionSelect
75cdf0e10cSrcweir 	{
76cdf0e10cSrcweir 	public:
OInteraction()77cdf0e10cSrcweir 		OInteraction() { }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	// XInteractionContinuation
80cdf0e10cSrcweir 	    virtual void SAL_CALL select(  ) throw(::com::sun::star::uno::RuntimeException);
81cdf0e10cSrcweir 	};
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 	//.........................................................................
84cdf0e10cSrcweir 	template <class INTERACTION>
select()85cdf0e10cSrcweir 	void SAL_CALL OInteraction< INTERACTION >::select(  ) throw(::com::sun::star::uno::RuntimeException)
86cdf0e10cSrcweir 	{
87cdf0e10cSrcweir 		implSelected();
88cdf0e10cSrcweir 	}
89cdf0e10cSrcweir 
90cdf0e10cSrcweir 	//=========================================================================
91cdf0e10cSrcweir 	//= OInteractionApprove
92cdf0e10cSrcweir 	//=========================================================================
93cdf0e10cSrcweir 	typedef OInteraction< ::com::sun::star::task::XInteractionApprove >	OInteractionApprove;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir 	//=========================================================================
96cdf0e10cSrcweir 	//= OInteractionDispprove
97cdf0e10cSrcweir 	//=========================================================================
98cdf0e10cSrcweir 	typedef OInteraction< ::com::sun::star::task::XInteractionDisapprove >	OInteractionDisapprove;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	//=========================================================================
101cdf0e10cSrcweir 	//= OInteractionAbort
102cdf0e10cSrcweir 	//=========================================================================
103cdf0e10cSrcweir 	typedef OInteraction< ::com::sun::star::task::XInteractionAbort >	OInteractionAbort;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	//=========================================================================
106cdf0e10cSrcweir 	//= OInteractionRetry
107cdf0e10cSrcweir 	//=========================================================================
108cdf0e10cSrcweir 	typedef OInteraction< ::com::sun::star::task::XInteractionRetry >	OInteractionRetry;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir     //=========================================================================
111cdf0e10cSrcweir 	//= OInteractionPassword
112cdf0e10cSrcweir 	//=========================================================================
113cdf0e10cSrcweir     class COMPHELPER_DLLPUBLIC OInteractionPassword : public OInteraction< ::com::sun::star::task::XInteractionPassword >
114cdf0e10cSrcweir 	{
115cdf0e10cSrcweir 	public:
OInteractionPassword()116cdf0e10cSrcweir 		OInteractionPassword()
117cdf0e10cSrcweir         {
118cdf0e10cSrcweir         }
119cdf0e10cSrcweir 
OInteractionPassword(const::rtl::OUString & _rInitialPassword)120cdf0e10cSrcweir         OInteractionPassword( const ::rtl::OUString& _rInitialPassword )
121cdf0e10cSrcweir             :m_sPassword( _rInitialPassword )
122cdf0e10cSrcweir         {
123cdf0e10cSrcweir         }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         // XInteractionPassword
126cdf0e10cSrcweir         virtual void SAL_CALL setPassword( const ::rtl::OUString& _Password ) throw (::com::sun::star::uno::RuntimeException);
127cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getPassword(  ) throw (::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir 
129cdf0e10cSrcweir     private:
130cdf0e10cSrcweir         ::rtl::OUString m_sPassword;
131cdf0e10cSrcweir 	};
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 	//=========================================================================
134cdf0e10cSrcweir 	//= OInteractionRequest
135cdf0e10cSrcweir 	//=========================================================================
136cdf0e10cSrcweir 	typedef ::cppu::WeakImplHelper1	<	::com::sun::star::task::XInteractionRequest
137cdf0e10cSrcweir 									>	OInteractionRequest_Base;
138cdf0e10cSrcweir 	/** implements an interaction request (<type scope="com.sun.star.task">XInteractionRequest</type>)<p/>
139cdf0e10cSrcweir 		at run time, you can freely add any interaction continuation objects
140cdf0e10cSrcweir 	*/
141cdf0e10cSrcweir 	class COMPHELPER_DLLPUBLIC OInteractionRequest : public OInteractionRequest_Base
142cdf0e10cSrcweir 	{
143cdf0e10cSrcweir 		::com::sun::star::uno::Any
144cdf0e10cSrcweir 					m_aRequest;			/// the request we represent
145cdf0e10cSrcweir 		::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >
146cdf0e10cSrcweir 					m_aContinuations;	/// all registered continuations
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 	public:
149cdf0e10cSrcweir 		OInteractionRequest(const ::com::sun::star::uno::Any& _rRequestDescription);
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 		/// add a new continuation
152cdf0e10cSrcweir 		void addContinuation(const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation >& _rxContinuation);
153cdf0e10cSrcweir 		/// clear all continuations
154cdf0e10cSrcweir 		void clearContinuations();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	// XInteractionRequest
157cdf0e10cSrcweir 		virtual ::com::sun::star::uno::Any SAL_CALL getRequest(  ) throw(::com::sun::star::uno::RuntimeException);
158cdf0e10cSrcweir 		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);
159cdf0e10cSrcweir 	};
160cdf0e10cSrcweir //.........................................................................
161cdf0e10cSrcweir }	// namespace comphelper
162cdf0e10cSrcweir //.........................................................................
163cdf0e10cSrcweir 
164cdf0e10cSrcweir #endif // _COMPHELPER_INTERACTION_HXX_
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 
167