diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-03 13:13:07 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-03-03 13:13:07 +0100 |
commit | 0fe2bc39aa1911546e4dccf1eff1047e10f72932 (patch) | |
tree | a119664b3236c6fbc9b5dd8013799ff6b1580439 /toolkit/source | |
parent | 8becbbb67be43e6a3adf7974e5a9b07dd8312386 (diff) |
gridfixes: #i117188# remove column sort when rows are inserted
Diffstat (limited to 'toolkit/source')
-rwxr-xr-x | toolkit/source/controls/grid/sortablegriddatamodel.cxx | 57 | ||||
-rwxr-xr-x | toolkit/source/controls/grid/sortablegriddatamodel.hxx | 4 |
2 files changed, 20 insertions, 41 deletions
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index 77a2ffa1637b..db16ee7ad7e2 100755 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -295,45 +295,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 ); } @@ -570,11 +540,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 ); @@ -584,11 +551,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 50f08d3a7113..0b07ff2d991a 100755 --- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx @@ -180,6 +180,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; |