LCOV - code coverage report
Current view: top level - svx/source/table - accessiblecell.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 254 0.4 %
Date: 2014-11-03 Functions: 2 39 5.1 %
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 <sal/config.h>
      21             : 
      22             : #include <memory>
      23             : #include <utility>
      24             : 
      25             : #include <accessiblecell.hxx>
      26             : 
      27             : #include "svx/DescriptionGenerator.hxx"
      28             : 
      29             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      30             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      31             : 
      32             : #include <vcl/svapp.hxx>
      33             : 
      34             : #include <unotools/accessiblestatesethelper.hxx>
      35             : #include <comphelper/string.hxx>
      36             : #include <editeng/outlobj.hxx>
      37             : #include <svx/unoshtxt.hxx>
      38             : #include <svx/svdotext.hxx>
      39             : 
      40             : using namespace ::sdr::table;
      41             : using namespace ::com::sun::star;
      42             : using namespace ::com::sun::star::uno;
      43             : using namespace ::com::sun::star::accessibility;
      44             : using namespace ::com::sun::star::lang;
      45             : using namespace ::com::sun::star::container;
      46             : 
      47             : namespace accessibility {
      48             : 
      49           0 : AccessibleCell::AccessibleCell( const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible>& rxParent, const sdr::table::CellRef& rCell, sal_Int32 nIndex, const AccessibleShapeTreeInfo& rShapeTreeInfo )
      50             : : AccessibleCellBase( rxParent, AccessibleRole::TABLE_CELL )
      51             : , maShapeTreeInfo( rShapeTreeInfo )
      52             : , mnIndexInParent( nIndex )
      53             : , mpText( NULL )
      54           0 : , mxCell( rCell )
      55             : {
      56             :     //Init the pAccTable var
      57           0 :     pAccTable = dynamic_cast <AccessibleTableShape *> (rxParent.get());
      58           0 : }
      59             : 
      60             : 
      61             : 
      62           0 : AccessibleCell::~AccessibleCell (void)
      63             : {
      64             :     DBG_ASSERT( mpText == 0, "svx::AccessibleCell::~AccessibleCell(), not disposed!?" );
      65           0 : }
      66             : 
      67             : 
      68             : 
      69           0 : void AccessibleCell::Init (void)
      70             : {
      71           0 :     SdrView* pView = maShapeTreeInfo.GetSdrView();
      72           0 :     const vcl::Window* pWindow = maShapeTreeInfo.GetWindow ();
      73           0 :     if( (pView != NULL) && (pWindow != NULL) && mxCell.is())
      74             :     {
      75           0 :         OutlinerParaObject* pOutlinerParaObject = mxCell->GetEditOutlinerParaObject(); // Get the OutlinerParaObject if text edit is active
      76             : 
      77           0 :         bool bOwnParaObject = pOutlinerParaObject != 0;
      78             : 
      79           0 :         if( !pOutlinerParaObject )
      80           0 :             pOutlinerParaObject = mxCell->GetOutlinerParaObject();
      81             : 
      82             :         // create AccessibleTextHelper to handle this shape's text
      83           0 :         if( pOutlinerParaObject )
      84             :         {
      85             :             // non-empty text -> use full-fledged edit source right away
      86           0 :             ::std::unique_ptr<SvxEditSource> pEditSource( new SvxTextEditSource( mxCell->GetObject(), mxCell.get(), *pView, *pWindow) );
      87           0 :             mpText = new AccessibleTextHelper( std::move(pEditSource) );
      88           0 :             mpText->SetEventSource(this);
      89             :         }
      90             : 
      91           0 :         if( bOwnParaObject)
      92           0 :             delete pOutlinerParaObject;
      93             :     }
      94           0 : }
      95             : 
      96             : 
      97             : 
      98           0 : bool AccessibleCell::SetState (sal_Int16 aState)
      99             : {
     100           0 :     bool bStateHasChanged = false;
     101             : 
     102           0 :     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
     103             :     {
     104             :         // Offer FOCUSED state to edit engine and detect whether the state
     105             :         // changes.
     106           0 :         bool bIsFocused = mpText->HaveFocus ();
     107           0 :         mpText->SetFocus (true);
     108           0 :         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
     109             :     }
     110             :     else
     111           0 :         bStateHasChanged = AccessibleContextBase::SetState (aState);
     112             : 
     113           0 :     return bStateHasChanged;
     114             : }
     115             : 
     116             : 
     117             : 
     118           0 : bool AccessibleCell::ResetState (sal_Int16 aState)
     119             : {
     120           0 :     bool bStateHasChanged = false;
     121             : 
     122           0 :     if (aState == AccessibleStateType::FOCUSED && mpText != NULL)
     123             :     {
     124             :         // Try to remove FOCUSED state from the edit engine and detect
     125             :         // whether the state changes.
     126           0 :         bool bIsFocused = mpText->HaveFocus ();
     127           0 :         mpText->SetFocus (false);
     128           0 :         bStateHasChanged = (bIsFocused != mpText->HaveFocus ());
     129             :     }
     130             :     else
     131           0 :         bStateHasChanged = AccessibleContextBase::ResetState (aState);
     132             : 
     133           0 :     return bStateHasChanged;
     134             : }
     135             : 
     136             : 
     137             : 
     138           0 : bool AccessibleCell::operator== (const AccessibleCell& rAccessibleCell)
     139             : {
     140           0 :     return this == &rAccessibleCell;
     141             : }
     142             : 
     143             : 
     144             : // XInterface
     145             : 
     146             : 
     147           0 : Any SAL_CALL AccessibleCell::queryInterface( const Type& aType ) throw (RuntimeException, std::exception)
     148             : {
     149           0 :     return AccessibleCellBase::queryInterface( aType );
     150             : }
     151             : 
     152             : 
     153             : 
     154           0 : void SAL_CALL AccessibleCell::acquire(  ) throw ()
     155             : {
     156           0 :     AccessibleCellBase::acquire();
     157           0 : }
     158             : 
     159             : 
     160             : 
     161           0 : void SAL_CALL AccessibleCell::release(  ) throw ()
     162             : {
     163           0 :     AccessibleCellBase::release();
     164           0 : }
     165             : 
     166             : 
     167             : // XAccessibleContext
     168             : 
     169             : 
     170             : /** The children of this cell come from the paragraphs of text.
     171             : */
     172           0 : sal_Int32 SAL_CALL AccessibleCell::getAccessibleChildCount() throw (::com::sun::star::uno::RuntimeException, std::exception)
     173             : {
     174           0 :     SolarMutexGuard aSolarGuard;
     175           0 :     ThrowIfDisposed ();
     176           0 :     return mpText != NULL ? mpText->GetChildCount () : 0;
     177             : }
     178             : 
     179             : 
     180             : 
     181             : /** Forward the request to the shape.  Return the requested shape or throw
     182             :     an exception for a wrong index.
     183             : */
     184           0 : Reference<XAccessible> SAL_CALL AccessibleCell::getAccessibleChild (sal_Int32 nIndex) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
     185             : {
     186           0 :     SolarMutexGuard aSolarGuard;
     187           0 :     ThrowIfDisposed ();
     188             : 
     189             :     // todo: does GetChild throw IndexOutOfBoundsException?
     190           0 :     return mpText->GetChild (nIndex);
     191             : }
     192             : 
     193             : 
     194             : 
     195             : /** Return a copy of the state set.
     196             :     Possible states are:
     197             :         ENABLED
     198             :         SHOWING
     199             :         VISIBLE
     200             : */
     201           0 : Reference<XAccessibleStateSet> SAL_CALL AccessibleCell::getAccessibleStateSet (void) throw (RuntimeException, std::exception)
     202             : {
     203           0 :     SolarMutexGuard aSolarGuard;
     204           0 :     ::osl::MutexGuard aGuard (maMutex);
     205           0 :     Reference<XAccessibleStateSet> xStateSet;
     206             : 
     207           0 :     if (rBHelper.bDisposed || mpText == NULL)
     208             :     {
     209             :         // Return a minimal state set that only contains the DEFUNC state.
     210           0 :         xStateSet = AccessibleContextBase::getAccessibleStateSet ();
     211             :     }
     212             :     else
     213             :     {
     214           0 :         ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     215             : 
     216           0 :         if(pStateSet)
     217             :         {
     218             :             // Merge current FOCUSED state from edit engine.
     219           0 :             if (mpText != NULL)
     220             :             {
     221           0 :                 if (mpText->HaveFocus())
     222           0 :                     pStateSet->AddState (AccessibleStateType::FOCUSED);
     223             :                 else
     224           0 :                     pStateSet->RemoveState (AccessibleStateType::FOCUSED);
     225             :             }
     226             :             // Set the invisible state for merged cell
     227           0 :             if (mxCell.is() && mxCell->isMerged())
     228           0 :                 pStateSet->RemoveState(AccessibleStateType::VISIBLE);
     229             :             else
     230           0 :                 pStateSet->AddState(AccessibleStateType::VISIBLE);
     231             : 
     232             : 
     233             :             //Just when the parent table is not read-only,set states EDITABLE,RESIZABLE,MOVEABLE
     234           0 :             ::com::sun::star::uno::Reference<XAccessible> xTempAcc = getAccessibleParent();
     235           0 :             if( xTempAcc.is() )
     236             :             {
     237             :                 ::com::sun::star::uno::Reference<XAccessibleContext>
     238           0 :                                         xTempAccContext = xTempAcc->getAccessibleContext();
     239           0 :                 if( xTempAccContext.is() )
     240             :                 {
     241             :                     ::com::sun::star::uno::Reference<XAccessibleStateSet> rState =
     242           0 :                         xTempAccContext->getAccessibleStateSet();
     243           0 :                     if( rState.is() )           {
     244           0 :                         com::sun::star::uno::Sequence<short> pStates = rState->getStates();
     245           0 :                         int count = pStates.getLength();
     246           0 :                         for( int iIndex = 0;iIndex < count;iIndex++ )
     247             :                         {
     248           0 :                             if( pStates[iIndex] == AccessibleStateType::EDITABLE )
     249             :                             {
     250           0 :                                 pStateSet->AddState (AccessibleStateType::EDITABLE);
     251           0 :                                 pStateSet->AddState (AccessibleStateType::RESIZABLE);
     252           0 :                                 pStateSet->AddState (AccessibleStateType::MOVEABLE);
     253           0 :                                 break;
     254             :                             }
     255           0 :                         }
     256           0 :                     }
     257           0 :                 }
     258             :             }
     259             :             // Create a copy of the state set that may be modified by the
     260             :             // caller without affecting the current state set.
     261           0 :             xStateSet = Reference<XAccessibleStateSet>(new ::utl::AccessibleStateSetHelper (*pStateSet));
     262             :         }
     263             :     }
     264             : 
     265           0 :     return xStateSet;
     266             : }
     267             : 
     268             : 
     269             : // XAccessibleComponent
     270             : 
     271             : 
     272           0 : sal_Bool SAL_CALL AccessibleCell::containsPoint( const ::com::sun::star::awt::Point& aPoint) throw (::com::sun::star::uno::RuntimeException, std::exception)
     273             : {
     274           0 :     return AccessibleComponentBase::containsPoint( aPoint );
     275             : }
     276             : 
     277             : /** The implementation below is at the moment straightforward.  It iterates
     278             :     over all children (and thereby instances all children which have not
     279             :     been already instatiated) until a child covering the specifed point is
     280             :     found.
     281             :     This leaves room for improvement.  For instance, first iterate only over
     282             :     the already instantiated children and only if no match is found
     283             :     instantiate the remaining ones.
     284             : */
     285           0 : Reference<XAccessible > SAL_CALL  AccessibleCell::getAccessibleAtPoint ( const ::com::sun::star::awt::Point& aPoint) throw(RuntimeException, std::exception)
     286             : {
     287           0 :     SolarMutexGuard aSolarGuard;
     288           0 :     ::osl::MutexGuard aGuard (maMutex);
     289             : 
     290           0 :     sal_Int32 nChildCount = getAccessibleChildCount ();
     291           0 :     for (sal_Int32 i=0; i<nChildCount; ++i)
     292             :     {
     293           0 :         Reference<XAccessible> xChild (getAccessibleChild (i));
     294           0 :         if (xChild.is())
     295             :         {
     296           0 :             Reference<XAccessibleComponent> xChildComponent (xChild->getAccessibleContext(), uno::UNO_QUERY);
     297           0 :             if (xChildComponent.is())
     298             :             {
     299           0 :                 awt::Rectangle aBBox (xChildComponent->getBounds());
     300           0 :                 if ( (aPoint.X >= aBBox.X)
     301           0 :                     && (aPoint.Y >= aBBox.Y)
     302           0 :                     && (aPoint.X < aBBox.X+aBBox.Width)
     303           0 :                     && (aPoint.Y < aBBox.Y+aBBox.Height) )
     304           0 :                     return xChild;
     305           0 :             }
     306             :         }
     307           0 :     }
     308             : 
     309             :     // Have not found a child under the given point.  Returning empty
     310             :     // reference to indicate this.
     311           0 :     return uno::Reference<XAccessible>();
     312             : }
     313             : 
     314             : 
     315             : 
     316           0 : ::com::sun::star::awt::Rectangle SAL_CALL AccessibleCell::getBounds(void) throw(RuntimeException, std::exception)
     317             : {
     318           0 :     SolarMutexGuard aSolarGuard;
     319           0 :     ::osl::MutexGuard aGuard (maMutex);
     320             : 
     321           0 :     ThrowIfDisposed ();
     322           0 :     ::com::sun::star::awt::Rectangle aBoundingBox;
     323           0 :     if( mxCell.is() )
     324             :     {
     325             :         // Get the cell's bounding box in internal coordinates (in 100th of mm)
     326           0 :         const ::Rectangle aCellRect( mxCell->getCellRect() );
     327             : 
     328             :         // Transform coordinates from internal to pixel.
     329           0 :         if (maShapeTreeInfo.GetViewForwarder() == NULL)
     330           0 :             throw uno::RuntimeException ("AccessibleCell has no valid view forwarder",static_cast<uno::XWeak*>(this));
     331             : 
     332           0 :         ::Size aPixelSize( maShapeTreeInfo.GetViewForwarder()->LogicToPixel(::Size(aCellRect.GetWidth(), aCellRect.GetHeight())) );
     333           0 :         ::Point aPixelPosition( maShapeTreeInfo.GetViewForwarder()->LogicToPixel( aCellRect.TopLeft() ));
     334             : 
     335             :         // Clip the shape's bounding box with the bounding box of its parent.
     336           0 :         Reference<XAccessibleComponent> xParentComponent ( getAccessibleParent(), uno::UNO_QUERY);
     337           0 :         if (xParentComponent.is())
     338             :         {
     339             :             // Make the coordinates relative to the parent.
     340           0 :             awt::Point aParentLocation (xParentComponent->getLocationOnScreen());
     341           0 :             int x = aPixelPosition.getX() - aParentLocation.X;
     342           0 :             int y = aPixelPosition.getY() - aParentLocation.Y;
     343             : 
     344             :             // Clip with parent (with coordinates relative to itself).
     345           0 :             ::Rectangle aBBox ( x, y, x + aPixelSize.getWidth(), y + aPixelSize.getHeight());
     346           0 :             awt::Size aParentSize (xParentComponent->getSize());
     347           0 :             ::Rectangle aParentBBox (0,0, aParentSize.Width, aParentSize.Height);
     348           0 :             aBBox = aBBox.GetIntersection (aParentBBox);
     349           0 :             aBoundingBox = awt::Rectangle ( aBBox.getX(), aBBox.getY(), aBBox.getWidth(), aBBox.getHeight());
     350             :         }
     351             :         else
     352             :         {
     353             :             OSL_TRACE ("parent does not support component");
     354           0 :             aBoundingBox = awt::Rectangle (aPixelPosition.getX(), aPixelPosition.getY(),aPixelSize.getWidth(), aPixelSize.getHeight());
     355           0 :         }
     356             :     }
     357             : 
     358           0 :     return aBoundingBox;
     359             : }
     360             : 
     361             : 
     362             : 
     363           0 : ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocation(void) throw (RuntimeException, std::exception)
     364             : {
     365           0 :     ThrowIfDisposed ();
     366           0 :     ::com::sun::star::awt::Rectangle aBoundingBox(getBounds());
     367           0 :     return ::com::sun::star::awt::Point(aBoundingBox.X, aBoundingBox.Y);
     368             : }
     369             : 
     370             : 
     371             : 
     372           0 : ::com::sun::star::awt::Point SAL_CALL AccessibleCell::getLocationOnScreen(void) throw(RuntimeException, std::exception)
     373             : {
     374           0 :     ThrowIfDisposed ();
     375             : 
     376             :     // Get relative position...
     377           0 :     ::com::sun::star::awt::Point aLocation(getLocation ());
     378             : 
     379             :     // ... and add absolute position of the parent.
     380           0 :     Reference<XAccessibleComponent> xParentComponent( getAccessibleParent(), uno::UNO_QUERY);
     381           0 :     if(xParentComponent.is())
     382             :     {
     383           0 :         ::com::sun::star::awt::Point aParentLocation(xParentComponent->getLocationOnScreen());
     384           0 :         aLocation.X += aParentLocation.X;
     385           0 :         aLocation.Y += aParentLocation.Y;
     386             :     }
     387             :     else
     388             :     {
     389             :         OSL_TRACE ("getLocation: parent does not support XAccessibleComponent");
     390             :     }
     391             : 
     392           0 :     return aLocation;
     393             : }
     394             : 
     395             : 
     396             : 
     397           0 : awt::Size SAL_CALL AccessibleCell::getSize (void) throw (RuntimeException, std::exception)
     398             : {
     399           0 :     ThrowIfDisposed ();
     400           0 :     awt::Rectangle aBoundingBox (getBounds());
     401           0 :     return awt::Size (aBoundingBox.Width, aBoundingBox.Height);
     402             : }
     403             : 
     404             : 
     405             : 
     406           0 : void SAL_CALL AccessibleCell::addFocusListener ( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener) throw (::com::sun::star::uno::RuntimeException)
     407             : {
     408           0 :     AccessibleComponentBase::addFocusListener( xListener );
     409           0 : }
     410             : 
     411             : 
     412             : 
     413           0 : void SAL_CALL AccessibleCell::removeFocusListener (const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFocusListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
     414             : {
     415           0 :     AccessibleComponentBase::removeFocusListener( xListener );
     416           0 : }
     417             : 
     418             : 
     419             : 
     420           0 : void SAL_CALL AccessibleCell::grabFocus (void) throw (::com::sun::star::uno::RuntimeException, std::exception)
     421             : {
     422           0 :     AccessibleComponentBase::grabFocus();
     423           0 : }
     424             : 
     425             : 
     426             : 
     427           0 : sal_Int32 SAL_CALL AccessibleCell::getForeground(void) throw (RuntimeException, std::exception)
     428             : {
     429           0 :     ThrowIfDisposed ();
     430           0 :     sal_Int32 nColor (0x0ffffffL);
     431             : 
     432             :     // todo
     433           0 :     return nColor;
     434             : }
     435             : 
     436             : 
     437             : 
     438           0 : sal_Int32 SAL_CALL AccessibleCell::getBackground (void) throw (RuntimeException, std::exception)
     439             : {
     440           0 :     ThrowIfDisposed ();
     441           0 :     sal_Int32 nColor (0L);
     442             : 
     443             :     // todo
     444           0 :     return nColor;
     445             : }
     446             : 
     447             : 
     448             : // XAccessibleExtendedComponent
     449             : 
     450             : 
     451           0 : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL AccessibleCell::getFont (void) throw (::com::sun::star::uno::RuntimeException, std::exception)
     452             : {
     453             : //todo
     454           0 :     return AccessibleComponentBase::getFont();
     455             : }
     456             : 
     457             : 
     458             : 
     459           0 : OUString SAL_CALL AccessibleCell::getTitledBorderText (void) throw (::com::sun::star::uno::RuntimeException, std::exception)
     460             : {
     461           0 :     return AccessibleComponentBase::getTitledBorderText();
     462             : }
     463             : 
     464             : 
     465             : 
     466           0 : OUString SAL_CALL AccessibleCell::getToolTipText (void) throw (::com::sun::star::uno::RuntimeException, std::exception)
     467             : {
     468           0 :     return AccessibleComponentBase::getToolTipText();
     469             : }
     470             : 
     471             : 
     472             : // XAccessibleEventBroadcaster
     473             : 
     474             : 
     475           0 : void SAL_CALL AccessibleCell::addAccessibleEventListener( const Reference<XAccessibleEventListener >& rxListener)  throw (RuntimeException, std::exception)
     476             : {
     477           0 :     SolarMutexGuard aSolarGuard;
     478           0 :     ::osl::MutexGuard aGuard (maMutex);
     479           0 :     if (rBHelper.bDisposed || rBHelper.bInDispose)
     480             :     {
     481           0 :         Reference<XInterface> xSource( static_cast<XComponent *>(this) );
     482           0 :         lang::EventObject aEventObj(xSource);
     483           0 :         rxListener->disposing(aEventObj);
     484             :     }
     485             :     else
     486             :     {
     487           0 :         AccessibleContextBase::addAccessibleEventListener (rxListener);
     488           0 :         if (mpText != NULL)
     489           0 :             mpText->AddEventListener (rxListener);
     490           0 :     }
     491           0 : }
     492             : 
     493             : 
     494             : 
     495           0 : void SAL_CALL AccessibleCell::removeAccessibleEventListener( const Reference<XAccessibleEventListener >& rxListener) throw (RuntimeException, std::exception)
     496             : {
     497           0 :     SolarMutexGuard aSolarGuard;
     498           0 :     AccessibleContextBase::removeAccessibleEventListener(rxListener);
     499           0 :     if (mpText != NULL)
     500           0 :         mpText->RemoveEventListener (rxListener);
     501           0 : }
     502             : 
     503             : 
     504             : // XServiceInfo
     505             : 
     506             : 
     507           0 : OUString SAL_CALL AccessibleCell::getImplementationName(void) throw (RuntimeException, std::exception)
     508             : {
     509           0 :     return OUString("AccessibleCell");
     510             : }
     511             : 
     512             : 
     513             : 
     514           0 : Sequence<OUString> SAL_CALL AccessibleCell::getSupportedServiceNames(void) throw (RuntimeException, std::exception)
     515             : {
     516           0 :     ThrowIfDisposed ();
     517             : 
     518             :     // Get list of supported service names from base class...
     519           0 :     uno::Sequence<OUString> aServiceNames = AccessibleContextBase::getSupportedServiceNames();
     520           0 :     sal_Int32 nCount (aServiceNames.getLength());
     521             : 
     522             :     // ...and add additional names.
     523           0 :     aServiceNames.realloc (nCount + 1);
     524           0 :     static const OUString sAdditionalServiceName ("com.sun.star.drawing.AccessibleCell");
     525           0 :     aServiceNames[nCount] = sAdditionalServiceName;
     526             : 
     527           0 :     return aServiceNames;
     528             : }
     529             : 
     530             : 
     531             : // IAccessibleViewForwarderListener
     532             : 
     533             : 
     534           0 : void AccessibleCell::ViewForwarderChanged (ChangeType /*aChangeType*/, const IAccessibleViewForwarder* /*pViewForwarder*/)
     535             : {
     536             :     // Inform all listeners that the graphical representation (i.e. size
     537             :     // and/or position) of the shape has changed.
     538           0 :     CommitChange(AccessibleEventId::VISIBLE_DATA_CHANGED, Any(), Any());
     539             : 
     540             :     // update our children that our screen position might have changed
     541           0 :     if( mpText )
     542           0 :         mpText->UpdateChildren();
     543           0 : }
     544             : 
     545             : 
     546             : // protected
     547             : 
     548             : 
     549           0 : void AccessibleCell::disposing (void)
     550             : {
     551           0 :     SolarMutexGuard aSolarGuard;
     552           0 :     ::osl::MutexGuard aGuard (maMutex);
     553             : 
     554             :     // Make sure to send an event that this object loses the focus in the
     555             :     // case that it has the focus.
     556           0 :     ::utl::AccessibleStateSetHelper* pStateSet = static_cast< ::utl::AccessibleStateSetHelper*>(mxStateSet.get());
     557           0 :     if (pStateSet != NULL)
     558           0 :         pStateSet->RemoveState(AccessibleStateType::FOCUSED);
     559             : 
     560           0 :     if (mpText != NULL)
     561             :     {
     562           0 :         mpText->Dispose();
     563           0 :         delete mpText;
     564           0 :         mpText = NULL;
     565             :     }
     566             : 
     567             :     // Cleanup.  Remove references to objects to allow them to be
     568             :     // destroyed.
     569           0 :     mxCell.clear();
     570           0 :     maShapeTreeInfo = AccessibleShapeTreeInfo();
     571             : 
     572             :     // Call base classes.
     573           0 :     AccessibleContextBase::dispose ();
     574           0 : }
     575             : 
     576           0 : sal_Int32 SAL_CALL AccessibleCell::getAccessibleIndexInParent (void) throw (RuntimeException, std::exception)
     577             : {
     578           0 :     ThrowIfDisposed ();
     579           0 :     return mnIndexInParent;
     580             : }
     581             : 
     582             : 
     583           0 : OUString AccessibleCell::getCellName( sal_Int32 nCol, sal_Int32 nRow )
     584             : {
     585           0 :     OUStringBuffer aBuf;
     586             : 
     587           0 :     if (nCol < 26*26)
     588             :     {
     589           0 :         if (nCol < 26)
     590             :             aBuf.append( static_cast<sal_Unicode>( 'A' +
     591           0 :                         static_cast<sal_uInt16>(nCol)));
     592             :         else
     593             :         {
     594             :             aBuf.append( static_cast<sal_Unicode>( 'A' +
     595           0 :                         (static_cast<sal_uInt16>(nCol) / 26) - 1));
     596             :             aBuf.append( static_cast<sal_Unicode>( 'A' +
     597           0 :                         (static_cast<sal_uInt16>(nCol) % 26)));
     598             :         }
     599             :     }
     600             :     else
     601             :     {
     602           0 :         OUStringBuffer aStr;
     603           0 :         while (nCol >= 26)
     604             :         {
     605           0 :             sal_Int32 nC = nCol % 26;
     606             :             aStr.append(static_cast<sal_Unicode>( 'A' +
     607           0 :                     static_cast<sal_uInt16>(nC)));
     608           0 :             nCol = nCol - nC;
     609           0 :             nCol = nCol / 26 - 1;
     610             :         }
     611             :         aStr.append(static_cast<sal_Unicode>( 'A' +
     612           0 :                 static_cast<sal_uInt16>(nCol)));
     613           0 :         aBuf.append(comphelper::string::reverseString(aStr.makeStringAndClear()));
     614             :     }
     615           0 :     aBuf.append( OUString::number(nRow+1) );
     616           0 :     return aBuf.makeStringAndClear();
     617             : }
     618             : 
     619           0 : OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException, std::exception)
     620             : {
     621           0 :     ThrowIfDisposed ();
     622           0 :     SolarMutexGuard aSolarGuard;
     623             : 
     624           0 :     if( pAccTable )
     625             :     {
     626             :         try
     627             :         {
     628           0 :             sal_Int32 nRow = 0, nCol = 0;
     629           0 :             pAccTable->getColumnAndRow(mnIndexInParent, nCol, nRow);
     630           0 :             return getCellName( nCol, nRow );
     631             :         }
     632           0 :         catch(const Exception&)
     633             :         {
     634             :         }
     635             :     }
     636             : 
     637           0 :     return AccessibleCellBase::getAccessibleName();
     638             : }
     639             : 
     640           0 : void AccessibleCell::UpdateChildren()
     641             : {
     642           0 :     if (mpText)
     643           0 :         mpText->UpdateChildren();
     644           0 : }
     645             : 
     646             : /* MT: Above getAccessibleName was introduced with IA2 CWS, while below was introduce in 3.3 meanwhile. Check which one is correct
     647             : +If this is correct, we also don't need  sdr::table::CellRef getCellRef(), UpdateChildren(), getCellName( sal_Int32 nCol, sal_Int32 nRow ) above
     648             : +
     649             : 
     650             : OUString SAL_CALL AccessibleCell::getAccessibleName (void) throw (::com::sun::star::uno::RuntimeException)
     651             : {
     652             :     ThrowIfDisposed ();
     653             :     SolarMutexGuard aSolarGuard;
     654             : 
     655             :     if( mxCell.is() )
     656             :         return mxCell->getName();
     657             : 
     658             :     return AccessibleCellBase::getAccessibleName();
     659             : }
     660             : */
     661             : 
     662         594 : } // end of namespace accessibility
     663             : 
     664             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10