1*b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b0724fc6SAndrew Rist * distributed with this work for additional information 6*b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9*b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15*b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17*b0724fc6SAndrew Rist * specific language governing permissions and limitations 18*b0724fc6SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b0724fc6SAndrew Rist *************************************************************/ 21*b0724fc6SAndrew Rist 22*b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_toolkit.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "defaultgridcolumnmodel.hxx" 28cdf0e10cSrcweir #include "gridcolumn.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir /** === begin UNO includes === **/ 31cdf0e10cSrcweir #include <com/sun/star/awt/XVclWindowPeer.hpp> 32cdf0e10cSrcweir /** === end UNO includes === **/ 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <comphelper/sequence.hxx> 35cdf0e10cSrcweir #include <comphelper/componentguard.hxx> 36cdf0e10cSrcweir #include <toolkit/helper/servicenames.hxx> 37cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 38cdf0e10cSrcweir #include <tools/diagnose_ex.h> 39cdf0e10cSrcweir 40cdf0e10cSrcweir //...................................................................................................................... 41cdf0e10cSrcweir namespace toolkit 42cdf0e10cSrcweir //...................................................................................................................... 43cdf0e10cSrcweir { 44cdf0e10cSrcweir /** === begin UNO using === **/ 45cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 46cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 47cdf0e10cSrcweir using ::com::sun::star::uno::RuntimeException; 48cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 49cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY_THROW; 50cdf0e10cSrcweir using ::com::sun::star::uno::UNO_QUERY; 51cdf0e10cSrcweir using ::com::sun::star::awt::grid::XGridColumn; 52cdf0e10cSrcweir using ::com::sun::star::uno::XInterface; 53cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 54cdf0e10cSrcweir using ::com::sun::star::lang::XComponent; 55cdf0e10cSrcweir using ::com::sun::star::lang::EventObject; 56cdf0e10cSrcweir using ::com::sun::star::container::XContainerListener; 57cdf0e10cSrcweir using ::com::sun::star::container::ContainerEvent; 58cdf0e10cSrcweir using ::com::sun::star::uno::Exception; 59cdf0e10cSrcweir using ::com::sun::star::lang::IndexOutOfBoundsException; 60cdf0e10cSrcweir using ::com::sun::star::util::XCloneable; 61cdf0e10cSrcweir using ::com::sun::star::lang::IllegalArgumentException; 62cdf0e10cSrcweir /** === end UNO using === **/ 63cdf0e10cSrcweir 64cdf0e10cSrcweir //================================================================================================================== 65cdf0e10cSrcweir //= DefaultGridColumnModel 66cdf0e10cSrcweir //================================================================================================================== 67cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 68cdf0e10cSrcweir DefaultGridColumnModel::DefaultGridColumnModel( const Reference< XMultiServiceFactory >& i_factory ) 69cdf0e10cSrcweir :DefaultGridColumnModel_Base( m_aMutex ) 70cdf0e10cSrcweir ,m_aContext( i_factory ) 71cdf0e10cSrcweir ,m_aContainerListeners( m_aMutex ) 72cdf0e10cSrcweir ,m_aColumns() 73cdf0e10cSrcweir { 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 77cdf0e10cSrcweir DefaultGridColumnModel::DefaultGridColumnModel( DefaultGridColumnModel const & i_copySource ) 78cdf0e10cSrcweir :cppu::BaseMutex() 79cdf0e10cSrcweir ,DefaultGridColumnModel_Base( m_aMutex ) 80cdf0e10cSrcweir ,m_aContext( i_copySource.m_aContext ) 81cdf0e10cSrcweir ,m_aContainerListeners( m_aMutex ) 82cdf0e10cSrcweir ,m_aColumns() 83cdf0e10cSrcweir { 84cdf0e10cSrcweir Columns aColumns; 85cdf0e10cSrcweir aColumns.reserve( i_copySource.m_aColumns.size() ); 86cdf0e10cSrcweir try 87cdf0e10cSrcweir { 88cdf0e10cSrcweir for ( Columns::const_iterator col = i_copySource.m_aColumns.begin(); 89cdf0e10cSrcweir col != i_copySource.m_aColumns.end(); 90cdf0e10cSrcweir ++col 91cdf0e10cSrcweir ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir Reference< XCloneable > const xCloneable( *col, UNO_QUERY_THROW ); 94cdf0e10cSrcweir Reference< XGridColumn > const xClone( xCloneable->createClone(), UNO_QUERY_THROW ); 95cdf0e10cSrcweir 96cdf0e10cSrcweir GridColumn* const pGridColumn = GridColumn::getImplementation( xClone ); 97cdf0e10cSrcweir if ( pGridColumn == NULL ) 98cdf0e10cSrcweir throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "invalid clone source implementation" ) ), *this ); 99cdf0e10cSrcweir // that's indeed a RuntimeException, not an IllegalArgumentException or some such: 100cdf0e10cSrcweir // a DefaultGridColumnModel implementation whose columns are not GridColumn implementations 101cdf0e10cSrcweir // is borked. 102cdf0e10cSrcweir pGridColumn->setIndex( col - i_copySource.m_aColumns.begin() ); 103cdf0e10cSrcweir 104cdf0e10cSrcweir aColumns.push_back( xClone ); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107cdf0e10cSrcweir catch( const Exception& ) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir if ( aColumns.size() == i_copySource.m_aColumns.size() ) 112cdf0e10cSrcweir m_aColumns.swap( aColumns ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 116cdf0e10cSrcweir DefaultGridColumnModel::~DefaultGridColumnModel() 117cdf0e10cSrcweir { 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 121cdf0e10cSrcweir ::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (RuntimeException) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir return m_aColumns.size(); 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 127cdf0e10cSrcweir Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::createColumn( ) throw (RuntimeException) 128cdf0e10cSrcweir { 129cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 130cdf0e10cSrcweir return new GridColumn(); 131cdf0e10cSrcweir } 132cdf0e10cSrcweir 133cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 134cdf0e10cSrcweir ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException, IllegalArgumentException) 135cdf0e10cSrcweir { 136cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 137cdf0e10cSrcweir 138cdf0e10cSrcweir GridColumn* const pGridColumn = GridColumn::getImplementation( i_column ); 139cdf0e10cSrcweir if ( pGridColumn == NULL ) 140cdf0e10cSrcweir throw IllegalArgumentException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "invalid column implementation" ) ), *this, 1 ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir m_aColumns.push_back( i_column ); 143cdf0e10cSrcweir sal_Int32 index = m_aColumns.size() - 1; 144cdf0e10cSrcweir pGridColumn->setIndex( index ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir // fire insertion notifications 147cdf0e10cSrcweir ContainerEvent aEvent; 148cdf0e10cSrcweir aEvent.Source = *this; 149cdf0e10cSrcweir aEvent.Accessor <<= index; 150cdf0e10cSrcweir aEvent.Element <<= i_column; 151cdf0e10cSrcweir 152cdf0e10cSrcweir aGuard.clear(); 153cdf0e10cSrcweir m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir return index; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir 158cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 159cdf0e10cSrcweir void SAL_CALL DefaultGridColumnModel::removeColumn( ::sal_Int32 i_columnIndex ) throw (RuntimeException, IndexOutOfBoundsException) 160cdf0e10cSrcweir { 161cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 162cdf0e10cSrcweir 163cdf0e10cSrcweir if ( ( i_columnIndex < 0 ) || ( size_t( i_columnIndex ) >= m_aColumns.size() ) ) 164cdf0e10cSrcweir throw IndexOutOfBoundsException( ::rtl::OUString(), *this ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir Columns::iterator const pos = m_aColumns.begin() + i_columnIndex; 167cdf0e10cSrcweir Reference< XGridColumn > const xColumn( *pos ); 168cdf0e10cSrcweir m_aColumns.erase( pos ); 169cdf0e10cSrcweir 170cdf0e10cSrcweir // update indexes of all subsequent columns 171cdf0e10cSrcweir sal_Int32 columnIndex( i_columnIndex ); 172cdf0e10cSrcweir for ( Columns::iterator updatePos = m_aColumns.begin() + columnIndex; 173cdf0e10cSrcweir updatePos != m_aColumns.end(); 174cdf0e10cSrcweir ++updatePos, ++columnIndex 175cdf0e10cSrcweir ) 176cdf0e10cSrcweir { 177cdf0e10cSrcweir GridColumn* pColumnImpl = GridColumn::getImplementation( *updatePos ); 178cdf0e10cSrcweir ENSURE_OR_CONTINUE( pColumnImpl, "DefaultGridColumnModel::removeColumn: invalid column implementation!" ); 179cdf0e10cSrcweir pColumnImpl->setIndex( columnIndex ); 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir // fire removal notifications 183cdf0e10cSrcweir ContainerEvent aEvent; 184cdf0e10cSrcweir aEvent.Source = *this; 185cdf0e10cSrcweir aEvent.Accessor <<= i_columnIndex; 186cdf0e10cSrcweir aEvent.Element <<= xColumn; 187cdf0e10cSrcweir 188cdf0e10cSrcweir aGuard.clear(); 189cdf0e10cSrcweir m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir // dispose the removed column 192cdf0e10cSrcweir try 193cdf0e10cSrcweir { 194cdf0e10cSrcweir Reference< XComponent > const xColComp( xColumn, UNO_QUERY_THROW ); 195cdf0e10cSrcweir xColComp->dispose(); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir catch( const Exception& ) 198cdf0e10cSrcweir { 199cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 200cdf0e10cSrcweir } 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 204cdf0e10cSrcweir Sequence< Reference< XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (RuntimeException) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 207cdf0e10cSrcweir return ::comphelper::containerToSequence( m_aColumns ); 208cdf0e10cSrcweir } 209cdf0e10cSrcweir 210cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 211cdf0e10cSrcweir Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (IndexOutOfBoundsException, RuntimeException) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 214cdf0e10cSrcweir 215cdf0e10cSrcweir if ( index >=0 && index < ((sal_Int32)m_aColumns.size())) 216cdf0e10cSrcweir return m_aColumns[index]; 217cdf0e10cSrcweir 218cdf0e10cSrcweir throw IndexOutOfBoundsException(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 222cdf0e10cSrcweir void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (RuntimeException) 223cdf0e10cSrcweir { 224cdf0e10cSrcweir ::std::vector< ContainerEvent > aRemovedColumns; 225cdf0e10cSrcweir ::std::vector< ContainerEvent > aInsertedColumns; 226cdf0e10cSrcweir 227cdf0e10cSrcweir { 228cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 229cdf0e10cSrcweir 230cdf0e10cSrcweir // remove existing columns 231cdf0e10cSrcweir while ( !m_aColumns.empty() ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir const size_t lastColIndex = m_aColumns.size() - 1; 234cdf0e10cSrcweir 235cdf0e10cSrcweir ContainerEvent aEvent; 236cdf0e10cSrcweir aEvent.Source = *this; 237cdf0e10cSrcweir aEvent.Accessor <<= sal_Int32( lastColIndex ); 238cdf0e10cSrcweir aEvent.Element <<= m_aColumns[ lastColIndex ]; 239cdf0e10cSrcweir aRemovedColumns.push_back( aEvent ); 240cdf0e10cSrcweir 241cdf0e10cSrcweir m_aColumns.erase( m_aColumns.begin() + lastColIndex ); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir 244cdf0e10cSrcweir // add new columns 245cdf0e10cSrcweir for ( sal_Int32 i=0; i<rowElements; ++i ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir ::rtl::Reference< GridColumn > const pGridColumn = new GridColumn(); 248cdf0e10cSrcweir Reference< XGridColumn > const xColumn( pGridColumn.get() ); 249cdf0e10cSrcweir ::rtl::OUStringBuffer colTitle; 250cdf0e10cSrcweir colTitle.appendAscii( "Column " ); 251cdf0e10cSrcweir colTitle.append( i + 1 ); 252cdf0e10cSrcweir pGridColumn->setTitle( colTitle.makeStringAndClear() ); 253cdf0e10cSrcweir pGridColumn->setColumnWidth( 80 /* APPFONT */ ); 254cdf0e10cSrcweir pGridColumn->setFlexibility( 1 ); 255cdf0e10cSrcweir pGridColumn->setResizeable( sal_True ); 256cdf0e10cSrcweir pGridColumn->setDataColumnIndex( i ); 257cdf0e10cSrcweir 258cdf0e10cSrcweir ContainerEvent aEvent; 259cdf0e10cSrcweir aEvent.Source = *this; 260cdf0e10cSrcweir aEvent.Accessor <<= i; 261cdf0e10cSrcweir aEvent.Element <<= xColumn; 262cdf0e10cSrcweir aInsertedColumns.push_back( aEvent ); 263cdf0e10cSrcweir 264cdf0e10cSrcweir m_aColumns.push_back( xColumn ); 265cdf0e10cSrcweir pGridColumn->setIndex( i ); 266cdf0e10cSrcweir } 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir // fire removal notifications 270cdf0e10cSrcweir for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); 271cdf0e10cSrcweir event != aRemovedColumns.end(); 272cdf0e10cSrcweir ++event 273cdf0e10cSrcweir ) 274cdf0e10cSrcweir { 275cdf0e10cSrcweir m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, *event ); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir // fire insertion notifications 279cdf0e10cSrcweir for ( ::std::vector< ContainerEvent >::const_iterator event = aInsertedColumns.begin(); 280cdf0e10cSrcweir event != aInsertedColumns.end(); 281cdf0e10cSrcweir ++event 282cdf0e10cSrcweir ) 283cdf0e10cSrcweir { 284cdf0e10cSrcweir m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, *event ); 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir // dispose removed columns 288cdf0e10cSrcweir for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); 289cdf0e10cSrcweir event != aRemovedColumns.end(); 290cdf0e10cSrcweir ++event 291cdf0e10cSrcweir ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir try 294cdf0e10cSrcweir { 295cdf0e10cSrcweir const Reference< XComponent > xColComp( event->Element, UNO_QUERY_THROW ); 296cdf0e10cSrcweir xColComp->dispose(); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir catch( const Exception& ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 301cdf0e10cSrcweir } 302cdf0e10cSrcweir } 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 306cdf0e10cSrcweir ::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.DefaultGridColumnModel" ) ); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 312cdf0e10cSrcweir sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); 315cdf0e10cSrcweir for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i ) 316cdf0e10cSrcweir if ( aServiceNames[i] == i_serviceName ) 317cdf0e10cSrcweir return sal_True; 318cdf0e10cSrcweir return sal_False; 319cdf0e10cSrcweir } 320cdf0e10cSrcweir 321cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 322cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); 325cdf0e10cSrcweir const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); 326cdf0e10cSrcweir return aSeq; 327cdf0e10cSrcweir } 328cdf0e10cSrcweir 329cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 330cdf0e10cSrcweir void SAL_CALL DefaultGridColumnModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) 331cdf0e10cSrcweir { 332cdf0e10cSrcweir if ( i_listener.is() ) 333cdf0e10cSrcweir m_aContainerListeners.addInterface( i_listener ); 334cdf0e10cSrcweir } 335cdf0e10cSrcweir 336cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 337cdf0e10cSrcweir void SAL_CALL DefaultGridColumnModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir if ( i_listener.is() ) 340cdf0e10cSrcweir m_aContainerListeners.removeInterface( i_listener ); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 344cdf0e10cSrcweir void SAL_CALL DefaultGridColumnModel::disposing() 345cdf0e10cSrcweir { 346cdf0e10cSrcweir DefaultGridColumnModel_Base::disposing(); 347cdf0e10cSrcweir 348cdf0e10cSrcweir EventObject aEvent( *this ); 349cdf0e10cSrcweir m_aContainerListeners.disposeAndClear( aEvent ); 350cdf0e10cSrcweir 351cdf0e10cSrcweir ::osl::MutexGuard aGuard( m_aMutex ); 352cdf0e10cSrcweir 353cdf0e10cSrcweir // remove, dispose and clear columns 354cdf0e10cSrcweir while ( !m_aColumns.empty() ) 355cdf0e10cSrcweir { 356cdf0e10cSrcweir try 357cdf0e10cSrcweir { 358cdf0e10cSrcweir const Reference< XComponent > xColComponent( m_aColumns[ 0 ], UNO_QUERY_THROW ); 359cdf0e10cSrcweir xColComponent->dispose(); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir catch( const Exception& ) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 364cdf0e10cSrcweir } 365cdf0e10cSrcweir 366cdf0e10cSrcweir m_aColumns.erase( m_aColumns.begin() ); 367cdf0e10cSrcweir } 368cdf0e10cSrcweir 369cdf0e10cSrcweir Columns aEmpty; 370cdf0e10cSrcweir m_aColumns.swap( aEmpty ); 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------------ 374cdf0e10cSrcweir Reference< XCloneable > SAL_CALL DefaultGridColumnModel::createClone( ) throw (RuntimeException) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir ::comphelper::ComponentGuard aGuard( *this, rBHelper ); 377cdf0e10cSrcweir return new DefaultGridColumnModel( *this ); 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir //...................................................................................................................... 381cdf0e10cSrcweir } // namespace toolkit 382cdf0e10cSrcweir //...................................................................................................................... 383cdf0e10cSrcweir 384cdf0e10cSrcweir //---------------------------------------------------------------------------------------------------------------------- 385cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rFactory) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); 388cdf0e10cSrcweir } 389