LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleDocumentViewBase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 118 265 44.5 %
Date: 2012-08-25 Functions: 17 40 42.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 102 406 25.1 %

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

Generated by: LCOV version 1.10