LCOV - code coverage report
Current view: top level - sc/source/ui/Accessibility - AccessibleSpreadsheet.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 211 504 41.9 %
Date: 2012-08-25 Functions: 22 49 44.9 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 194 898 21.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "AccessibleSpreadsheet.hxx"
      30                 :            : #include "AccessibilityHints.hxx"
      31                 :            : #include "AccessibleCell.hxx"
      32                 :            : #include "AccessibleDocument.hxx"
      33                 :            : #include "tabvwsh.hxx"
      34                 :            : #include "document.hxx"
      35                 :            : #include "hints.hxx"
      36                 :            : #include "scmod.hxx"
      37                 :            : #include "markdata.hxx"
      38                 :            : 
      39                 :            : #include <unotools/accessiblestatesethelper.hxx>
      40                 :            : #include <com/sun/star/accessibility/AccessibleRole.hpp>
      41                 :            : #include <com/sun/star/accessibility/AccessibleStateType.hpp>
      42                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      43                 :            : #include <com/sun/star/accessibility/AccessibleTableModelChangeType.hpp>
      44                 :            : #include <comphelper/servicehelper.hxx>
      45                 :            : #include <tools/gen.hxx>
      46                 :            : #include <svtools/colorcfg.hxx>
      47                 :            : #include <vcl/svapp.hxx>
      48                 :            : 
      49                 :            : #include <algorithm>
      50                 :            : 
      51                 :            : using namespace ::com::sun::star;
      52                 :            : using namespace ::com::sun::star::accessibility;
      53                 :            : 
      54                 :            : //=====  internal  ============================================================
      55                 :            : 
      56                 :          5 : ScAccessibleSpreadsheet::ScAccessibleSpreadsheet(
      57                 :            :         ScAccessibleDocument* pAccDoc,
      58                 :            :         ScTabViewShell* pViewShell,
      59                 :            :         SCTAB nTab,
      60                 :            :         ScSplitPos eSplitPos)
      61                 :            :     :
      62                 :            :     ScAccessibleTableBase (pAccDoc, GetDocument(pViewShell),
      63                 :            :         ScRange(ScAddress(0, 0, nTab),ScAddress(MAXCOL, MAXROW, nTab))),
      64 [ +  - ][ +  - ]:          5 :     mbIsSpreadsheet( sal_True )
         [ +  - ][ +  - ]
                 [ +  - ]
      65                 :            : {
      66         [ +  - ]:          5 :     ConstructScAccessibleSpreadsheet( pAccDoc, pViewShell, nTab, eSplitPos );
      67                 :          5 : }
      68                 :            : 
      69                 :          0 : ScAccessibleSpreadsheet::ScAccessibleSpreadsheet(
      70                 :            :         ScAccessibleSpreadsheet& rParent, const ScRange& rRange ) :
      71                 :            :     ScAccessibleTableBase( rParent.mpAccDoc, rParent.mpDoc, rRange),
      72 [ #  # ][ #  # ]:          0 :     mbIsSpreadsheet( false )
                 [ #  # ]
      73                 :            : {
      74         [ #  # ]:          0 :     ConstructScAccessibleSpreadsheet( rParent.mpAccDoc, rParent.mpViewShell, rParent.mnTab, rParent.meSplitPos );
      75                 :          0 : }
      76                 :            : 
      77                 :          5 : ScAccessibleSpreadsheet::~ScAccessibleSpreadsheet()
      78                 :            : {
      79         [ -  + ]:          5 :     if (mpMarkedRanges)
      80 [ #  # ][ #  # ]:          0 :         delete mpMarkedRanges;
      81         [ -  + ]:          5 :     if (mpSortedMarkedCells)
      82         [ #  # ]:          0 :         delete mpSortedMarkedCells;
      83         [ -  + ]:          5 :     if (mpViewShell)
      84         [ #  # ]:          0 :         mpViewShell->RemoveAccessibilityObject(*this);
      85         [ -  + ]:         10 : }
      86                 :            : 
      87                 :          5 : void ScAccessibleSpreadsheet::ConstructScAccessibleSpreadsheet(
      88                 :            :     ScAccessibleDocument* pAccDoc,
      89                 :            :     ScTabViewShell* pViewShell,
      90                 :            :     SCTAB nTab,
      91                 :            :     ScSplitPos eSplitPos)
      92                 :            : {
      93                 :          5 :     mpViewShell = pViewShell;
      94                 :          5 :     mpMarkedRanges = 0;
      95                 :          5 :     mpSortedMarkedCells = 0;
      96                 :          5 :     mpAccDoc = pAccDoc;
      97                 :          5 :     mpAccCell = 0;
      98                 :          5 :     meSplitPos = eSplitPos;
      99                 :          5 :     mnTab = nTab;
     100                 :          5 :     mbHasSelection = false;
     101                 :          5 :     mbDelIns = false;
     102                 :          5 :     mbIsFocusSend = false;
     103         [ +  - ]:          5 :     maVisCells = GetVisCells(GetVisArea(mpViewShell, meSplitPos));
     104         [ +  - ]:          5 :     if (mpViewShell)
     105                 :            :     {
     106                 :          5 :         mpViewShell->AddAccessibilityObject(*this);
     107                 :            : 
     108                 :          5 :         const ScViewData& rViewData = *mpViewShell->GetViewData();
     109                 :          5 :         const ScMarkData& rMarkData = rViewData.GetMarkData();
     110                 :          5 :         maActiveCell = rViewData.GetCurPos();
     111                 :          5 :         mbHasSelection = rMarkData.GetTableSelect(maActiveCell.Tab()) &&
     112 [ +  - ][ -  + ]:          5 :                     (rMarkData.IsMarked() || rMarkData.IsMultiMarked());
                 [ +  - ]
     113                 :          5 :         mpAccCell = GetAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col());
     114                 :          5 :         mpAccCell->acquire();
     115                 :          5 :         mpAccCell->Init();
     116                 :            :     }
     117                 :          5 : }
     118                 :            : 
     119                 :          5 : void SAL_CALL ScAccessibleSpreadsheet::disposing()
     120                 :            : {
     121         [ +  - ]:          5 :     SolarMutexGuard aGuard;
     122         [ +  - ]:          5 :     if (mpViewShell)
     123                 :            :     {
     124         [ +  - ]:          5 :         mpViewShell->RemoveAccessibilityObject(*this);
     125                 :          5 :         mpViewShell = NULL;
     126                 :            :     }
     127         [ +  - ]:          5 :     if (mpAccCell)
     128                 :            :     {
     129                 :          5 :         mpAccCell->release();
     130                 :          5 :         mpAccCell = NULL;
     131                 :            :     }
     132                 :            : 
     133 [ +  - ][ +  - ]:          5 :     ScAccessibleTableBase::disposing();
     134                 :          5 : }
     135                 :            : 
     136                 :          0 : void ScAccessibleSpreadsheet::CompleteSelectionChanged(sal_Bool bNewState)
     137                 :            : {
     138         [ #  # ]:          0 :     if (mpMarkedRanges)
     139 [ #  # ][ #  # ]:          0 :         DELETEZ(mpMarkedRanges);
     140         [ #  # ]:          0 :     if (mpSortedMarkedCells)
     141         [ #  # ]:          0 :         DELETEZ(mpSortedMarkedCells);
     142                 :            : 
     143                 :          0 :     mbHasSelection = bNewState;
     144                 :            : 
     145         [ #  # ]:          0 :     AccessibleEventObject aEvent;
     146                 :          0 :     aEvent.EventId = AccessibleEventId::STATE_CHANGED;
     147         [ #  # ]:          0 :     if (bNewState)
     148         [ #  # ]:          0 :         aEvent.NewValue = uno::makeAny(AccessibleStateType::SELECTED);
     149                 :            :     else
     150         [ #  # ]:          0 :         aEvent.OldValue = uno::makeAny(AccessibleStateType::SELECTED);
     151 [ #  # ][ #  # ]:          0 :     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     152                 :            : 
     153 [ #  # ][ #  # ]:          0 :     CommitChange(aEvent);
     154                 :          0 : }
     155                 :            : 
     156                 :          5 : void ScAccessibleSpreadsheet::LostFocus()
     157                 :            : {
     158         [ +  - ]:          5 :     AccessibleEventObject aEvent;
     159                 :          5 :     aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
     160 [ +  - ][ +  - ]:          5 :     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     161 [ +  - ][ +  - ]:          5 :     uno::Reference< XAccessible > xOld = mpAccCell;
     162         [ +  - ]:          5 :     aEvent.OldValue <<= xOld;
     163                 :            : 
     164         [ +  - ]:          5 :     CommitChange(aEvent);
     165                 :            : 
     166 [ +  - ][ +  - ]:          5 :     CommitFocusLost();
     167                 :          5 : }
     168                 :            : 
     169                 :          0 : void ScAccessibleSpreadsheet::GotFocus()
     170                 :            : {
     171         [ #  # ]:          0 :     CommitFocusGained();
     172                 :            : 
     173         [ #  # ]:          0 :     AccessibleEventObject aEvent;
     174                 :          0 :     aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
     175 [ #  # ][ #  # ]:          0 :     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     176 [ #  # ][ #  # ]:          0 :     uno::Reference< XAccessible > xNew = mpAccCell;
     177         [ #  # ]:          0 :     aEvent.NewValue <<= xNew;
     178                 :            : 
     179 [ #  # ][ #  # ]:          0 :     CommitChange(aEvent);
     180                 :          0 : }
     181                 :            : 
     182                 :          0 : void ScAccessibleSpreadsheet::BoundingBoxChanged()
     183                 :            : {
     184         [ #  # ]:          0 :     AccessibleEventObject aEvent;
     185                 :          0 :     aEvent.EventId = AccessibleEventId::BOUNDRECT_CHANGED;
     186 [ #  # ][ #  # ]:          0 :     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     187                 :            : 
     188 [ #  # ][ #  # ]:          0 :     CommitChange(aEvent);
     189                 :          0 : }
     190                 :            : 
     191                 :          0 : void ScAccessibleSpreadsheet::VisAreaChanged()
     192                 :            : {
     193         [ #  # ]:          0 :     AccessibleEventObject aEvent;
     194                 :          0 :     aEvent.EventId = AccessibleEventId::VISIBLE_DATA_CHANGED;
     195 [ #  # ][ #  # ]:          0 :     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     196                 :            : 
     197 [ #  # ][ #  # ]:          0 :     CommitChange(aEvent);
     198                 :          0 : }
     199                 :            : 
     200                 :            :     //=====  SfxListener  =====================================================
     201                 :            : 
     202                 :         29 : void ScAccessibleSpreadsheet::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
     203                 :            : {
     204         [ +  + ]:         29 :     if (rHint.ISA( SfxSimpleHint ) )
     205                 :            :     {
     206                 :         24 :         const SfxSimpleHint& rRef = (const SfxSimpleHint&)rHint;
     207                 :            :         // only notify if child exist, otherwise it is not necessary
     208         [ +  + ]:         24 :         if ((rRef.GetId() == SC_HINT_ACC_CURSORCHANGED))
     209                 :            :         {
     210         [ +  - ]:          2 :             if (mpViewShell)
     211                 :            :             {
     212         [ +  - ]:          2 :                 ScAddress aNewCell = mpViewShell->GetViewData()->GetCurPos();
     213 [ +  - ][ +  - ]:          2 :                 sal_Bool bNewMarked(mpViewShell->GetViewData()->GetMarkData().GetTableSelect(aNewCell.Tab()) &&
     214         [ +  - ]:          2 :                     (mpViewShell->GetViewData()->GetMarkData().IsMarked() ||
     215   [ +  -  +  - ]:          4 :                     mpViewShell->GetViewData()->GetMarkData().IsMultiMarked()));
         [ +  - ][ -  + ]
     216         [ +  - ]:          2 :                 sal_Bool bNewCellSelected(isAccessibleSelected(aNewCell.Row(), aNewCell.Col()));
     217 [ +  - ][ +  - ]:          2 :                 if ((bNewMarked != mbHasSelection) ||
         [ +  - ][ -  + ]
                 [ #  # ]
     218                 :            :                     (!bNewCellSelected && bNewMarked) ||
     219                 :            :                     (bNewCellSelected && mbHasSelection))
     220                 :            :                 {
     221         [ #  # ]:          0 :                     if (mpMarkedRanges)
     222 [ #  # ][ #  # ]:          0 :                         DELETEZ(mpMarkedRanges);
     223         [ #  # ]:          0 :                     if (mpSortedMarkedCells)
     224         [ #  # ]:          0 :                         DELETEZ(mpSortedMarkedCells);
     225         [ #  # ]:          0 :                     AccessibleEventObject aEvent;
     226                 :          0 :                     aEvent.EventId = AccessibleEventId::SELECTION_CHANGED;
     227 [ #  # ][ #  # ]:          0 :                     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     228                 :            : 
     229                 :          0 :                     mbHasSelection = bNewMarked;
     230                 :            : 
     231 [ #  # ][ #  # ]:          0 :                     CommitChange(aEvent);
     232                 :            :                 }
     233                 :            : 
     234                 :            :                 // active descendant changed event (new cell selected)
     235                 :          2 :                 bool bFireActiveDescChanged = (aNewCell != maActiveCell) &&
     236 [ +  - ][ +  - ]:          2 :                     (aNewCell.Tab() == maActiveCell.Tab()) && IsFocused();
         [ +  - ][ +  - ]
     237                 :            : 
     238                 :            :                 /*  Remember old active cell and set new active cell.
     239                 :            :                     #i82409# always update the class members mpAccCell and
     240                 :            :                     maActiveCell, even if the sheet is not focused, e.g. when
     241                 :            :                     using the name box in the toolbar. */
     242 [ +  - ][ +  - ]:          2 :                 uno::Reference< XAccessible > xOld = mpAccCell;
     243                 :          2 :                 mpAccCell->release();
     244         [ +  - ]:          2 :                 mpAccCell = GetAccessibleCellAt(aNewCell.Row(), aNewCell.Col());
     245                 :          2 :                 mpAccCell->acquire();
     246         [ +  - ]:          2 :                 mpAccCell->Init();
     247 [ +  - ][ +  - ]:          2 :                 uno::Reference< XAccessible > xNew = mpAccCell;
     248                 :          2 :                 maActiveCell = aNewCell;
     249                 :            : 
     250                 :            :                 // #i14108# fire event only if sheet is focused
     251         [ +  - ]:          2 :                 if( bFireActiveDescChanged )
     252                 :            :                 {
     253         [ +  - ]:          2 :                     AccessibleEventObject aEvent;
     254                 :          2 :                     aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
     255 [ +  - ][ +  - ]:          2 :                     aEvent.Source = uno::Reference< XAccessibleContext >(this);
     256         [ +  - ]:          2 :                     aEvent.OldValue <<= xOld;
     257         [ +  - ]:          2 :                     aEvent.NewValue <<= xNew;
     258 [ +  - ][ +  - ]:          2 :                     CommitChange(aEvent);
     259                 :          2 :                 }
     260                 :            :             }
     261                 :            :         }
     262         [ +  + ]:         22 :         else if ((rRef.GetId() == SC_HINT_DATACHANGED))
     263                 :            :         {
     264         [ +  - ]:         18 :             if (!mbDelIns)
     265                 :         18 :                 CommitTableModelChange(maRange.aStart.Row(), maRange.aStart.Col(), maRange.aEnd.Row(), maRange.aEnd.Col(), AccessibleTableModelChangeType::UPDATE);
     266                 :            :             else
     267                 :          0 :                 mbDelIns = false;
     268                 :            :         }
     269                 :            :         // commented out, because to use a ModelChangeEvent is not the right way
     270                 :            :         // at the moment there is no way, but the Java/Gnome Api should be extended sometime
     271                 :            : /*          if (mpViewShell)
     272                 :            :             {
     273                 :            :                 Rectangle aNewVisCells(GetVisCells(GetVisArea(mpViewShell, meSplitPos)));
     274                 :            : 
     275                 :            :                 Rectangle aNewPos(aNewVisCells);
     276                 :            : 
     277                 :            :                 if (aNewVisCells.IsOver(maVisCells))
     278                 :            :                     aNewPos.Union(maVisCells);
     279                 :            :                 else
     280                 :            :                     CommitTableModelChange(maVisCells.Top(), maVisCells.Left(), maVisCells.Bottom(), maVisCells.Right(), AccessibleTableModelChangeType::UPDATE);
     281                 :            : 
     282                 :            :                 maVisCells = aNewVisCells;
     283                 :            : 
     284                 :            :                 CommitTableModelChange(aNewPos.Top(), aNewPos.Left(), aNewPos.Bottom(), aNewPos.Right(), AccessibleTableModelChangeType::UPDATE);
     285                 :            :             }
     286                 :            :         }*/
     287                 :            :     }
     288         [ -  + ]:          5 :     else if (rHint.ISA( ScUpdateRefHint ))
     289                 :            :     {
     290                 :          0 :         const ScUpdateRefHint& rRef = (const ScUpdateRefHint&)rHint;
     291 [ #  # ][ #  # ]:          0 :         if (rRef.GetMode() == URM_INSDEL && rRef.GetDz() == 0) //test whether table is inserted or deleted
                 [ #  # ]
     292                 :            :         {
     293   [ #  #  #  #  :          0 :             if (((rRef.GetRange().aStart.Col() == maRange.aStart.Col()) &&
             #  #  #  # ]
                 [ #  # ]
     294                 :          0 :                 (rRef.GetRange().aEnd.Col() == maRange.aEnd.Col())) ||
     295                 :          0 :                 ((rRef.GetRange().aStart.Row() == maRange.aStart.Row()) &&
     296                 :          0 :                 (rRef.GetRange().aEnd.Row() == maRange.aEnd.Row())))
     297                 :            :             {
     298                 :            :                 // ignore next SC_HINT_DATACHANGED notification
     299                 :          0 :                 mbDelIns = sal_True;
     300                 :            : 
     301                 :          0 :                 sal_Int16 nId(0);
     302                 :          0 :                 SCsCOL nX(rRef.GetDx());
     303                 :          0 :                 SCsROW nY(rRef.GetDy());
     304                 :          0 :                 ScRange aRange(rRef.GetRange());
     305 [ #  # ][ #  # ]:          0 :                 if ((nX < 0) || (nY < 0))
     306                 :            :                 {
     307                 :            :                     OSL_ENSURE(!((nX < 0) && (nY < 0)), "should not be possible to remove row and column at the same time");
     308                 :          0 :                     nId = AccessibleTableModelChangeType::DELETE;
     309         [ #  # ]:          0 :                     if (nX < 0)
     310                 :            :                     {
     311                 :          0 :                         nX = -nX;
     312                 :          0 :                         nY = aRange.aEnd.Row() - aRange.aStart.Row();
     313                 :            :                     }
     314                 :            :                     else
     315                 :            :                     {
     316                 :          0 :                         nY = -nY;
     317                 :          0 :                         nX = aRange.aEnd.Col() - aRange.aStart.Col();
     318                 :            :                     }
     319                 :            :                 }
     320 [ #  # ][ #  # ]:          0 :                 else if ((nX > 0) || (nY > 0))
     321                 :            :                 {
     322                 :            :                     OSL_ENSURE(!((nX > 0) && (nY > 0)), "should not be possible to add row and column at the same time");
     323                 :          0 :                     nId = AccessibleTableModelChangeType::INSERT;
     324         [ #  # ]:          0 :                     if (nX < 0)
     325                 :          0 :                         nY = aRange.aEnd.Row() - aRange.aStart.Row();
     326                 :            :                     else
     327                 :          0 :                         nX = aRange.aEnd.Col() - aRange.aStart.Col();
     328                 :            :                 }
     329                 :            :                 else
     330                 :            :                 {
     331                 :            :                     OSL_FAIL("is it a deletion or a insertion?");
     332                 :            :                 }
     333                 :            : 
     334                 :          0 :                 CommitTableModelChange(rRef.GetRange().aStart.Row(),
     335                 :          0 :                     rRef.GetRange().aStart.Col(),
     336                 :          0 :                     rRef.GetRange().aStart.Row() + nY,
     337         [ #  # ]:          0 :                     rRef.GetRange().aStart.Col() + nX, nId);
     338                 :            : 
     339         [ #  # ]:          0 :                 AccessibleEventObject aEvent;
     340                 :          0 :                 aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
     341 [ #  # ][ #  # ]:          0 :                 aEvent.Source = uno::Reference< XAccessibleContext >(this);
     342 [ #  # ][ #  # ]:          0 :                 uno::Reference< XAccessible > xNew = mpAccCell;
     343         [ #  # ]:          0 :                 aEvent.NewValue <<= xNew;
     344                 :            : 
     345 [ #  # ][ #  # ]:          0 :                 CommitChange(aEvent);
     346                 :            :             }
     347                 :            :         }
     348                 :            :     }
     349                 :            : 
     350                 :         29 :     ScAccessibleTableBase::Notify(rBC, rHint);
     351                 :         29 : }
     352                 :            : 
     353                 :            :     //=====  XAccessibleTable  ================================================
     354                 :            : 
     355                 :          0 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleRowHeaders(  )
     356                 :            :                     throw (uno::RuntimeException)
     357                 :            : {
     358         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     359         [ #  # ]:          0 :     IsObjectValid();
     360                 :          0 :     uno::Reference< XAccessibleTable > xAccessibleTable;
     361 [ #  # ][ #  # ]:          0 :     if( mpDoc && mbIsSpreadsheet )
     362                 :            :     {
     363 [ #  # ][ #  # ]:          0 :         if( const ScRange* pRowRange = mpDoc->GetRepeatRowRange( mnTab ) )
     364                 :            :         {
     365                 :          0 :             SCROW nStart = pRowRange->aStart.Row();
     366                 :          0 :             SCROW nEnd = pRowRange->aEnd.Row();
     367 [ #  # ][ #  # ]:          0 :             if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXROW) )
                 [ #  # ]
     368 [ #  # ][ #  # ]:          0 :                 xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( 0, nStart, mnTab, MAXCOL, nEnd, mnTab ) ) );
                 [ #  # ]
     369                 :            :         }
     370                 :            :     }
     371         [ #  # ]:          0 :     return xAccessibleTable;
     372                 :            : }
     373                 :            : 
     374                 :          0 : uno::Reference< XAccessibleTable > SAL_CALL ScAccessibleSpreadsheet::getAccessibleColumnHeaders(  )
     375                 :            :                     throw (uno::RuntimeException)
     376                 :            : {
     377         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     378         [ #  # ]:          0 :     IsObjectValid();
     379                 :          0 :     uno::Reference< XAccessibleTable > xAccessibleTable;
     380 [ #  # ][ #  # ]:          0 :     if( mpDoc && mbIsSpreadsheet )
     381                 :            :     {
     382 [ #  # ][ #  # ]:          0 :         if( const ScRange* pColRange = mpDoc->GetRepeatColRange( mnTab ) )
     383                 :            :         {
     384                 :          0 :             SCCOL nStart = pColRange->aStart.Col();
     385                 :          0 :             SCCOL nEnd = pColRange->aEnd.Col();
     386 [ #  # ][ #  # ]:          0 :             if( (0 <= nStart) && (nStart <= nEnd) && (nEnd <= MAXCOL) )
                 [ #  # ]
     387 [ #  # ][ #  # ]:          0 :                 xAccessibleTable.set( new ScAccessibleSpreadsheet( *this, ScRange( nStart, 0, mnTab, nEnd, MAXROW, mnTab ) ) );
                 [ #  # ]
     388                 :            :         }
     389                 :            :     }
     390         [ #  # ]:          0 :     return xAccessibleTable;
     391                 :            : }
     392                 :            : 
     393                 :          0 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleRows(  )
     394                 :            :                     throw (uno::RuntimeException)
     395                 :            : {
     396         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     397         [ #  # ]:          0 :     IsObjectValid();
     398         [ #  # ]:          0 :     uno::Sequence<sal_Int32> aSequence;
     399 [ #  # ][ #  # ]:          0 :     if (mpViewShell && mpViewShell->GetViewData())
                 [ #  # ]
     400                 :            :     {
     401         [ #  # ]:          0 :         aSequence.realloc(maRange.aEnd.Row() - maRange.aStart.Row() + 1);
     402         [ #  # ]:          0 :         const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
     403         [ #  # ]:          0 :         sal_Int32* pSequence = aSequence.getArray();
     404                 :          0 :         sal_Int32 nCount(0);
     405         [ #  # ]:          0 :         for (SCROW i = maRange.aStart.Row(); i <= maRange.aEnd.Row(); ++i)
     406                 :            :         {
     407 [ #  # ][ #  # ]:          0 :             if (rMarkdata.IsRowMarked(i))
     408                 :            :             {
     409                 :          0 :                 pSequence[nCount] = i;
     410                 :          0 :                 ++nCount;
     411                 :            :             }
     412                 :            :         }
     413         [ #  # ]:          0 :         aSequence.realloc(nCount);
     414                 :            :     }
     415                 :            :     else
     416         [ #  # ]:          0 :         aSequence.realloc(0);
     417         [ #  # ]:          0 :     return aSequence;
     418                 :            : }
     419                 :            : 
     420                 :          0 : uno::Sequence< sal_Int32 > SAL_CALL ScAccessibleSpreadsheet::getSelectedAccessibleColumns(  )
     421                 :            :                     throw (uno::RuntimeException)
     422                 :            : {
     423         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     424         [ #  # ]:          0 :     IsObjectValid();
     425         [ #  # ]:          0 :     uno::Sequence<sal_Int32> aSequence;
     426 [ #  # ][ #  # ]:          0 :     if (mpViewShell && mpViewShell->GetViewData())
                 [ #  # ]
     427                 :            :     {
     428         [ #  # ]:          0 :         aSequence.realloc(maRange.aEnd.Col() - maRange.aStart.Col() + 1);
     429         [ #  # ]:          0 :         const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
     430         [ #  # ]:          0 :         sal_Int32* pSequence = aSequence.getArray();
     431                 :          0 :         sal_Int32 nCount(0);
     432         [ #  # ]:          0 :         for (SCCOL i = maRange.aStart.Col(); i <= maRange.aEnd.Col(); ++i)
     433                 :            :         {
     434 [ #  # ][ #  # ]:          0 :             if (rMarkdata.IsColumnMarked(i))
     435                 :            :             {
     436                 :          0 :                 pSequence[nCount] = i;
     437                 :          0 :                 ++nCount;
     438                 :            :             }
     439                 :            :         }
     440         [ #  # ]:          0 :         aSequence.realloc(nCount);
     441                 :            :     }
     442                 :            :     else
     443         [ #  # ]:          0 :         aSequence.realloc(0);
     444         [ #  # ]:          0 :     return aSequence;
     445                 :            : }
     446                 :            : 
     447                 :          0 : sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleRowSelected( sal_Int32 nRow )
     448                 :            :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     449                 :            : {
     450         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     451         [ #  # ]:          0 :     IsObjectValid();
     452                 :            : 
     453 [ #  # ][ #  # ]:          0 :     if ((nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
                 [ #  # ]
     454         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     455                 :            : 
     456                 :          0 :     sal_Bool bResult(false);
     457 [ #  # ][ #  # ]:          0 :     if (mpViewShell && mpViewShell->GetViewData())
                 [ #  # ]
     458                 :            :     {
     459         [ #  # ]:          0 :         const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
     460         [ #  # ]:          0 :         bResult = rMarkdata.IsRowMarked((SCROW)nRow);
     461                 :            :     }
     462         [ #  # ]:          0 :     return bResult;
     463                 :            : }
     464                 :            : 
     465                 :          0 : sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleColumnSelected( sal_Int32 nColumn )
     466                 :            :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     467                 :            : {
     468         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     469         [ #  # ]:          0 :     IsObjectValid();
     470                 :            : 
     471 [ #  # ][ #  # ]:          0 :     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0))
                 [ #  # ]
     472         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     473                 :            : 
     474                 :          0 :     sal_Bool bResult(false);
     475 [ #  # ][ #  # ]:          0 :     if (mpViewShell && mpViewShell->GetViewData())
                 [ #  # ]
     476                 :            :     {
     477         [ #  # ]:          0 :         const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
     478         [ #  # ]:          0 :         bResult = rMarkdata.IsColumnMarked((SCCOL)nColumn);
     479                 :            :     }
     480         [ #  # ]:          0 :     return bResult;
     481                 :            : }
     482                 :            : 
     483                 :         25 : ScAccessibleCell* ScAccessibleSpreadsheet::GetAccessibleCellAt(sal_Int32 nRow, sal_Int32 nColumn)
     484                 :            : {
     485                 :         25 :     ScAccessibleCell* pAccessibleCell = NULL;
     486                 :         25 :     ScAddress aCellAddress(static_cast<SCCOL>(maRange.aStart.Col() + nColumn),
     487                 :         50 :         static_cast<SCROW>(maRange.aStart.Row() + nRow), maRange.aStart.Tab());
     488 [ +  + ][ +  + ]:         25 :     if ((aCellAddress == maActiveCell) && mpAccCell)
                 [ +  + ]
     489                 :            :     {
     490                 :         14 :         pAccessibleCell = mpAccCell;
     491                 :            :     }
     492                 :            :     else
     493 [ +  - ][ +  - ]:         11 :         pAccessibleCell = new ScAccessibleCell(this, mpViewShell, aCellAddress, getAccessibleIndex(nRow, nColumn), meSplitPos, mpAccDoc);
                 [ +  - ]
     494                 :            : 
     495                 :         25 :     return pAccessibleCell;
     496                 :            : }
     497                 :            : 
     498                 :         18 : uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleCellAt( sal_Int32 nRow, sal_Int32 nColumn )
     499                 :            :                     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     500                 :            : {
     501         [ +  - ]:         18 :     SolarMutexGuard aGuard;
     502         [ +  - ]:         18 :     IsObjectValid();
     503         [ +  - ]:         36 :     if (nRow > (maRange.aEnd.Row() - maRange.aStart.Row()) ||
           [ +  -  +  - ]
         [ -  + ][ -  + ]
     504                 :            :         nRow < 0 ||
     505                 :         18 :         nColumn > (maRange.aEnd.Col() - maRange.aStart.Col()) ||
     506                 :            :         nColumn < 0)
     507         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     508                 :            : 
     509                 :         18 :     uno::Reference<XAccessible> xAccessible;
     510         [ +  - ]:         18 :     ScAccessibleCell* pAccessibleCell = GetAccessibleCellAt(nRow, nColumn);
     511 [ +  - ][ +  - ]:         18 :     xAccessible = pAccessibleCell;
     512         [ +  - ]:         18 :     pAccessibleCell->Init();
     513         [ +  - ]:         18 :     return xAccessible;
     514                 :            : }
     515                 :            : 
     516                 :          2 : sal_Bool SAL_CALL ScAccessibleSpreadsheet::isAccessibleSelected( sal_Int32 nRow, sal_Int32 nColumn )
     517                 :            :     throw (uno::RuntimeException, lang::IndexOutOfBoundsException)
     518                 :            : {
     519         [ +  - ]:          2 :     SolarMutexGuard aGuard;
     520         [ +  - ]:          2 :     IsObjectValid();
     521                 :            : 
     522         [ +  - ]:          4 :     if ((nColumn > (maRange.aEnd.Col() - maRange.aStart.Col())) || (nColumn < 0) ||
           [ +  -  +  - ]
         [ -  + ][ -  + ]
     523                 :          2 :         (nRow > (maRange.aEnd.Row() - maRange.aStart.Row())) || (nRow < 0))
     524         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     525                 :            : 
     526                 :          2 :     sal_Bool bResult(false);
     527         [ +  - ]:          2 :     if (mpViewShell)
     528                 :            :     {
     529         [ +  - ]:          2 :         const ScMarkData& rMarkdata = mpViewShell->GetViewData()->GetMarkData();
     530         [ +  - ]:          2 :         bResult = rMarkdata.IsCellMarked(static_cast<SCCOL>(nColumn), static_cast<SCROW>(nRow));
     531                 :            :     }
     532         [ +  - ]:          2 :     return bResult;
     533                 :            : }
     534                 :            : 
     535                 :            :     //=====  XAccessibleComponent  ============================================
     536                 :            : 
     537                 :          0 : uno::Reference< XAccessible > SAL_CALL ScAccessibleSpreadsheet::getAccessibleAtPoint(
     538                 :            :     const awt::Point& rPoint )
     539                 :            :         throw (uno::RuntimeException)
     540                 :            : {
     541                 :          0 :     uno::Reference< XAccessible > xAccessible;
     542 [ #  # ][ #  # ]:          0 :     if (containsPoint(rPoint))
     543                 :            :     {
     544         [ #  # ]:          0 :         SolarMutexGuard aGuard;
     545         [ #  # ]:          0 :         IsObjectValid();
     546         [ #  # ]:          0 :         if (mpViewShell)
     547                 :            :         {
     548                 :            :             SCsCOL nX;
     549                 :            :             SCsROW nY;
     550         [ #  # ]:          0 :             mpViewShell->GetViewData()->GetPosFromPixel( rPoint.X, rPoint.Y, meSplitPos, nX, nY);
     551 [ #  # ][ #  # ]:          0 :             xAccessible = getAccessibleCellAt(nY, nX);
     552         [ #  # ]:          0 :         }
     553                 :            :     }
     554                 :          0 :     return xAccessible;
     555                 :            : }
     556                 :            : 
     557                 :          2 : void SAL_CALL ScAccessibleSpreadsheet::grabFocus(  )
     558                 :            :         throw (uno::RuntimeException)
     559                 :            : {
     560         [ +  - ]:          2 :     if (getAccessibleParent().is())
     561                 :            :     {
     562 [ +  - ][ +  - ]:          2 :         uno::Reference<XAccessibleComponent> xAccessibleComponent(getAccessibleParent()->getAccessibleContext(), uno::UNO_QUERY);
         [ +  - ][ +  - ]
     563         [ +  - ]:          2 :         if (xAccessibleComponent.is())
     564 [ +  - ][ +  - ]:          2 :             xAccessibleComponent->grabFocus();
     565                 :            :     }
     566                 :          2 : }
     567                 :            : 
     568                 :          0 : sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getForeground(  )
     569                 :            :         throw (uno::RuntimeException)
     570                 :            : {
     571                 :          0 :     return COL_BLACK;
     572                 :            : }
     573                 :            : 
     574                 :          0 : sal_Int32 SAL_CALL ScAccessibleSpreadsheet::getBackground(  )
     575                 :            :         throw (uno::RuntimeException)
     576                 :            : {
     577         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     578         [ #  # ]:          0 :     IsObjectValid();
     579 [ #  # ][ #  # ]:          0 :     return SC_MOD()->GetColorConfig().GetColorValue( ::svtools::DOCCOLOR ).nColor;
         [ #  # ][ #  # ]
     580                 :            : }
     581                 :            : 
     582                 :            :     //=====  XAccessibleContext  ==============================================
     583                 :            : 
     584                 :          0 : uno::Reference<XAccessibleRelationSet> SAL_CALL ScAccessibleSpreadsheet::getAccessibleRelationSet(void)
     585                 :            :         throw (::com::sun::star::uno::RuntimeException)
     586                 :            : {
     587                 :          0 :     utl::AccessibleRelationSetHelper* pRelationSet = NULL;
     588         [ #  # ]:          0 :     if(mpAccDoc)
     589                 :          0 :         pRelationSet = mpAccDoc->GetRelationSet(NULL);
     590         [ #  # ]:          0 :     if (!pRelationSet)
     591         [ #  # ]:          0 :         pRelationSet = new utl::AccessibleRelationSetHelper();
     592         [ #  # ]:          0 :     return pRelationSet;
     593                 :            : }
     594                 :            : 
     595                 :            : uno::Reference<XAccessibleStateSet> SAL_CALL
     596                 :         26 :     ScAccessibleSpreadsheet::getAccessibleStateSet(void)
     597                 :            :     throw (uno::RuntimeException)
     598                 :            : {
     599         [ +  - ]:         26 :     SolarMutexGuard aGuard;
     600                 :         26 :     uno::Reference<XAccessibleStateSet> xParentStates;
     601 [ +  - ][ +  - ]:         26 :     if (getAccessibleParent().is())
     602                 :            :     {
     603 [ +  - ][ +  - ]:         26 :         uno::Reference<XAccessibleContext> xParentContext = getAccessibleParent()->getAccessibleContext();
                 [ +  - ]
     604 [ +  - ][ +  - ]:         26 :         xParentStates = xParentContext->getAccessibleStateSet();
                 [ +  - ]
     605                 :            :     }
     606         [ +  - ]:         26 :     utl::AccessibleStateSetHelper* pStateSet = new utl::AccessibleStateSetHelper();
     607 [ +  - ][ -  + ]:         26 :     if (IsDefunc(xParentStates))
     608         [ #  # ]:          0 :         pStateSet->AddState(AccessibleStateType::DEFUNC);
     609                 :            :     else
     610                 :            :     {
     611         [ +  - ]:         26 :         pStateSet->AddState(AccessibleStateType::MANAGES_DESCENDANTS);
     612 [ +  - ][ +  - ]:         26 :         if (IsEditable(xParentStates))
     613         [ +  - ]:         26 :             pStateSet->AddState(AccessibleStateType::EDITABLE);
     614         [ +  - ]:         26 :         pStateSet->AddState(AccessibleStateType::ENABLED);
     615         [ +  - ]:         26 :         pStateSet->AddState(AccessibleStateType::FOCUSABLE);
     616 [ +  - ][ +  - ]:         26 :         if (IsFocused())
     617         [ +  - ]:         26 :             pStateSet->AddState(AccessibleStateType::FOCUSED);
     618         [ +  - ]:         26 :         pStateSet->AddState(AccessibleStateType::MULTI_SELECTABLE);
     619         [ +  - ]:         26 :         pStateSet->AddState(AccessibleStateType::OPAQUE);
     620         [ +  - ]:         26 :         pStateSet->AddState(AccessibleStateType::SELECTABLE);
     621 [ +  - ][ -  + ]:         26 :         if (IsCompleteSheetSelected())
     622         [ #  # ]:          0 :             pStateSet->AddState(AccessibleStateType::SELECTED);
     623 [ +  - ][ +  - ]:         26 :         if (isShowing())
     624         [ +  - ]:         26 :             pStateSet->AddState(AccessibleStateType::SHOWING);
     625 [ +  - ][ +  - ]:         26 :         if (isVisible())
     626         [ +  - ]:         26 :             pStateSet->AddState(AccessibleStateType::VISIBLE);
     627                 :            :     }
     628 [ +  - ][ +  - ]:         26 :     return pStateSet;
                 [ +  - ]
     629                 :            : }
     630                 :            : 
     631                 :            :     ///=====  XAccessibleSelection  ===========================================
     632                 :            : 
     633                 :            : void SAL_CALL
     634                 :          0 :         ScAccessibleSpreadsheet::selectAccessibleChild( sal_Int32 nChildIndex )
     635                 :            :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     636                 :            : {
     637         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     638         [ #  # ]:          0 :     IsObjectValid();
     639 [ #  # ][ #  # ]:          0 :     if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
         [ #  # ][ #  # ]
     640         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     641                 :            : 
     642         [ #  # ]:          0 :     if (mpViewShell)
     643                 :            :     {
     644         [ #  # ]:          0 :         sal_Int32 nCol(getAccessibleColumn(nChildIndex));
     645         [ #  # ]:          0 :         sal_Int32 nRow(getAccessibleRow(nChildIndex));
     646                 :            : 
     647         [ #  # ]:          0 :         SelectCell(nRow, nCol, false);
     648         [ #  # ]:          0 :     }
     649                 :          0 : }
     650                 :            : 
     651                 :            : void SAL_CALL
     652                 :          0 :         ScAccessibleSpreadsheet::clearAccessibleSelection(  )
     653                 :            :         throw (uno::RuntimeException)
     654                 :            : {
     655         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     656         [ #  # ]:          0 :     IsObjectValid();
     657         [ #  # ]:          0 :     if (mpViewShell)
     658                 :            :     {
     659         [ #  # ]:          0 :         mpViewShell->Unmark();
     660         [ #  # ]:          0 :     }
     661                 :          0 : }
     662                 :            : 
     663                 :            : void SAL_CALL
     664                 :          0 :         ScAccessibleSpreadsheet::selectAllAccessibleChildren(  )
     665                 :            :         throw (uno::RuntimeException)
     666                 :            : {
     667         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     668         [ #  # ]:          0 :     IsObjectValid();
     669         [ #  # ]:          0 :     if (mpViewShell)
     670                 :            :     {
     671         [ #  # ]:          0 :         mpViewShell->SelectAll();
     672         [ #  # ]:          0 :     }
     673                 :          0 : }
     674                 :            : 
     675                 :            : sal_Int32 SAL_CALL
     676                 :          0 :         ScAccessibleSpreadsheet::getSelectedAccessibleChildCount(  )
     677                 :            :         throw (uno::RuntimeException)
     678                 :            : {
     679         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     680         [ #  # ]:          0 :     IsObjectValid();
     681                 :          0 :     sal_Int32 nResult(0);
     682         [ #  # ]:          0 :     if (mpViewShell)
     683                 :            :     {
     684         [ #  # ]:          0 :         if (!mpMarkedRanges)
     685                 :            :         {
     686 [ #  # ][ #  # ]:          0 :             mpMarkedRanges = new ScRangeList();
     687 [ #  # ][ #  # ]:          0 :             ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
     688         [ #  # ]:          0 :             aMarkData.MarkToMulti();
     689 [ #  # ][ #  # ]:          0 :             aMarkData.FillRangeListWithMarks(mpMarkedRanges, false);
     690                 :            :         }
     691                 :            :         // is possible, because there shouldn't be overlapped ranges in it
     692         [ #  # ]:          0 :         if (mpMarkedRanges)
     693         [ #  # ]:          0 :             nResult = mpMarkedRanges->GetCellCount();
     694                 :            :     }
     695         [ #  # ]:          0 :     return nResult;
     696                 :            : }
     697                 :            : 
     698                 :            : uno::Reference<XAccessible > SAL_CALL
     699                 :          0 :         ScAccessibleSpreadsheet::getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex )
     700                 :            :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     701                 :            : {
     702         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     703         [ #  # ]:          0 :     IsObjectValid();
     704                 :          0 :     uno::Reference < XAccessible > xAccessible;
     705         [ #  # ]:          0 :     if (mpViewShell)
     706                 :            :     {
     707         [ #  # ]:          0 :         if (!mpMarkedRanges)
     708                 :            :         {
     709 [ #  # ][ #  # ]:          0 :             mpMarkedRanges = new ScRangeList();
     710 [ #  # ][ #  # ]:          0 :             mpViewShell->GetViewData()->GetMarkData().FillRangeListWithMarks(mpMarkedRanges, false);
     711                 :            :         }
     712         [ #  # ]:          0 :         if (mpMarkedRanges)
     713                 :            :         {
     714         [ #  # ]:          0 :             if (!mpSortedMarkedCells)
     715         [ #  # ]:          0 :                 CreateSortedMarkedCells();
     716         [ #  # ]:          0 :             if (mpSortedMarkedCells)
     717                 :            :             {
     718   [ #  #  #  # ]:          0 :                 if ((nSelectedChildIndex < 0) ||
                 [ #  # ]
     719                 :          0 :                     (mpSortedMarkedCells->size() <= static_cast<sal_uInt32>(nSelectedChildIndex)))
     720         [ #  # ]:          0 :                     throw lang::IndexOutOfBoundsException();
     721                 :            :                 else
     722 [ #  # ][ #  # ]:          0 :                     xAccessible = getAccessibleCellAt((*mpSortedMarkedCells)[nSelectedChildIndex].Row(), (*mpSortedMarkedCells)[nSelectedChildIndex].Col());
     723                 :            :             }
     724                 :            :         }
     725                 :            :     }
     726         [ #  # ]:          0 :     return xAccessible;
     727                 :            : }
     728                 :            : 
     729                 :            : void SAL_CALL
     730                 :          0 :         ScAccessibleSpreadsheet::deselectAccessibleChild( sal_Int32 nChildIndex )
     731                 :            :         throw (lang::IndexOutOfBoundsException, uno::RuntimeException)
     732                 :            : {
     733         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     734         [ #  # ]:          0 :     IsObjectValid();
     735                 :            : 
     736 [ #  # ][ #  # ]:          0 :     if (nChildIndex < 0 || nChildIndex >= getAccessibleChildCount())
         [ #  # ][ #  # ]
     737         [ #  # ]:          0 :         throw lang::IndexOutOfBoundsException();
     738                 :            : 
     739         [ #  # ]:          0 :     if (mpViewShell)
     740                 :            :     {
     741         [ #  # ]:          0 :         sal_Int32 nCol(getAccessibleColumn(nChildIndex));
     742         [ #  # ]:          0 :         sal_Int32 nRow(getAccessibleRow(nChildIndex));
     743                 :            : 
     744 [ #  # ][ #  # ]:          0 :         if (mpViewShell->GetViewData()->GetMarkData().IsCellMarked(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow)))
                 [ #  # ]
     745         [ #  # ]:          0 :             SelectCell(nRow, nCol, sal_True);
     746         [ #  # ]:          0 :     }
     747                 :          0 : }
     748                 :            : 
     749                 :          0 : void ScAccessibleSpreadsheet::SelectCell(sal_Int32 nRow, sal_Int32 nCol, sal_Bool bDeselect)
     750                 :            : {
     751                 :          0 :     mpViewShell->SetTabNo( maRange.aStart.Tab() );
     752                 :            : 
     753                 :          0 :     mpViewShell->DoneBlockMode( sal_True ); // continue selecting
     754                 :          0 :     mpViewShell->InitBlockMode( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), maRange.aStart.Tab(), bDeselect, false, false );
     755                 :            : 
     756                 :          0 :     mpViewShell->SelectionChanged();
     757                 :          0 : }
     758                 :            : 
     759                 :          0 : void ScAccessibleSpreadsheet::CreateSortedMarkedCells()
     760                 :            : {
     761         [ #  # ]:          0 :     mpSortedMarkedCells = new std::vector<ScMyAddress>();
     762                 :          0 :     mpSortedMarkedCells->reserve(mpMarkedRanges->GetCellCount());
     763         [ #  # ]:          0 :     for ( size_t i = 0, ListSize = mpMarkedRanges->size(); i < ListSize; ++i )
     764                 :            :     {
     765                 :          0 :         ScRange* pRange = (*mpMarkedRanges)[i];
     766         [ #  # ]:          0 :         if (pRange->aStart.Tab() != pRange->aEnd.Tab())
     767                 :            :         {
     768   [ #  #  #  # ]:          0 :             if ((maActiveCell.Tab() >= pRange->aStart.Tab()) ||
                 [ #  # ]
     769                 :          0 :                 maActiveCell.Tab() <= pRange->aEnd.Tab())
     770                 :            :             {
     771                 :          0 :                 ScRange aRange(*pRange);
     772                 :          0 :                 aRange.aStart.SetTab(maActiveCell.Tab());
     773                 :          0 :                 aRange.aEnd.SetTab(maActiveCell.Tab());
     774         [ #  # ]:          0 :                 AddMarkedRange(aRange);
     775                 :            :             }
     776                 :            :             else
     777                 :            :             {
     778                 :            :                 OSL_FAIL("Range of wrong table");
     779                 :            :             }
     780                 :            :         }
     781         [ #  # ]:          0 :         else if(pRange->aStart.Tab() == maActiveCell.Tab())
     782                 :          0 :             AddMarkedRange(*pRange);
     783                 :            :         else
     784                 :            :         {
     785                 :            :             OSL_FAIL("Range of wrong table");
     786                 :            :         }
     787                 :            :     }
     788                 :          0 :     std::sort(mpSortedMarkedCells->begin(), mpSortedMarkedCells->end());
     789                 :          0 : }
     790                 :            : 
     791                 :          0 : void ScAccessibleSpreadsheet::AddMarkedRange(const ScRange& rRange)
     792                 :            : {
     793         [ #  # ]:          0 :     for (SCROW nRow = rRange.aStart.Row(); nRow <= rRange.aEnd.Row(); ++nRow)
     794                 :            :     {
     795         [ #  # ]:          0 :         for (SCCOL nCol = rRange.aStart.Col(); nCol <= rRange.aEnd.Col(); ++nCol)
     796                 :            :         {
     797                 :          0 :             ScMyAddress aCell(nCol, nRow, maActiveCell.Tab());
     798         [ #  # ]:          0 :             mpSortedMarkedCells->push_back(aCell);
     799                 :            :         }
     800                 :            :     }
     801                 :          0 : }
     802                 :            : 
     803                 :            :     //=====  XServiceInfo  ====================================================
     804                 :            : 
     805                 :          0 : ::rtl::OUString SAL_CALL ScAccessibleSpreadsheet::getImplementationName(void)
     806                 :            :         throw (uno::RuntimeException)
     807                 :            : {
     808                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM ("ScAccessibleSpreadsheet"));
     809                 :            : }
     810                 :            : 
     811                 :            : uno::Sequence< ::rtl::OUString> SAL_CALL
     812                 :          0 :     ScAccessibleSpreadsheet::getSupportedServiceNames (void)
     813                 :            :         throw (uno::RuntimeException)
     814                 :            : {
     815                 :          0 :     uno::Sequence< ::rtl::OUString > aSequence = ScAccessibleTableBase::getSupportedServiceNames();
     816                 :          0 :     sal_Int32 nOldSize(aSequence.getLength());
     817         [ #  # ]:          0 :     aSequence.realloc(nOldSize + 1);
     818         [ #  # ]:          0 :     ::rtl::OUString* pNames = aSequence.getArray();
     819                 :            : 
     820         [ #  # ]:          0 :     pNames[nOldSize] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.AccessibleSpreadsheet"));
     821                 :            : 
     822                 :          0 :     return aSequence;
     823                 :            : }
     824                 :            : 
     825                 :            : //=====  XTypeProvider  =======================================================
     826                 :            : 
     827                 :            : namespace
     828                 :            : {
     829                 :            :     class theScAccessibleSpreadsheetImplementationId : public rtl::Static< UnoTunnelIdInit, theScAccessibleSpreadsheetImplementationId > {};
     830                 :            : }
     831                 :            : 
     832                 :            : uno::Sequence<sal_Int8> SAL_CALL
     833                 :          0 :     ScAccessibleSpreadsheet::getImplementationId(void)
     834                 :            :     throw (uno::RuntimeException)
     835                 :            : {
     836                 :          0 :     return theScAccessibleSpreadsheetImplementationId::get().getSeq();
     837                 :            : }
     838                 :            : 
     839                 :            : ///=====  XAccessibleEventBroadcaster  =====================================
     840                 :            : 
     841                 :         25 : void SAL_CALL ScAccessibleSpreadsheet::addEventListener(const uno::Reference<XAccessibleEventListener>& xListener)
     842                 :            :         throw (uno::RuntimeException)
     843                 :            : {
     844         [ +  - ]:         25 :     SolarMutexGuard aGuard;
     845         [ +  - ]:         25 :     IsObjectValid();
     846         [ +  - ]:         25 :     ScAccessibleTableBase::addEventListener(xListener);
     847                 :            : 
     848         [ +  + ]:         25 :     if (!mbIsFocusSend)
     849                 :            :     {
     850                 :          5 :         mbIsFocusSend = sal_True;
     851         [ +  - ]:          5 :         CommitFocusGained();
     852                 :            : 
     853         [ +  - ]:          5 :         AccessibleEventObject aEvent;
     854                 :          5 :         aEvent.EventId = AccessibleEventId::ACTIVE_DESCENDANT_CHANGED;
     855 [ +  - ][ +  - ]:          5 :         aEvent.Source = uno::Reference< XAccessibleContext >(this);
     856 [ +  - ][ +  - ]:          5 :         aEvent.NewValue <<= getAccessibleCellAt(maActiveCell.Row(), maActiveCell.Col());
     857                 :            : 
     858 [ +  - ][ +  - ]:          5 :         CommitChange(aEvent);
     859         [ +  - ]:         25 :     }
     860                 :         25 : }
     861                 :            : 
     862                 :            :     //====  internal  =========================================================
     863                 :            : 
     864                 :          2 : Rectangle ScAccessibleSpreadsheet::GetBoundingBoxOnScreen() const
     865                 :            :     throw (uno::RuntimeException)
     866                 :            : {
     867                 :          2 :     Rectangle aRect;
     868         [ +  - ]:          2 :     if (mpViewShell)
     869                 :            :     {
     870                 :          2 :         Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
     871         [ +  - ]:          2 :         if (pWindow)
     872                 :          2 :             aRect = pWindow->GetWindowExtentsRelative(NULL);
     873                 :            :     }
     874                 :          2 :     return aRect;
     875                 :            : }
     876                 :            : 
     877                 :         37 : Rectangle ScAccessibleSpreadsheet::GetBoundingBox() const
     878                 :            :     throw (uno::RuntimeException)
     879                 :            : {
     880                 :         37 :     Rectangle aRect;
     881         [ +  - ]:         37 :     if (mpViewShell)
     882                 :            :     {
     883                 :         37 :         Window* pWindow = mpViewShell->GetWindowByPos(meSplitPos);
     884         [ +  - ]:         37 :         if (pWindow)
     885                 :            :             //#101986#; extends to the same window, because the parent is the document and it has the same window
     886                 :         37 :             aRect = pWindow->GetWindowExtentsRelative(pWindow);
     887                 :            :     }
     888                 :         37 :     return aRect;
     889                 :            : }
     890                 :            : 
     891                 :         26 : sal_Bool ScAccessibleSpreadsheet::IsDefunc(
     892                 :            :     const uno::Reference<XAccessibleStateSet>& rxParentStates)
     893                 :            : {
     894 [ +  - ][ +  - ]:         78 :     return ScAccessibleContextBase::IsDefunc() || (mpViewShell == NULL) || !getAccessibleParent().is() ||
                 [ #  # ]
     895   [ +  -  +  - ]:         78 :         (rxParentStates.is() && rxParentStates->contains(AccessibleStateType::DEFUNC));
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
                 [ +  - ]
     896                 :            : }
     897                 :            : 
     898                 :         26 : sal_Bool ScAccessibleSpreadsheet::IsEditable(
     899                 :            :     const uno::Reference<XAccessibleStateSet>& /* rxParentStates */)
     900                 :            : {
     901                 :         26 :     sal_Bool bProtected(false);
     902 [ +  - ][ -  + ]:         26 :     if (mpDoc && mpDoc->IsTabProtected(maRange.aStart.Tab()))
                 [ -  + ]
     903                 :          0 :         bProtected = sal_True;
     904                 :         26 :     return !bProtected;
     905                 :            : }
     906                 :            : 
     907                 :         28 : sal_Bool ScAccessibleSpreadsheet::IsFocused()
     908                 :            : {
     909                 :         28 :     sal_Bool bFocused(false);
     910         [ +  - ]:         28 :     if (mpViewShell)
     911                 :            :     {
     912         [ +  - ]:         28 :         if (mpViewShell->GetViewData()->GetActivePart() == meSplitPos)
     913                 :         28 :             bFocused = mpViewShell->GetActiveWin()->HasFocus();
     914                 :            :     }
     915                 :         28 :     return bFocused;
     916                 :            : }
     917                 :            : 
     918                 :         26 : sal_Bool ScAccessibleSpreadsheet::IsCompleteSheetSelected()
     919                 :            : {
     920                 :         26 :     sal_Bool bResult(false);
     921         [ +  - ]:         26 :     if(mpViewShell)
     922                 :            :     {
     923                 :            :         //#103800#; use a copy of MarkData
     924 [ +  - ][ +  - ]:         26 :         ScMarkData aMarkData(mpViewShell->GetViewData()->GetMarkData());
     925         [ +  - ]:         26 :         aMarkData.MarkToMulti();
     926 [ +  - ][ -  + ]:         26 :         if (aMarkData.IsAllMarked(maRange))
     927         [ +  - ]:         26 :             bResult = sal_True;
     928                 :            :     }
     929                 :         26 :     return bResult;
     930                 :            : }
     931                 :            : 
     932                 :          5 : ScDocument* ScAccessibleSpreadsheet::GetDocument(ScTabViewShell* pViewShell)
     933                 :            : {
     934                 :          5 :     ScDocument* pDoc = NULL;
     935         [ +  - ]:          5 :     if (pViewShell)
     936                 :          5 :         pDoc = pViewShell->GetViewData()->GetDocument();
     937                 :          5 :     return pDoc;
     938                 :            : }
     939                 :            : 
     940                 :          5 : Rectangle ScAccessibleSpreadsheet::GetVisArea(ScTabViewShell* pViewShell, ScSplitPos eSplitPos)
     941                 :            : {
     942                 :          5 :     Rectangle aVisArea;
     943         [ +  - ]:          5 :     if (pViewShell)
     944                 :            :     {
     945                 :          5 :         Window* pWindow = pViewShell->GetWindowByPos(eSplitPos);
     946         [ +  - ]:          5 :         if (pWindow)
     947                 :            :         {
     948                 :          5 :             aVisArea.SetPos(pViewShell->GetViewData()->GetPixPos(eSplitPos));
     949         [ +  - ]:          5 :             aVisArea.SetSize(pWindow->GetSizePixel());
     950                 :            :         }
     951                 :            :     }
     952                 :          5 :     return aVisArea;
     953                 :            : }
     954                 :            : 
     955                 :          5 : Rectangle ScAccessibleSpreadsheet::GetVisCells(const Rectangle& rVisArea)
     956                 :            : {
     957         [ +  - ]:          5 :     if (mpViewShell)
     958                 :            :     {
     959                 :            :         SCsCOL nStartX, nEndX;
     960                 :            :         SCsROW nStartY, nEndY;
     961                 :            : 
     962         [ +  - ]:          5 :         mpViewShell->GetViewData()->GetPosFromPixel( 1, 1, meSplitPos, nStartX, nStartY);
     963 [ +  - ][ +  - ]:          5 :         mpViewShell->GetViewData()->GetPosFromPixel( rVisArea.GetWidth(), rVisArea.GetHeight(), meSplitPos, nEndX, nEndY);
                 [ +  - ]
     964                 :            : 
     965         [ +  - ]:          5 :         return Rectangle(nStartX, nStartY, nEndX, nEndY);
     966                 :            :     }
     967                 :            :     else
     968                 :          5 :         return Rectangle();
     969                 :            : }
     970                 :            : 
     971                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10