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