Kaydet (Commit) 7bfbc952 authored tarafından Frank Schoenheit [fs]'s avatar Frank Schoenheit [fs] Kaydeden (comit) Miklos Vajna

gridfixes: #i117188# remove column sort when rows are inserted

Change-Id: I43b041583c20b47c0fd33a9b5deadffe6fd8f273
Reviewed-on: https://gerrit.libreoffice.org/532Reviewed-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
Tested-by: 's avatarMiklos Vajna <vmiklos@suse.cz>
üst 732f3546
...@@ -293,45 +293,15 @@ namespace toolkit ...@@ -293,45 +293,15 @@ namespace toolkit
MethodGuard aGuard( *this, rBHelper ); MethodGuard aGuard( *this, rBHelper );
DBG_CHECK_ME(); DBG_CHECK_ME();
// if the data is not sorted, broadcast the event unchanged if ( impl_isSorted_nothrow() )
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() )
{ {
OSL_ENSURE( false, "SortableGridDataModel::rowsInserted: invalid event - too large row index!" ); // no infrastructure is in place currently to sort the new row to its proper location,
needReIndex = true; // so we remove the sorting here.
} impl_removeColumnSort( aGuard );
aGuard.reset();
if ( needReIndex )
{
impl_rebuildIndexesAndNotify( aGuard );
return;
} }
// we do not insert the new rows into the sort order - if somebody adds rows while we're sorted, s/he has GridDataEvent const aEvent( impl_createPublicEvent( i_event ) );
// 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 );
impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard );
} }
...@@ -568,11 +538,8 @@ namespace toolkit ...@@ -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_publicToPrivateRowIndex );
lcl_clear( m_privateToPublicRowIndex ); lcl_clear( m_privateToPublicRowIndex );
...@@ -582,10 +549,18 @@ namespace toolkit ...@@ -582,10 +549,18 @@ namespace toolkit
impl_broadcast( impl_broadcast(
&XGridDataListener::dataChanged, &XGridDataListener::dataChanged,
GridDataEvent( *this, -1, -1, -1, -1 ), 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) Pair< ::sal_Int32, ::sal_Bool > SAL_CALL SortableGridDataModel::getCurrentSortOrder( ) throw (RuntimeException)
{ {
......
...@@ -179,6 +179,10 @@ namespace toolkit ...@@ -179,6 +179,10 @@ namespace toolkit
*/ */
void impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ); void impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock );
/** removes the current sorting, and notifies a change of all data
*/
void impl_removeColumnSort( MethodGuard& i_instanceLock );
private: private:
::comphelper::ComponentContext m_context; ::comphelper::ComponentContext m_context;
bool m_isInitialized; bool m_isInitialized;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment