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