xref: /aoo42x/main/svx/source/table/tablerows.cxx (revision f6e50924)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <com/sun/star/lang/DisposedException.hpp>
28 
29 #include "cell.hxx"
30 #include "tablerow.hxx"
31 #include "tablerows.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 // TableRows
47 // -----------------------------------------------------------------------------
48 
TableRows(const TableModelRef & xTableModel)49 TableRows::TableRows( const TableModelRef& xTableModel )
50 : mxTableModel( xTableModel )
51 {
52 }
53 
54 // -----------------------------------------------------------------------------
55 
~TableRows()56 TableRows::~TableRows()
57 {
58 	dispose();
59 }
60 
61 // -----------------------------------------------------------------------------
62 
dispose()63 void TableRows::dispose()
64 {
65 	mxTableModel.clear();
66 }
67 
68 // -----------------------------------------------------------------------------
69 
throwIfDisposed() const70 void TableRows::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException)
71 {
72 	if( !mxTableModel.is() )
73 		throw DisposedException();
74 }
75 
76 // -----------------------------------------------------------------------------
77 // XTableRows
78 // -----------------------------------------------------------------------------
79 
insertByIndex(sal_Int32 nIndex,sal_Int32 nCount)80 void SAL_CALL TableRows::insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException)
81 {
82 	throwIfDisposed();
83 	mxTableModel->insertRows( nIndex, nCount );
84 }
85 
86 // -----------------------------------------------------------------------------
87 
removeByIndex(sal_Int32 nIndex,sal_Int32 nCount)88 void SAL_CALL TableRows::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException)
89 {
90 	throwIfDisposed();
91 	mxTableModel->removeRows( nIndex, nCount );
92 }
93 
94 // -----------------------------------------------------------------------------
95 // XIndexAccess
96 // -----------------------------------------------------------------------------
97 
getCount()98 sal_Int32 SAL_CALL TableRows::getCount() throw (RuntimeException)
99 {
100 	throwIfDisposed();
101 	return mxTableModel->getRowCount();
102 }
103 
104 // -----------------------------------------------------------------------------
105 
getByIndex(sal_Int32 Index)106 Any SAL_CALL TableRows::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
107 {
108 	throwIfDisposed();
109 	return Any( Reference< XCellRange >( static_cast< XCellRange* >( mxTableModel->getRow( Index ).get() ) ) );
110 }
111 
112 // -----------------------------------------------------------------------------
113 // XElementAccess
114 // -----------------------------------------------------------------------------
115 
getElementType()116 Type SAL_CALL TableRows::getElementType() throw (RuntimeException)
117 {
118 	throwIfDisposed();
119 	return XCellRange::static_type();
120 }
121 
122 // -----------------------------------------------------------------------------
123 
hasElements()124 sal_Bool SAL_CALL TableRows::hasElements() throw (RuntimeException)
125 {
126 	throwIfDisposed();
127 	return mxTableModel->getRowCount() != 0;
128 }
129 
130 // -----------------------------------------------------------------------------
131 
132 } }
133