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

Generated by: LCOV version 1.10