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 //IAccessibility2 Implementation 2009----- 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svtools.hxx" 26 27 #ifndef _SVTOOLS_VCLXACCESSIBLEHEADERBAR_HXX_ 28 #include <svtools/vclxaccessibleheaderbaritem.hxx> 29 #endif 30 31 #ifndef _HEADBAR_HXX 32 #include <svtools/headbar.hxx> 33 #endif 34 35 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEEVENTID_HPP_ 36 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 37 #endif 38 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLEROLE_HPP_ 39 #include <com/sun/star/accessibility/AccessibleRole.hpp> 40 #endif 41 #ifndef _COM_SUN_STAR_ACCESSIBILITY_ACCESSIBLESTATETYPE_HPP_ 42 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 43 #endif 44 45 #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX_ 46 #include <unotools/accessiblestatesethelper.hxx> 47 #endif 48 #ifndef _UTL_ACCESSIBLERELATIONSETHELPER_HXX_ 49 #include <unotools/accessiblerelationsethelper.hxx> 50 #endif 51 #ifndef _SV_SVAPP_HXX 52 #include <vcl/svapp.hxx> 53 #endif 54 #ifndef _TOOLKIT_AWT_VCLXFONT_HXX_ 55 #include <toolkit/awt/vclxfont.hxx> 56 #endif 57 #ifndef _TOOLKIT_HELPER_EXTERNALLOCK_HXX_ 58 #include <toolkit/helper/externallock.hxx> 59 #endif 60 #ifndef _TOOLKIT_HELPER_CONVERT_HXX_ 61 #include <toolkit/helper/convert.hxx> 62 #endif 63 64 #include <vector> 65 66 67 using namespace ::com::sun::star; 68 using namespace ::com::sun::star::uno; 69 using namespace ::com::sun::star::lang; 70 using namespace ::com::sun::star::accessibility; 71 using namespace ::comphelper; 72 73 DBG_NAME( VCLXAccessibleHeaderBarItem ) 74 75 // ---------------------------------------------------- 76 // class AccessibleTabBar 77 // ---------------------------------------------------- 78 79 VCLXAccessibleHeaderBarItem::VCLXAccessibleHeaderBarItem( HeaderBar* pHeadBar, sal_Int32 _nIndexInParent ) 80 :AccessibleExtendedComponentHelper_BASE( new VCLExternalSolarLock() ) 81 ,m_pHeadBar( pHeadBar ) 82 ,m_nIndexInParent(_nIndexInParent + 1) 83 84 { 85 DBG_CTOR( VCLXAccessibleHeaderBarItem, NULL ); 86 m_pExternalLock = static_cast< VCLExternalSolarLock* >( getExternalLock() ); 87 } 88 89 // ----------------------------------------------------------------------------- 90 91 VCLXAccessibleHeaderBarItem::~VCLXAccessibleHeaderBarItem() 92 { 93 delete m_pExternalLock; 94 m_pExternalLock = NULL; 95 } 96 97 // ----------------------------------------------------------------------------- 98 99 IMPL_LINK( VCLXAccessibleHeaderBarItem, WindowEventListener, VclSimpleEvent*, pEvent ) 100 { 101 DBG_CHKTHIS( VCLXAccessibleHeaderBarItem, 0 ); 102 DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "VCLXAccessibleHeaderBarItem::WindowEventListener: unknown window event!" ); 103 104 if ( pEvent && pEvent->ISA( VclWindowEvent ) ) 105 { 106 DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "VCLXAccessibleHeaderBarItem::WindowEventListener: no window!" ); 107 if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) ) 108 { 109 ProcessWindowEvent( *(VclWindowEvent*)pEvent ); 110 } 111 } 112 113 return 0; 114 } 115 116 // ----------------------------------------------------------------------------- 117 118 void VCLXAccessibleHeaderBarItem::ProcessWindowEvent( const VclWindowEvent& ) 119 { 120 Any aOldValue, aNewValue; 121 } 122 123 // ----------------------------------------------------------------------------- 124 125 void VCLXAccessibleHeaderBarItem::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet ) 126 { 127 if ( m_pHeadBar ) 128 { 129 if ( m_pHeadBar->IsEnabled() ) 130 rStateSet.AddState( AccessibleStateType::ENABLED ); 131 132 if ( m_pHeadBar->IsVisible() ) 133 { 134 rStateSet.AddState( AccessibleStateType::VISIBLE ); 135 } 136 rStateSet.AddState( AccessibleStateType::SELECTABLE ); 137 rStateSet.AddState( AccessibleStateType::RESIZABLE ); 138 } 139 } 140 141 // ----------------------------------------------------------------------------- 142 // OCommonAccessibleComponent 143 // ----------------------------------------------------------------------------- 144 145 awt::Rectangle VCLXAccessibleHeaderBarItem::implGetBounds() throw (RuntimeException) 146 { 147 awt::Rectangle aBounds; 148 OExternalLockGuard aGuard( this ); 149 150 ::com::sun::star::awt::Size aSize; 151 152 if ( m_pHeadBar ) 153 aBounds = AWTRectangle( m_pHeadBar->GetItemRect( sal_uInt16( m_nIndexInParent ) ) ); 154 155 return aBounds; 156 } 157 158 // ----------------------------------------------------------------------------- 159 // XInterface 160 // ----------------------------------------------------------------------------- 161 162 IMPLEMENT_FORWARD_XINTERFACE2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE ) 163 164 // ----------------------------------------------------------------------------- 165 // XTypeProvider 166 // ----------------------------------------------------------------------------- 167 168 IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXAccessibleHeaderBarItem, AccessibleExtendedComponentHelper_BASE, VCLXAccessibleHeaderBarItem_BASE ) 169 170 // ----------------------------------------------------------------------------- 171 // XComponent 172 // ----------------------------------------------------------------------------- 173 174 void VCLXAccessibleHeaderBarItem::disposing() 175 { 176 AccessibleExtendedComponentHelper_BASE::disposing(); 177 } 178 179 // ----------------------------------------------------------------------------- 180 // XServiceInfo 181 // ----------------------------------------------------------------------------- 182 183 ::rtl::OUString VCLXAccessibleHeaderBarItem::getImplementationName() throw (RuntimeException) 184 { 185 return ::rtl::OUString::createFromAscii( "com.sun.star.comp.svtools.AccessibleHeaderBarItem" ); 186 } 187 188 // ----------------------------------------------------------------------------- 189 190 sal_Bool VCLXAccessibleHeaderBarItem::supportsService( const ::rtl::OUString& rServiceName ) throw (RuntimeException) 191 { 192 Sequence< ::rtl::OUString > aNames( getSupportedServiceNames() ); 193 const ::rtl::OUString* pNames = aNames.getConstArray(); 194 const ::rtl::OUString* pEnd = pNames + aNames.getLength(); 195 for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames ) 196 ; 197 198 return pNames != pEnd; 199 } 200 201 // ----------------------------------------------------------------------------- 202 203 Sequence< ::rtl::OUString > VCLXAccessibleHeaderBarItem::getSupportedServiceNames() throw (RuntimeException) 204 { 205 Sequence< ::rtl::OUString > aNames(1); 206 aNames[0] = ::rtl::OUString::createFromAscii( "com.sun.star.awt.AccessibleHeaderBarItem" ); 207 return aNames; 208 } 209 210 // ----------------------------------------------------------------------------- 211 // XAccessible 212 // ----------------------------------------------------------------------------- 213 214 Reference< XAccessibleContext > VCLXAccessibleHeaderBarItem::getAccessibleContext() throw (RuntimeException) 215 { 216 OExternalLockGuard aGuard( this ); 217 218 return this; 219 } 220 221 // ----------------------------------------------------------------------------- 222 // XAccessibleContext 223 // ----------------------------------------------------------------------------- 224 225 sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleChildCount() throw (RuntimeException) 226 { 227 OExternalLockGuard aGuard( this ); 228 229 return 0; 230 } 231 232 // ----------------------------------------------------------------------------- 233 234 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) 235 { 236 OExternalLockGuard aGuard( this ); 237 238 if ( i < 0 || i >= getAccessibleChildCount() ) 239 throw IndexOutOfBoundsException(); 240 241 return Reference< XAccessible >(); 242 } 243 244 // ----------------------------------------------------------------------------- 245 246 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleParent() throw (RuntimeException) 247 { 248 OExternalLockGuard aGuard( this ); 249 250 Reference< XAccessible > xParent; 251 if ( m_pHeadBar ) 252 { 253 xParent = m_pHeadBar->GetAccessible(); 254 } 255 256 return xParent; 257 } 258 259 // ----------------------------------------------------------------------------- 260 261 sal_Int32 VCLXAccessibleHeaderBarItem::getAccessibleIndexInParent() throw (RuntimeException) 262 { 263 OExternalLockGuard aGuard( this ); 264 return m_nIndexInParent - 1; 265 } 266 267 // ----------------------------------------------------------------------------- 268 269 sal_Int16 VCLXAccessibleHeaderBarItem::getAccessibleRole() throw (RuntimeException) 270 { 271 OExternalLockGuard aGuard( this ); 272 273 return AccessibleRole::COLUMN_HEADER; 274 } 275 276 // ----------------------------------------------------------------------------- 277 278 ::rtl::OUString VCLXAccessibleHeaderBarItem::getAccessibleDescription() throw (RuntimeException) 279 { 280 OExternalLockGuard aGuard( this ); 281 ::rtl::OUString sDescription; 282 return sDescription; 283 } 284 285 // ----------------------------------------------------------------------------- 286 287 ::rtl::OUString VCLXAccessibleHeaderBarItem::getAccessibleName() throw (RuntimeException) 288 { 289 OExternalLockGuard aGuard( this ); 290 291 ::rtl::OUString sName; 292 if(m_pHeadBar) 293 sName = m_pHeadBar->GetItemText( sal_uInt16( m_nIndexInParent ) ); 294 return sName; 295 } 296 297 // ----------------------------------------------------------------------------- 298 299 Reference< XAccessibleRelationSet > VCLXAccessibleHeaderBarItem::getAccessibleRelationSet( ) throw (RuntimeException) 300 { 301 OExternalLockGuard aGuard( this ); 302 303 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 304 Reference< XAccessibleRelationSet > xSet = pRelationSetHelper; 305 return xSet; 306 } 307 308 // ----------------------------------------------------------------------------- 309 310 Reference< XAccessibleStateSet > VCLXAccessibleHeaderBarItem::getAccessibleStateSet( ) throw (RuntimeException) 311 { 312 OExternalLockGuard aGuard( this ); 313 314 utl::AccessibleStateSetHelper* pStateSetHelper = new utl::AccessibleStateSetHelper; 315 Reference< XAccessibleStateSet > xSet = pStateSetHelper; 316 317 if ( !rBHelper.bDisposed && !rBHelper.bInDispose ) 318 { 319 FillAccessibleStateSet( *pStateSetHelper ); 320 } 321 else 322 { 323 pStateSetHelper->AddState( AccessibleStateType::DEFUNC ); 324 } 325 326 return xSet; 327 } 328 329 // ----------------------------------------------------------------------------- 330 331 com::sun::star::lang::Locale VCLXAccessibleHeaderBarItem::getLocale() throw (IllegalAccessibleComponentStateException, RuntimeException) 332 { 333 OExternalLockGuard aGuard( this ); 334 335 return Application::GetSettings().GetLocale(); 336 } 337 338 // ----------------------------------------------------------------------------- 339 // XAccessibleComponent 340 // ----------------------------------------------------------------------------- 341 342 Reference< XAccessible > VCLXAccessibleHeaderBarItem::getAccessibleAtPoint( const awt::Point& ) throw (RuntimeException) 343 { 344 OExternalLockGuard aGuard( this ); 345 346 return Reference< XAccessible >(); 347 } 348 349 // ----------------------------------------------------------------------------- 350 351 sal_Int32 VCLXAccessibleHeaderBarItem::getForeground() throw (RuntimeException) 352 { 353 OExternalLockGuard aGuard( this ); 354 355 sal_Int32 nColor = 0; 356 return nColor; 357 } 358 359 // ----------------------------------------------------------------------------- 360 361 sal_Int32 VCLXAccessibleHeaderBarItem::getBackground() throw (RuntimeException) 362 { 363 OExternalLockGuard aGuard( this ); 364 365 sal_Int32 nColor = 0; 366 return nColor; 367 } 368 369 // ----------------------------------------------------------------------------- 370 // XAccessibleExtendedComponent 371 // ----------------------------------------------------------------------------- 372 373 Reference< awt::XFont > VCLXAccessibleHeaderBarItem::getFont() throw (RuntimeException) 374 { 375 OExternalLockGuard aGuard( this ); 376 377 Reference< awt::XFont > xFont; 378 return xFont; 379 } 380 381 // ----------------------------------------------------------------------------- 382 383 ::rtl::OUString VCLXAccessibleHeaderBarItem::getTitledBorderText() throw (RuntimeException) 384 { 385 OExternalLockGuard aGuard( this ); 386 387 ::rtl::OUString sText; 388 return sText; 389 } 390 391 // ----------------------------------------------------------------------------- 392 393 ::rtl::OUString VCLXAccessibleHeaderBarItem::getToolTipText() throw (RuntimeException) 394 { 395 OExternalLockGuard aGuard( this ); 396 397 ::rtl::OUString sText; 398 if ( m_pHeadBar ) 399 sText = m_pHeadBar->GetQuickHelpText(); 400 401 return sText; 402 } 403 //-----IAccessibility2 Implementation 2009 404