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