LibreOffice Module framework (master) 1
ocomponentaccess.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/frame/XFramesSupplier.hpp>
23#include <com/sun/star/container/XEnumerationAccess.hpp>
24#include <com/sun/star/container/XEnumeration.hpp>
25#include <com/sun/star/frame/XDesktop.hpp>
26#include <com/sun/star/lang/XComponent.hpp>
27
30#include <vector>
31
32namespace framework{
33
34/*-************************************************************************************************************
35 @short implement XEnumerationAccess interface as helper to create many oneway enumeration of components
36 @descr We share mutex and framecontainer with our owner and have full access to its child tasks.
37 (Our owner can be the Desktop only!) We create oneway enumerations on demand. These "lists"
38 can be used for one time only. Step during the list from first to last element.
39 (The type of created enumerations is OComponentEnumeration.)
40
41 @implements XInterface
42 XTypeProvider
43 XEnumerationAccess
44 XElementAccess
45
46 @base OWeakObject
47
48 @devstatus ready to use
49*//*-*************************************************************************************************************/
50
51class OComponentAccess final : public ::cppu::WeakImplHelper< css::container::XEnumerationAccess >
52{
53
54 // public methods
55
56 public:
57
58 // constructor / destructor
59
60 /*-****************************************************************************************************
61 @short constructor to initialize this instance
62 @descr A desktop will create an enumeration-access-object. An enumeration is a oneway-list and a
63 snapshot of the components of current tasks under the desktop.
64 But we need an instance to create more than one enumerations at different times!
65
66 @seealso class Desktop
67 @seealso class OComponentEnumeration
68
69 @param "xOwner" is a reference to our owner and must be the desktop!
70 @onerror Do nothing and reset this object to default with an empty list.
71 *//*-*****************************************************************************************************/
72
73 OComponentAccess( const css::uno::Reference< css::frame::XDesktop >& xOwner );
74
75 // XEnumerationAccess
76
77 /*-****************************************************************************************************
78 @short create a new enumeration of components
79 @descr You can call this method to get a new snapshot from all components of all tasks of the desktop as an enumeration.
80
81 @seealso interface XEnumerationAccess
82 @seealso interface XEnumeration
83 @seealso class Desktop
84 @return If the desktop and some components exist => a valid reference to an enumeration<BR>
85 An NULL-reference, other way.
86 *//*-*****************************************************************************************************/
87
88 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override;
89
90 // XElementAccess
91
92 /*-****************************************************************************************************
93 @short get the type of elements in enumeration
94 @seealso interface XElementAccess
95 @seealso class OComponentEnumeration
96 @return The uno-type XComponent.
97 *//*-*****************************************************************************************************/
98
99 virtual css::uno::Type SAL_CALL getElementType() override;
100
101 /*-****************************************************************************************************
102 @short get state of componentlist of enumeration.
103 @seealso interface XElementAccess
104 @return sal_True ,if more than 0 elements exist.
105 @return sal_False ,otherwise.
106 *//*-*****************************************************************************************************/
107
108 virtual sal_Bool SAL_CALL hasElements() override;
109
110 // protected methods
111
112 private:
113
114 /*-****************************************************************************************************
115 @short standard destructor
116 @descr This method destruct an instance of this class and clear some member.
117 Don't use an instance of this class as normal member. Use it dynamically with a pointer.
118 We hold a weakreference to our owner and not to our superclass!
119 That's the reason for a protected dtor.
120
121 @seealso class Desktop
122 *//*-*****************************************************************************************************/
123
124 virtual ~OComponentAccess() override;
125
126
127 /*-****************************************************************************************************
128 @short recursive method (!) to collect all components of all frames from the subtree of given node
129 @descr This is necessary to create the enumeration.
130
131 @seealso method createEnumeration
132
133 @param "xNode" , root of subtree and start point of search
134 @param "seqComponents", result list of search. We can't use a return value, we search recursive
135 and must collect all information.
136 *//*-*****************************************************************************************************/
137
138 void impl_collectAllChildComponents( const css::uno::Reference< css::frame::XFramesSupplier >& xNode ,
139 std::vector< css::uno::Reference< css::lang::XComponent > >& seqComponents );
140
141 /*-****************************************************************************************************
142 @short get the component of a frame
143 @descr The component of a frame can be the window, the controller or the model.
144
145 @seealso method createEnumeration
146
147 @param "xFrame", frame which contains the component
148 @return A reference to the component of given frame.
149
150 @onerror A null reference is returned.
151 *//*-*****************************************************************************************************/
152
153 css::uno::Reference< css::lang::XComponent > impl_getFrameComponent( const css::uno::Reference< css::frame::XFrame >& xFrame ) const;
154
155 css::uno::WeakReference< css::frame::XDesktop > m_xOwner;
156
157}; // class OComponentAccess
158
159} // namespace framework
160
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::WeakReference< css::frame::XDesktop > m_xOwner
OComponentAccess(const css::uno::Reference< css::frame::XDesktop > &xOwner)
virtual sal_Bool SAL_CALL hasElements() override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
css::uno::Reference< css::lang::XComponent > impl_getFrameComponent(const css::uno::Reference< css::frame::XFrame > &xFrame) const
virtual css::uno::Type SAL_CALL getElementType() override
void impl_collectAllChildComponents(const css::uno::Reference< css::frame::XFramesSupplier > &xNode, std::vector< css::uno::Reference< css::lang::XComponent > > &seqComponents)
virtual ~OComponentAccess() override
Reference< XFrame > xFrame
unsigned char sal_Bool