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

Generated by: LCOV version 1.10