LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/svx/source/table - cellrange.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 30 50.0 %
Date: 2013-07-09 Functions: 8 11 72.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "cellrange.hxx"
      22             : 
      23             : // -----------------------------------------------------------------------------
      24             : 
      25             : using namespace ::com::sun::star::uno;
      26             : using namespace ::com::sun::star::lang;
      27             : using namespace ::com::sun::star::container;
      28             : using namespace ::com::sun::star::table;
      29             : 
      30             : // -----------------------------------------------------------------------------
      31             : 
      32             : namespace sdr { namespace table {
      33             : 
      34             : // -----------------------------------------------------------------------------
      35             : // CellRange
      36             : // -----------------------------------------------------------------------------
      37             : 
      38          16 : CellRange::CellRange( const TableModelRef & xTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom )
      39             : : mxTable( xTable )
      40             : , mnLeft(nLeft)
      41             : , mnTop(nTop)
      42             : , mnRight(nRight)
      43          16 : , mnBottom(nBottom)
      44             : {
      45          16 : }
      46             : 
      47             : // -----------------------------------------------------------------------------
      48             : 
      49          24 : CellRange::~CellRange()
      50             : {
      51          24 : }
      52             : 
      53             : // -----------------------------------------------------------------------------
      54             : // ICellRange
      55             : // -----------------------------------------------------------------------------
      56             : 
      57           8 : sal_Int32 CellRange::getLeft()
      58             : {
      59           8 :     return mnLeft;
      60             : }
      61             : 
      62           8 : sal_Int32 CellRange::getTop()
      63             : {
      64           8 :     return mnTop;
      65             : }
      66             : 
      67           8 : sal_Int32 CellRange::getRight()
      68             : {
      69           8 :     return mnRight;
      70             : }
      71             : 
      72           8 : sal_Int32 CellRange::getBottom()
      73             : {
      74           8 :     return mnBottom;
      75             : }
      76             : 
      77           8 : Reference< XTable > CellRange::getTable()
      78             : {
      79           8 :     return mxTable.get();
      80             : }
      81             : 
      82             : // -----------------------------------------------------------------------------
      83             : // XCellRange
      84             : // -----------------------------------------------------------------------------
      85             : 
      86           0 : Reference< XCell > SAL_CALL CellRange::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException)
      87             : {
      88           0 :     return mxTable->getCellByPosition( mnLeft + nColumn, mnTop + nRow );
      89             : }
      90             : 
      91             : // -----------------------------------------------------------------------------
      92             : 
      93           0 : Reference< XCellRange > SAL_CALL CellRange::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException)
      94             : {
      95           0 :     if( (nLeft >= 0 ) && (nTop >= 0) && (nRight >= nLeft) && (nBottom >= nTop)  )
      96             :     {
      97           0 :         nLeft += mnLeft;
      98           0 :         nTop += mnTop;
      99           0 :         nRight += mnLeft;
     100           0 :         nBottom += mnTop;
     101             : 
     102           0 :         const sal_Int32 nMaxColumns = (mnRight == -1) ? mxTable->getColumnCount() : mnLeft;
     103           0 :         const sal_Int32 nMaxRows = (mnBottom == -1) ? mxTable->getRowCount() : mnBottom;
     104           0 :         if( (nLeft < nMaxColumns) && (nRight < nMaxColumns) && (nTop < nMaxRows) && (nBottom < nMaxRows) )
     105             :         {
     106           0 :             return mxTable->getCellRangeByPosition( nLeft, nTop, nRight, nBottom );
     107             :         }
     108             :     }
     109           0 :     throw IndexOutOfBoundsException();
     110             : }
     111             : 
     112             : // -----------------------------------------------------------------------------
     113             : 
     114           0 : Reference< XCellRange > SAL_CALL CellRange::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException)
     115             : {
     116           0 :     return Reference< XCellRange >();
     117             : }
     118             : 
     119             : // -----------------------------------------------------------------------------
     120             : 
     121             : } }
     122             : 
     123             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10