2009-08-26 13:11:27 +00:00
|
|
|
/*************************************************************************
|
2010-02-12 15:01:35 +01:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2009-08-26 13:11:27 +00:00
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_svtools.hxx"
|
|
|
|
|
2011-01-14 11:44:35 +01:00
|
|
|
#include "svtools/table/tablecontrol.hxx"
|
|
|
|
|
2009-08-26 13:11:27 +00:00
|
|
|
#include "tablegeometry.hxx"
|
|
|
|
#include "tablecontrol_impl.hxx"
|
2011-01-14 11:44:35 +01:00
|
|
|
#include "tabledatawindow.hxx"
|
2011-01-11 13:26:40 +01:00
|
|
|
|
2009-10-30 12:37:25 +00:00
|
|
|
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
|
|
|
|
#include <com/sun/star/accessibility/AccessibleRole.hpp>
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
#include <tools/diagnose_ex.h>
|
|
|
|
|
2009-10-30 12:37:25 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using ::com::sun::star::accessibility::XAccessible;
|
|
|
|
using namespace ::com::sun::star::accessibility;
|
|
|
|
using namespace ::com::sun::star::lang;
|
|
|
|
using namespace utl;
|
2011-01-11 13:26:40 +01:00
|
|
|
|
|
|
|
//......................................................................................................................
|
2009-08-26 13:11:27 +00:00
|
|
|
namespace svt { namespace table
|
|
|
|
{
|
2011-01-11 13:26:40 +01:00
|
|
|
//......................................................................................................................
|
|
|
|
|
|
|
|
//==================================================================================================================
|
2009-08-26 13:11:27 +00:00
|
|
|
//= TableControl
|
2011-01-11 13:26:40 +01:00
|
|
|
//==================================================================================================================
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
TableControl::TableControl( Window* _pParent, WinBits _nStyle )
|
|
|
|
:Control( _pParent, _nStyle )
|
|
|
|
,m_pImpl( new TableControl_Impl( *this ) )
|
|
|
|
{
|
2011-01-13 15:07:42 +01:00
|
|
|
TableDataWindow& rDataWindow = m_pImpl->getDataWindow();
|
|
|
|
rDataWindow.SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) );
|
|
|
|
rDataWindow.SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) );
|
|
|
|
rDataWindow.SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) );
|
2010-05-05 10:46:06 +02:00
|
|
|
|
|
|
|
// by default, use the background as determined by the style settings
|
|
|
|
const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() );
|
|
|
|
SetBackground( Wallpaper( aWindowColor ) );
|
|
|
|
SetFillColor( aWindowColor );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
TableControl::~TableControl()
|
|
|
|
{
|
2010-03-22 11:17:10 +01:00
|
|
|
ImplCallEventListeners( VCLEVENT_OBJECT_DYING );
|
2010-12-17 13:38:24 +01:00
|
|
|
|
|
|
|
m_pImpl->setModel( PTableModel() );
|
2011-01-13 15:07:42 +01:00
|
|
|
m_pImpl->disposeAccessible();
|
2010-12-17 13:38:24 +01:00
|
|
|
m_pImpl.reset();
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
void TableControl::GetFocus()
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->getInputHandler()->GetFocus( *m_pImpl ) )
|
|
|
|
Control::GetFocus();
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
void TableControl::LoseFocus()
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->getInputHandler()->LoseFocus( *m_pImpl ) )
|
|
|
|
Control::LoseFocus();
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
void TableControl::KeyInput( const KeyEvent& rKEvt )
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) )
|
|
|
|
Control::KeyInput( rKEvt );
|
|
|
|
}
|
2010-05-05 10:46:06 +02:00
|
|
|
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2010-05-05 10:46:06 +02:00
|
|
|
void TableControl::StateChanged( StateChangedType i_nStateChange )
|
|
|
|
{
|
|
|
|
Control::StateChanged( i_nStateChange );
|
|
|
|
|
|
|
|
// forward certain settings to the data window
|
|
|
|
switch ( i_nStateChange )
|
|
|
|
{
|
|
|
|
case STATE_CHANGE_CONTROLBACKGROUND:
|
|
|
|
if ( IsControlBackground() )
|
2011-01-13 15:07:42 +01:00
|
|
|
getDataWindow().SetControlBackground( GetControlBackground() );
|
2010-05-05 10:46:06 +02:00
|
|
|
else
|
2011-01-13 15:07:42 +01:00
|
|
|
getDataWindow().SetControlBackground();
|
2010-05-05 10:46:06 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATE_CHANGE_CONTROLFOREGROUND:
|
|
|
|
if ( IsControlForeground() )
|
2011-01-13 15:07:42 +01:00
|
|
|
getDataWindow().SetControlForeground( GetControlForeground() );
|
2010-05-05 10:46:06 +02:00
|
|
|
else
|
2011-01-13 15:07:42 +01:00
|
|
|
getDataWindow().SetControlForeground();
|
2010-05-05 10:46:06 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case STATE_CHANGE_CONTROLFONT:
|
|
|
|
if ( IsControlFont() )
|
2011-01-13 15:07:42 +01:00
|
|
|
getDataWindow().SetControlFont( GetControlFont() );
|
2010-05-05 10:46:06 +02:00
|
|
|
else
|
2011-01-13 15:07:42 +01:00
|
|
|
getDataWindow().SetControlFont();
|
2010-05-05 10:46:06 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
void TableControl::Resize()
|
|
|
|
{
|
|
|
|
Control::Resize();
|
|
|
|
m_pImpl->onResize();
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
void TableControl::SetModel( PTableModel _pModel )
|
|
|
|
{
|
|
|
|
m_pImpl->setModel( _pModel );
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
PTableModel TableControl::GetModel() const
|
|
|
|
{
|
|
|
|
return m_pImpl->getModel();
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
RowPos TableControl::GetTopRow() const
|
|
|
|
{
|
|
|
|
return m_pImpl->getTopRow();
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
void TableControl::SetTopRow( RowPos _nRow )
|
|
|
|
{
|
2011-01-11 13:26:40 +01:00
|
|
|
OSL_ENSURE( false, "TableControl::SetTopRow: not implemented!" );
|
|
|
|
OSL_UNUSED( _nRow );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-10-30 12:37:25 +00:00
|
|
|
sal_Int32 TableControl::GetCurrentRow() const
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-11 14:00:09 +01:00
|
|
|
return m_pImpl->getCurrentRow();
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-10-30 12:37:25 +00:00
|
|
|
sal_Int32 TableControl::GetCurrentColumn() const
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-11 14:00:09 +01:00
|
|
|
return m_pImpl->getCurrentColumn();
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
bool TableControl::GoTo( ColPos _nColumn, RowPos _nRow )
|
|
|
|
{
|
|
|
|
return m_pImpl->goTo( _nColumn, _nRow );
|
|
|
|
}
|
2011-01-11 13:26:40 +01:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-10-30 12:37:25 +00:00
|
|
|
sal_Bool TableControl::GoToCell(sal_Int32 _nColPos, sal_Int32 _nRowPos)
|
|
|
|
{
|
|
|
|
return m_pImpl->goTo( _nColPos, _nRowPos );
|
|
|
|
}
|
2011-01-11 13:26:40 +01:00
|
|
|
|
2011-01-14 11:04:24 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Int32 TableControl::GetSelectedRowCount() const
|
|
|
|
{
|
|
|
|
return sal_Int32( m_pImpl->getSelectedRowCount() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Int32 TableControl::GetSelectedRowIndex( sal_Int32 const i_selectionIndex ) const
|
|
|
|
{
|
|
|
|
return sal_Int32( m_pImpl->getSelectedRowIndex( i_selectionIndex ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
bool TableControl::IsRowSelected( sal_Int32 const i_rowIndex ) const
|
|
|
|
{
|
|
|
|
return m_pImpl->isRowSelected( i_rowIndex );
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +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
|
|
|
void TableControl::SelectRow( RowPos const i_rowIndex, bool const i_select )
|
2010-03-18 08:21:26 +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
|
|
|
ENSURE_OR_RETURN_VOID( ( i_rowIndex >= 0 ) && ( i_rowIndex < m_pImpl->getModel()->getRowCount() ),
|
|
|
|
"TableControl::SelectRow: no control (anymore)!" );
|
|
|
|
|
|
|
|
if ( i_select )
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->markRowAsSelected( i_rowIndex ) )
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_pImpl->markRowAsDeselected( i_rowIndex );
|
|
|
|
}
|
|
|
|
|
2011-01-13 16:28:06 +01:00
|
|
|
m_pImpl->invalidateRowRange( i_rowIndex, i_rowIndex );
|
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
|
|
|
Select();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2011-01-14 11:04:24 +01:00
|
|
|
void TableControl::SelectAllRows( bool const i_select )
|
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
|
|
|
{
|
|
|
|
if ( i_select )
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->markAllRowsAsSelected() )
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( !m_pImpl->markAllRowsAsDeselected() )
|
|
|
|
// nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Invalidate();
|
|
|
|
// TODO: can't we do better than this, and invalidate only the rows which changed?
|
|
|
|
Select();
|
2010-03-18 08:21:26 +01:00
|
|
|
}
|
2011-01-11 13:26:40 +01:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2011-01-13 16:28:06 +01:00
|
|
|
void TableControl::InvalidateDataWindow( RowPos const i_firstRow, RowPos const i_lastRow )
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-13 16:28:06 +01:00
|
|
|
m_pImpl->invalidateRowRange( i_firstRow, i_lastRow );
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
2011-01-11 13:26:40 +01:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
|
|
ITableControl& TableControl::getTableControlInterface()
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
2011-01-11 10:58:26 +01:00
|
|
|
return *m_pImpl;
|
2009-08-26 13:11:27 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-08-26 13:11:27 +00:00
|
|
|
SelectionEngine* TableControl::getSelEngine()
|
|
|
|
{
|
|
|
|
return m_pImpl->getSelEngine();
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2011-01-14 11:44:35 +01:00
|
|
|
Window& TableControl::getDataWindow()
|
2009-08-26 13:11:27 +00:00
|
|
|
{
|
|
|
|
return m_pImpl->getDataWindow();
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-10-30 12:37:25 +00:00
|
|
|
Reference< XAccessible > TableControl::CreateAccessible()
|
|
|
|
{
|
|
|
|
Window* pParent = GetAccessibleParentWindow();
|
2011-01-13 15:07:42 +01:00
|
|
|
ENSURE_OR_RETURN( pParent, "TableControl::CreateAccessible - parent not found", NULL );
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-13 15:07:42 +01:00
|
|
|
return m_pImpl->getAccessible( *pParent );
|
2009-10-30 12:37:25 +00:00
|
|
|
}
|
2011-01-13 15:07:42 +01:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-10-30 12:37:25 +00:00
|
|
|
Reference<XAccessible> TableControl::CreateAccessibleControl( sal_Int32 _nIndex )
|
|
|
|
{
|
|
|
|
(void)_nIndex;
|
|
|
|
DBG_ASSERT( FALSE, "TableControl::CreateAccessibleControl: to be overwritten!" );
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-01-13 15:07:42 +01:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
2009-10-30 12:37:25 +00:00
|
|
|
::rtl::OUString TableControl::GetAccessibleObjectName( AccessibleTableControlObjType eObjType, sal_Int32 _nRow, sal_Int32 _nCol) const
|
|
|
|
{
|
|
|
|
::rtl::OUString aRetText;
|
2010-02-12 17:08:15 +01:00
|
|
|
//Window* pWin;
|
2009-10-30 12:37:25 +00:00
|
|
|
switch( eObjType )
|
|
|
|
{
|
|
|
|
case TCTYPE_GRIDCONTROL:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_TABLE:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_ROWHEADERBAR:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_COLUMNHEADERBAR:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_TABLECELL:
|
2010-06-09 14:39:18 +02:00
|
|
|
aRetText = GetAccessibleCellText(_nRow, _nCol);
|
2009-10-30 12:37:25 +00:00
|
|
|
break;
|
|
|
|
case TCTYPE_ROWHEADERCELL:
|
|
|
|
aRetText = GetRowName(_nRow);
|
|
|
|
break;
|
|
|
|
case TCTYPE_COLUMNHEADERCELL:
|
|
|
|
aRetText = GetColumnName(_nCol);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
OSL_ENSURE(0,"GridControl::GetAccessibleName: invalid enum!");
|
|
|
|
}
|
|
|
|
return aRetText;
|
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString TableControl::GetAccessibleObjectDescription( AccessibleTableControlObjType eObjType, sal_Int32 ) const
|
2009-10-30 12:37:25 +00:00
|
|
|
{
|
2011-01-11 13:26:40 +01:00
|
|
|
::rtl::OUString aRetText;
|
|
|
|
switch( eObjType )
|
|
|
|
{
|
|
|
|
case TCTYPE_GRIDCONTROL:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl description" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_TABLE:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_ROWHEADERBAR:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERBAR description" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_COLUMNHEADERBAR:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_TABLECELL:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_ROWHEADERCELL:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) );
|
|
|
|
break;
|
|
|
|
case TCTYPE_COLUMNHEADERCELL:
|
|
|
|
aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERCELL description" ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return aRetText;
|
2009-10-30 12:37:25 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString TableControl::GetRowDescription( sal_Int32 _nRow) const
|
|
|
|
{
|
|
|
|
(void)_nRow;
|
|
|
|
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "row description" ) );
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString TableControl::GetRowName( sal_Int32 _nIndex) const
|
|
|
|
{
|
|
|
|
return GetModel()->getRowHeader( _nIndex );
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString TableControl::GetColumnDescription( sal_uInt16 _nColumn) const
|
|
|
|
{
|
|
|
|
(void)_nColumn;
|
|
|
|
return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "col description" ) );
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString TableControl::GetColumnName( sal_Int32 _nIndex) const
|
|
|
|
{
|
|
|
|
return GetModel()->getColumnModel(_nIndex)->getName();
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::com::sun::star::uno::Any TableControl::GetCellContent( sal_Int32 _nRowPos, sal_Int32 _nColPos ) const
|
|
|
|
{
|
|
|
|
Any aCellContent;
|
|
|
|
GetModel()->getCellContent( _nColPos, _nRowPos, aCellContent );
|
|
|
|
return aCellContent;
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
::rtl::OUString TableControl::GetAccessibleCellText( sal_Int32 _nRowPos, sal_Int32 _nColPos) const
|
|
|
|
{
|
|
|
|
return m_pImpl->getCellContentAsString( _nRowPos, _nColPos );
|
|
|
|
}
|
2011-01-03 16:01:14 +01:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TableControl::FillAccessibleStateSet(
|
|
|
|
::utl::AccessibleStateSetHelper& rStateSet,
|
|
|
|
AccessibleTableControlObjType eObjType ) const
|
|
|
|
{
|
|
|
|
switch( eObjType )
|
|
|
|
{
|
|
|
|
case TCTYPE_GRIDCONTROL:
|
|
|
|
case TCTYPE_TABLE:
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
rStateSet.AddState( AccessibleStateType::FOCUSABLE );
|
|
|
|
rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE);
|
|
|
|
if ( HasFocus() )
|
|
|
|
rStateSet.AddState( AccessibleStateType::FOCUSED );
|
|
|
|
if ( IsActive() )
|
|
|
|
rStateSet.AddState( AccessibleStateType::ACTIVE );
|
|
|
|
if ( IsEnabled() )
|
|
|
|
rStateSet.AddState( AccessibleStateType::ENABLED );
|
|
|
|
if ( IsReallyVisible() )
|
|
|
|
rStateSet.AddState( AccessibleStateType::VISIBLE );
|
|
|
|
rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
|
2010-03-22 11:17:10 +01:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
break;
|
|
|
|
case TCTYPE_ROWHEADERBAR:
|
|
|
|
rStateSet.AddState( AccessibleStateType::VISIBLE );
|
|
|
|
rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
|
|
|
|
break;
|
|
|
|
case TCTYPE_COLUMNHEADERBAR:
|
|
|
|
rStateSet.AddState( AccessibleStateType::VISIBLE );
|
|
|
|
rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS );
|
|
|
|
break;
|
|
|
|
case TCTYPE_TABLECELL:
|
|
|
|
{
|
|
|
|
rStateSet.AddState( AccessibleStateType::TRANSIENT );
|
|
|
|
rStateSet.AddState( AccessibleStateType::SELECTABLE);
|
|
|
|
if( GetSelectedRowCount()>0)
|
|
|
|
rStateSet.AddState( AccessibleStateType::SELECTED);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TCTYPE_ROWHEADERCELL:
|
2009-10-30 12:37:25 +00:00
|
|
|
rStateSet.AddState( AccessibleStateType::VISIBLE );
|
|
|
|
rStateSet.AddState( AccessibleStateType::TRANSIENT );
|
2011-01-11 13:26:40 +01:00
|
|
|
break;
|
|
|
|
case TCTYPE_COLUMNHEADERCELL:
|
|
|
|
rStateSet.AddState( AccessibleStateType::VISIBLE );
|
|
|
|
break;
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const
|
|
|
|
{
|
|
|
|
return Control::GetWindowExtentsRelative( pRelativeWindow );
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TableControl::GrabFocus()
|
|
|
|
{
|
|
|
|
Control::GrabFocus();
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Reference< XAccessible > TableControl::GetAccessible( BOOL bCreate )
|
|
|
|
{
|
|
|
|
return Control::GetAccessible( bCreate );
|
|
|
|
}
|
2009-10-30 12:37:25 +00:00
|
|
|
|
2011-01-11 13:26:40 +01:00
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Window* TableControl::GetAccessibleParentWindow() const
|
|
|
|
{
|
|
|
|
return Control::GetAccessibleParentWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Window* TableControl::GetWindowInstance()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool TableControl::HasRowHeader()
|
|
|
|
{
|
|
|
|
return GetModel()->hasRowHeaders();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool TableControl::HasColHeader()
|
|
|
|
{
|
|
|
|
return GetModel()->hasColumnHeaders();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Int32 TableControl::GetAccessibleControlCount() const
|
|
|
|
{
|
|
|
|
sal_Int32 count = 0;
|
|
|
|
if(GetRowCount()>0)
|
|
|
|
count+=1;
|
|
|
|
if(GetModel()->hasRowHeaders())
|
|
|
|
count+=1;
|
|
|
|
if(GetModel()->hasColumnHeaders())
|
|
|
|
count+=1;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool TableControl::ConvertPointToControlIndex( sal_Int32& _rnIndex, const Point& _rPoint )
|
|
|
|
{
|
|
|
|
sal_Int32 nRow = m_pImpl->getRowAtPoint( _rPoint );
|
|
|
|
sal_Int32 nCol = m_pImpl->getColAtPoint( _rPoint );
|
|
|
|
_rnIndex = nRow * GetColumnCount() + nCol;
|
|
|
|
return nRow >= 0 ? sal_True : sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
long TableControl::GetRowCount() const
|
|
|
|
{
|
|
|
|
return GetModel()->getRowCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
long TableControl::GetColumnCount() const
|
|
|
|
{
|
|
|
|
return GetModel()->getColumnCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool TableControl::HasRowHeader() const
|
|
|
|
{
|
|
|
|
return GetModel()->hasRowHeaders();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Bool TableControl::ConvertPointToCellAddress( sal_Int32& _rnRow, sal_Int32& _rnColPos, const Point& _rPoint )
|
|
|
|
{
|
|
|
|
_rnRow = m_pImpl->getRowAtPoint( _rPoint );
|
|
|
|
_rnColPos = m_pImpl->getColAtPoint( _rPoint );
|
|
|
|
return _rnRow >= 0 ? sal_True : sal_False;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TableControl::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const
|
|
|
|
{
|
|
|
|
if ( GetCurrentRow() == _nRow && GetCurrentColumn() == _nColumnPos )
|
|
|
|
_rStateSet.AddState( AccessibleStateType::FOCUSED );
|
|
|
|
else // only transient when column is not focused
|
|
|
|
_rStateSet.AddState( AccessibleStateType::TRANSIENT );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Rectangle TableControl::GetFieldCharacterBounds(sal_Int32 _nRow,sal_Int32 _nColumnPos,sal_Int32 nIndex)
|
|
|
|
{
|
|
|
|
(void)_nRow;
|
|
|
|
(void)_nColumnPos;
|
|
|
|
return GetCharacterBounds(nIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
sal_Int32 TableControl::GetFieldIndexAtPoint(sal_Int32 _nRow,sal_Int32 _nColumnPos,const Point& _rPoint)
|
|
|
|
{
|
|
|
|
(void)_nRow;
|
|
|
|
(void)_nColumnPos;
|
|
|
|
return GetIndexForPoint(_rPoint);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Rectangle TableControl::calcHeaderRect(sal_Bool _bIsColumnBar,BOOL _bOnScreen)
|
|
|
|
{
|
|
|
|
(void)_bOnScreen;
|
|
|
|
return m_pImpl->calcHeaderRect(_bIsColumnBar);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
Rectangle TableControl::calcTableRect(BOOL _bOnScreen)
|
|
|
|
{
|
|
|
|
(void)_bOnScreen;
|
|
|
|
return m_pImpl->calcTableRect();
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG )
|
|
|
|
{
|
|
|
|
Select();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData )
|
|
|
|
{
|
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData )
|
|
|
|
{
|
|
|
|
CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData );
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TableControl::Select()
|
|
|
|
{
|
2011-01-13 15:07:42 +01:00
|
|
|
ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_pImpl->getSelectHandler(), this );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
void TableControl::SetSelectHdl( const Link& i_selectHandler )
|
|
|
|
{
|
|
|
|
m_pImpl->setSelectHandler( i_selectHandler );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
|
|
const Link& TableControl::GetSelectHdl() const
|
|
|
|
{
|
|
|
|
return m_pImpl->getSelectHandler();
|
2011-01-11 13:26:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//......................................................................................................................
|
2009-10-30 12:37:25 +00:00
|
|
|
}} // namespace svt::table
|
2011-01-11 13:26:40 +01:00
|
|
|
//......................................................................................................................
|