1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_HXX 25 #define _SVX_ACCESSIBILITY_ACCESSIBLE_CONTROL_SHAPE_HXX 26 27 #include <svx/AccessibleShape.hxx> 28 29 #include <com/sun/star/accessibility/XAccessibleAction.hpp> 30 #include <com/sun/star/accessibility/XAccessibleEventListener.hpp> 31 #include <com/sun/star/util/XModeChangeBroadcaster.hpp> 32 #include <com/sun/star/container/XContainerListener.hpp> 33 #include <cppuhelper/implbase3.hxx> 34 #include <comphelper/uno3.hxx> 35 36 namespace com { namespace sun { namespace star { namespace awt { 37 class XControl; 38 } } } } 39 40 namespace comphelper 41 { 42 class OWrappedAccessibleChildrenManager; 43 } 44 45 class SdrObject; 46 namespace accessibility { 47 48 typedef ::cppu::ImplHelper4 < ::com::sun::star::beans::XPropertyChangeListener 49 , ::com::sun::star::util::XModeChangeListener 50 , ::com::sun::star::container::XContainerListener 51 , ::com::sun::star::accessibility::XAccessibleEventListener 52 > AccessibleControlShape_Base; 53 /** @descr 54 */ 55 class AccessibleControlShape 56 :public AccessibleShape 57 ,public AccessibleControlShape_Base 58 { 59 public: 60 //===== internal ======================================================== 61 AccessibleControlShape( 62 const AccessibleShapeInfo& rShapeInfo, 63 const AccessibleShapeTreeInfo& rShapeTreeInfo); 64 virtual ~AccessibleControlShape( ); 65 GetControlModel()66 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL GetControlModel( ) { return m_xControlModel;} ; 67 AccessibleControlShape* SAL_CALL GetLabeledByControlShape(); 68 protected: 69 //--- XAccessible ---------------------------------------- 70 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext> SAL_CALL getAccessibleContext( ) throw(::com::sun::star::uno::RuntimeException); 71 72 //--- XAccessibleComponent ------------------------------- 73 /// forward the focus to the contained control(in alive mode) 74 virtual void SAL_CALL grabFocus( ) throw(::com::sun::star::uno::RuntimeException); 75 76 //--- XAccessibleContext --------------------------------- 77 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ) throw(::com::sun::star::uno::RuntimeException); 78 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); 79 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ) throw (::com::sun::star::uno::RuntimeException); 80 81 //--- XServiceInfo --------------------------------------- 82 virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException); 83 84 //--- XInterface ----------------------------------------- 85 DECLARE_XINTERFACE( ) 86 87 //--- XTypeProvider -------------------------------------- 88 DECLARE_XTYPEPROVIDER( ) 89 90 //--- XPropertyChangeListener ---------------------------- 91 virtual void SAL_CALL propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw(::com::sun::star::uno::RuntimeException); 92 93 //--- XComponent ----------------------------------------- 94 virtual void SAL_CALL disposing( ); 95 96 //--- XEventListener ------------------------------------- 97 virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw(::com::sun::star::uno::RuntimeException); 98 99 //--- XModeChangeListener -------------------------------- 100 virtual void SAL_CALL modeChanged( const ::com::sun::star::util::ModeChangeEvent& _rSource ) throw(::com::sun::star::uno::RuntimeException); 101 102 //--- XAccessibleEventListener ---------------------------- 103 virtual void SAL_CALL notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent ) throw(::com::sun::star::uno::RuntimeException); 104 105 //--- document::XEventListener ---------------------------- 106 using AccessibleShape::notifyEvent; 107 108 // XVclContainerListener 109 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 110 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 111 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); 112 113 protected: 114 /** Initialize a new shape. See the documentation of the base' constructor 115 for the reason of this method's existence. 116 */ 117 virtual void Init( ); 118 119 /// Create a name string that contains the accessible name. 120 virtual ::rtl::OUString 121 CreateAccessibleBaseName( ) 122 throw(::com::sun::star::uno::RuntimeException); 123 124 /** Create a unique name string that contains the accessible name. The 125 name consists of the base name and the index. 126 */ 127 virtual ::rtl::OUString 128 CreateAccessibleName( ) 129 throw(::com::sun::star::uno::RuntimeException); 130 131 /// Create a description string that contains the accessible description. 132 virtual ::rtl::OUString 133 CreateAccessibleDescription( ) 134 throw(::com::sun::star::uno::RuntimeException); 135 136 #ifdef DBG_UTIL 137 /// Set the specified state 138 virtual sal_Bool SetState( sal_Int16 _nState ); 139 #endif // DBG_UTIL 140 141 /// (safely) reads the given property from the model of the UNO control 142 ::rtl::OUString getControlModelStringProperty( const ::rtl::OUString& _rPropertyName ) const SAL_THROW(( )); 143 144 /// ensure that our control model exists(will be retrieved upon need only) 145 sal_Bool ensureControlModelAccess( ) SAL_THROW(( )); 146 147 /// ensures that we're listening for the given property if(and only if!) necessary 148 sal_Bool ensureListeningState( const sal_Bool _bCurrentlyListening, const sal_Bool _bNeedNewListening, 149 const ::rtl::OUString& _rPropertyName ); 150 151 /// starts multiplexing the state changes of our aggregate context 152 void startStateMultiplexing( ); 153 /// stops multiplexing the state changes of our aggregate context 154 void stopStateMultiplexing( ); 155 156 /// retrieves the SdrObject of the shape we represent 157 SdrObject* getSdrObject( ) const; 158 159 /** adjusts our AccessibleRole, depending on the control type we're working for 160 161 <p>Only to be called during inituialization</p> 162 */ 163 void adjustAccessibleRole( ); 164 165 /** initializes composed states of the context 166 167 <p>Some of the states of our inner context need to be propagated to the "composed context", too 168 (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes, 169 at initialization time, this method is used.</p> 170 */ 171 void initializeComposedState( ); 172 173 private: 174 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 175 m_xControlModel; 176 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 177 m_xModelPropsMeta; // cache this for performance reasons 178 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > 179 m_xUnoControl; // our UNO control 180 181 ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessibleContext > 182 m_aControlContext; // the AccessibleContext of the control 183 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > 184 m_xControlContextProxy; // the proxy for "aggregating" the AccessibleContext of the control 185 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > 186 m_xControlContextTypeAccess; // cached interface of our aggregate 187 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > 188 m_xControlContextComponent; // cached interface of our aggregate 189 190 ::comphelper::OWrappedAccessibleChildrenManager* 191 m_pChildManager; 192 193 sal_Bool m_bListeningForName : 1; // are we currently listening for changes of the "Name" property? 194 sal_Bool m_bListeningForDesc : 1; // are we currently listening for changes of the "HelpText" property? 195 sal_Bool m_bMultiplexingStates : 1; // are we currently multiplexing state changes of the native context? 196 sal_Bool m_bDisposeNativeContext : 1; // do we need to dispose mxNativeContextComponent? 197 sal_Bool m_bWaitingForControl : 1; // if we are created before our control exists, we need to wait for it to appear ... 198 199 private: 200 /** Don't use the default constructor. Use the public constructor that 201 takes the original shape and the parent as arguments instead. 202 */ 203 AccessibleControlShape( ); 204 205 /// Don't use the constructor. not implemented. 206 AccessibleControlShape(const AccessibleControlShape&); 207 208 /// Don't use the assignment operator. not implemented. 209 AccessibleControlShape& operator= (const AccessibleControlShape&); 210 }; 211 212 } // end of namespace accessibility 213 214 #endif 215