LCOV - code coverage report
Current view: top level - sc/source/ui/unoobj - cursuno.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 226 259 87.3 %
Date: 2012-08-25 Functions: 24 28 85.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 133 294 45.2 %

           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 "scitems.hxx"
      30                 :            : #include <svl/intitem.hxx>
      31                 :            : #include <svl/zforlist.hxx>
      32                 :            : #include <vcl/svapp.hxx>
      33                 :            : #include <comphelper/servicehelper.hxx>
      34                 :            : 
      35                 :            : #include "cursuno.hxx"
      36                 :            : #include "cellsuno.hxx"
      37                 :            : #include "docsh.hxx"
      38                 :            : #include "hints.hxx"
      39                 :            : #include "markdata.hxx"
      40                 :            : #include "dociter.hxx"
      41                 :            : #include "miscuno.hxx"
      42                 :            : 
      43                 :            : using namespace com::sun::star;
      44                 :            : 
      45                 :            : //------------------------------------------------------------------------
      46                 :            : 
      47                 :            : #define SCSHEETCELLCURSOR_SERVICE   "com.sun.star.sheet.SheetCellCursor"
      48                 :            : #define SCCELLCURSOR_SERVICE        "com.sun.star.table.CellCursor"
      49                 :            : 
      50                 :            : //------------------------------------------------------------------------
      51                 :            : 
      52                 :         42 : ScCellCursorObj::ScCellCursorObj(ScDocShell* pDocSh, const ScRange& rR) :
      53                 :         42 :     ScCellRangeObj( pDocSh, rR )
      54                 :            : {
      55                 :         42 : }
      56                 :            : 
      57                 :         42 : ScCellCursorObj::~ScCellCursorObj()
      58                 :            : {
      59         [ -  + ]:         84 : }
      60                 :            : 
      61                 :        706 : uno::Any SAL_CALL ScCellCursorObj::queryInterface( const uno::Type& rType ) throw(uno::RuntimeException)
      62                 :            : {
      63 [ -  + ][ #  # ]:        706 :     SC_QUERYINTERFACE( sheet::XSheetCellCursor )
      64 [ +  + ][ +  - ]:        706 :     SC_QUERYINTERFACE( sheet::XUsedAreaCursor )
      65 [ +  + ][ +  - ]:        697 :     SC_QUERYINTERFACE( table::XCellCursor )
      66                 :            : 
      67                 :        706 :     return ScCellRangeObj::queryInterface( rType );
      68                 :            : }
      69                 :            : 
      70                 :       1573 : void SAL_CALL ScCellCursorObj::acquire() throw()
      71                 :            : {
      72                 :       1573 :     ScCellRangeObj::acquire();
      73                 :       1573 : }
      74                 :            : 
      75                 :       1573 : void SAL_CALL ScCellCursorObj::release() throw()
      76                 :            : {
      77                 :       1573 :     ScCellRangeObj::release();
      78                 :       1573 : }
      79                 :            : 
      80                 :          0 : uno::Sequence<uno::Type> SAL_CALL ScCellCursorObj::getTypes() throw(uno::RuntimeException)
      81                 :            : {
      82 [ #  # ][ #  # ]:          0 :     static uno::Sequence<uno::Type> aTypes;
         [ #  # ][ #  # ]
      83         [ #  # ]:          0 :     if ( aTypes.getLength() == 0 )
      84                 :            :     {
      85         [ #  # ]:          0 :         uno::Sequence<uno::Type> aParentTypes(ScCellRangeObj::getTypes());
      86                 :          0 :         long nParentLen = aParentTypes.getLength();
      87                 :          0 :         const uno::Type* pParentPtr = aParentTypes.getConstArray();
      88                 :            : 
      89         [ #  # ]:          0 :         aTypes.realloc( nParentLen + 3 );
      90         [ #  # ]:          0 :         uno::Type* pPtr = aTypes.getArray();
      91         [ #  # ]:          0 :         pPtr[nParentLen + 0] = getCppuType((const uno::Reference<sheet::XSheetCellCursor>*)0);
      92         [ #  # ]:          0 :         pPtr[nParentLen + 1] = getCppuType((const uno::Reference<sheet::XUsedAreaCursor>*)0);
      93         [ #  # ]:          0 :         pPtr[nParentLen + 2] = getCppuType((const uno::Reference<table::XCellCursor>*)0);
      94                 :            : 
      95         [ #  # ]:          0 :         for (long i=0; i<nParentLen; i++)
      96         [ #  # ]:          0 :             pPtr[i] = pParentPtr[i];                // parent types first
      97                 :            :     }
      98                 :          0 :     return aTypes;
      99                 :            : }
     100                 :            : 
     101                 :            : namespace
     102                 :            : {
     103                 :            :     class theScCellCursorObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScCellCursorObjImplementationId > {};
     104                 :            : }
     105                 :            : 
     106                 :          0 : uno::Sequence<sal_Int8> SAL_CALL ScCellCursorObj::getImplementationId() throw(uno::RuntimeException)
     107                 :            : {
     108                 :          0 :     return theScCellCursorObjImplementationId::get().getSeq();
     109                 :            : }
     110                 :            : 
     111                 :            : // XSheetCellCursor
     112                 :            : 
     113                 :          1 : void SAL_CALL ScCellCursorObj::collapseToCurrentRegion() throw(uno::RuntimeException)
     114                 :            : {
     115         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     116                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     117                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     118         [ +  - ]:          1 :     ScRange aOneRange( *rRanges[ 0 ] );
     119                 :            : 
     120         [ +  - ]:          1 :     aOneRange.Justify();
     121                 :          1 :     ScDocShell* pDocSh = GetDocShell();
     122         [ +  - ]:          1 :     if ( pDocSh )
     123                 :            :     {
     124                 :          1 :         SCCOL nStartCol = aOneRange.aStart.Col();
     125                 :          1 :         SCROW nStartRow = aOneRange.aStart.Row();
     126                 :          1 :         SCCOL nEndCol = aOneRange.aEnd.Col();
     127                 :          1 :         SCROW nEndRow = aOneRange.aEnd.Row();
     128                 :          1 :         SCTAB nTab = aOneRange.aStart.Tab();
     129                 :            : 
     130                 :            :         pDocSh->GetDocument()->GetDataArea(
     131         [ +  - ]:          1 :                         nTab, nStartCol, nStartRow, nEndCol, nEndRow, true, false );
     132                 :            : 
     133                 :          1 :         ScRange aNew( nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab );
     134         [ +  - ]:          1 :         SetNewRange( aNew );
     135         [ +  - ]:          1 :     }
     136                 :          1 : }
     137                 :            : 
     138                 :          1 : void SAL_CALL ScCellCursorObj::collapseToCurrentArray() throw(uno::RuntimeException)
     139                 :            : {
     140         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     141                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     142                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     143         [ +  - ]:          1 :     ScRange aOneRange( *rRanges[ 0 ] );
     144                 :            : 
     145         [ +  - ]:          1 :     aOneRange.Justify();
     146                 :          1 :     ScAddress aCursor(aOneRange.aStart);        //  use the start address of the range
     147                 :            : 
     148                 :          1 :     ScDocShell* pDocSh = GetDocShell();
     149         [ +  - ]:          1 :     if ( pDocSh )
     150                 :            :     {
     151                 :          1 :         ScDocument* pDoc = pDocSh->GetDocument();
     152                 :          1 :         ScRange aMatrix;
     153                 :            : 
     154                 :            :         // finding the matrix range is now in GetMatrixFormulaRange in the document
     155 [ +  - ][ +  - ]:          1 :         if ( pDoc->GetMatrixFormulaRange( aCursor, aMatrix ) )
     156                 :            :         {
     157         [ +  - ]:          1 :             SetNewRange( aMatrix );
     158                 :            :         }
     159         [ +  - ]:          1 :     }
     160                 :            :     // thats a Bug, that this assertion comes; the API Reference says, that
     161                 :            :     // if there is no Matrix, the Range is left unchanged; they says nothing
     162                 :            :     // about a exception
     163                 :            :     /*if (!bFound)
     164                 :            :     {
     165                 :            :         OSL_FAIL("keine Matrix");
     166                 :            :         //! Exception, oder was?
     167                 :            :     }*/
     168                 :          1 : }
     169                 :            : 
     170                 :          5 : void SAL_CALL ScCellCursorObj::collapseToMergedArea() throw(uno::RuntimeException)
     171                 :            : {
     172         [ +  - ]:          5 :     SolarMutexGuard aGuard;
     173                 :          5 :     ScDocShell* pDocSh = GetDocShell();
     174         [ +  - ]:          5 :     if ( pDocSh )
     175                 :            :     {
     176                 :          5 :         const ScRangeList& rRanges = GetRangeList();
     177                 :            :         OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     178         [ +  - ]:          5 :         ScRange aNewRange( *rRanges[ 0 ] );
     179                 :            : 
     180                 :          5 :         ScDocument* pDoc = pDocSh->GetDocument();
     181         [ +  - ]:          5 :         pDoc->ExtendOverlapped( aNewRange );
     182         [ +  - ]:          5 :         pDoc->ExtendMerge( aNewRange );                 // after ExtendOverlapped!
     183                 :            : 
     184         [ +  - ]:          5 :         SetNewRange( aNewRange );
     185         [ +  - ]:          5 :     }
     186                 :          5 : }
     187                 :            : 
     188                 :          1 : void SAL_CALL ScCellCursorObj::expandToEntireColumns() throw(uno::RuntimeException)
     189                 :            : {
     190         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     191                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     192                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     193         [ +  - ]:          1 :     ScRange aNewRange( *rRanges[ 0 ] );
     194                 :            : 
     195                 :          1 :     aNewRange.aStart.SetRow( 0 );
     196                 :          1 :     aNewRange.aEnd.SetRow( MAXROW );
     197                 :            : 
     198 [ +  - ][ +  - ]:          1 :     SetNewRange( aNewRange );
     199                 :          1 : }
     200                 :            : 
     201                 :          1 : void SAL_CALL ScCellCursorObj::expandToEntireRows() throw(uno::RuntimeException)
     202                 :            : {
     203         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     204                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     205                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     206         [ +  - ]:          1 :     ScRange aNewRange( *rRanges[ 0 ] );
     207                 :            : 
     208                 :          1 :     aNewRange.aStart.SetCol( 0 );
     209                 :          1 :     aNewRange.aEnd.SetCol( MAXCOL );
     210                 :            : 
     211 [ +  - ][ +  - ]:          1 :     SetNewRange( aNewRange );
     212                 :          1 : }
     213                 :            : 
     214                 :          7 : void SAL_CALL ScCellCursorObj::collapseToSize( sal_Int32 nColumns, sal_Int32 nRows )
     215                 :            :                                                 throw(uno::RuntimeException)
     216                 :            : {
     217         [ +  - ]:          7 :     SolarMutexGuard aGuard;
     218 [ +  - ][ +  - ]:          7 :     if ( nColumns <= 0 || nRows <= 0 )
     219                 :            :     {
     220                 :            :         OSL_FAIL("leerer Range geht nicht");
     221                 :            :         //! und dann?
     222                 :            :     }
     223                 :            :     else
     224                 :            :     {
     225                 :          7 :         const ScRangeList& rRanges = GetRangeList();
     226                 :            :         OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     227         [ +  - ]:          7 :         ScRange aNewRange( *rRanges[ 0 ] );
     228                 :            : 
     229         [ +  - ]:          7 :         aNewRange.Justify();    //! wirklich?
     230                 :            : 
     231                 :          7 :         long nEndX = aNewRange.aStart.Col() + nColumns - 1;
     232                 :          7 :         long nEndY = aNewRange.aStart.Row() + nRows - 1;
     233         [ -  + ]:          7 :         if ( nEndX < 0 )      nEndX = 0;
     234         [ -  + ]:          7 :         if ( nEndX > MAXCOL ) nEndX = MAXCOL;
     235         [ -  + ]:          7 :         if ( nEndY < 0 )      nEndY = 0;
     236         [ -  + ]:          7 :         if ( nEndY > MAXROW ) nEndY = MAXROW;
     237                 :            :         //! Fehler/Exception oder so, wenn zu gross/zu klein?
     238                 :            : 
     239                 :          7 :         aNewRange.aEnd.SetCol((SCCOL)nEndX);
     240                 :          7 :         aNewRange.aEnd.SetRow((SCROW)nEndY);
     241                 :            : 
     242         [ +  - ]:          7 :         aNewRange.Justify();    //! wirklich?
     243                 :            : 
     244         [ +  - ]:          7 :         SetNewRange( aNewRange );
     245         [ +  - ]:          7 :     }
     246                 :          7 : }
     247                 :            : 
     248                 :            : // XUsedAreaCursor
     249                 :            : 
     250                 :          3 : void SAL_CALL ScCellCursorObj::gotoStartOfUsedArea( sal_Bool bExpand )
     251                 :            :                                             throw(uno::RuntimeException)
     252                 :            : {
     253         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     254                 :          3 :     ScDocShell* pDocSh = GetDocShell();
     255         [ +  - ]:          3 :     if ( pDocSh )
     256                 :            :     {
     257                 :          3 :         const ScRangeList& rRanges = GetRangeList();
     258                 :            :         OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     259         [ +  - ]:          3 :         ScRange aNewRange( *rRanges[0] );
     260                 :          3 :         SCTAB nTab = aNewRange.aStart.Tab();
     261                 :            : 
     262                 :          3 :         SCCOL nUsedX = 0;       // Anfang holen
     263                 :          3 :         SCROW nUsedY = 0;
     264 [ -  + ][ +  - ]:          3 :         if (!pDocSh->GetDocument()->GetDataStart( nTab, nUsedX, nUsedY ))
     265                 :            :         {
     266                 :          0 :             nUsedX = 0;
     267                 :          0 :             nUsedY = 0;
     268                 :            :         }
     269                 :            : 
     270                 :          3 :         aNewRange.aStart.SetCol( nUsedX );
     271                 :          3 :         aNewRange.aStart.SetRow( nUsedY );
     272         [ +  + ]:          3 :         if (!bExpand)
     273                 :          2 :             aNewRange.aEnd = aNewRange.aStart;
     274         [ +  - ]:          3 :         SetNewRange( aNewRange );
     275         [ +  - ]:          3 :     }
     276                 :          3 : }
     277                 :            : 
     278                 :         11 : void SAL_CALL ScCellCursorObj::gotoEndOfUsedArea( sal_Bool bExpand )
     279                 :            :                                             throw(uno::RuntimeException)
     280                 :            : {
     281         [ +  - ]:         11 :     SolarMutexGuard aGuard;
     282                 :         11 :     ScDocShell* pDocSh = GetDocShell();
     283         [ +  - ]:         11 :     if ( pDocSh )
     284                 :            :     {
     285                 :         11 :         const ScRangeList& rRanges = GetRangeList();
     286                 :            :         OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     287         [ +  - ]:         11 :         ScRange aNewRange( *rRanges[ 0 ]);
     288                 :         11 :         SCTAB nTab = aNewRange.aStart.Tab();
     289                 :            : 
     290                 :         11 :         SCCOL nUsedX = 0;       // Ende holen
     291                 :         11 :         SCROW nUsedY = 0;
     292 [ -  + ][ +  - ]:         11 :         if (!pDocSh->GetDocument()->GetTableArea( nTab, nUsedX, nUsedY ))
     293                 :            :         {
     294                 :          0 :             nUsedX = 0;
     295                 :          0 :             nUsedY = 0;
     296                 :            :         }
     297                 :            : 
     298                 :         11 :         aNewRange.aEnd.SetCol( nUsedX );
     299                 :         11 :         aNewRange.aEnd.SetRow( nUsedY );
     300         [ +  + ]:         11 :         if (!bExpand)
     301                 :          2 :             aNewRange.aStart = aNewRange.aEnd;
     302         [ +  - ]:         11 :         SetNewRange( aNewRange );
     303         [ +  - ]:         11 :     }
     304                 :         11 : }
     305                 :            : 
     306                 :            : // XCellCursor
     307                 :            : 
     308                 :          1 : void SAL_CALL ScCellCursorObj::gotoStart() throw(uno::RuntimeException)
     309                 :            : {
     310                 :            :     //  this is similar to collapseToCurrentRegion
     311                 :            :     //! something like gotoEdge with 4 possible directions is needed
     312                 :            : 
     313         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     314                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     315                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     316         [ +  - ]:          1 :     ScRange aOneRange( *rRanges[ 0 ]);
     317                 :            : 
     318         [ +  - ]:          1 :     aOneRange.Justify();
     319                 :          1 :     ScDocShell* pDocSh = GetDocShell();
     320         [ +  - ]:          1 :     if ( pDocSh )
     321                 :            :     {
     322                 :          1 :         SCCOL nStartCol = aOneRange.aStart.Col();
     323                 :          1 :         SCROW nStartRow = aOneRange.aStart.Row();
     324                 :          1 :         SCCOL nEndCol = aOneRange.aEnd.Col();
     325                 :          1 :         SCROW nEndRow = aOneRange.aEnd.Row();
     326                 :          1 :         SCTAB nTab = aOneRange.aStart.Tab();
     327                 :            : 
     328                 :            :         pDocSh->GetDocument()->GetDataArea(
     329         [ +  - ]:          1 :                         nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, false );
     330                 :            : 
     331                 :          1 :         ScRange aNew( nStartCol, nStartRow, nTab );
     332         [ +  - ]:          1 :         SetNewRange( aNew );
     333         [ +  - ]:          1 :     }
     334                 :          1 : }
     335                 :            : 
     336                 :         17 : void SAL_CALL ScCellCursorObj::gotoEnd() throw(uno::RuntimeException)
     337                 :            : {
     338                 :            :     //  this is similar to collapseToCurrentRegion
     339                 :            :     //! something like gotoEdge with 4 possible directions is needed
     340                 :            : 
     341         [ +  - ]:         17 :     SolarMutexGuard aGuard;
     342                 :         17 :     const ScRangeList& rRanges = GetRangeList();
     343                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     344         [ +  - ]:         17 :     ScRange aOneRange( *rRanges[ 0 ] );
     345                 :            : 
     346         [ +  - ]:         17 :     aOneRange.Justify();
     347                 :         17 :     ScDocShell* pDocSh = GetDocShell();
     348         [ +  - ]:         17 :     if ( pDocSh )
     349                 :            :     {
     350                 :         17 :         SCCOL nStartCol = aOneRange.aStart.Col();
     351                 :         17 :         SCROW nStartRow = aOneRange.aStart.Row();
     352                 :         17 :         SCCOL nEndCol = aOneRange.aEnd.Col();
     353                 :         17 :         SCROW nEndRow = aOneRange.aEnd.Row();
     354                 :         17 :         SCTAB nTab = aOneRange.aStart.Tab();
     355                 :            : 
     356                 :            :         pDocSh->GetDocument()->GetDataArea(
     357         [ +  - ]:         17 :                         nTab, nStartCol, nStartRow, nEndCol, nEndRow, false, false );
     358                 :            : 
     359                 :         17 :         ScRange aNew( nEndCol, nEndRow, nTab );
     360         [ +  - ]:         17 :         SetNewRange( aNew );
     361         [ +  - ]:         17 :     }
     362                 :         17 : }
     363                 :            : 
     364                 :          1 : void SAL_CALL ScCellCursorObj::gotoNext() throw(uno::RuntimeException)
     365                 :            : {
     366         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     367                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     368                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     369         [ +  - ]:          1 :     ScRange aOneRange( *rRanges[ 0 ] );
     370                 :            : 
     371         [ +  - ]:          1 :     aOneRange.Justify();
     372                 :          1 :     ScAddress aCursor(aOneRange.aStart);        //  bei Block immer den Start nehmen
     373                 :            : 
     374         [ +  - ]:          1 :     ScMarkData aMark;   // not used with bMarked=FALSE
     375                 :          1 :     SCCOL nNewX = aCursor.Col();
     376                 :          1 :     SCROW nNewY = aCursor.Row();
     377                 :          1 :     SCTAB nTab  = aCursor.Tab();
     378                 :          1 :     ScDocShell* pDocSh = GetDocShell();
     379         [ +  - ]:          1 :     if ( pDocSh )
     380         [ +  - ]:          1 :         pDocSh->GetDocument()->GetNextPos( nNewX,nNewY, nTab,  1,0, false,sal_True, aMark );
     381                 :            :     //! sonst Exception oder so
     382                 :            : 
     383 [ +  - ][ +  - ]:          1 :     SetNewRange( ScRange( nNewX, nNewY, nTab ) );
                 [ +  - ]
     384                 :          1 : }
     385                 :            : 
     386                 :          1 : void SAL_CALL ScCellCursorObj::gotoPrevious() throw(uno::RuntimeException)
     387                 :            : {
     388         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     389                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     390                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     391         [ +  - ]:          1 :     ScRange aOneRange( *rRanges[ 0 ] );
     392                 :            : 
     393         [ +  - ]:          1 :     aOneRange.Justify();
     394                 :          1 :     ScAddress aCursor(aOneRange.aStart);        //  bei Block immer den Start nehmen
     395                 :            : 
     396         [ +  - ]:          1 :     ScMarkData aMark;   // not used with bMarked=FALSE
     397                 :          1 :     SCCOL nNewX = aCursor.Col();
     398                 :          1 :     SCROW nNewY = aCursor.Row();
     399                 :          1 :     SCTAB nTab  = aCursor.Tab();
     400                 :          1 :     ScDocShell* pDocSh = GetDocShell();
     401         [ +  - ]:          1 :     if ( pDocSh )
     402         [ +  - ]:          1 :         pDocSh->GetDocument()->GetNextPos( nNewX,nNewY, nTab, -1,0, false,sal_True, aMark );
     403                 :            :     //! sonst Exception oder so
     404                 :            : 
     405 [ +  - ][ +  - ]:          1 :     SetNewRange( ScRange( nNewX, nNewY, nTab ) );
                 [ +  - ]
     406                 :          1 : }
     407                 :            : 
     408                 :          1 : void SAL_CALL ScCellCursorObj::gotoOffset( sal_Int32 nColumnOffset, sal_Int32 nRowOffset )
     409                 :            :                                                 throw(uno::RuntimeException)
     410                 :            : {
     411         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     412                 :          1 :     const ScRangeList& rRanges = GetRangeList();
     413                 :            :     OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
     414         [ +  - ]:          1 :     ScRange aOneRange( *rRanges[ 0 ] );
     415         [ +  - ]:          1 :     aOneRange.Justify();
     416                 :            : 
     417   [ +  -  +  -  :          4 :     if ( aOneRange.aStart.Col() + nColumnOffset >= 0 &&
             +  -  +  - ]
                 [ +  - ]
     418                 :          1 :          aOneRange.aEnd.Col()   + nColumnOffset <= MAXCOL &&
     419                 :          1 :          aOneRange.aStart.Row() + nRowOffset    >= 0 &&
     420                 :          1 :          aOneRange.aEnd.Row()   + nRowOffset    <= MAXROW )
     421                 :            :     {
     422                 :          1 :         ScRange aNew( (SCCOL)(aOneRange.aStart.Col() + nColumnOffset),
     423                 :          1 :                       (SCROW)(aOneRange.aStart.Row() + nRowOffset),
     424                 :          1 :                       aOneRange.aStart.Tab(),
     425                 :          1 :                       (SCCOL)(aOneRange.aEnd.Col() + nColumnOffset),
     426                 :          1 :                       (SCROW)(aOneRange.aEnd.Row() + nRowOffset),
     427                 :          2 :                       aOneRange.aEnd.Tab() );
     428         [ +  - ]:          1 :         SetNewRange( aNew );
     429         [ +  - ]:          1 :     }
     430                 :          1 : }
     431                 :            : 
     432                 :            : // XSheetCellRange
     433                 :            : 
     434                 :          3 : uno::Reference<sheet::XSpreadsheet> SAL_CALL ScCellCursorObj::getSpreadsheet()
     435                 :            :                                                 throw(uno::RuntimeException)
     436                 :            : {
     437         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     438 [ +  - ][ +  - ]:          3 :     return ScCellRangeObj::getSpreadsheet();
     439                 :            : }
     440                 :            : 
     441                 :            : // XCellRange
     442                 :            : 
     443                 :         20 : uno::Reference<table::XCell> SAL_CALL ScCellCursorObj::getCellByPosition(
     444                 :            :                                         sal_Int32 nColumn, sal_Int32 nRow )
     445                 :            :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
     446                 :            : {
     447         [ +  - ]:         20 :     SolarMutexGuard aGuard;
     448 [ +  + ][ +  - ]:         20 :     return ScCellRangeObj::getCellByPosition(nColumn,nRow);
     449                 :            : }
     450                 :            : 
     451                 :          3 : uno::Reference<table::XCellRange> SAL_CALL ScCellCursorObj::getCellRangeByPosition(
     452                 :            :                 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
     453                 :            :                                 throw(lang::IndexOutOfBoundsException, uno::RuntimeException)
     454                 :            : {
     455         [ +  - ]:          3 :     SolarMutexGuard aGuard;
     456 [ +  + ][ +  - ]:          3 :     return ScCellRangeObj::getCellRangeByPosition(nLeft,nTop,nRight,nBottom);
     457                 :            : }
     458                 :            : 
     459                 :          1 : uno::Reference<table::XCellRange> SAL_CALL ScCellCursorObj::getCellRangeByName(
     460                 :            :                         const rtl::OUString& rRange ) throw(uno::RuntimeException)
     461                 :            : {
     462         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     463 [ +  - ][ +  - ]:          1 :     return ScCellRangeObj::getCellRangeByName(rRange);
     464                 :            : }
     465                 :            : 
     466                 :            : // XServiceInfo
     467                 :            : 
     468                 :          0 : rtl::OUString SAL_CALL ScCellCursorObj::getImplementationName() throw(uno::RuntimeException)
     469                 :            : {
     470                 :          0 :     return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ScCellCursorObj" ));
     471                 :            : }
     472                 :            : 
     473                 :          4 : sal_Bool SAL_CALL ScCellCursorObj::supportsService( const rtl::OUString& rServiceName )
     474                 :            :                                                     throw(uno::RuntimeException)
     475                 :            : {
     476         [ +  - ]:          4 :     String aServiceStr( rServiceName );
     477         [ +  - ]:          4 :     return aServiceStr.EqualsAscii( SCSHEETCELLCURSOR_SERVICE ) ||
     478         [ +  - ]:          4 :            aServiceStr.EqualsAscii( SCCELLCURSOR_SERVICE ) ||
     479 [ +  - ][ +  - ]:          8 :            ScCellRangeObj::supportsService(rServiceName);
         [ +  - ][ +  + ]
                 [ +  - ]
     480                 :            : }
     481                 :            : 
     482                 :          0 : uno::Sequence<rtl::OUString> SAL_CALL ScCellCursorObj::getSupportedServiceNames()
     483                 :            :                                                     throw(uno::RuntimeException)
     484                 :            : {
     485                 :            :     //  get all service names from cell range
     486         [ #  # ]:          0 :     uno::Sequence<rtl::OUString> aParentSeq(ScCellRangeObj::getSupportedServiceNames());
     487                 :          0 :     sal_Int32 nParentLen = aParentSeq.getLength();
     488                 :          0 :     const rtl::OUString* pParentArr = aParentSeq.getConstArray();
     489                 :            : 
     490                 :            :     //  SheetCellCursor should be first (?)
     491         [ #  # ]:          0 :     uno::Sequence<rtl::OUString> aTotalSeq( nParentLen + 2 );
     492         [ #  # ]:          0 :     rtl::OUString* pTotalArr = aTotalSeq.getArray();
     493         [ #  # ]:          0 :     pTotalArr[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCSHEETCELLCURSOR_SERVICE ));
     494         [ #  # ]:          0 :     pTotalArr[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCCELLCURSOR_SERVICE ));
     495                 :            : 
     496                 :            :     //  append cell range services
     497         [ #  # ]:          0 :     for (long i=0; i<nParentLen; i++)
     498                 :          0 :         pTotalArr[i+2] = pParentArr[i];
     499                 :            : 
     500         [ #  # ]:          0 :     return aTotalSeq;
     501                 :            : }
     502                 :            : 
     503                 :            : 
     504                 :            : 
     505                 :            : 
     506                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10