summaryrefslogtreecommitdiff
path: root/toolkit
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-09-03 14:46:42 -0500
committerMiklos Vajna <vmiklos@suse.cz>2012-09-14 07:00:55 +0000
commitd4e79eb8f8f633ce59ee172bcae44e06fdb723bd (patch)
tree4b811c47568f2d9f272f77ed090df75e5d77eb65 /toolkit
parenta7e949673cda3f0e2abfa49b2c22735f33205d01 (diff)
gridfixes: #i117625# recognize unsuccessful sorting attempts
and do not claim to be sorted afterwards Change-Id: I3d71d45893563eac3b59e865aa1aa8d31e8154a8 Reviewed-on: https://gerrit.libreoffice.org/535 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.cxx28
-rw-r--r--toolkit/source/controls/grid/sortablegriddatamodel.hxx6
2 files changed, 25 insertions, 9 deletions
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
index ed8301306633..4f4f60107692 100644
--- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
@@ -330,14 +330,18 @@ namespace toolkit
lcl_clear( m_publicToPrivateRowIndex );
lcl_clear( m_privateToPublicRowIndex );
+ // rebuild the index
+ if ( !impl_reIndex_nothrow( m_currentSortColumn, m_sortAscending ) )
+ {
+ impl_removeColumnSort( i_instanceLock );
+ return;
+ }
+
// broadcast an artificial event, saying that all rows have been removed
GridDataEvent const aRemovalEvent( *this, -1, -1, -1, -1 );
impl_broadcast( &XGridDataListener::rowsRemoved, aRemovalEvent, i_instanceLock );
i_instanceLock.reset();
- // rebuild the index
- impl_reIndex_nothrow( m_currentSortColumn, m_sortAscending );
-
// broadcast an artificial event, saying that n rows have been added
GridDataEvent const aAdditionEvent( *this, -1, -1, 0, m_delegator->getRowCount() - 1 );
impl_broadcast( &XGridDataListener::rowsInserted, aAdditionEvent, i_instanceLock );
@@ -473,7 +477,7 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
- void SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending )
+ bool SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending )
{
::sal_Int32 const rowCount( getRowCount() );
::std::vector< ::sal_Int32 > aPublicToPrivate( rowCount );
@@ -495,7 +499,7 @@ namespace toolkit
// get predicate object
::std::auto_ptr< ::comphelper::IKeyPredicateLess > const pPredicate( ::comphelper::getStandardLessPredicate( dataType, m_collator ) );
- ENSURE_OR_RETURN_VOID( pPredicate.get(), "SortableGridDataModel::impl_reIndex_nothrow: no sortable data found!" );
+ ENSURE_OR_RETURN_FALSE( pPredicate.get(), "SortableGridDataModel::impl_reIndex_nothrow: no sortable data found!" );
// then sort
CellDataLessComparison const aComparator( aColumnData, *pPredicate, i_sortAscending );
@@ -504,7 +508,7 @@ namespace toolkit
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
- return;
+ return false;
}
// also build the "private to public" mapping
@@ -514,6 +518,8 @@ namespace toolkit
m_publicToPrivateRowIndex.swap( aPublicToPrivate );
m_privateToPublicRowIndex.swap( aPrivateToPublic );
+
+ return true;
}
//------------------------------------------------------------------------------------------------------------------
@@ -525,7 +531,8 @@ namespace toolkit
if ( ( i_columnIndex < 0 ) || ( i_columnIndex >= getColumnCount() ) )
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
- impl_reIndex_nothrow( i_columnIndex, i_sortAscending );
+ if ( !impl_reIndex_nothrow( i_columnIndex, i_sortAscending ) )
+ return;
m_currentSortColumn = i_columnIndex;
m_sortAscending = i_sortAscending;
@@ -538,14 +545,19 @@ namespace toolkit
}
//------------------------------------------------------------------------------------------------------------------
- void SortableGridDataModel::impl_removeColumnSort( MethodGuard& i_instanceLock )
+ void SortableGridDataModel::impl_removeColumnSort_noBroadcast()
{
lcl_clear( m_publicToPrivateRowIndex );
lcl_clear( m_privateToPublicRowIndex );
m_currentSortColumn = -1;
m_sortAscending = sal_True;
+ }
+ //------------------------------------------------------------------------------------------------------------------
+ void SortableGridDataModel::impl_removeColumnSort( MethodGuard& i_instanceLock )
+ {
+ impl_removeColumnSort_noBroadcast();
impl_broadcast(
&XGridDataListener::dataChanged,
GridDataEvent( *this, -1, -1, -1, -1 ),
diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.hxx b/toolkit/source/controls/grid/sortablegriddatamodel.hxx
index d5dd1e4fdcfa..f29d9f302649 100644
--- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx
@@ -154,7 +154,7 @@ namespace toolkit
Neither <member>m_currentSortColumn</member> nor <member>m_sortAscending</member> are touched by this method.
Also, the given column index is not checked, this is the responsibility of the caller.
*/
- void impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending );
+ bool impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, sal_Bool const i_sortAscending );
/** translates the given event, obtained from our delegator, to a version which can be broadcasted to our own
clients.
@@ -183,6 +183,10 @@ namespace toolkit
*/
void impl_removeColumnSort( MethodGuard& i_instanceLock );
+ /** removes the current sorting, without any broadcast
+ */
+ void impl_removeColumnSort_noBroadcast();
+
private:
::comphelper::ComponentContext m_context;
bool m_isInitialized;