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 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svx.hxx" 26 27 #define _SVX_CHARMAP_CXX_ 28 #include <unotools/accessiblestatesethelper.hxx> 29 #include <vcl/svapp.hxx> 30 #include <stdio.h> 31 #include <svx/charmap.hxx> 32 #include "charmapacc.hxx" 33 #include <com/sun/star/accessibility/AccessibleRole.hpp> 34 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 35 #include <toolkit/helper/externallock.hxx> 36 #include <toolkit/helper/convert.hxx> 37 #include <osl/interlck.h> 38 #include <svx/dialmgr.hxx> 39 #include "accessibility.hrc" 40 #include <comphelper/types.hxx> 41 42 namespace svx 43 { 44 using namespace comphelper; 45 using namespace ::com::sun::star; 46 using namespace ::com::sun::star::uno; 47 using namespace ::com::sun::star::lang; 48 using namespace ::com::sun::star::accessibility; 49 50 // ---------------- 51 // - SvxShowCharSetVirtualAcc - 52 // ---------------- 53 SvxShowCharSetVirtualAcc::SvxShowCharSetVirtualAcc( SvxShowCharSet* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock()) 54 ,mpParent( pParent ) 55 ,m_pTable(NULL) 56 { 57 osl_incrementInterlockedCount(&m_refCount); 58 { // #b6211265 # 59 lateInit(this); 60 } 61 osl_decrementInterlockedCount(&m_refCount); 62 } 63 64 // ----------------------------------------------------------------------------- 65 66 SvxShowCharSetVirtualAcc::~SvxShowCharSetVirtualAcc() 67 { 68 ensureDisposed(); 69 delete getExternalLock(); 70 } 71 // ----------------------------------------------------------------------------- 72 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 ) 73 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetVirtualAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 ) 74 75 void SAL_CALL SvxShowCharSetVirtualAcc::fireEvent( 76 const sal_Int16 _nEventId, 77 const ::com::sun::star::uno::Any& _rOldValue, 78 const ::com::sun::star::uno::Any& _rNewValue 79 ) 80 { 81 if ( m_pTable ) 82 m_pTable->fireEvent(_nEventId,_rOldValue,_rNewValue); 83 } 84 // ----------------------------------------------------------------------------- 85 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChildCount( ) throw (RuntimeException) 86 { 87 OExternalLockGuard aGuard( this ); 88 ensureAlive(); 89 return ( mpParent->getScrollBar()->IsVisible() ) ? 2 : 1; 90 } 91 // ----------------------------------------------------------------------------- 92 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleAtPoint( const awt::Point& aPoint ) 93 throw (uno::RuntimeException) 94 { 95 OExternalLockGuard aGuard( this ); 96 ensureAlive(); 97 98 uno::Reference< accessibility::XAccessible > xRet; 99 const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>(mpParent->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) )); 100 101 if( sal_uInt16(-1) != nItemId ) 102 { 103 if ( !m_pTable ) 104 m_pTable = new SvxShowCharSetAcc(this); 105 xRet = m_pTable; 106 } 107 else if ( mpParent->getScrollBar()->IsVisible() ) 108 { 109 const Point aOutPos( mpParent->getScrollBar()->GetPosPixel() ); 110 const Size aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel(); 111 Rectangle aRect(aOutPos,aScrollBar); 112 113 if ( aRect.IsInside(VCLPoint(aPoint)) ) 114 xRet = mpParent->getScrollBar()->GetAccessible(); 115 } 116 return xRet; 117 } 118 // ----------------------------------------------------------------------------- 119 uno::Any SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleKeyBinding() 120 throw (uno::RuntimeException) 121 { 122 return uno::Any(); 123 } 124 // ----------------------------------------------------------------------------- 125 void SAL_CALL SvxShowCharSetVirtualAcc::grabFocus() 126 throw (uno::RuntimeException) 127 { 128 OExternalLockGuard aGuard( this ); 129 ensureAlive(); 130 mpParent->GrabFocus(); 131 } 132 133 134 // ----------------------------------------------------------------------------- 135 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleChild( sal_Int32 i ) throw (IndexOutOfBoundsException, RuntimeException) 136 { 137 OExternalLockGuard aGuard( this ); 138 ensureAlive(); 139 if ( mpParent->getScrollBar()->IsVisible() && i == 0 ) 140 return mpParent->getScrollBar()->GetAccessible(); 141 else if ( i == 1 ) 142 { 143 if ( !m_xAcc.is() ) 144 { 145 m_pTable = new SvxShowCharSetAcc(this); 146 m_xAcc = m_pTable; 147 } 148 } 149 else 150 throw IndexOutOfBoundsException(); 151 return m_xAcc; 152 } 153 // ----------------------------------------------------------------------------- 154 Reference< XAccessible > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleParent( ) throw (RuntimeException) 155 { 156 OExternalLockGuard aGuard( this ); 157 ensureAlive(); 158 Window* pParent = mpParent->GetParent(); 159 uno::Reference< accessibility::XAccessible > xRet; 160 161 if ( pParent ) 162 xRet = pParent->GetAccessible(); 163 164 return xRet; 165 } 166 // ----------------------------------------------------------------------------- 167 ::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetVirtualAcc::implGetBounds( ) throw (RuntimeException) 168 { 169 //IAccessibility2 Implementation 2009----- 170 /* const Point aOutPos( mpParent->GetPosPixel() ); 171 Size aOutSize( mpParent->GetOutputSizePixel() ); 172 if ( mpParent->getScrollBar()->IsVisible() ) 173 { 174 const Size aScrollBar = mpParent->getScrollBar()->GetOutputSizePixel(); 175 aOutSize.Width() -= aScrollBar.Width(); 176 aOutSize.Height() -= aScrollBar.Height(); 177 } 178 179 awt::Rectangle aRet; 180 181 aRet.X = aOutPos.X(); 182 aRet.Y = aOutPos.Y(); 183 aRet.Width = aOutSize.Width(); 184 aRet.Height = aOutSize.Height(); 185 186 return aRet; 187 */ 188 ::com::sun::star::awt::Rectangle aBounds ( 0, 0, 0, 0 ); 189 Window* pWindow = mpParent; 190 if ( pWindow ) 191 { 192 Rectangle aRect = pWindow->GetWindowExtentsRelative( NULL ); 193 aBounds = AWTRectangle( aRect ); 194 Window* pParent = pWindow->GetAccessibleParentWindow(); 195 if ( pParent ) 196 { 197 Rectangle aParentRect = pParent->GetWindowExtentsRelative( NULL ); 198 ::com::sun::star::awt::Point aParentScreenLoc = AWTPoint( aParentRect.TopLeft() ); 199 aBounds.X -= aParentScreenLoc.X; 200 aBounds.Y -= aParentScreenLoc.Y; 201 } 202 } 203 return aBounds; 204 //-----IAccessibility2 Implementation 2009 205 } 206 // ----------------------------------------------------------------------------- 207 sal_Int16 SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRole( ) throw (RuntimeException) 208 { 209 return accessibility::AccessibleRole::SCROLL_PANE; 210 } 211 // ----------------------------------------------------------------------------- 212 ::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleDescription( ) throw (RuntimeException) 213 { 214 OExternalLockGuard aGuard( this ); 215 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION); 216 } 217 // ----------------------------------------------------------------------------- 218 ::rtl::OUString SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleName( ) throw (RuntimeException) 219 { 220 OExternalLockGuard aGuard( this ); 221 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC); 222 } 223 // ----------------------------------------------------------------------------- 224 Reference< XAccessibleRelationSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleRelationSet( ) throw (RuntimeException) 225 { 226 return Reference< XAccessibleRelationSet >(); 227 } 228 // ----------------------------------------------------------------------------- 229 Reference< XAccessibleStateSet > SAL_CALL SvxShowCharSetVirtualAcc::getAccessibleStateSet( ) throw (RuntimeException) 230 { 231 OExternalLockGuard aGuard( this ); 232 233 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper; 234 235 if( mpParent ) 236 { 237 // SELECTABLE 238 pStateSet->AddState( AccessibleStateType::FOCUSABLE ); 239 if ( mpParent->HasFocus() ) 240 pStateSet->AddState( AccessibleStateType::FOCUSED ); 241 if ( mpParent->IsActive() ) 242 pStateSet->AddState( AccessibleStateType::ACTIVE ); 243 if ( mpParent->IsEnabled() ) 244 { 245 pStateSet->AddState( AccessibleStateType::ENABLED ); 246 pStateSet->AddState( AccessibleStateType::SENSITIVE ); 247 } 248 if ( mpParent->IsReallyVisible() ) 249 pStateSet->AddState( AccessibleStateType::VISIBLE ); 250 } 251 252 return pStateSet; 253 } 254 // ----------------------------------------------------------------------------- 255 void SAL_CALL SvxShowCharSetVirtualAcc::disposing() 256 { 257 OAccessibleContextHelper::disposing(); 258 if ( m_pTable ) 259 m_pTable->dispose(); 260 m_pTable = NULL; 261 } 262 // ----------------------------------------------------------------------------- 263 // ---------------- 264 // - SvxShowCharSetItem - 265 // ---------------- 266 267 SvxShowCharSetItem::SvxShowCharSetItem( SvxShowCharSet& rParent,SvxShowCharSetAcc* _pParent,sal_uInt16 _nPos ) : 268 mrParent( rParent ) 269 ,mnId( _nPos ) 270 ,m_pItem(NULL) 271 ,m_pParent(_pParent) 272 { 273 } 274 // ----------------------------------------------------------------------- 275 276 SvxShowCharSetItem::~SvxShowCharSetItem() 277 { 278 if ( m_xAcc.is() ) 279 { 280 m_pItem->ParentDestroyed(); 281 ClearAccessible(); 282 } 283 } 284 285 // ----------------------------------------------------------------------- 286 287 uno::Reference< accessibility::XAccessible > SvxShowCharSetItem::GetAccessible() 288 { 289 if( !m_xAcc.is() ) 290 { 291 m_pItem = new SvxShowCharSetItemAcc( this ); 292 m_xAcc = m_pItem; 293 } 294 295 return m_xAcc; 296 } 297 298 // ----------------------------------------------------------------------- 299 300 void SvxShowCharSetItem::ClearAccessible() 301 { 302 if ( m_xAcc.is() ) 303 { 304 m_pItem = NULL; 305 m_xAcc = NULL; 306 } 307 } 308 309 310 // --------------- 311 // - SvxShowCharSetAcc - 312 // --------------- 313 314 SvxShowCharSetAcc::SvxShowCharSetAcc( SvxShowCharSetVirtualAcc* _pParent ) : OAccessibleSelectionHelper(new VCLExternalSolarLock()) 315 ,m_pParent( _pParent ) 316 { 317 osl_incrementInterlockedCount(&m_refCount); 318 { // #b6211265 # 319 lateInit(this); 320 } 321 osl_decrementInterlockedCount(&m_refCount); 322 } 323 324 // ----------------------------------------------------------------------------- 325 326 SvxShowCharSetAcc::~SvxShowCharSetAcc() 327 { 328 ensureDisposed(); 329 delete getExternalLock(); 330 } 331 // ----------------------------------------------------------------------------- 332 void SAL_CALL SvxShowCharSetAcc::disposing() 333 { 334 OAccessibleSelectionHelper::disposing(); 335 ::std::vector< Reference< XAccessible > >::iterator aIter = m_aChildren.begin(); 336 ::std::vector< Reference< XAccessible > >::iterator aEnd = m_aChildren.end(); 337 for (;aIter != aEnd ; ++aIter) 338 ::comphelper::disposeComponent(*aIter); 339 340 m_aChildren.clear(); 341 m_pParent = NULL; 342 } 343 344 // ----------------------------------------------------------------------------- 345 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base ) 346 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetAcc, OAccessibleSelectionHelper, OAccessibleHelper_Base ) 347 // ----------------------------------------------------------------------- 348 sal_Bool SvxShowCharSetAcc::implIsSelected( sal_Int32 nAccessibleChildIndex ) throw (RuntimeException) 349 { 350 return m_pParent && m_pParent->getCharSetControl()->IsSelected( 351 sal::static_int_cast<sal_uInt16>(nAccessibleChildIndex)); 352 } 353 // ----------------------------------------------------------------------------- 354 // select the specified child => watch for special ChildIndexes (ACCESSIBLE_SELECTION_CHILD_xxx) 355 void SvxShowCharSetAcc::implSelect( sal_Int32 nAccessibleChildIndex, sal_Bool bSelect ) throw (IndexOutOfBoundsException, RuntimeException) 356 { 357 if ( m_pParent ) 358 { 359 if ( bSelect ) 360 m_pParent->getCharSetControl()->SelectIndex(nAccessibleChildIndex,sal_True); 361 else 362 m_pParent->getCharSetControl()->DeSelect(); 363 } 364 } 365 // ----------------------------------------------------------------------------- 366 ::com::sun::star::awt::Rectangle SAL_CALL SvxShowCharSetAcc::implGetBounds( ) throw (RuntimeException) 367 { 368 //IAccessibility2 Implementation 2009----- 369 const Point aOutPos;//( m_pParent->getCharSetControl()->GetPosPixel() ); 370 Size aOutSize( m_pParent->getCharSetControl()->GetOutputSizePixel()); 371 if ( m_pParent->getCharSetControl()->getScrollBar()->IsVisible() ) 372 { 373 const Size aScrollBar = m_pParent->getCharSetControl()->getScrollBar()->GetOutputSizePixel(); 374 aOutSize.Width() -= aScrollBar.Width(); 375 //aOutSize.Height() -= aScrollBar.Height(); 376 //-----IAccessibility2 Implementation 2009 377 } 378 379 awt::Rectangle aRet; 380 381 aRet.X = aOutPos.X(); 382 aRet.Y = aOutPos.Y(); 383 aRet.Width = aOutSize.Width(); 384 aRet.Height = aOutSize.Height(); 385 386 return aRet; 387 } 388 // ----------------------------------------------------------------------------- 389 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleChildCount() 390 throw (uno::RuntimeException) 391 { 392 OExternalLockGuard aGuard( this ); 393 ensureAlive(); 394 return m_pParent->getCharSetControl()->getMaxCharCount(); 395 } 396 397 // ----------------------------------------------------------------------------- 398 399 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleChild( sal_Int32 i ) 400 throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 401 { 402 OExternalLockGuard aGuard( this ); 403 ensureAlive(); 404 uno::Reference< accessibility::XAccessible > xRet; 405 SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16 >( i ) ); 406 407 if( pItem ) 408 { 409 pItem->m_pParent = this; 410 xRet = pItem->GetAccessible(); 411 m_aChildren.push_back(xRet); 412 } 413 else 414 throw lang::IndexOutOfBoundsException(); 415 416 return xRet; 417 } 418 419 // ----------------------------------------------------------------------------- 420 421 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleParent() 422 throw (uno::RuntimeException) 423 { 424 OExternalLockGuard aGuard( this ); 425 ensureAlive(); 426 return m_pParent; 427 } 428 429 // ----------------------------------------------------------------------------- 430 431 sal_Int16 SAL_CALL SvxShowCharSetAcc::getAccessibleRole() 432 throw (uno::RuntimeException) 433 { 434 return accessibility::AccessibleRole::TABLE; 435 } 436 437 // ----------------------------------------------------------------------------- 438 439 ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleDescription() 440 throw (uno::RuntimeException) 441 { 442 OExternalLockGuard aGuard( this ); 443 return SVX_RESSTR( RID_SVXSTR_CHARACTER_SELECTION ); 444 } 445 446 // ----------------------------------------------------------------------------- 447 448 ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleName() 449 throw (uno::RuntimeException) 450 { 451 OExternalLockGuard aGuard( this ); 452 ensureAlive(); 453 return SVX_RESSTR( RID_SVXSTR_CHAR_SEL_DESC ); 454 } 455 456 // ----------------------------------------------------------------------------- 457 458 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetAcc::getAccessibleRelationSet() 459 throw (uno::RuntimeException) 460 { 461 return uno::Reference< accessibility::XAccessibleRelationSet >(); 462 } 463 464 // ----------------------------------------------------------------------------- 465 466 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetAcc::getAccessibleStateSet() 467 throw (uno::RuntimeException) 468 { 469 OExternalLockGuard aGuard( this ); 470 471 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper; 472 473 if( m_pParent->getCharSetControl() ) 474 { 475 // SELECTABLE 476 pStateSet->AddState( AccessibleStateType::FOCUSABLE ); 477 if ( m_pParent->getCharSetControl()->HasFocus() ) 478 pStateSet->AddState( AccessibleStateType::FOCUSED ); 479 if ( m_pParent->getCharSetControl()->IsActive() ) 480 pStateSet->AddState( AccessibleStateType::ACTIVE ); 481 if ( m_pParent->getCharSetControl()->IsEnabled() ) 482 { 483 pStateSet->AddState( AccessibleStateType::ENABLED ); 484 pStateSet->AddState( AccessibleStateType::SENSITIVE ); 485 } 486 if ( m_pParent->getCharSetControl()->IsReallyVisible() ) 487 pStateSet->AddState( AccessibleStateType::VISIBLE ); 488 489 pStateSet->AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 490 } 491 492 return pStateSet; 493 } 494 // ----------------------------------------------------------------------------- 495 496 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleAtPoint( const awt::Point& aPoint ) 497 throw (uno::RuntimeException) 498 { 499 OExternalLockGuard aGuard( this ); 500 ensureAlive(); 501 502 uno::Reference< accessibility::XAccessible > xRet; 503 const sal_uInt16 nItemId = sal::static_int_cast<sal_uInt16>( 504 m_pParent->getCharSetControl()->PixelToMapIndex( Point( aPoint.X, aPoint.Y ) )); 505 506 if( sal_uInt16(-1) != nItemId ) 507 { 508 SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( nItemId ); 509 xRet = pItem->GetAccessible(); 510 } 511 return xRet; 512 } 513 514 // ----------------------------------------------------------------------------- 515 // ----------------------------------------------------------------------------- 516 517 void SAL_CALL SvxShowCharSetAcc::grabFocus() 518 throw (uno::RuntimeException) 519 { 520 OExternalLockGuard aGuard( this ); 521 ensureAlive(); 522 m_pParent->getCharSetControl()->GrabFocus(); 523 } 524 525 // ----------------------------------------------------------------------------- 526 527 uno::Any SAL_CALL SvxShowCharSetAcc::getAccessibleKeyBinding() 528 throw (uno::RuntimeException) 529 { 530 return uno::Any(); 531 } 532 // ----------------------------------------------------------------------------- 533 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowCount( ) throw (RuntimeException) 534 { 535 return ((getAccessibleChildCount()-1) / COLUMN_COUNT) + 1; 536 } 537 // ----------------------------------------------------------------------------- 538 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnCount( ) throw (RuntimeException) 539 { 540 return COLUMN_COUNT; 541 } 542 // ----------------------------------------------------------------------------- 543 ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleRowDescription( sal_Int32 /*nRow*/ ) throw (IndexOutOfBoundsException, RuntimeException) 544 { 545 return ::rtl::OUString(); 546 } 547 // ----------------------------------------------------------------------------- 548 ::rtl::OUString SAL_CALL SvxShowCharSetAcc::getAccessibleColumnDescription( sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException) 549 { 550 return ::rtl::OUString(); 551 } 552 // ----------------------------------------------------------------------------- 553 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRowExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException) 554 { 555 return 1; 556 } 557 // ----------------------------------------------------------------------------- 558 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumnExtentAt( sal_Int32 /*nRow*/, sal_Int32 /*nColumn*/ ) throw (IndexOutOfBoundsException, RuntimeException) 559 { 560 return 1; 561 } 562 // ----------------------------------------------------------------------------- 563 Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleRowHeaders( ) throw (RuntimeException) 564 { 565 return Reference< XAccessibleTable >(); 566 } 567 // ----------------------------------------------------------------------------- 568 Reference< XAccessibleTable > SAL_CALL SvxShowCharSetAcc::getAccessibleColumnHeaders( ) throw (RuntimeException) 569 { 570 return Reference< XAccessibleTable >(); 571 } 572 // ----------------------------------------------------------------------------- 573 Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleRows( ) throw (RuntimeException) 574 { 575 OExternalLockGuard aGuard( this ); 576 ensureAlive(); 577 Sequence< sal_Int32 > aSel(1); 578 aSel[0] = m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId()); 579 return aSel; 580 } 581 // ----------------------------------------------------------------------------- 582 Sequence< sal_Int32 > SAL_CALL SvxShowCharSetAcc::getSelectedAccessibleColumns( ) throw (RuntimeException) 583 { 584 OExternalLockGuard aGuard( this ); 585 ensureAlive(); 586 Sequence< sal_Int32 > aSel(1); 587 aSel[0] = m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId()); 588 return aSel; 589 } 590 // ----------------------------------------------------------------------------- 591 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleRowSelected( sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException) 592 { 593 OExternalLockGuard aGuard( this ); 594 ensureAlive(); 595 return m_pParent->getCharSetControl()->GetRowPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nRow; 596 } 597 // ----------------------------------------------------------------------------- 598 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleColumnSelected( sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException) 599 { 600 OExternalLockGuard aGuard( this ); 601 ensureAlive(); 602 return m_pParent->getCharSetControl()->GetColumnPos(m_pParent->getCharSetControl()->GetSelectIndexId()) == nColumn; 603 } 604 // ----------------------------------------------------------------------------- 605 Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException) 606 { 607 OExternalLockGuard aGuard( this ); 608 ensureAlive(); 609 ::svx::SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( 610 sal::static_int_cast<sal_uInt16>(getAccessibleIndex(nRow,nColumn) )); 611 if ( !pItem ) 612 throw IndexOutOfBoundsException(); 613 return pItem->GetAccessible(); 614 } 615 // ----------------------------------------------------------------------------- 616 Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleCaption( ) throw (RuntimeException) 617 { 618 return Reference< XAccessible >(); 619 } 620 // ----------------------------------------------------------------------------- 621 Reference< XAccessible > SAL_CALL SvxShowCharSetAcc::getAccessibleSummary( ) throw (RuntimeException) 622 { 623 return Reference< XAccessible >(); 624 } 625 // ----------------------------------------------------------------------------- 626 sal_Bool SAL_CALL SvxShowCharSetAcc::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException) 627 { 628 OExternalLockGuard aGuard( this ); 629 ensureAlive(); 630 return m_pParent->getCharSetControl()->GetSelectIndexId() == getAccessibleIndex(nRow,nColumn); 631 } 632 // ----------------------------------------------------------------------------- 633 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn ) throw (IndexOutOfBoundsException, RuntimeException) 634 { 635 return (nRow*COLUMN_COUNT) + nColumn; 636 } 637 // ----------------------------------------------------------------------------- 638 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleRow( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 639 { 640 OExternalLockGuard aGuard( this ); 641 ensureAlive(); 642 return m_pParent->getCharSetControl()->GetRowPos(sal::static_int_cast<sal_uInt16>(nChildIndex)); 643 } 644 // ----------------------------------------------------------------------------- 645 sal_Int32 SAL_CALL SvxShowCharSetAcc::getAccessibleColumn( sal_Int32 nChildIndex ) throw (IndexOutOfBoundsException, RuntimeException) 646 { 647 OExternalLockGuard aGuard( this ); 648 ensureAlive(); 649 return m_pParent->getCharSetControl()->GetColumnPos(sal::static_int_cast<sal_uInt16>(nChildIndex)); 650 } 651 // ----------------------------------------------------------------------------- 652 653 // ----------------------------------------------------------------------------- 654 // ---------------- 655 // - SvxShowCharSetItemAcc - 656 // ---------------- 657 658 SvxShowCharSetItemAcc::SvxShowCharSetItemAcc( SvxShowCharSetItem* pParent ) : OAccessibleComponentHelper(new VCLExternalSolarLock()) 659 ,mpParent( pParent ) 660 { 661 OSL_ENSURE(pParent,"NO parent supplied!"); 662 osl_incrementInterlockedCount(&m_refCount); 663 { // #b6211265 # 664 lateInit(this); 665 } 666 osl_decrementInterlockedCount(&m_refCount); 667 } 668 669 // ----------------------------------------------------------------------------- 670 671 SvxShowCharSetItemAcc::~SvxShowCharSetItemAcc() 672 { 673 ensureDisposed(); 674 delete getExternalLock(); 675 } 676 // ----------------------------------------------------------------------------- 677 IMPLEMENT_FORWARD_XINTERFACE2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 ) 678 IMPLEMENT_FORWARD_XTYPEPROVIDER2( SvxShowCharSetItemAcc, OAccessibleComponentHelper, OAccessibleHelper_Base_2 ) 679 // ----------------------------------------------------------------------------- 680 681 void SvxShowCharSetItemAcc::ParentDestroyed() 682 { 683 const ::osl::MutexGuard aGuard( GetMutex() ); 684 mpParent = NULL; 685 } 686 687 // ----------------------------------------------------------------------------- 688 689 sal_Int32 SAL_CALL SvxShowCharSetItemAcc::getAccessibleChildCount() 690 throw (uno::RuntimeException) 691 { 692 return 0; 693 } 694 695 // ----------------------------------------------------------------------------- 696 697 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleChild( sal_Int32 /*i*/ ) 698 throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 699 { 700 throw lang::IndexOutOfBoundsException(); 701 } 702 703 // ----------------------------------------------------------------------------- 704 705 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleParent() 706 throw (uno::RuntimeException) 707 { 708 OExternalLockGuard aGuard( this ); 709 ensureAlive(); 710 return mpParent->m_pParent; 711 } 712 713 // ----------------------------------------------------------------------------- 714 715 sal_Int16 SAL_CALL SvxShowCharSetItemAcc::getAccessibleRole() 716 throw (uno::RuntimeException) 717 { 718 //return accessibility::AccessibleRole::LABEL; 719 //IAccessibility2 Implementation 2009----- 720 return accessibility::AccessibleRole::TABLE_CELL; 721 //-----IAccessibility2 Implementation 2009 722 } 723 724 // ----------------------------------------------------------------------------- 725 726 ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleDescription() 727 throw (uno::RuntimeException) 728 { 729 OExternalLockGuard aGuard( this ); 730 ensureAlive(); 731 String sDescription = SVX_RESSTR( RID_SVXSTR_CHARACTER_CODE ); 732 733 sal_Unicode c = mpParent->maText.GetChar(0); 734 char buf[16] = "0x0000"; 735 sal_Unicode c_Shifted = c; 736 //IAccessibility2 Implementation 2009----- 737 /* 738 for( int i = 0; i < 4; ++i ) 739 { 740 char h = (char)(c_Shifted & 0x0F); 741 buf[5-i] = (h > 9) ? (h - 10 + 'A') : (h + '0'); 742 c_Shifted >>= 4; 743 } 744 */ 745 int tmp_len = 4; 746 if(c_Shifted>0xFFFF) tmp_len = 8; 747 for( int i = 0; i < tmp_len; ++i ) 748 { 749 char h = c_Shifted & 0x0F; 750 //buf[9-i] = (h > 9) ? (h - 10 + 'A') : (h + '0'); 751 buf[tmp_len+1-i] = (h > 9) ? (h - 10 + 'A') : (h + '0'); 752 c_Shifted >>= 4; 753 } 754 //-----IAccessibility2 Implementation 2009 755 if( c < 256 ) 756 snprintf( buf+6, 10, " (%d)", c ); 757 //IAccessibility2 Implementation 2009----- 758 sDescription.AppendAscii(" "); 759 //-----IAccessibility2 Implementation 2009 760 sDescription.AppendAscii(buf); 761 762 return sDescription; 763 } 764 765 // ----------------------------------------------------------------------------- 766 767 ::rtl::OUString SAL_CALL SvxShowCharSetItemAcc::getAccessibleName() 768 throw (uno::RuntimeException) 769 { 770 OExternalLockGuard aGuard( this ); 771 ensureAlive(); 772 String aRet; 773 774 if( mpParent ) 775 { 776 aRet = mpParent->maText; 777 778 if( !aRet.Len() ) 779 aRet = getAccessibleDescription(); 780 } 781 782 return aRet; 783 } 784 785 // ----------------------------------------------------------------------------- 786 787 uno::Reference< accessibility::XAccessibleRelationSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleRelationSet() 788 throw (uno::RuntimeException) 789 { 790 return uno::Reference< accessibility::XAccessibleRelationSet >(); 791 } 792 793 // ----------------------------------------------------------------------------- 794 795 uno::Reference< accessibility::XAccessibleStateSet > SAL_CALL SvxShowCharSetItemAcc::getAccessibleStateSet() 796 throw (uno::RuntimeException) 797 { 798 OExternalLockGuard aGuard( this ); 799 ensureAlive(); 800 801 ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper; 802 803 if( mpParent ) 804 { 805 //IAccessibility2 Implementation 2009----- 806 if(mpParent->mrParent.IsEnabled()) 807 { 808 pStateSet->AddState( accessibility::AccessibleStateType::ENABLED ); 809 // SELECTABLE 810 pStateSet->AddState( accessibility::AccessibleStateType::SELECTABLE ); 811 pStateSet->AddState( accessibility::AccessibleStateType::FOCUSABLE ); 812 } 813 //-----IAccessibility2 Implementation 2009 814 815 // SELECTED 816 if( mpParent->mrParent.GetSelectIndexId() == mpParent->mnId ) 817 { 818 pStateSet->AddState( accessibility::AccessibleStateType::SELECTED ); 819 pStateSet->AddState( accessibility::AccessibleStateType::FOCUSED ); 820 } 821 if ( mpParent->mnId >= mpParent->mrParent.FirstInView() && mpParent->mnId <= mpParent->mrParent.LastInView() ) 822 //IAccessibility2 Implementation 2009----- 823 { 824 pStateSet->AddState( AccessibleStateType::VISIBLE ); 825 pStateSet->AddState( AccessibleStateType::SHOWING ); 826 } 827 //-----IAccessibility2 Implementation 2009 828 pStateSet->AddState( AccessibleStateType::TRANSIENT ); 829 } 830 831 return pStateSet; 832 } 833 834 // ----------------------------------------------------------------------------- 835 void SAL_CALL SvxShowCharSetItemAcc::grabFocus() 836 throw (uno::RuntimeException) 837 { 838 // nothing to do 839 } 840 841 // ----------------------------------------------------------------------------- 842 843 uno::Any SAL_CALL SvxShowCharSetItemAcc::getAccessibleKeyBinding() 844 throw (uno::RuntimeException) 845 { 846 return uno::Any(); 847 } 848 // ----------------------------------------------------------------------------- 849 awt::Rectangle SAL_CALL SvxShowCharSetItemAcc::implGetBounds( ) throw (RuntimeException) 850 { 851 awt::Rectangle aRet; 852 853 if( mpParent ) 854 { 855 Rectangle aRect( mpParent->maRect ); 856 Point aOrigin; 857 Rectangle aParentRect( aOrigin, mpParent->mrParent.GetOutputSizePixel() ); 858 859 aRect.Intersection( aParentRect ); 860 861 aRet.X = aRect.Left(); 862 aRet.Y = aRect.Top(); 863 aRet.Width = aRect.GetWidth(); 864 aRet.Height = aRect.GetHeight(); 865 } 866 867 return aRet; 868 } 869 // ----------------------------------------------------------------------------- 870 uno::Reference< accessibility::XAccessible > SAL_CALL SvxShowCharSetItemAcc::getAccessibleAtPoint( const awt::Point& /*aPoint*/ ) 871 throw (uno::RuntimeException) 872 { 873 return uno::Reference< accessibility::XAccessible >(); 874 } 875 // ----------------------------------------------------------------------------- 876 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getForeground( ) throw (RuntimeException) 877 { 878 OExternalLockGuard aGuard( this ); 879 880 sal_Int32 nColor = 0; 881 if ( mpParent ) 882 { 883 if ( mpParent->IsControlForeground() ) 884 nColor = mpParent->GetControlForeground().GetColor(); 885 else 886 { 887 Font aFont; 888 if ( mpParent->IsControlFont() ) 889 aFont = mpParent->GetControlFont(); 890 else 891 aFont = mpParent->GetFont(); 892 nColor = aFont.GetColor().GetColor(); 893 } 894 } 895 896 return nColor; 897 } 898 // ----------------------------------------------------------------------------- 899 sal_Int32 SAL_CALL SvxShowCharSetVirtualAcc::getBackground( ) throw (RuntimeException) 900 { 901 OExternalLockGuard aGuard( this ); 902 sal_Int32 nColor = 0; 903 if ( mpParent ) 904 { 905 if ( mpParent->IsControlBackground() ) 906 nColor = mpParent->GetControlBackground().GetColor(); 907 else 908 nColor = mpParent->GetBackground().GetColor().GetColor(); 909 } 910 911 return nColor; 912 } 913 // ----------------------------------------------------------------------------- 914 sal_Int32 SAL_CALL SvxShowCharSetAcc::getForeground( ) throw (RuntimeException) 915 { 916 OExternalLockGuard aGuard( this ); 917 918 sal_Int32 nColor = 0; 919 if ( m_pParent ) 920 nColor = m_pParent->getForeground(); 921 return nColor; 922 } 923 // ----------------------------------------------------------------------------- 924 sal_Int32 SAL_CALL SvxShowCharSetAcc::getBackground( ) throw (RuntimeException) 925 { 926 OExternalLockGuard aGuard( this ); 927 sal_Int32 nColor = 0; 928 if ( m_pParent ) 929 nColor = m_pParent->getBackground(); 930 return nColor; 931 } 932 // ----------------------------------------------------------------------------- 933 934 // ----------------------------------------------------------------------------- 935 } // namespace svx 936 // ----------------------------------------------------------------------------- 937 938 939