LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/Accessibility - AccessibleTableBase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 189 0.0 %
Date: 2012-12-27 Functions: 0 43 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             : #include "AccessibleTableBase.hxx"
      21             : #include "miscuno.hxx"
      22             : #include "document.hxx"
      23             : #include "scresid.hxx"
      24             : #include "sc.hrc"
      25             : 
      26             : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      27             : #include <com/sun/star/accessibility/AccessibleTableModelChange.hpp>
      28             : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      29             : #include <comphelper/sequence.hxx>
      30             : #include <comphelper/servicehelper.hxx>
      31             : #include <vcl/svapp.hxx>
      32             : 
      33             : 
      34             : using namespace ::com::sun::star;
      35             : using namespace ::com::sun::star::accessibility;
      36             : 
      37             : //=====  internal  ============================================================
      38             : 
      39           0 : ScAccessibleTableBase::ScAccessibleTableBase(
      40             :         const uno::Reference<XAccessible>& rxParent,
      41             :         ScDocument* pDoc,
      42             :         const ScRange& rRange)
      43             :     :
      44             :     ScAccessibleContextBase (rxParent, AccessibleRole::TABLE),
      45             :     maRange(rRange),
      46           0 :     mpDoc(pDoc)
      47             : {
      48           0 : }
      49             : 
      50           0 : ScAccessibleTableBase::~ScAccessibleTableBase()
      51             : {
      52           0 : }
      53             : 
      54           0 : void SAL_CALL ScAccessibleTableBase::disposing()
      55             : {
      56           0 :     SolarMutexGuard aGuard;
      57           0 :     mpDoc = NULL;
      58             : 
      59           0 :     ScAccessibleContextBase::disposing();
      60           0 : }
      61             : 
      62             :     //=====  XInterface  =====================================================
      63             : 
      64           0 : uno::Any SAL_CALL ScAccessibleTableBase::queryInterface( uno::Type const & rType )
      65             :     throw (uno::RuntimeException)
      66             : {
      67           0 :     uno::Any aAny (ScAccessibleTableBaseImpl::queryInterface(rType));
      68           0 :     return aAny.hasValue() ? aAny : ScAccessibleContextBase::queryInterface(rType);
      69             : }
      70             : 
      71           0 : void SAL_CALL ScAccessibleTableBase::acquire()
      72             :     throw ()
      73             : {
      74           0 :     ScAccessibleContextBase::acquire();
      75           0 : }
      76             : 
      77           0 : void SAL_CALL ScAccessibleTableBase::release()
      78             :     throw ()
      79             : {
      80           0 :     ScAccessibleContextBase::release();
      81           0 : }
      82             : 
      83             :     //=====  XAccessibleTable  ================================================
      84             : 
      85           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowCount(  )
      86             :                     throw (uno::RuntimeException)
      87             : {
      88           0 :     SolarMutexGuard aGuard;
      89           0 :     IsObjectValid();
      90           0 :     return maRange.aEnd.Row() - maRange.aStart.Row() + 1;
      91             : }
      92             : 
      93           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnCount(  )
      94             :                     throw (uno::RuntimeException)
      95             : {
      96           0 :     SolarMutexGuard aGuard;
      97           0 :     IsObjectValid();
      98           0 :     return maRange.aEnd.Col() - maRange.aStart.Col() + 1;
      99             : }
     100             : 
     101           0 : ::rtl::OUString SAL_CALL ScAccessibleTableBase::getAccessibleRowDescription( sal_Int32 nRow )
     102             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     103             : {
     104             :     OSL_FAIL("Here should be a implementation to fill the description");
     105             : 
     106           0 :     if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
     107           0 :         throw lang::IndexOutOfBoundsException();
     108             : 
     109             :     //setAccessibleRowDescription(nRow, xAccessible); // to remember the created Description
     110           0 :     return rtl::OUString();
     111             : }
     112             : 
     113           0 : ::rtl::OUString SAL_CALL ScAccessibleTableBase::getAccessibleColumnDescription( sal_Int32 nColumn )
     114             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     115             : {
     116             :     OSL_FAIL("Here should be a implementation to fill the description");
     117             : 
     118           0 :     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0))
     119           0 :         throw lang::IndexOutOfBoundsException();
     120             : 
     121             :     //setAccessibleColumnDescription(nColumn, xAccessible); // to remember the created Description
     122           0 :     return rtl::OUString();
     123             : }
     124             : 
     125           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRowExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
     126             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     127             : {
     128           0 :     SolarMutexGuard aGuard;
     129           0 :     IsObjectValid();
     130             : 
     131           0 :     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
     132           0 :         (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
     133           0 :         throw lang::IndexOutOfBoundsException();
     134             : 
     135           0 :     sal_Int32 nCount(1); // the same cell
     136           0 :     nRow += maRange.aStart.Row();
     137           0 :     nColumn += maRange.aStart.Col();
     138             : 
     139           0 :     if (mpDoc)
     140             :     {
     141           0 :         SCROW nEndRow(0);
     142           0 :         SCCOL nEndCol(0);
     143           0 :         if (mpDoc->ExtendMerge(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow),
     144           0 :             nEndCol, nEndRow, maRange.aStart.Tab()))
     145             :         {
     146           0 :             if (nEndRow > nRow)
     147           0 :                 nCount = nEndRow - nRow + 1;
     148             :         }
     149             :     }
     150             : 
     151           0 :     return nCount;
     152             : }
     153             : 
     154           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumnExtentAt( sal_Int32 nRow, sal_Int32 nColumn )
     155             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     156             : {
     157           0 :     SolarMutexGuard aGuard;
     158           0 :     IsObjectValid();
     159             : 
     160           0 :     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
     161           0 :         (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
     162           0 :         throw lang::IndexOutOfBoundsException();
     163             : 
     164           0 :     sal_Int32 nCount(1); // the same cell
     165           0 :     nRow += maRange.aStart.Row();
     166           0 :     nColumn += maRange.aStart.Col();
     167             : 
     168           0 :     if (mpDoc)
     169             :     {
     170           0 :         SCROW nEndRow(0);
     171           0 :         SCCOL nEndCol(0);
     172           0 :         if (mpDoc->ExtendMerge(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow),
     173           0 :             nEndCol, nEndRow, maRange.aStart.Tab()))
     174             :         {
     175           0 :             if (nEndCol > nColumn)
     176           0 :                 nCount = nEndCol - nColumn + 1;
     177             :         }
     178             :     }
     179             : 
     180           0 :     return nCount;
     181             : }
     182             : 
     183           0 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleTableBase::getAccessibleRowHeaders(  )
     184             :                     throw (uno::RuntimeException)
     185             : {
     186           0 :     uno::Reference< XAccessibleTable > xAccessibleTable;
     187             :     OSL_FAIL("Here should be a implementation to fill the row headers");
     188             : 
     189             :     //CommitChange
     190           0 :     return xAccessibleTable;
     191             : }
     192             : 
     193           0 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleTableBase::getAccessibleColumnHeaders(  )
     194             :                     throw (uno::RuntimeException)
     195             : {
     196           0 :     uno::Reference< XAccessibleTable > xAccessibleTable;
     197             :     OSL_FAIL("Here should be a implementation to fill the column headers");
     198             : 
     199             :     //CommitChange
     200           0 :     return xAccessibleTable;
     201             : }
     202             : 
     203           0 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleTableBase::getSelectedAccessibleRows(  )
     204             :                     throw (uno::RuntimeException)
     205             : {
     206             :     OSL_FAIL("not implemented yet");
     207           0 :     uno::Sequence< sal_Int32 > aSequence;
     208           0 :     return aSequence;
     209             : }
     210             : 
     211           0 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleTableBase::getSelectedAccessibleColumns(  )
     212             :                     throw (uno::RuntimeException)
     213             : {
     214             :     OSL_FAIL("not implemented yet");
     215           0 :     uno::Sequence< sal_Int32 > aSequence;
     216           0 :     return aSequence;
     217             : }
     218             : 
     219           0 : sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleRowSelected( sal_Int32 /* nRow */ )
     220             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     221             : {
     222             :     OSL_FAIL("not implemented yet");
     223           0 :     return false;
     224             : }
     225             : 
     226           0 : sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleColumnSelected( sal_Int32 /* nColumn */ )
     227             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     228             : {
     229             :     OSL_FAIL("not implemented yet");
     230           0 :     return false;
     231             : }
     232             : 
     233           0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleCellAt( sal_Int32 /* nRow */, sal_Int32 /* nColumn */ )
     234             :                     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     235             : {
     236             :     OSL_FAIL("not implemented yet");
     237           0 :     uno::Reference< XAccessible > xAccessible;
     238           0 :     return xAccessible;
     239             : }
     240             : 
     241           0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleCaption(  )
     242             :                     throw (uno::RuntimeException)
     243             : {
     244             :     OSL_FAIL("not implemented yet");
     245           0 :     uno::Reference< XAccessible > xAccessible;
     246           0 :     return xAccessible;
     247             : }
     248             : 
     249           0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleTableBase::getAccessibleSummary(  )
     250             :                     throw (uno::RuntimeException)
     251             : {
     252             :     OSL_FAIL("not implemented yet");
     253           0 :     uno::Reference< XAccessible > xAccessible;
     254           0 :     return xAccessible;
     255             : }
     256             : 
     257           0 : sal_Bool SAL_CALL ScAccessibleTableBase::isAccessibleSelected( sal_Int32 /* nRow */, sal_Int32 /* nColumn */ )
     258             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     259             : {
     260             :     OSL_FAIL("not implemented yet");
     261           0 :     return false;
     262             : }
     263             : 
     264             : // =====  XAccessibleExtendedTable  ========================================
     265             : 
     266           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleIndex( sal_Int32 nRow, sal_Int32 nColumn )
     267             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     268             : {
     269           0 :     SolarMutexGuard aGuard;
     270           0 :     IsObjectValid();
     271             : 
     272           0 :     if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) ||
     273             :         nRow < 0 ||
     274           0 :         nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) ||
     275             :         nColumn < 0)
     276           0 :         throw lang::IndexOutOfBoundsException();
     277             : 
     278           0 :     nRow -= maRange.aStart.Row();
     279           0 :     nColumn -= maRange.aStart.Col();
     280           0 :     return (nRow * (maRange.aEnd.Col() + 1)) + nColumn;
     281             : }
     282             : 
     283           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleRow( sal_Int32 nChildIndex )
     284             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     285             : {
     286           0 :     SolarMutexGuard aGuard;
     287           0 :     IsObjectValid();
     288             : 
     289           0 :     if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0)
     290           0 :         throw lang::IndexOutOfBoundsException();
     291             : 
     292           0 :     return nChildIndex / (maRange.aEnd.Col() - maRange.aStart.Col() + 1);
     293             : }
     294             : 
     295           0 : sal_Int32 SAL_CALL ScAccessibleTableBase::getAccessibleColumn( sal_Int32 nChildIndex )
     296             :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     297             : {
     298           0 :     SolarMutexGuard aGuard;
     299           0 :     IsObjectValid();
     300             : 
     301           0 :     if (nChildIndex >= getAccessibleChildCount() || nChildIndex < 0)
     302           0 :         throw lang::IndexOutOfBoundsException();
     303             : 
     304           0 :     return nChildIndex % static_cast<sal_Int32>(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
     305             : }
     306             : 
     307             : // =====  XAccessibleContext  ==============================================
     308             : 
     309             : sal_Int32 SAL_CALL
     310           0 :     ScAccessibleTableBase::getAccessibleChildCount(void)
     311             :                     throw (uno::RuntimeException)
     312             : {
     313           0 :     SolarMutexGuard aGuard;
     314           0 :     IsObjectValid();
     315             : 
     316             :     // FIXME: representing rows & columns this way is a plain and simple madness.
     317             :     // this needs a radical re-think.
     318           0 :     sal_Int64 nMax = ((sal_Int64)(maRange.aEnd.Row() - maRange.aStart.Row() + 1) *
     319           0 :                       (sal_Int64)(maRange.aEnd.Col() - maRange.aStart.Col() + 1));
     320           0 :     if (nMax > SAL_MAX_INT32)
     321           0 :         nMax = SAL_MAX_INT32;
     322           0 :     if (nMax < 0)
     323           0 :         return 0;
     324           0 :     return static_cast<sal_Int32>(nMax);
     325             : }
     326             : 
     327             : uno::Reference< XAccessible > SAL_CALL
     328           0 :     ScAccessibleTableBase::getAccessibleChild(sal_Int32 nIndex)
     329             :         throw (uno::RuntimeException,
     330             :         lang::IndexOutOfBoundsException)
     331             : {
     332           0 :     SolarMutexGuard aGuard;
     333           0 :     IsObjectValid();
     334             : 
     335           0 :     if (nIndex >= getAccessibleChildCount() || nIndex < 0)
     336           0 :         throw lang::IndexOutOfBoundsException();
     337             : 
     338             :     // FIXME: representing rows & columns this way is a plain and simple madness.
     339             :     // this needs a radical re-think.
     340             : 
     341           0 :     sal_Int32 nRow(0);
     342           0 :     sal_Int32 nColumn(0);
     343           0 :     sal_Int32 nTemp(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
     344           0 :     nRow = nIndex / nTemp;
     345           0 :     nColumn = nIndex % nTemp;
     346           0 :     return getAccessibleCellAt(nRow, nColumn);
     347             : }
     348             : 
     349             : ::rtl::OUString SAL_CALL
     350           0 :     ScAccessibleTableBase::createAccessibleDescription(void)
     351             :     throw (uno::RuntimeException)
     352             : {
     353           0 :     String sDesc(ScResId(STR_ACC_TABLE_DESCR));
     354           0 :     return rtl::OUString(sDesc);
     355             : }
     356             : 
     357             : ::rtl::OUString SAL_CALL
     358           0 :     ScAccessibleTableBase::createAccessibleName(void)
     359             :     throw (uno::RuntimeException)
     360             : {
     361           0 :     String sName(ScResId(STR_ACC_TABLE_NAME));
     362           0 :     rtl::OUString sCoreName;
     363           0 :     if (mpDoc && mpDoc->GetName( maRange.aStart.Tab(), sCoreName ))
     364           0 :         sName.SearchAndReplaceAscii("%1", sCoreName);
     365           0 :     return rtl::OUString(sName);
     366             : }
     367             : 
     368             : uno::Reference<XAccessibleRelationSet> SAL_CALL
     369           0 :     ScAccessibleTableBase::getAccessibleRelationSet(void)
     370             :     throw (uno::RuntimeException)
     371             : {
     372             :     OSL_FAIL("should be implemented in the abrevated class");
     373           0 :     return uno::Reference<XAccessibleRelationSet>();
     374             : }
     375             : 
     376             : uno::Reference<XAccessibleStateSet> SAL_CALL
     377           0 :     ScAccessibleTableBase::getAccessibleStateSet(void)
     378             :     throw (uno::RuntimeException)
     379             : {
     380             :     OSL_FAIL("should be implemented in the abrevated class");
     381           0 :     uno::Reference< XAccessibleStateSet > xAccessibleStateSet;
     382           0 :     return xAccessibleStateSet;
     383             : }
     384             : 
     385             :     ///=====  XAccessibleSelection  ===========================================
     386             : 
     387             : void SAL_CALL
     388           0 :         ScAccessibleTableBase::selectAccessibleChild( sal_Int32 /* nChildIndex */ )
     389             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     390             : {
     391           0 : }
     392             : 
     393             : sal_Bool SAL_CALL
     394           0 :         ScAccessibleTableBase::isAccessibleChildSelected( sal_Int32 nChildIndex )
     395             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     396             : {
     397             :     // I don't need to guard, because the called functions have a guard
     398           0 :     if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
     399           0 :         throw lang::IndexOutOfBoundsException();
     400           0 :     return isAccessibleSelected(getAccessibleRow(nChildIndex), getAccessibleColumn(nChildIndex));
     401             : }
     402             : 
     403             : void SAL_CALL
     404           0 :         ScAccessibleTableBase::clearAccessibleSelection(  )
     405             :         throw (uno::RuntimeException)
     406             : {
     407           0 : }
     408             : 
     409             : void SAL_CALL
     410           0 :         ScAccessibleTableBase::selectAllAccessibleChildren(  )
     411             :         throw (uno::RuntimeException)
     412             : {
     413           0 : }
     414             : 
     415             : sal_Int32 SAL_CALL
     416           0 :         ScAccessibleTableBase::getSelectedAccessibleChildCount(  )
     417             :         throw (uno::RuntimeException)
     418             : {
     419           0 :     sal_Int32 nResult(0);
     420           0 :     return nResult;
     421             : }
     422             : 
     423             : uno::Reference<XAccessible > SAL_CALL
     424           0 :         ScAccessibleTableBase::getSelectedAccessibleChild( sal_Int32 /* nSelectedChildIndex */ )
     425             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     426             : {
     427           0 :     uno::Reference < XAccessible > xAccessible;
     428           0 :     return xAccessible;
     429             : }
     430             : 
     431             : void SAL_CALL
     432           0 :         ScAccessibleTableBase::deselectAccessibleChild( sal_Int32 /* nSelectedChildIndex */ )
     433             :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     434             : {
     435           0 : }
     436             : 
     437             :     //=====  XServiceInfo  ====================================================
     438             : 
     439           0 : ::rtl::OUString SAL_CALL ScAccessibleTableBase::getImplementationName(void)
     440             :         throw (uno::RuntimeException)
     441             : {
     442           0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleTableBase"));
     443             : }
     444             : 
     445             :     //=====  XTypeProvider  ===================================================
     446             : 
     447           0 : uno::Sequence< uno::Type > SAL_CALL ScAccessibleTableBase::getTypes()
     448             :         throw (uno::RuntimeException)
     449             : {
     450           0 :     return comphelper::concatSequences(ScAccessibleTableBaseImpl::getTypes(), ScAccessibleContextBase::getTypes());
     451             : }
     452             : 
     453             : namespace
     454             : {
     455             :     class theScAccessibleTableBaseImplementationId : public rtl::Static< UnoTunnelIdInit, theScAccessibleTableBaseImplementationId > {};
     456             : }
     457             : 
     458             : uno::Sequence<sal_Int8> SAL_CALL
     459           0 :     ScAccessibleTableBase::getImplementationId(void)
     460             :     throw (uno::RuntimeException)
     461             : {
     462           0 :     return theScAccessibleTableBaseImplementationId::get().getSeq();
     463             : }
     464             : 
     465           0 : void ScAccessibleTableBase::CommitTableModelChange(sal_Int32 nStartRow, sal_Int32 nStartCol, sal_Int32 nEndRow, sal_Int32 nEndCol, sal_uInt16 nId)
     466             : {
     467           0 :     AccessibleTableModelChange aModelChange;
     468           0 :     aModelChange.FirstRow = nStartRow;
     469           0 :     aModelChange.FirstColumn = nStartCol;
     470           0 :     aModelChange.LastRow = nEndRow;
     471           0 :     aModelChange.LastColumn = nEndCol;
     472           0 :     aModelChange.Type = nId;
     473             : 
     474           0 :     AccessibleEventObject aEvent;
     475           0 :     aEvent.EventId = AccessibleEventId::TABLE_MODEL_CHANGED;
     476           0 :     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     477           0 :     aEvent.NewValue <<= aModelChange;
     478             : 
     479           0 :     CommitChange(aEvent);
     480           0 : }
     481             : 
     482             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10