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: ocomponentaccess.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_OCOMPONENTACCESS_HXX_
32 #define __FRAMEWORK_HELPER_OCOMPONENTACCESS_HXX_
34 //_________________________________________________________________________________________________________________
36 //_________________________________________________________________________________________________________________
38 #include <threadhelp/threadhelpbase.hxx>
39 #include <macros/generic.hxx>
40 #include <macros/xinterface.hxx>
41 #include <macros/xtypeprovider.hxx>
42 #include <macros/debug.hxx>
45 //_________________________________________________________________________________________________________________
47 //_________________________________________________________________________________________________________________
48 #include <com/sun/star/frame/XFramesSupplier.hpp>
49 #include <com/sun/star/container/XEnumerationAccess.hpp>
50 #include <com/sun/star/container/XElementAccess.hpp>
51 #include <com/sun/star/container/XEnumeration.hpp>
52 #include <com/sun/star/frame/XDesktop.hpp>
53 #include <com/sun/star/lang/XComponent.hpp>
55 //_________________________________________________________________________________________________________________
57 //_________________________________________________________________________________________________________________
58 #include <cppuhelper/implbase1.hxx>
59 #include <cppuhelper/weakref.hxx>
61 //_________________________________________________________________________________________________________________
63 //_________________________________________________________________________________________________________________
67 //_________________________________________________________________________________________________________________
69 //_________________________________________________________________________________________________________________
71 //_________________________________________________________________________________________________________________
72 // exported definitions
73 //_________________________________________________________________________________________________________________
75 /*-************************************************************************************************************//**
76 @short implement XEnumerationAccess interface as helper to create many oneway enumeration of components
77 @descr We share mutex and framecontainer with ouer owner and have full access to his child tasks.
78 (Ouer owner can be the Desktop only!) We create oneway enumerations on demand. These "lists"
79 can be used for one time only. Step during the list from first to last element.
80 (The type of created enumerations is OComponentEnumeration.)
82 @implements XInterface
90 @devstatus ready to use
91 *//*-*************************************************************************************************************/
93 class OComponentAccess
: private ThreadHelpBase
, // Must be the first of baseclasses - Is neccessary for right initialization of objects!
94 public ::cppu::WeakImplHelper1
< ::com::sun::star::container::XEnumerationAccess
>
96 //-------------------------------------------------------------------------------------------------------------
98 //-------------------------------------------------------------------------------------------------------------
102 //---------------------------------------------------------------------------------------------------------
103 // constructor / destructor
104 //---------------------------------------------------------------------------------------------------------
106 /*-****************************************************************************************************//**
107 @short constructor to initialize this instance
108 @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a
109 snapshot of the components of current tasks under the desktop.
110 But we need a instance to create more then one enumerations at different times!
112 @seealso class Desktop
113 @seealso class OComponentEnumeration
115 @param "xOwner" is a reference to ouer owner and must be the desktop!
118 @onerror Do nothing and reset this object to default with an empty list.
119 *//*-*****************************************************************************************************/
121 OComponentAccess( const css::uno::Reference
< css::frame::XDesktop
>& xOwner
);
123 //---------------------------------------------------------------------------------------------------------
124 // XEnumerationAccess
125 //---------------------------------------------------------------------------------------------------------
127 /*-****************************************************************************************************//**
128 @short create a new enumeration of components
129 @descr You can call this method to get a new snapshot from all components of all tasks of the desktop as an enumeration.
131 @seealso interface XEnumerationAccess
132 @seealso interface XEnumeration
133 @seealso class Desktop
136 @return If the desktop and some components exist => a valid reference to an enumeration<BR>
137 An NULL-reference, other way.
140 *//*-*****************************************************************************************************/
142 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() throw( css::uno::RuntimeException
);
144 //---------------------------------------------------------------------------------------------------------
146 //---------------------------------------------------------------------------------------------------------
148 /*-****************************************************************************************************//**
149 @short get the type of elements in enumeration
152 @seealso interface XElementAccess
153 @seealso class OComponentEnumeration
156 @return The uno-type XComponent.
159 *//*-*****************************************************************************************************/
161 virtual css::uno::Type SAL_CALL
getElementType() throw( css::uno::RuntimeException
);
163 /*-****************************************************************************************************//**
164 @short get state of componentlist of enumeration.
167 @seealso interface XElementAccess
170 @return sal_True ,if more then 0 elements exist.
171 @return sal_False ,otherwise.
174 *//*-*****************************************************************************************************/
176 virtual sal_Bool SAL_CALL
hasElements() throw( css::uno::RuntimeException
);
178 //-------------------------------------------------------------------------------------------------------------
180 //-------------------------------------------------------------------------------------------------------------
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 ouer owner and not to ouer superclass!
189 Thats the reason for a protected dtor.
191 @seealso class Desktop
197 *//*-*****************************************************************************************************/
199 virtual ~OComponentAccess();
201 //-------------------------------------------------------------------------------------------------------------
203 //-------------------------------------------------------------------------------------------------------------
207 /*-****************************************************************************************************//**
208 @short recursive method (!) to collect all components of all frames from the subtree of given node
209 @descr This is neccessary to create the enumeration.
211 @seealso method createEnumeration
213 @param "xNode" , root of subtree and start point of search
214 @param "seqComponents", result list of search. We cant use a return value, we search recursive
215 and must collect all informations.
219 *//*-*****************************************************************************************************/
221 void impl_collectAllChildComponents( const css::uno::Reference
< css::frame::XFramesSupplier
>& xNode
,
222 css::uno::Sequence
< css::uno::Reference
< css::lang::XComponent
> >& seqComponents
);
224 /*-****************************************************************************************************//**
225 @short get the component of a frame
226 @descr The component of a frame can be the window, the controller or the model.
228 @seealso method createEnumeration
230 @param "xFrame", frame which contains the component
231 @return A reference to the component of given frame.
233 @onerror A null reference is returned.
234 *//*-*****************************************************************************************************/
236 css::uno::Reference
< css::lang::XComponent
> impl_getFrameComponent( const css::uno::Reference
< css::frame::XFrame
>& xFrame
) const;
238 //-------------------------------------------------------------------------------------------------------------
240 // (should be private everyway!)
241 //-------------------------------------------------------------------------------------------------------------
243 /*-****************************************************************************************************//**
244 @short debug-method to check incoming parameter of some other mehods of this class
245 @descr The following methods are used to check parameters for other methods
246 of this class. The return value is used directly for an ASSERT(...).
248 @seealso ASSERTs in implementation!
250 @param references to checking variables
251 @return sal_False ,on invalid parameter.
252 @return sal_True ,otherwise
255 *//*-*****************************************************************************************************/
257 #ifdef ENABLE_ASSERTIONS
261 static sal_Bool
impldbg_checkParameter_OComponentAccessCtor( const css::uno::Reference
< css::frame::XDesktop
>& xOwner
);
263 #endif // #ifdef ENABLE_ASSERTIONS
265 //-------------------------------------------------------------------------------------------------------------
267 // (should be private everyway!)
268 //-------------------------------------------------------------------------------------------------------------
272 css::uno::WeakReference
< css::frame::XDesktop
> m_xOwner
; /// weak reference to the desktop object!
274 }; // class OComponentAccess
276 } // namespace framework
278 #endif // #ifndef __FRAMEWORK_HELPER_OCOMPONENTACCESS_HXX_