diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-01-26 16:58:21 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2006-01-26 16:58:21 +0000 |
commit | d25192e172576c96736e8582b68bb7a4b3de4245 (patch) | |
tree | aa8ad695f72041a645c0d7bee7dfe0192b8fb855 /accessibility | |
parent | cf491d5d2518512c2cceeccfab0ae3812fd57d99 (diff) |
INTEGRATION: CWS vcl47 (1.5.16); FILE MERGED
2006/01/12 15:17:33 obr 1.5.16.1: #i48361# Buttons can have children now
Diffstat (limited to 'accessibility')
-rw-r--r-- | accessibility/bridge/org/openoffice/java/accessibility/Button.java | 109 |
1 files changed, 107 insertions, 2 deletions
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Button.java b/accessibility/bridge/org/openoffice/java/accessibility/Button.java index f1ff586a1..273d22dc3 100644 --- a/accessibility/bridge/org/openoffice/java/accessibility/Button.java +++ b/accessibility/bridge/org/openoffice/java/accessibility/Button.java @@ -4,9 +4,9 @@ * * $RCSfile: Button.java,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: rt $ $Date: 2005-09-07 15:35:33 $ + * last change: $Author: hr $ $Date: 2006-01-26 17:58:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -44,17 +44,122 @@ class Button extends AbstractButton implements javax.accessibility.Accessible { super(xAccessible, xAccessibleContext); } + protected XAccessibleEventListener createEventListener() { + return new AccessibleButtonListener(); + } + + protected class AccessibleButtonListener + extends AccessibleUNOComponentListener { + protected AccessibleButtonListener() { + super(); + } + + protected javax.accessibility.AccessibleContext getContext( Object any ) { + try { + XAccessible xAccessible = (XAccessible) + AnyConverter.toObject( AccessibleObjectFactory.XAccessibleType, any ); + + javax.accessibility.Accessible accessible = + (javax.accessibility.Accessible) Button.this.getComponent( xAccessible ); + + return accessible.getAccessibleContext(); + } catch( com.sun.star.uno.Exception e ) { + return null; + } + } + + /** Called by OpenOffice process to notify property changes */ + public void notifyEvent(AccessibleEventObject event) { + switch (event.EventId) { + case AccessibleEventId.CHILD: + java.awt.Component c = getComponent(unoAccessible); + + Object values[] = { null, null }; + + if (AnyConverter.isObject(event.OldValue)) { + values[0] = getContext( event.OldValue ); + } + + if (AnyConverter.isObject(event.NewValue)) { + values[1] = getContext( event.NewValue); + } + + firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY, + values[0], values[1]); + break; + + default: + super.notifyEvent(event); + } + } + } + /** Creates the AccessibleContext associated with this object */ public javax.accessibility.AccessibleContext createAccessibleContext() { return new AccessibleButton(); } + protected java.awt.Component getComponent(XAccessible unoAccessible) { + java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(unoAccessible); + + if (c == null) { + c = AccessibleObjectFactory.createAccessibleComponent(unoAccessible); + + if (c instanceof javax.accessibility.Accessible) { + ((javax.accessibility.Accessible) c).getAccessibleContext() + .setAccessibleParent(this); + } + + if( c instanceof java.awt.Container ) { + AccessibleObjectFactory.populateContainer((java.awt.Container) c, unoAccessible.getAccessibleContext() ); + } + } + + return c; + } + protected class AccessibleButton extends AccessibleAbstractButton { /** Gets the role of this object */ public javax.accessibility.AccessibleRole getAccessibleRole() { return javax.accessibility.AccessibleRole.PUSH_BUTTON; } + + /** Returns the number of accessible children of the object */ + public int getAccessibleChildrenCount() { + try { + return unoAccessibleContext.getAccessibleChildCount(); + } catch (com.sun.star.uno.RuntimeException e) { + return 0; + } + } + + /** Returns the specified Accessible child of the object */ + public synchronized javax.accessibility.Accessible getAccessibleChild( int i) { + try { + return (javax.accessibility.Accessible) getComponent( unoAccessibleContext.getAccessibleChild(i) ); + } catch (com.sun.star.uno.RuntimeException e) { + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + return null; + } + + /* + * AccessibleComponent + */ + + /** Returns the Accessible child, if one exists, contained at the local coordinate Point */ + public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) { + try { + java.awt.Component c = getComponent(unoAccessibleComponent.getAccessibleAtPoint( + new com.sun.star.awt.Point(p.x, p.y))); + + return (javax.accessibility.Accessible) c; + } catch (com.sun.star.uno.RuntimeException e) { + return null; + } + } + } } |