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