summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-03-03 13:13:07 +0100
committerMiklos Vajna <vmiklos@suse.cz>2012-09-14 06:58:40 +0000
commit7bfbc9523fd2a6c907cb3ad0b3407ae60c66d358 (patch)
treea34f961f8d7c856b2a5ead9f449ad427aaea5faf /toolkit
parent732f3546c4051d92e544df6462022e7d07765e83 (diff)
gridfixes: #i117188# remove column sort when rows are inserted
Change-Id: I43b041583c20b47c0fd33a9b5deadffe6fd8f273 Reviewed-on: https://gerrit.libreoffice.org/532 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'toolkit')
-rw-r--r--toolkit/source/controls/grid/sortablegriddatamodel.cxx57
-rw-r--r--toolkit/source/controls/grid/sortablegriddatamodel.hxx4
2 files changed, 20 insertions, 41 deletions
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
index fd476e3d31a7..ed8301306633 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 4222ed6b45b6..d5dd1e4fdcfa 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;