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