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_sd.hxx" 30 #include "AccessibleDocumentViewBase.hxx" 31 #include <com/sun/star/drawing/XDrawPage.hpp> 32 #include <com/sun/star/drawing/XDrawView.hpp> 33 #include <com/sun/star/drawing/XShapes.hpp> 34 #include <com/sun/star/container/XChild.hpp> 35 #include <com/sun/star/frame/XController.hpp> 36 #include <com/sun/star/frame/XFrame.hpp> 37 #include <com/sun/star/document/XEventBroadcaster.hpp> 38 #include <com/sun/star/beans/XPropertySet.hpp> 39 #include <com/sun/star/accessibility/AccessibleEventId.hpp> 40 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> 41 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42 #include <rtl/ustring.h> 43 #include<sfx2/viewfrm.hxx> 44 45 #include <svx/AccessibleShape.hxx> 46 47 #include <svx/svdobj.hxx> 48 #include <svx/svdmodel.hxx> 49 #include <svx/unoapi.hxx> 50 #include <toolkit/helper/vclunohelper.hxx> 51 #include "Window.hxx" 52 #include <vcl/svapp.hxx> 53 54 55 #include "ViewShell.hxx" 56 #include "View.hxx" 57 #include <memory> 58 59 using ::rtl::OUString; 60 using namespace ::com::sun::star; 61 using namespace ::com::sun::star::accessibility; 62 using ::com::sun::star::uno::Reference; 63 64 class SfxViewFrame; 65 66 namespace accessibility { 67 68 //===== internal ============================================================ 69 AccessibleDocumentViewBase::AccessibleDocumentViewBase ( 70 ::sd::Window* pSdWindow, 71 ::sd::ViewShell* pViewShell, 72 const uno::Reference<frame::XController>& rxController, 73 const uno::Reference<XAccessible>& rxParent) 74 : AccessibleContextBase (rxParent, AccessibleRole::DOCUMENT), 75 mpWindow (pSdWindow), 76 mxController (rxController), 77 mxModel (NULL), 78 maViewForwarder ( 79 static_cast<SdrPaintView*>(pViewShell->GetView()), 80 *static_cast<OutputDevice*>(pSdWindow)) 81 { 82 if (mxController.is()) 83 mxModel = mxController->getModel(); 84 85 // Fill the shape tree info. 86 maShapeTreeInfo.SetModelBroadcaster ( 87 uno::Reference<document::XEventBroadcaster>( 88 mxModel, uno::UNO_QUERY)); 89 maShapeTreeInfo.SetController (mxController); 90 maShapeTreeInfo.SetSdrView (pViewShell->GetView()); 91 maShapeTreeInfo.SetWindow (pSdWindow); 92 maShapeTreeInfo.SetViewForwarder (&maViewForwarder); 93 94 mxWindow = ::VCLUnoHelper::GetInterface (pSdWindow); 95 } 96 97 98 99 100 AccessibleDocumentViewBase::~AccessibleDocumentViewBase (void) 101 { 102 // At this place we should be disposed. You may want to add a 103 // corresponding assertion into the destructor of a derived class. 104 } 105 106 107 108 109 void AccessibleDocumentViewBase::Init (void) 110 { 111 // Finish the initialization of the shape tree info container. 112 maShapeTreeInfo.SetDocumentWindow (this); 113 114 // Register as window listener to stay up to date with its size and 115 // position. 116 mxWindow->addWindowListener (this); 117 // Register as focus listener to 118 mxWindow->addFocusListener (this); 119 120 // Determine the list of shapes on the current page. 121 uno::Reference<drawing::XShapes> xShapeList; 122 uno::Reference<drawing::XDrawView> xView (mxController, uno::UNO_QUERY); 123 if (xView.is()) 124 xShapeList = uno::Reference<drawing::XShapes> ( 125 xView->getCurrentPage(), uno::UNO_QUERY); 126 127 // Register this object as dispose event listener at the model. 128 if (mxModel.is()) 129 mxModel->addEventListener ( 130 static_cast<awt::XWindowListener*>(this)); 131 132 // Register as property change listener at the controller. 133 uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY); 134 if (xSet.is()) 135 xSet->addPropertyChangeListener ( 136 OUString (RTL_CONSTASCII_USTRINGPARAM("")), 137 static_cast<beans::XPropertyChangeListener*>(this)); 138 139 // Register this object as dispose event listener at the controller. 140 if (mxController.is()) 141 mxController->addEventListener ( 142 static_cast<awt::XWindowListener*>(this)); 143 144 // Register at VCL Window to be informed of activated and deactivated 145 // OLE objects. 146 Window* pWindow = maShapeTreeInfo.GetWindow(); 147 if (pWindow != NULL) 148 { 149 maWindowLink = LINK( 150 this, AccessibleDocumentViewBase, WindowChildEventListener); 151 152 pWindow->AddChildEventListener (maWindowLink); 153 154 sal_uInt16 nCount = pWindow->GetChildCount(); 155 for (sal_uInt16 i=0; i<nCount; i++) 156 { 157 Window* pChildWindow = pWindow->GetChild (i); 158 if (pChildWindow && 159 (AccessibleRole::EMBEDDED_OBJECT 160 ==pChildWindow->GetAccessibleRole())) 161 { 162 SetAccessibleOLEObject (pChildWindow->GetAccessible()); 163 } 164 } 165 } 166 } 167 168 169 170 171 IMPL_LINK(AccessibleDocumentViewBase, WindowChildEventListener, 172 VclSimpleEvent*, pEvent) 173 { 174 OSL_ASSERT(pEvent!=NULL && pEvent->ISA(VclWindowEvent)); 175 if (pEvent!=NULL && pEvent->ISA(VclWindowEvent)) 176 { 177 VclWindowEvent* pWindowEvent = static_cast<VclWindowEvent*>(pEvent); 178 // DBG_ASSERT( pVclEvent->GetWindow(), "Window???" ); 179 switch (pWindowEvent->GetId()) 180 { 181 case VCLEVENT_OBJECT_DYING: 182 { 183 // Window is dying. Unregister from VCL Window. 184 // This is also attempted in the disposing() method. 185 Window* pWindow = maShapeTreeInfo.GetWindow(); 186 Window* pDyingWindow = static_cast<Window*>( 187 pWindowEvent->GetWindow()); 188 if (pWindow==pDyingWindow && pWindow!=NULL && maWindowLink.IsSet()) 189 { 190 pWindow->RemoveChildEventListener (maWindowLink); 191 maWindowLink = Link(); 192 } 193 } 194 break; 195 196 case VCLEVENT_WINDOW_SHOW: 197 { 198 // A new window has been created. Is it an OLE object? 199 Window* pChildWindow = static_cast<Window*>( 200 pWindowEvent->GetData()); 201 if (pChildWindow!=NULL 202 && (pChildWindow->GetAccessibleRole() 203 == AccessibleRole::EMBEDDED_OBJECT)) 204 { 205 SetAccessibleOLEObject (pChildWindow->GetAccessible()); 206 } 207 } 208 break; 209 210 case VCLEVENT_WINDOW_HIDE: 211 { 212 // A window has been destroyed. Has that been an OLE 213 // object? 214 Window* pChildWindow = static_cast<Window*>( 215 pWindowEvent->GetData()); 216 if (pChildWindow!=NULL 217 && (pChildWindow->GetAccessibleRole() 218 == AccessibleRole::EMBEDDED_OBJECT)) 219 { 220 SetAccessibleOLEObject (NULL); 221 } 222 } 223 break; 224 } 225 } 226 227 return 0; 228 } 229 230 231 232 233 //===== IAccessibleViewForwarderListener ==================================== 234 235 void AccessibleDocumentViewBase::ViewForwarderChanged(ChangeType, const IAccessibleViewForwarder* ) 236 { 237 // Empty 238 } 239 240 241 242 243 //===== XAccessibleContext ================================================== 244 245 Reference<XAccessible> SAL_CALL 246 AccessibleDocumentViewBase::getAccessibleParent (void) 247 throw (uno::RuntimeException) 248 { 249 ThrowIfDisposed (); 250 251 return AccessibleContextBase::getAccessibleParent(); 252 } 253 254 255 256 sal_Int32 SAL_CALL 257 AccessibleDocumentViewBase::getAccessibleChildCount (void) 258 throw (uno::RuntimeException) 259 { 260 ThrowIfDisposed (); 261 262 if (mxAccessibleOLEObject.is()) 263 return 1; 264 else 265 return 0; 266 } 267 268 269 270 271 Reference<XAccessible> SAL_CALL 272 AccessibleDocumentViewBase::getAccessibleChild (sal_Int32 nIndex) 273 throw (uno::RuntimeException, lang::IndexOutOfBoundsException) 274 { 275 ThrowIfDisposed (); 276 277 ::osl::MutexGuard aGuard (maMutex); 278 if (mxAccessibleOLEObject.is()) 279 if (nIndex == 0) 280 return mxAccessibleOLEObject; 281 282 throw lang::IndexOutOfBoundsException ( 283 ::rtl::OUString::createFromAscii ("no child with index ") 284 + rtl::OUString::valueOf(nIndex), 285 NULL); 286 } 287 288 289 290 291 //===== XAccessibleComponent ================================================ 292 293 /** Iterate over all children and test whether the specified point lies 294 within one of their bounding boxes. Return the first child for which 295 this is true. 296 */ 297 uno::Reference<XAccessible > SAL_CALL 298 AccessibleDocumentViewBase::getAccessibleAtPoint ( 299 const awt::Point& aPoint) 300 throw (uno::RuntimeException) 301 { 302 ThrowIfDisposed (); 303 304 ::osl::MutexGuard aGuard (maMutex); 305 uno::Reference<XAccessible> xChildAtPosition; 306 307 sal_Int32 nChildCount = getAccessibleChildCount (); 308 for (sal_Int32 i=nChildCount-1; i>=0; --i) 309 { 310 Reference<XAccessible> xChild (getAccessibleChild (i)); 311 if (xChild.is()) 312 { 313 Reference<XAccessibleComponent> xChildComponent ( 314 xChild->getAccessibleContext(), uno::UNO_QUERY); 315 if (xChildComponent.is()) 316 { 317 awt::Rectangle aBBox (xChildComponent->getBounds()); 318 if ( (aPoint.X >= aBBox.X) 319 && (aPoint.Y >= aBBox.Y) 320 && (aPoint.X < aBBox.X+aBBox.Width) 321 && (aPoint.Y < aBBox.Y+aBBox.Height) ) 322 { 323 xChildAtPosition = xChild; 324 break; 325 } 326 } 327 } 328 } 329 330 // Have not found a child under the given point. Returning empty 331 // reference to indicate this. 332 return xChildAtPosition; 333 } 334 335 336 337 338 awt::Rectangle SAL_CALL 339 AccessibleDocumentViewBase::getBounds (void) 340 throw (::com::sun::star::uno::RuntimeException) 341 { 342 ThrowIfDisposed (); 343 344 // Transform visible area into screen coordinates. 345 ::Rectangle aVisibleArea ( 346 maShapeTreeInfo.GetViewForwarder()->GetVisibleArea()); 347 ::Point aPixelTopLeft ( 348 maShapeTreeInfo.GetViewForwarder()->LogicToPixel ( 349 aVisibleArea.TopLeft())); 350 ::Point aPixelSize ( 351 maShapeTreeInfo.GetViewForwarder()->LogicToPixel ( 352 aVisibleArea.BottomRight()) 353 - aPixelTopLeft); 354 355 // Prepare to subtract the parent position to transform into relative 356 // coordinates. 357 awt::Point aParentPosition; 358 Reference<XAccessible> xParent = getAccessibleParent (); 359 if (xParent.is()) 360 { 361 Reference<XAccessibleComponent> xParentComponent ( 362 xParent->getAccessibleContext(), uno::UNO_QUERY); 363 if (xParentComponent.is()) 364 aParentPosition = xParentComponent->getLocationOnScreen(); 365 } 366 367 return awt::Rectangle ( 368 aPixelTopLeft.X() - aParentPosition.X, 369 aPixelTopLeft.Y() - aParentPosition.Y, 370 aPixelSize.X(), 371 aPixelSize.Y()); 372 } 373 374 375 376 377 awt::Point SAL_CALL 378 AccessibleDocumentViewBase::getLocation (void) 379 throw (uno::RuntimeException) 380 { 381 ThrowIfDisposed (); 382 awt::Rectangle aBoundingBox (getBounds()); 383 return awt::Point (aBoundingBox.X, aBoundingBox.Y); 384 } 385 386 387 388 389 awt::Point SAL_CALL 390 AccessibleDocumentViewBase::getLocationOnScreen (void) 391 throw (uno::RuntimeException) 392 { 393 ThrowIfDisposed (); 394 ::Point aLogicalPoint (maShapeTreeInfo.GetViewForwarder()->GetVisibleArea().TopLeft()); 395 ::Point aPixelPoint (maShapeTreeInfo.GetViewForwarder()->LogicToPixel (aLogicalPoint)); 396 return awt::Point (aPixelPoint.X(), aPixelPoint.Y()); 397 } 398 399 400 401 402 awt::Size SAL_CALL 403 AccessibleDocumentViewBase::getSize (void) 404 throw (uno::RuntimeException) 405 { 406 ThrowIfDisposed (); 407 408 // Transform visible area into screen coordinates. 409 ::Rectangle aVisibleArea ( 410 maShapeTreeInfo.GetViewForwarder()->GetVisibleArea()); 411 ::Point aPixelTopLeft ( 412 maShapeTreeInfo.GetViewForwarder()->LogicToPixel ( 413 aVisibleArea.TopLeft())); 414 ::Point aPixelSize ( 415 maShapeTreeInfo.GetViewForwarder()->LogicToPixel ( 416 aVisibleArea.BottomRight()) 417 - aPixelTopLeft); 418 419 return awt::Size (aPixelSize.X(), aPixelSize.Y()); 420 } 421 422 423 424 425 //===== XInterface ========================================================== 426 427 uno::Any SAL_CALL 428 AccessibleDocumentViewBase::queryInterface (const uno::Type & rType) 429 throw (uno::RuntimeException) 430 { 431 uno::Any aReturn = AccessibleContextBase::queryInterface (rType); 432 if ( ! aReturn.hasValue()) 433 aReturn = ::cppu::queryInterface (rType, 434 static_cast<XAccessibleComponent*>(this), 435 static_cast<XAccessibleSelection*>(this), 436 static_cast<lang::XEventListener*>( 437 static_cast<awt::XWindowListener*>(this)), 438 static_cast<beans::XPropertyChangeListener*>(this), 439 static_cast<awt::XWindowListener*>(this), 440 static_cast<awt::XFocusListener*>(this) 441 ); 442 return aReturn; 443 } 444 445 446 447 448 void SAL_CALL 449 AccessibleDocumentViewBase::acquire (void) 450 throw () 451 { 452 AccessibleContextBase::acquire (); 453 } 454 455 456 457 458 void SAL_CALL 459 AccessibleDocumentViewBase::release (void) 460 throw () 461 { 462 AccessibleContextBase::release (); 463 } 464 465 466 467 468 //===== XServiceInfo ======================================================== 469 470 ::rtl::OUString SAL_CALL 471 AccessibleDocumentViewBase::getImplementationName (void) 472 throw (::com::sun::star::uno::RuntimeException) 473 { 474 return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase")); 475 } 476 477 478 479 480 ::com::sun::star::uno::Sequence< ::rtl::OUString> SAL_CALL 481 AccessibleDocumentViewBase::getSupportedServiceNames (void) 482 throw (::com::sun::star::uno::RuntimeException) 483 { 484 ThrowIfDisposed (); 485 return AccessibleContextBase::getSupportedServiceNames (); 486 } 487 488 489 490 491 492 //===== XTypeProvider ======================================================= 493 494 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type> SAL_CALL 495 AccessibleDocumentViewBase::getTypes (void) 496 throw (::com::sun::star::uno::RuntimeException) 497 { 498 ThrowIfDisposed (); 499 500 // Get list of types from the context base implementation, ... 501 uno::Sequence<uno::Type> aTypeList (AccessibleContextBase::getTypes()); 502 // ... get list of types from component base implementation, ... 503 uno::Sequence<uno::Type> aComponentTypeList (AccessibleComponentBase::getTypes()); 504 505 506 // ...and add the additional type for the component, ... 507 const uno::Type aLangEventListenerType = 508 ::getCppuType((const uno::Reference<lang::XEventListener>*)0); 509 const uno::Type aPropertyChangeListenerType = 510 ::getCppuType((const uno::Reference<beans::XPropertyChangeListener>*)0); 511 const uno::Type aWindowListenerType = 512 ::getCppuType((const uno::Reference<awt::XWindowListener>*)0); 513 const uno::Type aFocusListenerType = 514 ::getCppuType((const uno::Reference<awt::XFocusListener>*)0); 515 const uno::Type aEventBroadcaster = 516 ::getCppuType((const uno::Reference<XAccessibleEventBroadcaster>*)0); 517 518 // ... and merge them all into one list. 519 sal_Int32 nTypeCount (aTypeList.getLength()), 520 nComponentTypeCount (aComponentTypeList.getLength()), 521 i; 522 523 aTypeList.realloc (nTypeCount + nComponentTypeCount + 5); 524 525 for (i=0; i<nComponentTypeCount; i++) 526 aTypeList[nTypeCount + i] = aComponentTypeList[i]; 527 528 aTypeList[nTypeCount + i++ ] = aLangEventListenerType; 529 aTypeList[nTypeCount + i++] = aPropertyChangeListenerType; 530 aTypeList[nTypeCount + i++] = aWindowListenerType; 531 aTypeList[nTypeCount + i++] = aFocusListenerType; 532 aTypeList[nTypeCount + i++] = aEventBroadcaster; 533 534 return aTypeList; 535 } 536 537 538 539 540 void AccessibleDocumentViewBase::impl_dispose() 541 { 542 // Unregister from VCL Window. 543 Window* pWindow = maShapeTreeInfo.GetWindow(); 544 if (maWindowLink.IsSet()) 545 { 546 if (pWindow) 547 pWindow->RemoveChildEventListener (maWindowLink); 548 maWindowLink = Link(); 549 } 550 else 551 { 552 DBG_ASSERT (pWindow, "AccessibleDocumentViewBase::disposing"); 553 } 554 555 // Unregister from window. 556 if (mxWindow.is()) 557 { 558 mxWindow->removeWindowListener (this); 559 mxWindow->removeFocusListener (this); 560 mxWindow = NULL; 561 } 562 563 // Unregister form the model. 564 if (mxModel.is()) 565 mxModel->removeEventListener ( 566 static_cast<awt::XWindowListener*>(this)); 567 568 // Unregister from the controller. 569 if (mxController.is()) 570 { 571 uno::Reference<beans::XPropertySet> xSet (mxController, uno::UNO_QUERY); 572 if (xSet.is()) 573 xSet->removePropertyChangeListener ( 574 OUString (RTL_CONSTASCII_USTRINGPARAM("")), 575 static_cast<beans::XPropertyChangeListener*>(this)); 576 577 mxController->removeEventListener ( 578 static_cast<awt::XWindowListener*>(this)); 579 } 580 581 // Propagate change of controller down the shape tree. 582 maShapeTreeInfo.SetControllerBroadcaster (NULL); 583 584 // Reset the model reference. 585 mxModel = NULL; 586 // Reset the model reference. 587 mxController = NULL; 588 589 maShapeTreeInfo.SetDocumentWindow (NULL); 590 } 591 592 593 594 595 //===== XEventListener ====================================================== 596 597 void SAL_CALL 598 AccessibleDocumentViewBase::disposing (const lang::EventObject& rEventObject) 599 throw (::com::sun::star::uno::RuntimeException) 600 { 601 ThrowIfDisposed (); 602 603 // Register this object as dispose event and document::XEventListener 604 // listener at the model. 605 606 if ( ! rEventObject.Source.is()) 607 { 608 // Paranoia. Can this really happen? 609 } 610 else if (rEventObject.Source == mxModel || rEventObject.Source == mxController) 611 { 612 impl_dispose(); 613 } 614 } 615 616 //===== XPropertyChangeListener ============================================= 617 618 void SAL_CALL AccessibleDocumentViewBase::propertyChange (const beans::PropertyChangeEvent& ) 619 throw (::com::sun::star::uno::RuntimeException) 620 { 621 // Empty 622 } 623 624 625 626 627 //===== XWindowListener ===================================================== 628 629 void SAL_CALL 630 AccessibleDocumentViewBase::windowResized (const ::com::sun::star::awt::WindowEvent& ) 631 throw (::com::sun::star::uno::RuntimeException) 632 { 633 if( IsDisposed() ) 634 return; 635 636 ViewForwarderChanged ( 637 IAccessibleViewForwarderListener::VISIBLE_AREA, 638 &maViewForwarder); 639 } 640 641 642 643 644 void SAL_CALL 645 AccessibleDocumentViewBase::windowMoved (const ::com::sun::star::awt::WindowEvent& ) 646 throw (::com::sun::star::uno::RuntimeException) 647 { 648 if( IsDisposed() ) 649 return; 650 651 ViewForwarderChanged ( 652 IAccessibleViewForwarderListener::VISIBLE_AREA, 653 &maViewForwarder); 654 } 655 656 657 658 659 void SAL_CALL 660 AccessibleDocumentViewBase::windowShown (const ::com::sun::star::lang::EventObject& ) 661 throw (::com::sun::star::uno::RuntimeException) 662 { 663 if( IsDisposed() ) 664 return; 665 666 ViewForwarderChanged ( 667 IAccessibleViewForwarderListener::VISIBLE_AREA, 668 &maViewForwarder); 669 } 670 671 672 673 674 void SAL_CALL 675 AccessibleDocumentViewBase::windowHidden (const ::com::sun::star::lang::EventObject& ) 676 throw (::com::sun::star::uno::RuntimeException) 677 { 678 if( IsDisposed() ) 679 return; 680 681 ViewForwarderChanged ( 682 IAccessibleViewForwarderListener::VISIBLE_AREA, 683 &maViewForwarder); 684 } 685 686 687 688 689 //===== XFocusListener ================================================== 690 691 void AccessibleDocumentViewBase::focusGained (const ::com::sun::star::awt::FocusEvent& e) 692 throw (::com::sun::star::uno::RuntimeException) 693 { 694 ThrowIfDisposed (); 695 if (e.Source == mxWindow) 696 Activated (); 697 } 698 699 void AccessibleDocumentViewBase::focusLost (const ::com::sun::star::awt::FocusEvent& e) 700 throw (::com::sun::star::uno::RuntimeException) 701 { 702 ThrowIfDisposed (); 703 if (e.Source == mxWindow) 704 Deactivated (); 705 } 706 707 708 709 710 //===== protected internal ================================================== 711 712 // This method is called from the component helper base class while disposing. 713 void SAL_CALL AccessibleDocumentViewBase::disposing (void) 714 { 715 impl_dispose(); 716 717 AccessibleContextBase::disposing (); 718 } 719 720 721 722 723 /// Create a name for this view. 724 ::rtl::OUString 725 AccessibleDocumentViewBase::CreateAccessibleName (void) 726 throw (::com::sun::star::uno::RuntimeException) 727 { 728 return ::rtl::OUString ( 729 RTL_CONSTASCII_USTRINGPARAM("AccessibleDocumentViewBase")); 730 } 731 732 733 734 735 /** Create a description for this view. Use the model's description or URL 736 if a description is not available. 737 */ 738 ::rtl::OUString 739 AccessibleDocumentViewBase::CreateAccessibleDescription (void) 740 throw (::com::sun::star::uno::RuntimeException) 741 { 742 rtl::OUString sDescription; 743 744 uno::Reference<lang::XServiceInfo> xInfo (mxController, uno::UNO_QUERY); 745 if (xInfo.is()) 746 { 747 OUString sFirstService = xInfo->getSupportedServiceNames()[0]; 748 if (sFirstService == OUString ( 749 RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.DrawingDocumentDrawView"))) 750 { 751 sDescription = OUString (RTL_CONSTASCII_USTRINGPARAM("Draw Document")); 752 } 753 else 754 sDescription = sFirstService; 755 } 756 else 757 sDescription = OUString ( 758 RTL_CONSTASCII_USTRINGPARAM("Accessible Draw Document")); 759 return sDescription; 760 } 761 762 763 764 765 void AccessibleDocumentViewBase::Activated (void) 766 { 767 // Empty. Overwrite to do something usefull. 768 } 769 770 771 772 773 void AccessibleDocumentViewBase::Deactivated (void) 774 { 775 // Empty. Overwrite to do something usefull. 776 } 777 778 779 780 781 void AccessibleDocumentViewBase::SetAccessibleOLEObject ( 782 const Reference <XAccessible>& xOLEObject) 783 { 784 // Send child event about removed accessible OLE object if necessary. 785 if (mxAccessibleOLEObject != xOLEObject) 786 if (mxAccessibleOLEObject.is()) 787 CommitChange ( 788 AccessibleEventId::CHILD, 789 uno::Any(), 790 uno::makeAny (mxAccessibleOLEObject)); 791 792 // Assume that the accessible OLE Object disposes itself correctly. 793 794 { 795 ::osl::MutexGuard aGuard (maMutex); 796 mxAccessibleOLEObject = xOLEObject; 797 } 798 799 // Send child event about new accessible OLE object if necessary. 800 if (mxAccessibleOLEObject.is()) 801 CommitChange ( 802 AccessibleEventId::CHILD, 803 uno::makeAny (mxAccessibleOLEObject), 804 uno::Any()); 805 } 806 807 808 809 810 //===== methods from AccessibleSelectionBase ================================================== 811 812 // return the member maMutex; 813 ::osl::Mutex& 814 AccessibleDocumentViewBase::implGetMutex() 815 { 816 return( maMutex ); 817 } 818 819 // return ourself as context in default case 820 uno::Reference< XAccessibleContext > 821 AccessibleDocumentViewBase::implGetAccessibleContext() 822 throw (uno::RuntimeException) 823 { 824 return( this ); 825 } 826 827 // return sal_False in default case 828 sal_Bool 829 AccessibleDocumentViewBase::implIsSelected( sal_Int32 ) 830 throw (uno::RuntimeException) 831 { 832 return( sal_False ); 833 } 834 835 // return nothing in default case 836 void 837 AccessibleDocumentViewBase::implSelect( sal_Int32, sal_Bool ) 838 throw (lang::IndexOutOfBoundsException, uno::RuntimeException) 839 { 840 } 841 842 } // end of namespace accessibility 843