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