1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX
21 #define INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX
23 #include <macros/generic.hxx>
24 #include <macros/xinterface.hxx>
25 #include <macros/xtypeprovider.hxx>
28 #include <com/sun/star/frame/XFramesSupplier.hpp>
29 #include <com/sun/star/container/XEnumerationAccess.hpp>
30 #include <com/sun/star/container/XElementAccess.hpp>
31 #include <com/sun/star/container/XEnumeration.hpp>
32 #include <com/sun/star/frame/XDesktop.hpp>
33 #include <com/sun/star/lang/XComponent.hpp>
35 #include <cppuhelper/implbase1.hxx>
36 #include <cppuhelper/weakref.hxx>
40 /*-************************************************************************************************************
41 @short implement XEnumerationAccess interface as helper to create many oneway enumeration of components
42 @descr We share mutex and framecontainer with our owner and have full access to his child tasks.
43 (Our owner can be the Desktop only!) We create oneway enumerations on demand. These "lists"
44 can be used for one time only. Step during the list from first to last element.
45 (The type of created enumerations is OComponentEnumeration.)
47 @implements XInterface
54 @devstatus ready to use
55 *//*-*************************************************************************************************************/
57 class OComponentAccess
: public ::cppu::WeakImplHelper1
< ::com::sun::star::container::XEnumerationAccess
>
64 // constructor / destructor
66 /*-****************************************************************************************************
67 @short constructor to initialize this instance
68 @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a
69 snapshot of the components of current tasks under the desktop.
70 But we need a instance to create more than one enumerations at different times!
72 @seealso class Desktop
73 @seealso class OComponentEnumeration
75 @param "xOwner" is a reference to our owner and must be the desktop!
76 @onerror Do nothing and reset this object to default with an empty list.
77 *//*-*****************************************************************************************************/
79 OComponentAccess( const css::uno::Reference
< css::frame::XDesktop
>& xOwner
);
83 /*-****************************************************************************************************
84 @short create a new enumeration of components
85 @descr You can call this method to get a new snapshot from all components of all tasks of the desktop as an enumeration.
87 @seealso interface XEnumerationAccess
88 @seealso interface XEnumeration
89 @seealso class Desktop
90 @return If the desktop and some components exist => a valid reference to an enumeration<BR>
91 An NULL-reference, other way.
92 *//*-*****************************************************************************************************/
94 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration() throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
98 /*-****************************************************************************************************
99 @short get the type of elements in enumeration
100 @seealso interface XElementAccess
101 @seealso class OComponentEnumeration
102 @return The uno-type XComponent.
103 *//*-*****************************************************************************************************/
105 virtual css::uno::Type SAL_CALL
getElementType() throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
107 /*-****************************************************************************************************
108 @short get state of componentlist of enumeration.
109 @seealso interface XElementAccess
110 @return sal_True ,if more than 0 elements exist.
111 @return sal_False ,otherwise.
112 *//*-*****************************************************************************************************/
114 virtual sal_Bool SAL_CALL
hasElements() throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
120 /*-****************************************************************************************************
121 @short standard destructor
122 @descr This method destruct an instance of this class and clear some member.
123 Don't use an instance of this class as normal member. Use it dynamicly with a pointer.
124 We hold a weakreference to our owner and not to our superclass!
125 Thats the reason for a protected dtor.
127 @seealso class Desktop
128 *//*-*****************************************************************************************************/
130 virtual ~OComponentAccess();
135 /*-****************************************************************************************************
136 @short recursive method (!) to collect all components of all frames from the subtree of given node
137 @descr This is necessary to create the enumeration.
139 @seealso method createEnumeration
141 @param "xNode" , root of subtree and start point of search
142 @param "seqComponents", result list of search. We can't use a return value, we search recursive
143 and must collect all information.
144 *//*-*****************************************************************************************************/
146 void impl_collectAllChildComponents( const css::uno::Reference
< css::frame::XFramesSupplier
>& xNode
,
147 css::uno::Sequence
< css::uno::Reference
< css::lang::XComponent
> >& seqComponents
);
149 /*-****************************************************************************************************
150 @short get the component of a frame
151 @descr The component of a frame can be the window, the controller or the model.
153 @seealso method createEnumeration
155 @param "xFrame", frame which contains the component
156 @return A reference to the component of given frame.
158 @onerror A null reference is returned.
159 *//*-*****************************************************************************************************/
161 css::uno::Reference
< css::lang::XComponent
> impl_getFrameComponent( const css::uno::Reference
< css::frame::XFrame
>& xFrame
) const;
164 // (should be private everyway!)
166 /*-****************************************************************************************************
167 @short debug-method to check incoming parameter of some other mehods of this class
168 @descr The following methods are used to check parameters for other methods
169 of this class. The return value is used directly for an ASSERT(...).
171 @seealso ASSERTs in implementation!
173 @param references to checking variables
174 @return sal_False ,on invalid parameter.
175 @return sal_True ,otherwise
176 *//*-*****************************************************************************************************/
180 static bool impldbg_checkParameter_OComponentAccessCtor( const css::uno::Reference
< css::frame::XDesktop
>& xOwner
);
183 // (should be private everyway!)
187 css::uno::WeakReference
< css::frame::XDesktop
> m_xOwner
; /// weak reference to the desktop object!
189 }; // class OComponentAccess
191 } // namespace framework
193 #endif // INCLUDED_FRAMEWORK_INC_HELPER_OCOMPONENTACCESS_HXX
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */