2010-10-14 08:27:31 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
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.
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
|
2010-02-15 14:45:34 +01:00
|
|
|
#include "defaultgriddatamodel.hxx"
|
2011-01-10 15:47:51 +01:00
|
|
|
|
|
|
|
#include <comphelper/stlunosequence.hxx>
|
2011-01-16 20:59:30 +01:00
|
|
|
#include <comphelper/componentguard.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>
|
2012-09-03 12:20:27 -05:00
|
|
|
#include <functional>
|
|
|
|
#include <boost/bind.hpp>
|
2009-08-26 13:11:27 +00:00
|
|
|
|
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 === **/
|
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
using ::comphelper::stl_begin;
|
|
|
|
using ::comphelper::stl_end;
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//==================================================================================================================
|
|
|
|
//= DefaultGridDataModel
|
|
|
|
//==================================================================================================================
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DefaultGridDataModel::DefaultGridDataModel()
|
2011-01-16 20:59:30 +01:00
|
|
|
:DefaultGridDataModel_Base( m_aMutex )
|
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-18 11:15:23 +01:00
|
|
|
:cppu::BaseMutex()
|
|
|
|
,DefaultGridDataModel_Base( m_aMutex )
|
2011-01-03 23:14:55 +01:00
|
|
|
,m_aData( i_copySource.m_aData )
|
|
|
|
,m_aRowHeaders( i_copySource.m_aRowHeaders )
|
2011-01-16 20:59:30 +01:00
|
|
|
,m_nColumnCount( i_copySource.m_nColumnCount )
|
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()
|
|
|
|
{
|
|
|
|
}
|
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,
|
2011-01-16 20:59:30 +01:00
|
|
|
void ( SAL_CALL XGridDataListener::*i_listenerMethod )( GridDataEvent const & ), ::comphelper::ComponentGuard & i_instanceLock )
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::cppu::OInterfaceContainerHelper* pListeners = rBHelper.getContainer( XGridDataListener::static_type() );
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( !pListeners )
|
|
|
|
return;
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
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)
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
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-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2011-01-10 15:47:51 +01:00
|
|
|
return m_nColumnCount;
|
2011-01-06 16:28:45 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00: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 ) );
|
2009-08-26 13:11:27 +00: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 ];
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
static CellData s_aEmpty;
|
|
|
|
return s_aEmpty;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-14 15:13:23 +01:00
|
|
|
DefaultGridDataModel::RowData& DefaultGridDataModel::impl_getRowDataAccess_throw( sal_Int32 const i_rowIndex, size_t const i_requiredColumnCount )
|
2011-01-14 13:19:09 +01:00
|
|
|
{
|
2011-01-14 15:13:23 +01:00
|
|
|
OSL_ENSURE( i_requiredColumnCount <= size_t( m_nColumnCount ), "DefaultGridDataModel::impl_getRowDataAccess_throw: invalid column count!" );
|
|
|
|
if ( ( i_rowIndex < 0 ) || ( size_t( i_rowIndex ) >= m_aData.size() ) )
|
2011-01-14 13:19:09 +01:00
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
|
|
|
|
2011-01-14 15:13:23 +01:00
|
|
|
RowData& rRowData( m_aData[ i_rowIndex ] );
|
|
|
|
if ( rRowData.size() < i_requiredColumnCount )
|
|
|
|
rRowData.resize( i_requiredColumnCount );
|
|
|
|
return rRowData;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 15:13:23 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
DefaultGridDataModel::CellData& DefaultGridDataModel::impl_getCellDataAccess_throw( sal_Int32 const i_columnIndex, sal_Int32 const i_rowIndex )
|
|
|
|
{
|
|
|
|
if ( ( i_columnIndex < 0 ) || ( i_columnIndex >= m_nColumnCount ) )
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 15:13:23 +01:00
|
|
|
RowData& rRowData( impl_getRowDataAccess_throw( i_rowIndex, size_t( i_columnIndex + 1 ) ) );
|
|
|
|
return rRowData[ i_columnIndex ];
|
2011-01-14 13:19:09 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL DefaultGridDataModel::getCellData( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException)
|
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2011-01-14 13:19:09 +01:00
|
|
|
return impl_getCellData_throw( i_column, i_row ).first;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Any SAL_CALL DefaultGridDataModel::getCellToolTip( ::sal_Int32 i_column, ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException)
|
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2011-01-14 13:19:09 +01:00
|
|
|
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-16 22:18:58 +01:00
|
|
|
Any SAL_CALL DefaultGridDataModel::getRowHeading( ::sal_Int32 i_row ) throw (RuntimeException, IndexOutOfBoundsException)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
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-03-22 13:00:39 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Sequence< Any > SAL_CALL DefaultGridDataModel::getRowData( ::sal_Int32 i_rowIndex ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
|
|
|
|
|
|
|
Sequence< Any > resultData( m_nColumnCount );
|
|
|
|
RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
|
|
|
|
|
2012-09-03 12:20:27 -05:00
|
|
|
::std::transform( rRowData.begin(), rRowData.end(), resultData.getArray(),
|
|
|
|
boost::bind(&CellData::first,_1));
|
2011-03-22 13:00:39 +01:00
|
|
|
return resultData;
|
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-16 22:18:58 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::addRow( const Any& i_heading, const Sequence< Any >& i_data ) throw (RuntimeException)
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
sal_Int32 const columnCount = i_data.getLength();
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
// store header name
|
2011-01-16 22:18:58 +01:00
|
|
|
m_aRowHeaders.push_back( i_heading );
|
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 )
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-14 13:19:09 +01:00
|
|
|
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 );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-16 22:18:58 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::addRows( const Sequence< Any >& i_headings, const Sequence< Sequence< Any > >& i_data ) throw (IllegalArgumentException, RuntimeException)
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-16 22:18:58 +01:00
|
|
|
if ( i_headings.getLength() != i_data.getLength() )
|
2011-01-10 15:47:51 +01:00
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *this, -1 );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 22:18:58 +01:00
|
|
|
sal_Int32 const rowCount = i_headings.getLength();
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( rowCount == 0 )
|
|
|
|
return;
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
// 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();
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( maxColCount < m_nColumnCount )
|
|
|
|
maxColCount = m_nColumnCount;
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
for ( sal_Int32 row=0; row<rowCount; ++row )
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
2011-01-16 22:18:58 +01:00
|
|
|
m_aRowHeaders.push_back( i_headings[row] );
|
2011-01-14 13:19:09 +01:00
|
|
|
impl_addRow( i_data[row], maxColCount );
|
2011-01-03 23:14:55 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( maxColCount > m_nColumnCount )
|
|
|
|
m_nColumnCount = maxColCount;
|
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 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)
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
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
|
|
|
|
);
|
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-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2011-01-10 15:47:51 +01:00
|
|
|
|
|
|
|
m_aRowHeaders.clear();
|
|
|
|
m_aData.clear();
|
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, -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-14 15:13:23 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::updateCellData( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException)
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2011-01-10 15:47:51 +01:00
|
|
|
|
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
|
|
|
|
);
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-14 15:13:23 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::updateRowData( 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-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
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() ) )
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
if ( i_columnIndexes.getLength() != i_values.getLength() )
|
|
|
|
throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
sal_Int32 const columnCount = i_columnIndexes.getLength();
|
|
|
|
if ( columnCount == 0 )
|
|
|
|
return;
|
2009-08-26 13:11:27 +00:00
|
|
|
|
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
|
|
|
if ( ( i_columnIndexes[col] < 0 ) || ( i_columnIndexes[col] > m_nColumnCount ) )
|
|
|
|
throw IndexOutOfBoundsException( ::rtl::OUString(), *this );
|
2010-04-23 17:41:32 +02:00
|
|
|
}
|
2011-01-10 15:47:51 +01:00
|
|
|
|
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
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-03 23:14:55 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-27 08:17:57 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::updateRowHeading( ::sal_Int32 i_rowIndex, const Any& i_heading ) throw (IndexOutOfBoundsException, RuntimeException)
|
2010-04-23 17:41:32 +02:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
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 );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 22:18:58 +01:00
|
|
|
m_aRowHeaders[ i_rowIndex ] = i_heading;
|
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-16 22:18:58 +01:00
|
|
|
&XGridDataListener::rowHeadingChanged,
|
2011-01-10 15:47:51 +01:00
|
|
|
aGuard
|
|
|
|
);
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 13:19:09 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-14 15:13:23 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::updateCellToolTip( ::sal_Int32 i_columnIndex, ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException)
|
2011-01-14 13:19:09 +01:00
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2011-01-14 13:19:09 +01:00
|
|
|
impl_getCellDataAccess_throw( i_columnIndex, i_rowIndex ).second = i_value;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 15:13:23 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::updateRowToolTip( ::sal_Int32 i_rowIndex, const Any& i_value ) throw (IndexOutOfBoundsException, RuntimeException)
|
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
::comphelper::ComponentGuard aGuard( *this, rBHelper );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-14 15:13:23 +01:00
|
|
|
RowData& rRowData = impl_getRowDataAccess_throw( i_rowIndex, m_nColumnCount );
|
|
|
|
for ( RowData::iterator cell = rRowData.begin(); cell != rRowData.end(); ++cell )
|
|
|
|
cell->second = i_value;
|
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::addGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException)
|
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
rBHelper.addListener( XGridDataListener::static_type(), i_listener );
|
2011-01-10 15:47:51 +01:00
|
|
|
}
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-10 15:47:51 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void SAL_CALL DefaultGridDataModel::removeGridDataListener( const Reference< grid::XGridDataListener >& i_listener ) throw (RuntimeException)
|
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
rBHelper.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
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
2011-01-16 20:59:30 +01:00
|
|
|
void SAL_CALL DefaultGridDataModel::disposing()
|
2011-01-03 23:14:55 +01:00
|
|
|
{
|
|
|
|
::com::sun::star::lang::EventObject aEvent;
|
2011-01-16 20:59:30 +01:00
|
|
|
aEvent.Source.set( *this );
|
|
|
|
rBHelper.aLC.disposeAndClear( aEvent );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 20:59:30 +01:00
|
|
|
::osl::MutexGuard aGuard( m_aMutex );
|
|
|
|
GridData aEmptyData;
|
|
|
|
m_aData.swap( aEmptyData );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 22:18:58 +01:00
|
|
|
::std::vector< Any > aEmptyRowHeaders;
|
2011-01-16 20:59:30 +01:00
|
|
|
m_aRowHeaders.swap( aEmptyRowHeaders );
|
2009-08-26 13:11:27 +00:00
|
|
|
|
2011-01-16 20:59:30 +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
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString SAL_CALL DefaultGridDataModel::getImplementationName( ) throw (RuntimeException)
|
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
static const ::rtl::OUString aImplName( RTL_CONSTASCII_USTRINGPARAM( "toolkit.DefaultGridDataModel" ) );
|
2011-01-03 23:14:55 +01:00
|
|
|
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
|
|
|
{
|
2011-01-16 20:59:30 +01:00
|
|
|
static const ::rtl::OUString aServiceName( ::rtl::OUString::createFromAscii( szServiceName_DefaultGridDataModel ) );
|
|
|
|
static const Sequence< ::rtl::OUString > aSeq( &aServiceName, 1 );
|
2011-01-03 23:14:55 +01:00
|
|
|
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
|
|
|
}
|
2010-10-14 08:27:31 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|