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 "tablecolumns.hxx" 30 #include "tablecolumn.hxx" 31 32 // ----------------------------------------------------------------------------- 33 34 using ::rtl::OUString; 35 using namespace ::com::sun::star::uno; 36 using namespace ::com::sun::star::lang; 37 using namespace ::com::sun::star::container; 38 using namespace ::com::sun::star::table; 39 40 // ----------------------------------------------------------------------------- 41 42 namespace sdr { namespace table { 43 44 // ----------------------------------------------------------------------------- 45 // TableColumns 46 // ----------------------------------------------------------------------------- 47 48 TableColumns::TableColumns( const TableModelRef& xTableModel ) 49 : mxTableModel( xTableModel ) 50 { 51 } 52 53 // ----------------------------------------------------------------------------- 54 55 TableColumns::~TableColumns() 56 { 57 dispose(); 58 } 59 60 // ----------------------------------------------------------------------------- 61 62 void TableColumns::dispose() 63 { 64 mxTableModel.clear(); 65 } 66 67 // ----------------------------------------------------------------------------- 68 69 void TableColumns::throwIfDisposed() const throw (::com::sun::star::uno::RuntimeException) 70 { 71 if( !mxTableModel.is() ) 72 throw DisposedException(); 73 } 74 75 // ----------------------------------------------------------------------------- 76 // XTableRows 77 // ----------------------------------------------------------------------------- 78 79 void SAL_CALL TableColumns::insertByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException) 80 { 81 throwIfDisposed(); 82 mxTableModel->insertColumns( nIndex, nCount ); 83 } 84 85 // ----------------------------------------------------------------------------- 86 87 void SAL_CALL TableColumns::removeByIndex( sal_Int32 nIndex, sal_Int32 nCount ) throw (RuntimeException) 88 { 89 throwIfDisposed(); 90 mxTableModel->removeColumns( nIndex, nCount ); 91 } 92 93 // ----------------------------------------------------------------------------- 94 // XIndexAccess 95 // ----------------------------------------------------------------------------- 96 97 sal_Int32 SAL_CALL TableColumns::getCount() throw (RuntimeException) 98 { 99 throwIfDisposed(); 100 return mxTableModel->getColumnCount(); 101 } 102 103 // ----------------------------------------------------------------------------- 104 105 Any SAL_CALL TableColumns::getByIndex( sal_Int32 Index ) throw (IndexOutOfBoundsException, WrappedTargetException, RuntimeException) 106 { 107 throwIfDisposed(); 108 109 if( ( Index < 0 ) || ( Index >= mxTableModel->getColumnCount() ) ) 110 throw IndexOutOfBoundsException(); 111 112 return Any( Reference< XCellRange >( mxTableModel->getColumn( Index ).get() ) ); 113 } 114 115 // ----------------------------------------------------------------------------- 116 // XElementAccess 117 // ----------------------------------------------------------------------------- 118 119 Type SAL_CALL TableColumns::getElementType() throw (RuntimeException) 120 { 121 throwIfDisposed(); 122 123 return XCellRange::static_type(); 124 } 125 126 // ----------------------------------------------------------------------------- 127 128 sal_Bool SAL_CALL TableColumns::hasElements() throw (RuntimeException) 129 { 130 throwIfDisposed(); 131 132 return mxTableModel->getColumnCount() != 0; 133 } 134 135 // ----------------------------------------------------------------------------- 136 137 } } 138