1*b1cdbd2cSJim Jagielski /**************************************************************
2*b1cdbd2cSJim Jagielski  *
3*b1cdbd2cSJim Jagielski  * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski  * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski  * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski  * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski  * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski  * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski  * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski  *
11*b1cdbd2cSJim Jagielski  *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski  *
13*b1cdbd2cSJim Jagielski  * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski  * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski  * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski  * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski  * under the License.
19*b1cdbd2cSJim Jagielski  *
20*b1cdbd2cSJim Jagielski  *************************************************************/
21*b1cdbd2cSJim Jagielski 
22*b1cdbd2cSJim Jagielski 
23*b1cdbd2cSJim Jagielski 
24*b1cdbd2cSJim Jagielski #ifndef __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
25*b1cdbd2cSJim Jagielski #define __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
26*b1cdbd2cSJim Jagielski 
27*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
28*b1cdbd2cSJim Jagielski //	my own includes
29*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
30*b1cdbd2cSJim Jagielski 
31*b1cdbd2cSJim Jagielski #include <classes/framecontainer.hxx>
32*b1cdbd2cSJim Jagielski #include <threadhelp/threadhelpbase.hxx>
33*b1cdbd2cSJim Jagielski #include <macros/generic.hxx>
34*b1cdbd2cSJim Jagielski #include <macros/xinterface.hxx>
35*b1cdbd2cSJim Jagielski #include <macros/xtypeprovider.hxx>
36*b1cdbd2cSJim Jagielski #include <macros/debug.hxx>
37*b1cdbd2cSJim Jagielski 
38*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
39*b1cdbd2cSJim Jagielski //	interface includes
40*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
41*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XEnumerationAccess.hpp>
42*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XElementAccess.hpp>
43*b1cdbd2cSJim Jagielski #include <com/sun/star/container/XEnumeration.hpp>
44*b1cdbd2cSJim Jagielski #include <com/sun/star/frame/XDesktop.hpp>
45*b1cdbd2cSJim Jagielski 
46*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
47*b1cdbd2cSJim Jagielski //	other includes
48*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
49*b1cdbd2cSJim Jagielski #include <cppuhelper/weak.hxx>
50*b1cdbd2cSJim Jagielski #include <cppuhelper/weakref.hxx>
51*b1cdbd2cSJim Jagielski 
52*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
53*b1cdbd2cSJim Jagielski //	namespace
54*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
55*b1cdbd2cSJim Jagielski 
56*b1cdbd2cSJim Jagielski namespace framework{
57*b1cdbd2cSJim Jagielski 
58*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
59*b1cdbd2cSJim Jagielski //	exported const
60*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
61*b1cdbd2cSJim Jagielski 
62*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
63*b1cdbd2cSJim Jagielski //	exported definitions
64*b1cdbd2cSJim Jagielski //_________________________________________________________________________________________________________________
65*b1cdbd2cSJim Jagielski 
66*b1cdbd2cSJim Jagielski /*-************************************************************************************************************//**
67*b1cdbd2cSJim Jagielski 	@short			implement XEnumerationAccess interface as helper to create many oneway enumeration of tasks
68*b1cdbd2cSJim Jagielski 	@descr			We share mutex and framecontainer with ouer owner and have full access to his child tasks.
69*b1cdbd2cSJim Jagielski 					(Ouer owner can be the Desktop only!) We create oneway enumerations on demand. These "lists"
70*b1cdbd2cSJim Jagielski 					can be used for one time only. Step during the list from first to last element.
71*b1cdbd2cSJim Jagielski 					(The type of created enumerations is OTasksEnumeration.)
72*b1cdbd2cSJim Jagielski 
73*b1cdbd2cSJim Jagielski 	@implements		XInterface
74*b1cdbd2cSJim Jagielski 					XEnumerationAccess
75*b1cdbd2cSJim Jagielski 					XElementAccess
76*b1cdbd2cSJim Jagielski 
77*b1cdbd2cSJim Jagielski 	@base			OWeakObject
78*b1cdbd2cSJim Jagielski 
79*b1cdbd2cSJim Jagielski 	@devstatus		deprecated
80*b1cdbd2cSJim Jagielski *//*-*************************************************************************************************************/
81*b1cdbd2cSJim Jagielski 
82*b1cdbd2cSJim Jagielski class OTasksAccess	:	public css::lang::XTypeProvider				,
83*b1cdbd2cSJim Jagielski 						public css::container::XEnumerationAccess	,	// => XElementAccess
84*b1cdbd2cSJim Jagielski                         private ThreadHelpBase                      ,
85*b1cdbd2cSJim Jagielski 						public ::cppu::OWeakObject
86*b1cdbd2cSJim Jagielski {
87*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
88*b1cdbd2cSJim Jagielski 	//	public methods
89*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
90*b1cdbd2cSJim Jagielski 
91*b1cdbd2cSJim Jagielski 	public:
92*b1cdbd2cSJim Jagielski 
93*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
94*b1cdbd2cSJim Jagielski 		//	constructor / destructor
95*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
96*b1cdbd2cSJim Jagielski 
97*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
98*b1cdbd2cSJim Jagielski 			@short		constructor to initialize this instance
99*b1cdbd2cSJim Jagielski 			@descr		A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a
100*b1cdbd2cSJim Jagielski 						snapshot of the tasklist of current tasks of desktop.
101*b1cdbd2cSJim Jagielski 						But we need a instance to create more then one enumerations to the same tasklist!
102*b1cdbd2cSJim Jagielski 
103*b1cdbd2cSJim Jagielski 			@seealso	class Desktop
104*b1cdbd2cSJim Jagielski 			@seealso	class OTasksEnumeration
105*b1cdbd2cSJim Jagielski 
106*b1cdbd2cSJim Jagielski 			@param		"xOwner" is a reference to ouer owner and must be the desktop!
107*b1cdbd2cSJim Jagielski 			@param		"pTasks" is a pointer to the taskcontainer of the desktop. We need it to create a new enumeration.
108*b1cdbd2cSJim Jagielski 			@return		-
109*b1cdbd2cSJim Jagielski 
110*b1cdbd2cSJim Jagielski 			@onerror	Do nothing and reset this object to default with an empty list.
111*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
112*b1cdbd2cSJim Jagielski 
113*b1cdbd2cSJim Jagielski 	 	OTasksAccess(	const	css::uno::Reference< css::frame::XDesktop >&	xOwner	,
114*b1cdbd2cSJim Jagielski                                 FrameContainer*                                 pTasks  );
115*b1cdbd2cSJim Jagielski 
116*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
117*b1cdbd2cSJim Jagielski 		//	XInterface
118*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
119*b1cdbd2cSJim Jagielski 
120*b1cdbd2cSJim Jagielski 		DECLARE_XINTERFACE
121*b1cdbd2cSJim Jagielski 		DECLARE_XTYPEPROVIDER
122*b1cdbd2cSJim Jagielski 
123*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
124*b1cdbd2cSJim Jagielski 		//	XEnumerationAccess
125*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
126*b1cdbd2cSJim Jagielski 
127*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
128*b1cdbd2cSJim Jagielski 			@short		create a new enumeration of tasks
129*b1cdbd2cSJim Jagielski 			@descr		You can call this method to get a new snapshot to all tasks of the desktop as an enumeration.
130*b1cdbd2cSJim Jagielski 
131*b1cdbd2cSJim Jagielski 			@seealso	interface XEnumerationAccess
132*b1cdbd2cSJim Jagielski 			@seealso	interface XEnumeration
133*b1cdbd2cSJim Jagielski 			@seealso	class Desktop
134*b1cdbd2cSJim Jagielski 
135*b1cdbd2cSJim Jagielski 			@param		-
136*b1cdbd2cSJim Jagielski 			@return		If the desktop and some tasks exist => a valid reference to an enumeration<BR>
137*b1cdbd2cSJim Jagielski 						An NULL-reference, other way.
138*b1cdbd2cSJim Jagielski 
139*b1cdbd2cSJim Jagielski 			@onerror	-
140*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
141*b1cdbd2cSJim Jagielski 
142*b1cdbd2cSJim Jagielski 	    virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() throw( css::uno::RuntimeException );
143*b1cdbd2cSJim Jagielski 
144*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
145*b1cdbd2cSJim Jagielski 		//	XElementAccess
146*b1cdbd2cSJim Jagielski 		//---------------------------------------------------------------------------------------------------------
147*b1cdbd2cSJim Jagielski 
148*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
149*b1cdbd2cSJim Jagielski 			@short		get the type of elements in enumeration
150*b1cdbd2cSJim Jagielski 			@descr		-
151*b1cdbd2cSJim Jagielski 
152*b1cdbd2cSJim Jagielski 			@seealso	interface XElementAccess
153*b1cdbd2cSJim Jagielski 			@seealso	class TasksEnumeration
154*b1cdbd2cSJim Jagielski 
155*b1cdbd2cSJim Jagielski 			@param		-
156*b1cdbd2cSJim Jagielski 			@return		The uno-type XTask.
157*b1cdbd2cSJim Jagielski 
158*b1cdbd2cSJim Jagielski 			@onerror	-
159*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
160*b1cdbd2cSJim Jagielski 
161*b1cdbd2cSJim Jagielski 		virtual css::uno::Type SAL_CALL getElementType() throw( css::uno::RuntimeException );
162*b1cdbd2cSJim Jagielski 
163*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
164*b1cdbd2cSJim Jagielski 			@short		get state of tasklist of enumeration.
165*b1cdbd2cSJim Jagielski 			@descr		-
166*b1cdbd2cSJim Jagielski 
167*b1cdbd2cSJim Jagielski 			@seealso	interface XElementAccess
168*b1cdbd2cSJim Jagielski 
169*b1cdbd2cSJim Jagielski 			@param		-
170*b1cdbd2cSJim Jagielski 			@return		sal_True  ,if more then 0 elements exist.
171*b1cdbd2cSJim Jagielski 			@return		sal_False ,otherwise.
172*b1cdbd2cSJim Jagielski 
173*b1cdbd2cSJim Jagielski 			@onerror	-
174*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
175*b1cdbd2cSJim Jagielski 
176*b1cdbd2cSJim Jagielski     	virtual sal_Bool SAL_CALL hasElements() throw( css::uno::RuntimeException );
177*b1cdbd2cSJim Jagielski 
178*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
179*b1cdbd2cSJim Jagielski 	//	protected methods
180*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
181*b1cdbd2cSJim Jagielski 
182*b1cdbd2cSJim Jagielski 	protected:
183*b1cdbd2cSJim Jagielski 
184*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
185*b1cdbd2cSJim Jagielski 			@short		standard destructor
186*b1cdbd2cSJim Jagielski 			@descr		This method destruct an instance of this class and clear some member.
187*b1cdbd2cSJim Jagielski 						Don't use an instance of this class as normal member. Use it dynamicly with a pointer.
188*b1cdbd2cSJim Jagielski 						We hold a weakreference to ouer owner and not to ouer superclass!
189*b1cdbd2cSJim Jagielski 						Thats the reason for a protected dtor.
190*b1cdbd2cSJim Jagielski 
191*b1cdbd2cSJim Jagielski 			@seealso	class Desktop
192*b1cdbd2cSJim Jagielski 
193*b1cdbd2cSJim Jagielski 			@param		-
194*b1cdbd2cSJim Jagielski 			@return		-
195*b1cdbd2cSJim Jagielski 
196*b1cdbd2cSJim Jagielski 			@onerror	-
197*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
198*b1cdbd2cSJim Jagielski 
199*b1cdbd2cSJim Jagielski 		virtual	~OTasksAccess();
200*b1cdbd2cSJim Jagielski 
201*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
202*b1cdbd2cSJim Jagielski 	//	private methods
203*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
204*b1cdbd2cSJim Jagielski 
205*b1cdbd2cSJim Jagielski 	private:
206*b1cdbd2cSJim Jagielski 
207*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
208*b1cdbd2cSJim Jagielski 	//	debug methods
209*b1cdbd2cSJim Jagielski 	//	(should be private everyway!)
210*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
211*b1cdbd2cSJim Jagielski 
212*b1cdbd2cSJim Jagielski 		/*-****************************************************************************************************//**
213*b1cdbd2cSJim Jagielski 			@short		debug-method to check incoming parameter of some other mehods of this class
214*b1cdbd2cSJim Jagielski 			@descr		The following methods are used to check parameters for other methods
215*b1cdbd2cSJim Jagielski 						of this class. The return value is used directly for an ASSERT(...).
216*b1cdbd2cSJim Jagielski 
217*b1cdbd2cSJim Jagielski 			@seealso	ASSERTs in implementation!
218*b1cdbd2cSJim Jagielski 
219*b1cdbd2cSJim Jagielski 			@param		references to checking variables
220*b1cdbd2cSJim Jagielski 			@return		sal_False ,on invalid parameter.
221*b1cdbd2cSJim Jagielski 			@return		sal_True  ,otherwise
222*b1cdbd2cSJim Jagielski 
223*b1cdbd2cSJim Jagielski 			@onerror	-
224*b1cdbd2cSJim Jagielski 		*//*-*****************************************************************************************************/
225*b1cdbd2cSJim Jagielski 
226*b1cdbd2cSJim Jagielski 	#ifdef ENABLE_ASSERTIONS
227*b1cdbd2cSJim Jagielski 
228*b1cdbd2cSJim Jagielski 	private:
229*b1cdbd2cSJim Jagielski 
230*b1cdbd2cSJim Jagielski 		static sal_Bool impldbg_checkParameter_OTasksAccessCtor(	const	css::uno::Reference< css::frame::XDesktop >&	xOwner	,
231*b1cdbd2cSJim Jagielski                                                                             FrameContainer*                                 pTasks  );
232*b1cdbd2cSJim Jagielski 
233*b1cdbd2cSJim Jagielski 	#endif	// #ifdef ENABLE_ASSERTIONS
234*b1cdbd2cSJim Jagielski 
235*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
236*b1cdbd2cSJim Jagielski 	//	variables
237*b1cdbd2cSJim Jagielski 	//	(should be private everyway!)
238*b1cdbd2cSJim Jagielski 	//-------------------------------------------------------------------------------------------------------------
239*b1cdbd2cSJim Jagielski 
240*b1cdbd2cSJim Jagielski 	private:
241*b1cdbd2cSJim Jagielski 
242*b1cdbd2cSJim Jagielski 		css::uno::WeakReference< css::frame::XDesktop >		m_xOwner			;	/// weak reference to the desktop object!
243*b1cdbd2cSJim Jagielski 		FrameContainer*										m_pTasks			;	/// pointer to list of current tasks on desktop (is a member of class Desktop!)
244*b1cdbd2cSJim Jagielski 																					/// This pointer is valid only, if weakreference can be locked.
245*b1cdbd2cSJim Jagielski 
246*b1cdbd2cSJim Jagielski };		//	class OTasksAccess
247*b1cdbd2cSJim Jagielski 
248*b1cdbd2cSJim Jagielski }		//	namespace framework
249*b1cdbd2cSJim Jagielski 
250*b1cdbd2cSJim Jagielski #endif	//	#ifndef __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
251