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