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 _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_HXX
21 #define _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_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/implbase3.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
< ::com::sun::star::beans::XPropertyChangeListener
45 , ::com::sun::star::util::XModeChangeListener
46 , ::com::sun::star::container::XContainerListener
47 , ::com::sun::star::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( );
63 //--- XAccessible ----------------------------------------
64 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException
);
66 //--- XAccessibleComponent -------------------------------
67 /// forward the focus to the contained control(in alive mode)
68 virtual void SAL_CALL
grabFocus( ) throw(::com::sun::star::uno::RuntimeException
);
70 //--- XAccessibleContext ---------------------------------
71 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw(::com::sun::star::uno::RuntimeException
);
72 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessible
> SAL_CALL
getAccessibleChild( sal_Int32 i
) throw(::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::uno::RuntimeException
);
73 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
75 //--- XServiceInfo ---------------------------------------
76 virtual OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
78 //--- XInterface -----------------------------------------
81 //--- XTypeProvider --------------------------------------
82 DECLARE_XTYPEPROVIDER( )
84 //--- XPropertyChangeListener ----------------------------
85 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw(::com::sun::star::uno::RuntimeException
);
87 //--- XComponent -----------------------------------------
88 virtual void SAL_CALL
disposing( );
90 //--- XEventListener -------------------------------------
91 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
93 //--- XModeChangeListener --------------------------------
94 virtual void SAL_CALL
modeChanged( const ::com::sun::star::util::ModeChangeEvent
& _rSource
) throw(::com::sun::star::uno::RuntimeException
);
96 //--- XAccessibleEventListener ----------------------------
97 virtual void SAL_CALL
notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
99 //--- document::XEventListener ----------------------------
100 using AccessibleShape::notifyEvent
;
102 // XVclContainerListener
103 virtual void SAL_CALL
elementInserted( const ::com::sun::star::container::ContainerEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
104 virtual void SAL_CALL
elementRemoved( const ::com::sun::star::container::ContainerEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
105 virtual void SAL_CALL
elementReplaced( const ::com::sun::star::container::ContainerEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
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( );
113 /// Create a name string that contains the accessible name.
115 CreateAccessibleBaseName( )
116 throw(::com::sun::star::uno::RuntimeException
);
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(::com::sun::star::uno::RuntimeException
);
125 /// Create a description string that contains the accessible description.
127 CreateAccessibleDescription( )
128 throw(::com::sun::star::uno::RuntimeException
);
131 /// Set the specified state
132 virtual sal_Bool
SetState( sal_Int16 _nState
);
135 /// (safely) reads the given property from the model of the UNO control
136 OUString
getControlModelStringProperty( const OUString
& _rPropertyName
) const SAL_THROW(( ));
138 /// ensure that our control model exists(will be retrieved upon need only)
139 sal_Bool
ensureControlModelAccess( ) SAL_THROW(( ));
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 /// retrieves the SdrObject of the shape we represent
151 SdrObject
* getSdrObject( ) const;
153 /** adjusts our AccessibleRole, depending on the control type we're working for
155 <p>Only to be called during inituialization</p>
157 void adjustAccessibleRole( );
159 /** initializes composed states of the context
161 <p>Some of the states of our inner context need to be propagated to the "composed context", too
162 (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes,
163 at initialization time, this method is used.</p>
165 void initializeComposedState( );
168 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
170 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
171 m_xModelPropsMeta
; // cache this for performance reasons
172 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>
173 m_xUnoControl
; // our UNO control
175 ::com::sun::star::uno::WeakReference
< ::com::sun::star::accessibility::XAccessibleContext
>
176 m_aControlContext
; // the AccessibleContext of the control
177 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
>
178 m_xControlContextProxy
; // the proxy for "aggregating" the AccessibleContext of the control
179 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XTypeProvider
>
180 m_xControlContextTypeAccess
; // cached interface of our aggregate
181 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
182 m_xControlContextComponent
; // cached interface of our aggregate
184 ::comphelper::OWrappedAccessibleChildrenManager
*
187 bool m_bListeningForName
: 1; // are we currently listening for changes of the "Name" property?
188 bool m_bListeningForDesc
: 1; // are we currently listening for changes of the "HelpText" property?
189 bool m_bMultiplexingStates
: 1; // are we currently multiplexing state changes of the native context?
190 bool m_bDisposeNativeContext
: 1; // do we need to dispose mxNativeContextComponent?
191 bool m_bWaitingForControl
: 1; // if we are created before our control exists, we need to wait for it to appear ...
194 /** Don't use the default constructor. Use the public constructor that
195 takes the original shape and the parent as arguments instead.
197 AccessibleControlShape( );
199 /// Don't use the constructor. not implemented.
200 AccessibleControlShape(const AccessibleControlShape
&);
202 /// Don't use the assignment operator. not implemented.
203 AccessibleControlShape
& operator= (const AccessibleControlShape
&);
206 } // end of namespace accessibility
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */