diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-01-13 14:08:36 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-01-13 14:08:36 +0100 |
commit | 4c08b4b3d3b5427ffa843868704e8dd44c8b1826 (patch) | |
tree | a06a046c56caea9a3447d3bb61b65290075a80af /toolkit | |
parent | 6fba3904b909f7604a38e58e2a8ac3d2542a9410 (diff) |
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/controls/grid/defaultgriddatamodel.cxx | 49 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcontrol.cxx | 14 | ||||
-rw-r--r-- | toolkit/source/controls/grid/gridcontrol.hxx | 5 | ||||
-rwxr-xr-x | toolkit/source/controls/grid/grideventforwarder.cxx | 4 | ||||
-rwxr-xr-x | toolkit/source/controls/grid/grideventforwarder.hxx | 2 |
5 files changed, 23 insertions, 51 deletions
diff --git a/toolkit/source/controls/grid/defaultgriddatamodel.cxx b/toolkit/source/controls/grid/defaultgriddatamodel.cxx index 746be68d3b4e..3d9b8324de81 100644 --- a/toolkit/source/controls/grid/defaultgriddatamodel.cxx +++ b/toolkit/source/controls/grid/defaultgriddatamodel.cxx @@ -89,28 +89,6 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - namespace - { - Sequence< sal_Int32 > lcl_buildSingleElementSequence( sal_Int32 const i_index ) - { - Sequence< sal_Int32 > aIndexes(1); - aIndexes[0] = i_index; - return aIndexes; - } - Sequence< sal_Int32 > lcl_buildIndexSequence( sal_Int32 const i_start, sal_Int32 const i_end ) - { - Sequence< sal_Int32 > aIndexes; - ENSURE_OR_RETURN( i_end >= i_start, "lcl_buildIndexSequence: illegal indexes!", aIndexes ); - - aIndexes.realloc( i_end - i_start + 1 ); - for ( sal_Int32 i = i_start; i <= i_end; ++i ) - aIndexes[ i - i_start ] = i; - - return aIndexes; - } - } - - //------------------------------------------------------------------------------------------------------------------ void DefaultGridDataModel::broadcast( GridDataEvent const & i_event, void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::osl::ClearableMutexGuard & i_instanceLock ) { @@ -183,9 +161,10 @@ namespace toolkit if ( columnCount > m_nColumnCount ) m_nColumnCount = columnCount; + sal_Int32 const rowIndex = sal_Int32( m_aData.size() - 1 ); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( m_aData.size() - 1 ) ), - &XGridDataListener::rowsAdded, + GridDataEvent( *this, -1, -1, rowIndex, rowIndex ), + &XGridDataListener::rowsInserted, aGuard ); } @@ -224,9 +203,11 @@ namespace toolkit if ( maxColCount > m_nColumnCount ) m_nColumnCount = maxColCount; + sal_Int32 const firstRow = sal_Int32( m_aData.size() - rowCount ); + sal_Int32 const lastRow = sal_Int32( m_aData.size() - 1 ); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildIndexSequence( m_aData.size() - rowCount, m_aData.size() - 1 ) ), - &XGridDataListener::rowsAdded, + GridDataEvent( *this, -1, -1, firstRow, lastRow ), + &XGridDataListener::rowsInserted, aGuard ); } @@ -243,7 +224,7 @@ namespace toolkit m_aData.erase( m_aData.begin() + i_rowIndex ); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), &XGridDataListener::rowsRemoved, aGuard ); @@ -258,7 +239,7 @@ namespace toolkit m_aData.clear(); broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), Sequence< sal_Int32 >() ), + GridDataEvent( *this, -1, -1, -1, -1 ), &XGridDataListener::rowsRemoved, aGuard ); @@ -280,7 +261,7 @@ namespace toolkit rRowData[ i_columnIndex ] = i_value; broadcast( - GridDataEvent( *this, lcl_buildSingleElementSequence( i_columnIndex ), lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, i_columnIndex, i_columnIndex, i_rowIndex, i_rowIndex ), &XGridDataListener::dataChanged, aGuard ); @@ -317,12 +298,10 @@ namespace toolkit rDataRow[ columnIndex ] = i_values[ col ]; } - // by definition, the indexes in the notified sequences shall be sorted - Sequence< sal_Int32 > columnIndexes( i_columnIndexes ); - ::std::sort( stl_begin( columnIndexes ), stl_end( columnIndexes ) ); - + sal_Int32 const firstAffectedColumn = *::std::min_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); + sal_Int32 const lastAffectedColumn = *::std::max_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) ); broadcast( - GridDataEvent( *this, columnIndexes, lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, firstAffectedColumn, lastAffectedColumn, i_rowIndex, i_rowIndex ), &XGridDataListener::dataChanged, aGuard ); @@ -339,7 +318,7 @@ namespace toolkit m_aRowHeaders[ i_rowIndex ] = i_title; broadcast( - GridDataEvent( *this, Sequence< sal_Int32 >(), lcl_buildSingleElementSequence( i_rowIndex ) ), + GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ), &XGridDataListener::rowTitleChanged, aGuard ); diff --git a/toolkit/source/controls/grid/gridcontrol.cxx b/toolkit/source/controls/grid/gridcontrol.cxx index 33d0bf048bfd..b9cab5a18cf0 100644 --- a/toolkit/source/controls/grid/gridcontrol.cxx +++ b/toolkit/source/controls/grid/gridcontrol.cxx @@ -372,9 +372,9 @@ sal_Bool SAL_CALL UnoGridControl::setModel( const Reference< XControlModel >& i_ } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::selectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRows( rangeOfRows); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->selectRow( i_rowIndex ); } //---------------------------------------------------------------------------------------------------------------------- @@ -384,9 +384,9 @@ void SAL_CALL UnoGridControl::selectAllRows() throw (::com::sun::star::uno::Runt } //---------------------------------------------------------------------------------------------------------------------- -void SAL_CALL UnoGridControl::deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException) +void SAL_CALL UnoGridControl::deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException) { - Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRows( rangeOfRows); + Reference< XGridControl >( getPeer(), UNO_QUERY_THROW )->deselectRow( i_rowIndex ); } //---------------------------------------------------------------------------------------------------------------------- @@ -414,12 +414,6 @@ void SAL_CALL UnoGridControl::deselectAllRows() throw (::com::sun::star::uno::Ru } //---------------------------------------------------------------------------------------------------------------------- -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 ); diff --git a/toolkit/source/controls/grid/gridcontrol.hxx b/toolkit/source/controls/grid/gridcontrol.hxx index cf832cb80705..5259711e97d6 100644 --- a/toolkit/source/controls/grid/gridcontrol.hxx +++ b/toolkit/source/controls/grid/gridcontrol.hxx @@ -105,14 +105,13 @@ public: // ::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); + virtual void SAL_CALL selectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL selectAllRows() throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL deselectRows(const ::com::sun::star::uno::Sequence< ::sal_Int32 >& rangeOfRows) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL deselectRow( ::sal_Int32 i_rowIndex ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL deselectAllRows() throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::sal_Int32 > SAL_CALL getSelection() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectionEmpty() throw (::com::sun::star::uno::RuntimeException); virtual ::sal_Bool SAL_CALL isSelectedIndex(::sal_Int32 index) throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL selectRow(::sal_Int32 y) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL removeSelectionListener(const ::com::sun::star::uno::Reference< ::com::sun::star::awt::grid::XGridSelectionListener > & listener) throw (::com::sun::star::uno::RuntimeException); diff --git a/toolkit/source/controls/grid/grideventforwarder.cxx b/toolkit/source/controls/grid/grideventforwarder.cxx index b3d17a897bad..68293025bd4e 100755 --- a/toolkit/source/controls/grid/grideventforwarder.cxx +++ b/toolkit/source/controls/grid/grideventforwarder.cxx @@ -81,11 +81,11 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL GridEventForwarder::rowsAdded( const GridDataEvent& i_event ) throw (RuntimeException) + void SAL_CALL GridEventForwarder::rowsInserted( const GridDataEvent& i_event ) throw (RuntimeException) { Reference< XGridDataListener > xPeer( m_parent.getPeer(), UNO_QUERY ); if ( xPeer.is() ) - xPeer->rowsAdded( i_event ); + xPeer->rowsInserted( i_event ); } //------------------------------------------------------------------------------------------------------------------ diff --git a/toolkit/source/controls/grid/grideventforwarder.hxx b/toolkit/source/controls/grid/grideventforwarder.hxx index c0c09a7cc95d..0abdcc59fd85 100755 --- a/toolkit/source/controls/grid/grideventforwarder.hxx +++ b/toolkit/source/controls/grid/grideventforwarder.hxx @@ -61,7 +61,7 @@ namespace toolkit virtual void SAL_CALL release() throw(); // XGridDataListener - virtual void SAL_CALL rowsAdded( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL rowsInserted( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL rowsRemoved( 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); virtual void SAL_CALL rowTitleChanged( const ::com::sun::star::awt::grid::GridDataEvent& Event ) throw (::com::sun::star::uno::RuntimeException); |