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