/src/libreoffice/include/svx/AccessibleControlShape.hxx
Line | Count | Source |
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 | | #ifndef INCLUDED_SVX_ACCESSIBLECONTROLSHAPE_HXX |
21 | | #define INCLUDED_SVX_ACCESSIBLECONTROLSHAPE_HXX |
22 | | |
23 | | #include <com/sun/star/beans/XPropertyChangeListener.hpp> |
24 | | #include <com/sun/star/container/XContainerListener.hpp> |
25 | | #include <com/sun/star/lang/EventObject.hpp> |
26 | | #include <com/sun/star/uno/Reference.hxx> |
27 | | #include <com/sun/star/util/XModeChangeListener.hpp> |
28 | | #include <comphelper/uno3.hxx> |
29 | | #include <cppuhelper/implbase4.hxx> |
30 | | #include <cppuhelper/weakref.hxx> |
31 | | #include <rtl/ref.hxx> |
32 | | #include <rtl/ustring.hxx> |
33 | | #include <sal/types.h> |
34 | | #include <svx/AccessibleShape.hxx> |
35 | | |
36 | | namespace com::sun::star { |
37 | | namespace accessibility { class XAccessibleContext; } |
38 | | namespace awt { class XControl; } |
39 | | namespace beans { class XPropertySet; } |
40 | | namespace beans { class XPropertySetInfo; } |
41 | | namespace lang { class XComponent; } |
42 | | namespace lang { class XTypeProvider; } |
43 | | namespace uno { class XAggregation; } |
44 | | } |
45 | | |
46 | | namespace accessibility |
47 | | { |
48 | | class OWrappedAccessibleChildrenManager; |
49 | | } |
50 | | |
51 | | namespace accessibility { |
52 | | |
53 | | class AccessibleShapeInfo; |
54 | | class AccessibleShapeTreeInfo; |
55 | | |
56 | | typedef ::cppu::ImplHelper4 < css::beans::XPropertyChangeListener |
57 | | , css::util::XModeChangeListener |
58 | | , css::container::XContainerListener |
59 | | , css::accessibility::XAccessibleEventListener |
60 | | > AccessibleControlShape_Base; |
61 | | /** @descr |
62 | | */ |
63 | | class SAL_DLLPUBLIC_RTTI AccessibleControlShape final |
64 | | :public AccessibleShape |
65 | | ,public AccessibleControlShape_Base |
66 | | { |
67 | | public: |
68 | | AccessibleControlShape( |
69 | | const AccessibleShapeInfo& rShapeInfo, |
70 | | const AccessibleShapeTreeInfo& rShapeTreeInfo); |
71 | | virtual ~AccessibleControlShape( ) override; |
72 | | |
73 | 0 | const css::uno::Reference< css::beans::XPropertySet >& GetControlModel( ) const { return m_xControlModel;} |
74 | | AccessibleControlShape* GetLabeledByControlShape(); |
75 | | |
76 | | private: |
77 | | //--- XAccessibleComponent ------------------------------- |
78 | | /// forward the focus to the contained control(in alive mode) |
79 | | virtual void SAL_CALL grabFocus( ) override; |
80 | | |
81 | | //--- XAccessibleContext --------------------------------- |
82 | | virtual sal_Int64 SAL_CALL getAccessibleChildCount( ) override; |
83 | | virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int64 i ) override; |
84 | | virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) override; |
85 | | |
86 | | //--- XInterface ----------------------------------------- |
87 | | DECLARE_XINTERFACE( ) |
88 | | |
89 | | //--- XTypeProvider -------------------------------------- |
90 | | DECLARE_XTYPEPROVIDER( ) |
91 | | |
92 | | //--- XPropertyChangeListener ---------------------------- |
93 | | virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& _rEvent ) override; |
94 | | |
95 | | //--- XComponent ----------------------------------------- |
96 | | virtual void SAL_CALL disposing( ) override; |
97 | | |
98 | | //--- XEventListener ------------------------------------- |
99 | | virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; |
100 | | |
101 | | //--- XModeChangeListener -------------------------------- |
102 | | virtual void SAL_CALL modeChanged( const css::util::ModeChangeEvent& _rSource ) override; |
103 | | |
104 | | //--- XAccessibleEventListener ---------------------------- |
105 | | virtual void SAL_CALL notifyEvent( const css::accessibility::AccessibleEventObject& aEvent ) override; |
106 | | |
107 | | // XVclContainerListener |
108 | | virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& Event ) override; |
109 | | virtual void SAL_CALL elementRemoved( const css::container::ContainerEvent& Event ) override; |
110 | | virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& Event ) override; |
111 | | |
112 | | /** Initialize a new shape. See the documentation of the base' constructor |
113 | | for the reason of this method's existence. |
114 | | */ |
115 | | virtual void Init( ) override; |
116 | | |
117 | | /// Create a name string that contains the accessible name. |
118 | | virtual OUString |
119 | | CreateAccessibleBaseName( ) override; |
120 | | |
121 | | /** Create a unique name string that contains the accessible name. The |
122 | | name consists of the base name and the index. |
123 | | */ |
124 | | virtual OUString |
125 | | CreateAccessibleName( ) override; |
126 | | |
127 | | /// Create a description string that contains the accessible description. |
128 | | OUString CreateAccessibleDescription(); |
129 | | |
130 | | #ifdef DBG_UTIL |
131 | | /// Set the specified state |
132 | | virtual bool SetState( sal_Int64 _nState ) override; |
133 | | #endif // DBG_UTIL |
134 | | |
135 | | /// (safely) reads the given property from the model of the UNO control |
136 | | OUString getControlModelStringProperty( const OUString& _rPropertyName ) const; |
137 | | |
138 | | /// ensure that our control model exists(will be retrieved upon need only) |
139 | | bool ensureControlModelAccess( ); |
140 | | |
141 | | /// ensures that we're listening for the given property if(and only if!) necessary |
142 | | bool ensureListeningState( const bool _bCurrentlyListening, const bool _bNeedNewListening, |
143 | | const OUString& _rPropertyName ); |
144 | | |
145 | | /// starts multiplexing the state changes of our aggregate context |
146 | | void startStateMultiplexing( ); |
147 | | /// stops multiplexing the state changes of our aggregate context |
148 | | void stopStateMultiplexing( ); |
149 | | |
150 | | /** adjusts our AccessibleRole, depending on the control type we're working for |
151 | | |
152 | | <p>Only to be called during initialization</p> |
153 | | */ |
154 | | void adjustAccessibleRole( ); |
155 | | |
156 | | /** initializes composed states of the context |
157 | | |
158 | | <p>Some of the states of our inner context need to be propagated to the "composed context", too |
159 | | (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes, |
160 | | at initialization time, this method is used.</p> |
161 | | */ |
162 | | void initializeComposedState( ); |
163 | | |
164 | | /// determines whether the control is in alive mode |
165 | | bool isControlInAliveMode(); |
166 | | |
167 | | AccessibleControlShape(const AccessibleControlShape&) = delete; |
168 | | AccessibleControlShape& operator= (const AccessibleControlShape&) = delete; |
169 | | |
170 | | css::uno::Reference< css::beans::XPropertySet > |
171 | | m_xControlModel; |
172 | | css::uno::Reference< css::beans::XPropertySetInfo > |
173 | | m_xModelPropsMeta; // cache this for performance reasons |
174 | | css::uno::Reference< css::awt::XControl > |
175 | | m_xUnoControl; // our UNO control |
176 | | |
177 | | css::uno::WeakReference< css::accessibility::XAccessibleContext > |
178 | | m_aControlContext; // the AccessibleContext of the control |
179 | | css::uno::Reference< css::uno::XAggregation > |
180 | | m_xControlContextProxy; // the proxy for "aggregating" the AccessibleContext of the control |
181 | | css::uno::Reference< css::lang::XTypeProvider > |
182 | | m_xControlContextTypeAccess; // cached interface of our aggregate |
183 | | css::uno::Reference< css::lang::XComponent > |
184 | | m_xControlContextComponent; // cached interface of our aggregate |
185 | | |
186 | | rtl::Reference<::accessibility::OWrappedAccessibleChildrenManager> |
187 | | m_pChildManager; |
188 | | |
189 | | bool m_bListeningForName : 1; // are we currently listening for changes of the "Name" property? |
190 | | bool m_bListeningForDesc : 1; // are we currently listening for changes of the "HelpText" property? |
191 | | bool m_bMultiplexingStates : 1; // are we currently multiplexing state changes of the native context? |
192 | | bool m_bDisposeNativeContext : 1; // do we need to dispose mxNativeContextComponent? |
193 | | bool m_bWaitingForControl : 1; // if we are created before our control exists, we need to wait for it to appear ... |
194 | | }; |
195 | | |
196 | | } // end of namespace accessibility |
197 | | |
198 | | #endif |
199 | | |
200 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |