1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svx.hxx" 30 31 #include "cellrange.hxx" 32 33 // ----------------------------------------------------------------------------- 34 35 using ::rtl::OUString; 36 using namespace ::com::sun::star::uno; 37 using namespace ::com::sun::star::lang; 38 using namespace ::com::sun::star::container; 39 using namespace ::com::sun::star::table; 40 41 // ----------------------------------------------------------------------------- 42 43 namespace sdr { namespace table { 44 45 // ----------------------------------------------------------------------------- 46 // CellRange 47 // ----------------------------------------------------------------------------- 48 49 CellRange::CellRange( const TableModelRef & xTable, sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) 50 : mxTable( xTable ) 51 , mnLeft(nLeft) 52 , mnTop(nTop) 53 , mnRight(nRight) 54 , mnBottom(nBottom) 55 { 56 } 57 58 // ----------------------------------------------------------------------------- 59 60 CellRange::~CellRange() 61 { 62 } 63 64 // ----------------------------------------------------------------------------- 65 // ICellRange 66 // ----------------------------------------------------------------------------- 67 68 sal_Int32 CellRange::getLeft() 69 { 70 return mnLeft; 71 } 72 73 sal_Int32 CellRange::getTop() 74 { 75 return mnTop; 76 } 77 78 sal_Int32 CellRange::getRight() 79 { 80 return mnRight; 81 } 82 83 sal_Int32 CellRange::getBottom() 84 { 85 return mnBottom; 86 } 87 88 Reference< XTable > CellRange::getTable() 89 { 90 return mxTable.get(); 91 } 92 93 // ----------------------------------------------------------------------------- 94 // XCellRange 95 // ----------------------------------------------------------------------------- 96 97 Reference< XCell > SAL_CALL CellRange::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException) 98 { 99 return mxTable->getCellByPosition( mnLeft + nColumn, mnTop + nRow ); 100 } 101 102 // ----------------------------------------------------------------------------- 103 104 Reference< XCellRange > SAL_CALL CellRange::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException) 105 { 106 if( (nLeft >= 0 ) && (nTop >= 0) && (nRight >= nLeft) && (nBottom >= nTop) ) 107 { 108 nLeft += mnLeft; 109 nTop += mnTop; 110 nRight += mnLeft; 111 nBottom += mnTop; 112 113 const sal_Int32 nMaxColumns = (mnRight == -1) ? mxTable->getColumnCount() : mnLeft; 114 const sal_Int32 nMaxRows = (mnBottom == -1) ? mxTable->getRowCount() : mnBottom; 115 if( (nLeft < nMaxColumns) && (nRight < nMaxColumns) && (nTop < nMaxRows) && (nBottom < nMaxRows) ) 116 { 117 return mxTable->getCellRangeByPosition( nLeft, nTop, nRight, nBottom ); 118 } 119 } 120 throw IndexOutOfBoundsException(); 121 } 122 123 // ----------------------------------------------------------------------------- 124 125 Reference< XCellRange > SAL_CALL CellRange::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException) 126 { 127 return Reference< XCellRange >(); 128 } 129 130 // ----------------------------------------------------------------------------- 131 132 } } 133