1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: otasksaccess.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
32 #define __FRAMEWORK_HELPER_OTASKSACCESS_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <classes/framecontainer.hxx>
39 #include <threadhelp/threadhelpbase.hxx>
40 #include <macros/generic.hxx>
41 #include <macros/xinterface.hxx>
42 #include <macros/xtypeprovider.hxx>
43 #include <macros/debug.hxx>
45 //_________________________________________________________________________________________________________________
47 //_________________________________________________________________________________________________________________
48 #include <com/sun/star/container/XEnumerationAccess.hpp>
49 #include <com/sun/star/container/XElementAccess.hpp>
50 #include <com/sun/star/container/XEnumeration.hpp>
51 #include <com/sun/star/frame/XDesktop.hpp>
53 //_________________________________________________________________________________________________________________
55 //_________________________________________________________________________________________________________________
56 #include <cppuhelper/weak.hxx>
57 #include <cppuhelper/weakref.hxx>
59 //_________________________________________________________________________________________________________________
61 //_________________________________________________________________________________________________________________
65 //_________________________________________________________________________________________________________________
67 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
70 // exported definitions
71 //_________________________________________________________________________________________________________________
73 /*-************************************************************************************************************//**
74 @short implement XEnumerationAccess interface as helper to create many oneway enumeration of tasks
75 @descr We share mutex and framecontainer with ouer owner and have full access to his child tasks.
76 (Ouer owner can be the Desktop only!) We create oneway enumerations on demand. These "lists"
77 can be used for one time only. Step during the list from first to last element.
78 (The type of created enumerations is OTasksEnumeration.)
80 @implements XInterface
87 *//*-*************************************************************************************************************/
89 class OTasksAccess
: public css::lang::XTypeProvider
,
90 public css::container::XEnumerationAccess
, // => XElementAccess
91 private ThreadHelpBase
,
92 public ::cppu::OWeakObject
94 //-------------------------------------------------------------------------------------------------------------
96 //-------------------------------------------------------------------------------------------------------------
100 //---------------------------------------------------------------------------------------------------------
101 // constructor / destructor
102 //---------------------------------------------------------------------------------------------------------
104 /*-****************************************************************************************************//**
105 @short constructor to initialize this instance
106 @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a
107 snapshot of the tasklist of current tasks of desktop.
108 But we need a instance to create more then one enumerations to the same tasklist!
110 @seealso class Desktop
111 @seealso class OTasksEnumeration
113 @param "xOwner" is a reference to ouer owner and must be the desktop!
114 @param "pTasks" is a pointer to the taskcontainer of the desktop. We need it to create a new enumeration.
117 @onerror Do nothing and reset this object to default with an empty list.
118 *//*-*****************************************************************************************************/
120 OTasksAccess( const css::uno::Reference
< css::frame::XDesktop
>& xOwner
,
121 FrameContainer
* pTasks
);
123 //---------------------------------------------------------------------------------------------------------
125 //---------------------------------------------------------------------------------------------------------
128 DECLARE_XTYPEPROVIDER
130 //---------------------------------------------------------------------------------------------------------
131 // XEnumerationAccess
132 //---------------------------------------------------------------------------------------------------------
134 /*-****************************************************************************************************//**
135 @short create a new enumeration of tasks
136 @descr You can call this method to get a new snapshot to all tasks of the desktop as an enumeration.
138 @seealso interface XEnumerationAccess
139 @seealso interface XEnumeration
140 @seealso class Desktop
143 @return If the desktop and some tasks exist => a valid reference to an enumeration<BR>
144 An NULL-reference, other way.
147 *//*-*****************************************************************************************************/
149 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() throw( css::uno::RuntimeException
);
151 //---------------------------------------------------------------------------------------------------------
153 //---------------------------------------------------------------------------------------------------------
155 /*-****************************************************************************************************//**
156 @short get the type of elements in enumeration
159 @seealso interface XElementAccess
160 @seealso class TasksEnumeration
163 @return The uno-type XTask.
166 *//*-*****************************************************************************************************/
168 virtual css::uno::Type SAL_CALL
getElementType() throw( css::uno::RuntimeException
);
170 /*-****************************************************************************************************//**
171 @short get state of tasklist of enumeration.
174 @seealso interface XElementAccess
177 @return sal_True ,if more then 0 elements exist.
178 @return sal_False ,otherwise.
181 *//*-*****************************************************************************************************/
183 virtual sal_Bool SAL_CALL
hasElements() throw( css::uno::RuntimeException
);
185 //-------------------------------------------------------------------------------------------------------------
187 //-------------------------------------------------------------------------------------------------------------
191 /*-****************************************************************************************************//**
192 @short standard destructor
193 @descr This method destruct an instance of this class and clear some member.
194 Don't use an instance of this class as normal member. Use it dynamicly with a pointer.
195 We hold a weakreference to ouer owner and not to ouer superclass!
196 Thats the reason for a protected dtor.
198 @seealso class Desktop
204 *//*-*****************************************************************************************************/
206 virtual ~OTasksAccess();
208 //-------------------------------------------------------------------------------------------------------------
210 //-------------------------------------------------------------------------------------------------------------
214 //-------------------------------------------------------------------------------------------------------------
216 // (should be private everyway!)
217 //-------------------------------------------------------------------------------------------------------------
219 /*-****************************************************************************************************//**
220 @short debug-method to check incoming parameter of some other mehods of this class
221 @descr The following methods are used to check parameters for other methods
222 of this class. The return value is used directly for an ASSERT(...).
224 @seealso ASSERTs in implementation!
226 @param references to checking variables
227 @return sal_False ,on invalid parameter.
228 @return sal_True ,otherwise
231 *//*-*****************************************************************************************************/
233 #ifdef ENABLE_ASSERTIONS
237 static sal_Bool
impldbg_checkParameter_OTasksAccessCtor( const css::uno::Reference
< css::frame::XDesktop
>& xOwner
,
238 FrameContainer
* pTasks
);
240 #endif // #ifdef ENABLE_ASSERTIONS
242 //-------------------------------------------------------------------------------------------------------------
244 // (should be private everyway!)
245 //-------------------------------------------------------------------------------------------------------------
249 css::uno::WeakReference
< css::frame::XDesktop
> m_xOwner
; /// weak reference to the desktop object!
250 FrameContainer
* m_pTasks
; /// pointer to list of current tasks on desktop (is a member of class Desktop!)
251 /// This pointer is valid only, if weakreference can be locked.
253 }; // class OTasksAccess
255 } // namespace framework
257 #endif // #ifndef __FRAMEWORK_HELPER_OTASKSACCESS_HXX_