2009-08-26 13:11:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2009-08-26 13:11:27 +00:00
|
|
|
*
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
|
|
|
*
|
|
|
|
* This file is part of OpenOffice.org.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_toolkit.hxx"
|
2010-02-15 14:45:34 +01:00
|
|
|
#include "defaultgriddatamodel.hxx"
|
2011-01-10 15:47:51 +01:00
|
|
|
|
|
|
|
#include <comphelper/stlunosequence.hxx>
|
2009-08-26 13:11:27 +00:00
|
|
|
#include <toolkit/helper/servicenames.hxx>
|
2011-01-10 15:47:51 +01:00
|
|
|
#include <tools/diagnose_ex.h>
|
2009-08-26 13:11:27 +00:00
|
|
|
#include <rtl/ref.hxx>
|
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
using ::rtl::OUString;
|
2011-01-10 15:47:51 +01:00
|
|
|
using ::comphelper::stl_begin;
|
|
|
|
using ::comphelper::stl_end;
|
2009-08-26 13:11:27 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::awt;
|
|
|
|
using namespace ::com::sun::star::awt::grid;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//......................................................................................................................
|
2009-08-26 13:11:27 +00:00
|
|
|
namespace toolkit
|
2011-01-03 23:14:55 +01:00
|
|
|
//......................................................................................................................
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-03 23:14:55 +01:00
|
|
|
/** === begin UNO using === **/
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::RuntimeException;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY_THROW;
|
|
|
|
using ::com::sun::star::uno::UNO_QUERY;
|
|
|
|
using ::com::sun::star::uno::XInterface;
|
|
|
|
using ::com::sun::star::lang::XComponent;
|
|
|
|
using ::com::sun::star::lang::EventObject;
|
|
|
|
using ::com::sun::star::uno::Exception;
|
|
|
|
using ::com::sun::star::util::XCloneable;
|
|
|
|
/** === end UNO using === **/
|
|
|
|
|
|
|
|
//==================================================================================================================
|
|
|
|
//= DefaultGridDataModel
|
|
|
|
//==================================================================================================================
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DefaultGridDataModel::DefaultGridDataModel()
|
2011-01-04 15:09:05 +01:00
|
|
|
:DefaultGridDataModel_Base()
|
|
|
|
,MutexAndBroadcastHelper()
|
2011-01-03 23:14:55 +01:00
|
|
|
,m_aRowHeaders()
|
2011-01-10 15:47:51 +01:00
|
|
|
,m_nColumnCount(0)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DefaultGridDataModel::DefaultGridDataModel( DefaultGridDataModel const & i_copySource )
|
2011-01-04 15:09:05 +01:00
|
|
|
:DefaultGridDataModel_Base()
|
|
|
|
,MutexAndBroadcastHelper()
|
2011-01-03 23:14:55 +01:00
|
|
|
,m_aData( i_copySource.m_aData )
|
|
|
|
,m_aRowHeaders( i_copySource.m_aRowHeaders )
|
|
|
|
{
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DefaultGridDataModel::~DefaultGridDataModel()
|
|
|
|
{
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void DefaultGridDataModel::broadcast( GridDataEvent const & i_event,
|
|
|
|
void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::osl::ClearableMutexGuard & i_instanceLock )
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::cppu::OInterfaceContainerHelper* pListeners = BrdcstHelper.getContainer( XGridDataListener::static_type() );
|
|
|
|
if ( !pListeners )
|
|
|
|
return;
|
|
|
|
|
|
|
|
i_instanceLock.clear();
|
|
|
|
pListeners->notifyEach( i_listenerMethod, i_event );
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::sal_Int32 SAL_CALL DefaultGridDataModel::getRowCount() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
2011-01-03 23:14:55 +01:00
|
|
|
return m_aData.size();
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-06 16:28:45 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::sal_Int32 SAL_CALL DefaultGridDataModel::getColumnCount() throw (::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
|
|
|
return m_nColumnCount;
|
2011-01-06 16:28:45 +01:00
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-14 13:19:09 +01:00
|
|
|
DefaultGridDataModel::CellData const & DefaultGridDataModel::impl_getCellData_throw( sal_Int32 const i_column, sal_Int32 const i_row ) const
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( ( i_row < 0 ) || ( size_t( i_row ) > m_aData.size() )
|
|
|
|
|| ( i_column < 0 ) || ( i_column > m_nColumnCount )
|
|
|
|
)
|
2011-01-14 13:19:09 +01:00
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *const_cast< DefaultGridDataModel* >( this ) );
|
2011-01-07 15:52:55 +01:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
RowData const & rRow( m_aData[ i_row ] );
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( size_t( i_column ) < rRow.size() )
|
|
|
|
return rRow[ i_column ];
|
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
static CellData s_aEmpty;
|
|
|
|
return s_aEmpty;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DefaultGridDataModel::CellData& DefaultGridDataModel::impl_getCellDataAccess_throw( sal_Int32 const i_column, sal_Int32 const i_row )
|
|
|
|
{
|
|
|
|
if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aData.size() )
|
|
|
|
|| ( i_column < 0 ) || ( i_column >= m_nColumnCount )
|
|
|
|
)
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
|
|
|
|
|
|
|
RowData& rRowData( m_aData[ i_row ] );
|
|
|
|
if ( size_t( i_column ) >= rRowData.size() )
|
|
|
|
rRowData.resize( i_column + 1 );
|
|
|
|
return rRowData[ i_column ];
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
|
|
|
return impl_getCellData_throw( i_column, i_row ).first;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL DefaultGridDataModel::getCellToolTip( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
|
|
|
return impl_getCellData_throw( i_column, i_row ).second;
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
::rtl::OUString SAL_CALL DefaultGridDataModel::getRowTitle( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( ( i_row < 0 ) || ( size_t( i_row ) >= m_aRowHeaders.size() ) )
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
return m_aRowHeaders[ i_row ];
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::addRow( const ::rtl::OUString& i_title, const Sequence< Any >& i_data ) throw (RuntimeException)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
|
|
|
|
sal_Int32 const columnCount = i_data.getLength();
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
// store header name
|
2011-01-10 15:47:51 +01:00
|
|
|
m_aRowHeaders.push_back( i_title );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
// store row m_aData
|
2011-01-14 13:19:09 +01:00
|
|
|
impl_addRow( i_data );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
// update column count
|
|
|
|
if ( columnCount > m_nColumnCount )
|
|
|
|
m_nColumnCount = columnCount;
|
2009-08-26 13:11:27 +00:00
|
|
|
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
sal_Int32 const rowIndex = sal_Int32( m_aData.size() - 1 );
|
2011-01-10 15:47:51 +01:00
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, -1, -1, rowIndex, rowIndex ),
|
|
|
|
&XGridDataListener::rowsInserted,
|
2011-01-10 15:47:51 +01:00
|
|
|
aGuard
|
|
|
|
);
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void DefaultGridDataModel::impl_addRow( Sequence< Any > const & i_rowData, sal_Int32 const i_assumedColCount )
|
|
|
|
{
|
|
|
|
OSL_PRECOND( ( i_assumedColCount <= 0 ) || ( i_assumedColCount >= i_rowData.getLength() ),
|
|
|
|
"DefaultGridDataModel::impl_addRow: invalid column count!" );
|
|
|
|
|
|
|
|
RowData newRow( i_assumedColCount > 0 ? i_assumedColCount : i_rowData.getLength() );
|
|
|
|
RowData::iterator cellData = newRow.begin();
|
|
|
|
for ( const Any* pData = stl_begin( i_rowData ); pData != stl_end( i_rowData ); ++pData, ++cellData )
|
|
|
|
cellData->first = *pData;
|
|
|
|
|
|
|
|
m_aData.push_back( newRow );
|
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::addRows( const Sequence< ::rtl::OUString >& i_titles, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException)
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( i_titles.getLength() != i_data.getLength() )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *this, -1 );
|
|
|
|
|
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
|
|
|
|
sal_Int32 const rowCount = i_titles.getLength();
|
|
|
|
if ( rowCount == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// determine max col count in the new data
|
|
|
|
sal_Int32 maxColCount = 0;
|
|
|
|
for ( sal_Int32 row=0; row<rowCount; ++row )
|
|
|
|
if ( i_data[row].getLength() > maxColCount )
|
|
|
|
maxColCount = i_data[row].getLength();
|
|
|
|
|
|
|
|
if ( maxColCount < m_nColumnCount )
|
|
|
|
maxColCount = m_nColumnCount;
|
|
|
|
|
|
|
|
for ( sal_Int32 row=0; row<rowCount; ++row )
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
m_aRowHeaders.push_back( i_titles[row] );
|
2011-01-14 13:19:09 +01:00
|
|
|
impl_addRow( i_data[row], maxColCount );
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2011-01-10 15:47:51 +01:00
|
|
|
|
|
|
|
if ( maxColCount > m_nColumnCount )
|
|
|
|
m_nColumnCount = maxColCount;
|
|
|
|
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
sal_Int32 const firstRow = sal_Int32( m_aData.size() - rowCount );
|
|
|
|
sal_Int32 const lastRow = sal_Int32( m_aData.size() - 1 );
|
2011-01-10 15:47:51 +01:00
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, -1, -1, firstRow, lastRow ),
|
|
|
|
&XGridDataListener::rowsInserted,
|
2011-01-10 15:47:51 +01:00
|
|
|
aGuard
|
|
|
|
);
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::removeRow( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
2010-02-12 17:05:02 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) )
|
2011-01-06 16:28:45 +01:00
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
m_aRowHeaders.erase( m_aRowHeaders.begin() + i_rowIndex );
|
|
|
|
m_aData.erase( m_aData.begin() + i_rowIndex );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ),
|
2011-01-10 15:47:51 +01:00
|
|
|
&XGridDataListener::rowsRemoved,
|
|
|
|
aGuard
|
|
|
|
);
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::removeAllRows( ) throw (RuntimeException)
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
|
|
|
|
m_aRowHeaders.clear();
|
|
|
|
m_aData.clear();
|
|
|
|
|
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, -1, -1, -1, -1 ),
|
2011-01-10 15:47:51 +01:00
|
|
|
&XGridDataListener::rowsRemoved,
|
|
|
|
aGuard
|
|
|
|
);
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::updateCell( ::sal_Int32 i_rowIndex, ::sal_Int32 i_columnIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).first = i_value;
|
2011-01-10 15:47:51 +01:00
|
|
|
|
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, i_columnIndex, i_columnIndex, i_rowIndex, i_rowIndex ),
|
2011-01-10 15:47:51 +01:00
|
|
|
&XGridDataListener::dataChanged,
|
|
|
|
aGuard
|
|
|
|
);
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::updateRow( const Sequence< ::sal_Int32 >& i_columnIndexes, ::sal_Int32 i_rowIndex, const Sequence< Any >& i_values ) throw (IndexOutOfBoundsException, IllegalArgumentException, RuntimeException)
|
2010-04-23 17:41:32 +02:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
|
|
|
|
if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) )
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
|
|
|
|
|
|
|
if ( i_columnIndexes.getLength() != i_values.getLength() )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
|
|
|
|
|
|
|
|
sal_Int32 const columnCount = i_columnIndexes.getLength();
|
|
|
|
if ( columnCount == 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
for ( sal_Int32 col = 0; col < columnCount; ++col )
|
|
|
|
{
|
|
|
|
if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) )
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
|
|
|
}
|
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
RowData& rDataRow = m_aData[ i_rowIndex ];
|
2011-01-10 15:47:51 +01:00
|
|
|
for ( sal_Int32 col = 0; col < columnCount; ++col )
|
2010-04-23 17:41:32 +02:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
sal_Int32 const columnIndex = i_columnIndexes[ col ];
|
|
|
|
if ( size_t( columnIndex ) >= rDataRow.size() )
|
|
|
|
rDataRow.resize( columnIndex + 1 );
|
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
rDataRow[ columnIndex ].first = i_values[ col ];
|
2010-04-23 17:41:32 +02:00
|
|
|
}
|
2011-01-10 15:47:51 +01:00
|
|
|
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
sal_Int32 const firstAffectedColumn = *::std::min_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) );
|
|
|
|
sal_Int32 const lastAffectedColumn = *::std::max_element( stl_begin( i_columnIndexes ), stl_end( i_columnIndexes ) );
|
2011-01-10 15:47:51 +01:00
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, firstAffectedColumn, lastAffectedColumn, i_rowIndex, i_rowIndex ),
|
2011-01-10 15:47:51 +01:00
|
|
|
&XGridDataListener::dataChanged,
|
|
|
|
aGuard
|
|
|
|
);
|
2010-04-23 17:41:32 +02:00
|
|
|
}
|
2011-01-03 23:14:55 +01:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::setRowTitle( ::sal_Int32 i_rowIndex, const ::rtl::OUString& i_title ) throw (IndexOutOfBoundsException, RuntimeException)
|
2010-04-23 17:41:32 +02:00
|
|
|
{
|
2011-01-10 15:47:51 +01:00
|
|
|
::osl::ClearableMutexGuard aGuard( GetMutex() );
|
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aRowHeaders.size() ) )
|
2011-01-10 15:47:51 +01:00
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
|
|
|
|
|
|
|
m_aRowHeaders[ i_rowIndex ] = i_title;
|
|
|
|
|
|
|
|
broadcast(
|
gridsort: reworked the notification system for inserted/removed rows
In this course, more code which was in SVTXGridControl was moved to the places it belongs to, effectively
meaning that the TableControl has better chances than before to be used outside an SVTXGridControl (though
we're not there, yet).
Also, the selection-related methods in TableControl/_Impl got some refactoring love, so the implementation
details are hidden in the Impl class now, instead of being exposed to an exploited by the TableControl.
And while we were there ... The XGridSelection does not provide a |selectColumn| anymore (there was no
preparation whatsoever for column selection, anywhere, thus it was a complete dummy.)
Also, its de/selectRows methods have been removed: They have questionable use, and make implementation
rather difficult, compared with multiple calls to de/selectRow.
2011-01-13 14:08:36 +01:00
|
|
|
GridDataEvent( *this, -1, -1, i_rowIndex, i_rowIndex ),
|
2011-01-10 15:47:51 +01:00
|
|
|
&XGridDataListener::rowTitleChanged,
|
|
|
|
aGuard
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::setCellToolTip( ::sal_Int32 i_rowIndex, ::sal_Int32 i_columnIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
::osl::MutexGuard aGuard( GetMutex() );
|
|
|
|
impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).second = i_value;
|
|
|
|
}
|
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
BrdcstHelper.addListener( XGridDataListener::static_type(), i_listener );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
BrdcstHelper.removeListener( XGridDataListener::static_type(), i_listener );
|
2010-04-23 17:41:32 +02:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::dispose() throw (RuntimeException)
|
|
|
|
{
|
|
|
|
::com::sun::star::lang::EventObject aEvent;
|
|
|
|
aEvent.Source.set( static_cast< ::cppu::OWeakObject* >( this ) );
|
|
|
|
BrdcstHelper.aLC.disposeAndClear( aEvent );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
BrdcstHelper.addListener( XEventListener::static_type(), xListener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::removeEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
BrdcstHelper.removeListener( XEventListener::static_type(), xListener );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
static const OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) );
|
|
|
|
return aImplName;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool SAL_CALL DefaultGridDataModel::supportsService( const ::rtl::OUString& ServiceName ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return ServiceName.equalsAscii( szServiceName_DefaultGridDataModel );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-10 15:47:51 +01:00
|
|
|
Sequence< ::rtl::OUString > SAL_CALL DefaultGridDataModel::getSupportedServiceNames( ) throw (RuntimeException)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
|
|
|
static const OUString aServiceName( OUString::createFromAscii( szServiceName_DefaultGridDataModel ) );
|
|
|
|
static const Sequence< OUString > aSeq( &aServiceName, 1 );
|
|
|
|
return aSeq;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Reference< XCloneable > SAL_CALL DefaultGridDataModel::createClone( ) throw (RuntimeException)
|
|
|
|
{
|
|
|
|
return new DefaultGridDataModel( *this );
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//......................................................................................................................
|
|
|
|
} // namespace toolkit
|
|
|
|
//......................................................................................................................
|
2009-08-26 13:11:27 +00:00
|
|
|
|
|
|
|
Reference< XInterface > SAL_CALL DefaultGridDataModel_CreateInstance( const Reference< XMultiServiceFactory >& )
|
|
|
|
{
|
2010-02-12 17:05:02 +01:00
|
|
|
return Reference < XInterface >( ( ::cppu::OWeakObject* ) new ::toolkit::DefaultGridDataModel() );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|