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

Generated by: LCOV version 1.10