LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleDocumentViewBase.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 381 0.0 %
Date: 2014-04-14 Functions: 0 44 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10