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_sc.hxx" 26 #include "AccessibleDataPilotControl.hxx" 27 #include "unoguard.hxx" 28 #include "fieldwnd.hxx" 29 30 #include <com/sun/star/accessibility/AccessibleRole.hpp> 31 #include <com/sun/star/accessibility/AccessibleStateType.hpp> 32 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 33 34 #include <com/sun/star/accessibility/XAccessibleAction.hpp> 35 #include <comphelper/accessiblekeybindinghelper.hxx> 36 #include <com/sun/star/awt/KeyModifier.hpp> 37 #include <vcl/keycodes.hxx> 38 #ifndef _UTL_ACCESSIBLESTATESETHELPER_HXX 39 #include <unotools/accessiblestatesethelper.hxx> 40 #endif 41 #include <rtl/uuid.h> 42 #include <tools/gen.hxx> 43 #include <toolkit/helper/convert.hxx> 44 #include <tools/debug.hxx> 45 46 #include <com/sun/star/accessibility/AccessibleRelationType.hpp> 47 #include <unotools/accessiblerelationsethelper.hxx> 48 using namespace ::com::sun::star; 49 using namespace ::com::sun::star::accessibility; 50 51 class ScAccessibleDataPilotButton 52 : public ScAccessibleContextBase 53 , public ::com::sun::star::accessibility::XAccessibleAction 54 { 55 public: 56 //===== internal ======================================================== 57 ScAccessibleDataPilotButton( 58 const ::com::sun::star::uno::Reference< 59 ::com::sun::star::accessibility::XAccessible>& rxParent, 60 ScPivotFieldWindow* pFieldWindow, 61 sal_Int32 nIndex); 62 63 virtual void Init(); 64 65 using ScAccessibleContextBase::disposing; 66 virtual void SAL_CALL disposing(); 67 68 void SetIndex(sal_Int32 nIndex) { mnIndex = nIndex; } 69 void NameChanged(); 70 void SetFocused(); 71 void ResetFocused(); 72 protected: 73 virtual ~ScAccessibleDataPilotButton(void); 74 public: 75 // XAccessibleAction 76 virtual sal_Int32 SAL_CALL getAccessibleActionCount( ); 77 virtual sal_Bool SAL_CALL doAccessibleAction ( sal_Int32 nIndex ); 78 virtual ::rtl::OUString SAL_CALL getAccessibleActionDescription ( sal_Int32 nIndex ); 79 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleKeyBinding > SAL_CALL getAccessibleActionKeyBinding( sal_Int32 nIndex ); 80 ///===== XInterface ===================================================== 81 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( 82 ::com::sun::star::uno::Type const & rType ); 83 virtual void SAL_CALL acquire() throw (); 84 virtual void SAL_CALL release() throw (); 85 ///===== XAccessibleComponent ============================================ 86 87 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > 88 SAL_CALL getAccessibleAtPoint( 89 const ::com::sun::star::awt::Point& rPoint ); 90 91 virtual sal_Bool SAL_CALL isVisible( ); 92 93 virtual void SAL_CALL grabFocus( ); 94 95 virtual sal_Int32 SAL_CALL getForeground( ); 96 97 virtual sal_Int32 SAL_CALL getBackground( ); 98 99 ///===== XAccessibleContext ============================================== 100 101 /// Return the number of currently visible children. 102 virtual sal_Int32 SAL_CALL 103 getAccessibleChildCount(void); 104 105 /// Return the specified child or NULL if index is invalid. 106 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible> SAL_CALL 107 getAccessibleChild(sal_Int32 nIndex); 108 109 /// Return this objects index among the parents children. 110 virtual sal_Int32 SAL_CALL 111 getAccessibleIndexInParent(void); 112 113 /// Return the set of current states. 114 virtual ::com::sun::star::uno::Reference< 115 ::com::sun::star::accessibility::XAccessibleStateSet> SAL_CALL 116 getAccessibleStateSet(void); 117 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > 118 SAL_CALL getAccessibleRelationSet( ); 119 ///===== XServiceInfo ==================================================== 120 121 /** Returns an identifier for the implementation of this object. 122 */ 123 virtual ::rtl::OUString SAL_CALL 124 getImplementationName(void); 125 126 ///===== XTypeProvider =================================================== 127 128 /** Returns a implementation id. 129 */ 130 virtual ::com::sun::star::uno::Sequence<sal_Int8> SAL_CALL 131 getImplementationId(void); 132 133 protected: 134 /// Return this object's description. 135 virtual ::rtl::OUString SAL_CALL 136 createAccessibleDescription(void); 137 138 /// Return the object's current name. 139 virtual ::rtl::OUString SAL_CALL 140 createAccessibleName(void); 141 142 /// Return the object's current bounding box relative to the desktop. 143 virtual Rectangle GetBoundingBoxOnScreen(void) const; 144 145 /// Return the object's current bounding box relative to the parent object. 146 virtual Rectangle GetBoundingBox(void) const; 147 148 private: 149 ScPivotFieldWindow* mpFieldWindow; 150 sal_Int32 mnIndex; 151 }; 152 153 //===== internal ======================================================== 154 ScAccessibleDataPilotControl::ScAccessibleDataPilotControl( 155 const uno::Reference<XAccessible>& rxParent, 156 ScPivotFieldWindow* pFieldWindow) 157 : 158 ScAccessibleContextBase(rxParent, AccessibleRole::GROUP_BOX), 159 mpFieldWindow(pFieldWindow) 160 { 161 if (mpFieldWindow) 162 maChildren.resize(mpFieldWindow->GetFieldCount()); 163 } 164 165 ScAccessibleDataPilotControl::~ScAccessibleDataPilotControl(void) 166 { 167 if (!IsDefunc() && !rBHelper.bInDispose) 168 { 169 // increment refcount to prevent double call off dtor 170 osl_incrementInterlockedCount( &m_refCount ); 171 // call dispose to inform object which have a weak reference to this object 172 dispose(); 173 } 174 } 175 176 void ScAccessibleDataPilotControl::Init() 177 { 178 } 179 180 void SAL_CALL ScAccessibleDataPilotControl::disposing() 181 { 182 ScUnoGuard aGuard; 183 mpFieldWindow = NULL; 184 185 ScAccessibleContextBase::disposing(); 186 } 187 188 void ScAccessibleDataPilotControl::AddField(sal_Int32 nNewIndex) 189 { 190 sal_Bool bAdded(sal_False); 191 if (static_cast<size_t>(nNewIndex) == maChildren.size()) 192 { 193 maChildren.push_back(AccessibleWeak()); 194 bAdded = sal_True; 195 } 196 else if (static_cast<size_t>(nNewIndex) < maChildren.size()) 197 { 198 ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nNewIndex; 199 maChildren.insert(aItr, AccessibleWeak()); 200 201 ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end(); 202 aItr = maChildren.begin() + nNewIndex + 1; 203 uno::Reference< XAccessible > xTempAcc; 204 sal_Int32 nIndex = nNewIndex + 1; 205 while (aItr != aEndItr) 206 { 207 xTempAcc = aItr->xWeakAcc; 208 if (xTempAcc.is() && aItr->pAcc) 209 aItr->pAcc->SetIndex(nIndex); 210 ++nIndex; 211 ++aItr; 212 } 213 bAdded = sal_True; 214 } 215 else 216 { 217 DBG_ERRORFILE("did not recognize a child count change"); 218 } 219 220 if (bAdded) 221 { 222 AccessibleEventObject aEvent; 223 aEvent.EventId = AccessibleEventId::CHILD; 224 aEvent.Source = uno::Reference< XAccessibleContext >(this); 225 aEvent.NewValue <<= getAccessibleChild(nNewIndex); 226 227 CommitChange(aEvent); // new child - event 228 } 229 } 230 231 void ScAccessibleDataPilotControl::RemoveField(sal_Int32 nOldIndex) 232 { 233 sal_Bool bRemoved(sal_False); 234 uno::Reference< XAccessible > xTempAcc; 235 ScAccessibleDataPilotButton* pField = NULL; 236 if (static_cast<size_t>(nOldIndex) < maChildren.size()) 237 { 238 xTempAcc = getAccessibleChild(nOldIndex); 239 pField = maChildren[nOldIndex].pAcc; 240 241 ::std::vector < AccessibleWeak >::iterator aItr = maChildren.begin() + nOldIndex; 242 aItr = maChildren.erase(aItr); 243 244 ::std::vector < AccessibleWeak >::iterator aEndItr = maChildren.end(); 245 uno::Reference< XAccessible > xItrAcc; 246 while (aItr != aEndItr) 247 { 248 xItrAcc = aItr->xWeakAcc; 249 if (xItrAcc.is() && aItr->pAcc) 250 aItr->pAcc->SetIndex(nOldIndex); 251 ++nOldIndex; 252 ++aItr; 253 } 254 bRemoved = sal_True; 255 } 256 else 257 { 258 DBG_ERRORFILE("did not recognize a child count change"); 259 } 260 261 if (bRemoved) 262 { 263 AccessibleEventObject aEvent; 264 aEvent.EventId = AccessibleEventId::CHILD; 265 aEvent.Source = uno::Reference< XAccessibleContext >(this); 266 aEvent.NewValue <<= xTempAcc; 267 268 CommitChange(aEvent); // gone child - event 269 270 if (pField) 271 pField->dispose(); 272 } 273 } 274 275 void ScAccessibleDataPilotControl::FieldFocusChange(sal_Int32 nOldIndex, sal_Int32 nNewIndex) 276 { 277 DBG_ASSERT(static_cast<size_t>(nOldIndex) < maChildren.size() && 278 static_cast<size_t>(nNewIndex) < maChildren.size(), "did not recognize a child count change"); 279 280 uno::Reference < XAccessible > xTempAcc = maChildren[nOldIndex].xWeakAcc; 281 if (xTempAcc.is() && maChildren[nOldIndex].pAcc) 282 maChildren[nOldIndex].pAcc->ResetFocused(); 283 284 xTempAcc = maChildren[nNewIndex].xWeakAcc; 285 if (xTempAcc.is() && maChildren[nNewIndex].pAcc) 286 maChildren[nNewIndex].pAcc->SetFocused(); 287 } 288 289 void ScAccessibleDataPilotControl::FieldNameChange(sal_Int32 nIndex) 290 { 291 DBG_ASSERT(static_cast<size_t>(nIndex) < maChildren.size(), "did not recognize a child count change"); 292 293 uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 294 if (xTempAcc.is() && maChildren[nIndex].pAcc) 295 maChildren[nIndex].pAcc->ChangeName(); 296 } 297 298 void ScAccessibleDataPilotControl::GotFocus() 299 { 300 if (mpFieldWindow) 301 { 302 DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 303 304 if(maChildren.size()==0) 305 return ; 306 sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex()); 307 uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 308 if (xTempAcc.is() && maChildren[nIndex].pAcc) 309 maChildren[nIndex].pAcc->SetFocused(); 310 } 311 } 312 313 void ScAccessibleDataPilotControl::LostFocus() 314 { 315 if (mpFieldWindow) 316 { 317 DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 318 if(maChildren.size()==0) 319 return ; 320 sal_Int32 nIndex(mpFieldWindow->GetSelectedIndex()); 321 uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 322 if (xTempAcc.is() && maChildren[nIndex].pAcc) 323 maChildren[nIndex].pAcc->ResetFocused(); 324 } 325 } 326 327 ///===== XAccessibleComponent ============================================ 328 329 uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotControl::getAccessibleAtPoint( 330 const awt::Point& rPoint ) 331 { 332 uno::Reference<XAccessible> xAcc; 333 if (containsPoint(rPoint)) 334 { 335 ScUnoGuard aGuard; 336 IsObjectValid(); 337 if (mpFieldWindow) 338 { 339 Point aAbsPoint(VCLPoint(rPoint)); 340 Point aControlEdge(GetBoundingBoxOnScreen().TopLeft()); 341 Point aRelPoint(aAbsPoint - aControlEdge); 342 size_t nChildIndex = mpFieldWindow->GetFieldIndex( aRelPoint ); 343 if( nChildIndex != PIVOTFIELD_INVALID ) 344 xAcc = getAccessibleChild(static_cast< long >( nChildIndex )); 345 } 346 } 347 return xAcc; 348 } 349 350 sal_Bool SAL_CALL ScAccessibleDataPilotControl::isVisible( ) 351 { 352 return sal_True; 353 } 354 355 void SAL_CALL ScAccessibleDataPilotControl::grabFocus( ) 356 { 357 ScUnoGuard aGuard; 358 IsObjectValid(); 359 if (mpFieldWindow) 360 mpFieldWindow->GrabFocus(); 361 } 362 363 sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getForeground( ) 364 { 365 ScUnoGuard aGuard; 366 IsObjectValid(); 367 sal_Int32 nColor(0); 368 if (mpFieldWindow) 369 { 370 nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetWindowTextColor().GetColor(); 371 } 372 return nColor; 373 } 374 375 sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getBackground( ) 376 { 377 ScUnoGuard aGuard; 378 IsObjectValid(); 379 sal_Int32 nColor(0); 380 if (mpFieldWindow) 381 { 382 const StyleSettings& rStyleSett = mpFieldWindow->GetSettings().GetStyleSettings(); 383 nColor = (mpFieldWindow->GetType() == PIVOTFIELDTYPE_SELECT) ? rStyleSett.GetFaceColor().GetColor() : rStyleSett.GetWindowColor().GetColor(); 384 } 385 return nColor; 386 } 387 388 ///===== XAccessibleContext ============================================== 389 390 sal_Int32 SAL_CALL ScAccessibleDataPilotControl::getAccessibleChildCount(void) 391 { 392 ScUnoGuard aGuard; 393 IsObjectValid(); 394 if (mpFieldWindow) 395 return mpFieldWindow->GetFieldCount(); 396 else 397 return 0; 398 } 399 400 uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotControl::getAccessibleChild(sal_Int32 nIndex) 401 { 402 ScUnoGuard aGuard; 403 IsObjectValid(); 404 uno::Reference<XAccessible> xAcc; 405 if (mpFieldWindow) 406 { 407 if (nIndex < 0 || static_cast< size_t >( nIndex ) >= mpFieldWindow->GetFieldCount()) 408 throw lang::IndexOutOfBoundsException(); 409 410 DBG_ASSERT(mpFieldWindow->GetFieldCount() == maChildren.size(), "did not recognize a child count change"); 411 412 uno::Reference < XAccessible > xTempAcc = maChildren[nIndex].xWeakAcc; 413 if (!xTempAcc.is()) 414 { 415 maChildren[nIndex].pAcc = new ScAccessibleDataPilotButton(this, mpFieldWindow, nIndex); 416 xTempAcc = maChildren[nIndex].pAcc; 417 maChildren[nIndex].xWeakAcc = xTempAcc; 418 } 419 420 xAcc = xTempAcc; 421 } 422 return xAcc; 423 } 424 425 uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotControl::getAccessibleStateSet(void) 426 { 427 ScUnoGuard aGuard; 428 IsObjectValid(); 429 430 utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 431 432 if (IsDefunc()) 433 pStateSet->AddState(AccessibleStateType::DEFUNC); 434 else 435 { 436 pStateSet->AddState(AccessibleStateType::ENABLED); 437 pStateSet->AddState(AccessibleStateType::OPAQUE); 438 if (isShowing()) 439 pStateSet->AddState(AccessibleStateType::SHOWING); 440 if (isVisible()) 441 pStateSet->AddState(AccessibleStateType::VISIBLE); 442 } 443 444 return pStateSet; 445 } 446 447 ///===== XServiceInfo ==================================================== 448 449 ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::getImplementationName(void) 450 { 451 return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotControl")); 452 } 453 454 ///===== XTypeProvider =================================================== 455 456 uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotControl::getImplementationId(void) 457 { 458 ScUnoGuard aGuard; 459 IsObjectValid(); 460 static uno::Sequence<sal_Int8> aId; 461 if (aId.getLength() == 0) 462 { 463 aId.realloc (16); 464 rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 465 } 466 return aId; 467 } 468 469 //===== internal ======================================================== 470 471 ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleDescription(void) 472 { 473 ScUnoGuard aGuard; 474 IsObjectValid(); 475 if (mpFieldWindow) 476 return mpFieldWindow->GetDescription(); 477 478 return rtl::OUString(); 479 } 480 481 ::rtl::OUString SAL_CALL ScAccessibleDataPilotControl::createAccessibleName(void) 482 { 483 ScUnoGuard aGuard; 484 IsObjectValid(); 485 if (mpFieldWindow) 486 return mpFieldWindow->GetName(); 487 488 return rtl::OUString(); 489 } 490 491 Rectangle ScAccessibleDataPilotControl::GetBoundingBoxOnScreen(void) const 492 { 493 if (mpFieldWindow) 494 return mpFieldWindow->GetWindowExtentsRelative(NULL); 495 else 496 return Rectangle(); 497 } 498 499 Rectangle ScAccessibleDataPilotControl::GetBoundingBox(void) const 500 { 501 if (mpFieldWindow) 502 return mpFieldWindow->GetWindowExtentsRelative(mpFieldWindow->GetAccessibleParentWindow()); 503 else 504 return Rectangle(); 505 } 506 507 508 //=============================================================================== 509 510 ScAccessibleDataPilotButton::ScAccessibleDataPilotButton( 511 const ::com::sun::star::uno::Reference< 512 ::com::sun::star::accessibility::XAccessible>& rxParent, 513 ScPivotFieldWindow* pFieldWindow, 514 sal_Int32 nIndex) 515 //change role from PUSH_BUTTON to BUTTON_MENU 516 : ScAccessibleContextBase(rxParent, AccessibleRole::BUTTON_MENU), 517 mpFieldWindow(pFieldWindow), 518 mnIndex(nIndex) 519 { 520 } 521 522 ScAccessibleDataPilotButton::~ScAccessibleDataPilotButton(void) 523 { 524 if (!IsDefunc() && !rBHelper.bInDispose) 525 { 526 // increment refcount to prevent double call off dtor 527 osl_incrementInterlockedCount( &m_refCount ); 528 // call dispose to inform object which have a weak reference to this object 529 dispose(); 530 } 531 } 532 533 void ScAccessibleDataPilotButton::Init() 534 { 535 } 536 537 void SAL_CALL ScAccessibleDataPilotButton::disposing() 538 { 539 ScUnoGuard aGuard; 540 mpFieldWindow = NULL; 541 542 ScAccessibleContextBase::disposing(); 543 } 544 545 void ScAccessibleDataPilotButton::SetFocused() 546 { 547 CommitFocusGained(); 548 } 549 550 void ScAccessibleDataPilotButton::ResetFocused() 551 { 552 CommitFocusLost(); 553 } 554 555 ///===== XAccessibleComponent ============================================ 556 557 uno::Reference< XAccessible > SAL_CALL ScAccessibleDataPilotButton::getAccessibleAtPoint( 558 const ::com::sun::star::awt::Point& /* rPoint */ ) 559 { 560 return NULL; 561 } 562 563 sal_Bool SAL_CALL ScAccessibleDataPilotButton::isVisible( ) 564 { 565 return sal_True; 566 } 567 568 void SAL_CALL ScAccessibleDataPilotButton::grabFocus( ) 569 { 570 ScUnoGuard aGuard; 571 IsObjectValid(); 572 if (mpFieldWindow) 573 { 574 mpFieldWindow->GrabFocusAndSelect(getAccessibleIndexInParent()); 575 } 576 } 577 578 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getForeground( ) 579 { 580 ScUnoGuard aGuard; 581 IsObjectValid(); 582 sal_Int32 nColor(0); 583 if (mpFieldWindow) 584 { 585 nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetButtonTextColor().GetColor(); 586 } 587 return nColor; 588 } 589 590 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getBackground( ) 591 { 592 ScUnoGuard aGuard; 593 IsObjectValid(); 594 sal_Int32 nColor(0); 595 if (mpFieldWindow) 596 { 597 nColor = mpFieldWindow->GetSettings().GetStyleSettings().GetFaceColor().GetColor(); 598 } 599 return nColor; 600 } 601 602 ///===== XAccessibleContext ============================================== 603 604 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleChildCount(void) 605 { 606 return 0; 607 } 608 609 uno::Reference< XAccessible> SAL_CALL ScAccessibleDataPilotButton::getAccessibleChild(sal_Int32 /* nIndex */) 610 { 611 throw lang::IndexOutOfBoundsException(); 612 } 613 614 sal_Int32 SAL_CALL ScAccessibleDataPilotButton::getAccessibleIndexInParent(void) 615 { 616 ScUnoGuard aGuard; 617 IsObjectValid(); 618 return mnIndex; 619 } 620 621 uno::Reference<XAccessibleStateSet> SAL_CALL ScAccessibleDataPilotButton::getAccessibleStateSet(void) 622 { 623 ScUnoGuard aGuard; 624 IsObjectValid(); 625 626 utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper(); 627 628 if (IsDefunc()) 629 pStateSet->AddState(AccessibleStateType::DEFUNC); 630 else 631 { 632 pStateSet->AddState(AccessibleStateType::ENABLED); 633 pStateSet->AddState(AccessibleStateType::OPAQUE); 634 pStateSet->AddState(AccessibleStateType::FOCUSABLE); 635 if (mpFieldWindow && (sal::static_int_cast<sal_Int32>(mpFieldWindow->GetSelectedIndex()) == mnIndex)) 636 pStateSet->AddState(AccessibleStateType::FOCUSED); 637 if (isShowing()) 638 pStateSet->AddState(AccessibleStateType::SHOWING); 639 if (isVisible()) 640 pStateSet->AddState(AccessibleStateType::VISIBLE); 641 } 642 643 return pStateSet; 644 } 645 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > 646 SAL_CALL ScAccessibleDataPilotButton::getAccessibleRelationSet( ) 647 { 648 utl::AccessibleRelationSetHelper* pRelationSetHelper = new utl::AccessibleRelationSetHelper; 649 uno::Reference< accessibility::XAccessibleRelationSet > xSet = pRelationSetHelper; 650 if(mxParent.is()) 651 { 652 uno::Sequence< uno::Reference< uno::XInterface > > aSequence(1); 653 aSequence[0] = mxParent; 654 pRelationSetHelper->AddRelation( accessibility::AccessibleRelation( accessibility::AccessibleRelationType::MEMBER_OF, aSequence ) ); 655 } 656 657 return xSet; 658 659 } 660 ///===== XServiceInfo ==================================================== 661 662 ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::getImplementationName(void) 663 { 664 return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleDataPilotButton")); 665 } 666 667 ///===== XTypeProvider =================================================== 668 669 uno::Sequence<sal_Int8> SAL_CALL ScAccessibleDataPilotButton::getImplementationId(void) 670 { 671 ScUnoGuard aGuard; 672 IsObjectValid(); 673 static uno::Sequence<sal_Int8> aId; 674 if (aId.getLength() == 0) 675 { 676 aId.realloc (16); 677 rtl_createUuid (reinterpret_cast<sal_uInt8 *>(aId.getArray()), 0, sal_True); 678 } 679 return aId; 680 } 681 682 ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleDescription(void) 683 { 684 if (mpFieldWindow) 685 return mpFieldWindow->GetHelpText(); 686 return rtl::OUString(); 687 } 688 689 ::rtl::OUString SAL_CALL ScAccessibleDataPilotButton::createAccessibleName(void) 690 { 691 ScUnoGuard aGuard; 692 IsObjectValid(); 693 if (mpFieldWindow) 694 return mpFieldWindow->GetFieldText(getAccessibleIndexInParent()); 695 696 return rtl::OUString(); 697 } 698 699 Rectangle ScAccessibleDataPilotButton::GetBoundingBoxOnScreen(void) const 700 { 701 Rectangle aRect(GetBoundingBox()); 702 703 if (mpFieldWindow) 704 { 705 Point aParentPos(mpFieldWindow->GetWindowExtentsRelative(NULL).TopLeft()); 706 aRect.Move(aParentPos.getX(), aParentPos.getY()); 707 } 708 709 return aRect; 710 } 711 712 Rectangle ScAccessibleDataPilotButton::GetBoundingBox(void) const 713 { 714 if (mpFieldWindow) 715 return Rectangle (mpFieldWindow->GetFieldPosition(const_cast<ScAccessibleDataPilotButton*> (this)->getAccessibleIndexInParent()), mpFieldWindow->GetFieldSize()); 716 else 717 return Rectangle(); 718 } 719 // ----------------------------------------------------------------------------- 720 // XAccessibleAction 721 // ----------------------------------------------------------------------------- 722 sal_Int32 ScAccessibleDataPilotButton::getAccessibleActionCount( ) 723 { 724 return 1; 725 } 726 // ----------------------------------------------------------------------------- 727 sal_Bool ScAccessibleDataPilotButton::doAccessibleAction ( sal_Int32 nIndex ) 728 { 729 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 730 throw lang::IndexOutOfBoundsException(); 731 return sal_True; 732 } 733 // ----------------------------------------------------------------------------- 734 ::rtl::OUString ScAccessibleDataPilotButton::getAccessibleActionDescription ( sal_Int32 nIndex ) 735 { 736 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 737 throw lang::IndexOutOfBoundsException(); 738 return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "press" ) ); 739 } 740 // ----------------------------------------------------------------------------- 741 ::com::sun::star::uno::Reference< XAccessibleKeyBinding > ScAccessibleDataPilotButton::getAccessibleActionKeyBinding( sal_Int32 nIndex ) 742 { 743 if ( nIndex < 0 || nIndex >= getAccessibleActionCount() ) 744 throw lang::IndexOutOfBoundsException(); 745 comphelper::OAccessibleKeyBindingHelper* pKeyBindingHelper = new comphelper::OAccessibleKeyBindingHelper(); 746 ::com::sun::star::uno::Reference< XAccessibleKeyBinding > xKeyBinding = pKeyBindingHelper; 747 ScPivotFieldWindow* pWindow = mpFieldWindow; 748 if ( pWindow ) 749 { 750 awt::KeyStroke aKeyStroke; 751 aKeyStroke.Modifiers = 0; 752 aKeyStroke.KeyCode = KEY_SPACE; 753 pKeyBindingHelper->AddKeyBinding( aKeyStroke ); 754 } 755 return xKeyBinding; 756 } 757 //===== XInterface ===================================================== 758 uno::Any SAL_CALL ScAccessibleDataPilotButton::queryInterface( uno::Type const & rType ) 759 { 760 uno::Any aAny (ScAccessibleContextBase::queryInterface(rType)); 761 if(!aAny.hasValue()) 762 { 763 aAny = ::cppu::queryInterface (rType, 764 static_cast<XAccessibleAction*>(this) 765 ); 766 } 767 return aAny; 768 } 769 void SAL_CALL ScAccessibleDataPilotButton::acquire() 770 throw () 771 { 772 ScAccessibleContextBase::acquire(); 773 } 774 void SAL_CALL ScAccessibleDataPilotButton::release() 775 throw () 776 { 777 ScAccessibleContextBase::release(); 778 } 779