Kaydet (Commit) 01a9f7b2 authored tarafından Jacobo Aragunde Pérez's avatar Jacobo Aragunde Pérez Kaydeden (comit) Caolán McNamara

fdo#72639: send proper ACTIVE_DESCENDANT_CHANGED events

At ThumbnailView::SelectItem the piece of code in charge of the
accessible events related to selection change was mistakenly using
the accessibility helper class ThumbnailViewAcc instead of
ThumbnailViewItemAcc which is the proper one for managing the events
related to ThumbnailViewItem objects.

The methods FireAccessibleEvent and static getImplementation had to
be added to ThumbnailViewItemAcc to provide the full functionality
required.

Change-Id: Ia5ffb24c920f3c48854021700819be683c979411
Reviewed-on: https://gerrit.libreoffice.org/7551Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 2cb1a05e
...@@ -1139,7 +1139,7 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId ) ...@@ -1139,7 +1139,7 @@ void ThumbnailView::SelectItem( sal_uInt16 nItemId )
if( ImplHasAccessibleListeners() ) if( ImplHasAccessibleListeners() )
{ {
// focus event (select) // focus event (select)
ThumbnailViewAcc* pItemAcc = ThumbnailViewAcc::getImplementation( pItem->GetAccessible( mbIsTransientChildrenDisabled ) ); ThumbnailViewItemAcc* pItemAcc = ThumbnailViewItemAcc::getImplementation( pItem->GetAccessible( mbIsTransientChildrenDisabled ) );
if( pItemAcc ) if( pItemAcc )
{ {
......
...@@ -97,7 +97,7 @@ void ThumbnailViewAcc::GetFocus (void) ...@@ -97,7 +97,7 @@ void ThumbnailViewAcc::GetFocus (void)
{ {
mbIsFocused = true; mbIsFocused = true;
// Boradcast the state change. // Broadcast the state change.
::com::sun::star::uno::Any aOldState, aNewState; ::com::sun::star::uno::Any aOldState, aNewState;
aNewState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED; aNewState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
FireAccessibleEvent( FireAccessibleEvent(
...@@ -109,7 +109,7 @@ void ThumbnailViewAcc::LoseFocus (void) ...@@ -109,7 +109,7 @@ void ThumbnailViewAcc::LoseFocus (void)
{ {
mbIsFocused = false; mbIsFocused = false;
// Boradcast the state change. // Broadcast the state change.
::com::sun::star::uno::Any aOldState, aNewState; ::com::sun::star::uno::Any aOldState, aNewState;
aOldState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED; aOldState <<= ::com::sun::star::accessibility::AccessibleStateType::FOCUSED;
FireAccessibleEvent( FireAccessibleEvent(
...@@ -612,6 +612,32 @@ ThumbnailViewItemAcc::~ThumbnailViewItemAcc() ...@@ -612,6 +612,32 @@ ThumbnailViewItemAcc::~ThumbnailViewItemAcc()
{ {
} }
void ThumbnailViewItemAcc::FireAccessibleEvent( short nEventId, const uno::Any& rOldValue, const uno::Any& rNewValue )
{
if( nEventId )
{
::std::vector< uno::Reference< accessibility::XAccessibleEventListener > > aTmpListeners( mxEventListeners );
accessibility::AccessibleEventObject aEvtObject;
aEvtObject.EventId = nEventId;
aEvtObject.Source = static_cast<uno::XWeak*>(this);
aEvtObject.NewValue = rNewValue;
aEvtObject.OldValue = rOldValue;
for (::std::vector< uno::Reference< accessibility::XAccessibleEventListener > >::const_iterator aIter( aTmpListeners.begin() ), aEnd( aTmpListeners.end() );
aIter != aEnd ; ++aIter)
{
try
{
(*aIter)->notifyEvent( aEvtObject );
}
catch(const uno::Exception&)
{
}
}
}
}
void ThumbnailViewItemAcc::ParentDestroyed() void ThumbnailViewItemAcc::ParentDestroyed()
{ {
const ::osl::MutexGuard aGuard( maMutex ); const ::osl::MutexGuard aGuard( maMutex );
...@@ -628,6 +654,23 @@ const uno::Sequence< sal_Int8 >& ThumbnailViewItemAcc::getUnoTunnelId() ...@@ -628,6 +654,23 @@ const uno::Sequence< sal_Int8 >& ThumbnailViewItemAcc::getUnoTunnelId()
return theValueItemAccUnoTunnelId::get().getSeq(); return theValueItemAccUnoTunnelId::get().getSeq();
} }
ThumbnailViewItemAcc* ThumbnailViewItemAcc::getImplementation( const uno::Reference< uno::XInterface >& rxData )
throw()
{
try
{
uno::Reference< lang::XUnoTunnel > xUnoTunnel( rxData, uno::UNO_QUERY );
return( xUnoTunnel.is() ?
reinterpret_cast<ThumbnailViewItemAcc*>(sal::static_int_cast<sal_IntPtr>(
xUnoTunnel->getSomething( ThumbnailViewItemAcc::getUnoTunnelId() ))) :
NULL );
}
catch(const ::com::sun::star::uno::Exception&)
{
return NULL;
}
}
uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewItemAcc::getAccessibleContext() uno::Reference< accessibility::XAccessibleContext > SAL_CALL ThumbnailViewItemAcc::getAccessibleContext()
throw (uno::RuntimeException) throw (uno::RuntimeException)
{ {
......
...@@ -187,10 +187,16 @@ public: ...@@ -187,10 +187,16 @@ public:
ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled ); ThumbnailViewItemAcc( ThumbnailViewItem* pParent, bool bIsTransientChildrenDisabled );
~ThumbnailViewItemAcc(); ~ThumbnailViewItemAcc();
void FireAccessibleEvent( short nEventId,
const ::com::sun::star::uno::Any& rOldValue,
const ::com::sun::star::uno::Any& rNewValue );
void ParentDestroyed(); void ParentDestroyed();
sal_Bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); } sal_Bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
static ThumbnailViewItemAcc* getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) throw();
public: public:
// XAccessible // XAccessible
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment