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_SVX_ACCESSIBLECONTROLSHAPE_HXX
21 #define INCLUDED_SVX_ACCESSIBLECONTROLSHAPE_HXX
23 #include <svx/AccessibleShape.hxx>
25 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
26 #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
27 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
28 #include <com/sun/star/container/XContainerListener.hpp>
29 #include <cppuhelper/implbase4.hxx>
30 #include <comphelper/uno3.hxx>
32 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
38 class OWrappedAccessibleChildrenManager
;
42 namespace accessibility
{
44 typedef ::cppu::ImplHelper4
< css::beans::XPropertyChangeListener
45 , css::util::XModeChangeListener
46 , css::container::XContainerListener
47 , css::accessibility::XAccessibleEventListener
48 > AccessibleControlShape_Base
;
51 class AccessibleControlShape
52 :public AccessibleShape
53 ,public AccessibleControlShape_Base
56 //===== internal ========================================================
57 AccessibleControlShape(
58 const AccessibleShapeInfo
& rShapeInfo
,
59 const AccessibleShapeTreeInfo
& rShapeTreeInfo
);
60 virtual ~AccessibleControlShape( ) override
;
62 const css::uno::Reference
< css::beans::XPropertySet
>& SAL_CALL
GetControlModel( ) { return m_xControlModel
;} ;
63 AccessibleControlShape
* SAL_CALL
GetLabeledByControlShape();
66 //--- XAccessibleComponent -------------------------------
67 /// forward the focus to the contained control(in alive mode)
68 virtual void SAL_CALL
grabFocus( ) throw(css::uno::RuntimeException
, std::exception
) override
;
70 //--- XAccessibleContext ---------------------------------
71 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw(css::uno::RuntimeException
, std::exception
) override
;
72 virtual css::uno::Reference
< css::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) throw(css::lang::IndexOutOfBoundsException
, css::uno::RuntimeException
, std::exception
) override
;
73 virtual css::uno::Reference
< css::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (css::uno::RuntimeException
, std::exception
) override
;
75 //--- XServiceInfo ---------------------------------------
76 virtual OUString SAL_CALL
getImplementationName( ) throw(css::uno::RuntimeException
, std::exception
) override
;
78 //--- XInterface -----------------------------------------
81 //--- XTypeProvider --------------------------------------
82 DECLARE_XTYPEPROVIDER( )
84 //--- XPropertyChangeListener ----------------------------
85 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& _rEvent
) throw(css::uno::RuntimeException
, std::exception
) override
;
87 //--- XComponent -----------------------------------------
88 virtual void SAL_CALL
disposing( ) override
;
90 //--- XEventListener -------------------------------------
91 virtual void SAL_CALL
disposing(const css::lang::EventObject
& Source
) throw(css::uno::RuntimeException
, std::exception
) override
;
93 //--- XModeChangeListener --------------------------------
94 virtual void SAL_CALL
modeChanged( const css::util::ModeChangeEvent
& _rSource
) throw(css::uno::RuntimeException
, std::exception
) override
;
96 //--- XAccessibleEventListener ----------------------------
97 virtual void SAL_CALL
notifyEvent( const css::accessibility::AccessibleEventObject
& aEvent
) throw(css::uno::RuntimeException
, std::exception
) override
;
99 //--- document::XEventListener ----------------------------
100 using AccessibleShape::notifyEvent
;
102 // XVclContainerListener
103 virtual void SAL_CALL
elementInserted( const css::container::ContainerEvent
& Event
) throw (css::uno::RuntimeException
, std::exception
) override
;
104 virtual void SAL_CALL
elementRemoved( const css::container::ContainerEvent
& Event
) throw (css::uno::RuntimeException
, std::exception
) override
;
105 virtual void SAL_CALL
elementReplaced( const css::container::ContainerEvent
& Event
) throw (css::uno::RuntimeException
, std::exception
) override
;
108 /** Initialize a new shape. See the documentation of the base' constructor
109 for the reason of this method's existence.
111 virtual void Init( ) override
;
113 /// Create a name string that contains the accessible name.
115 CreateAccessibleBaseName( )
116 throw(css::uno::RuntimeException
) override
;
118 /** Create a unique name string that contains the accessible name. The
119 name consists of the base name and the index.
122 CreateAccessibleName( )
123 throw(css::uno::RuntimeException
, std::exception
) override
;
125 /// Create a description string that contains the accessible description.
127 CreateAccessibleDescription( )
128 throw(css::uno::RuntimeException
, std::exception
) override
;
131 /// Set the specified state
132 virtual bool SetState( sal_Int16 _nState
) override
;
135 /// (safely) reads the given property from the model of the UNO control
136 OUString
getControlModelStringProperty( const OUString
& _rPropertyName
) const;
138 /// ensure that our control model exists(will be retrieved upon need only)
139 bool ensureControlModelAccess( );
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
);
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( );
150 /** adjusts our AccessibleRole, depending on the control type we're working for
152 <p>Only to be called during initialization</p>
154 void adjustAccessibleRole( );
156 /** initializes composed states of the context
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>
162 void initializeComposedState( );
165 css::uno::Reference
< css::beans::XPropertySet
>
167 css::uno::Reference
< css::beans::XPropertySetInfo
>
168 m_xModelPropsMeta
; // cache this for performance reasons
169 css::uno::Reference
< css::awt::XControl
>
170 m_xUnoControl
; // our UNO control
172 css::uno::WeakReference
< css::accessibility::XAccessibleContext
>
173 m_aControlContext
; // the AccessibleContext of the control
174 css::uno::Reference
< css::uno::XAggregation
>
175 m_xControlContextProxy
; // the proxy for "aggregating" the AccessibleContext of the control
176 css::uno::Reference
< css::lang::XTypeProvider
>
177 m_xControlContextTypeAccess
; // cached interface of our aggregate
178 css::uno::Reference
< css::lang::XComponent
>
179 m_xControlContextComponent
; // cached interface of our aggregate
181 rtl::Reference
<::comphelper::OWrappedAccessibleChildrenManager
>
184 bool m_bListeningForName
: 1; // are we currently listening for changes of the "Name" property?
185 bool m_bListeningForDesc
: 1; // are we currently listening for changes of the "HelpText" property?
186 bool m_bMultiplexingStates
: 1; // are we currently multiplexing state changes of the native context?
187 bool m_bDisposeNativeContext
: 1; // do we need to dispose mxNativeContextComponent?
188 bool m_bWaitingForControl
: 1; // if we are created before our control exists, we need to wait for it to appear ...
191 AccessibleControlShape(const AccessibleControlShape
&) = delete;
193 AccessibleControlShape
& operator= (const AccessibleControlShape
&) = delete;
196 } // end of namespace accessibility
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */