LCOV - code coverage report
Current view: top level - sc/source/ui/Accessibility - AccessiblePreviewTable.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 272 315 86.3 %
Date: 2014-04-11 Functions: 41 45 91.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             : 
      21             : #include "scitems.hxx"
      22             : #include "AccessiblePreviewTable.hxx"
      23             : #include "AccessiblePreviewCell.hxx"
      24             : #include "AccessiblePreviewHeaderCell.hxx"
      25             : #include "AccessibilityHints.hxx"
      26             : #include "prevwsh.hxx"
      27             : #include "miscuno.hxx"
      28             : #include "prevloc.hxx"
      29             : #include "attrib.hxx"
      30             : #include "document.hxx"
      31             : #include "scresid.hxx"
      32             : #include "sc.hrc"
      33             : 
      34             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      35             : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      36             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      37             : 
      38             : #include <vcl/window.hxx>
      39             : #include <vcl/svapp.hxx>
      40             : #include <svl/smplhint.hxx>
      41             : #include <unotools/accessiblestatesethelper.hxx>
      42             : #include <comphelper/sequence.hxx>
      43             : #include <comphelper/servicehelper.hxx>
      44             : 
      45             : using namespace ::com::sun::star;
      46             : using namespace ::com::sun::star::accessibility;
      47             : 
      48             : //=====  internal  ============================================================
      49             : 
      50          15 : ScAccessiblePreviewTable::ScAccessiblePreviewTable( const ::com::sun::star::uno::Reference<
      51             :                                 ::com::sun::star::accessibility::XAccessible>& rxParent,
      52             :                             ScPreviewShell* pViewShell, sal_Int32 nIndex ) :
      53             :     ScAccessibleContextBase( rxParent, AccessibleRole::TABLE ),
      54             :     mpViewShell( pViewShell ),
      55             :     mnIndex( nIndex ),
      56          15 :     mpTableInfo( NULL )
      57             : {
      58          15 :     if (mpViewShell)
      59          15 :         mpViewShell->AddAccessibilityObject(*this);
      60          15 : }
      61             : 
      62          45 : ScAccessiblePreviewTable::~ScAccessiblePreviewTable()
      63             : {
      64          15 :     if (!ScAccessibleContextBase::IsDefunc() && !rBHelper.bInDispose)
      65             :     {
      66             :         // increment refcount to prevent double call off dtor
      67           0 :         osl_atomic_increment( &m_refCount );
      68           0 :         dispose();
      69             :     }
      70          30 : }
      71             : 
      72          15 : void SAL_CALL ScAccessiblePreviewTable::disposing()
      73             : {
      74          15 :     SolarMutexGuard aGuard;
      75          15 :     if (mpViewShell)
      76             :     {
      77          15 :         mpViewShell->RemoveAccessibilityObject(*this);
      78          15 :         mpViewShell = NULL;
      79             :     }
      80             : 
      81          15 :     if (mpTableInfo)
      82           7 :         DELETEZ (mpTableInfo);
      83             : 
      84          15 :     ScAccessibleContextBase::disposing();
      85          15 : }
      86             : 
      87             : //=====  SfxListener  =====================================================
      88             : 
      89          21 : void ScAccessiblePreviewTable::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
      90             : {
      91          21 :     if (rHint.ISA( SfxSimpleHint ))
      92             :     {
      93          13 :         const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
      94          13 :         sal_uLong nId = rRef.GetId();
      95          13 :         if ( nId == SFX_HINT_DATACHANGED )
      96             :         {
      97             :             //  column / row layout may change with any document change,
      98             :             //  so it must be invalidated
      99           8 :             DELETEZ( mpTableInfo );
     100             :         }
     101           5 :         else if (rRef.GetId() == SC_HINT_ACC_VISAREACHANGED)
     102             :         {
     103           5 :             AccessibleEventObject aEvent;
     104           5 :             aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
     105           5 :             aEvent.Source = uno::Reference< XAccessibleContext >(this);
     106           5 :             CommitChange(aEvent);
     107             :         }
     108             :     }
     109             : 
     110          21 :     ScAccessibleContextBase::Notify(rBC, rHint);
     111          21 : }
     112             : 
     113             : //=====  XInterface  =====================================================
     114             : 
     115         241 : uno::Any SAL_CALL ScAccessiblePreviewTable::queryInterface( uno::Type const & rType )
     116             :     throw (uno::RuntimeException, std::exception)
     117             : {
     118         241 :     uno::Any aAny (ScAccessiblePreviewTableImpl::queryInterface(rType));
     119         241 :     return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
     120             : }
     121             : 
     122        1246 : void SAL_CALL ScAccessiblePreviewTable::acquire()
     123             :     throw ()
     124             : {
     125        1246 :     ScAccessibleContextBase::acquire();
     126        1246 : }
     127             : 
     128        1246 : void SAL_CALL ScAccessiblePreviewTable::release()
     129             :     throw ()
     130             : {
     131        1246 :     ScAccessibleContextBase::release();
     132        1246 : }
     133             : 
     134             : //=====  XAccessibleTable  ================================================
     135             : 
     136           1 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowCount()
     137             :     throw (uno::RuntimeException, std::exception)
     138             : {
     139           1 :     SolarMutexGuard aGuard;
     140           1 :     IsObjectValid();
     141             : 
     142           1 :     FillTableInfo();
     143             : 
     144           1 :     sal_Int32 nRet = 0;
     145           1 :     if ( mpTableInfo )
     146           1 :         nRet = mpTableInfo->GetRows();
     147           1 :     return nRet;
     148             : }
     149             : 
     150           1 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnCount()
     151             :     throw (uno::RuntimeException, std::exception)
     152             : {
     153           1 :     SolarMutexGuard aGuard;
     154           1 :     IsObjectValid();
     155             : 
     156           1 :     FillTableInfo();
     157             : 
     158           1 :     sal_Int32 nRet = 0;
     159           1 :     if ( mpTableInfo )
     160           1 :         nRet = mpTableInfo->GetCols();
     161           1 :     return nRet;
     162             : }
     163             : 
     164           3 : OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleRowDescription( sal_Int32 nRow )
     165             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     166             : {
     167           3 :     SolarMutexGuard aGuard;
     168           3 :     FillTableInfo();
     169           3 :     if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
     170           2 :         throw lang::IndexOutOfBoundsException();
     171             : 
     172           3 :     return OUString();
     173             : }
     174             : 
     175           3 : OUString SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnDescription( sal_Int32 nColumn )
     176             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     177             : {
     178           3 :     SolarMutexGuard aGuard;
     179           3 :     FillTableInfo();
     180           3 :     if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
     181           2 :         throw lang::IndexOutOfBoundsException();
     182             : 
     183           3 :     return OUString();
     184             : }
     185             : 
     186           5 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
     187             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     188             : {
     189           5 :     SolarMutexGuard aGuard;
     190           5 :     IsObjectValid();
     191             : 
     192           5 :     FillTableInfo();
     193             : 
     194           5 :     sal_Int32 nRows = 1;
     195          13 :     if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
     196          10 :             nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
     197             :     {
     198           1 :         const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
     199           1 :         const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
     200             : 
     201           1 :         if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
     202             :         {
     203             :             //  header cells only span a single cell
     204             :         }
     205             :         else
     206             :         {
     207           1 :             ScDocument* pDoc = mpViewShell->GetDocument();
     208             :             const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
     209           1 :                 static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
     210           1 :             if ( pItem && pItem->GetRowMerge() > 0 )
     211           0 :                 nRows = pItem->GetRowMerge();
     212             :         }
     213             :     }
     214             :     else
     215           4 :         throw lang::IndexOutOfBoundsException();
     216             : 
     217           5 :     return nRows;
     218             : }
     219             : 
     220           5 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
     221             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     222             : {
     223           5 :     SolarMutexGuard aGuard;
     224           5 :     IsObjectValid();
     225             : 
     226           5 :     FillTableInfo();
     227             : 
     228           5 :     sal_Int32 nColumns = 1;
     229          13 :     if ( mpViewShell && mpTableInfo && nColumn >= 0 && nRow >= 0 &&
     230          10 :             nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
     231             :     {
     232           1 :         const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
     233           1 :         const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
     234             : 
     235           1 :         if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
     236             :         {
     237             :             //  header cells only span a single cell
     238             :         }
     239             :         else
     240             :         {
     241           1 :             ScDocument* pDoc = mpViewShell->GetDocument();
     242             :             const ScMergeAttr* pItem = (const ScMergeAttr*)pDoc->GetAttr(
     243           1 :                 static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab(), ATTR_MERGE );
     244           1 :             if ( pItem && pItem->GetColMerge() > 0 )
     245           0 :                 nColumns = pItem->GetColMerge();
     246             :         }
     247             :     }
     248             :     else
     249           4 :         throw lang::IndexOutOfBoundsException();
     250             : 
     251           5 :     return nColumns;
     252             : }
     253             : 
     254           1 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleRowHeaders() throw (uno::RuntimeException, std::exception)
     255             : {
     256             :     //! missing
     257           1 :     return NULL;
     258             : }
     259             : 
     260           1 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessiblePreviewTable::getAccessibleColumnHeaders() throw (uno::RuntimeException, std::exception)
     261             : {
     262             :     //! missing
     263           1 :     return NULL;
     264             : }
     265             : 
     266           1 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleRows() throw (uno::RuntimeException, std::exception)
     267             : {
     268             :     //  in the page preview, there is no selection
     269           1 :     return uno::Sequence<sal_Int32>(0);
     270             : }
     271             : 
     272           1 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessiblePreviewTable::getSelectedAccessibleColumns() throw (uno::RuntimeException, std::exception)
     273             : {
     274             :     //  in the page preview, there is no selection
     275           1 :     return uno::Sequence<sal_Int32>(0);
     276             : }
     277             : 
     278           3 : sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleRowSelected( sal_Int32 nRow )
     279             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     280             : {
     281             :     //  in the page preview, there is no selection
     282             : 
     283           3 :     SolarMutexGuard aGuard;
     284           3 :     FillTableInfo();
     285           3 :     if ( nRow < 0 || (mpTableInfo && nRow >= mpTableInfo->GetRows()) )
     286           2 :         throw lang::IndexOutOfBoundsException();
     287             : 
     288           3 :     return false;
     289             : }
     290             : 
     291           3 : sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleColumnSelected( sal_Int32 nColumn )
     292             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     293             : {
     294             :     //  in the page preview, there is no selection
     295             : 
     296           3 :     SolarMutexGuard aGuard;
     297           3 :     FillTableInfo();
     298           3 :     if ( nColumn < 0 || (mpTableInfo && nColumn >= mpTableInfo->GetCols()) )
     299           2 :         throw lang::IndexOutOfBoundsException();
     300             : 
     301           3 :     return false;
     302             : }
     303             : 
     304          24 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
     305             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     306             : {
     307          24 :     SolarMutexGuard aGuard;
     308          24 :     IsObjectValid();
     309             : 
     310          24 :     FillTableInfo();
     311             : 
     312          24 :     uno::Reference<XAccessible> xRet;
     313          24 :     if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
     314             :     {
     315             :         //  index iterates horizontally
     316          20 :         long nNewIndex = nRow * mpTableInfo->GetCols() + nColumn;
     317             : 
     318          20 :         const ScPreviewColRowInfo& rColInfo = mpTableInfo->GetColInfo()[nColumn];
     319          20 :         const ScPreviewColRowInfo& rRowInfo = mpTableInfo->GetRowInfo()[nRow];
     320             : 
     321          20 :         ScAddress aCellPos( static_cast<SCCOL>(rColInfo.nDocIndex), static_cast<SCROW>(rRowInfo.nDocIndex), mpTableInfo->GetTab() );
     322          20 :         if ( rColInfo.bIsHeader || rRowInfo.bIsHeader )
     323             :         {
     324             :             ScAccessiblePreviewHeaderCell* pHeaderCell = new ScAccessiblePreviewHeaderCell( this, mpViewShell, aCellPos,
     325           9 :                                         rRowInfo.bIsHeader, rColInfo.bIsHeader, nNewIndex );
     326           9 :             xRet = pHeaderCell;
     327           9 :             pHeaderCell->Init();
     328             :         }
     329             :         else
     330             :         {
     331          11 :             ScAccessiblePreviewCell* pCell = new ScAccessiblePreviewCell( this, mpViewShell, aCellPos, nNewIndex );
     332          11 :             xRet = pCell;
     333          11 :             pCell->Init();
     334             :         }
     335             :     }
     336             : 
     337          24 :     if ( !xRet.is() )
     338           4 :         throw lang::IndexOutOfBoundsException();
     339             : 
     340          24 :     return xRet;
     341             : }
     342             : 
     343           1 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleCaption() throw (uno::RuntimeException, std::exception)
     344             : {
     345             :     //! missing
     346           1 :     return NULL;
     347             : }
     348             : 
     349           1 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleSummary() throw (uno::RuntimeException, std::exception)
     350             : {
     351             :     //! missing
     352           1 :     return NULL;
     353             : }
     354             : 
     355           5 : sal_Bool SAL_CALL ScAccessiblePreviewTable::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
     356             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     357             : {
     358             :     //  in the page preview, there is no selection
     359           5 :     SolarMutexGuard aGuard;
     360           5 :     IsObjectValid();
     361             : 
     362           5 :     FillTableInfo();
     363             : 
     364           5 :     if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
     365             :     {
     366             :         //  index iterates horizontally
     367             :     }
     368             :     else
     369           4 :         throw lang::IndexOutOfBoundsException();
     370             : 
     371           5 :     return false;
     372             : }
     373             : 
     374           5 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
     375             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     376             : {
     377           5 :     SolarMutexGuard aGuard;
     378           5 :     IsObjectValid();
     379             : 
     380           5 :     FillTableInfo();
     381             : 
     382           5 :     sal_Int32 nRet = 0;
     383           5 :     if ( mpTableInfo && nColumn >= 0 && nRow >= 0 && nColumn < mpTableInfo->GetCols() && nRow < mpTableInfo->GetRows() )
     384             :     {
     385             :         //  index iterates horizontally
     386           1 :         nRet = nRow * mpTableInfo->GetCols() + nColumn;
     387             :     }
     388             :     else
     389           4 :         throw lang::IndexOutOfBoundsException();
     390             : 
     391           5 :     return nRet;
     392             : }
     393             : 
     394           4 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleRow( sal_Int32 nChildIndex )
     395             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     396             : {
     397           4 :     SolarMutexGuard aGuard;
     398           4 :     IsObjectValid();
     399             : 
     400           4 :     FillTableInfo();
     401             : 
     402           4 :     sal_Int32 nRow = 0;
     403           4 :     if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
     404             :     {
     405           2 :         nRow = nChildIndex / mpTableInfo->GetCols();
     406             :     }
     407             :     else
     408           2 :         throw lang::IndexOutOfBoundsException();
     409             : 
     410           4 :     return nRow;
     411             : }
     412             : 
     413           4 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleColumn( sal_Int32 nChildIndex )
     414             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     415             : {
     416           4 :     SolarMutexGuard aGuard;
     417           4 :     IsObjectValid();
     418             : 
     419           4 :     FillTableInfo();
     420             : 
     421           4 :     sal_Int32 nCol = 0;
     422           4 :     if ( mpTableInfo && nChildIndex >= 0 && nChildIndex < static_cast<sal_Int32>(mpTableInfo->GetRows()) * mpTableInfo->GetCols() )
     423             :     {
     424           2 :         nCol = nChildIndex % static_cast<sal_Int32>(mpTableInfo->GetCols());
     425             :     }
     426             :     else
     427           2 :         throw lang::IndexOutOfBoundsException();
     428             : 
     429           4 :     return nCol;
     430             : }
     431             : 
     432             : //=====  XAccessibleComponent  ============================================
     433             : 
     434           0 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleAtPoint( const awt::Point& aPoint )
     435             :     throw (uno::RuntimeException, std::exception)
     436             : {
     437           0 :     uno::Reference<XAccessible> xRet;
     438           0 :     if (containsPoint(aPoint))
     439             :     {
     440           0 :         SolarMutexGuard aGuard;
     441           0 :         IsObjectValid();
     442             : 
     443           0 :         FillTableInfo();
     444             : 
     445           0 :         if ( mpTableInfo )
     446             :         {
     447           0 :             SCCOL nCols = mpTableInfo->GetCols();
     448           0 :             SCROW nRows = mpTableInfo->GetRows();
     449           0 :             const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
     450           0 :             const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
     451             : 
     452           0 :             Rectangle aScreenRect(GetBoundingBox());
     453             : 
     454           0 :             awt::Point aMovedPoint = aPoint;
     455           0 :             aMovedPoint.X += aScreenRect.Left();
     456           0 :             aMovedPoint.Y += aScreenRect.Top();
     457             : 
     458           0 :             if ( nCols > 0 && nRows > 0 && aMovedPoint.X >= pColInfo[0].nPixelStart && aMovedPoint.Y >= pRowInfo[0].nPixelStart )
     459             :             {
     460           0 :                 SCCOL nColIndex = 0;
     461           0 :                 while ( nColIndex < nCols && aMovedPoint.X > pColInfo[nColIndex].nPixelEnd )
     462           0 :                     ++nColIndex;
     463           0 :                 SCROW nRowIndex = 0;
     464           0 :                 while ( nRowIndex < nRows && aMovedPoint.Y > pRowInfo[nRowIndex].nPixelEnd )
     465           0 :                     ++nRowIndex;
     466           0 :                 if ( nColIndex < nCols && nRowIndex < nRows )
     467             :                 {
     468             :                     try
     469             :                     {
     470           0 :                         xRet = getAccessibleCellAt( nRowIndex, nColIndex );
     471             :                     }
     472           0 :                     catch (uno::Exception&)
     473             :                     {
     474             :                     }
     475             :                 }
     476             :             }
     477           0 :         }
     478             :     }
     479             : 
     480           0 :     return xRet;
     481             : }
     482             : 
     483           2 : void SAL_CALL ScAccessiblePreviewTable::grabFocus() throw (uno::RuntimeException, std::exception)
     484             : {
     485           2 :      SolarMutexGuard aGuard;
     486           2 :     IsObjectValid();
     487           2 :     if (getAccessibleParent().is())
     488             :     {
     489           2 :         uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
     490           2 :         if (xAccessibleComponent.is())
     491           2 :             xAccessibleComponent->grabFocus();
     492           2 :     }
     493           2 : }
     494             : 
     495             : //=====  XAccessibleContext  ==============================================
     496             : 
     497          38 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleChildCount()
     498             :     throw (uno::RuntimeException, std::exception)
     499             : {
     500          38 :     SolarMutexGuard aGuard;
     501          38 :     IsObjectValid();
     502             : 
     503          38 :     FillTableInfo();
     504             : 
     505          38 :     long nRet = 0;
     506          38 :     if ( mpTableInfo )
     507          38 :         nRet = static_cast<sal_Int32>(mpTableInfo->GetCols()) * mpTableInfo->GetRows();
     508          38 :     return nRet;
     509             : }
     510             : 
     511          19 : uno::Reference< XAccessible > SAL_CALL ScAccessiblePreviewTable::getAccessibleChild( sal_Int32 nIndex )
     512             :     throw (lang::IndexOutOfBoundsException, uno::RuntimeException, std::exception)
     513             : {
     514          19 :     SolarMutexGuard aGuard;
     515          19 :     IsObjectValid();
     516             : 
     517          19 :     FillTableInfo();
     518             : 
     519          19 :     uno::Reference<XAccessible> xRet;
     520          19 :     if ( mpTableInfo )
     521             :     {
     522          19 :         long nColumns = mpTableInfo->GetCols();
     523          19 :         if ( nColumns > 0 )
     524             :         {
     525             :             // nCol, nRow are within the visible table, not the document
     526          19 :             long nCol = nIndex % nColumns;
     527          19 :             long nRow = nIndex / nColumns;
     528             : 
     529          19 :             xRet = getAccessibleCellAt( nRow, nCol );
     530             :         }
     531             :     }
     532             : 
     533          19 :     if ( !xRet.is() )
     534           0 :         throw lang::IndexOutOfBoundsException();
     535             : 
     536          19 :     return xRet;
     537             : }
     538             : 
     539           1 : sal_Int32 SAL_CALL ScAccessiblePreviewTable::getAccessibleIndexInParent() throw (uno::RuntimeException, std::exception)
     540             : {
     541           1 :     return mnIndex;
     542             : }
     543             : 
     544          40 : uno::Reference< XAccessibleStateSet > SAL_CALL ScAccessiblePreviewTable::getAccessibleStateSet()
     545             :                                 throw (uno::RuntimeException, std::exception)
     546             : {
     547          40 :     SolarMutexGuard aGuard;
     548          80 :     uno::Reference<XAccessibleStateSet> xParentStates;
     549          40 :     if (getAccessibleParent().is())
     550             :     {
     551          40 :         uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
     552          40 :         xParentStates = xParentContext->getAccessibleStateSet();
     553             :     }
     554          40 :     utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
     555          40 :     if (IsDefunc(xParentStates))
     556           0 :         pStateSet->AddState(AccessibleStateType::DEFUNC);
     557             :     else
     558             :     {
     559          40 :         pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
     560          40 :         pStateSet->AddState(AccessibleStateType::ENABLED);
     561          40 :         pStateSet->AddState(AccessibleStateType::OPAQUE);
     562          40 :         if (isShowing())
     563          40 :             pStateSet->AddState(AccessibleStateType::SHOWING);
     564          40 :         if (isVisible())
     565          40 :             pStateSet->AddState(AccessibleStateType::VISIBLE);
     566             :     }
     567          80 :     return pStateSet;
     568             : }
     569             : 
     570             : //=====  XServiceInfo  ====================================================
     571             : 
     572           1 : OUString SAL_CALL ScAccessiblePreviewTable::getImplementationName() throw(uno::RuntimeException, std::exception)
     573             : {
     574           1 :     return OUString("ScAccessiblePreviewTable");
     575             : }
     576             : 
     577           0 : uno::Sequence<OUString> SAL_CALL ScAccessiblePreviewTable::getSupportedServiceNames()
     578             :                                                     throw(uno::RuntimeException, std::exception)
     579             : {
     580           0 :     uno::Sequence< OUString > aSequence = ScAccessibleContextBase::getSupportedServiceNames();
     581           0 :     sal_Int32 nOldSize(aSequence.getLength());
     582           0 :     aSequence.realloc(nOldSize + 1);
     583             : 
     584           0 :     aSequence[nOldSize] = "com.sun.star.table.AccessibleTableView";
     585             : 
     586           0 :     return aSequence;
     587             : }
     588             : 
     589             : //=====  XTypeProvider  ===================================================
     590             : 
     591           0 : uno::Sequence< uno::Type > SAL_CALL ScAccessiblePreviewTable::getTypes()
     592             :         throw (uno::RuntimeException, std::exception)
     593             : {
     594           0 :     return comphelper::concatSequences(ScAccessiblePreviewTableImpl::getTypes(), ScAccessibleContextBase::getTypes());
     595             : }
     596             : 
     597           0 : uno::Sequence<sal_Int8> SAL_CALL ScAccessiblePreviewTable::getImplementationId()
     598             :                                                     throw(uno::RuntimeException, std::exception)
     599             : {
     600           0 :     return css::uno::Sequence<sal_Int8>();
     601             : }
     602             : 
     603             : //====  internal  =========================================================
     604             : 
     605          32 : OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleDescription(void)
     606             :                     throw (uno::RuntimeException)
     607             : {
     608          32 :     OUString sDesc(ScResId(STR_ACC_TABLE_DESCR));
     609          32 :     return sDesc;
     610             : }
     611             : 
     612          15 : OUString SAL_CALL ScAccessiblePreviewTable::createAccessibleName()
     613             :     throw (uno::RuntimeException, std::exception)
     614             : {
     615          15 :     OUString sName(SC_RESSTR(STR_ACC_TABLE_NAME));
     616             : 
     617          15 :     if (mpViewShell && mpViewShell->GetDocument())
     618             :     {
     619          15 :         FillTableInfo();
     620             : 
     621          15 :         if ( mpTableInfo )
     622             :         {
     623          15 :             OUString sCoreName;
     624          15 :             if (mpViewShell->GetDocument()->GetName( mpTableInfo->GetTab(), sCoreName ))
     625          15 :                 sName = sName.replaceFirst("%1", sCoreName);
     626             :         }
     627             :     }
     628             : 
     629          15 :     return sName;
     630             : }
     631             : 
     632           2 : Rectangle ScAccessiblePreviewTable::GetBoundingBoxOnScreen() const throw (uno::RuntimeException, std::exception)
     633             : {
     634           2 :     Rectangle aCellRect(GetBoundingBox());
     635           2 :     if (mpViewShell)
     636             :     {
     637           2 :         Window* pWindow = mpViewShell->GetWindow();
     638           2 :         if (pWindow)
     639             :         {
     640           2 :             Rectangle aRect = pWindow->GetWindowExtentsRelative(NULL);
     641           2 :             aCellRect.setX(aCellRect.getX() + aRect.getX());
     642           2 :             aCellRect.setY(aCellRect.getY() + aRect.getY());
     643             :         }
     644             :     }
     645           2 :     return aCellRect;
     646             : }
     647             : 
     648         271 : Rectangle ScAccessiblePreviewTable::GetBoundingBox() const
     649             :     throw (uno::RuntimeException, std::exception)
     650             : {
     651         271 :     FillTableInfo();
     652             : 
     653         271 :     Rectangle aRect;
     654         271 :     if ( mpTableInfo )
     655             :     {
     656         271 :         SCCOL nColumns = mpTableInfo->GetCols();
     657         271 :         SCROW nRows = mpTableInfo->GetRows();
     658         271 :         if ( nColumns > 0 && nRows > 0 )
     659             :         {
     660         271 :             const ScPreviewColRowInfo* pColInfo = mpTableInfo->GetColInfo();
     661         271 :             const ScPreviewColRowInfo* pRowInfo = mpTableInfo->GetRowInfo();
     662             : 
     663             :             aRect = Rectangle( pColInfo[0].nPixelStart,
     664             :                                pRowInfo[0].nPixelStart,
     665         271 :                                pColInfo[nColumns-1].nPixelEnd,
     666         542 :                                pRowInfo[nRows-1].nPixelEnd );
     667             :         }
     668             :     }
     669         271 :     return aRect;
     670             : }
     671             : 
     672          40 : bool ScAccessiblePreviewTable::IsDefunc( const uno::Reference<XAccessibleStateSet>& rxParentStates )
     673             : {
     674         160 :     return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
     675         160 :         (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
     676             : }
     677             : 
     678         409 : void ScAccessiblePreviewTable::FillTableInfo() const
     679             : {
     680         409 :     if ( mpViewShell && !mpTableInfo )
     681             :     {
     682          15 :         Size aOutputSize;
     683          15 :         Window* pWindow = mpViewShell->GetWindow();
     684          15 :         if ( pWindow )
     685          15 :             aOutputSize = pWindow->GetOutputSizePixel();
     686          15 :         Point aPoint;
     687          15 :         Rectangle aVisRect( aPoint, aOutputSize );
     688             : 
     689          15 :         mpTableInfo = new ScPreviewTableInfo;
     690          15 :         mpViewShell->GetLocationData().GetTableInfo( aVisRect, *mpTableInfo );
     691             :     }
     692         511 : }
     693             : 
     694             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10