LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/editeng/source/accessibility - AccessibleContextBase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 120 202 59.4 %
Date: 2013-07-09 Functions: 19 36 52.8 %
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 <editeng/AccessibleContextBase.hxx>
      21             : 
      22             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      23             : #include <com/sun/star/beans/PropertyChangeEvent.hpp>
      24             : #include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
      25             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      26             : #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
      27             : 
      28             : #include <unotools/accessiblestatesethelper.hxx>
      29             : #include <unotools/accessiblerelationsethelper.hxx>
      30             : #include <comphelper/accessibleeventnotifier.hxx>
      31             : #include <comphelper/servicehelper.hxx>
      32             : #include <osl/mutex.hxx>
      33             : 
      34             : #include <utility>
      35             : 
      36             : using namespace ::com::sun::star;
      37             : using namespace ::com::sun::star::accessibility;
      38             : using ::com::sun::star::uno::Reference;
      39             : 
      40             : namespace accessibility {
      41             : 
      42             : //=====  internal  ============================================================
      43             : 
      44             : // Define a shortcut for the somewhot longish base class name.
      45             : typedef ::cppu::PartialWeakComponentImplHelper4<
      46             :     ::com::sun::star::accessibility::XAccessible,
      47             :     ::com::sun::star::accessibility::XAccessibleContext,
      48             :     ::com::sun::star::accessibility::XAccessibleEventBroadcaster,
      49             :     ::com::sun::star::lang::XServiceInfo> BaseClass;
      50             : 
      51          14 : AccessibleContextBase::AccessibleContextBase (
      52             :         const uno::Reference<XAccessible>& rxParent,
      53             :         const sal_Int16 aRole)
      54             :     :   BaseClass (MutexOwner::maMutex),
      55             :         mxStateSet (NULL),
      56             :         mxRelationSet (NULL),
      57             :         mxParent(rxParent),
      58             :         msDescription(),
      59             :         meDescriptionOrigin(NotSet),
      60             :         msName(),
      61             :         meNameOrigin(NotSet),
      62             :         mnClientId(0),
      63          14 :         maRole(aRole)
      64             : {
      65             :     // Create the state set.
      66          14 :     ::utl::AccessibleStateSetHelper* pStateSet  = new ::utl::AccessibleStateSetHelper ();
      67          14 :     mxStateSet = pStateSet;
      68             : 
      69             :     // Set some states.  Don't use the SetState method because no events
      70             :     // shall be broadcastet (that is not yet initialized anyway).
      71          14 :     if (pStateSet != NULL)
      72             :     {
      73          14 :         pStateSet->AddState (AccessibleStateType::ENABLED);
      74          14 :         pStateSet->AddState (AccessibleStateType::SENSITIVE);
      75          14 :         pStateSet->AddState (AccessibleStateType::SHOWING);
      76          14 :         pStateSet->AddState (AccessibleStateType::VISIBLE);
      77          14 :         pStateSet->AddState (AccessibleStateType::FOCUSABLE);
      78          14 :         pStateSet->AddState (AccessibleStateType::SELECTABLE);
      79             :     }
      80             : 
      81             :     // Create the relation set.
      82          14 :     ::utl::AccessibleRelationSetHelper* pRelationSet = new ::utl::AccessibleRelationSetHelper ();
      83          14 :     mxRelationSet = pRelationSet;
      84          14 : }
      85             : 
      86             : 
      87             : 
      88             : 
      89          14 : AccessibleContextBase::~AccessibleContextBase(void)
      90             : {
      91          14 : }
      92             : 
      93             : 
      94             : 
      95             : 
      96          21 : sal_Bool AccessibleContextBase::SetState (sal_Int16 aState)
      97             : {
      98          21 :     ::osl::ClearableMutexGuard aGuard (maMutex);
      99             :     ::utl::AccessibleStateSetHelper* pStateSet =
     100          21 :         static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     101          21 :     if ((pStateSet != NULL) && !pStateSet->contains(aState))
     102             :     {
     103           4 :         pStateSet->AddState (aState);
     104             :         // Clear the mutex guard so that it is not locked during calls to
     105             :         // listeners.
     106           4 :         aGuard.clear();
     107             : 
     108             :         // Send event for all states except the DEFUNC state.
     109           4 :         if (aState != AccessibleStateType::DEFUNC)
     110             :         {
     111           1 :             uno::Any aNewValue;
     112           1 :             aNewValue <<= aState;
     113             :             CommitChange(
     114             :                 AccessibleEventId::STATE_CHANGED,
     115             :                 aNewValue,
     116           1 :                 uno::Any());
     117             :         }
     118           4 :         return sal_True;
     119             :     }
     120             :     else
     121          17 :         return sal_False;
     122             : }
     123             : 
     124             : 
     125             : 
     126             : 
     127           0 : sal_Bool AccessibleContextBase::ResetState (sal_Int16 aState)
     128             : {
     129           0 :     ::osl::ClearableMutexGuard aGuard (maMutex);
     130             :     ::utl::AccessibleStateSetHelper* pStateSet =
     131           0 :         static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     132           0 :     if ((pStateSet != NULL) && pStateSet->contains(aState))
     133             :     {
     134           0 :         pStateSet->RemoveState (aState);
     135             :         // Clear the mutex guard so that it is not locked during calls to listeners.
     136           0 :         aGuard.clear();
     137             : 
     138           0 :         uno::Any aOldValue;
     139           0 :         aOldValue <<= aState;
     140             :         CommitChange(
     141             :             AccessibleEventId::STATE_CHANGED,
     142             :             uno::Any(),
     143           0 :             aOldValue);
     144           0 :         return sal_True;
     145             :     }
     146             :     else
     147           0 :         return sal_False;
     148             : }
     149             : 
     150             : 
     151             : 
     152             : 
     153           0 : sal_Bool AccessibleContextBase::GetState (sal_Int16 aState)
     154             : {
     155           0 :     ::osl::MutexGuard aGuard (maMutex);
     156             :     ::utl::AccessibleStateSetHelper* pStateSet =
     157           0 :         static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     158           0 :     if (pStateSet != NULL)
     159           0 :         return pStateSet->contains(aState);
     160             :     else
     161             :         // If there is no state set then return false as a default value.
     162           0 :         return sal_False;
     163             : }
     164             : 
     165             : 
     166             : 
     167             : 
     168           0 : void AccessibleContextBase::SetRelationSet (
     169             :     const uno::Reference<XAccessibleRelationSet>& rxNewRelationSet)
     170             :     throw (::com::sun::star::uno::RuntimeException)
     171             : {
     172             :     OSL_TRACE ("setting relation set");
     173             : 
     174             :     // Try to emit some meaningfull events indicating differing relations in
     175             :     // both sets.
     176             :     typedef std::pair<short int,short int> RD;
     177             :     const RD aRelationDescriptors[] = {
     178             :         RD(AccessibleRelationType::CONTROLLED_BY, AccessibleEventId::CONTROLLED_BY_RELATION_CHANGED),
     179             :         RD(AccessibleRelationType::CONTROLLER_FOR, AccessibleEventId::CONTROLLER_FOR_RELATION_CHANGED),
     180             :         RD(AccessibleRelationType::LABELED_BY, AccessibleEventId::LABELED_BY_RELATION_CHANGED),
     181             :         RD(AccessibleRelationType::LABEL_FOR, AccessibleEventId::LABEL_FOR_RELATION_CHANGED),
     182             :         RD(AccessibleRelationType::MEMBER_OF, AccessibleEventId::MEMBER_OF_RELATION_CHANGED),
     183             :         RD(AccessibleRelationType::INVALID, -1),
     184           0 :     };
     185           0 :     for (int i=0; aRelationDescriptors[i].first!=AccessibleRelationType::INVALID; i++)
     186           0 :         if (mxRelationSet->containsRelation(aRelationDescriptors[i].first)
     187           0 :         != rxNewRelationSet->containsRelation(aRelationDescriptors[i].first))
     188           0 :         CommitChange (aRelationDescriptors[i].second, uno::Any(), uno::Any());
     189             : 
     190           0 :     mxRelationSet = rxNewRelationSet;
     191           0 : }
     192             : 
     193             : 
     194             : 
     195             : 
     196             : //=====  XAccessible  =========================================================
     197             : 
     198             : uno::Reference< XAccessibleContext> SAL_CALL
     199          40 :     AccessibleContextBase::getAccessibleContext (void)
     200             :     throw (uno::RuntimeException)
     201             : {
     202          40 :     ThrowIfDisposed ();
     203          40 :     return this;
     204             : }
     205             : 
     206             : 
     207             : 
     208             : 
     209             : //=====  XAccessibleContext  ==================================================
     210             : 
     211             : /** No children.
     212             : */
     213             : sal_Int32 SAL_CALL
     214           0 :        AccessibleContextBase::getAccessibleChildCount (void)
     215             :     throw (uno::RuntimeException)
     216             : {
     217           0 :     ThrowIfDisposed ();
     218           0 :     return 0;
     219             : }
     220             : 
     221             : 
     222             : 
     223             : 
     224             : /** Forward the request to the shape.  Return the requested shape or throw
     225             :     an exception for a wrong index.
     226             : */
     227             : uno::Reference<XAccessible> SAL_CALL
     228           0 :     AccessibleContextBase::getAccessibleChild (sal_Int32 nIndex)
     229             :     throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException)
     230             : {
     231           0 :     ThrowIfDisposed ();
     232             :     throw lang::IndexOutOfBoundsException (
     233           0 :         "no child with index " + OUString(nIndex),
     234           0 :         NULL);
     235             : }
     236             : 
     237             : 
     238             : 
     239             : 
     240             : uno::Reference<XAccessible> SAL_CALL
     241         266 :        AccessibleContextBase::getAccessibleParent (void)
     242             :     throw (::com::sun::star::uno::RuntimeException)
     243             : {
     244         266 :     ThrowIfDisposed ();
     245         266 :     return mxParent;
     246             : }
     247             : 
     248             : 
     249             : 
     250             : 
     251             : sal_Int32 SAL_CALL
     252           1 :        AccessibleContextBase::getAccessibleIndexInParent (void)
     253             :     throw (::com::sun::star::uno::RuntimeException)
     254             : {
     255           1 :     ThrowIfDisposed ();
     256             :     //  Use a simple but slow solution for now.  Optimize later.
     257             : 
     258             :     //  Iterate over all the parent's children and search for this object.
     259           1 :     if (mxParent.is())
     260             :     {
     261             :         uno::Reference<XAccessibleContext> xParentContext (
     262           1 :             mxParent->getAccessibleContext());
     263           1 :         if (xParentContext.is())
     264             :         {
     265           1 :             sal_Int32 nChildCount = xParentContext->getAccessibleChildCount();
     266           1 :             for (sal_Int32 i=0; i<nChildCount; i++)
     267             :             {
     268           1 :                 uno::Reference<XAccessible> xChild (xParentContext->getAccessibleChild (i));
     269           1 :                 if (xChild.is())
     270             :                 {
     271           1 :                     uno::Reference<XAccessibleContext> xChildContext = xChild->getAccessibleContext();
     272           1 :                     if (xChildContext == (XAccessibleContext*)this)
     273           1 :                         return i;
     274             :                 }
     275           0 :             }
     276           0 :         }
     277             :    }
     278             : 
     279             :    //   Return -1 to indicate that this object's parent does not know about the
     280             :    //   object.
     281           0 :    return -1;
     282             : }
     283             : 
     284             : 
     285             : 
     286             : 
     287             : sal_Int16 SAL_CALL
     288          17 :     AccessibleContextBase::getAccessibleRole (void)
     289             :     throw (::com::sun::star::uno::RuntimeException)
     290             : {
     291          17 :     ThrowIfDisposed ();
     292          17 :     return maRole;
     293             : }
     294             : 
     295             : 
     296             : 
     297             : 
     298             : OUString SAL_CALL
     299          14 :        AccessibleContextBase::getAccessibleDescription (void)
     300             :     throw (::com::sun::star::uno::RuntimeException)
     301             : {
     302          14 :     ThrowIfDisposed ();
     303             : 
     304          14 :     return msDescription;
     305             : }
     306             : 
     307             : 
     308             : 
     309             : 
     310             : OUString SAL_CALL
     311          17 :        AccessibleContextBase::getAccessibleName (void)
     312             :     throw (::com::sun::star::uno::RuntimeException)
     313             : {
     314          17 :     ThrowIfDisposed ();
     315             : 
     316          17 :     if (meNameOrigin == NotSet)
     317             :     {
     318             :         // Do not send an event because this is the first time it has been
     319             :         // requested.
     320           4 :         msName = CreateAccessibleName();
     321           4 :         meNameOrigin = AutomaticallyCreated;
     322             :     }
     323             : 
     324          17 :     return msName;
     325             : }
     326             : 
     327             : 
     328             : 
     329             : 
     330             : /** Return a copy of the relation set.
     331             : */
     332             : uno::Reference<XAccessibleRelationSet> SAL_CALL
     333           2 :        AccessibleContextBase::getAccessibleRelationSet (void)
     334             :     throw (::com::sun::star::uno::RuntimeException)
     335             : {
     336           2 :     ThrowIfDisposed ();
     337             : 
     338             :     // Create a copy of the relation set and return it.
     339             :     ::utl::AccessibleRelationSetHelper* pRelationSet =
     340           2 :         static_cast< ::utl::AccessibleRelationSetHelper*>(mxRelationSet.get());
     341           2 :     if (pRelationSet != NULL)
     342             :     {
     343             :         return uno::Reference<XAccessibleRelationSet> (
     344           2 :             new ::utl::AccessibleRelationSetHelper (*pRelationSet));
     345             :     }
     346             :     else
     347           0 :         return uno::Reference<XAccessibleRelationSet>(NULL);
     348             : }
     349             : 
     350             : 
     351             : 
     352             : 
     353             : /** Return a copy of the state set.
     354             :     Possible states are:
     355             :         ENABLED
     356             :         SHOWING
     357             :         VISIBLE
     358             : */
     359             : uno::Reference<XAccessibleStateSet> SAL_CALL
     360           7 :     AccessibleContextBase::getAccessibleStateSet (void)
     361             :     throw (::com::sun::star::uno::RuntimeException)
     362             : {
     363           7 :     ::utl::AccessibleStateSetHelper* pStateSet = NULL;
     364             : 
     365           7 :     if (rBHelper.bDisposed)
     366             :     {
     367             :         // We are already disposed!
     368             :         // Create a new state set that has only set the DEFUNC state.
     369           0 :         pStateSet = new ::utl::AccessibleStateSetHelper ();
     370           0 :         if (pStateSet != NULL)
     371           0 :             pStateSet->AddState (AccessibleStateType::DEFUNC);
     372             :     }
     373             :     else
     374             :     {
     375             :         // Create a copy of the state set and return it.
     376           7 :         pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     377             : 
     378             :         // Merge current focused state from edit engine.
     379             : #if 0
     380             :         if (aState == AccessibleStateType::FOCUSED
     381             :             && pStateSet != NULL
     382             :             && mpText != NULL)
     383             :         {
     384             :             if (mpText->GetFocusedState ())
     385             :                 pStateSet->AddState (aState);
     386             :             else
     387             :                 pStateSet->RemoveState (aState);
     388             :         }
     389             : #endif
     390           7 :         if (pStateSet != NULL)
     391           7 :             pStateSet = new ::utl::AccessibleStateSetHelper (*pStateSet);
     392             :     }
     393             : 
     394           7 :     return uno::Reference<XAccessibleStateSet>(pStateSet);
     395             : }
     396             : 
     397             : 
     398             : 
     399             : 
     400             : lang::Locale SAL_CALL
     401           3 :        AccessibleContextBase::getLocale (void)
     402             :     throw (IllegalAccessibleComponentStateException,
     403             :         ::com::sun::star::uno::RuntimeException)
     404             : {
     405           3 :     ThrowIfDisposed ();
     406             :     // Delegate request to parent.
     407           3 :     if (mxParent.is())
     408             :     {
     409             :         uno::Reference<XAccessibleContext> xParentContext (
     410           3 :             mxParent->getAccessibleContext());
     411           3 :         if (xParentContext.is())
     412           6 :             return xParentContext->getLocale ();
     413             :     }
     414             : 
     415             :     //  No locale and no parent.  Therefore throw exception to indicate this
     416             :     //  cluelessness.
     417           0 :     throw IllegalAccessibleComponentStateException ();
     418             : }
     419             : 
     420             : 
     421             : 
     422             : 
     423             : //=====  XAccessibleEventListener  ============================================
     424             : 
     425           2 : void SAL_CALL AccessibleContextBase::addAccessibleEventListener (
     426             :         const uno::Reference<XAccessibleEventListener >& rxListener)
     427             :     throw (uno::RuntimeException)
     428             : {
     429           2 :     if (rxListener.is())
     430             :     {
     431           2 :         if (rBHelper.bDisposed || rBHelper.bInDispose)
     432             :         {
     433           0 :             uno::Reference<uno::XInterface> x ((lang::XComponent *)this, uno::UNO_QUERY);
     434           0 :             rxListener->disposing (lang::EventObject (x));
     435             :         }
     436             :         else
     437             :         {
     438           2 :             if (!mnClientId)
     439           2 :                 mnClientId = comphelper::AccessibleEventNotifier::registerClient( );
     440           2 :             comphelper::AccessibleEventNotifier::addEventListener( mnClientId, rxListener );
     441             :         }
     442             :     }
     443           2 : }
     444             : 
     445             : 
     446             : 
     447             : 
     448           2 : void SAL_CALL AccessibleContextBase::removeAccessibleEventListener (
     449             :         const uno::Reference<XAccessibleEventListener >& rxListener )
     450             :     throw (uno::RuntimeException)
     451             : {
     452           2 :     ThrowIfDisposed ();
     453           2 :     if (rxListener.is())
     454             :     {
     455           2 :         sal_Int32 nListenerCount = comphelper::AccessibleEventNotifier::removeEventListener( mnClientId, rxListener );
     456           2 :         if ( !nListenerCount )
     457             :         {
     458             :             // no listeners anymore
     459             :             // -> revoke ourself. This may lead to the notifier thread dying (if we were the last client),
     460             :             // and at least to us not firing any events anymore, in case somebody calls
     461             :             // NotifyAccessibleEvent, again
     462           2 :             comphelper::AccessibleEventNotifier::revokeClient( mnClientId );
     463           2 :             mnClientId = 0;
     464             :         }
     465             :     }
     466           2 : }
     467             : 
     468             : 
     469             : 
     470             : 
     471             : //=====  XServiceInfo  ========================================================
     472             : 
     473           0 : OUString SAL_CALL AccessibleContextBase::getImplementationName (void)
     474             :     throw (::com::sun::star::uno::RuntimeException)
     475             : {
     476           0 :     ThrowIfDisposed ();
     477           0 :     return OUString("AccessibleContextBase");
     478             : }
     479             : 
     480             : 
     481             : 
     482             : 
     483             : sal_Bool SAL_CALL
     484           0 :      AccessibleContextBase::supportsService (const OUString& sServiceName)
     485             :     throw (::com::sun::star::uno::RuntimeException)
     486             : {
     487           0 :     ThrowIfDisposed ();
     488             :     //  Iterate over all supported service names and return true if on of them
     489             :     //  matches the given name.
     490             :     uno::Sequence< OUString > aSupportedServices (
     491           0 :         getSupportedServiceNames ());
     492           0 :     for (int i=0; i<aSupportedServices.getLength(); i++)
     493           0 :         if (sServiceName == aSupportedServices[i])
     494           0 :             return sal_True;
     495           0 :     return sal_False;
     496             : }
     497             : 
     498             : 
     499             : 
     500             : 
     501             : uno::Sequence< OUString > SAL_CALL
     502           0 :        AccessibleContextBase::getSupportedServiceNames (void)
     503             :     throw (::com::sun::star::uno::RuntimeException)
     504             : {
     505           0 :     ThrowIfDisposed ();
     506             :     static const OUString sServiceNames[2] = {
     507             :             OUString("com.sun.star.accessibility.Accessible"),
     508             :             OUString("com.sun.star.accessibility.AccessibleContext")
     509           0 :     };
     510           0 :     return uno::Sequence<OUString> (sServiceNames, 2);
     511             : }
     512             : 
     513             : 
     514             : 
     515             : 
     516             : //=====  XTypeProvider  =======================================================
     517             : 
     518             : uno::Sequence< ::com::sun::star::uno::Type>
     519           0 :     AccessibleContextBase::getTypes (void)
     520             :     throw (::com::sun::star::uno::RuntimeException)
     521             : {
     522           0 :     ThrowIfDisposed ();
     523             : 
     524             :     // This class supports no interfaces on its own.  Just return those
     525             :     // supported by the base class.
     526           0 :     return BaseClass::getTypes();
     527             : }
     528             : 
     529             : namespace
     530             : {
     531             :     class theAccessibleContextBaseImplementationId : public rtl::Static< UnoTunnelIdInit, theAccessibleContextBaseImplementationId > {};
     532             : }
     533             : 
     534             : uno::Sequence<sal_Int8> SAL_CALL
     535           0 :     AccessibleContextBase::getImplementationId (void)
     536             :     throw (::com::sun::star::uno::RuntimeException)
     537             : {
     538           0 :     return theAccessibleContextBaseImplementationId::get().getSeq();
     539             : }
     540             : 
     541             : //=====  internal  ============================================================
     542             : 
     543           3 : void SAL_CALL AccessibleContextBase::disposing (void)
     544             : {
     545           3 :     SetState (AccessibleStateType::DEFUNC);
     546             : 
     547           3 :     ::osl::MutexGuard aGuard (maMutex);
     548             : 
     549             :     // Send a disposing to all listeners.
     550           3 :     if ( mnClientId )
     551             :     {
     552           0 :         comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( mnClientId, *this );
     553           0 :         mnClientId =  0;
     554           3 :     }
     555           3 : }
     556             : 
     557             : 
     558             : 
     559             : 
     560           0 : void AccessibleContextBase::SetAccessibleDescription (
     561             :     const OUString& rDescription,
     562             :     StringOrigin eDescriptionOrigin)
     563             :     throw (uno::RuntimeException)
     564             : {
     565           0 :     if (eDescriptionOrigin < meDescriptionOrigin
     566           0 :         || (eDescriptionOrigin == meDescriptionOrigin && msDescription != rDescription))
     567             :     {
     568           0 :         uno::Any aOldValue, aNewValue;
     569           0 :         aOldValue <<= msDescription;
     570           0 :         aNewValue <<= rDescription;
     571             : 
     572           0 :         msDescription = rDescription;
     573           0 :         meDescriptionOrigin = eDescriptionOrigin;
     574             : 
     575             :         CommitChange(
     576             :             AccessibleEventId::DESCRIPTION_CHANGED,
     577             :             aNewValue,
     578           0 :             aOldValue);
     579             :     }
     580           0 : }
     581             : 
     582             : 
     583             : 
     584             : 
     585           7 : void AccessibleContextBase::SetAccessibleName (
     586             :     const OUString& rName,
     587             :     StringOrigin eNameOrigin)
     588             :     throw (uno::RuntimeException)
     589             : {
     590          14 :     if (eNameOrigin < meNameOrigin
     591           7 :         || (eNameOrigin == meNameOrigin && msName != rName))
     592             :     {
     593          14 :         uno::Any aOldValue, aNewValue;
     594           7 :         aOldValue <<= msName;
     595           7 :         aNewValue <<= rName;
     596             : 
     597           7 :         msName = rName;
     598           7 :         meNameOrigin = eNameOrigin;
     599             : 
     600             :         CommitChange(
     601             :             AccessibleEventId::NAME_CHANGED,
     602             :             aNewValue,
     603          14 :             aOldValue);
     604             :     }
     605           7 : }
     606             : 
     607             : 
     608             : 
     609             : 
     610           0 : OUString AccessibleContextBase::CreateAccessibleDescription (void)
     611             :     throw (::com::sun::star::uno::RuntimeException)
     612             : {
     613           0 :     return OUString("Empty Description");
     614             : }
     615             : 
     616             : 
     617             : 
     618             : 
     619           0 : OUString AccessibleContextBase::CreateAccessibleName (void)
     620             :     throw (::com::sun::star::uno::RuntimeException)
     621             : {
     622           0 :     return OUString("Empty Name");
     623             : }
     624             : 
     625             : 
     626             : 
     627             : 
     628          24 : void AccessibleContextBase::CommitChange (
     629             :     sal_Int16 nEventId,
     630             :     const uno::Any& rNewValue,
     631             :     const uno::Any& rOldValue)
     632             : {
     633             :     // Do not call FireEvent and do not even create the event object when no
     634             :     // listener has been registered yet.  Creating the event object can
     635             :     // otherwise lead to a crash.  See issue 93419 for details.
     636          24 :     if (mnClientId != 0)
     637             :     {
     638             :         AccessibleEventObject aEvent (
     639             :             static_cast<XAccessibleContext*>(this),
     640             :             nEventId,
     641             :             rNewValue,
     642           9 :             rOldValue);
     643             : 
     644           9 :         FireEvent (aEvent);
     645             :     }
     646          24 : }
     647             : 
     648             : 
     649             : 
     650             : 
     651           9 : void AccessibleContextBase::FireEvent (const AccessibleEventObject& aEvent)
     652             : {
     653           9 :     if (mnClientId)
     654           9 :         comphelper::AccessibleEventNotifier::addEvent( mnClientId, aEvent );
     655           9 : }
     656             : 
     657             : 
     658             : 
     659             : 
     660        1434 : void AccessibleContextBase::ThrowIfDisposed (void)
     661             :     throw (::com::sun::star::lang::DisposedException)
     662             : {
     663        1434 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     664             :     {
     665             :         OSL_TRACE ("Calling disposed object. Throwing exception:");
     666             :         throw lang::DisposedException ("object has been already disposed",
     667           3 :             static_cast<uno::XWeak*>(this));
     668             :     }
     669        1431 : }
     670             : 
     671             : 
     672             : 
     673           0 : sal_Bool AccessibleContextBase::IsDisposed (void)
     674             : {
     675           0 :     return (rBHelper.bDisposed || rBHelper.bInDispose);
     676             : }
     677             : 
     678             : 
     679             : 
     680           0 : void AccessibleContextBase::SetAccessibleRole( sal_Int16 _nRole )
     681             : {
     682           0 :     maRole = _nRole;
     683           0 : }
     684             : 
     685             : 
     686             : } // end of namespace accessibility
     687             : 
     688             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10