LCOV - code coverage report
Current view: top level - sd/source/ui/accessibility - AccessibleSlideSorterObject.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 189 0.0 %
Date: 2014-04-11 Functions: 0 35 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             : 
      21             : #include "AccessibleSlideSorterObject.hxx"
      22             : 
      23             : #include "SlideSorter.hxx"
      24             : #include "controller/SlideSorterController.hxx"
      25             : #include "controller/SlsPageSelector.hxx"
      26             : #include "controller/SlsFocusManager.hxx"
      27             : #include "model/SlideSorterModel.hxx"
      28             : #include "model/SlsPageDescriptor.hxx"
      29             : #include "view/SlideSorterView.hxx"
      30             : #include "view/SlsLayouter.hxx"
      31             : #include "view/SlsPageObjectLayouter.hxx"
      32             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      33             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      34             : #include <comphelper/accessibleeventnotifier.hxx>
      35             : #include <cppuhelper/supportsservice.hxx>
      36             : #include <unotools/accessiblestatesethelper.hxx>
      37             : 
      38             : #include "sdpage.hxx"
      39             : #include "sdresid.hxx"
      40             : #include <vcl/svapp.hxx>
      41             : #include <vcl/settings.hxx>
      42             : 
      43             : #include "glob.hrc"
      44             : 
      45             : using namespace ::com::sun::star;
      46             : using namespace ::com::sun::star::uno;
      47             : using namespace ::com::sun::star::accessibility;
      48             : 
      49             : 
      50             : namespace accessibility {
      51             : 
      52             : 
      53           0 : AccessibleSlideSorterObject::AccessibleSlideSorterObject(
      54             :     const Reference<XAccessible>& rxParent,
      55             :     ::sd::slidesorter::SlideSorter& rSlideSorter,
      56             :     sal_uInt16 nPageNumber)
      57             :     : AccessibleSlideSorterObjectBase(::sd::MutexOwner::maMutex),
      58             :       mxParent(rxParent),
      59             :       mnPageNumber(nPageNumber),
      60             :       mrSlideSorter(rSlideSorter),
      61           0 :       mnClientId(0)
      62             : {
      63           0 : }
      64             : 
      65             : 
      66             : 
      67             : 
      68           0 : AccessibleSlideSorterObject::~AccessibleSlideSorterObject (void)
      69             : {
      70           0 :     if ( ! IsDisposed())
      71           0 :         dispose();
      72           0 : }
      73             : 
      74             : 
      75             : 
      76             : 
      77           0 : sal_uInt16 AccessibleSlideSorterObject::GetPageNumber (void) const
      78             : {
      79           0 :     return mnPageNumber;
      80             : }
      81             : 
      82             : 
      83             : 
      84             : 
      85           0 : void AccessibleSlideSorterObject::FireAccessibleEvent (
      86             :     short nEventId,
      87             :     const uno::Any& rOldValue,
      88             :     const uno::Any& rNewValue)
      89             : {
      90           0 :     if (mnClientId != 0)
      91             :     {
      92           0 :         AccessibleEventObject aEventObject;
      93             : 
      94           0 :         aEventObject.Source = Reference<XWeak>(this);
      95           0 :         aEventObject.EventId = nEventId;
      96           0 :         aEventObject.NewValue = rNewValue;
      97           0 :         aEventObject.OldValue = rOldValue;
      98             : 
      99           0 :         comphelper::AccessibleEventNotifier::addEvent(mnClientId, aEventObject);
     100             :     }
     101           0 : }
     102             : 
     103             : 
     104             : 
     105             : 
     106           0 : void SAL_CALL AccessibleSlideSorterObject::disposing (void)
     107             : {
     108           0 :     const SolarMutexGuard aSolarGuard;
     109             : 
     110             :     // Send a disposing to all listeners.
     111           0 :     if (mnClientId != 0)
     112             :     {
     113           0 :         comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(mnClientId, *this);
     114           0 :         mnClientId =  0;
     115           0 :     }
     116           0 : }
     117             : 
     118             : 
     119             : 
     120             : //===== XAccessible ===========================================================
     121             : 
     122             : Reference<XAccessibleContext> SAL_CALL
     123           0 :     AccessibleSlideSorterObject::getAccessibleContext (void)
     124             :     throw (uno::RuntimeException, std::exception)
     125             : {
     126           0 :     ThrowIfDisposed();
     127           0 :     return this;
     128             : }
     129             : 
     130             : 
     131             : 
     132             : //===== XAccessibleContext ====================================================
     133             : 
     134           0 : sal_Int32 SAL_CALL AccessibleSlideSorterObject::getAccessibleChildCount (void)
     135             :     throw (uno::RuntimeException, std::exception)
     136             : {
     137           0 :     ThrowIfDisposed();
     138           0 :     return 0;
     139             : }
     140             : 
     141             : 
     142             : 
     143             : 
     144           0 : Reference<XAccessible> SAL_CALL AccessibleSlideSorterObject::getAccessibleChild (sal_Int32 )
     145             :     throw (lang::IndexOutOfBoundsException, RuntimeException, std::exception)
     146             : {
     147           0 :     ThrowIfDisposed();
     148           0 :     throw lang::IndexOutOfBoundsException();
     149             : }
     150             : 
     151             : 
     152             : 
     153             : 
     154           0 : Reference<XAccessible> SAL_CALL AccessibleSlideSorterObject::getAccessibleParent (void)
     155             :     throw (uno::RuntimeException, std::exception)
     156             : {
     157           0 :     ThrowIfDisposed();
     158           0 :     return mxParent;
     159             : }
     160             : 
     161             : 
     162             : 
     163             : 
     164           0 : sal_Int32 SAL_CALL AccessibleSlideSorterObject::getAccessibleIndexInParent()
     165             :     throw (uno::RuntimeException, std::exception)
     166             : {
     167           0 :     ThrowIfDisposed();
     168           0 :     const SolarMutexGuard aSolarGuard;
     169           0 :     sal_Int32 nIndexInParent(-1);
     170             : 
     171           0 :     if (mxParent.is())
     172             :     {
     173           0 :         Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext());
     174           0 :         if (xParentContext.is())
     175             :         {
     176           0 :             sal_Int32 nChildCount (xParentContext->getAccessibleChildCount());
     177           0 :             for (sal_Int32 i=0; i<nChildCount; ++i)
     178           0 :                 if (xParentContext->getAccessibleChild(i).get()
     179           0 :                     == static_cast<XAccessible*>(this))
     180             :                 {
     181           0 :                     nIndexInParent = i;
     182           0 :                     break;
     183             :                 }
     184           0 :         }
     185             :     }
     186             : 
     187           0 :     return nIndexInParent;
     188             : }
     189             : 
     190             : 
     191             : 
     192             : 
     193           0 : sal_Int16 SAL_CALL AccessibleSlideSorterObject::getAccessibleRole (void)
     194             :     throw (uno::RuntimeException, std::exception)
     195             : {
     196           0 :     ThrowIfDisposed();
     197             :     //set Role = Shape
     198             :     //static sal_Int16 nRole = AccessibleRole::LIST_ITEM;
     199             :     static sal_Int16 nRole = AccessibleRole::SHAPE;
     200           0 :     return nRole;
     201             : }
     202             : 
     203             : 
     204             : 
     205             : 
     206           0 : OUString SAL_CALL AccessibleSlideSorterObject::getAccessibleDescription (void)
     207             :     throw (uno::RuntimeException, std::exception)
     208             : {
     209           0 :     ThrowIfDisposed();
     210           0 :     return SD_RESSTR(STR_PAGE);
     211             : }
     212             : 
     213             : 
     214             : 
     215             : 
     216           0 : OUString SAL_CALL AccessibleSlideSorterObject::getAccessibleName (void)
     217             :     throw (uno::RuntimeException, std::exception)
     218             : {
     219           0 :     ThrowIfDisposed();
     220           0 :     const SolarMutexGuard aSolarGuard;
     221             : 
     222           0 :     SdPage* pPage = GetPage();
     223           0 :     if (pPage != NULL)
     224           0 :         return pPage->GetName();
     225             :     else
     226           0 :         return OUString();
     227             : }
     228             : 
     229             : 
     230             : 
     231             : 
     232             : Reference<XAccessibleRelationSet> SAL_CALL
     233           0 :     AccessibleSlideSorterObject::getAccessibleRelationSet (void)
     234             :     throw (uno::RuntimeException, std::exception)
     235             : {
     236           0 :     ThrowIfDisposed();
     237           0 :     return Reference<XAccessibleRelationSet>();
     238             : }
     239             : 
     240             : 
     241             : 
     242             : 
     243             : Reference<XAccessibleStateSet> SAL_CALL
     244           0 :     AccessibleSlideSorterObject::getAccessibleStateSet (void)
     245             :     throw (uno::RuntimeException, std::exception)
     246             : {
     247           0 :     ThrowIfDisposed();
     248           0 :     const SolarMutexGuard aSolarGuard;
     249           0 :     ::utl::AccessibleStateSetHelper* pStateSet = new ::utl::AccessibleStateSetHelper();
     250             : 
     251           0 :     if (mxParent.is())
     252             :     {
     253             :         // Unconditional states.
     254           0 :         pStateSet->AddState(AccessibleStateType::SELECTABLE);
     255           0 :         pStateSet->AddState(AccessibleStateType::FOCUSABLE);
     256           0 :         pStateSet->AddState(AccessibleStateType::ENABLED);
     257           0 :         pStateSet->AddState(AccessibleStateType::VISIBLE);
     258           0 :         pStateSet->AddState(AccessibleStateType::SHOWING);
     259           0 :         pStateSet->AddState(AccessibleStateType::ACTIVE);
     260           0 :         pStateSet->AddState(AccessibleStateType::SENSITIVE);
     261             : 
     262             :         // Conditional states.
     263           0 :         if (mrSlideSorter.GetController().GetPageSelector().IsPageSelected(mnPageNumber))
     264           0 :             pStateSet->AddState(AccessibleStateType::SELECTED);
     265           0 :         if (mrSlideSorter.GetController().GetFocusManager().GetFocusedPageIndex() == mnPageNumber)
     266           0 :             if (mrSlideSorter.GetController().GetFocusManager().IsFocusShowing())
     267           0 :                 pStateSet->AddState(AccessibleStateType::FOCUSED);
     268             :     }
     269             : 
     270           0 :     return pStateSet;
     271             : }
     272             : 
     273             : 
     274             : 
     275             : 
     276           0 : lang::Locale SAL_CALL AccessibleSlideSorterObject::getLocale (void)
     277             :     throw (IllegalAccessibleComponentStateException,
     278             :         RuntimeException, std::exception)
     279             : {
     280           0 :     ThrowIfDisposed();
     281             :     // Delegate request to parent.
     282           0 :     if (mxParent.is())
     283             :     {
     284           0 :         Reference<XAccessibleContext> xParentContext (mxParent->getAccessibleContext());
     285           0 :         if (xParentContext.is())
     286           0 :             return xParentContext->getLocale ();
     287             :     }
     288             : 
     289             :     //  No locale and no parent.  Therefore throw exception to indicate this
     290             :     //  cluelessness.
     291           0 :     throw IllegalAccessibleComponentStateException();
     292             : }
     293             : 
     294             : 
     295             : 
     296             : 
     297             : 
     298             : //===== XAccessibleEventBroadcaster ===========================================
     299             : 
     300           0 : void SAL_CALL AccessibleSlideSorterObject::addAccessibleEventListener(
     301             :     const Reference<XAccessibleEventListener>& rxListener)
     302             :     throw (RuntimeException, std::exception)
     303             : {
     304           0 :     if (rxListener.is())
     305             :     {
     306           0 :         const osl::MutexGuard aGuard(maMutex);
     307             : 
     308           0 :         if (IsDisposed())
     309             :         {
     310           0 :             uno::Reference<uno::XInterface> x ((lang::XComponent *)this, uno::UNO_QUERY);
     311           0 :             rxListener->disposing (lang::EventObject (x));
     312             :         }
     313             :         else
     314             :         {
     315           0 :             if (mnClientId == 0)
     316           0 :                 mnClientId = comphelper::AccessibleEventNotifier::registerClient();
     317           0 :             comphelper::AccessibleEventNotifier::addEventListener(mnClientId, rxListener);
     318           0 :         }
     319             :     }
     320           0 : }
     321             : 
     322             : 
     323             : 
     324             : 
     325           0 : void SAL_CALL AccessibleSlideSorterObject::removeAccessibleEventListener(
     326             :     const Reference<XAccessibleEventListener>& rxListener)
     327             :     throw (uno::RuntimeException, std::exception)
     328             : {
     329           0 :     ThrowIfDisposed();
     330           0 :     if (rxListener.is())
     331             :     {
     332           0 :         const osl::MutexGuard aGuard(maMutex);
     333             : 
     334           0 :         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
     335           0 :         if ( !nListenerCount )
     336             :         {
     337             :             // no listeners anymore
     338             :             // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     339             :             // and at least to us not firing any events anymore, in case somebody calls
     340             :             // NotifyAccessibleEvent, again
     341           0 :             comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
     342           0 :             mnClientId = 0;
     343           0 :         }
     344             :     }
     345           0 : }
     346             : 
     347             : 
     348             : 
     349             : 
     350             : //===== XAccessibleComponent ==================================================
     351             : 
     352           0 : sal_Bool SAL_CALL AccessibleSlideSorterObject::containsPoint(const awt::Point& aPoint)
     353             :     throw (uno::RuntimeException, std::exception)
     354             : {
     355           0 :     ThrowIfDisposed();
     356           0 :     const awt::Size aSize (getSize());
     357           0 :     return (aPoint.X >= 0)
     358           0 :         && (aPoint.X < aSize.Width)
     359           0 :         && (aPoint.Y >= 0)
     360           0 :         && (aPoint.Y < aSize.Height);
     361             : }
     362             : 
     363             : 
     364             : 
     365             : 
     366             : Reference<XAccessible> SAL_CALL
     367           0 :     AccessibleSlideSorterObject::getAccessibleAtPoint(const awt::Point& )
     368             :     throw (uno::RuntimeException, std::exception)
     369             : {
     370           0 :     return NULL;
     371             : }
     372             : 
     373             : 
     374             : 
     375             : 
     376           0 : awt::Rectangle SAL_CALL AccessibleSlideSorterObject::getBounds (void)
     377             :     throw (RuntimeException, std::exception)
     378             : {
     379           0 :     ThrowIfDisposed ();
     380             : 
     381           0 :     const SolarMutexGuard aSolarGuard;
     382             : 
     383             :     Rectangle aBBox (
     384           0 :         mrSlideSorter.GetView().GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
     385           0 :             mrSlideSorter.GetModel().GetPageDescriptor(mnPageNumber),
     386             :             ::sd::slidesorter::view::PageObjectLayouter::PageObject,
     387           0 :             ::sd::slidesorter::view::PageObjectLayouter::WindowCoordinateSystem));
     388             : 
     389           0 :     if (mxParent.is())
     390             :     {
     391           0 :         Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(), UNO_QUERY);
     392           0 :         if (xParentComponent.is())
     393             :         {
     394           0 :             awt::Rectangle aParentBBox (xParentComponent->getBounds());
     395             :             aBBox.Intersection(Rectangle(
     396             :                 aParentBBox.X,
     397             :                 aParentBBox.Y,
     398             :                 aParentBBox.Width,
     399           0 :                 aParentBBox.Height));
     400           0 :         }
     401             :     }
     402             : 
     403             :     return awt::Rectangle(
     404           0 :         aBBox.Left(),
     405           0 :         aBBox.Top(),
     406           0 :         aBBox.GetWidth(),
     407           0 :         aBBox.GetHeight());
     408             : }
     409             : 
     410             : 
     411             : 
     412             : 
     413           0 : awt::Point SAL_CALL AccessibleSlideSorterObject::getLocation ()
     414             :     throw (RuntimeException, std::exception)
     415             : {
     416           0 :     ThrowIfDisposed ();
     417           0 :     const awt::Rectangle aBBox (getBounds());
     418           0 :     return awt::Point(aBBox.X, aBBox.Y);
     419             : }
     420             : 
     421             : 
     422             : 
     423             : 
     424           0 : awt::Point SAL_CALL AccessibleSlideSorterObject::getLocationOnScreen (void)
     425             :     throw (RuntimeException, std::exception)
     426             : {
     427           0 :     ThrowIfDisposed ();
     428             : 
     429           0 :     const SolarMutexGuard aSolarGuard;
     430             : 
     431           0 :     awt::Point aLocation (getLocation());
     432             : 
     433           0 :     if (mxParent.is())
     434             :     {
     435           0 :         Reference<XAccessibleComponent> xParentComponent(mxParent->getAccessibleContext(),UNO_QUERY);
     436           0 :         if (xParentComponent.is())
     437             :         {
     438           0 :             const awt::Point aParentLocationOnScreen(xParentComponent->getLocationOnScreen());
     439           0 :             aLocation.X += aParentLocationOnScreen.X;
     440           0 :             aLocation.Y += aParentLocationOnScreen.Y;
     441           0 :         }
     442             :     }
     443             : 
     444           0 :     return aLocation;
     445             : }
     446             : 
     447             : 
     448             : 
     449             : 
     450           0 : awt::Size SAL_CALL AccessibleSlideSorterObject::getSize (void)
     451             :     throw (RuntimeException, std::exception)
     452             : {
     453           0 :     ThrowIfDisposed ();
     454           0 :     const awt::Rectangle aBBox (getBounds());
     455           0 :     return awt::Size(aBBox.Width,aBBox.Height);
     456             : }
     457             : 
     458             : 
     459             : 
     460             : 
     461           0 : void SAL_CALL AccessibleSlideSorterObject::grabFocus (void)
     462             :     throw (RuntimeException, std::exception)
     463             : {
     464             :     // nothing to do
     465           0 : }
     466             : 
     467             : 
     468             : 
     469             : 
     470           0 : sal_Int32 SAL_CALL AccessibleSlideSorterObject::getForeground (void)
     471             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     472             : {
     473           0 :     ThrowIfDisposed ();
     474           0 :     svtools::ColorConfig aColorConfig;
     475           0 :     sal_uInt32 nColor = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
     476           0 :     return static_cast<sal_Int32>(nColor);
     477             : }
     478             : 
     479             : 
     480             : 
     481             : 
     482           0 : sal_Int32 SAL_CALL AccessibleSlideSorterObject::getBackground (void)
     483             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     484             : {
     485           0 :     ThrowIfDisposed ();
     486           0 :     sal_uInt32 nColor = Application::GetSettings().GetStyleSettings().GetWindowColor().GetColor();
     487           0 :     return static_cast<sal_Int32>(nColor);
     488             : }
     489             : 
     490             : //=====  XServiceInfo  ========================================================
     491             : OUString SAL_CALL
     492           0 :        AccessibleSlideSorterObject::getImplementationName (void)
     493             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     494             : {
     495           0 :     return OUString("AccessibleSlideSorterObject");
     496             : }
     497             : 
     498           0 : sal_Bool SAL_CALL AccessibleSlideSorterObject::supportsService (const OUString& sServiceName)
     499             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     500             : {
     501           0 :     return cppu::supportsService(this, sServiceName);
     502             : }
     503             : 
     504             : uno::Sequence< OUString> SAL_CALL
     505           0 :        AccessibleSlideSorterObject::getSupportedServiceNames (void)
     506             :     throw (::com::sun::star::uno::RuntimeException, std::exception)
     507             : {
     508           0 :     ThrowIfDisposed ();
     509             : 
     510             :     static const OUString sServiceNames[2] = {
     511             :         OUString("com.sun.star.accessibility.Accessible"),
     512             :         OUString("com.sun.star.accessibility.AccessibleContext")
     513           0 :     };
     514           0 :     return uno::Sequence<OUString> (sServiceNames, 2);
     515             : }
     516             : 
     517           0 : void AccessibleSlideSorterObject::ThrowIfDisposed (void)
     518             :     throw (lang::DisposedException)
     519             : {
     520           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     521             :     {
     522             :         OSL_TRACE ("Calling disposed object. Throwing exception:");
     523             :         throw lang::DisposedException ("object has been already disposed",
     524           0 :             static_cast<uno::XWeak*>(this));
     525             :     }
     526           0 : }
     527             : 
     528             : 
     529             : 
     530           0 : sal_Bool AccessibleSlideSorterObject::IsDisposed (void)
     531             : {
     532           0 :     return (rBHelper.bDisposed || rBHelper.bInDispose);
     533             : }
     534             : 
     535           0 : SdPage* AccessibleSlideSorterObject::GetPage (void) const
     536             : {
     537             :     ::sd::slidesorter::model::SharedPageDescriptor pDescriptor(
     538           0 :         mrSlideSorter.GetModel().GetPageDescriptor(mnPageNumber));
     539           0 :     if (pDescriptor.get() != NULL)
     540           0 :         return pDescriptor->GetPage();
     541             :     else
     542           0 :         return NULL;
     543             : }
     544             : 
     545             : } // end of namespace ::accessibility
     546             : 
     547             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10