1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: AccessibleControlShape.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_HXX
32 #define _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_HXX
34 #include <svx/AccessibleShape.hxx>
36 #include <com/sun/star/accessibility/XAccessibleAction.hpp>
37 #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
38 #include <com/sun/star/util/XModeChangeBroadcaster.hpp>
39 #include <com/sun/star/container/XContainerListener.hpp>
40 #include <cppuhelper/implbase3.hxx>
41 #include <comphelper/uno3.hxx>
43 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
49 class OWrappedAccessibleChildrenManager
;
53 namespace accessibility
{
55 typedef ::cppu::ImplHelper4
< ::com::sun::star::beans::XPropertyChangeListener
56 , ::com::sun::star::util::XModeChangeListener
57 , ::com::sun::star::container::XContainerListener
58 , ::com::sun::star::accessibility::XAccessibleEventListener
59 > AccessibleControlShape_Base
;
62 class AccessibleControlShape
63 :public AccessibleShape
64 ,public AccessibleControlShape_Base
67 //===== internal ========================================================
68 AccessibleControlShape(
69 const AccessibleShapeInfo
& rShapeInfo
,
70 const AccessibleShapeTreeInfo
& rShapeTreeInfo
);
71 virtual ~AccessibleControlShape( );
74 //--- XAccessible ----------------------------------------
75 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleContext
> SAL_CALL
getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException
);
77 //--- XAccessibleComponent -------------------------------
78 /// forward the focus to the contained control(in alive mode)
79 virtual void SAL_CALL
grabFocus( ) throw(::com::sun::star::uno::RuntimeException
);
81 //--- XAccessibleContext ---------------------------------
82 virtual sal_Int32 SAL_CALL
getAccessibleChildCount( ) throw(::com::sun::star::uno::RuntimeException
);
83 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
);
84 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::accessibility::XAccessibleRelationSet
> SAL_CALL
getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException
);
86 //--- XServiceInfo ---------------------------------------
87 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
89 //--- XInterface -----------------------------------------
92 //--- XTypeProvider --------------------------------------
93 DECLARE_XTYPEPROVIDER( )
95 //--- XPropertyChangeListener ----------------------------
96 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw(::com::sun::star::uno::RuntimeException
);
98 //--- XComponent -----------------------------------------
99 virtual void SAL_CALL
disposing( );
101 //--- XEventListener -------------------------------------
102 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
104 //--- XModeChangeListener --------------------------------
105 virtual void SAL_CALL
modeChanged( const ::com::sun::star::util::ModeChangeEvent
& _rSource
) throw(::com::sun::star::uno::RuntimeException
);
107 //--- XAccessibleEventListener ----------------------------
108 virtual void SAL_CALL
notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject
& aEvent
) throw(::com::sun::star::uno::RuntimeException
);
110 //--- document::XEventListener ----------------------------
111 using AccessibleShape::notifyEvent
;
113 // XVclContainerListener
114 virtual void SAL_CALL
elementInserted( const ::com::sun::star::container::ContainerEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
115 virtual void SAL_CALL
elementRemoved( const ::com::sun::star::container::ContainerEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
116 virtual void SAL_CALL
elementReplaced( const ::com::sun::star::container::ContainerEvent
& Event
) throw (::com::sun::star::uno::RuntimeException
);
119 /** Initialize a new shape. See the documentation of the base' constructor
120 for the reason of this method's existence.
122 virtual void Init( );
124 /// Create a name string that contains the accessible name.
125 virtual ::rtl::OUString
126 CreateAccessibleBaseName( )
127 throw(::com::sun::star::uno::RuntimeException
);
129 /** Create a unique name string that contains the accessible name. The
130 name consists of the base name and the index.
132 virtual ::rtl::OUString
133 CreateAccessibleName( )
134 throw(::com::sun::star::uno::RuntimeException
);
136 /// Create a description string that contains the accessible description.
137 virtual ::rtl::OUString
138 CreateAccessibleDescription( )
139 throw(::com::sun::star::uno::RuntimeException
);
142 /// Set the specified state
143 virtual sal_Bool
SetState( sal_Int16 _nState
);
146 /// (safely) reads the given property from the model of the UNO control
147 ::rtl::OUString
getControlModelStringProperty( const ::rtl::OUString
& _rPropertyName
) const SAL_THROW(( ));
149 /// ensure that our control model exists(will be retrieved upon need only)
150 sal_Bool
ensureControlModelAccess( ) SAL_THROW(( ));
152 /// ensures that we're listening for the given property if(and only if!) necessary
153 sal_Bool
ensureListeningState( const sal_Bool _bCurrentlyListening
, const sal_Bool _bNeedNewListening
,
154 const ::rtl::OUString
& _rPropertyName
);
156 /// starts multiplexing the state changes of our aggregate context
157 void startStateMultiplexing( );
158 /// stops multiplexing the state changes of our aggregate context
159 void stopStateMultiplexing( );
161 /// retrieves the SdrObject of the shape we represent
162 SdrObject
* getSdrObject( ) const;
164 /** adjusts our AccessibleRole, depending on the control type we're working for
166 <p>Only to be called during inituialization</p>
168 void adjustAccessibleRole( );
170 /** initializes composed states of the context
172 <p>Some of the states of our inner context need to be propagated to the "composed context", too
173 (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes,
174 at initialization time, this method is used.</p>
176 void initializeComposedState( );
179 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>
181 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
>
182 m_xModelPropsMeta
; // cache this for performance reasons
183 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>
184 m_xUnoControl
; // our UNO control
186 ::com::sun::star::uno::WeakReference
< ::com::sun::star::accessibility::XAccessibleContext
>
187 m_aControlContext
; // the AccessibleContext of the control
188 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAggregation
>
189 m_xControlContextProxy
; // the proxy for "aggregating" the AccessibleContext of the control
190 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XTypeProvider
>
191 m_xControlContextTypeAccess
; // cached interface of our aggregate
192 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
>
193 m_xControlContextComponent
; // cached interface of our aggregate
195 ::comphelper::OWrappedAccessibleChildrenManager
*
198 sal_Bool m_bListeningForName
: 1; // are we currently listening for changes of the "Name" property?
199 sal_Bool m_bListeningForDesc
: 1; // are we currently listening for changes of the "HelpText" property?
200 sal_Bool m_bMultiplexingStates
: 1; // are we currently multiplexing state changes of the native context?
201 sal_Bool m_bDisposeNativeContext
: 1; // do we need to dispose mxNativeContextComponent?
202 sal_Bool m_bWaitingForControl
: 1; // if we are created before our control exists, we need to wait for it to appear ...
205 /** Don't use the default constructor. Use the public constructor that
206 takes the original shape and the parent as arguments instead.
208 AccessibleControlShape( );
210 /// Don't use the constructor. not implemented.
211 AccessibleControlShape(const AccessibleControlShape
&);
213 /// Don't use the assignment operator. not implemented.
214 AccessibleControlShape
& operator= (const AccessibleControlShape
&);
217 } // end of namespace accessibility