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

Generated by: LCOV version 1.10