diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-12-07 13:50:47 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2010-12-07 13:50:47 +0100 |
commit | 7bef1fa0ecb93f800ae3d0b0ab049b00560fcdf1 (patch) | |
tree | 3becf5d1bc986e9483410cdec4332ba5bd07e058 /toolkit | |
parent | 2d8c797828962d0a5fb0725c15d1de6b33a04e8b (diff) |
gridsort: introduced container listeners at the grid model, reworked and fixed listener relationship between grid model/control/peer
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx | 6 | ||||
-rw-r--r-- | toolkit/source/controls/grid/defaultgridcolumnmodel.cxx | 379 | ||||
-rw-r--r-- | toolkit/source/controls/grid/defaultgridcolumnmodel.hxx | 63 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcolumn.cxx | 420 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcolumn.hxx | 62 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcontrol.cxx | 106 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcontrol.hxx | 27 | ||||
-rwxr-xr-x | toolkit/source/controls/grid/grideventforwarder.cxx | 141 | ||||
-rwxr-xr-x | toolkit/source/controls/grid/grideventforwarder.hxx | 84 | ||||
-rw-r--r-- | toolkit/source/controls/grid/makefile.mk | 3 | ||||
-rw-r--r-- | toolkit/util/tk.component | 2 |
11 files changed, 819 insertions, 474 deletions
diff --git a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx index c84a6e54d73b..611d90427609 100644 --- a/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx +++ b/toolkit/inc/toolkit/helper/mutexandbroadcasthelper.hxx @@ -39,7 +39,6 @@ class MutexAndBroadcastHelper public: MutexAndBroadcastHelper() : BrdcstHelper( Mutex ) {} - ::osl::Mutex Mutex; ::cppu::OBroadcastHelper BrdcstHelper; @@ -47,11 +46,6 @@ public: }; - - - - - #endif // _TOOLKIT_HELPER_MUTEXANDBROADCASTHELPER_HXX diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx index 011f3502cdd8..a48f75966bde 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.cxx @@ -27,174 +27,273 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" + #include "defaultgridcolumnmodel.hxx" -#include <comphelper/sequence.hxx> -#include <toolkit/helper/servicenames.hxx> + +/** === begin UNO includes === **/ #include <com/sun/star/awt/XVclWindowPeer.hpp> -#include <rtl/ref.hxx> +/** === end UNO includes === **/ -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::style; +#include <comphelper/sequence.hxx> +#include <toolkit/helper/servicenames.hxx> +#include <tools/diagnose_ex.h> +//...................................................................................................................... namespace toolkit +//...................................................................................................................... { + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::awt::grid::XGridColumn; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::lang::XMultiServiceFactory; + using ::com::sun::star::lang::XComponent; + using ::com::sun::star::lang::EventObject; + using ::com::sun::star::container::XContainerListener; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::uno::Exception; + /** === end UNO using === **/ + + //================================================================================================================== + //= DefaultGridColumnModel + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::DefaultGridColumnModel( const Reference< XMultiServiceFactory >& i_factory ) + :DefaultGridColumnModel_Base( m_aMutex ) + ,m_aContext( i_factory ) + ,m_aContainerListeners( m_aMutex ) + ,m_aColumns() + ,m_nColumnHeaderHeight(0) + { + } -/////////////////////////////////////////////////////////////////////// -// class DefaultGridColumnModel -/////////////////////////////////////////////////////////////////////// - -DefaultGridColumnModel::DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory) -: columns(std::vector< Reference< XGridColumn > >()) - ,m_nColumnHeaderHeight(0) - ,m_xFactory(xFactory) -{ -} - -//--------------------------------------------------------------------- - -DefaultGridColumnModel::~DefaultGridColumnModel() -{ -} - -//--------------------------------------------------------------------- - -::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException) -{ - return columns.size(); -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + DefaultGridColumnModel::~DefaultGridColumnModel() + { + } -::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - Reference<XGridColumn> xColumn(column); - columns.push_back(xColumn); - sal_Int32 index = columns.size() - 1; - xColumn->setIndex(index); - return index; -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnCount() throw (RuntimeException) + { + return m_aColumns.size(); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL DefaultGridColumnModel::addColumn( const Reference< XGridColumn > & i_column ) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); -::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (::com::sun::star::uno::RuntimeException) -{ - return comphelper::containerToSequence(columns); -} + m_aColumns.push_back( i_column ); + sal_Int32 index = m_aColumns.size() - 1; + i_column->setIndex( index ); -//--------------------------------------------------------------------- + return index; + } -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) -{ - if ( index >=0 && index < ((sal_Int32)columns.size())) + //------------------------------------------------------------------------------------------------------------------ + Sequence< Reference< XGridColumn > > SAL_CALL DefaultGridColumnModel::getColumns() throw (RuntimeException) { - return columns[index]; + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + return ::comphelper::containerToSequence( m_aColumns ); } - else - return Reference< XGridColumn >(); -} -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (::com::sun::star::uno::RuntimeException) -{ - m_nColumnHeaderHeight = _value; -} -//--------------------------------------------------------------------- -sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (::com::sun::star::uno::RuntimeException) -{ - return m_nColumnHeaderHeight; -} - -//--------------------------------------------------------------------- -void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - for(sal_Int32 i=0;i<rowElements;i++) + //------------------------------------------------------------------------------------------------------------------ + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::getColumn(::sal_Int32 index) throw (RuntimeException) { - Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); - columns.push_back(xColumn); - xColumn->setIndex(i); + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + if ( index >=0 && index < ((sal_Int32)m_aColumns.size())) + { + return m_aColumns[index]; + } + else + // TODO: exception + return Reference< XGridColumn >(); } -} -::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException) -{ - Reference<XGridColumn> xColumn( m_xFactory->createInstance ( OUString::createFromAscii( "com.sun.star.awt.grid.GridColumn" ) ), UNO_QUERY ); - xColumn->setColumnWidth(column->getColumnWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setMaxWidth(column->getMaxWidth()); - xColumn->setMinWidth(column->getMinWidth()); - xColumn->setPreferredWidth(column->getPreferredWidth()); - xColumn->setResizeable(column->getResizeable()); - xColumn->setTitle(column->getTitle()); - xColumn->setHorizontalAlign(column->getHorizontalAlign()); - return xColumn; -} -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- - -void SAL_CALL DefaultGridColumnModel::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::setColumnHeaderHeight(sal_Int32 _value) throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + m_nColumnHeaderHeight = _value; + } -void SAL_CALL DefaultGridColumnModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + sal_Int32 SAL_CALL DefaultGridColumnModel::getColumnHeaderHeight() throw (RuntimeException) + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aMutex ); + return m_nColumnHeaderHeight; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::setDefaultColumns(sal_Int32 rowElements) throw (RuntimeException) + { + ::std::vector< ContainerEvent > aRemovedColumns; + ::std::vector< ContainerEvent > aInsertedColumns; + + { + ::osl::MutexGuard aGuard( m_aMutex ); + + // remove existing columns + while ( !m_aColumns.empty() ) + { + const size_t lastColIndex = m_aColumns.size() - 1; + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= sal_Int32( lastColIndex ); + aEvent.Element <<= m_aColumns[ lastColIndex ]; + aRemovedColumns.push_back( aEvent ); + + m_aColumns.erase( m_aColumns.begin() + lastColIndex ); + } + + // add new columns + for ( sal_Int32 i=0; i<rowElements; ++i ) + { + const Reference< XGridColumn > xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW ); + + ContainerEvent aEvent; + aEvent.Source = *this; + aEvent.Accessor <<= i; + aEvent.Element <<= xColumn; + aInsertedColumns.push_back( aEvent ); + + m_aColumns.push_back( xColumn ); + xColumn->setIndex( i ); + } + } + + // fire removal notifications + for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); + event != aRemovedColumns.end(); + ++event + ) + { + m_aContainerListeners.notifyEach( &XContainerListener::elementRemoved, *event ); + } + + // fire insertion notifications + for ( ::std::vector< ContainerEvent >::const_iterator event = aInsertedColumns.begin(); + event != aInsertedColumns.end(); + ++event + ) + { + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, *event ); + } + + // dispose removed columns + for ( ::std::vector< ContainerEvent >::const_iterator event = aRemovedColumns.begin(); + event != aRemovedColumns.end(); + ++event + ) + { + try + { + const Reference< XComponent > xColComp( event->Element, UNO_QUERY_THROW ); + xColComp->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + } -void SAL_CALL DefaultGridColumnModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + Reference< XGridColumn > SAL_CALL DefaultGridColumnModel::copyColumn(const Reference< XGridColumn > & column) throw (RuntimeException) + { + Reference< XGridColumn > xColumn( m_aContext.createComponent( "com.sun.star.awt.grid.GridColumn" ), UNO_QUERY_THROW ); + xColumn->setColumnWidth(column->getColumnWidth()); + xColumn->setPreferredWidth(column->getPreferredWidth()); + xColumn->setMaxWidth(column->getMaxWidth()); + xColumn->setMinWidth(column->getMinWidth()); + xColumn->setPreferredWidth(column->getPreferredWidth()); + xColumn->setResizeable(column->getResizeable()); + xColumn->setTitle(column->getTitle()); + xColumn->setHorizontalAlign(column->getHorizontalAlign()); + return xColumn; + } -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.DefaultGridColumnModel" ) ); + } -::rtl::OUString SAL_CALL DefaultGridColumnModel::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridColumnModel" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i ) + if ( aServiceNames[i] == i_serviceName ) + return sal_True; + return sal_False; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + Sequence< ::rtl::OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); + const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } -sal_Bool SAL_CALL DefaultGridColumnModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_DefaultGridColumnModel ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::addContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + if ( i_listener.is() ) + m_aContainerListeners.addInterface( i_listener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::removeContainerListener( const Reference< XContainerListener >& i_listener ) throw (RuntimeException) + { + if ( i_listener.is() ) + m_aContainerListeners.removeInterface( i_listener ); + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL DefaultGridColumnModel::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridColumnModel ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL DefaultGridColumnModel::disposing() + { + DefaultGridColumnModel_Base::disposing(); + + EventObject aEvent( *this ); + m_aContainerListeners.disposeAndClear( aEvent ); + + ::osl::MutexGuard aGuard( m_aMutex ); + // remove, dispose and clear columns + { + while ( !m_aColumns.empty() ) + { + try + { + const Reference< XComponent > xColComponent( m_aColumns[ 0 ], UNO_QUERY_THROW ); + xColComponent->dispose(); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } + + m_aColumns.erase( m_aColumns.begin() ); + } + + Columns aEmpty; + m_aColumns.swap( aEmpty ); + } + } -} +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... -Reference< XInterface > SAL_CALL DefaultGridColumnModel_CreateInstance( const Reference< XMultiServiceFactory >& _rFactory) +//---------------------------------------------------------------------------------------------------------------------- +::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) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); + return ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridColumnModel( _rFactory ) ); } - diff --git a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx index 8b8c8bfc795c..964d604c8ab1 100644 --- a/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx +++ b/toolkit/source/controls/grid/defaultgridcolumnmodel.hxx @@ -25,76 +25,67 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_toolkit.hxx" +/** === begin UNO includes === **/ #include <com/sun/star/awt/grid/XGridColumnModel.hpp> #include <com/sun/star/awt/grid/XGridColumn.hpp> //#include <com/sun/star/awt/grid/GridColumnEvent.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> -#include <rtl/ref.hxx> -#include <vector> -#include <toolkit/helper/mutexandbroadcasthelper.hxx> -#include <com/sun/star/util/Color.hpp> #include <com/sun/star/style/VerticalAlignment.hpp> -#include <com/sun/star/awt/grid/XGridColumnListener.hpp> +#include <com/sun/star/util/Color.hpp> +/** === end UNO includes === **/ -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; +#include <cppuhelper/basemutex.hxx> +#include <cppuhelper/compbase2.hxx> +#include <comphelper/componentcontext.hxx> +#include <vector> namespace toolkit { //enum broadcast_type { column_added, column_removed, column_changed}; -class DefaultGridColumnModel : public ::cppu::WeakImplHelper2< XGridColumnModel, XServiceInfo >, - public MutexAndBroadcastHelper +typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumnModel + , ::com::sun::star::lang::XServiceInfo + > DefaultGridColumnModel_Base; + +class DefaultGridColumnModel :public ::cppu::BaseMutex + ,public DefaultGridColumnModel_Base { public: - DefaultGridColumnModel(const Reference< XMultiServiceFactory >& xFactory); + DefaultGridColumnModel(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xFactory); virtual ~DefaultGridColumnModel(); // XGridColumnModel - - //virtual ::sal_Bool SAL_CALL getColumnSelectionAllowed() throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL setColumnSelectionAllowed(::sal_Bool the_value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnCount() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > SAL_CALL getColumns() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL getColumn(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - //virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); - //virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException); virtual void SAL_CALL setColumnHeaderHeight( sal_Int32 _value) throw (com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getColumnHeaderHeight() throw (com::sun::star::uno::RuntimeException); virtual void SAL_CALL setDefaultColumns(sal_Int32 rowElements) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > SAL_CALL copyColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & column) throw (::com::sun::star::uno::RuntimeException); - // XComponent - virtual void SAL_CALL dispose( ) throw (RuntimeException); - virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException); // XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); -private: - /*void broadcast( broadcast_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue, sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_add( sal_Int32 index,const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn ); - void broadcast_remove( sal_Int32 index, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > & rColumn );*/ + // XContainer + virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + // OComponentHelper + virtual void SAL_CALL disposing(); + +private: + typedef ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > Columns; - std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumn > > columns; - sal_Bool selectionAllowed; - sal_Int32 m_nColumnHeaderHeight; - Reference< XMultiServiceFactory > m_xFactory; + ::comphelper::ComponentContext m_aContext; + ::cppu::OInterfaceContainerHelper m_aContainerListeners; + Columns m_aColumns; + sal_Int32 m_nColumnHeaderHeight; }; } diff --git a/toolkit/source/controls/grid/gridcolumn.cxx b/toolkit/source/controls/grid/gridcolumn.cxx index 6720d639f5c1..4094f4433538 100644 --- a/toolkit/source/controls/grid/gridcolumn.cxx +++ b/toolkit/source/controls/grid/gridcolumn.cxx @@ -25,20 +25,11 @@ * ************************************************************************/ -// MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" #include "gridcolumn.hxx" + #include <comphelper/sequence.hxx> #include <toolkit/helper/servicenames.hxx> -#include <rtl/ref.hxx> - -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::style; #define COLWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ColWidth" )) #define MAXWIDTH ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "MaxWidth" )) @@ -51,255 +42,240 @@ using namespace ::com::sun::star::style; namespace toolkit { + using namespace ::com::sun::star; + using namespace ::com::sun::star::uno; + using namespace ::com::sun::star::awt; + using namespace ::com::sun::star::awt::grid; + using namespace ::com::sun::star::lang; + using namespace ::com::sun::star::style; + + //================================================================================================================== + //= DefaultGridColumnModel + //================================================================================================================== + GridColumn::GridColumn() + :GridColumn_Base( m_aMutex ) + ,m_aIdentifier() + ,m_nIndex(0) + ,m_nColumnWidth(4) + ,m_nPreferredWidth(0) + ,m_nMaxWidth(0) + ,m_nMinWidth(0) + ,m_bResizeable(true) + ,m_eHorizontalAlign(HorizontalAlignment(0)) + { + } -/////////////////////////////////////////////////////////////////////// -// class GridColumn -/////////////////////////////////////////////////////////////////////// - -GridColumn::GridColumn() -: identifier(Any()) -,index(0) -,columnWidth(4) -,preferredWidth(0) -,maxWidth(0) -,minWidth(0) -,bResizeable(true) -,horizontalAlign(HorizontalAlignment(0)) -{ -} - -//--------------------------------------------------------------------- - -GridColumn::~GridColumn() -{ -} - -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + GridColumn::~GridColumn() + { + } -void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) -{ - ::cppu::OInterfaceContainerHelper* pIter = BrdcstHelper.getContainer( XGridColumnListener::static_type() ); - if( pIter ) + //------------------------------------------------------------------------------------------------------------------ + void GridColumn::broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ) { - ::cppu::OInterfaceIteratorHelper aListIter(*pIter); - while(aListIter.hasMoreElements()) + ::cppu::OInterfaceContainerHelper* pIter = rBHelper.getContainer( XGridColumnListener::static_type() ); + if( pIter ) { - XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next()); - switch( eType ) + ::cppu::OInterfaceIteratorHelper aListIter(*pIter); + while(aListIter.hasMoreElements()) { - case column_attribute_changed: pListener->columnChanged(aEvent); break; + XGridColumnListener* pListener = static_cast<XGridColumnListener*>(aListIter.next()); + switch( eType ) + { + case column_attribute_changed: pListener->columnChanged(aEvent); break; + } } } } -} - -//--------------------------------------------------------------------- -void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) -{ - Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - GridColumnEvent aEvent( xSource, name, oldValue, newValue, index); - broadcast( column_attribute_changed, aEvent); -} - -void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) -{ - if(PREFWIDTH == name) - preferredWidth = width; - else if (COLWIDTH == name) - columnWidth = width; -} -//--------------------------------------------------------------------- -// XGridColumn -//--------------------------------------------------------------------- - -::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) -{ - return identifier; -} - -//--------------------------------------------------------------------- - -void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) -{ - value >>= identifier; -} - -//-------------------------------------------------------------------- - -::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) -{ - broadcast_changed(UPDATE, Any(columnWidth), Any()); - return columnWidth; -} - -//-------------------------------------------------------------------- - -void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - columnWidth = value; - broadcast_changed(COLWIDTH, Any(columnWidth),Any(value)); -} -//-------------------------------------------------------------------- - -::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) -{ - broadcast_changed(UPDATE, Any(preferredWidth), Any()); - return preferredWidth; -} - -//-------------------------------------------------------------------- - -void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - preferredWidth = value; - broadcast_changed(PREFWIDTH, Any(preferredWidth),Any(value)); -} -//-------------------------------------------------------------------- - -::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return maxWidth; -} - -//-------------------------------------------------------------------- - -void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - maxWidth = value; - broadcast_changed(MAXWIDTH, Any(maxWidth),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void GridColumn::broadcast_changed(::rtl::OUString name, Any oldValue, Any newValue) + { + Reference< XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + GridColumnEvent aEvent( xSource, name, oldValue, newValue, m_nIndex); + broadcast( column_attribute_changed, aEvent); + } -::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) -{ - return minWidth; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::updateColumn(const ::rtl::OUString& name, sal_Int32 width) throw (::com::sun::star::uno::RuntimeException) + { + if(PREFWIDTH == name) + m_nPreferredWidth = width; + else if (COLWIDTH == name) + m_nColumnWidth = width; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Any SAL_CALL GridColumn::getIdentifier() throw (::com::sun::star::uno::RuntimeException) + { + return m_aIdentifier; + } -void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) -{ - minWidth = value; - broadcast_changed(MINWIDTH, Any(minWidth),Any(value)); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException) + { + value >>= m_aIdentifier; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getColumnWidth() throw (::com::sun::star::uno::RuntimeException) + { + broadcast_changed(UPDATE, Any(m_nColumnWidth), Any()); + return m_nColumnWidth; + } -::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) -{ - return title; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setColumnWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nColumnWidth = value; + broadcast_changed(COLWIDTH, Any(m_nColumnWidth),Any(value)); + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getPreferredWidth() throw (::com::sun::star::uno::RuntimeException) + { + broadcast_changed(UPDATE, Any(m_nPreferredWidth), Any()); + return m_nPreferredWidth; + } -void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) -{ - title = value; - broadcast_changed(TITLE, Any(title),Any(value)); -} -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setPreferredWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nPreferredWidth = value; + broadcast_changed(PREFWIDTH, Any(m_nPreferredWidth),Any(value)); + } -sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) -{ - return bResizeable; -} + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getMaxWidth() throw (::com::sun::star::uno::RuntimeException) + { + return m_nMaxWidth; + } -//-------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setMaxWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nMaxWidth = value; + broadcast_changed(MAXWIDTH, Any(m_nMaxWidth),Any(value)); + } -void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) -{ - bResizeable = value; - broadcast_changed(COLRESIZE, Any(bResizeable),Any(value)); -} -//--------------------------------------------------------------------- -HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) -{ - return horizontalAlign; -} -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::sal_Int32 SAL_CALL GridColumn::getMinWidth() throw (::com::sun::star::uno::RuntimeException) + { + return m_nMinWidth; + } -void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) -{ - horizontalAlign = align; - broadcast_changed(HALIGN, Any(horizontalAlign),Any(align)); -} -//--------------------------------------------------------------------- -void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XGridColumnListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setMinWidth(::sal_Int32 value) throw (::com::sun::star::uno::RuntimeException) + { + m_nMinWidth = value; + broadcast_changed(MINWIDTH, Any(m_nMinWidth),Any(value)); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getTitle() throw (::com::sun::star::uno::RuntimeException) + { + return m_sTitle; + } -void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XGridColumnListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException) + { + m_sTitle = value; + broadcast_changed(TITLE, Any(m_sTitle),Any(value)); + } -//--------------------------------------------------------------------- -// XComponent -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL GridColumn::getResizeable() throw (::com::sun::star::uno::RuntimeException) + { + return m_bResizeable; + } -void SAL_CALL GridColumn::dispose() throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setResizeable(sal_Bool value) throw (::com::sun::star::uno::RuntimeException) + { + m_bResizeable = value; + broadcast_changed(COLRESIZE, Any(m_bResizeable),Any(value)); + } - ::com::sun::star::lang::EventObject aEvent; - aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) ); - BrdcstHelper.aLC.disposeAndClear( aEvent ); -} + //------------------------------------------------------------------------------------------------------------------ + HorizontalAlignment SAL_CALL GridColumn::getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException) + { + return m_eHorizontalAlign; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setHorizontalAlign(HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException) + { + m_eHorizontalAlign = align; + broadcast_changed(HALIGN, Any(m_eHorizontalAlign),Any(align)); + } -void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.addListener( XEventListener::static_type(), xListener ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + { + rBHelper.addListener( XGridColumnListener::static_type(), xListener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (RuntimeException) + { + rBHelper.removeListener( XGridColumnListener::static_type(), xListener ); + } -void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException) -{ - BrdcstHelper.removeListener( XEventListener::static_type(), xListener ); -} -void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException) -{ - index = _nIndex; -} -//--------------------------------------------------------------------- -// XServiceInfo -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::dispose() throw (RuntimeException) + { + // simply disambiguate, the base class handles this + GridColumn_Base::dispose(); + } -::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.GridColumn" ) ); - return aImplName; -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::addEventListener( const Reference< XEventListener >& i_listener ) throw (RuntimeException) + { + // simply disambiguate, the base class handles this + GridColumn_Base::addEventListener( i_listener ); + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::removeEventListener( const Reference< XEventListener >& i_listener ) throw (RuntimeException) + { + // simply disambiguate, the base class handles this + GridColumn_Base::removeEventListener( i_listener ); + } -sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - return ServiceName.equalsAscii( szServiceName_GridColumn ); -} + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridColumn::setIndex(sal_Int32 _nIndex) throw (::com::sun::star::uno::RuntimeException) + { + m_nIndex = _nIndex; + } -//--------------------------------------------------------------------- + //------------------------------------------------------------------------------------------------------------------ + ::rtl::OUString SAL_CALL GridColumn::getImplementationName( ) throw (RuntimeException) + { + return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.openoffice.comp.toolkit.GridColumn" ) ); + } -::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException) -{ - ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() ); - static const OUString aServiceName( OUString::createFromAscii( szServiceName_GridColumn ) ); - static const Sequence< OUString > aSeq( &aServiceName, 1 ); - return aSeq; -} + //------------------------------------------------------------------------------------------------------------------ + sal_Bool SAL_CALL GridColumn::supportsService( const ::rtl::OUString& i_serviceName ) throw (RuntimeException) + { + const Sequence< ::rtl::OUString > aServiceNames( getSupportedServiceNames() ); + for ( sal_Int32 i=0; i<aServiceNames.getLength(); ++i ) + if ( aServiceNames[i] == i_serviceName ) + return sal_True; + return sal_False; + } + //------------------------------------------------------------------------------------------------------------------ + ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL GridColumn::getSupportedServiceNames( ) throw (RuntimeException) + { + const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_GridColumn ) ); + const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 ); + return aSeq; + } } -Reference< XInterface > SAL_CALL GridColumn_CreateInstance( const Reference< XMultiServiceFactory >& ) +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL GridColumn_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) { - return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::GridColumn ); + return *( new ::toolkit::GridColumn ); } diff --git a/toolkit/source/controls/grid/gridcolumn.hxx b/toolkit/source/controls/grid/gridcolumn.hxx index 38d43d55a07b..4a47f44ce674 100644 --- a/toolkit/source/controls/grid/gridcolumn.hxx +++ b/toolkit/source/controls/grid/gridcolumn.hxx @@ -33,32 +33,29 @@ #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/basemutex.hxx> #include <rtl/ref.hxx> #include <vector> #include <toolkit/helper/mutexandbroadcasthelper.hxx> #include <com/sun/star/style/HorizontalAlignment.hpp> -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::awt::grid; -using namespace ::com::sun::star::lang; - namespace toolkit { enum broadcast_column_type { column_attribute_changed}; -class GridColumn : public ::cppu::WeakImplHelper2< XGridColumn, XServiceInfo >, - public MutexAndBroadcastHelper + +typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::awt::grid::XGridColumn + , ::com::sun::star::lang::XServiceInfo + > GridColumn_Base; +class GridColumn :public ::cppu::BaseMutex + ,public GridColumn_Base { public: GridColumn(); virtual ~GridColumn(); - // XGridColumn + // ::com::sun::star::awt::grid::XGridColumn virtual ::com::sun::star::uno::Any SAL_CALL getIdentifier() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setIdentifier(const ::com::sun::star::uno::Any & value) throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getColumnWidth() throw (::com::sun::star::uno::RuntimeException); @@ -75,33 +72,34 @@ public: virtual void SAL_CALL setTitle(const ::rtl::OUString & value) throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::style::HorizontalAlignment SAL_CALL getHorizontalAlign() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setHorizontalAlign(::com::sun::star::style::HorizontalAlignment align) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL addColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL removeColumnListener( const Reference< XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeColumnListener( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridColumnListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL updateColumn( const ::rtl::OUString& name, ::sal_Int32 width ) throw (::com::sun::star::uno::RuntimeException); - // XComponent - virtual void SAL_CALL dispose( ) throw (RuntimeException); - virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException); - virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException); + + // XComponent (base of XGridColumn) + virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); // XServiceInfo - virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (RuntimeException); - virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException); - virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setIndex(sal_Int32 _nIndex)throw (::com::sun::star::uno::RuntimeException); private: - void broadcast( broadcast_column_type eType, const GridColumnEvent& aEvent ); - void broadcast_changed( ::rtl::OUString name, Any oldValue, Any newValue); + void broadcast( broadcast_column_type eType, const ::com::sun::star::awt::grid::GridColumnEvent& aEvent ); + void broadcast_changed( ::rtl::OUString name, ::com::sun::star::uno::Any oldValue, ::com::sun::star::uno::Any newValue); - Any identifier; - sal_Int32 index; - sal_Int32 columnWidth; - sal_Int32 preferredWidth; - sal_Int32 maxWidth; - sal_Int32 minWidth; - sal_Bool bResizeable; - ::rtl::OUString title; - ::com::sun::star::style::HorizontalAlignment horizontalAlign; + ::com::sun::star::uno::Any m_aIdentifier; + sal_Int32 m_nIndex; + sal_Int32 m_nColumnWidth; + sal_Int32 m_nPreferredWidth; + sal_Int32 m_nMaxWidth; + sal_Int32 m_nMinWidth; + sal_Bool m_bResizeable; + ::rtl::OUString m_sTitle; + ::com::sun::star::style::HorizontalAlignment m_eHorizontalAlign; }; } diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index e15e6683a902..57b5086e2272 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -28,7 +28,8 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_toolkit.hxx" -#include <gridcontrol.hxx> +#include "gridcontrol.hxx" +#include "grideventforwarder.hxx" #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/view/SelectionType.hpp> @@ -39,11 +40,12 @@ #include <toolkit/helper/property.hxx> #include <com/sun/star/awt/XVclWindowPeer.hpp> #include <comphelper/processfactory.hxx> -#include <osl/diagnose.h> +#include <tools/diagnose_ex.h> using ::rtl::OUString; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::awt; using namespace ::com::sun::star::awt::grid; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; @@ -55,6 +57,7 @@ namespace toolkit // ---------------------------------------------------- // class UnoGridModel // ---------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& i_factory ) :UnoControlModel( i_factory ) { @@ -96,21 +99,25 @@ UnoGridModel::UnoGridModel( const ::com::sun::star::uno::Reference< ::com::sun:: osl_decrementInterlockedCount( &m_refCount ); } +//---------------------------------------------------------------------------------------------------------------------- UnoGridModel::UnoGridModel( const UnoGridModel& rModel ) : UnoControlModel( rModel ) { } +//---------------------------------------------------------------------------------------------------------------------- UnoControlModel* UnoGridModel::Clone() const { return new UnoGridModel( *this ); } +//---------------------------------------------------------------------------------------------------------------------- OUString UnoGridModel::getServiceName() throw(RuntimeException) { return OUString::createFromAscii( szServiceName_GridControlModel ); } +//---------------------------------------------------------------------------------------------------------------------- Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const { switch( nPropId ) @@ -141,6 +148,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const } +//---------------------------------------------------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper& UnoGridModel::getInfoHelper() { static UnoPropertyArrayHelper* pHelper = NULL; @@ -152,6 +160,7 @@ Any UnoGridModel::ImplGetDefaultValue( sal_uInt16 nPropId ) const return *pHelper; } +//---------------------------------------------------------------------------------------------------------------------- // XMultiPropertySet Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(RuntimeException) { @@ -160,21 +169,29 @@ Reference< XPropertySetInfo > UnoGridModel::getPropertySetInfo( ) throw(Runtime } -// ---------------------------------------------------- -// class UnoGridControl -// ---------------------------------------------------- +//====================================================================================================================== +//= UnoGridControl +//====================================================================================================================== UnoGridControl::UnoGridControl( const Reference< XMultiServiceFactory >& i_factory ) :UnoGridControl_Base( i_factory ) ,mSelectionMode(SelectionType(1)) ,m_aSelectionListeners( *this ) + ,m_pEventForwarder( new GridEventForwarder( *this ) ) +{ +} + +//---------------------------------------------------------------------------------------------------------------------- +UnoGridControl::~UnoGridControl() { } +//---------------------------------------------------------------------------------------------------------------------- OUString UnoGridControl::GetComponentServiceName() { return OUString::createFromAscii( "Grid" ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) { lang::EventObject aEvt; @@ -183,105 +200,146 @@ void SAL_CALL UnoGridControl::dispose( ) throw(RuntimeException) UnoControl::dispose(); } -void UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) +//---------------------------------------------------------------------------------------------------------------------- +void SAL_CALL UnoGridControl::createPeer( const uno::Reference< awt::XToolkit > & rxToolkit, const uno::Reference< awt::XWindowPeer > & rParentPeer ) throw(uno::RuntimeException) { UnoControlBase::createPeer( rxToolkit, rParentPeer ); - Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); + const Reference< XGridControl > xGrid( getPeer(), UNO_QUERY_THROW ); xGrid->addSelectionListener(&m_aSelectionListeners); +} - Reference<XGridDataListener> xListener ( getPeer(), UNO_QUERY_THROW ); - Reference<XGridColumnListener> xColListener ( getPeer(), UNO_QUERY_THROW ); - Reference<XPropertySet> xPropSet ( getModel(), UNO_QUERY_THROW ); - - Reference<XGridDataModel> xGridDataModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "GridDataModel" )), UNO_QUERY_THROW ); - if(xGridDataModel != NULL) - xGridDataModel->addDataListener(xListener); - Reference<XGridColumnModel> xGridColumnModel ( xPropSet->getPropertyValue(OUString::createFromAscii( "ColumnModel" )), UNO_QUERY_THROW ); - if(xGridColumnModel != NULL) +//---------------------------------------------------------------------------------------------------------------------- +namespace +{ + void lcl_setEventForwarding( const Reference< XControlModel >& i_gridControlModel, const ::boost::scoped_ptr< GridEventForwarder >& i_listener, + bool const i_add ) { - for(int i = 0;i<xGridColumnModel->getColumnCount();i++) + const Reference< XPropertySet > xModelProps( i_gridControlModel, UNO_QUERY ); + if ( !xModelProps.is() ) + return; + + try { - xGridColumnModel->getColumn(i)->addColumnListener(xColListener); + const Reference< XContainer > xColModel( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnModel" ) ) ), + UNO_QUERY_THROW ); + if ( i_add ) + xColModel->addContainerListener( i_listener.get() ); + else + xColModel->removeContainerListener( i_listener.get() ); + + const Reference< XGridDataModel > xDataModel( + xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridDataModel" ) ) ), + UNO_QUERY_THROW + ); + if ( i_add ) + xDataModel->addDataListener( i_listener.get() ); + else + xDataModel->removeDataListener( i_listener.get() ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); } } } +//---------------------------------------------------------------------------------------------------------------------- +sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_model ) throw(RuntimeException) +{ + lcl_setEventForwarding( getModel(), m_pEventForwarder, false ); + if ( !UnoGridControl_Base::setModel( i_model ) ) + return sal_False; + lcl_setEventForwarding( getModel(), m_pEventForwarder, true ); + return sal_True; +} -// ------------------------------------------------------------------- -// XGridControl - +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 UnoGridControl::getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl > xGrid ( getPeer(), UNO_QUERY_THROW ); return xGrid->getItemIndexAtPoint( x, y ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->setToolTip( text, columns ); } -// ------------------------------------------------------------------- -// XGridSelection -// ------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL UnoGridControl::getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMinSelectionIndex(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Int32 SAL_CALL UnoGridControl::getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getMaxSelectionIndex(); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectAllRows(); } + +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectAllRows(); } + +//---------------------------------------------------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL UnoGridControl::getSelection() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->getSelection(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL UnoGridControl::isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectionEmpty(); } +//---------------------------------------------------------------------------------------------------------------------- ::sal_Bool SAL_CALL UnoGridControl::isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException) { return Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->isSelectedIndex( index ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException) { Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( y ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.addInterface( listener ); } +//---------------------------------------------------------------------------------------------------------------------- void SAL_CALL UnoGridControl::removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException) { m_aSelectionListeners.removeInterface( listener ); } + }//namespace toolkit Reference< XInterface > SAL_CALL GridControl_CreateInstance( const Reference< XMultiServiceFactory >& i_factory ) diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index c41981cacfd1..d5c76f4a07f6 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -30,21 +30,20 @@ #include <com/sun/star/awt/grid/XGridControl.hpp> #include <com/sun/star/view/SelectionType.hpp> + #include <toolkit/controls/unocontrolbase.hxx> #include <toolkit/controls/unocontrolmodel.hxx> #include <toolkit/helper/servicenames.hxx> #include <cppuhelper/implbase1.hxx> #include <comphelper/sequence.hxx> - #include <toolkit/helper/listenermultiplexer.hxx> -namespace toolkit { +#include <boost/scoped_ptr.hpp> -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::awt; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; +namespace toolkit +{ + +class GridEventForwarder; // =================================================================== // = UnoGridModel @@ -52,7 +51,7 @@ using namespace ::com::sun::star::container; class UnoGridModel : public UnoControlModel { protected: - Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; + ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); public: @@ -89,14 +88,13 @@ public: // ::com::sun::star::awt::XControl void SAL_CALL createPeer( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XToolkit >& Toolkit, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindowPeer >& Parent ) throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL setModel( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxModel ) throw(::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridControl - virtual ::sal_Int32 SAL_CALL getItemIndexAtPoint(::sal_Int32 x, ::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL setToolTip(const ::com::sun::star::uno::Sequence< ::rtl::OUString >& text, const ::com::sun::star::uno::Sequence< ::sal_Int32 >& columns) throw (::com::sun::star::uno::RuntimeException); // ::com::sun::star::awt::grid::XGridSelection - virtual ::sal_Int32 SAL_CALL getMinSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Int32 SAL_CALL getMaxSelectionIndex() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); @@ -114,9 +112,14 @@ public: DECLIMPL_SERVICEINFO_DERIVED( UnoGridControl, UnoControlBase, szServiceName_GridControl ) using UnoControl::getPeer; + +protected: + ~UnoGridControl(); + private: - ::com::sun::star::view::SelectionType mSelectionMode; - SelectionListenerMultiplexer m_aSelectionListeners; + ::com::sun::star::view::SelectionType mSelectionMode; + SelectionListenerMultiplexer m_aSelectionListeners; + ::boost::scoped_ptr< GridEventForwarder > m_pEventForwarder; }; } // toolkit diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx new file mode 100755 index 000000000000..2c3d740af04e --- /dev/null +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -0,0 +1,141 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_toolkit.hxx" + +#include "grideventforwarder.hxx" +#include "gridcontrol.hxx" + +/** === begin UNO includes === **/ +/** === end UNO includes === **/ + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + /** === begin UNO using === **/ + using ::com::sun::star::uno::Reference; + using ::com::sun::star::uno::XInterface; + using ::com::sun::star::uno::UNO_QUERY; + using ::com::sun::star::uno::UNO_QUERY_THROW; + using ::com::sun::star::uno::UNO_SET_THROW; + using ::com::sun::star::uno::Exception; + using ::com::sun::star::uno::RuntimeException; + using ::com::sun::star::uno::Any; + using ::com::sun::star::uno::makeAny; + using ::com::sun::star::uno::Sequence; + using ::com::sun::star::uno::Type; + using ::com::sun::star::awt::grid::GridDataEvent; + using ::com::sun::star::container::ContainerEvent; + using ::com::sun::star::lang::EventObject; + /** === end UNO using === **/ + + //================================================================================================================== + //= GridEventForwarder + //================================================================================================================== + //------------------------------------------------------------------------------------------------------------------ + GridEventForwarder::GridEventForwarder( UnoGridControl& i_parent ) + :m_parent( i_parent ) + { + } + + //------------------------------------------------------------------------------------------------------------------ + GridEventForwarder::~GridEventForwarder() + { + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::acquire() + { + m_parent.acquire(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::release() + { + m_parent.release(); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowAdded( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowAdded( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::rowRemoved( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->rowRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::dataChanged( const GridDataEvent& i_event ) throw (RuntimeException) + { + Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->dataChanged( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementInserted( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementInserted( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementRemoved( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementRemoved( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::elementReplaced( const ContainerEvent& i_event ) throw (RuntimeException) + { + Reference< XContainerListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->elementReplaced( i_event ); + } + + //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL GridEventForwarder::disposing( const EventObject& i_event ) throw (RuntimeException) + { + Reference< XEventListener > xPeer( m_parent.getPeer(), UNO_QUERY ); + if ( xPeer.is() ) + xPeer->disposing( i_event ); + } + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx new file mode 100755 index 000000000000..3066ead79c94 --- /dev/null +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -0,0 +1,84 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef TOOLKIT_GRIDEVENTFORWARDER_HXX +#define TOOLKIT_GRIDEVENTFORWARDER_HXX + +/** === begin UNO includes === **/ +#include <com/sun/star/awt/grid/XGridDataListener.hpp> +#include <com/sun/star/awt/grid/XGridColumnListener.hpp> +#include <com/sun/star/container/XContainerListener.hpp> +/** === end UNO includes === **/ + +#include <cppuhelper/implbase2.hxx> + +//...................................................................................................................... +namespace toolkit +{ +//...................................................................................................................... + + class UnoGridControl; + + //================================================================================================================== + //= GridEventForwarder + //================================================================================================================== + typedef ::cppu::ImplHelper2 < ::com::sun::star::awt::grid::XGridDataListener + , ::com::sun::star::container::XContainerListener + > GridEventForwarder_Base; + + class GridEventForwarder : public GridEventForwarder_Base + { + public: + GridEventForwarder( UnoGridControl& i_parent ); + virtual ~GridEventForwarder(); + + public: + // XInterface + virtual void SAL_CALL acquire(); + virtual void SAL_CALL release(); + + // XGridDataListener + virtual void SAL_CALL rowAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowRemoved( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL dataChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XContainerListener + virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + + // XEventListener + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& i_event ) throw (::com::sun::star::uno::RuntimeException); + + private: + UnoGridControl& m_parent; + }; + +//...................................................................................................................... +} // namespace toolkit +//...................................................................................................................... + +#endif // TOOLKIT_GRIDEVENTFORWARDER_HXX diff --git a/toolkit/source/controls/grid/makefile.mk b/toolkit/source/controls/grid/makefile.mk index 70bfc34b9d02..c7bc6f038b10 100644 --- a/toolkit/source/controls/grid/makefile.mk +++ b/toolkit/source/controls/grid/makefile.mk @@ -43,7 +43,8 @@ SLOFILES= \ $(SLO)$/gridcontrol.obj\ $(SLO)$/defaultgriddatamodel.obj\ $(SLO)$/defaultgridcolumnmodel.obj\ - $(SLO)$/gridcolumn.obj + $(SLO)$/gridcolumn.obj\ + $(SLO)$/grideventforwarder.obj # --- Targets ------------------------------------------------------ diff --git a/toolkit/util/tk.component b/toolkit/util/tk.component index e782283c39eb..e919e8451dbb 100644 --- a/toolkit/util/tk.component +++ b/toolkit/util/tk.component @@ -41,7 +41,7 @@ <implementation name="stardiv.Toolkit.DefaultGridDataModel"> <service name="com.sun.star.awt.grid.DefaultGridDataModel"/> </implementation> - <implementation name="stardiv.Toolkit.GridColumn"> + <implementation name="org.openoffice.comp.toolkit.GridColumn"> <service name="com.sun.star.awt.grid.GridColumn"/> </implementation> <implementation name="stardiv.Toolkit.GridControl"> |