toolkit/source/controls/grid/sortablegriddatamodel.cxx | 57 ++++------------- toolkit/source/controls/grid/sortablegriddatamodel.hxx | 4 + 2 files changed, 20 insertions(+), 41 deletions(-)
New commits: commit 7bfbc9523fd2a6c907cb3ad0b3407ae60c66d358 Author: Frank Schoenheit [fs] <frank.schoenh...@oracle.com> Date: Thu Mar 3 13:13:07 2011 +0100 gridfixes: #i117188# remove column sort when rows are inserted Change-Id: I43b041583c20b47c0fd33a9b5deadffe6fd8f273 Reviewed-on: https://gerrit.libreoffice.org/532 Reviewed-by: Miklos Vajna <vmik...@suse.cz> Tested-by: Miklos Vajna <vmik...@suse.cz> diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index fd476e3..ed83013 100644 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -293,45 +293,15 @@ namespace toolkit MethodGuard aGuard( *this, rBHelper ); DBG_CHECK_ME(); - // if the data is not sorted, broadcast the event unchanged - if ( !impl_isSorted_nothrow() ) - { - GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); - impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); - return; - } - - bool needReIndex = false; - if ( i_event.FirstRow > i_event.LastRow ) - { - OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - invalid row indexes!" ); - needReIndex = true; - } - else if ( size_t( i_event.FirstRow ) > m_privateToPublicRowIndex.size() ) + if ( impl_isSorted_nothrow() ) { - OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - too large row index!" ); - needReIndex = true; - } - - if ( needReIndex ) - { - impl_rebuildIndexesAndNotify( aGuard ); - return; + // no infrastructure is in place currently to sort the new row to its proper location, + // so we remove the sorting here. + impl_removeColumnSort( aGuard ); + aGuard.reset(); } - // we do not insert the new rows into the sort order - if somebody adds rows while we're sorted, s/he has - // to resort. Instead, we simply append the rows, no matter where they were inserted in the delegator data - // model. - sal_Int32 const nPublicFirstRow = sal_Int32( m_privateToPublicRowIndex.size() ); - sal_Int32 nPublicLastRow = nPublicFirstRow; - for ( sal_Int32 newRow = i_event.FirstRow; newRow <= i_event.LastRow; ++newRow, ++nPublicLastRow ) - { - m_privateToPublicRowIndex.push_back( nPublicLastRow ); - m_publicToPrivateRowIndex.push_back( nPublicLastRow ); - } - - // broadcast the event - GridDataEvent const aEvent( *this, -1, -1, nPublicFirstRow, nPublicLastRow ); + GridDataEvent const aEvent( impl_createPublicEvent( i_event ) ); impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); } @@ -568,11 +538,8 @@ namespace toolkit } //------------------------------------------------------------------------------------------------------------------ - void SAL_CALL SortableGridDataModel::removeColumnSort( ) throw (RuntimeException) + void SortableGridDataModel::impl_removeColumnSort( MethodGuard& i_instanceLock ) { - MethodGuard aGuard( *this, rBHelper ); - DBG_CHECK_ME(); - lcl_clear( m_publicToPrivateRowIndex ); lcl_clear( m_privateToPublicRowIndex ); @@ -582,11 +549,19 @@ namespace toolkit impl_broadcast( &XGridDataListener::dataChanged, GridDataEvent( *this, -1, -1, -1, -1 ), - aGuard + i_instanceLock ); } //------------------------------------------------------------------------------------------------------------------ + void SAL_CALL SortableGridDataModel::removeColumnSort( ) throw (RuntimeException) + { + MethodGuard aGuard( *this, rBHelper ); + DBG_CHECK_ME(); + impl_removeColumnSort( aGuard ); + } + + //------------------------------------------------------------------------------------------------------------------ Pair< ::sal_Int32, ::sal_Bool > SAL_CALL SortableGridDataModel::getCurrentSortOrder( ) throw (RuntimeException) { MethodGuard aGuard( *this, rBHelper ); diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx index 4222ed6..d5dd1e4 100644 --- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx @@ -179,6 +179,10 @@ namespace toolkit */ void impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ); + /** removes the current sorting, and notifies a change of all data + */ + void impl_removeColumnSort( MethodGuard& i_instanceLock ); + private: ::comphelper::ComponentContext m_context; bool m_isInitialized; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits