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