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_OTASKSACCESS_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir //_________________________________________________________________________________________________________________
28cdf0e10cSrcweir //	my own includes
29cdf0e10cSrcweir //_________________________________________________________________________________________________________________
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <classes/framecontainer.hxx>
32cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
33cdf0e10cSrcweir #include <macros/generic.hxx>
34cdf0e10cSrcweir #include <macros/xinterface.hxx>
35cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
36cdf0e10cSrcweir #include <macros/debug.hxx>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir //_________________________________________________________________________________________________________________
39cdf0e10cSrcweir //	interface includes
40cdf0e10cSrcweir //_________________________________________________________________________________________________________________
41cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
42cdf0e10cSrcweir #include <com/sun/star/container/XElementAccess.hpp>
43cdf0e10cSrcweir #include <com/sun/star/container/XEnumeration.hpp>
44cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp>
45cdf0e10cSrcweir 
46cdf0e10cSrcweir //_________________________________________________________________________________________________________________
47cdf0e10cSrcweir //	other includes
48cdf0e10cSrcweir //_________________________________________________________________________________________________________________
49cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
50cdf0e10cSrcweir #include <cppuhelper/weakref.hxx>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir //_________________________________________________________________________________________________________________
53cdf0e10cSrcweir //	namespace
54cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55cdf0e10cSrcweir 
56cdf0e10cSrcweir namespace framework{
57cdf0e10cSrcweir 
58cdf0e10cSrcweir //_________________________________________________________________________________________________________________
59cdf0e10cSrcweir //	exported const
60cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63cdf0e10cSrcweir //	exported definitions
64cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65cdf0e10cSrcweir 
66cdf0e10cSrcweir /*-************************************************************************************************************//**
67cdf0e10cSrcweir 	@short			implement XEnumerationAccess interface as helper to create many oneway enumeration of tasks
68*6b5a962bSmseidel 	@descr			We share mutex and framecontainer with our owner and have full access to his child tasks.
69*6b5a962bSmseidel 					(Our owner can be the Desktop only!) We create oneway enumerations on demand. These "lists"
70cdf0e10cSrcweir 					can be used for one time only. Step during the list from first to last element.
71cdf0e10cSrcweir 					(The type of created enumerations is OTasksEnumeration.)
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 	@implements		XInterface
74cdf0e10cSrcweir 					XEnumerationAccess
75cdf0e10cSrcweir 					XElementAccess
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	@base			OWeakObject
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 	@devstatus		deprecated
80cdf0e10cSrcweir *//*-*************************************************************************************************************/
81cdf0e10cSrcweir 
82cdf0e10cSrcweir class OTasksAccess	:	public css::lang::XTypeProvider				,
83cdf0e10cSrcweir 						public css::container::XEnumerationAccess	,	// => XElementAccess
84cdf0e10cSrcweir                         private ThreadHelpBase                      ,
85cdf0e10cSrcweir 						public ::cppu::OWeakObject
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
88cdf0e10cSrcweir 	//	public methods
89cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	public:
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
94cdf0e10cSrcweir 		//	constructor / destructor
95cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 		/*-****************************************************************************************************//**
98cdf0e10cSrcweir 			@short		constructor to initialize this instance
99cdf0e10cSrcweir 			@descr		A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a
100cdf0e10cSrcweir 						snapshot of the tasklist of current tasks of desktop.
101cdf0e10cSrcweir 						But we need a instance to create more then one enumerations to the same tasklist!
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 			@seealso	class Desktop
104cdf0e10cSrcweir 			@seealso	class OTasksEnumeration
105cdf0e10cSrcweir 
106*6b5a962bSmseidel 			@param		"xOwner" is a reference to our owner and must be the desktop!
107cdf0e10cSrcweir 			@param		"pTasks" is a pointer to the taskcontainer of the desktop. We need it to create a new enumeration.
108cdf0e10cSrcweir 			@return		-
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 			@onerror	Do nothing and reset this object to default with an empty list.
111cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	 	OTasksAccess(	const	css::uno::Reference< css::frame::XDesktop >&	xOwner	,
114cdf0e10cSrcweir                                 FrameContainer*                                 pTasks  );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
117cdf0e10cSrcweir 		//	XInterface
118cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 		DECLARE_XINTERFACE
121cdf0e10cSrcweir 		DECLARE_XTYPEPROVIDER
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
124cdf0e10cSrcweir 		//	XEnumerationAccess
125cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 		/*-****************************************************************************************************//**
128cdf0e10cSrcweir 			@short		create a new enumeration of tasks
129cdf0e10cSrcweir 			@descr		You can call this method to get a new snapshot to all tasks of the desktop as an enumeration.
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 			@seealso	interface XEnumerationAccess
132cdf0e10cSrcweir 			@seealso	interface XEnumeration
133cdf0e10cSrcweir 			@seealso	class Desktop
134cdf0e10cSrcweir 
135cdf0e10cSrcweir 			@param		-
136cdf0e10cSrcweir 			@return		If the desktop and some tasks exist => a valid reference to an enumeration<BR>
137cdf0e10cSrcweir 						An NULL-reference, other way.
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 			@onerror	-
140cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw( css::uno::RuntimeException );
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
145cdf0e10cSrcweir 		//	XElementAccess
146cdf0e10cSrcweir 		//---------------------------------------------------------------------------------------------------------
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 		/*-****************************************************************************************************//**
149cdf0e10cSrcweir 			@short		get the type of elements in enumeration
150cdf0e10cSrcweir 			@descr		-
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 			@seealso	interface XElementAccess
153cdf0e10cSrcweir 			@seealso	class TasksEnumeration
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 			@param		-
156cdf0e10cSrcweir 			@return		The uno-type XTask.
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 			@onerror	-
159cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 		virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException );
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 		/*-****************************************************************************************************//**
164cdf0e10cSrcweir 			@short		get state of tasklist of enumeration.
165cdf0e10cSrcweir 			@descr		-
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 			@seealso	interface XElementAccess
168cdf0e10cSrcweir 
169cdf0e10cSrcweir 			@param		-
170cdf0e10cSrcweir 			@return		sal_True  ,if more then 0 elements exist.
171cdf0e10cSrcweir 			@return		sal_False ,otherwise.
172cdf0e10cSrcweir 
173cdf0e10cSrcweir 			@onerror	-
174cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     	virtual sal_Bool SAL_CALL hasElements() throw( 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 						Don't use an instance of this class as normal member. Use it dynamicly with a pointer.
188*6b5a962bSmseidel 						We hold a weakreference to our owner and not to our superclass!
189796b7e2aSmseidel 						That's the reason for a protected dtor.
190cdf0e10cSrcweir 
191cdf0e10cSrcweir 			@seealso	class Desktop
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 			@param		-
194cdf0e10cSrcweir 			@return		-
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 			@onerror	-
197cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
198cdf0e10cSrcweir 
199cdf0e10cSrcweir 		virtual	~OTasksAccess();
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
202cdf0e10cSrcweir 	//	private methods
203cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	private:
206cdf0e10cSrcweir 
207cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
208cdf0e10cSrcweir 	//	debug methods
209cdf0e10cSrcweir 	//	(should be private everyway!)
210cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
211cdf0e10cSrcweir 
212cdf0e10cSrcweir 		/*-****************************************************************************************************//**
213cdf0e10cSrcweir 			@short		debug-method to check incoming parameter of some other mehods of this class
214cdf0e10cSrcweir 			@descr		The following methods are used to check parameters for other methods
215cdf0e10cSrcweir 						of this class. The return value is used directly for an ASSERT(...).
216cdf0e10cSrcweir 
217cdf0e10cSrcweir 			@seealso	ASSERTs in implementation!
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 			@param		references to checking variables
220cdf0e10cSrcweir 			@return		sal_False ,on invalid parameter.
221cdf0e10cSrcweir 			@return		sal_True  ,otherwise
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 			@onerror	-
224cdf0e10cSrcweir 		*//*-*****************************************************************************************************/
225cdf0e10cSrcweir 
226cdf0e10cSrcweir 	#ifdef ENABLE_ASSERTIONS
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 	private:
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 		static sal_Bool impldbg_checkParameter_OTasksAccessCtor(	const	css::uno::Reference< css::frame::XDesktop >&	xOwner	,
231cdf0e10cSrcweir                                                                             FrameContainer*                                 pTasks  );
232cdf0e10cSrcweir 
233cdf0e10cSrcweir 	#endif	// #ifdef ENABLE_ASSERTIONS
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
236cdf0e10cSrcweir 	//	variables
237cdf0e10cSrcweir 	//	(should be private everyway!)
238cdf0e10cSrcweir 	//-------------------------------------------------------------------------------------------------------------
239cdf0e10cSrcweir 
240cdf0e10cSrcweir 	private:
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 		css::uno::WeakReference< css::frame::XDesktop >		m_xOwner			;	/// weak reference to the desktop object!
243cdf0e10cSrcweir 		FrameContainer*										m_pTasks			;	/// pointer to list of current tasks on desktop (is a member of class Desktop!)
244cdf0e10cSrcweir 																					/// This pointer is valid only, if weakreference can be locked.
245cdf0e10cSrcweir 
246cdf0e10cSrcweir };		//	class OTasksAccess
247cdf0e10cSrcweir 
248cdf0e10cSrcweir }		//	namespace framework
249cdf0e10cSrcweir 
250cdf0e10cSrcweir #endif	//	#ifndef __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
251