Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / AccessibleControlShape.hxx
blobe19cf1499101bc50b712500df7320397ea331c15
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/implbase3.hxx>
30 #include <comphelper/uno3.hxx>
32 namespace com { namespace sun { namespace star { namespace awt {
33 class XControl;
34 } } } }
36 namespace comphelper
38 class OWrappedAccessibleChildrenManager;
41 class SdrObject;
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;
49 /** @descr
51 class AccessibleControlShape
52 :public AccessibleShape
53 ,public AccessibleControlShape_Base
55 public:
56 //===== internal ========================================================
57 AccessibleControlShape(
58 const AccessibleShapeInfo& rShapeInfo,
59 const AccessibleShapeTreeInfo& rShapeTreeInfo);
60 virtual ~AccessibleControlShape( );
62 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL GetControlModel( ) { return m_xControlModel;} ;
63 AccessibleControlShape* SAL_CALL GetLabeledByControlShape();
64 protected:
65 //--- XAccessible ----------------------------------------
66 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
68 //--- XAccessibleComponent -------------------------------
69 /// forward the focus to the contained control(in alive mode)
70 virtual void SAL_CALL grabFocus( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 //--- XAccessibleContext ---------------------------------
73 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
74 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, std::exception) SAL_OVERRIDE;
75 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
77 //--- XServiceInfo ---------------------------------------
78 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 //--- XInterface -----------------------------------------
81 DECLARE_XINTERFACE( )
83 //--- XTypeProvider --------------------------------------
84 DECLARE_XTYPEPROVIDER( )
86 //--- XPropertyChangeListener ----------------------------
87 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
89 //--- XComponent -----------------------------------------
90 virtual void SAL_CALL disposing( ) SAL_OVERRIDE;
92 //--- XEventListener -------------------------------------
93 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 //--- XModeChangeListener --------------------------------
96 virtual void SAL_CALL modeChanged( const ::com::sun::star::util::ModeChangeEvent& _rSource ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
98 //--- XAccessibleEventListener ----------------------------
99 virtual void SAL_CALL notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
101 //--- document::XEventListener ----------------------------
102 using AccessibleShape::notifyEvent;
104 // XVclContainerListener
105 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
106 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
107 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
109 protected:
110 /** Initialize a new shape. See the documentation of the base' constructor
111 for the reason of this method's existence.
113 virtual void Init( ) SAL_OVERRIDE;
115 /// Create a name string that contains the accessible name.
116 virtual OUString
117 CreateAccessibleBaseName( )
118 throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
120 /** Create a unique name string that contains the accessible name. The
121 name consists of the base name and the index.
123 virtual OUString
124 CreateAccessibleName( )
125 throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
127 /// Create a description string that contains the accessible description.
128 virtual OUString
129 CreateAccessibleDescription( )
130 throw(::com::sun::star::uno::RuntimeException) SAL_OVERRIDE;
132 #ifdef DBG_UTIL
133 /// Set the specified state
134 virtual bool SetState( sal_Int16 _nState ) SAL_OVERRIDE;
135 #endif // DBG_UTIL
137 /// (safely) reads the given property from the model of the UNO control
138 OUString getControlModelStringProperty( const OUString& _rPropertyName ) const;
140 /// ensure that our control model exists(will be retrieved upon need only)
141 bool ensureControlModelAccess( );
143 /// ensures that we're listening for the given property if(and only if!) necessary
144 bool ensureListeningState( const bool _bCurrentlyListening, const bool _bNeedNewListening,
145 const OUString& _rPropertyName );
147 /// starts multiplexing the state changes of our aggregate context
148 void startStateMultiplexing( );
149 /// stops multiplexing the state changes of our aggregate context
150 void stopStateMultiplexing( );
152 /// retrieves the SdrObject of the shape we represent
153 SdrObject* getSdrObject( ) const;
155 /** adjusts our AccessibleRole, depending on the control type we're working for
157 <p>Only to be called during inituialization</p>
159 void adjustAccessibleRole( );
161 /** initializes composed states of the context
163 <p>Some of the states of our inner context need to be propagated to the "composed context", too
164 (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes,
165 at initialization time, this method is used.</p>
167 void initializeComposedState( );
169 private:
170 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
171 m_xControlModel;
172 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
173 m_xModelPropsMeta; // cache this for performance reasons
174 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl >
175 m_xUnoControl; // our UNO control
177 ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessibleContext >
178 m_aControlContext; // the AccessibleContext of the control
179 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation >
180 m_xControlContextProxy; // the proxy for "aggregating" the AccessibleContext of the control
181 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider >
182 m_xControlContextTypeAccess; // cached interface of our aggregate
183 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
184 m_xControlContextComponent; // cached interface of our aggregate
186 ::comphelper::OWrappedAccessibleChildrenManager*
187 m_pChildManager;
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 ...
195 private:
196 AccessibleControlShape(const AccessibleControlShape&) SAL_DELETED_FUNCTION;
198 AccessibleControlShape& operator= (const AccessibleControlShape&) SAL_DELETED_FUNCTION;
201 } // end of namespace accessibility
203 #endif
205 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */