summaryrefslogtreecommitdiff
path: root/svtools/source/control
diff options
context:
space:
mode:
authorChristian Lippka <christian.lippka@sun.com>2010-04-28 16:04:47 +0200
committerChristian Lippka <christian.lippka@sun.com>2010-04-28 16:04:47 +0200
commitd22c384fac4fbf9977010da0b1348c1ab9d565e8 (patch)
treeab2eaad68d689bfeb7b691ce86aeb7d60e4efa38 /svtools/source/control
parentd282c98c9218f4abbd815d5309e3449045a366e3 (diff)
#i107213# possible solution for the missing a11y focus
Diffstat (limited to 'svtools/source/control')
-rw-r--r--svtools/source/control/toolbarmenu.cxx8
-rwxr-xr-xsvtools/source/control/toolbarmenuacc.cxx87
-rwxr-xr-xsvtools/source/control/toolbarmenuimp.hxx16
3 files changed, 74 insertions, 37 deletions
diff --git a/svtools/source/control/toolbarmenu.cxx b/svtools/source/control/toolbarmenu.cxx
index 3a3c8bb885ab..6f7be376266e 100644
--- a/svtools/source/control/toolbarmenu.cxx
+++ b/svtools/source/control/toolbarmenu.cxx
@@ -704,10 +704,6 @@ void ToolbarMenu::GetFocus()
implChangeHighlightEntry( 0 );
DockingWindow::GetFocus();
-
- // Tell the accessible object that we got the focus.
- if( mpImpl->mxAccessible.is() )
- mpImpl->mxAccessible->GetFocus();
}
// --------------------------------------------------------------------
@@ -718,10 +714,6 @@ void ToolbarMenu::LoseFocus()
implChangeHighlightEntry( -1 );
DockingWindow::LoseFocus();
-
- // Tell the accessible object that we lost the focus.
- if( mpImpl->mxAccessible.is() )
- mpImpl->mxAccessible->LoseFocus();
}
// --------------------------------------------------------------------
diff --git a/svtools/source/control/toolbarmenuacc.cxx b/svtools/source/control/toolbarmenuacc.cxx
index 702c1f72b83d..f227a4cb2558 100755
--- a/svtools/source/control/toolbarmenuacc.cxx
+++ b/svtools/source/control/toolbarmenuacc.cxx
@@ -58,12 +58,81 @@ ToolbarMenuAcc::ToolbarMenuAcc( ToolbarMenu_Impl& rParent )
, mpParent( &rParent )
, mbIsFocused(false)
{
+ mpParent->mrMenu.AddEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
}
// -----------------------------------------------------------------------------
ToolbarMenuAcc::~ToolbarMenuAcc()
{
+ if( mpParent )
+ mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
+}
+
+// -----------------------------------------------------------------------
+
+IMPL_LINK( ToolbarMenuAcc, WindowEventListener, VclSimpleEvent*, pEvent )
+{
+ DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "Unknown WindowEvent!" );
+
+ /* Ignore VCLEVENT_WINDOW_ENDPOPUPMODE, because the UNO accessibility wrapper
+ * might have been destroyed by the previous VCLEventListener (if no AT tool
+ * is running), e.g. sub-toolbars in impress.
+ */
+ if ( mpParent && pEvent && pEvent->ISA( VclWindowEvent ) && (pEvent->GetId() != VCLEVENT_WINDOW_ENDPOPUPMODE) )
+ {
+ DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "Window???" );
+ if( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) )
+ {
+ ProcessWindowEvent( *(VclWindowEvent*)pEvent );
+ }
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------
+
+void ToolbarMenuAcc::ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent )
+{
+ Any aOldValue, aNewValue;
+
+ Window* pAccWindow = rVclWindowEvent.GetWindow();
+ DBG_ASSERT( pAccWindow, "VCLXAccessibleComponent::ProcessWindowEvent - Window?" );
+
+ switch ( rVclWindowEvent.GetId() )
+ {
+ case VCLEVENT_OBJECT_DYING:
+ {
+ mpParent->mrMenu.RemoveEventListener( LINK( this, ToolbarMenuAcc, WindowEventListener ) );
+ mpParent = 0;
+ }
+ break;
+
+ case VCLEVENT_WINDOW_GETFOCUS:
+ {
+ if( !mbIsFocused )
+ {
+ aNewValue <<= accessibility::AccessibleStateType::FOCUSED;
+ FireAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ mbIsFocused = true;
+ }
+ }
+ break;
+ case VCLEVENT_WINDOW_LOSEFOCUS:
+ {
+ if( mbIsFocused )
+ {
+ aOldValue <<= accessibility::AccessibleStateType::FOCUSED;
+ FireAccessibleEvent( accessibility::AccessibleEventId::STATE_CHANGED, aOldValue, aNewValue );
+ mbIsFocused = false;
+ }
+ }
+ break;
+ default:
+ {
+ }
+ break;
+ }
}
// -----------------------------------------------------------------------
@@ -98,22 +167,6 @@ void ToolbarMenuAcc::FireAccessibleEvent( short nEventId, const Any& rOldValue,
// -----------------------------------------------------------------------------
-void ToolbarMenuAcc::GetFocus (void)
-{
- mbIsFocused = true;
- FireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any(), Any( AccessibleStateType::FOCUSED ) );
-}
-
-// -----------------------------------------------------------------------------
-
-void ToolbarMenuAcc::LoseFocus (void)
-{
- mbIsFocused = false;
- FireAccessibleEvent( AccessibleEventId::STATE_CHANGED, Any( AccessibleStateType::FOCUSED ), Any() );
-}
-
-// -----------------------------------------------------------------------------
-
Reference< XAccessibleContext > SAL_CALL ToolbarMenuAcc::getAccessibleContext() throw (RuntimeException)
{
ThrowIfDisposed();
@@ -560,7 +613,7 @@ void SAL_CALL ToolbarMenuAcc::disposing (void)
void ToolbarMenuAcc::ThrowIfDisposed (void) throw (DisposedException)
{
- if(rBHelper.bDisposed || rBHelper.bInDispose)
+ if(rBHelper.bDisposed || rBHelper.bInDispose || !mpParent)
{
throw DisposedException ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("object has been already disposed")), static_cast<XWeak*>(this));
}
diff --git a/svtools/source/control/toolbarmenuimp.hxx b/svtools/source/control/toolbarmenuimp.hxx
index 1d9037b61dc5..051fe23883a4 100755
--- a/svtools/source/control/toolbarmenuimp.hxx
+++ b/svtools/source/control/toolbarmenuimp.hxx
@@ -135,18 +135,6 @@ public:
bool HasAccessibleListeners() const { return( mxEventListeners.size() > 0 ); }
public:
-
- /** Called by the corresponding ToolbarMenu when it gets the focus.
- Stores the new focus state and broadcasts a state change event.
- */
- void GetFocus (void);
-
- /** Called by the corresponding ToolbarMenu when it loses the focus.
- Stores the new focus state and broadcasts a state change event.
- */
- void LoseFocus (void);
-
-
// XAccessible
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext( ) throw (::com::sun::star::uno::RuntimeException);
@@ -189,12 +177,16 @@ public:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getSelectedAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL deselectAccessibleChild( sal_Int32 nSelectedChildIndex ) throw (::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
+ DECL_LINK( WindowEventListener, VclSimpleEvent* );
+
private:
EventListenerVector mxEventListeners;
ToolbarMenu_Impl* mpParent;
/// The current FOCUSED state.
bool mbIsFocused;
+ void ProcessWindowEvent( const VclWindowEvent& rVclWindowEvent );
+
/** Tell all listeners that the object is dying. This callback is
usually called from the WeakComponentImplHelper class.
*/