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( ); 71 72 //--- XAccessibleComponent ------------------------------- 73 /// forward the focus to the contained control(in alive mode) 74 virtual void SAL_CALL grabFocus( ); 75 76 //--- XAccessibleContext --------------------------------- 77 virtual sal_Int32 SAL_CALL getAccessibleChildCount( ); 78 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( sal_Int32 i ); 79 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet( ); 80 81 //--- XServiceInfo --------------------------------------- 82 virtual ::rtl::OUString SAL_CALL getImplementationName( ); 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 ); 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); 98 99 //--- XModeChangeListener -------------------------------- 100 virtual void SAL_CALL modeChanged( const ::com::sun::star::util::ModeChangeEvent& _rSource ); 101 102 //--- XAccessibleEventListener ---------------------------- 103 virtual void SAL_CALL notifyEvent( const ::com::sun::star::accessibility::AccessibleEventObject& aEvent ); 104 105 //--- document::XEventListener ---------------------------- 106 using AccessibleShape::notifyEvent; 107 108 // XVclContainerListener 109 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ); 110 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ); 111 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ); 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 123 /** Create a unique name string that contains the accessible name. The 124 name consists of the base name and the index. 125 */ 126 virtual ::rtl::OUString 127 CreateAccessibleName( ); 128 129 /// Create a description string that contains the accessible description. 130 virtual ::rtl::OUString 131 CreateAccessibleDescription( ); 132 133 #ifdef DBG_UTIL 134 /// Set the specified state 135 virtual sal_Bool SetState( sal_Int16 _nState ); 136 #endif // DBG_UTIL 137 138 /// (safely) reads the given property from the model of the UNO control 139 ::rtl::OUString getControlModelStringProperty( const ::rtl::OUString& _rPropertyName ) const SAL_THROW(( )); 140 141 /// ensure that our control model exists(will be retrieved upon need only) 142 sal_Bool ensureControlModelAccess( ) SAL_THROW(( )); 143 144 /// ensures that we're listening for the given property if(and only if!) necessary 145 sal_Bool ensureListeningState( const sal_Bool _bCurrentlyListening, const sal_Bool _bNeedNewListening, 146 const ::rtl::OUString& _rPropertyName ); 147 148 /// starts multiplexing the state changes of our aggregate context 149 void startStateMultiplexing( ); 150 /// stops multiplexing the state changes of our aggregate context 151 void stopStateMultiplexing( ); 152 153 /// retrieves the SdrObject of the shape we represent 154 SdrObject* getSdrObject( ) const; 155 156 /** adjusts our AccessibleRole, depending on the control type we're working for 157 158 <p>Only to be called during initialization</p> 159 */ 160 void adjustAccessibleRole( ); 161 162 /** initializes composed states of the context 163 164 <p>Some of the states of our inner context need to be propagated to the "composed context", too 165 (such as "checked" for check boxes). At lifetime, this is done by multiplexing state changes, 166 at initialization time, this method is used.</p> 167 */ 168 void initializeComposedState( ); 169 170 private: 171 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > 172 m_xControlModel; 173 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > 174 m_xModelPropsMeta; // cache this for performance reasons 175 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl > 176 m_xUnoControl; // our UNO control 177 178 ::com::sun::star::uno::WeakReference< ::com::sun::star::accessibility::XAccessibleContext > 179 m_aControlContext; // the AccessibleContext of the control 180 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAggregation > 181 m_xControlContextProxy; // the proxy for "aggregating" the AccessibleContext of the control 182 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XTypeProvider > 183 m_xControlContextTypeAccess; // cached interface of our aggregate 184 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > 185 m_xControlContextComponent; // cached interface of our aggregate 186 187 ::comphelper::OWrappedAccessibleChildrenManager* 188 m_pChildManager; 189 190 sal_Bool m_bListeningForName : 1; // are we currently listening for changes of the "Name" property? 191 sal_Bool m_bListeningForDesc : 1; // are we currently listening for changes of the "HelpText" property? 192 sal_Bool m_bMultiplexingStates : 1; // are we currently multiplexing state changes of the native context? 193 sal_Bool m_bDisposeNativeContext : 1; // do we need to dispose mxNativeContextComponent? 194 sal_Bool m_bWaitingForControl : 1; // if we are created before our control exists, we need to wait for it to appear ... 195 196 private: 197 /** Don't use the default constructor. Use the public constructor that 198 takes the original shape and the parent as arguments instead. 199 */ 200 AccessibleControlShape( ); 201 202 /// Don't use the constructor. not implemented. 203 AccessibleControlShape(const AccessibleControlShape&); 204 205 /// Don't use the assignment operator. not implemented. 206 AccessibleControlShape& operator= (const AccessibleControlShape&); 207 }; 208 209 } // end of namespace accessibility 210 211 #endif 212