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