Version 4.3.0.0.beta1, tag libreoffice-4.3.0.0.beta1
[LibreOffice.git] / svx / source / table / cellrange.cxx
blob3615b366d676e4e9500c74e3692174eec6387510
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "cellrange.hxx"
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;
32 namespace sdr { namespace table {
35 // CellRange
38 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 , mnBottom(nBottom)
49 CellRange::~CellRange()
54 // ICellRange
57 sal_Int32 CellRange::getLeft()
59 return mnLeft;
62 sal_Int32 CellRange::getTop()
64 return mnTop;
67 sal_Int32 CellRange::getRight()
69 return mnRight;
72 sal_Int32 CellRange::getBottom()
74 return mnBottom;
77 Reference< XTable > CellRange::getTable()
79 return mxTable.get();
83 // XCellRange
86 Reference< XCell > SAL_CALL CellRange::getCellByPosition( sal_Int32 nColumn, sal_Int32 nRow ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
88 return mxTable->getCellByPosition( mnLeft + nColumn, mnTop + nRow );
93 Reference< XCellRange > SAL_CALL CellRange::getCellRangeByPosition( sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom ) throw (IndexOutOfBoundsException, RuntimeException, std::exception)
95 if( (nLeft >= 0 ) && (nTop >= 0) && (nRight >= nLeft) && (nBottom >= nTop) )
97 nLeft += mnLeft;
98 nTop += mnTop;
99 nRight += mnLeft;
100 nBottom += mnTop;
102 const sal_Int32 nMaxColumns = (mnRight == -1) ? mxTable->getColumnCount() : mnLeft;
103 const sal_Int32 nMaxRows = (mnBottom == -1) ? mxTable->getRowCount() : mnBottom;
104 if( (nLeft < nMaxColumns) && (nRight < nMaxColumns) && (nTop < nMaxRows) && (nBottom < nMaxRows) )
106 return mxTable->getCellRangeByPosition( nLeft, nTop, nRight, nBottom );
109 throw IndexOutOfBoundsException();
114 Reference< XCellRange > SAL_CALL CellRange::getCellRangeByName( const OUString& /*aRange*/ ) throw (RuntimeException, std::exception)
116 return Reference< XCellRange >();
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */