1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_HELPER_OTASKSENUMERATION_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_HELPER_OTASKSENUMERATION_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifndef __FRAMEWORK_OMUTEXMEMBER_HXX_
32cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
33cdf0e10cSrcweir #endif
34cdf0e10cSrcweir #include <macros/generic.hxx>
35cdf0e10cSrcweir #include <macros/xinterface.hxx>
36cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
37cdf0e10cSrcweir #include <macros/debug.hxx>
38cdf0e10cSrcweir #include <general.h>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir //_________________________________________________________________________________________________________________
41cdf0e10cSrcweir //	interface includes
42cdf0e10cSrcweir //_________________________________________________________________________________________________________________
43cdf0e10cSrcweir #include <com/sun/star/lang/XEventListener.hpp>
44cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
45cdf0e10cSrcweir #include <com/sun/star/frame/XTask.hpp>
46cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49cdf0e10cSrcweir //	other includes
50cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54cdf0e10cSrcweir //	namespace
55cdf0e10cSrcweir //_________________________________________________________________________________________________________________
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace framework{
58cdf0e10cSrcweir 
59cdf0e10cSrcweir //_________________________________________________________________________________________________________________
60cdf0e10cSrcweir //	exported const
61cdf0e10cSrcweir //_________________________________________________________________________________________________________________
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //_________________________________________________________________________________________________________________
64cdf0e10cSrcweir //	exported definitions
65cdf0e10cSrcweir //_________________________________________________________________________________________________________________
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /*-************************************************************************************************************//**
68cdf0e10cSrcweir 	@short			implement a helper for a oneway enumeration of tasks
69cdf0e10cSrcweir 	@descr			You can step during this list only for one time! Its a snapshot.
70cdf0e10cSrcweir 					Don't forget to release the reference. You are the owner of an instance of this implementation.
7107a3d7f1SPedro Giffuni 					You can't use this as a baseclass. Please use it as a dynamical object for return.
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	@implements		XInterface
74cdf0e10cSrcweir 					XTypeProvider
75cdf0e10cSrcweir 					XEventListener
76cdf0e10cSrcweir 					XEnumeration
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	@base			ThreadHelpBase
79cdf0e10cSrcweir 					OWeakObject
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	@devstatus		ready to use
82cdf0e10cSrcweir *//*-*************************************************************************************************************/
83cdf0e10cSrcweir 
84cdf0e10cSrcweir class OTasksEnumeration	:	public css::lang::XTypeProvider		,
85cdf0e10cSrcweir 							public css::lang::XEventListener	,
86cdf0e10cSrcweir 							public css::container::XEnumeration	,
87cdf0e10cSrcweir 							public ThreadHelpBase					,
88cdf0e10cSrcweir 							public ::cppu::OWeakObject
89cdf0e10cSrcweir {
90cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
91cdf0e10cSrcweir 	//	public methods
92cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	public:
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
97cdf0e10cSrcweir 		//	constructor / destructor
98cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		/*-****************************************************************************************************//**
101cdf0e10cSrcweir 			@short		constructor to initialize this enumeration
102cdf0e10cSrcweir 			@descr		An enumeration is a list with oneway-access! You can get every member only for one time.
103cdf0e10cSrcweir 						This method allow to initialize this oneway list with values.
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 			@seealso	-
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 			@param		"seqTasks" is a sequence of interfaces, which are tasks.
108cdf0e10cSrcweir 			@return		-
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 			@onerror	Do nothing and reset this object to default with an empty list.
111cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	 	OTasksEnumeration( const css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >& seqTasks );
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
116cdf0e10cSrcweir 		//	XInterface
117cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 		DECLARE_XINTERFACE
120cdf0e10cSrcweir 		DECLARE_XTYPEPROVIDER
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
123cdf0e10cSrcweir 		//	XEventListener
124cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
125cdf0e10cSrcweir 
126cdf0e10cSrcweir 		/*-****************************************************************************************************//**
127cdf0e10cSrcweir 			@short		last chance to release all references and free memory
128*d2b26721Smseidel 			@descr		This method is called, if the enumeration is used completely and has no more elements.
1296b5a962bSmseidel 						Then we must destroy our list and release all references to other objects.
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			@seealso	interface XEventListener
132cdf0e10cSrcweir 
133cdf0e10cSrcweir 			@param		"aEvent" describe the source of this event.
134cdf0e10cSrcweir 			@return		-
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 			@onerror	-
137cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 		virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
142cdf0e10cSrcweir 		//	XEnumeration
143cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		/*-****************************************************************************************************//**
146cdf0e10cSrcweir 			@short		check count of accessible elements of enumeration
147cdf0e10cSrcweir 			@descr		You can call this method to get information about accessible elements in future.
148*d2b26721Smseidel 						Elements you already got are not accessible!
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 			@seealso	interface XEnumeration
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 			@param		-
153cdf0e10cSrcweir 			@return		sal_True  = if more elements accessible<BR>
154cdf0e10cSrcweir 						sal_False = other way
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 			@onerror	sal_False<BR>
157*d2b26721Smseidel 						(List is empty and there are no accessible elements ...)
158cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     	virtual sal_Bool SAL_CALL hasMoreElements() throw( css::uno::RuntimeException );
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 		/*-****************************************************************************************************//**
163cdf0e10cSrcweir 			@short		give the next element, if some exist
164cdf0e10cSrcweir 			@descr		If a call "hasMoreElements()" return true, you can get the next element of list.
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 			@seealso	interface XEnumeration
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 			@param		-
169*d2b26721Smseidel 			@return		A Reference to a task, saved in an Any-structure.
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 			@onerror	If end of enumeration is arrived or there are no elements in list => a NoSuchElementException is thrown.
172cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
173cdf0e10cSrcweir 
174cdf0e10cSrcweir     	virtual css::uno::Any SAL_CALL nextElement() throw(	css::container::NoSuchElementException	,
175cdf0e10cSrcweir 							 								css::lang::WrappedTargetException		,
176cdf0e10cSrcweir 															css::uno::RuntimeException				);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
179cdf0e10cSrcweir 	//	protected methods
180cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	protected:
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 		/*-****************************************************************************************************//**
185cdf0e10cSrcweir 			@short		standard destructor
186cdf0e10cSrcweir 			@descr		This method destruct an instance of this class and clear some member.
187cdf0e10cSrcweir 						We make it protected, because its not supported to use this class as normal instance!
188cdf0e10cSrcweir 						You must create it dynamical in memory and use a pointer.
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 			@seealso	-
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 			@param		-
193cdf0e10cSrcweir 			@return		-
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 			@onerror	-
196cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 		virtual	~OTasksEnumeration();
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		/*-****************************************************************************************************//**
201cdf0e10cSrcweir 			@short		reset instance to default values
202cdf0e10cSrcweir 
203cdf0e10cSrcweir 			@descr		There are two ways to delete an instance of this class.<BR>
204cdf0e10cSrcweir 						1) delete with destructor<BR>
205cdf0e10cSrcweir 						2) dispose from parent or factory ore ...<BR>
206cdf0e10cSrcweir 						This method do the same for both ways! It free used memory and release references ...
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 			@seealso	method dispose()
209cdf0e10cSrcweir 			@seealso	destructor ~TaskEnumeration()
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 			@param		-
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 			@return		-
214cdf0e10cSrcweir 
215cdf0e10cSrcweir 			@onerror	-
216cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 		virtual void impl_resetObject();
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
221cdf0e10cSrcweir 	//	private methods
222cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 	private:
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
227cdf0e10cSrcweir 	//	debug methods
228cdf0e10cSrcweir 	//	(should be private everyway!)
229cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 		/*-****************************************************************************************************//**
232*d2b26721Smseidel 			@short		debug-method to check incoming parameter of some other methods of this class
233cdf0e10cSrcweir 			@descr		The following methods are used to check parameters for other methods
234cdf0e10cSrcweir 						of this class. The return value is used directly for an ASSERT(...).
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 			@seealso	ASSERT in implementation!
237cdf0e10cSrcweir 
238cdf0e10cSrcweir 			@param		references to checking variables
239cdf0e10cSrcweir 			@return		sal_False on invalid parameter<BR>
240cdf0e10cSrcweir 						sal_True  otherway
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 			@onerror	-
243cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
244cdf0e10cSrcweir 
245cdf0e10cSrcweir 	#ifdef ENABLE_ASSERTIONS
246cdf0e10cSrcweir 
247cdf0e10cSrcweir 	private:
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_OTasksEnumerationCtor	(	const	css::uno::Sequence< css::uno::Reference< css::frame::XFrame > >&	seqTasks	);
250cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_disposing				(	const	css::lang::EventObject&			   									aEvent		);
251cdf0e10cSrcweir 
252cdf0e10cSrcweir 	#endif	// #ifdef ENABLE_ASSERTIONS
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
255cdf0e10cSrcweir 	//	variables
256cdf0e10cSrcweir 	//	(should be private everyway!)
257cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	private:
260cdf0e10cSrcweir 
261cdf0e10cSrcweir 		sal_uInt32															m_nPosition			;	/// current position in enumeration
262cdf0e10cSrcweir 		css::uno::Sequence< css::uno::Reference< css::frame::XTask > >		m_seqTasks			;	/// list of current tasks
263cdf0e10cSrcweir 
264cdf0e10cSrcweir };		//	class OTasksEnumeration
265cdf0e10cSrcweir 
266cdf0e10cSrcweir }		//	namespace framework
267cdf0e10cSrcweir 
268cdf0e10cSrcweir #endif	//	#ifndef __FRAMEWORK_HELPER_OTASKSENUMERATION_HXX_
269