LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/accessibility - AccessibleDocumentViewBase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 265 0.0 %
Date: 2012-12-27 Functions: 0 40 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10