diff options
Diffstat (limited to 'svtools/source/table/tablecontrol.cxx')
-rw-r--r-- | svtools/source/table/tablecontrol.cxx | 169 |
1 files changed, 135 insertions, 34 deletions
diff --git a/svtools/source/table/tablecontrol.cxx b/svtools/source/table/tablecontrol.cxx index 01a9b667a8f7..d0e726fa5c53 100644 --- a/svtools/source/table/tablecontrol.cxx +++ b/svtools/source/table/tablecontrol.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <tools/diagnose_ex.h> @@ -49,6 +50,8 @@ namespace svt { namespace table { //...................................................................................................................... + namespace AccessibleEventId = ::com::sun::star::accessibility::AccessibleEventId; + //================================================================================================================== //= TableControl //================================================================================================================== @@ -58,14 +61,14 @@ namespace svt { namespace table ,m_pImpl( new TableControl_Impl( *this ) ) { TableDataWindow& rDataWindow = m_pImpl->getDataWindow(); - rDataWindow.SetMouseButtonDownHdl( LINK( this, TableControl, ImplMouseButtonDownHdl ) ); - rDataWindow.SetMouseButtonUpHdl( LINK( this, TableControl, ImplMouseButtonUpHdl ) ); rDataWindow.SetSelectHdl( LINK( this, TableControl, ImplSelectHdl ) ); // by default, use the background as determined by the style settings const Color aWindowColor( GetSettings().GetStyleSettings().GetFieldColor() ); SetBackground( Wallpaper( aWindowColor ) ); SetFillColor( aWindowColor ); + + SetCompoundControl( true ); } // ----------------------------------------------------------------------------------------------------------------- @@ -97,6 +100,27 @@ namespace svt { namespace table { if ( !m_pImpl->getInputHandler()->KeyInput( *m_pImpl, rKEvt ) ) Control::KeyInput( rKEvt ); + else + { + if ( m_pImpl->isAccessibleAlive() ) + { + m_pImpl->commitCellEvent( AccessibleEventId::STATE_CHANGED, + makeAny( AccessibleStateType::FOCUSED ), + Any() + ); + // Huh? What the heck? Why do we unconditionally notify a STATE_CHANGE/FOCUSED after each and every + // (handled) key stroke? + + m_pImpl->commitTableEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, + Any(), + Any() + ); + // ditto: Why do we notify this unconditionally? We should find the right place to notify the + // ACTIVE_DESCENDANT_CHANGED event. + // Also, we should check if STATE_CHANGED/FOCUSED is really necessary: finally, the children are + // transient, aren't they? + } + } } @@ -108,6 +132,10 @@ namespace svt { namespace table // forward certain settings to the data window switch ( i_nStateChange ) { + case STATE_CHANGE_CONTROL_FOCUS: + m_pImpl->invalidateSelectedRows(); + break; + case STATE_CHANGE_CONTROLBACKGROUND: if ( IsControlBackground() ) getDataWindow().SetControlBackground( GetControlBackground() ); @@ -209,7 +237,7 @@ namespace svt { namespace table void TableControl::SelectRow( RowPos const i_rowIndex, bool const i_select ) { ENSURE_OR_RETURN_VOID( ( i_rowIndex >= 0 ) && ( i_rowIndex < m_pImpl->getModel()->getRowCount() ), - "TableControl::SelectRow: no control (anymore)!" ); + "TableControl::SelectRow: invalid row index!" ); if ( i_select ) { @@ -291,10 +319,10 @@ namespace svt { namespace table switch( eObjType ) { case TCTYPE_GRIDCONTROL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl" ) ); + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grid control" ) ); break; case TCTYPE_TABLE: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Table" ) ); + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grid conrol" ) ); break; case TCTYPE_ROWHEADERBAR: aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "RowHeaderBar" ) ); @@ -303,7 +331,19 @@ namespace svt { namespace table aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ColumnHeaderBar" ) ); break; case TCTYPE_TABLECELL: - aRetText = GetAccessibleCellText(_nRow, _nCol); + //the name of the cell constists of column name and row name if defined + //if the name is equal to cell content, it'll be read twice + if(GetModel()->hasColumnHeaders()) + { + aRetText = GetColumnName(_nCol); + aRetText += rtl::OUString::createFromAscii(" , "); + } + if(GetModel()->hasRowHeaders()) + { + aRetText += GetRowName(_nRow); + aRetText += rtl::OUString::createFromAscii(" , "); + } + //aRetText = GetAccessibleCellText(_nRow, _nCol); break; case TCTYPE_ROWHEADERCELL: aRetText = GetRowName(_nRow); @@ -324,7 +364,7 @@ namespace svt { namespace table switch( eObjType ) { case TCTYPE_GRIDCONTROL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "GridControl description" ) ); + aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Grid control description" ) ); break; case TCTYPE_TABLE: aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLE description" ) ); @@ -336,7 +376,17 @@ namespace svt { namespace table aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "COLUMNHEADERBAR description" ) ); break; case TCTYPE_TABLECELL: - aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TABLECELL description" ) ); + // the description of the cell consists of column name and row name if defined + // if the name is equal to cell content, it'll be read twice + if ( GetModel()->hasColumnHeaders() ) + { + aRetText = GetColumnName( GetCurrentColumn() ); + aRetText += rtl::OUString::createFromAscii( " , " ); + } + if ( GetModel()->hasRowHeaders() ) + { + aRetText += GetRowName( GetCurrentRow() ); + } break; case TCTYPE_ROWHEADERCELL: aRetText = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ROWHEADERCELL description" ) ); @@ -401,38 +451,60 @@ namespace svt { namespace table case TCTYPE_TABLE: rStateSet.AddState( AccessibleStateType::FOCUSABLE ); - rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE); - if ( HasFocus() ) + + if ( m_pImpl->getSelEngine()->GetSelectionMode() == MULTIPLE_SELECTION ) + rStateSet.AddState( AccessibleStateType::MULTI_SELECTABLE); + + if ( HasChildPathFocus() ) rStateSet.AddState( AccessibleStateType::FOCUSED ); + if ( IsActive() ) rStateSet.AddState( AccessibleStateType::ACTIVE ); - if ( IsEnabled() ) + + if ( m_pImpl->getDataWindow().IsEnabled() ) + { rStateSet.AddState( AccessibleStateType::ENABLED ); + rStateSet.AddState( AccessibleStateType::SENSITIVE ); + } + if ( IsReallyVisible() ) rStateSet.AddState( AccessibleStateType::VISIBLE ); - rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); + if ( eObjType == TCTYPE_TABLE ) + rStateSet.AddState( AccessibleStateType::MANAGES_DESCENDANTS ); 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::FOCUSABLE ); + if ( HasChildPathFocus() ) + rStateSet.AddState( AccessibleStateType::FOCUSED ); + rStateSet.AddState( AccessibleStateType::ACTIVE ); rStateSet.AddState( AccessibleStateType::TRANSIENT ); rStateSet.AddState( AccessibleStateType::SELECTABLE); - if( GetSelectedRowCount()>0) - rStateSet.AddState( AccessibleStateType::SELECTED); + rStateSet.AddState( AccessibleStateType::VISIBLE ); + rStateSet.AddState( AccessibleStateType::SHOWING ); + if ( IsRowSelected( GetCurrentRow() ) ) + // Hmm? Wouldn't we expect the affected row to be a parameter to this function? + rStateSet.AddState( AccessibleStateType::SELECTED ); } break; + case TCTYPE_ROWHEADERCELL: rStateSet.AddState( AccessibleStateType::VISIBLE ); rStateSet.AddState( AccessibleStateType::TRANSIENT ); break; + case TCTYPE_COLUMNHEADERCELL: rStateSet.AddState( AccessibleStateType::VISIBLE ); break; @@ -440,6 +512,20 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ + void TableControl::commitCellEventIfAccessibleAlive( sal_Int16 const i_eventID, const Any& i_newValue, const Any& i_oldValue ) + { + if ( m_pImpl->isAccessibleAlive() ) + m_pImpl->commitCellEvent( i_eventID, i_newValue, i_oldValue ); + } + + //------------------------------------------------------------------------------------------------------------------ + void TableControl::commitTableEventIfAccessibleAlive( sal_Int16 const i_eventID, const Any& i_newValue, const Any& i_oldValue ) + { + if ( m_pImpl->isAccessibleAlive() ) + m_pImpl->commitTableEvent( i_eventID, i_newValue, i_oldValue ); + } + + //------------------------------------------------------------------------------------------------------------------ Rectangle TableControl::GetWindowExtentsRelative( Window *pRelativeWindow ) const { return Control::GetWindowExtentsRelative( pRelativeWindow ); @@ -484,13 +570,12 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ sal_Int32 TableControl::GetAccessibleControlCount() const { - sal_Int32 count = 0; - if(GetRowCount()>0) - count+=1; - if(GetModel()->hasRowHeaders()) - count+=1; - if(GetModel()->hasColumnHeaders()) - count+=1; + // TC_TABLE is always defined, no matter whether empty or not + sal_Int32 count = 1; + if ( GetModel()->hasRowHeaders() ) + ++count; + if ( GetModel()->hasColumnHeaders() ) + ++count; return count; } @@ -532,10 +617,20 @@ namespace svt { namespace table //------------------------------------------------------------------------------------------------------------------ void TableControl::FillAccessibleStateSetForCell( ::utl::AccessibleStateSetHelper& _rStateSet, sal_Int32 _nRow, sal_uInt16 _nColumnPos ) const { - if ( GetCurrentRow() == _nRow && GetCurrentColumn() == _nColumnPos ) + if ( IsRowSelected( _nRow ) ) + _rStateSet.AddState( AccessibleStateType::SELECTED ); + if ( HasChildPathFocus() ) _rStateSet.AddState( AccessibleStateType::FOCUSED ); else // only transient when column is not focused _rStateSet.AddState( AccessibleStateType::TRANSIENT ); + + _rStateSet.AddState( AccessibleStateType::VISIBLE ); + _rStateSet.AddState( AccessibleStateType::SHOWING ); + _rStateSet.AddState( AccessibleStateType::ENABLED ); + _rStateSet.AddState( AccessibleStateType::SENSITIVE ); + _rStateSet.AddState( AccessibleStateType::ACTIVE ); + + (void)_nColumnPos; } //------------------------------------------------------------------------------------------------------------------ @@ -562,30 +657,27 @@ namespace svt { namespace table } //------------------------------------------------------------------------------------------------------------------ - Rectangle TableControl::calcTableRect(sal_Bool _bOnScreen) + Rectangle TableControl::calcHeaderCellRect( sal_Bool _bIsColumnBar, sal_Int32 nPos ) { - (void)_bOnScreen; - return m_pImpl->calcTableRect(); + return m_pImpl->calcHeaderCellRect( _bIsColumnBar, nPos ); } //------------------------------------------------------------------------------------------------------------------ - IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) + Rectangle TableControl::calcTableRect(sal_Bool _bOnScreen) { - Select(); - return 1; + (void)_bOnScreen; + return m_pImpl->calcTableRect(); } //------------------------------------------------------------------------------------------------------------------ - IMPL_LINK( TableControl, ImplMouseButtonDownHdl, MouseEvent*, pData ) + Rectangle TableControl::calcCellRect( sal_Int32 _nRowPos, sal_Int32 _nColPos ) { - CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, pData ); - return 1; + return m_pImpl->calcCellRect( _nRowPos, _nColPos ); } - //------------------------------------------------------------------------------------------------------------------ - IMPL_LINK( TableControl, ImplMouseButtonUpHdl, MouseEvent*, pData ) + IMPL_LINK( TableControl, ImplSelectHdl, void*, EMPTYARG ) { - CallEventListeners( VCLEVENT_WINDOW_MOUSEBUTTONUP, pData ); + Select(); return 1; } @@ -593,6 +685,15 @@ namespace svt { namespace table void TableControl::Select() { ImplCallEventListenersAndHandler( VCLEVENT_TABLEROW_SELECT, m_pImpl->getSelectHandler(), this ); + + if ( m_pImpl->isAccessibleAlive() ) + { + m_pImpl->commitAccessibleEvent( AccessibleEventId::SELECTION_CHANGED, Any(), Any() ); + + m_pImpl->commitTableEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), Any() ); + // TODO: why do we notify this when the *selection* changed? Shouldn't we find a better place for this, + // actually, when the active descendant, i.e. the current cell, *really* changed? + } } //------------------------------------------------------------------------------------------------------------------ |