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 25 #ifndef ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOX_HXX 26 #define ACCESSIBILITY_EXT_ACCESSIBLEBROWSEBOX_HXX 27 28 #include <accessibility/extended/AccessibleBrowseBoxBase.hxx> 29 #include <cppuhelper/weakref.hxx> 30 #include <svtools/accessibletableprovider.hxx> 31 32 33 #include <memory> 34 35 // ============================================================================ 36 37 namespace accessibility { 38 39 class AccessibleBrowseBoxImpl; 40 class AccessibleBrowseBoxTable; 41 42 // ============================================================================ 43 44 /** This class represents the complete accessible BrowseBox object. */ 45 class AccessibleBrowseBox : public AccessibleBrowseBoxBase 46 { 47 friend class AccessibleBrowseBoxAccess; 48 49 protected: 50 AccessibleBrowseBox( 51 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, 52 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator, 53 ::svt::IAccessibleTableProvider& _rBrowseBox 54 ); 55 56 virtual ~AccessibleBrowseBox(); 57 58 /** sets the XAccessible which created the context 59 60 <p>To be called only once, and only if in the ctor NULL was passed.</p> 61 */ 62 void setCreator( 63 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxCreator 64 ); 65 66 /** Cleans up members. */ 67 using AccessibleBrowseBoxBase::disposing; 68 virtual void SAL_CALL disposing(); 69 70 protected: 71 // XAccessibleContext ----------------------------------------------------- 72 73 /** @return The count of visible children. */ 74 virtual sal_Int32 SAL_CALL getAccessibleChildCount() 75 throw ( ::com::sun::star::uno::RuntimeException ); 76 77 /** @return The XAccessible interface of the specified child. */ 78 virtual ::com::sun::star::uno::Reference< 79 ::com::sun::star::accessibility::XAccessible > SAL_CALL 80 getAccessibleChild( sal_Int32 nChildIndex ) 81 throw ( ::com::sun::star::lang::IndexOutOfBoundsException, 82 ::com::sun::star::uno::RuntimeException ); 83 84 /** @return The role of this object (a table). */ 85 // virtual sal_Int16 SAL_CALL getAccessibleRole() 86 // throw ( ::com::sun::star::uno::RuntimeException ); 87 88 // XAccessibleComponent --------------------------------------------------- 89 90 /** @return 91 The accessible child rendered under the given point. 92 */ 93 virtual ::com::sun::star::uno::Reference< 94 ::com::sun::star::accessibility::XAccessible > SAL_CALL 95 getAccessibleAtPoint( const ::com::sun::star::awt::Point& rPoint ) 96 throw ( ::com::sun::star::uno::RuntimeException ); 97 98 /** Grabs the focus to the BrowseBox. */ 99 virtual void SAL_CALL grabFocus() 100 throw ( ::com::sun::star::uno::RuntimeException ); 101 102 /** @return The key bindings associated with this object. */ 103 virtual ::com::sun::star::uno::Any SAL_CALL getAccessibleKeyBinding() 104 throw ( ::com::sun::star::uno::RuntimeException ); 105 106 // XServiceInfo ----------------------------------------------------------- 107 108 /** @return 109 The name of this class. 110 */ 111 virtual ::rtl::OUString SAL_CALL getImplementationName() 112 throw ( ::com::sun::star::uno::RuntimeException ); 113 114 public: 115 // helper functions 116 /** commitHeaderBarEvent commit the event at all listeners of the column/row header bar 117 @param nEventId 118 the event id 119 @param rNewValue 120 the new value 121 @param rOldValue 122 the old value 123 */ 124 void commitHeaderBarEvent(sal_Int16 nEventId, 125 const ::com::sun::star::uno::Any& rNewValue, 126 const ::com::sun::star::uno::Any& rOldValue,sal_Bool _bColumnHeaderBar = sal_True); 127 128 // helper functions 129 /** commitTableEvent commit the event at all listeners of the table 130 @param nEventId 131 the event id 132 @param rNewValue 133 the new value 134 @param rOldValue 135 the old value 136 */ 137 void commitTableEvent(sal_Int16 nEventId, 138 const ::com::sun::star::uno::Any& rNewValue, 139 const ::com::sun::star::uno::Any& rOldValue); 140 141 /** returns the accessible object for the row or the column header bar 142 */ 143 inline ::com::sun::star::uno::Reference< 144 ::com::sun::star::accessibility::XAccessible > getHeaderBar(::svt::AccessibleBrowseBoxObjType _eObjType)145 getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) 146 { 147 return implGetHeaderBar(_eObjType); 148 } 149 150 /** returns the accessible object for the table representation 151 */ 152 inline ::com::sun::star::uno::Reference< 153 ::com::sun::star::accessibility::XAccessible > getTable()154 getTable( ) 155 { 156 return implGetTable(); 157 } 158 159 protected: 160 // internal virtual methods ----------------------------------------------- 161 162 /** @attention This method requires locked mutex's and a living object. 163 @return The bounding box (VCL rect.) relative to the parent window. */ 164 virtual Rectangle implGetBoundingBox(); 165 /** @attention This method requires locked mutex's and a living object. 166 @return The bounding box (VCL rect.) in screen coordinates. */ 167 virtual Rectangle implGetBoundingBoxOnScreen(); 168 169 // internal helper methods ------------------------------------------------ 170 171 /** This method creates (once) and returns the accessible data table child. 172 @attention This method requires locked mutex's and a living object. 173 @return The XAccessible interface of the data table. */ 174 virtual ::com::sun::star::uno::Reference< 175 ::com::sun::star::accessibility::XAccessible > implGetTable(); 176 177 /** This method creates (once) and returns the specified header bar. 178 @attention This method requires locked mutex's and a living object. 179 @return The XAccessible interface of the header bar. */ 180 ::com::sun::star::uno::Reference< 181 ::com::sun::star::accessibility::XAccessible > 182 implGetHeaderBar( ::svt::AccessibleBrowseBoxObjType eObjType ); 183 184 /** This method returns one of the children that are always present: 185 Data table, row and column header bar or corner control. 186 @attention This method requires locked mutex's and a living object. 187 @return The XAccessible interface of the specified child. */ 188 ::com::sun::star::uno::Reference< 189 ::com::sun::star::accessibility::XAccessible > 190 implGetFixedChild( sal_Int32 nChildIndex ); 191 192 /** This method creates and returns an accessible table. 193 @return An AccessibleBrowseBoxTable. */ 194 virtual AccessibleBrowseBoxTable* createAccessibleTable(); 195 196 private: 197 // members ---------------------------------------------------------------- 198 ::std::auto_ptr< AccessibleBrowseBoxImpl > m_pImpl; 199 }; 200 201 // ============================================================================ 202 /** the XAccessible which creates/returns an AccessibleBrowseBox 203 204 <p>The instance holds it's XAccessibleContext with a hard reference, while 205 the contxt holds this instance weak.</p> 206 */ 207 typedef ::cppu::WeakImplHelper1 < ::com::sun::star::accessibility::XAccessible 208 > AccessibleBrowseBoxAccess_Base; 209 210 class AccessibleBrowseBoxAccess :public AccessibleBrowseBoxAccess_Base 211 ,public ::svt::IAccessibleBrowseBox 212 { 213 private: 214 ::osl::Mutex m_aMutex; 215 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 216 m_xParent; 217 ::svt::IAccessibleTableProvider& m_rBrowseBox; 218 219 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > 220 m_xContext; 221 AccessibleBrowseBox* m_pContext; 222 // note that this pointer is valid as long as m_xContext is valid! 223 224 public: 225 AccessibleBrowseBoxAccess( 226 const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >& _rxParent, 227 ::svt::IAccessibleTableProvider& _rBrowseBox 228 ); 229 230 /// checks whether the accessible context is still alive 231 bool isContextAlive() const; 232 233 /// returns the AccessibleContext belonging to this Accessible getContext()234 inline AccessibleBrowseBox* getContext() { return m_pContext; } getContext() const235 inline const AccessibleBrowseBox* getContext() const { return m_pContext; } 236 237 protected: 238 virtual ~AccessibleBrowseBoxAccess(); 239 240 // XAccessible 241 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > 242 SAL_CALL getAccessibleContext() throw ( ::com::sun::star::uno::RuntimeException ); 243 244 // IAccessibleBrowseBox 245 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getMyself()246 getMyself() 247 { 248 return this; 249 } 250 void dispose(); isAlive() const251 virtual sal_Bool isAlive() const 252 { 253 return isContextAlive(); 254 } 255 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getHeaderBar(::svt::AccessibleBrowseBoxObjType _eObjType)256 getHeaderBar( ::svt::AccessibleBrowseBoxObjType _eObjType ) 257 { 258 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible; 259 AccessibleBrowseBox* pContext( getContext() ); 260 if ( pContext ) 261 xAccessible = pContext->getHeaderBar( _eObjType ); 262 return xAccessible; 263 } 264 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > getTable()265 getTable() 266 { 267 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > xAccessible; 268 AccessibleBrowseBox* pContext( getContext() ); 269 if ( pContext ) 270 xAccessible = pContext->getTable(); 271 return xAccessible; 272 } commitHeaderBarEvent(sal_Int16 nEventId,const::com::sun::star::uno::Any & rNewValue,const::com::sun::star::uno::Any & rOldValue,sal_Bool _bColumnHeaderBar)273 virtual void commitHeaderBarEvent( sal_Int16 nEventId, const ::com::sun::star::uno::Any& rNewValue, 274 const ::com::sun::star::uno::Any& rOldValue, sal_Bool _bColumnHeaderBar ) 275 { 276 AccessibleBrowseBox* pContext( getContext() ); 277 if ( pContext ) 278 pContext->commitHeaderBarEvent( nEventId, rNewValue, rOldValue, _bColumnHeaderBar ); 279 } commitTableEvent(sal_Int16 nEventId,const::com::sun::star::uno::Any & rNewValue,const::com::sun::star::uno::Any & rOldValue)280 virtual void commitTableEvent( sal_Int16 nEventId, 281 const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) 282 { 283 AccessibleBrowseBox* pContext( getContext() ); 284 if ( pContext ) 285 pContext->commitTableEvent( nEventId, rNewValue, rOldValue ); 286 } commitEvent(sal_Int16 nEventId,const::com::sun::star::uno::Any & rNewValue,const::com::sun::star::uno::Any & rOldValue)287 virtual void commitEvent( sal_Int16 nEventId, 288 const ::com::sun::star::uno::Any& rNewValue, const ::com::sun::star::uno::Any& rOldValue ) 289 { 290 AccessibleBrowseBox* pContext( getContext() ); 291 if ( pContext ) 292 pContext->commitEvent( nEventId, rNewValue, rOldValue ); 293 } 294 295 private: 296 AccessibleBrowseBoxAccess(); // never implemented 297 AccessibleBrowseBoxAccess( const AccessibleBrowseBoxAccess& ); // never implemented 298 AccessibleBrowseBoxAccess& operator=( const AccessibleBrowseBoxAccess& ); // never implemented 299 }; 300 301 // ============================================================================ 302 } // namespace accessibility 303 304 // ============================================================================ 305 306 #endif 307 308