summaryrefslogtreecommitdiff
path: root/toolkit/source
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-03-07 22:10:21 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@oracle.com>2011-03-07 22:10:21 +0100
commit175636c31e205c1769742a16d1ac2fc4b1ae4c3e (patch)
tree3987ad1e586fddb7da10218187a5ab5726743f38 /toolkit/source
parent734177cad7e8b91f2c76f091da4959bf1ae07e5c (diff)
gridfixes: #i117625# recognize unsuccessful sorting attempts, and do not claim to be sorted afterwards
Diffstat (limited to 'toolkit/source')
-rwxr-xr-xtoolkit/source/controls/grid/sortablegriddatamodel.cxx28
-rwxr-xr-xtoolkit/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 db16ee7ad7e2..b11f65d264e9 100755
--- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx
@@ -332,14 +332,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 );
@@ -475,7 +479,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 );
@@ -497,7 +501,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 );
@@ -506,7 +510,7 @@ namespace toolkit
catch( const Exception& )
{
DBG_UNHANDLED_EXCEPTION();
- return;
+ return false;
}
// also build the "private to public" mapping
@@ -516,6 +520,8 @@ namespace toolkit
m_publicToPrivateRowIndex.swap( aPublicToPrivate );
m_privateToPublicRowIndex.swap( aPrivateToPublic );
+
+ return true;
}
//------------------------------------------------------------------------------------------------------------------
@@ -527,7 +533,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;
@@ -540,14 +547,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 0b07ff2d991a..6f0718fd5b17 100755
--- a/toolkit/source/controls/grid/sortablegriddatamodel.hxx
+++ b/toolkit/source/controls/grid/sortablegriddatamodel.hxx
@@ -155,7 +155,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.
@@ -184,6 +184,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;