summaryrefslogtreecommitdiff
path: root/accessibility
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility')
-rwxr-xr-xaccessibility/bridge/org/openoffice/accessibility/AccessBridge.java136
-rwxr-xr-xaccessibility/bridge/org/openoffice/accessibility/KeyHandler.java103
-rw-r--r--accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java505
-rwxr-xr-xaccessibility/bridge/org/openoffice/accessibility/makefile.mk10
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java102
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java4
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java67
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java252
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java6
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java129
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java124
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Button.java27
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java18
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java160
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Component.java286
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Container.java743
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java67
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Dialog.java28
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java111
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Frame.java30
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Icon.java69
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Label.java52
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/List.java44
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Menu.java58
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java16
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java6
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java18
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java144
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Separator.java64
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Table.java36
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java71
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java35
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java167
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Tree.java150
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Window.java24
-rwxr-xr-xaccessibility/bridge/org/openoffice/java/accessibility/makefile.mk11
-rwxr-xr-xaccessibility/prj/build.lst1
37 files changed, 2615 insertions, 1259 deletions
diff --git a/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java b/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java
index 39647d7a8406..82676ce83bbd 100755
--- a/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java
+++ b/accessibility/bridge/org/openoffice/accessibility/AccessBridge.java
@@ -2,10 +2,6 @@
*
* $RCSfile: AccessBridge.java,v $
*
- * $Revision: 1.12 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:34 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -86,7 +82,6 @@ import java.lang.reflect.InvocationTargetException;
public class AccessBridge {
-
//
static public class _AccessBridge implements XAccessibleTopWindowMap, XInitialization {
static final String _serviceName = "drafts.com.sun.star.accessibility.bridge.AccessBridge";
@@ -94,58 +89,10 @@ public class AccessBridge {
XMultiServiceFactory serviceManager;
java.util.Hashtable frameMap;
- AccessibleObjectFactory factory;
-
- protected class JABWEventListener implements java.awt.event.AWTEventListener {
- Method registerVirtualFrame;
- Method revokeVirtualFrame;
-
- // On Windows all native frames must be registered to the access bridge. Therefor
- // the bridge exports two methods that we try to find here.
- public JABWEventListener() {
- try {
- Class bridge = Class.forName("com.sun.java.accessibility.AccessBridge");
- Class[] parameterTypes = { javax.accessibility.Accessible.class, Integer.class };
-
- if (bridge != null) {
- registerVirtualFrame = bridge.getMethod("registerVirtualFrame", parameterTypes);
- revokeVirtualFrame = bridge.getMethod("revokeVirtualFrame", parameterTypes);
- }
- } catch (NoSuchMethodException e) {
- System.err.println("ERROR: incompatible AccessBridge found: " + e.getMessage());
-
- // Forward this exception to UNO to indicate that the service will not work correctly.
- throw new com.sun.star.uno.RuntimeException("incompatible AccessBridge class: " + e.getMessage());
- } catch (java.lang.SecurityException e) {
- System.err.println("ERROR: no access to AccessBridge: " + e.getMessage());
-
- // Forward this exception to UNO to indicate that the service will not work correctly.
- throw new com.sun.star.uno.RuntimeException("Security exception caught: " + e.getMessage());
- } catch(ClassNotFoundException e) {
- // Forward this exception to UNO to indicate that the service will not work correctly.
- throw new com.sun.star.uno.RuntimeException("ClassNotFound exception caught: " + e.getMessage());
- }
- }
-
- public void eventDispatched(java.awt.AWTEvent e) {
- switch (e.getID()) {
- case java.awt.event.WindowEvent.WINDOW_OPENED:
- if (Build.DEBUG) {
-// System.err.println("retrieved WINDOW_OPENED");
- }
- break;
- case java.awt.event.WindowEvent.WINDOW_CLOSED:
- break;
- default:
- break;
- }
- }
- }
public _AccessBridge(XMultiServiceFactory xMultiServiceFactory) {
serviceManager = xMultiServiceFactory;
frameMap = new java.util.Hashtable();
- factory = AccessibleObjectFactory.getDefault();
}
/*
@@ -153,25 +100,19 @@ public class AccessBridge {
*/
public void initialize(java.lang.Object[] arguments) {
- for(int i = 0; i < arguments.length; i++) {
- if( AnyConverter.isObject(arguments[i]) ) {
- try {
- // Currently there is no way to determine if key event forwarding is needed or not,
- // so we have to do it always ..
- XExtendedToolkit unoToolkit = (XExtendedToolkit)
- AnyConverter.toObject(new Type(XExtendedToolkit.class), arguments[i]);
-
- if(unoToolkit != null) {
- unoToolkit.addKeyHandler(new KeyHandler());
- } else if( Build.DEBUG) {
- System.err.println("argument " + i + "is not of type XExtendedToolkit.");
- }
- }
-
- catch(com.sun.star.lang.IllegalArgumentException e) {
- // FIXME: output
- }
+ try {
+ // Currently there is no way to determine if key event forwarding is needed or not,
+ // so we have to do it always ..
+ XExtendedToolkit unoToolkit = (XExtendedToolkit)
+ AnyConverter.toObject(new Type(XExtendedToolkit.class), arguments[0]);
+
+ if(unoToolkit != null) {
+ unoToolkit.addKeyHandler(new KeyHandler());
+ } else if( Build.DEBUG) {
+ System.err.println("argument 0 is not of type XExtendedToolkit.");
}
+ } catch(com.sun.star.lang.IllegalArgumentException e) {
+ // FIXME: output
}
}
@@ -188,7 +129,7 @@ public class AccessBridge {
System.out.println("register native frame: " + handle);
}
- java.awt.Window w = factory.getTopWindow(xAccessible);
+ java.awt.Window w = AccessibleObjectFactory.getTopWindow(xAccessible);
if (w != null) {
frameMap.put(handle, w);
}
@@ -227,8 +168,8 @@ public class AccessBridge {
public _WinAccessBridge(XMultiServiceFactory xMultiServiceFactory) {
super(xMultiServiceFactory);
- java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
- tk.addAWTEventListener(new JABWEventListener(), java.awt.AWTEvent.WINDOW_EVENT_MASK);
+// java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
+// tk.addAWTEventListener(new WindowsAccessBridgeAdapter(), java.awt.AWTEvent.WINDOW_EVENT_MASK);
// On Windows all native frames must be registered to the access bridge. Therefor
// the bridge exports two methods that we try to find here.
@@ -315,7 +256,7 @@ public class AccessBridge {
// The office sometimes registers frames more than once, so check here if already done
Integer handle = new Integer(AnyConverter.toInt(any));
if (! frameMap.containsKey(handle)) {
- java.awt.Window w = factory.getTopWindow(xAccessible);
+ java.awt.Window w = AccessibleObjectFactory.getTopWindow(xAccessible);
if (Build.DEBUG) {
System.out.println("register native frame: " + handle);
@@ -385,51 +326,6 @@ public class AccessBridge {
// Initialize toolkit to register at Java <-> Windows access bridge
java.awt.Toolkit tk = java.awt.Toolkit.getDefaultToolkit();
- String logPath = null;
-
- try {
- XInterface instance = (XInterface) multiFactory.createInstance(
- "org.openoffice.accessibility.internal.RemoteAccessBridge"
- );
-
- if(instance != null) {
- XAccessibilityInformationProvider infoProvider = (XAccessibilityInformationProvider)
- UnoRuntime.queryInterface(XAccessibilityInformationProvider.class, instance);
-
- if(infoProvider != null) {
- if( Build.DEBUG ) {
- logPath = infoProvider.getEnvironment("ACCESSBRIDGE_LOGPATH");
- }
- } else {
- System.err.println("InfoProvider does not implement XAccessibleInformationProvider.");
- }
-
- } else {
- System.err.println("InfoProvider service not found.");
- throw new com.sun.star.uno.RuntimeException("RemoteAccessBridge service not found.\n");
- }
- }
-
- catch (com.sun.star.uno.Exception e) {
- System.err.println(e.getMessage());
- throw new com.sun.star.uno.RuntimeException(e.getMessage());
- }
-
- // Redirect output to log file if ACCESSBRIDGE_LOGPATH environment variable is set.
- if( logPath != null && logPath.length() > 0 ) {
- try {
- java.io.PrintStream log = new java.io.PrintStream(
- new java.io.FileOutputStream( logPath + java.io.File.separator + "AccessBridge.log")
- );
-
- System.setOut(log);
- System.setErr(log);
- }
-
- catch(java.io.FileNotFoundException e) {
- }
- }
-
Class serviceClass;
String os = (String) System.getProperty("os.name");
if(os.startsWith("Windows")) {
diff --git a/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java b/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java
index ad3fc3f67a39..9d42a9fbd2e7 100755
--- a/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java
+++ b/accessibility/bridge/org/openoffice/accessibility/KeyHandler.java
@@ -2,9 +2,9 @@
*
* $RCSfile: KeyHandler.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: obr $ $Date: 2002-10-08 06:50:15 $
+ * last change: $Author: hr $ $Date: 2003-03-18 15:48:14 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,22 +71,21 @@ import java.awt.*;
import java.awt.event.KeyEvent;
import javax.accessibility.*;
-public class KeyHandler extends Component implements XKeyHandler {
+public class KeyHandler extends Component implements XKeyHandler, java.awt.KeyEventDispatcher {
EventQueue eventQueue;
public class VCLKeyEvent extends KeyEvent {
com.sun.star.awt.KeyEvent data;
+ XKeyHandler xKeyHandler;
- public VCLKeyEvent(int id, com.sun.star.awt.KeyEvent event) {
- super( KeyHandler.this,
- id,
- System.currentTimeMillis(),
- AccessibleKeyBinding.convertModifiers(event.Modifiers),
+ public VCLKeyEvent(Component c, int id, XKeyHandler handler, com.sun.star.awt.KeyEvent event) {
+ super(c, id, System.currentTimeMillis(), AccessibleKeyBinding.convertModifiers(event.Modifiers),
id == KeyEvent.KEY_TYPED ? KeyEvent.VK_UNDEFINED : AccessibleKeyBinding.convertKeyCode(event.KeyCode),
event.KeyChar != 0 ? event.KeyChar : KeyEvent.CHAR_UNDEFINED
);
data = event;
+ xKeyHandler = handler;
}
public void setData(com.sun.star.awt.KeyEvent event) {
@@ -96,73 +95,83 @@ public class KeyHandler extends Component implements XKeyHandler {
public com.sun.star.awt.KeyEvent getData() {
return data;
}
+
+ public XKeyHandler getKeyHandler() {
+ return xKeyHandler;
+ }
}
public KeyHandler() {
eventQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
- enableEvents(AWTEvent.KEY_EVENT_MASK);
+ java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(this);
}
- /** Processes key events occurring on this component by dispatching them to any registered KeyListener objects */
- protected void processKeyEvent(KeyEvent e) {
- // FIXME: will have to return this event object to VCL
- System.err.println("in process key event\n");
+ /** This method is called by the current KeyboardFocusManager requesting that this KeyEventDispatcher
+ * dispatch the specified event on its behalf
+ */
+ public boolean dispatchKeyEvent(java.awt.event.KeyEvent e) {
+ if (Build.DEBUG) {
+ System.err.println("in dispatchKeyEvent()");
+ }
- // Ignore key typed events, because VCL doesn't know about them
- if( e.getID() != KeyEvent.KEY_TYPED && e instanceof VCLKeyEvent ) {
+ if ((e.getID() != KeyEvent.KEY_TYPED) && (e instanceof VCLKeyEvent)) {
VCLKeyEvent event = (VCLKeyEvent) e;
com.sun.star.awt.KeyEvent unoKeyEvent = event.getData();
+ XKeyHandler xHandler = event.getKeyHandler();
// Return unhandled key events to VCL
- if( unoKeyEvent.Source != null ) {
- XKeyHandler xHandler = (XKeyHandler) UnoRuntime.queryInterface(XKeyHandler.class, unoKeyEvent.Source);
- if( xHandler != null ) {
- if( e.getID() == KeyEvent.KEY_PRESSED ) {
- xHandler.keyPressed(unoKeyEvent);
- } else if( e.getID() == KeyEvent.KEY_RELEASED ) {
- xHandler.keyReleased(unoKeyEvent);
- } else if( Build.DEBUG ) {
- System.err.println("*** WARNING ***: KeyEvent has unexspected id");
- }
- } else if( Build.DEBUG ) {
- System.err.println("*** ERROR ***: KeyEvent source does not implement XKeyHandler");
- }
- } else if( Build.DEBUG ) {
- System.err.println("*** ERROR ***: KeyEvent has no valid source");
+ if (e.getID() == KeyEvent.KEY_PRESSED) {
+ xHandler.keyPressed(unoKeyEvent);
+ } else if (e.getID() == KeyEvent.KEY_RELEASED) {
+ xHandler.keyReleased(unoKeyEvent);
+ } else if (Build.DEBUG) {
+ System.err.println("*** WARNING ***: KeyEvent has unexspected id");
}
}
+ return false;
}
/** Handler for KeyPressed events */
public boolean keyPressed(com.sun.star.awt.KeyEvent event) {
+ if (event.Source != null) {
+ XKeyHandler xHandler = (XKeyHandler) UnoRuntime.queryInterface(XKeyHandler.class, event.Source);
+ if (xHandler != null) {
+ eventQueue.postEvent(new VCLKeyEvent(this, KeyEvent.KEY_PRESSED, xHandler, event));
+
+ // Synthesize KEY_PRESSED event to emulate Java behavior
+ if (event.KeyChar != 0) {
+ eventQueue.postEvent(new VCLKeyEvent(this, KeyEvent.KEY_TYPED, xHandler, event));
+ }
- if( Build.DEBUG ) {
-// System.err.println("retrieved key pressed event: " + event.KeyChar );
- }
-
- eventQueue.postEvent(new VCLKeyEvent(KeyEvent.KEY_PRESSED, event));
-
- // Synthesize KEY_PRESSED event to emulate Java behavior
- if( event.KeyChar != 0 ) {
- eventQueue.postEvent(new VCLKeyEvent(KeyEvent.KEY_TYPED, event));
+// return true;
+ return false;
+ } else if (Build.DEBUG) {
+// System.err.println("*** ERROR *** KeyEvent source does not implement XKeyHandler");
+ }
+ } else if (Build.DEBUG) {
+// System.err.println("*** ERROR *** KeyEvent source not valid");
}
-
-// return true;
return false;
}
/** Handler for KeyReleased events */
public boolean keyReleased(com.sun.star.awt.KeyEvent event) {
- if( Build.DEBUG ) {
-// System.err.println("retrieved key released event\n");
+ if (event.Source != null) {
+ XKeyHandler xHandler = (XKeyHandler) UnoRuntime.queryInterface(XKeyHandler.class, event.Source);
+ if (xHandler != null) {
+ eventQueue.postEvent(new VCLKeyEvent(this, KeyEvent.KEY_RELEASED, xHandler, event));
+// return true;
+ return false;
+ } else if (Build.DEBUG) {
+ System.err.println("*** ERROR *** KeyEvent source does not implement XKeyHandler");
+ }
+ } else if (Build.DEBUG) {
+ System.err.println("*** ERROR *** KeyEvent source not valid");
}
-
- eventQueue.postEvent(new VCLKeyEvent(KeyEvent.KEY_RELEASED, event));
-
-// return true;
return false;
}
public void disposing(com.sun.star.lang.EventObject event) {
+ java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(this);
}
};
diff --git a/accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java b/accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java
new file mode 100644
index 000000000000..9aea64ecc9ed
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/accessibility/WindowsAccessBridgeAdapter.java
@@ -0,0 +1,505 @@
+/*************************************************************************
+ *
+ * $RCSfile: WindowsAccessBridgeAdapter.java,v $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package org.openoffice.accessibility;
+
+import org.openoffice.java.accessibility.*;
+
+import javax.accessibility.*;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+
+
+public class WindowsAccessBridgeAdapter implements java.awt.event.AWTEventListener, java.beans.PropertyChangeListener {
+
+ Method registerVirtualFrame;
+ Method revokeVirtualFrame;
+ Method removePropertyChangeListener;
+
+ protected class PopupMenuProxy extends AccessibleContext implements Accessible, AccessibleComponent {
+ AccessibleContext menu;
+
+ PopupMenuProxy(AccessibleContext ac) {
+ menu = ac;
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ return this;
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleComponent getAccessibleComponent() {
+ return this;
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ return null;
+ }
+
+ public java.util.Locale getLocale() {
+ return java.util.Locale.getDefault();
+ }
+
+ public int getAccessibleIndexInParent() {
+ return -1;
+ }
+
+ public int getAccessibleChildrenCount() {
+ return menu.getAccessibleChildrenCount();
+ }
+
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ return menu.getAccessibleChild(i);
+ }
+
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.POPUP_MENU;
+ }
+
+ /*
+ * AccessibleComponent
+ */
+
+ public void addFocusListener(java.awt.event.FocusListener fl) {
+ }
+
+ public void removeFocusListener(java.awt.event.FocusListener fl) {
+ }
+
+ /** Returns the background color of the object */
+ public java.awt.Color getBackground() {
+ return null;
+ }
+
+ public void setBackground(java.awt.Color c) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Returns the foreground color of the object */
+ public java.awt.Color getForeground() {
+ return null;
+ }
+
+ public void setForeground(java.awt.Color c) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Cursor getCursor() {
+ // Not supported by UNO accessibility API
+ return null;
+ }
+
+ public void setCursor(java.awt.Cursor cursor) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Font getFont() {
+ // FIXME
+ return null;
+ }
+
+ public void setFont(java.awt.Font f) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
+ // FIXME
+ return null;
+ }
+
+ public boolean isEnabled() {
+ return true;
+ }
+
+ public void setEnabled(boolean b) {
+ // Not supported by UNO accessibility API
+ }
+
+ public boolean isVisible() {
+ return true;
+ }
+
+ public void setVisible(boolean b) {
+ // Not supported by UNO accessibility API
+ }
+
+ public boolean isShowing() {
+ return true;
+ }
+
+ public boolean contains(java.awt.Point p) {
+ java.awt.Dimension d = getSize();
+
+ if (Build.DEBUG) {
+ System.err.println("PopupMenuProxy.contains(" + p.x + "," + p.y + ") returns " +
+ (((d.width >= 0) && (p.x < d.width) && (d.height >= 0) && (p.y < d.height)) ? "true" : "false"));
+ }
+
+ if ((d.width >= 0) && (p.x < d.width) && (d.height >= 0) && (p.y < d.height)) {
+ return true;
+ }
+ return false;
+ }
+
+ /** Returns the location of the object on the screen. */
+ public java.awt.Point getLocationOnScreen() {
+ if (menu != null) {
+ Accessible a = menu.getAccessibleChild(0);
+ if (a != null) {
+ AccessibleContext ac = a.getAccessibleContext();
+ if (ac != null) {
+ return ac.getAccessibleComponent().getLocationOnScreen();
+ }
+ }
+ }
+ return null;
+ }
+
+ /** Gets the location of this component in the form of a point specifying the component's top-left corner */
+ public java.awt.Point getLocation() {
+ // This object represents a toplevel, so this is the same as getLocationOnScreen()
+ return getLocationOnScreen();
+ }
+
+ /** Moves this component to a new location */
+ public void setLocation(java.awt.Point p) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Gets the bounds of this component in the form of a Rectangle object */
+ public java.awt.Rectangle getBounds() {
+ java.awt.Dimension d = getSize();
+ java.awt.Point p = getLocationOnScreen();
+ return new java.awt.Rectangle(p.x, p.y, d.width, d.height);
+ }
+
+ /** Moves and resizes this component to conform to the new bounding rectangle r */
+ public void setBounds(java.awt.Rectangle r) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Returns the size of this component in the form of a Dimension object */
+ public java.awt.Dimension getSize() {
+ if (menu != null) {
+ int count = menu.getAccessibleChildrenCount();
+ int width = 0; int height = 0;
+ for (int i = 0; i < count; i++) {
+ Accessible a = menu.getAccessibleChild(i);
+ if (a != null) {
+ AccessibleContext ac = a.getAccessibleContext();
+ if (ac != null) {
+ java.awt.Dimension d = ac.getAccessibleComponent().getSize();
+ width += d.width;
+ height += d.height;
+ }
+ }
+ }
+ return new java.awt.Dimension(width, height);
+ }
+ return null;
+ }
+
+ /** Resizes this component so that it has width d.width and height d.height */
+ public void setSize(java.awt.Dimension d) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Returns the Accessible child, if one exists, contained at the local coordinate Point */
+ public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) {
+ if (menu != null) {
+ int count = menu.getAccessibleChildrenCount();
+ for (int i = 0; i < count; i++) {
+ Accessible a = menu.getAccessibleChild(i);
+ if (a != null) {
+ AccessibleContext ac = a.getAccessibleContext();
+ AccessibleComponent comp = ac.getAccessibleComponent();
+ java.awt.Point loc = comp.getLocationOnScreen();
+ if ((p.x >= loc.x) && (p.y >= loc.y)) {
+ java.awt.Dimension d = comp.getSize();
+ if ((p.x < loc.x + d.width) && (p.y < loc.y + d.height)) {
+ return a;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ public boolean isFocusTraversable() {
+ return true;
+ }
+
+ public void requestFocus() {
+ }
+ }
+
+ // On Windows all native frames must be registered to the access bridge. Therefor
+ // the bridge exports two methods that we try to find here.
+ public WindowsAccessBridgeAdapter() {
+ try {
+ Class bridge = Class.forName("com.sun.java.accessibility.AccessBridge");
+ Class[] parameterTypes = { javax.accessibility.Accessible.class, Integer.class };
+
+ if (bridge != null) {
+ registerVirtualFrame = bridge.getMethod("registerVirtualFrame", parameterTypes);
+ revokeVirtualFrame = bridge.getMethod("revokeVirtualFrame", parameterTypes);
+ }
+
+ // Register PropertyChangeListener to track popup windows
+ Class monitor = Class.forName("com.sun.java.accessibility.util.AccessibilityEventMonitor");
+ Class[] monitorParams = { java.beans.PropertyChangeListener.class };
+
+ Method addPropertyChangeListener = monitor.getMethod("addPropertyChangeListener", monitorParams);
+ removePropertyChangeListener = monitor.getMethod("removePropertyChangeListener", monitorParams);
+
+ Object[] params = { this };
+ addPropertyChangeListener.invoke(null, params);
+
+ System.loadLibrary("java_uno_accessbridge");
+
+ } catch (NoSuchMethodException e) {
+ System.err.println("ERROR: incompatible AccessBridge found: " + e.getMessage());
+
+ // Forward this exception to UNO to indicate that the service will not work correctly.
+ throw new com.sun.star.uno.RuntimeException("incompatible AccessBridge class: " + e.getMessage());
+ } catch (java.lang.SecurityException e) {
+ System.err.println("ERROR: no access to AccessBridge: " + e.getMessage());
+
+ // Forward this exception to UNO to indicate that the service will not work correctly.
+ throw new com.sun.star.uno.RuntimeException("Security exception caught: " + e.getMessage());
+ } catch(ClassNotFoundException e) {
+
+ // Forward this exception to UNO to indicate that the service will not work correctly.
+ throw new com.sun.star.uno.RuntimeException("ClassNotFound exception caught: " + e.getMessage());
+ } catch(IllegalAccessException e) {
+ System.err.println("IllegalAccessException caught: " + e.getMessage());
+
+ // Forward this exception to UNO to indicate that the service will not work correctly.
+ throw new com.sun.star.uno.RuntimeException("IllegalAccessException caught: " + e.getMessage());
+ } catch(IllegalArgumentException e) {
+ System.err.println("IllegalArgumentException caught: " + e.getMessage());
+
+ // Forward this exception to UNO to indicate that the service will not work correctly.
+ throw new com.sun.star.uno.RuntimeException("IllegalArgumentException caught: " + e.getMessage());
+ } catch(InvocationTargetException e) {
+ System.err.println("InvokationTargetException caught: " + e.getMessage());
+
+ // Forward this exception to UNO to indicate that the service will not work correctly.
+ throw new com.sun.star.uno.RuntimeException("InvokationTargetException caught: " + e.getMessage());
+ }
+ }
+
+ /** Registers a native frame at the Java AccessBridge for Windows */
+ protected void registerFrame(Integer handle, Accessible a) {
+ Object[] args = { a, handle };
+
+ if (Build.DEBUG) {
+ System.err.println("Native frame " + handle + " has been opened");
+ }
+
+ try {
+ registerVirtualFrame.invoke(null, args);
+ } catch(IllegalAccessException e) {
+ System.err.println("IllegalAccessException caught: " + e.getMessage());
+ } catch(IllegalArgumentException e) {
+ System.err.println("IllegalArgumentException caught: " + e.getMessage());
+ } catch(InvocationTargetException e) {
+ System.err.println("InvokationTargetException caught: " + e.getMessage());
+ }
+ }
+
+ /** Registers a popup window at the Java AccessBridge for Windows */
+ protected void registerPopup(Integer handle, Accessible a) {
+ Object[] args = { a, handle };
+
+ if (Build.DEBUG) {
+ System.err.println("Popup menu " + handle + " has been opened");
+ }
+
+ try {
+ registerVirtualFrame.invoke(null, args);
+ } catch(IllegalAccessException e) {
+ System.err.println("IllegalAccessException caught: " + e.getMessage());
+ } catch(IllegalArgumentException e) {
+ System.err.println("IllegalArgumentException caught: " + e.getMessage());
+ } catch(InvocationTargetException e) {
+ System.err.println("InvokationTargetException caught: " + e.getMessage());
+ }
+ }
+
+ protected void handleWindowOpened(Accessible a) {
+ if (a != null) {
+ AccessibleContext ac = a.getAccessibleContext();
+ if (ac != null) {
+ int hwnd = getHWNDFromComponent(ac.getAccessibleComponent());
+ if (hwnd > 0) {
+ registerFrame(new Integer(hwnd), a);
+ }
+ }
+ }
+ }
+
+ public void eventDispatched(java.awt.AWTEvent evt) {
+ switch (evt.getID()) {
+ case java.awt.event.WindowEvent.WINDOW_OPENED:
+ handleWindowOpened((Accessible) evt.getSource());
+ break;
+ case java.awt.event.WindowEvent.WINDOW_CLOSED:
+ if (Build.DEBUG) {
+ System.err.println("retrieved WINDOW_CLOSED");
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected void handlePopupMenuOpened(AccessibleContext menu) {
+ try {
+ PopupMenuProxy pmp = new PopupMenuProxy(menu);
+ int hwnd = getHWNDFromComponent(pmp.getAccessibleComponent());
+ if (hwnd != 0) {
+ registerPopup(new Integer(hwnd), pmp);
+ }
+ } catch (NullPointerException e) {
+ } catch (IndexOutOfBoundsException e) {
+ }
+ }
+
+ /** This method gets called when a bound property is changed. */
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if (evt.getPropertyName().equals(AccessibleContext.ACCESSIBLE_STATE_PROPERTY)) {
+ AccessibleContext ac = null;
+
+ if (evt.getSource() instanceof AccessibleContext) {
+ ac = (AccessibleContext) evt.getSource();
+ } else if (evt.getSource() instanceof Accessible) {
+ ac = ((Accessible) evt.getSource()).getAccessibleContext();
+ } else {
+ // This should never happen
+ return;
+ }
+
+ // Track ComboBox popups by VISIBLE state of their lists ..
+ if (ac.getAccessibleRole().equals(AccessibleRole.LIST)) {
+ Accessible pa = ac.getAccessibleParent();
+ if (pa != null) {
+ AccessibleContext pac = pa.getAccessibleContext();
+ if (pac != null && pac.getAccessibleRole().equals(AccessibleRole.COMBO_BOX)) {
+ if (evt.getOldValue() instanceof AccessibleState) {
+ AccessibleState as = (AccessibleState) evt.getOldValue();
+ if (as.equals(AccessibleState.VISIBLE)) {
+ if (Build.DEBUG) {
+ System.err.println("ComboBox popup closed");
+ }
+ }
+ }
+ if (evt.getNewValue() instanceof AccessibleState) {
+ AccessibleState as = (AccessibleState) evt.getNewValue();
+ if (as.equals(AccessibleState.VISIBLE)) {
+ if (Build.DEBUG) {
+ System.err.println("ComboBox popup opened");
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Track Menu popups by SELECTED state changes ..
+ if (ac.getAccessibleRole().equals(AccessibleRole.MENU)) {
+ if (evt.getOldValue() instanceof AccessibleState) {
+ AccessibleState as = (AccessibleState) evt.getOldValue();
+ if (as.equals(AccessibleState.SELECTED)) {
+ if (Build.DEBUG) {
+ System.err.println("Popup menu closed");
+ }
+ }
+ }
+ if (evt.getNewValue() instanceof AccessibleState) {
+ AccessibleState as = (AccessibleState) evt.getNewValue();
+ if (as.equals(AccessibleState.SELECTED)) {
+ handlePopupMenuOpened(ac);
+ }
+ }
+ }
+ }
+ }
+
+ protected static int getHWNDFromComponent(AccessibleComponent ac) {
+ if (ac != null) {
+ java.awt.Point p = ac.getLocationOnScreen();
+ if (p != null) {
+ java.awt.Dimension d = ac.getSize();
+ if (d != null) {
+ return getHWNDFromPoint(p.x + (d.width % 2), p.y + (d.height % 2));
+ }
+ }
+ }
+ return -1;
+ }
+
+ protected static native int getHWNDFromPoint(int x, int y);
+
+ protected void finalize() throws Throwable {
+ Object[] params = { this };
+ removePropertyChangeListener.invoke(null, params);
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/accessibility/makefile.mk b/accessibility/bridge/org/openoffice/accessibility/makefile.mk
index 462e100f7a2a..0c619338514a 100755
--- a/accessibility/bridge/org/openoffice/accessibility/makefile.mk
+++ b/accessibility/bridge/org/openoffice/accessibility/makefile.mk
@@ -2,10 +2,6 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
-#
-# last change: $Author: obr $ $Date: 2002-08-14 12:14:49 $
-#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
@@ -73,7 +69,11 @@ USE_JAVAVER:=TRUE
.IF "$(JAVAVER:s/.//)" >= "140"
JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar
-JAVAFILES := $(shell +ls *.java)
+JAVAFILES = \
+ AccessBridge.java \
+ KeyHandler.java \
+ WindowsAccessBridgeAdapter.java
+
JAVACLASSFILES= $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
JARTARGET = $(TARGET).jar
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java b/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java
index 7629fae82197..baf50d0bc679 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java
@@ -2,10 +2,6 @@
*
* $RCSfile: AbstractButton.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:06 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,56 +57,21 @@
package org.openoffice.java.accessibility;
-import java.text.BreakIterator;
-
-import javax.accessibility.AccessibleAction;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
-import javax.accessibility.AccessibleStateSet;
-import javax.accessibility.AccessibleText;
-import javax.swing.text.SimpleAttributeSet;
-import javax.swing.text.StyleConstants;
-
-import com.sun.star.awt.Point;
-import com.sun.star.awt.Rectangle;
-import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.*;
import drafts.com.sun.star.accessibility.*;
/**
*/
public abstract class AbstractButton extends Component {
- protected AbstractButton() {
- super();
- }
-
- protected class AccessibleAbstractButtonListener extends AccessibleUNOComponentListener {
-
- protected AccessibleAbstractButtonListener() {
- super();
- }
-
- protected void setComponentState(short state, boolean enable) {
- switch (state) {
- case AccessibleStateType.ARMED:
- fireStatePropertyChange(AccessibleState.ARMED, enable);
- break;
- case AccessibleStateType.CHECKED:
- fireStatePropertyChange(AccessibleState.CHECKED, enable);
- break;
- case AccessibleStateType.PRESSED:
- fireStatePropertyChange(AccessibleState.PRESSED, enable);
- break;
- default:
- super.setComponentState(state, enable);
- break;
- }
- }
+ protected AbstractButton(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
protected abstract class AccessibleAbstractButton extends AccessibleUNOComponent
- implements AccessibleAction /*, AccessibleExtendedComponent */ {
+ implements javax.accessibility.AccessibleAction {
/**
* Though the class is abstract, this should be called by all sub-classes
@@ -119,44 +80,32 @@ public abstract class AbstractButton extends Component {
super();
}
- /*
- * AccessibleContext
- */
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
- /**
- * Get the state set of this object.
- *
- * @return an instance of AccessibleState containing the current state
- * of the object
- * @see AccessibleState
- */
- public AccessibleStateSet getAccessibleStateSet() {
- AccessibleStateSet states = super.getAccessibleStateSet();
- // FIXME: quick hack to avoid dead lock in Window.dispose ..
- if (java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().isDispatchThread()) {
- return states;
- }
- if (!isShowing()) {
- return states;
- }
try {
- XAccessibleStateSet unoAccessibleStateSet =
- unoAccessible.getAccessibleContext().getAccessibleStateSet();
- if (unoAccessibleStateSet.contains(AccessibleStateType.ARMED)) {
- states.add(AccessibleState.ARMED);
- }
- if (unoAccessibleStateSet.contains(AccessibleStateType.PRESSED)) {
- states.add(AccessibleState.PRESSED);
- }
- if (unoAccessibleStateSet.contains(AccessibleStateType.CHECKED)) {
- states.add(AccessibleState.CHECKED);
+ if (unoAS != null) {
+ if (unoAS.contains(AccessibleStateType.ARMED)) {
+ states.add(AccessibleState.ARMED);
+ }
+ if (unoAS.contains(AccessibleStateType.PRESSED)) {
+ states.add(AccessibleState.PRESSED);
+ }
+ if (unoAS.contains(AccessibleStateType.CHECKED)) {
+ states.add(AccessibleState.CHECKED);
+ }
}
} catch (com.sun.star.uno.RuntimeException e) {
- } catch (NullPointerException e) {
}
+
return states;
}
+ /*
+ * AccessibleContext
+ */
+
/** Gets the AccessibleAction associated with this object that supports one or more actions */
public javax.accessibility.AccessibleAction getAccessibleAction() {
return this;
@@ -177,12 +126,6 @@ public abstract class AbstractButton extends Component {
}
}
- /** Gets the locale of the component */
- public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException {
- // The java loader sets the UI locale as default at startup
- return java.util.Locale.getDefault();
- }
-
/*
* AccessibleAction
*/
@@ -227,4 +170,3 @@ public abstract class AbstractButton extends Component {
}
}
-
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java
index 8dd6d7453ffe..13430062063d 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleComponentImpl.java,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:06 $
+ * last change: $Author: hr $ $Date: 2003-03-18 15:48:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java
index c1f27eb86df0..e0d2a045b920 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleKeyBinding.java
@@ -2,10 +2,6 @@
*
* $RCSfile: AccessibleKeyBinding.java,v $
*
- * $Revision: 1.3 $
- *
- * last change: $Author: obr $ $Date: 2002-10-08 06:48:01 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,47 +57,40 @@
package org.openoffice.java.accessibility;
-import org.openoffice.accessibility.internal.*;
+import drafts.com.sun.star.accessibility.*;
+import drafts.com.sun.star.awt.*;
/**
*
*/
public class AccessibleKeyBinding extends Object implements javax.accessibility.AccessibleKeyBinding {
- javax.swing.KeyStroke[] data;
+ XAccessibleKeyBinding unoAccessibleKeybinding;
- public AccessibleKeyBinding(KeyStroke[] keys) {
- data = new javax.swing.KeyStroke[keys.length];
- for(int i=0; i < keys.length; i++) {
- data[i] = javax.swing.KeyStroke.getKeyStroke(
- convertKeyCode(keys[i].KeyCode),
- convertModifiers(keys[i].Modifiers)
- );
- }
+ public AccessibleKeyBinding(XAccessibleKeyBinding unoKB) {
+ unoAccessibleKeybinding = unoKB;
}
public static int convertModifiers(short s) {
int modifiers = 0;
-
- if( (s & com.sun.star.awt.KeyModifier.SHIFT) != 0 ) {
- modifiers = modifiers | java.awt.event.KeyEvent.VK_SHIFT;
+ if ((s & com.sun.star.awt.KeyModifier.SHIFT) != 0) {
+ modifiers = modifiers | java.awt.event.KeyEvent.SHIFT_DOWN_MASK;
}
- if( (s & com.sun.star.awt.KeyModifier.MOD1) != 0 ) {
- modifiers = modifiers | java.awt.event.KeyEvent.VK_CONTROL;
+ if ((s & com.sun.star.awt.KeyModifier.MOD1) != 0) {
+ modifiers = modifiers | java.awt.event.KeyEvent.CTRL_DOWN_MASK;
}
- if( (s & com.sun.star.awt.KeyModifier.MOD2) != 0 ) {
- modifiers = modifiers | java.awt.event.KeyEvent.VK_ALT;
+ if ((s & com.sun.star.awt.KeyModifier.MOD2) != 0) {
+ modifiers = modifiers | java.awt.event.KeyEvent.ALT_DOWN_MASK;
}
-
return modifiers;
}
public static int convertKeyCode(short s) {
int keycode = java.awt.event.KeyEvent.VK_UNDEFINED;
- switch( s ) {
+ switch(s) {
case com.sun.star.awt.Key.NUM0:
keycode = java.awt.event.KeyEvent.VK_NUMPAD0;
break;
@@ -378,7 +367,6 @@ public class AccessibleKeyBinding extends Object implements javax.accessibility.
default:
;
}
-
return keycode;
}
@@ -388,15 +376,36 @@ public class AccessibleKeyBinding extends Object implements javax.accessibility.
/** Returns a key binding for this object */
public Object getAccessibleKeyBinding(int i) {
- if( i < data.length ) {
- return data[i];
- }
+ try {
+ KeyStroke[] keys = unoAccessibleKeybinding.getAccessibleKeyBinding(i);
+ javax.swing.KeyStroke[] data = new javax.swing.KeyStroke[keys.length];
+ for (int j=0; j < keys.length; j++) {
+ int keyCode = convertKeyCode(keys[j].KeyCode);
+ if (keyCode != java.awt.event.KeyEvent.VK_UNDEFINED) {
+ data[j] = javax.swing.KeyStroke.getKeyStroke(keyCode, convertModifiers(keys[j].Modifiers));
+ } else {
+ data[j] = null;
+ }
+ }
- return null;
+ if (keys.length == 1) {
+ return data[0];
+ } else {
+ return data;
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ return null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
}
/** Returns the number of key bindings for this object */
public int getAccessibleKeyBindingCount() {
- return data.length;
+ try {
+ return unoAccessibleKeybinding.getAccessibleKeyBindingCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java
index 9b737e4f8240..c8efdb618652 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java
@@ -2,10 +2,6 @@
*
* $RCSfile: AccessibleObjectFactory.java,v $
*
- * $Revision: 1.13 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:06 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -72,67 +68,18 @@ import drafts.com.sun.star.accessibility.*;
/**
*/
-public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
-
- // This type is needed for conversions from/to uno Any
- public static boolean autoPopulate = true;
-
- java.util.Hashtable objectList = new java.util.Hashtable();
-
- private static AccessibleObjectFactory defaultFactory = new AccessibleObjectFactory();
-
- protected AccessibleObjectFactory() {
- // FIXME: provide default implementation of XAccessibilityInformationProvider
-// infoProvider = provider;
- }
-
- /** Returns the default accessible object factory */
- public static AccessibleObjectFactory getDefault() {
- return defaultFactory;
- }
-
- /** Returns the Component that should receive the focus after aComponent */
- public java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot,
- java.awt.Component aComponent) {
- return null;
- }
-
- /** Returns the Component that should receive the focus before aComponent */
- public java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot,
- java.awt.Component aComponent) {
- return null;
- }
-
- /** Returns the default Component to focus */
- public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot) {
- return null;
- }
-
- /** Returns the first Component in the traversal cycle */
- public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot) {
- return null;
- }
-
- /** Returns the Component that should receive the focus when a Window is made visible for the first time */
- public java.awt.Component getInitialComponent(java.awt.Window window) {
- if (window instanceof NativeFrame) {
- return ((NativeFrame) window).getInitialComponent();
- }
- return null;
- }
+public class AccessibleObjectFactory {
- /** Returns the last Component in the traversal cycle */
- public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot) {
- return null;
- }
+ private static java.util.Hashtable objectList = new java.util.Hashtable();
+ private static java.awt.FocusTraversalPolicy focusTraversalPolicy = new FocusTraversalPolicy();
- private java.awt.EventQueue eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
+ private static java.awt.EventQueue eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
- public java.awt.EventQueue getEventQueue() {
+ public static java.awt.EventQueue getEventQueue() {
return eventQueue;
}
- public java.awt.Component getAccessibleComponent(XAccessible xAccessible) {
+ protected static java.awt.Component getAccessibleComponent(XAccessible xAccessible) {
java.awt.Component c = null;
if (xAccessible != null) {
// Retrieve unique id for the original UNO object to be used as a hash key
@@ -149,10 +96,33 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
return c;
}
- /**
- * returns the child component that has the initial input focus
- */
- protected void populateContainer(java.awt.Container parent, XAccessibleContext parentAC, java.awt.Window frame) {
+
+ protected static void clearContainer(java.awt.Container parent) {
+ // FIXME: may need to purge the children to safe memory ..
+// int count = parent.getComponentCount();
+// for (int i = 0; i < count; i++) {
+// java.awt.Component c = parent.getComponent(i);
+// }
+ parent.removeAll();
+ }
+
+ protected static void populateContainer(java.awt.Container parent, XAccessibleContext parentAC) {
+ java.awt.Window w = null;
+
+ // find the top level window of this container
+ java.awt.Container c = parent;
+ while (c != null) {
+ if (c instanceof java.awt.Window) {
+ w = (java.awt.Window) c;
+ break;
+ }
+ c = c.getParent();
+ }
+
+ populateContainer(parent, parentAC, w);
+ }
+
+ protected static void populateContainer(java.awt.Container parent, XAccessibleContext parentAC, java.awt.Window frame) {
if (parentAC != null) {
try {
int childCount = parentAC.getAccessibleChildCount();
@@ -180,14 +150,12 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
}
}
- protected java.awt.Component createAccessibleComponent(XAccessible xAccessible) {
+ protected static java.awt.Component createAccessibleComponent(XAccessible xAccessible) {
if (xAccessible != null) {
try {
XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext();
if (xAccessibleContext != null) {
- java.awt.Component c = createAccessibleComponentImpl(xAccessible,
- xAccessibleContext.getAccessibleRole(), (XAccessibleComponent)
- UnoRuntime.queryInterface(XAccessibleComponent.class,xAccessibleContext),
+ java.awt.Component c = createAccessibleComponentImpl(xAccessible, xAccessibleContext,
xAccessibleContext.getAccessibleStateSet());
if (c != null) {
if (c instanceof java.awt.Container) {
@@ -202,22 +170,34 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
return null;
}
- protected java.awt.Component createAccessibleComponent(XAccessible xAccessible, XAccessibleContext xAccessibleContext,
+ protected static java.awt.Component createAccessibleComponent(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ try {
+ if (xAccessibleContext != null) {
+ java.awt.Component c = createAccessibleComponentImpl(xAccessible, xAccessibleContext,
+ xAccessibleContext.getAccessibleStateSet());
+ if (c != null) {
+ if (c instanceof java.awt.Container) {
+ populateContainer(((java.awt.Container) c), xAccessibleContext, null);
+ }
+ return c;
+ }
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return null;
+ }
+
+ protected static java.awt.Component createAccessibleComponent(XAccessible xAccessible, XAccessibleContext xAccessibleContext,
java.awt.Window frame) {
if (xAccessibleContext != null) {
try {
XAccessibleStateSet xAccessibleStateSet = xAccessibleContext.getAccessibleStateSet();
- java.awt.Component c = createAccessibleComponentImpl(xAccessible,
- xAccessibleContext.getAccessibleRole(), (XAccessibleComponent)
- UnoRuntime.queryInterface(XAccessibleComponent.class, xAccessibleContext),
- xAccessibleStateSet);
+ java.awt.Component c = createAccessibleComponentImpl(xAccessible, xAccessibleContext, xAccessibleStateSet);
if (c != null) {
// Set this component as initial component
if (xAccessibleStateSet.contains(AccessibleStateType.FOCUSED)) {
- if (frame instanceof Dialog) {
- ((Dialog) frame).setInitialComponent(c);
- } else if (frame instanceof Frame) {
- ((Frame) frame).setInitialComponent(c);
+ if (frame instanceof NativeFrame) {
+ ((NativeFrame) frame).setInitialComponent(c);
}
}
return c;
@@ -230,79 +210,68 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
return null;
}
- protected java.awt.Component createAccessibleComponentImpl(XAccessible xAccessible, short role,
- XAccessibleComponent xAccessibleComponent, XAccessibleStateSet xAccessibleStateSet) {
+ protected static java.awt.Component createAccessibleComponentImpl(XAccessible xAccessible, XAccessibleContext xAccessibleContext,
+ XAccessibleStateSet xAccessibleStateSet) {
java.awt.Component c = null;
+ short role = xAccessibleContext.getAccessibleRole();
switch (role) {
case AccessibleRole.CANVAS:
c = new Container(javax.accessibility.AccessibleRole.CANVAS,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.CHECKBOX:
- c = new CheckBox(xAccessible, xAccessibleComponent);
+ c = new CheckBox(xAccessible, xAccessibleContext);
break;
case AccessibleRole.COMBOBOX:
- // There is a different understanding of combo boxes in VCL than in Java:
- // the Java combo boxes correspond to the VCL DropDown[Combo|List]Boxes,
- // while all Combo-/ListBoxes if VCL return the role COMBOBOX
- XAccessibleAction xAccessibleAction = (XAccessibleAction)
- UnoRuntime.queryInterface(XAccessibleAction.class, xAccessibleComponent);
- if (xAccessibleAction != null && xAccessibleAction.getAccessibleActionCount() > 0) {
-// c = new ComboBox(xAccessible, xAccessibleComponent, xAccessibleAction);
- c = new Container(javax.accessibility.AccessibleRole.COMBO_BOX,
- xAccessible, xAccessibleComponent);
- } else {
- c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
- }
+ c = new ComboBox(xAccessible, xAccessibleContext);
break;
case AccessibleRole.DOCUMENT:
c = new Container(javax.accessibility.AccessibleRole.CANVAS,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.EMBEDDED_OBJECT:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.ENDNOTE:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.FILLER:
c = new Container(javax.accessibility.AccessibleRole.FILLER,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.FOOTNOTE:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.FOOTER:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.GRAPHIC:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.HEADER:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.ICON:
- c = new Icon(xAccessible, xAccessibleComponent);
+ c = new Icon(xAccessible, xAccessibleContext);
break;
case AccessibleRole.LABEL:
- c = new Label(xAccessible, xAccessibleComponent);
+ c = new Label(xAccessible, xAccessibleContext);
break;
case AccessibleRole.LAYEREDPANE:
c = new Container(javax.accessibility.AccessibleRole.LAYERED_PANE,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.LIST:
- c = new List(xAccessible, xAccessibleComponent);
+ c = new List(xAccessible, xAccessibleContext);
break;
case AccessibleRole.MENU:
- c = new Menu(xAccessible, xAccessibleComponent);
+ c = new Menu(xAccessible, xAccessibleContext);
// !!! FIXME !!!
// Menu items are always visible, but change SHOWING state
// if (!xAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
@@ -310,10 +279,10 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
// }
break;
case AccessibleRole.MENUBAR:
- c = new MenuBar(xAccessible, xAccessibleComponent);
+ c = new Container(javax.accessibility.AccessibleRole.MENU_BAR, xAccessible, xAccessibleContext);
break;
case AccessibleRole.MENUITEM:
- c = new MenuItem(xAccessible, xAccessibleComponent);
+ c = new MenuItem(xAccessible, xAccessibleContext);
c.setFocusable(false);
// Menu items are always visible, but change SHOWING state
// if (!xAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
@@ -321,108 +290,110 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
// }
break;
case AccessibleRole.POPUPMENU:
- c = new PopupMenu(xAccessible, xAccessibleComponent);
+ c = new Container(javax.accessibility.AccessibleRole.POPUP_MENU, xAccessible, xAccessibleContext);
break;
case AccessibleRole.OPTIONPANE:
c = new Container(javax.accessibility.AccessibleRole.OPTION_PANE,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.PAGETAB:
- c = new Container(javax.accessibility.AccessibleRole.PAGE_TAB,
- xAccessible, xAccessibleComponent);
+ c = new Container(javax.accessibility.AccessibleRole.PAGE_TAB, xAccessible, xAccessibleContext);
break;
case AccessibleRole.PAGETABLIST:
- c = new PageTabList(xAccessible, xAccessibleComponent);
+ c = new Container(javax.accessibility.AccessibleRole.PAGE_TAB_LIST, xAccessible, xAccessibleContext);
break;
case AccessibleRole.PARAGRAPH:
case AccessibleRole.HEADING:
- c = new TextComponent(xAccessible, xAccessibleComponent, xAccessibleStateSet);
+ c = new TextComponent(xAccessible, xAccessibleContext, xAccessibleStateSet);
break;
case AccessibleRole.PANEL:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.PUSHBUTTON:
- c = new Button(xAccessible, xAccessibleComponent);
+ c = new Button(xAccessible, xAccessibleContext);
break;
case AccessibleRole.RADIOBUTTON:
- c = new RadioButton(xAccessible, xAccessibleComponent);
+ c = new RadioButton(xAccessible, xAccessibleContext);
break;
case AccessibleRole.ROOTPANE:
c = new Container(javax.accessibility.AccessibleRole.ROOT_PANE,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.SCROLLBAR:
if (xAccessibleStateSet.contains(AccessibleStateType.VERTICAL)) {
- c = new ScrollBar(xAccessible, xAccessibleComponent,
+ c = new ScrollBar(xAccessible, xAccessibleContext,
javax.swing.SwingConstants.VERTICAL);
} else {
- c = new ScrollBar(xAccessible, xAccessibleComponent);
+ c = new ScrollBar(xAccessible, xAccessibleContext);
}
break;
case AccessibleRole.SCROLLPANE:
c = new Container(javax.accessibility.AccessibleRole.SCROLL_PANE,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.SEPARATOR:
if (xAccessibleStateSet.contains(AccessibleStateType.VERTICAL)) {
- c = new Separator(xAccessible, xAccessibleComponent,
+ c = new Separator(xAccessible, xAccessibleContext,
javax.swing.SwingConstants.VERTICAL);
} else {
- c = new Separator(xAccessible, xAccessibleComponent);
+ c = new Separator(xAccessible, xAccessibleContext);
}
break;
case AccessibleRole.SHAPE:
c = new Container(javax.accessibility.AccessibleRole.CANVAS,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.SPLITPANE:
c = new Container(javax.accessibility.AccessibleRole.SPLIT_PANE,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.STATUSBAR:
c = new Container(javax.accessibility.AccessibleRole.STATUS_BAR,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.TABLE:
if (xAccessibleStateSet.contains(AccessibleStateType.MANAGES_DESCENDANT)) {
- c = new Table(xAccessible, xAccessibleComponent,
+ c = new Table(xAccessible, xAccessibleContext,
xAccessibleStateSet.contains(AccessibleStateType.MULTISELECTABLE));
} else {
c = new Container(javax.accessibility.AccessibleRole.TABLE,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
}
break;
case AccessibleRole.TABLE_CELL:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.TEXT:
- c = new TextComponent(xAccessible, xAccessibleComponent, xAccessibleStateSet);
+ c = new TextComponent(xAccessible, xAccessibleContext, xAccessibleStateSet);
break;
case AccessibleRole.TEXT_FRAME:
c = new Container(javax.accessibility.AccessibleRole.PANEL,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
case AccessibleRole.TOGGLEBUTTON:
- c = new ToggleButton(xAccessible, xAccessibleComponent);
+ c = new ToggleButton(xAccessible, xAccessibleContext);
break;
case AccessibleRole.TOOLBAR:
c = new Container(javax.accessibility.AccessibleRole.TOOL_BAR,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
+ break;
+ case AccessibleRole.TOOLTIP:
+ c = new ToolTip(xAccessible, xAccessibleContext);
break;
case AccessibleRole.TREE:
- c = new Tree(xAccessible, xAccessibleComponent);
+ c = new Tree(xAccessible, xAccessibleContext);
break;
case AccessibleRole.VIEWPORT:
c = new Container(javax.accessibility.AccessibleRole.VIEWPORT,
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
default:
System.err.println("Unmapped accessible object " + role);
System.err.println("usually mapped to " + AccessibleRoleAdapter.getAccessibleRole(role));
c = new Container(AccessibleRoleAdapter.getAccessibleRole(role),
- xAccessible, xAccessibleComponent);
+ xAccessible, xAccessibleContext);
break;
}
if (c != null) {
@@ -446,7 +417,7 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
return c;
}
- protected void disposing(java.awt.Component c) {
+ protected static void disposing(java.awt.Component c) {
if (c != null) {
synchronized (objectList) {
objectList.remove(c.toString());
@@ -454,10 +425,7 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
}
}
-/*
- protected java.? createTransientObject()
-*/
- public java.awt.Window getTopWindow(XAccessible xAccessible) {
+ public static java.awt.Window getTopWindow(XAccessible xAccessible) {
XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext();
if (xAccessibleContext != null) {
@@ -485,7 +453,7 @@ public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
// return null;
}
populateContainer(w, xAccessibleContext, w);
- w.setFocusTraversalPolicy(this);
+ w.setFocusTraversalPolicy(focusTraversalPolicy);
w.setVisible(true);
// Post window gained focus event to let the frame/dialog become active
if (xAccessibleStateSet.contains(AccessibleStateType.ACTIVE)) {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java
index 46e641ca8749..401d0d90eaec 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleRoleAdapter.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:32 $
+ * last change: $Author: hr $ $Date: 2003-03-18 15:48:17 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,7 +97,7 @@ public abstract class AccessibleRoleAdapter {
javax.accessibility.AccessibleRole.LABEL,
javax.accessibility.AccessibleRole.LAYERED_PANE,
javax.accessibility.AccessibleRole.LIST,
- javax.accessibility.AccessibleRole.LIST_ITEM,
+ javax.accessibility.AccessibleRole.LABEL, // LIST_ITEM - required by Zoomtext
javax.accessibility.AccessibleRole.MENU,
javax.accessibility.AccessibleRole.MENU_BAR,
javax.accessibility.AccessibleRole.MENU_ITEM,
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java
new file mode 100644
index 000000000000..7b98e4c2bda7
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleSelectionImpl.java
@@ -0,0 +1,129 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleSelectionImpl.java,v $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package org.openoffice.java.accessibility;
+
+import drafts.com.sun.star.accessibility.*;
+
+class AccessibleSelectionImpl implements javax.accessibility.AccessibleSelection {
+ XAccessibleSelection unoAccessibleSelection;
+
+ AccessibleSelectionImpl(XAccessibleSelection xAccessibleSelection) {
+ unoAccessibleSelection = xAccessibleSelection;
+ }
+
+ /** Returns an Accessible representing the specified selected child of the object */
+ public javax.accessibility.Accessible getAccessibleSelection(int i) {
+ try {
+ return (javax.accessibility.Accessible) AccessibleObjectFactory.getAccessibleComponent(
+ unoAccessibleSelection.getSelectedAccessibleChild(i));
+ } catch (com.sun.star.uno.Exception e) {
+ return null;
+ }
+ }
+
+ /** Adds the specified Accessible child of the object to the object's selection */
+ public void addAccessibleSelection(int i) {
+ try {
+ unoAccessibleSelection.selectAccessibleChild(i);
+ } catch (com.sun.star.uno.Exception e) {
+ }
+ }
+
+ /** Clears the selection in the object, so that no children in the object are selected */
+ public void clearAccessibleSelection() {
+ try {
+ unoAccessibleSelection.clearAccessibleSelection();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Returns the number of Accessible children currently selected */
+ public int getAccessibleSelectionCount() {
+ try {
+ return unoAccessibleSelection.getSelectedAccessibleChildCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Determines if the current child of this object is selected */
+ public boolean isAccessibleChildSelected(int i) {
+ try {
+ return unoAccessibleSelection.isAccessibleChildSelected(i);
+ } catch (com.sun.star.uno.Exception e) {
+ return false;
+ }
+ }
+
+ /** Removes the specified child of the object from the object's selection */
+ public void removeAccessibleSelection(int i) {
+ try {
+ unoAccessibleSelection.deselectSelectedAccessibleChild(i);
+ } catch (com.sun.star.uno.Exception e) {
+ }
+ }
+
+ /** Causes every child of the object to be selected if the object supports multiple selection */
+ public void selectAllAccessibleSelection() {
+ try {
+ unoAccessibleSelection.selectAllAccessible();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java
index 9d4b9b77215d..4e0afdadbb1b 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java
@@ -2,10 +2,6 @@
*
* $RCSfile: AccessibleTextImpl.java,v $
*
- * $Revision: 1.5 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:07 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -77,6 +73,9 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
final static double toPointFactor = 1 / (7/10 + 34.5);
+ private javax.swing.text.TabSet tabSet = null;
+ private javax.swing.text.TabStop[] tabStops = null;
+
/** Creates new GenericAccessibleEditableText object */
public AccessibleTextImpl(XAccessibleText xAccessibleText) {
unoObject = xAccessibleText;
@@ -94,6 +93,12 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
case AccessibleText.SENTENCE:
type = AccessibleTextType.SENTENCE;
break;
+ case 4:
+ type = AccessibleTextType.LINE;
+ break;
+ case 5:
+ type = AccessibleTextType.ATTRIBUTE_RUN;
+ break;
default:
break;
}
@@ -105,10 +110,16 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
short type = toTextType(part);
if (type > 0) {
try {
- // FIXME: Workaround for a bug in the office that an empty string is returned
- // when asking for the word at the position of a blank
+ // the office returns an empty string when asking for the word at
+ // the position of a blank
String s = unoObject.getTextBehindIndex(index, type);
if ((part == AccessibleText.WORD) && (s.length() == 0)) {
+// int max = getCharCount();
+// for (int i=index; i < max; i++) {
+// if (! unoObject.getTextBehindIndex(i, AccessibleTextType.CHARACTER).equals(" "))
+// break;
+// s += " ";
+// }
s = " ";
}
return s;
@@ -144,13 +155,16 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
}
}
- protected static void setAttribute(javax.swing.text.MutableAttributeSet as, com.sun.star.beans.PropertyValue property) {
+ protected void setAttribute(javax.swing.text.MutableAttributeSet as, com.sun.star.beans.PropertyValue property) {
try {
// Map alignment attribute
if (property.Name.equals("ParaAdjust")) {
- ParagraphAdjust adjust = (ParagraphAdjust)
- AnyConverter.toObject(new Type(ParagraphAdjust.class), property.Value);
- if (adjust == null) {
+ ParagraphAdjust adjust = null;
+ if (property.Value instanceof ParagraphAdjust) {
+ adjust = (ParagraphAdjust) property.Value;
+ } else if (property.Value instanceof Any) {
+ adjust = (ParagraphAdjust) AnyConverter.toObject(new Type(ParagraphAdjust.class), property.Value);
+ } else {
adjust = ParagraphAdjust.fromInt(AnyConverter.toInt(property.Value));
}
if (adjust != null) {
@@ -202,10 +216,15 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
// Set italic attribute
} else if (property.Name.equals("CharPosture")) {
- boolean isItalic = (FontSlant.ITALIC == (FontSlant)
- AnyConverter.toObject(new Type(FontSlant.class), property.Value));
-
- StyleConstants.setItalic(as, isItalic);
+ FontSlant fs = null;
+ if (property.Value instanceof FontSlant) {
+ fs = (FontSlant) property.Value;
+ } else if (property.Value instanceof Any) {
+ fs = (FontSlant) AnyConverter.toObject(new Type(FontSlant.class), property.Value);
+ }
+ if (fs != null) {
+ StyleConstants.setItalic(as, FontSlant.ITALIC.equals(fs));
+ }
// Set left indent attribute
} else if (property.Name.equals("ParaLeftMargin")) {
@@ -218,7 +237,15 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
// Set line spacing attribute
else if (property.Name.equals("ParaLineSpacing")) {
- StyleConstants.setLineSpacing(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
+ LineSpacing ls = null;
+ if (property.Value instanceof LineSpacing) {
+ ls = (LineSpacing) property.Value;
+ } else if (property.Value instanceof Any) {
+ ls = (LineSpacing) AnyConverter.toObject(new Type(LineSpacing.class), property.Value);
+ }
+ if (ls != null) {
+ StyleConstants.setLineSpacing(as, (float) (toPointFactor * ls.Height));
+ }
}
// FIXME: Java 1.4 NameAttribute, Orientation, ResolveAttribute
@@ -279,7 +306,13 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
}
}
- StyleConstants.setTabSet(as, new javax.swing.text.TabSet(tabStops));
+ // Re-use tabSet object if possible to make AttributeSet.equals work
+ if ((this.tabSet == null) || !java.util.Arrays.equals(tabStops, this.tabStops)) {
+ this.tabStops = tabStops;
+ this.tabSet = new javax.swing.text.TabSet(tabStops);
+ }
+
+ StyleConstants.setTabSet(as, this.tabSet);
// Set underline attribute
} else if (property.Name.equals("CharUnderline")) {
@@ -288,25 +321,26 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
}
} catch (com.sun.star.lang.IllegalArgumentException e) {
if (Build.DEBUG) {
- System.err.println(e.getMessage());
+ System.err.println("*** ERROR *** " + e .getClass().getName() + " caught for property " + property.Name + ": " + e.getMessage());
+ System.err.println(" value is of type " + property.Value.getClass().getName());
}
}
}
/** Returns the AttributSet for a given character at a given index */
- public javax.swing.text.AttributeSet getCharacterAttribute(int param) {
+ public javax.swing.text.AttributeSet getCharacterAttribute(int index) {
try {
- com.sun.star.beans.PropertyValue[] propertyValues = unoObject.getCharacterAttributes(param);
+ com.sun.star.beans.PropertyValue[] propertyValues = unoObject.getCharacterAttributes(index);
javax.swing.text.SimpleAttributeSet attributeSet = new javax.swing.text.SimpleAttributeSet();
if (null != propertyValues) {
- for (int index = 0; index < propertyValues.length; index++) {
- setAttribute(attributeSet, propertyValues[index]);
+ for (int i = 0; i < propertyValues.length; i++) {
+ setAttribute(attributeSet, propertyValues[i]);
}
}
return attributeSet;
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
if (Build.DEBUG) {
- System.err.println(e.getMessage());
+ System.err.println(e.getClass().getName() + " caught at index " + index + ": " + e.getMessage());
}
return null;
}
@@ -347,10 +381,16 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
short type = toTextType(part);
if (type > 0) {
try {
- // FIXME: Workaround for a bug in the office that an empty string is returned
- // when asking for the word at the position of a blank
+ // the office returns an empty string when asking for the word at
+ // the position of a blank
String s = unoObject.getTextBeforeIndex(index, type);
if ((part == AccessibleText.WORD) && (s.length() == 0)) {
+// int max = getCharCount();
+// for (int i=index; i < max; i++) {
+// if (! unoObject.getTextBeforeIndex(i, AccessibleTextType.CHARACTER).equals(" "))
+// break;
+// s += " ";
+// }
s = " ";
}
return s;
@@ -366,17 +406,41 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
short type = toTextType(part);
if (type > 0) {
try {
-// if (Build.DEBUG) {
-// System.err.println(this + "getAtIndex(" + part + "," + index + ") returns " + unoObject.getTextAtIndex(index, type));
-// }
- // FIXME: Workaround for a bug in the office that an empty string is returned
- // when asking for the word at the position of a blank
+ // the office returns an empty string when asking for the word at
+ // the position of a blank
String s = unoObject.getTextAtIndex(index, type);
if ((part == AccessibleText.WORD) && (s.length() == 0)) {
+// int max = getCharCount();
+// for (int i=index; i < max; i++) {
+// if (! unoObject.getTextAtIndex(i, AccessibleTextType.CHARACTER).equals(" "))
+// break;
+// s += " ";
+// }
s = " ";
+
+ // Workaround for #104847#
+ } else if ((type == AccessibleTextType.LINE) && (s.length() == 0)) {
+ if (index == getCharCount()) {
+ s = unoObject.getTextAtIndex(index - 1, type);
+ }
+ }
+
+ if (Build.DEBUG && (type == AccessibleTextType.LINE)) {
+ System.err.println(this + " getAtIndex(" + part + "," + index + ") returns " + s + " (length: " + s.length() + ")");
}
return s;
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ if (Build.DEBUG) {
+ System.err.println(e.getClass().getName() + " caught for " + this + " getAtIndex(" + part + "," + index + ")");
+ }
+ // Workaround for #104847#
+ if (type == AccessibleTextType.LINE) {
+
+ try {
+ return unoObject.getTextAtIndex(index - 1, type);
+ } catch (com.sun.star.uno.Exception e2) {
+ }
+ }
} catch (com.sun.star.uno.RuntimeException e) {
}
}
@@ -409,7 +473,7 @@ public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
} catch (com.sun.star.uno.RuntimeException e) {
}
- return null;
+ return new java.awt.Rectangle();
}
public String toString() {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Button.java b/accessibility/bridge/org/openoffice/java/accessibility/Button.java
index a5cc63a3faf2..c780ac63ff19 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Button.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Button.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Button.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:34 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,28 +57,17 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
-
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
-class Button extends AbstractButton implements Accessible {
-
- public Button(XAccessible accessible, XAccessibleComponent component) {
- super();
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleButtonListener());
- }
+class Button extends AbstractButton implements javax.accessibility.Accessible {
- protected class AccessibleButtonListener extends AccessibleAbstractButtonListener {
+ public Button(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleButton();
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java b/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java
index bfc4fa521f00..0233cb941c4f 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java
@@ -2,10 +2,6 @@
*
* $RCSfile: CheckBox.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:34 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,20 +57,17 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
-
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
class CheckBox extends ToggleButton {
- public CheckBox(XAccessible accessible, XAccessibleComponent component) {
- super(accessible, component);
+ public CheckBox(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleCheckBox();
}
@@ -82,7 +75,6 @@ class CheckBox extends ToggleButton {
}
protected class AccessibleCheckBox extends AccessibleToggleButton {
-
/** Gets the role of this object */
public javax.accessibility.AccessibleRole getAccessibleRole() {
return javax.accessibility.AccessibleRole.CHECK_BOX;
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java b/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java
index 9f3ad9cac350..067ef16be7fb 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java
@@ -2,10 +2,6 @@
*
* $RCSfile: ComboBox.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:34 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -66,104 +62,38 @@ import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
import javax.swing.SwingConstants;
-import com.sun.star.uno.UnoRuntime;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleAction;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
/**
*/
-public class ComboBox extends Component implements javax.accessibility.Accessible {
+public class ComboBox extends Container {
private XAccessibleAction unoAccessibleAction = null;
- private boolean editable = false;
-
- public ComboBox(XAccessible accessible, XAccessibleComponent component, XAccessibleAction action) {
- super();
- initialize(accessible, component, action);
- }
- private AccessibleContext accessibleTextContext = null;
- private AccessibleContext accessiblePopupMenuContext = null;
-
- protected void initialize(XAccessible accessible, XAccessibleComponent component,
- XAccessibleAction action) {
- unoAccessibleAction = action;
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleComboBoxListener());
-// accessiblePopupMenuContext = new AccessiblePopupMenu();
+ public ComboBox(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(javax.accessibility.AccessibleRole.COMBO_BOX, xAccessible, xAccessibleContext);
}
- protected class AccessiblePopupMenu extends AccessibleContext implements javax.accessibility.Accessible {
-
- /** Gets the accessible context associated with this object */
- public javax.accessibility.AccessibleContext getAccessibleContext() {
- return this;
- }
-
- /*
- * AccessibleContext
- */
-
- /** Gets the role of this object */
- public javax.accessibility.AccessibleRole getAccessibleRole() {
- return javax.accessibility.AccessibleRole.POPUP_MENU;
- }
-
- /**
- * Get the state set of this object.
- *
- * @return an instance of AccessibleState containing the current state
- * of the object
- * @see AccessibleState
- */
- public AccessibleStateSet getAccessibleStateSet() {
- AccessibleStateSet states = new AccessibleStateSet();
- states.add(AccessibleState.ENABLED);
- return states;
- }
-
- /** Gets the locale of the component */
- public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException {
- return ComboBox.this.getLocale();
- }
-
- /** Returns the number of accessible children of the object. */
- public int getAccessibleChildrenCount() {
- return 0;
- }
-
- /** Returns the specified Accessible child of the object. */
- public javax.accessibility.Accessible getAccessibleChild(int i) {
- return null;
+ /** Appends the specified component to the end of this container */
+ public java.awt.Component add(java.awt.Component c) {
+ // List should be always the first child
+ if (c instanceof List) {
+ return super.add(c, 0);
+ } else {
+ return super.add(c);
}
-
- /** Gets the 0-based index of this object in its accessible parent */
- public int getAccessibleIndexInParent() {
- return 0;
- }
-
- /** Gets the accessible parent of this object */
- public javax.accessibility.Accessible getAccessibleParent() {
- return ComboBox.this;
- }
- }
-
- protected class AccessibleComboBoxListener extends AccessibleUNOComponentListener {
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleComboBox();
}
return accessibleContext;
}
- protected class AccessibleComboBox extends AccessibleUNOComponent
+ protected class AccessibleComboBox extends AccessibleContainer
implements javax.accessibility.AccessibleAction {
/**
@@ -173,48 +103,44 @@ public class ComboBox extends Component implements javax.accessibility.Accessibl
super();
}
- /** Gets the role of this object */
- public javax.accessibility.AccessibleRole getAccessibleRole() {
- return javax.accessibility.AccessibleRole.COMBO_BOX;
- }
-
- /** Returns the number of accessible children of the object */
- public int getAccessibleChildrenCount() {
- return editable ? 2 : 1;
- }
-
- /** Returns the specified Accessible child of the object */
- public javax.accessibility.Accessible getAccessibleChild(int i) {
- switch (i) {
- case 0:
- return (javax.accessibility.Accessible) accessiblePopupMenuContext;
- case 1:
- if (editable) {
- return (javax.accessibility.Accessible) accessibleTextContext;
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
+
+ try {
+ if (unoAS != null) {
+ if (unoAS.contains(AccessibleStateType.EXPANDABLE)) {
+ states.add(AccessibleState.EXPANDABLE);
+ }
+ if (unoAS.contains(AccessibleStateType.EXPANDED)) {
+ states.add(AccessibleState.EXPANDED);
+ }
+ if (unoAS.contains(AccessibleStateType.COLLAPSED)) {
+ states.add(AccessibleState.COLLAPSED);
+ }
}
- default:
- return null;
+ } catch (com.sun.star.uno.RuntimeException e) {
}
+
+ return states;
}
+ /*
+ * AccessibleContext
+ */
+
/** Gets the AccessibleAction associated with this object that supports one or more actions */
public javax.accessibility.AccessibleAction getAccessibleAction() {
+ if (unoAccessibleAction == null) {
+ unoAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext);
+ if (unoAccessibleAction == null) {
+ return null;
+ }
+ }
return this;
}
- /**
- * Get the state set of this object.
- *
- * @return an instance of AccessibleState containing the current state
- * of the object
- * @see AccessibleState
- */
-/*
- public AccessibleStateSet getAccessibleStateSet() {
- AccessibleStateSet states = super.getAccessibleStateSet();
- return states;
- }
-*/
/*
* AccessibleAction
*/
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Component.java b/accessibility/bridge/org/openoffice/java/accessibility/Component.java
index 6ce0aa8ebd8e..bac196f4b73c 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Component.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Component.java
@@ -2,9 +2,9 @@
*
* $RCSfile: Component.java,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:07 $
+ * last change: $Author: hr $ $Date: 2003-03-18 15:48:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -65,29 +65,32 @@ import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import com.sun.star.uno.*;
-import drafts.com.sun.star.accessibility.AccessibleEventId;
-import drafts.com.sun.star.accessibility.AccessibleEventObject;
-import drafts.com.sun.star.accessibility.AccessibleStateType;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleContext;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
-import drafts.com.sun.star.accessibility.XAccessibleEventListener;
-import drafts.com.sun.star.accessibility.XAccessibleEventBroadcaster;
+import drafts.com.sun.star.accessibility.*;
public abstract class Component extends java.awt.Component {
- final static String monitorClassName =
- "com.sun.java.accessibility.util.AccessibilityEventMonitor$AccessibilityEventListener";
-
public static final Type RectangleType = new Type(com.sun.star.awt.Rectangle.class);
+ public static final Type SelectionType = new Type(com.sun.star.awt.Selection.class);
- protected XAccessible unoAccessible = null;
- protected XAccessibleComponent unoAccessibleComponent = null;
+ protected XAccessible unoAccessible;
+ protected XAccessibleContext unoAccessibleContext;
+ protected XAccessibleComponent unoAccessibleComponent;
protected boolean disposed = false;
- protected Component() {
+ protected Component(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
super();
-// enableEvents(java.awt.AWTEvent.FOCUS_EVENT_MASK);
+ unoAccessible = xAccessible;
+ unoAccessibleContext = xAccessibleContext;
+ unoAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class, xAccessibleContext);
+ // Add the event listener right away, because the global focus notification doesn't
+ // work yet ..
+ XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
+ UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class,
+ unoAccessibleComponent);
+ if (broadcaster != null) {
+ broadcaster.addEventListener(createEventListener());
+ }
}
/**
@@ -154,10 +157,9 @@ public abstract class Component extends java.awt.Component {
public Object[] getAccessibleComponents(Object[] targetSet) {
try {
- AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
java.util.ArrayList list = new java.util.ArrayList(targetSet.length);
for (int i=0; i < targetSet.length; i++) {
- java.awt.Component c = factory.getAccessibleComponent(
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
(XAccessible) UnoRuntime.queryInterface(XAccessible.class, targetSet[i]));
if (c != null) {
list.add(c);
@@ -170,15 +172,6 @@ public abstract class Component extends java.awt.Component {
}
}
- protected void addAccessibleEventListener(XAccessibleEventListener listener) {
- XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
- UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class,
- unoAccessibleComponent);
- if (broadcaster != null) {
- broadcaster.addEventListener(listener);
- }
- }
-
protected java.awt.EventQueue getEventQueue() {
return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
}
@@ -201,11 +194,6 @@ public abstract class Component extends java.awt.Component {
AccessibleContext ac = accessibleContext;
if (ac != null) {
ac.firePropertyChange(propertyName, oldValue, newValue);
- } else if (Build.DEBUG) {
- XAccessibleContext xac = unoAccessible.getAccessibleContext();
- System.err.println("Ignoring event: " + propertyName + " for " +
- AccessibleRoleAdapter.getAccessibleRole(xac.getAccessibleRole()) +
- " " + xac.getAccessibleName());
}
} catch (java.lang.Exception e) {
if (Build.DEBUG) {
@@ -237,7 +225,7 @@ public abstract class Component extends java.awt.Component {
/**
* Update the proxy objects appropriatly on property change events
*/
- protected abstract class AccessibleUNOComponentListener implements XAccessibleEventListener {
+ protected class AccessibleUNOComponentListener implements XAccessibleEventListener {
protected AccessibleUNOComponentListener() {
}
@@ -247,6 +235,12 @@ public abstract class Component extends java.awt.Component {
case AccessibleStateType.ACTIVE:
// Only frames should be active
break;
+ case AccessibleStateType.ARMED:
+ fireStatePropertyChange(AccessibleState.ARMED, enable);
+ break;
+ case AccessibleStateType.CHECKED:
+ fireStatePropertyChange(AccessibleState.CHECKED, enable);
+ break;
case AccessibleStateType.ENABLED:
setEnabled(enable);
break;
@@ -256,6 +250,9 @@ public abstract class Component extends java.awt.Component {
java.awt.event.FocusEvent.FOCUS_GAINED :
java.awt.event.FocusEvent.FOCUS_LOST));
break;
+ case AccessibleStateType.PRESSED:
+ fireStatePropertyChange(AccessibleState.PRESSED, enable);
+ break;
case AccessibleStateType.SELECTED:
fireStatePropertyChange(AccessibleState.SELECTED, enable);
break;
@@ -313,9 +310,49 @@ public abstract class Component extends java.awt.Component {
}
}
+ /** Fires the appropriate PropertyChangeEvent */
+ protected void handleTextChangedEvent(Object any1, Object any2) {
+ Object[] values = new Object[2];
+ try {
+ if (AnyConverter.isObject(any1)) {
+ com.sun.star.awt.Selection s = (com.sun.star.awt.Selection)
+ AnyConverter.toObject(SelectionType, any1);
+ if (s != null) {
+ // Since there is nothing like a "range" object in the JAA yet,
+ // the Integer[2] is a private negotiation with the JABG
+ Integer[] deleted = { new Integer(s.Min), new Integer(s.Max) };
+ values[0] = deleted;
+ if (Build.DEBUG) {
+ System.err.println("text range (" + s.Min + "," + s.Max + ") deleted");
+ }
+ }
+ }
+
+ if (AnyConverter.isObject(any2)) {
+ com.sun.star.awt.Selection s = (com.sun.star.awt.Selection)
+ AnyConverter.toObject(SelectionType, any2);
+ if (s != null) {
+ // Since there is nothing like a "range" object in the JAA yet,
+ // the Integer[2] is a private negotiation with the JABG
+ Integer[] inserted = { new Integer(s.Min), new Integer(s.Max) };
+ values[1] = inserted;
+ if (Build.DEBUG) {
+ System.err.println("text range (" + s.Min + "," + s.Max + ") inserted");
+ }
+ }
+ }
+ firePropertyChange(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY, values[0], values[1]);
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
/** Called by OpenOffice process to notify property changes */
public void notifyEvent(AccessibleEventObject event) {
switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_ACTION_EVENT:
+ firePropertyChange(accessibleContext.ACCESSIBLE_ACTION_PROPERTY,
+ toNumber(event.OldValue), toNumber(event.NewValue));
+ break;
case AccessibleEventId.ACCESSIBLE_NAME_EVENT:
// Set the accessible name for the corresponding context, which will fire a property
// change event itself
@@ -326,6 +363,11 @@ public abstract class Component extends java.awt.Component {
// change event itself - so do not set propertyName !
handleDescriptionChangedEvent(event.NewValue);
break;
+ case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
+ if(Build.DEBUG) {
+ System.out.println("Unexpected child event for object of role " + getAccessibleContext().getAccessibleRole());
+ }
+ break;
case AccessibleEventId.ACCESSIBLE_STATE_EVENT:
// Update the internal state set and fire the appropriate PropertyChangedEvent
handleStateChangedEvent(event.OldValue, event.NewValue);
@@ -335,9 +377,13 @@ public abstract class Component extends java.awt.Component {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null);
break;
case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
- // FIXME: enhance text information ..
- firePropertyChange(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY, null, new Integer(0));
+ handleTextChangedEvent(event.OldValue, event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_CARET_EVENT:
+ firePropertyChange(accessibleContext.ACCESSIBLE_CARET_PROPERTY, toNumber(event.OldValue), toNumber(event.NewValue));
break;
+ case AccessibleEventId.ACCESSIBLE_VALUE_EVENT:
+ firePropertyChange(accessibleContext.ACCESSIBLE_VALUE_PROPERTY, toNumber(event.OldValue), toNumber(event.NewValue));
default:
// Warn about unhandled events
if(Build.DEBUG) {
@@ -349,13 +395,18 @@ public abstract class Component extends java.awt.Component {
/** Called by OpenOffice process to notify that the UNO component is disposing */
public void disposing(com.sun.star.lang.EventObject eventObject) {
disposed = true;
- AccessibleObjectFactory.getDefault().disposing(Component.this);
+ AccessibleObjectFactory.disposing(Component.this);
}
}
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleUNOComponentListener();
+ }
+
protected AccessibleContext accessibleContext = null;
- protected abstract class AccessibleUNOComponent extends java.awt.Component.AccessibleAWTComponent {
+ protected abstract class AccessibleUNOComponent extends java.awt.Component.AccessibleAWTComponent
+ implements javax.accessibility.AccessibleExtendedComponent {
/**
* Though the class is abstract, this should be called by all sub-classes
@@ -375,6 +426,62 @@ public abstract class Component extends java.awt.Component {
}
}
+ /** Check if the parent of an selectable object supports AccessibleSelection */
+ protected void dbgCheckSelectable() {
+ javax.accessibility.Accessible parent = getAccessibleParent();
+ if (parent != null) {
+ javax.accessibility.AccessibleContext parentAC = parent.getAccessibleContext();
+ if (parentAC != null) {
+ if (parentAC.getAccessibleSelection() == null) {
+ System.err.println("*** ERROR *** Object claims to be selectable, but parent does not support AccessibleSelection");
+ }
+ } else {
+ System.err.println("*** ERROR *** Object claims to be selectable, but parent is not accessible");
+ }
+ } else {
+ System.err.println("*** ERROR *** Object claims to be selectable, but has no accessible parent");
+ }
+ }
+
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = new javax.accessibility.AccessibleStateSet();
+
+ if (Component.this.isEnabled()) {
+ states.add(AccessibleState.ENABLED);
+ }
+ if (Component.this.isFocusTraversable()) {
+ states.add(AccessibleState.FOCUSABLE);
+ }
+ if (Component.this.isVisible()) {
+ states.add(AccessibleState.VISIBLE);
+ }
+ if (Component.this.isShowing()) {
+ states.add(AccessibleState.SHOWING);
+ }
+ if (Component.this.isFocusOwner()) {
+ states.add(AccessibleState.FOCUSED);
+ }
+
+ try {
+ if (unoAS != null) {
+ if (unoAS.contains(AccessibleStateType.SELECTABLE)) {
+ states.add(AccessibleState.SELECTABLE);
+
+ if (Build.DEBUG) {
+ dbgCheckSelectable();
+ }
+ }
+ if (unoAS.contains(AccessibleStateType.SELECTED)) {
+ states.add(AccessibleState.SELECTED);
+ }
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+
+ return states;
+ }
+
protected java.awt.event.ComponentListener accessibleComponentHandler = null;
/**
@@ -469,51 +576,32 @@ public abstract class Component extends java.awt.Component {
* containing the current state set of the object
* @see AccessibleState
*/
- public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
- javax.accessibility.AccessibleStateSet states = new javax.accessibility.AccessibleStateSet();
- if (Component.this.isEnabled()) {
- states.add(AccessibleState.ENABLED);
- }
- if (Component.this.isFocusTraversable()) {
- states.add(AccessibleState.FOCUSABLE);
- }
- if (Component.this.isVisible()) {
- states.add(AccessibleState.VISIBLE);
- }
- if (Component.this.isShowing()) {
- states.add(AccessibleState.SHOWING);
- }
- if (Component.this.isFocusOwner()) {
- states.add(AccessibleState.FOCUSED);
+ public final javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ try {
+ XAccessibleStateSet unoASS = null;
+ if ( !disposed ) {
+ unoASS = unoAccessibleContext.getAccessibleStateSet();
+ }
+ return getAccessibleStateSetImpl(unoASS);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return getAccessibleStateSetImpl(null);
}
+ }
- /**
- * Never hold the tree lock when calling back into the office !!
- * This may cause deadlocks when new native frames are registered
- * with the Solar-Mutex acquired ..
- */
-
- javax.accessibility.Accessible ap = getAccessibleParent();
- if (ap != null) {
- javax.accessibility.AccessibleContext pac = ap.getAccessibleContext();
- if (pac != null) {
- javax.accessibility.AccessibleSelection as = pac.getAccessibleSelection();
- if (as != null) {
- states.add(AccessibleState.SELECTABLE);
- int i = getAccessibleIndexInParent();
- if (i >= 0) {
- if (as.isAccessibleChildSelected(i)) {
- states.add(AccessibleState.SELECTED);
- }
- }
- }
- }
+ /** Gets the locale of the component */
+ public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException {
+ try {
+ com.sun.star.lang.Locale unoLocale = unoAccessible.getAccessibleContext().getLocale();
+ return new java.util.Locale(unoLocale.Language, unoLocale.Country);
+ } catch (IllegalAccessibleComponentStateException e) {
+ throw new java.awt.IllegalComponentStateException(e.getMessage());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return java.util.Locale.getDefault();
}
- return states;
}
/*
- * AccessibleComponent
+ * AccessibleExtendedComponent
*/
/** Returns the background color of the object */
@@ -660,6 +748,50 @@ public abstract class Component extends java.awt.Component {
public void requestFocus() {
unoAccessibleComponent.grabFocus();
}
+
+ public String getToolTipText() {
+ try {
+ XAccessibleExtendedComponent unoAccessibleExtendedComponent = (XAccessibleExtendedComponent)
+ UnoRuntime.queryInterface(XAccessibleExtendedComponent.class, unoAccessibleComponent);
+ if (unoAccessibleExtendedComponent != null) {
+ return unoAccessibleExtendedComponent.getToolTipText();
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ return null;
+ }
+
+ public String getTitledBorderText() {
+ try {
+ XAccessibleExtendedComponent unoAccessibleExtendedComponent = (XAccessibleExtendedComponent)
+ UnoRuntime.queryInterface(XAccessibleExtendedComponent.class, unoAccessibleComponent);
+ if (unoAccessibleExtendedComponent != null) {
+ return unoAccessibleExtendedComponent.getTitledBorderText();
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ return null;
+ }
+
+ public javax.accessibility.AccessibleKeyBinding getAccessibleKeyBinding() {
+ try {
+ XAccessibleAction unoAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleComponent);
+ if (unoAccessibleAction != null) {
+ XAccessibleKeyBinding unoAccessibleKeyBinding = unoAccessibleAction.getAccessibleKeyBinding(0);
+ if (unoAccessibleKeyBinding != null) {
+ return new AccessibleKeyBinding(unoAccessibleKeyBinding);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ return null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ return null;
+ }
}
// Extract a number from a UNO any
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Container.java b/accessibility/bridge/org/openoffice/java/accessibility/Container.java
index d267f46d7b65..da99a5ccb047 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Container.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Container.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Container.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:35 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -66,41 +62,339 @@ import javax.accessibility.AccessibleRole;
import javax.accessibility.AccessibleState;
import com.sun.star.uno.*;
-import drafts.com.sun.star.accessibility.AccessibleEventId;
-import drafts.com.sun.star.accessibility.AccessibleEventObject;
-import drafts.com.sun.star.accessibility.AccessibleStateType;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
-import drafts.com.sun.star.accessibility.XAccessibleEventListener;
-import drafts.com.sun.star.accessibility.XAccessibleEventBroadcaster;
+import drafts.com.sun.star.accessibility.*;
+
+public class Container extends java.awt.Container implements javax.accessibility.Accessible {
-public class Container extends AbstractContainer implements javax.accessibility.Accessible {
+ // This type is needed for conversions from/to uno Any
+ public static final Type XAccessibleType = new Type(XAccessible.class);
+
+ protected XAccessible unoAccessible;
+ protected XAccessibleContext unoAccessibleContext;
+ protected XAccessibleComponent unoAccessibleComponent = null;
protected AccessibleRole accessibleRole;
+ protected boolean disposed = false;
- protected Container(AccessibleRole role, XAccessible accessible, XAccessibleComponent component) {
- super();
+ protected Container(AccessibleRole role, XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
accessibleRole = role;
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
+
+ unoAccessible = xAccessible;
+ unoAccessibleContext = xAccessibleContext;
+ unoAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class, xAccessibleContext);
+
+ // Add the event listener right away, because the global focus notification doesn't
+ // work yet ..
XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
- UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, component);
+ UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class,
+ unoAccessibleContext);
if (broadcaster != null) {
- broadcaster.addEventListener(new AccessibleContainerListener());
+ broadcaster.addEventListener(createEventListener());
+ }
+ }
+
+ /**
+ * Determines whether this <code>Container</code> is showing on screen.
+ * This means that the component must be visible, and it must be in a
+ * <code>container</code> that is visible and showing.
+ * @see #addNotify
+ * @see #removeNotify
+ * @since JDK1.0
+ */
+ public boolean isShowing() {
+ if (isVisible()) {
+ java.awt.Container parent = getParent();
+ return (parent == null) || parent.isShowing();
}
+ return false;
+ }
+
+ /**
+ * Makes this <code>Container</code> displayable by connecting it to a
+ * native screen resource.
+ * This method is called internally by the toolkit and should
+ * not be called directly by programs.
+ * @see #isDisplayable
+ * @see #removeNotify
+ * @since JDK1.0
+ */
+ public void addNotify() {
+ }
+
+ /**
+ * Makes this <code>Container</code> undisplayable by destroying it native
+ * screen resource.
+ * This method is called by the toolkit internally and should
+ * not be called directly by programs.
+ * @see #isDisplayable
+ * @see #addNotify
+ * @since JDK1.0
+ */
+ public void removeNotify() {
+ }
+
+ protected java.awt.EventQueue getEventQueue() {
+ return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
+ }
+
+ protected class PropertyChangeBroadcaster implements Runnable {
+ String propertyName;
+ Object oldValue;
+ Object newValue;
+
+ public PropertyChangeBroadcaster(String name, Object param1, Object param2) {
+ propertyName = name;
+ oldValue = param1;
+ newValue = param2;
+ }
+
+ public void run() {
+ // Because this code is executed in the DispatchThread, it is better tocatch every
+ // exception that might occur
+ try {
+ AccessibleContext ac = Container.this.accessibleContext;
+ if (ac != null) {
+ ac.firePropertyChange(propertyName, oldValue, newValue);
+ }
+ } catch (java.lang.Exception e) {
+ if (Build.DEBUG) {
+ System.err.println(e.getClass().getName() + " caught propagating " + propertyName + " event: " + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ protected void firePropertyChange(String property, Object oldValue, Object newValue) {
+ getEventQueue().invokeLater(new PropertyChangeBroadcaster(property, oldValue, newValue));
+ }
+
+ protected void fireStatePropertyChange(AccessibleState state, boolean set) {
+ PropertyChangeBroadcaster broadcaster;
+ if (set) {
+ broadcaster = new PropertyChangeBroadcaster(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, state);
+ } else {
+ broadcaster = new PropertyChangeBroadcaster(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ state, null);
+ }
+ getEventQueue().invokeLater(broadcaster);
}
/**
* Update the proxy objects appropriatly on property change events
*/
- protected class AccessibleContainerListener extends AccessibleAbstractContainerListener {
+ protected class AccessibleContainerListener implements XAccessibleEventListener {
+
protected AccessibleContainerListener() {
- super();
+ }
+
+ protected java.awt.EventQueue getEventQueue() {
+ return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
+ }
+
+ protected void setComponentState(short state, boolean enable) {
+ switch (state) {
+ case AccessibleStateType.ACTIVE:
+ // Only frames should be active
+ break;
+ case AccessibleStateType.ENABLED:
+ setEnabled(enable);
+ break;
+ case AccessibleStateType.FOCUSED:
+ getEventQueue().postEvent(new java.awt.event.FocusEvent(
+ Container.this, enable ?
+ java.awt.event.FocusEvent.FOCUS_GAINED :
+ java.awt.event.FocusEvent.FOCUS_LOST));
+ break;
+ case AccessibleStateType.SELECTED:
+ fireStatePropertyChange(AccessibleState.SELECTED, enable);
+ break;
+ case AccessibleStateType.SHOWING:
+ case AccessibleStateType.VISIBLE:
+ setVisible(enable);
+ break;
+ default:
+ if (Build.DEBUG) {
+ System.err.println(Container.this + "unexpected state change " + state);
+ }
+ break;
+ }
+ }
+ /** Updates the accessible name and fires the appropriate PropertyChangedEvent */
+ protected void handleNameChangedEvent(Object any) {
+ try {
+ // This causes the property change event to be fired in the VCL thread
+ // context. If this causes problems, it has to be deligated to the java
+ // dispatch thread ..
+ if (accessibleContext != null) {
+ accessibleContext.setAccessibleName(AnyConverter.toString(any));
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ /** Updates the accessible description and fires the appropriate PropertyChangedEvent */
+ protected void handleDescriptionChangedEvent(Object any) {
+ try {
+ // This causes the property change event to be fired in the VCL thread
+ // context. If this causes problems, it has to be deligated to the java
+ // dispatch thread ..
+ if (accessibleContext != null) {
+ accessibleContext.setAccessibleDescription(AnyConverter.toString(any));
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ /** Updates the internal states and fires the appropriate PropertyChangedEvent */
+ protected void handleStateChangedEvent(Object any1, Object any2) {
+ try {
+ if (AnyConverter.isShort(any1)) {
+ setComponentState(AnyConverter.toShort(any1), false);
+ }
+
+ if (AnyConverter.isShort(any2)) {
+ setComponentState(AnyConverter.toShort(any2), true);
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ /** Updates the internal child list and fires the appropriate PropertyChangeEvent */
+ protected void handleChildRemovedEvent(Object any) {
+ try {
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
+ (XAccessible) AnyConverter.toObject(XAccessibleType, any));
+ if (c != null) {
+ if (c instanceof java.awt.Container) {
+ AccessibleObjectFactory.clearContainer((java.awt.Container) c);
+ }
+ remove(c);
+ }
+ } catch (com.sun.star.uno.Exception e) {
+ // FIXME: output
+ }
+ }
+
+ /** Updates the internal child list and fires the appropriate PropertyChangeEvent */
+ protected void handleChildAddedEvent(Object any) {
+ try {
+ XAccessible xAccessible = (XAccessible) AnyConverter.toObject(XAccessibleType, any);
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(xAccessible);
+ if (c != null) {
+ // Seems to be already in child list
+ if (this.equals(c.getParent()))
+ return;
+ } else {
+ c = AccessibleObjectFactory.createAccessibleComponent(xAccessible);
+ }
+ if (c != null) {
+
+ XAccessibleContext xChild = xAccessible.getAccessibleContext();
+ int i = xChild.getAccessibleIndexInParent();
+ if (Build.DEBUG && (i < 0)) {
+ System.err.println("*** ERROR *** Invalid index in parent " + i);
+ System.err.println(" Child is: [" + c.getAccessibleContext().getAccessibleRole() + "] " + xChild.getAccessibleName());
+ System.err.println(" Parent is: [" + Container.this.getAccessibleContext().getAccessibleRole() + "] " + Container.this.getAccessibleContext().getAccessibleName());
+ }
+ if ((i >= 0) && (i <= getComponentCount())) {
+ add(c, i);
+ } else {
+ add(c);
+ }
+ }
+ } catch (java.lang.IllegalArgumentException e) {
+ System.err.println(e.getClass().getName() + " caught: " + e.getMessage());
+ } catch (com.sun.star.uno.Exception e) {
+ // FIXME: output
+ }
+ }
+
+ /* This event is only necessary because some objects in the office don't know their parent
+ * and are therefor unable to revoke and re-insert themselves.
+ */
+ protected void handleAllChildrenChangedEvent() {
+ javax.accessibility.Accessible parent = (javax.accessibility.Accessible) getParent();
+ if (parent != null) {
+ javax.accessibility.AccessibleContext parentAC = parent.getAccessibleContext();
+ if (parentAC != null) {
+
+ parentAC.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ Container.this,
+ null);
+
+ AccessibleObjectFactory.clearContainer(Container.this);
+ AccessibleObjectFactory.populateContainer(Container.this, unoAccessibleContext);
+
+ parentAC.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ null,
+ Container.this);
+ }
+ }
+ }
+
+ /** Called by OpenOffice process to notify property changes */
+ public void notifyEvent(AccessibleEventObject event) {
+ switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_NAME_EVENT:
+ // Set the accessible name for the corresponding context, which will fire a property
+ // change event itself
+ handleNameChangedEvent(event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_DESCRIPTION_EVENT:
+ // Set the accessible description for the corresponding context, which will fire a property
+ // change event itself - so do not set propertyName !
+ handleDescriptionChangedEvent(event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_STATE_EVENT:
+ // Update the internal state set and fire the appropriate PropertyChangedEvent
+ handleStateChangedEvent(event.OldValue, event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
+ if (AnyConverter.isObject(event.OldValue)) {
+ handleChildRemovedEvent(event.OldValue);
+ } else if (AnyConverter.isObject(event.NewValue)) {
+ handleChildAddedEvent(event.NewValue);
+ }
+ break;
+ case AccessibleEventId.ACCESSIBLE_VISIBLE_DATA_EVENT:
+ case AccessibleEventId.ACCESSIBLE_BOUNDRECT_EVENT:
+ firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null);
+ break;
+ case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null);
+ break;
+ case AccessibleEventId.ACCESSIBLE_ALL_CHILDREN_CHANGED_EVENT:
+ handleAllChildrenChangedEvent();
+ break;
+
+ default:
+ // Warn about unhandled events
+ if(Build.DEBUG) {
+ System.out.println(this + ": unhandled accessibility event id=" + event.EventId);
+ }
+ }
+ }
+
+ /** Called by OpenOffice process to notify that the UNO component is disposing */
+ public void disposing(com.sun.star.lang.EventObject eventObject) {
+ disposed = true;
+ AccessibleObjectFactory.disposing(Container.this);
}
}
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleContainerListener();
+ }
+
+ protected javax.accessibility.AccessibleContext accessibleContext = null;
+
/** Returns the AccessibleContext associated with this object */
public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
@@ -109,18 +403,421 @@ public class Container extends AbstractContainer implements javax.accessibility.
return accessibleContext;
}
- protected class AccessibleContainer extends AccessibleAbstractContainer {
+ protected class AccessibleContainer extends java.awt.Container.AccessibleAWTContainer {
+
/**
* Though the class is abstract, this should be called by all sub-classes
*/
protected AccessibleContainer() {
super();
+ // Set accessible name and description here to avoid unnecessary property change
+ // events later ..
+ XAccessibleContext unoAccessibleContext = unoAccessible.getAccessibleContext();
+ String s = unoAccessibleContext.getAccessibleName();
+ if (s != null && s.length() > 0) {
+ setAccessibleName(s);
+ }
+ s = unoAccessibleContext.getAccessibleDescription();
+ if (s != null && s.length() > 0) {
+ setAccessibleDescription(s);
+ }
+/*
+ try {
+ XAccessibleContext unoAccessibleContext = (XAccessibleContext)
+ UnoRuntime.queryInterface(XAccessibleContext.class, unoAccessibleComponent);
+
+ if (unoAccessibleContext!= null) {
+ String s = unoAccessibleContext.getAccessibleName();
+ if (s != null && s.length() > 0) {
+ setAccessibleName(s);
+ }
+ s = unoAccessibleContext.getAccessibleDescription();
+ if (s != null && s.length() > 0) {
+ setAccessibleDescription(s);
+ }
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ System.err.println("RuntimeException caught");
+ }
+*/
+ }
+
+ /** Check if the parent of an selectable object supports AccessibleSelection */
+ protected void dbgCheckSelectable() {
+ javax.accessibility.Accessible parent = getAccessibleParent();
+ if (parent != null) {
+ javax.accessibility.AccessibleContext parentAC = parent.getAccessibleContext();
+ if (parentAC != null) {
+ if (parentAC.getAccessibleSelection() == null) {
+ System.err.println("*** ERROR *** Object claims to be selectable, but parent does not support AccessibleSelection");
+ }
+ } else {
+ System.err.println("*** ERROR *** Object claims to be selectable, but parent is not accessible");
+ }
+ } else {
+ System.err.println("*** ERROR *** Object claims to be selectable, but has no accessible parent");
+ }
+ }
+
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = new javax.accessibility.AccessibleStateSet();
+ if (Container.this.isEnabled()) {
+ states.add(AccessibleState.ENABLED);
+ }
+ if (Container.this.isFocusTraversable()) {
+ states.add(AccessibleState.FOCUSABLE);
+ }
+ if (Container.this.isVisible()) {
+ states.add(AccessibleState.VISIBLE);
+ }
+ if (Container.this.isShowing()) {
+ states.add(AccessibleState.SHOWING);
+ }
+ if (Container.this.isFocusOwner()) {
+ states.add(AccessibleState.FOCUSED);
+ }
+
+ try {
+ if (unoAS != null) {
+ if (unoAS.contains(AccessibleStateType.SELECTABLE)) {
+ states.add(AccessibleState.SELECTABLE);
+ }
+ if (unoAS.contains(AccessibleStateType.SELECTED)) {
+ states.add(AccessibleState.SELECTED);
+
+ if (Build.DEBUG) {
+ dbgCheckSelectable();
+ }
+ }
+ if (unoAS.contains(AccessibleStateType.MULTISELECTABLE)) {
+ states.add(AccessibleState.MULTISELECTABLE);
+ }
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+
+ return states;
+ }
+
+ protected java.awt.event.ComponentListener accessibleComponentHandler = null;
+
+ /**
+ * Fire PropertyChange listener, if one is registered,
+ * when shown/hidden..
+ */
+ protected class AccessibleComponentHandler implements java.awt.event.ComponentListener {
+ public void componentHidden(java.awt.event.ComponentEvent e) {
+ AccessibleContainer.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ AccessibleState.VISIBLE, null);
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ AccessibleContainer.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, AccessibleState.VISIBLE);
+ }
+
+ public void componentMoved(java.awt.event.ComponentEvent e) {
+ }
+
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ }
+ } // inner class AccessibleContainerHandler
+
+ protected java.awt.event.FocusListener accessibleFocusHandler = null;
+
+ /**
+ * Fire PropertyChange listener, if one is registered,
+ * when focus events happen
+ */
+ protected class AccessibleFocusHandler implements java.awt.event.FocusListener {
+ public void focusGained(java.awt.event.FocusEvent event) {
+ AccessibleContainer.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, AccessibleState.FOCUSED);
+ }
+ public void focusLost(java.awt.event.FocusEvent event) {
+ AccessibleContainer.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ AccessibleState.FOCUSED, null);
+ }
+ } // inner class AccessibleFocusHandler
+
+ protected java.awt.event.ContainerListener accessibleContainerHandler = null;
+
+ /**
+ * Fire PropertyChange listener, if one is registered,
+ * when children added/removed.
+ */
+
+ protected class AccessibleContainerHandler implements java.awt.event.ContainerListener {
+ public void componentAdded(java.awt.event.ContainerEvent e) {
+ java.awt.Component c = e.getChild();
+ if (c != null && c instanceof javax.accessibility.Accessible) {
+ AccessibleContainer.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ null, ((javax.accessibility.Accessible) c).getAccessibleContext());
+ }
+ }
+ public void componentRemoved(java.awt.event.ContainerEvent e) {
+ java.awt.Component c = e.getChild();
+ if (c != null && c instanceof javax.accessibility.Accessible) {
+ AccessibleContainer.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ ((javax.accessibility.Accessible) c).getAccessibleContext(), null);
+ }
+ }
+ }
+
+ protected int propertyChangeListenerCount = 0;
+
+ /**
+ * Add a PropertyChangeListener to the listener list.
+ *
+ * @param listener The PropertyChangeListener to be added
+ */
+ public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) {
+ if (propertyChangeListenerCount++ == 0) {
+ accessibleFocusHandler = new AccessibleFocusHandler();
+ Container.this.addFocusListener(accessibleFocusHandler);
+
+ accessibleContainerHandler = new AccessibleContainerHandler();
+ Container.this.addContainerListener(accessibleContainerHandler);
+
+ accessibleComponentHandler = new AccessibleComponentHandler();
+ Container.this.addComponentListener(accessibleComponentHandler);
+ }
+ super.addPropertyChangeListener(listener);
+ }
+
+ /**
+ * Remove a PropertyChangeListener from the listener list.
+ * This removes a PropertyChangeListener that was registered
+ * for all properties.
+ *
+ * @param listener The PropertyChangeListener to be removed
+ */
+ public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) {
+ if (--propertyChangeListenerCount == 0) {
+ Container.this.removeComponentListener(accessibleComponentHandler);
+ accessibleComponentHandler = null;
+
+ Container.this.removeContainerListener(accessibleContainerHandler);
+ accessibleContainerHandler = null;
+
+ Container.this.removeFocusListener(accessibleFocusHandler);
+ accessibleFocusHandler = null;
+ }
+ super.removePropertyChangeListener(listener);
}
/** Gets the role of this object */
public javax.accessibility.AccessibleRole getAccessibleRole() {
return accessibleRole;
}
+
+ /**
+ * Gets the current state set of this object.
+ *
+ * @return an instance of <code>AccessibleStateSet</code>
+ * containing the current state set of the object
+ * @see AccessibleState
+ */
+ public final javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ try {
+ XAccessibleStateSet unoASS = null;
+ if ( !disposed ) {
+ unoASS = unoAccessibleContext.getAccessibleStateSet();
+ }
+ return getAccessibleStateSetImpl(unoASS);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return getAccessibleStateSetImpl(null);
+ }
+ }
+
+ /** Returns the AccessibleSelection interface for this object */
+ public javax.accessibility.AccessibleSelection getAccessibleSelection() {
+ try {
+ XAccessibleSelection unoAccessibleSelection = (XAccessibleSelection)
+ UnoRuntime.queryInterface(XAccessibleSelection.class, unoAccessibleContext);
+ if (unoAccessibleSelection != null) {
+ return new AccessibleSelectionImpl(unoAccessibleSelection);
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+
+ return null;
+ }
+
+ /** Gets the locale of the component */
+ public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException {
+ try {
+ com.sun.star.lang.Locale unoLocale = unoAccessible.getAccessibleContext().getLocale();
+ return new java.util.Locale(unoLocale.Language, unoLocale.Country);
+ } catch (IllegalAccessibleComponentStateException e) {
+ throw new java.awt.IllegalComponentStateException(e.getMessage());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return super.getLocale();
+ }
+ }
+
+ /*
+ * AccessibleComponent
+ */
+
+ /** Returns the background color of the object */
+ public java.awt.Color getBackground() {
+ try {
+ return new java.awt.Color(unoAccessibleComponent.getBackground());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public void setBackground(java.awt.Color c) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Returns the foreground color of the object */
+ public java.awt.Color getForeground() {
+ try {
+ return new java.awt.Color(unoAccessibleComponent.getForeground());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public void setForeground(java.awt.Color c) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Cursor getCursor() {
+ // Not supported by UNO accessibility API
+ return null;
+ }
+
+ public void setCursor(java.awt.Cursor cursor) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Font getFont() {
+ // FIXME
+ return null;
+ }
+
+ public void setFont(java.awt.Font f) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
+ // FIXME
+ return null;
+ }
+
+ public boolean isEnabled() {
+ return Container.this.isEnabled();
+ }
+
+ public void setEnabled(boolean b) {
+ // Not supported by UNO accessibility API
+ }
+
+ public boolean isVisible() {
+ return Container.this.isVisible();
+ }
+
+ public void setVisible(boolean b) {
+ // Not supported by UNO accessibility API
+ }
+
+ public boolean isShowing() {
+ return Container.this.isShowing();
+ }
+
+ public boolean contains(java.awt.Point p) {
+ try {
+ return unoAccessibleComponent.contains(new com.sun.star.awt.Point(p.x, p.y));
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return false;
+ }
+ }
+
+ /** Returns the location of the object on the screen. */
+ public java.awt.Point getLocationOnScreen() {
+ try {
+ com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen();
+ return new java.awt.Point(unoPoint.X, unoPoint.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the location of this component in the form of a point specifying the component's top-left corner */
+ public java.awt.Point getLocation() {
+ try {
+ com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation();
+ return new java.awt.Point( unoPoint.X, unoPoint.Y );
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Moves this component to a new location */
+ public void setLocation(java.awt.Point p) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Gets the bounds of this component in the form of a Rectangle object */
+ public java.awt.Rectangle getBounds() {
+ try {
+ com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds();
+ return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Moves and resizes this component to conform to the new bounding rectangle r */
+ public void setBounds(java.awt.Rectangle r) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** Returns the size of this component in the form of a Dimension object */
+ public java.awt.Dimension getSize() {
+ try {
+ com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize();
+ return new java.awt.Dimension(unoSize.Width, unoSize.Height);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Resizes this component so that it has width d.width and height d.height */
+ public void setSize(java.awt.Dimension d) {
+ // Not supported by UNO accessibility API
+ }
+
+ /** 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 = AccessibleObjectFactory.getAccessibleComponent(
+ unoAccessibleComponent.getAccessibleAt(new com.sun.star.awt.Point(p.x, p.y)));
+
+ return (javax.accessibility.Accessible) c;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public boolean isFocusTraversable() {
+ return Container.this.isFocusable();
+ }
+
+ public void requestFocus() {
+ unoAccessibleComponent.grabFocus();
+ }
}
public String toString() {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java b/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java
index 4a7940b12856..f48b7212d1cf 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java
@@ -2,10 +2,6 @@
*
* $RCSfile: DescendantManager.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:35 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,39 +57,26 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime;
-import drafts.com.sun.star.accessibility.AccessibleEventId;
-import drafts.com.sun.star.accessibility.AccessibleEventObject;
-import drafts.com.sun.star.accessibility.AccessibleStateType;
-import drafts.com.sun.star.accessibility.XAccessibleContext;
-import drafts.com.sun.star.accessibility.XAccessibleEventBroadcaster;
-import drafts.com.sun.star.accessibility.XAccessibleSelection;
+import drafts.com.sun.star.accessibility.*;
public abstract class DescendantManager extends Component {
- final static String monitorClassName =
- "com.sun.java.accessibility.util.AccessibilityEventMonitor$AccessibilityEventListener";
-
+ protected XAccessibleSelection unoAccessibleSelection = null;
protected javax.accessibility.Accessible activeDescendant = null;
protected boolean multiselectable = false;
- protected DescendantManager() {
- super();
+ protected DescendantManager(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
- protected DescendantManager(boolean multiselectable) {
- super();
+ protected DescendantManager(XAccessible xAccessible, XAccessibleContext xAccessibleContext, boolean multiselectable) {
+ super(xAccessible, xAccessibleContext);
this.multiselectable = multiselectable;
}
- protected boolean isEventMonitorCalling(Throwable t) {
- StackTraceElement[] stack = t.getStackTrace();
- return (stack.length > 1) && (stack[1].getClassName().equals(monitorClassName));
- }
-
/**
* Update the proxy objects appropriatly on property change events
*/
@@ -107,7 +90,7 @@ public abstract class DescendantManager extends Component {
public void notifyEvent(AccessibleEventObject event) {
switch (event.EventId) {
case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
- firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null);
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null);
break;
default:
super.notifyEvent(event);
@@ -115,9 +98,6 @@ public abstract class DescendantManager extends Component {
}
}
- protected XAccessibleContext unoAccessibleContext = null;
- protected XAccessibleSelection unoAccessibleSelection = null;
-
protected abstract class AccessibleDescendantManager extends AccessibleUNOComponent
implements javax.accessibility.AccessibleSelection {
@@ -128,14 +108,25 @@ public abstract class DescendantManager extends Component {
super();
}
- /** Returns the number of accessible children of the object */
- public int getAccessibleChildrenCount() {
- // FIXME: Workaround for AccessibilityEventMonitor problem
- // The AccessibilityEventMonitor traverses all children to check if they have transient state or not.
- if (isEventMonitorCalling(new Throwable())) {
- return 0;
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
+
+ states.add(AccessibleExtendedState.MANAGES_DESCENDANTS);
+ if (multiselectable) {
+ states.add(javax.accessibility.AccessibleState.MULTISELECTABLE);
}
+ return states;
+ }
+
+
+ /*
+ * AccessibleContext
+ */
+
+ /** Returns the number of accessible children of the object */
+ public int getAccessibleChildrenCount() {
try {
return unoAccessibleContext.getAccessibleChildCount();
} catch (com.sun.star.uno.RuntimeException e) {
@@ -148,16 +139,6 @@ public abstract class DescendantManager extends Component {
return (unoAccessibleSelection != null) ? this : null;
}
- /** Returns the state set of this object */
- public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
- javax.accessibility.AccessibleStateSet stateSet = super.getAccessibleStateSet();
- stateSet.add(AccessibleExtendedState.MANAGES_DESCENDANTS);
- if (multiselectable) {
- stateSet.add(javax.accessibility.AccessibleState.MULTISELECTABLE);
- }
- return stateSet;
- }
-
/*
* AccessibleSelection
*/
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java b/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java
index e6e160a72125..0d99f2091752 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Dialog.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:07 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -110,9 +106,6 @@ public class Dialog extends java.awt.Dialog implements javax.accessibility.Acces
}
public void setInitialComponent(java.awt.Component c) {
- if (Build.DEBUG) {
- System.err.println("Initial component set to object of class: " + c.getClass().getName());
- }
initialComponent = c;
}
@@ -280,7 +273,7 @@ public class Dialog extends java.awt.Dialog implements javax.accessibility.Acces
/** Updates the internal child list and fires the appropriate PropertyChangeEvent */
protected void handleChildRemovedEvent(Object any) {
try {
- java.awt.Component c = AccessibleObjectFactory.getDefault().getAccessibleComponent(
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
(XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
if (c != null) {
Dialog.this.remove(c);
@@ -292,17 +285,15 @@ public class Dialog extends java.awt.Dialog implements javax.accessibility.Acces
/** Updates the internal child list and fires the appropriate PropertyChangeEvent */
protected void handleChildAddedEvent(Object any) {
- System.err.println("AccessibleDialog children added: " + getComponentCount());
try {
- XAccessible xAccessible = (XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any);
- AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
- java.awt.Component c = factory.getAccessibleComponent(xAccessible);
+ XAccessible xAccessible = (XAccessible) AnyConverter.toObject(Container.XAccessibleType, any);
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(xAccessible);
if (c != null) {
// Seems to be already in child list
if (this.equals(c.getParent()))
return;
} else {
- c = factory.createAccessibleComponent(xAccessible);
+ c = AccessibleObjectFactory.createAccessibleComponent(xAccessible);
}
if (c != null) {
Dialog.this.add(c, xAccessible.getAccessibleContext().
@@ -633,9 +624,16 @@ public class Dialog extends java.awt.Dialog implements javax.accessibility.Acces
// Not supported by UNO accessibility API
}
+ /** Returns the Accessible child, if one exists, contained at the local coordinate Point */
public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) {
- // Not supported by this implementation
- return null;
+ try {
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
+ unoAccessibleComponent.getAccessibleAt(new com.sun.star.awt.Point(p.x, p.y)));
+
+ return (javax.accessibility.Accessible) c;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
}
public boolean isFocusTraversable() {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java b/accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java
new file mode 100644
index 000000000000..ee37800a9c1d
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/FocusTraversalPolicy.java
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * $RCSfile: FocusTraversalPolicy.java,v $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package org.openoffice.java.accessibility;
+
+
+public class FocusTraversalPolicy extends java.awt.FocusTraversalPolicy {
+
+ protected javax.accessibility.Accessible getSelectedAccessibleChild(javax.accessibility.Accessible a) {
+ javax.accessibility.AccessibleContext ac = a.getAccessibleContext();
+ if (ac != null) {
+ javax.accessibility.AccessibleSelection as = ac.getAccessibleSelection();
+ if (as != null) {
+ return as.getAccessibleSelection(0);
+ }
+ }
+ return null;
+ }
+
+ /** Returns the Component that should receive the focus after aComponent */
+ public java.awt.Component getComponentAfter(java.awt.Container focusCycleRoot,
+ java.awt.Component aComponent) {
+ return null;
+ }
+
+ /** Returns the Component that should receive the focus before aComponent */
+ public java.awt.Component getComponentBefore(java.awt.Container focusCycleRoot,
+ java.awt.Component aComponent) {
+ return null;
+ }
+
+ /** Returns the default Component to focus */
+ public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot) {
+ if (focusCycleRoot instanceof javax.accessibility.Accessible) {
+ return (java.awt.Component) getSelectedAccessibleChild((javax.accessibility.Accessible) focusCycleRoot);
+ }
+ return null;
+ }
+
+ /** Returns the first Component in the traversal cycle */
+ public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot) {
+ return null;
+ }
+
+ /** Returns the Component that should receive the focus when a Window is made visible for the first time */
+ public java.awt.Component getInitialComponent(java.awt.Window window) {
+ if (window instanceof NativeFrame) {
+ return ((NativeFrame) window).getInitialComponent();
+ }
+ return null;
+ }
+
+ /** Returns the last Component in the traversal cycle */
+ public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot) {
+ return null;
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Frame.java b/accessibility/bridge/org/openoffice/java/accessibility/Frame.java
index d98b7da27199..87f534395d0b 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Frame.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Frame.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Frame.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:07 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -99,9 +95,6 @@ public class Frame extends java.awt.Frame implements javax.accessibility.Accessi
}
public void setInitialComponent(java.awt.Component c) {
- if (Build.DEBUG) {
- System.err.println("Initial component set to object of class: " + c.getClass().getName());
- }
initialComponent = c;
}
@@ -217,6 +210,9 @@ public class Frame extends java.awt.Frame implements javax.accessibility.Accessi
java.awt.event.WindowEvent.WINDOW_LOST_FOCUS);
break;
case AccessibleStateType.ICONIFIED:
+ if (Build.DEBUG) {
+ System.err.println("[frame]" + getTitle() + (enable ? " is now " : " is no longer ") + "iconified");
+ }
postWindowEvent(enable ?
java.awt.event.WindowEvent.WINDOW_ICONIFIED :
java.awt.event.WindowEvent.WINDOW_DEICONIFIED);
@@ -274,7 +270,7 @@ public class Frame extends java.awt.Frame implements javax.accessibility.Accessi
/** Updates the internal child list and fires the appropriate PropertyChangeEvent */
protected void handleChildRemovedEvent(Object any) {
try {
- java.awt.Component c = AccessibleObjectFactory.getDefault().getAccessibleComponent(
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
(XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
if (c != null) {
Frame.this.remove(c);
@@ -287,15 +283,14 @@ public class Frame extends java.awt.Frame implements javax.accessibility.Accessi
/** Updates the internal child list and fires the appropriate PropertyChangeEvent */
protected void handleChildAddedEvent(Object any) {
try {
- XAccessible xAccessible = (XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any);
- AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
- java.awt.Component c = factory.getAccessibleComponent(xAccessible);
+ XAccessible xAccessible = (XAccessible) AnyConverter.toObject(Container.XAccessibleType, any);
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(xAccessible);
if (c != null) {
// Seems to be already in child list
if (this.equals(c.getParent()))
return;
} else {
- c = factory.createAccessibleComponent(xAccessible);
+ c = AccessibleObjectFactory.createAccessibleComponent(xAccessible);
}
if (c != null) {
Frame.this.add(c, xAccessible.getAccessibleContext().
@@ -641,9 +636,16 @@ public class Frame extends java.awt.Frame implements javax.accessibility.Accessi
// Not supported by UNO accessibility API
}
+ /** Returns the Accessible child, if one exists, contained at the local coordinate Point */
public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) {
- // Not supported by this implementation
- return null;
+ try {
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
+ unoAccessibleComponent.getAccessibleAt(new com.sun.star.awt.Point(p.x, p.y)));
+
+ return (javax.accessibility.Accessible) c;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
}
public boolean isFocusTraversable() {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Icon.java b/accessibility/bridge/org/openoffice/java/accessibility/Icon.java
index d6f3e73e3f54..9967b7049d46 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Icon.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Icon.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Icon.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:36 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,83 +57,30 @@
package org.openoffice.java.accessibility;
-import java.text.BreakIterator;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
-import com.sun.star.awt.Point;
-import com.sun.star.awt.Rectangle;
-import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.*;
-import drafts.com.sun.star.accessibility.AccessibleEventId;
-import drafts.com.sun.star.accessibility.AccessibleEventObject;
-import drafts.com.sun.star.accessibility.AccessibleStateType;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
-import drafts.com.sun.star.accessibility.XAccessibleImage;
+import drafts.com.sun.star.accessibility.*;
/**
*/
-public class Icon extends Component implements Accessible {
-
- protected Icon(XAccessible accessible, XAccessibleComponent xAccessibleComponent) {
- super();
- initialize(accessible, xAccessibleComponent);
- }
-
- protected void initialize(XAccessible accessible, XAccessibleComponent xAccessibleComponent) {
- unoAccessible = accessible;
- unoAccessibleComponent = xAccessibleComponent;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleIconListener());
- }
-
- protected class AccessibleIconListener extends AccessibleUNOComponentListener {
-
- protected AccessibleIconListener() {
- super();
- }
+public class Icon extends Component implements javax.accessibility.Accessible {
- /** Updates the accessible name and fires the appropriate PropertyChangedEvent */
- protected void handleNameChangedEvent(Object any) {
- try {
- // This causes the property change event to be fired in the VCL thread
- // context. If this causes problems, it has to be deligated to the java
- // dispatch thread ..
- if (accessibleContext != null) {
- accessibleContext.setAccessibleName(AnyConverter.toString(any));
- }
- }
- catch (com.sun.star.lang.IllegalArgumentException e) {
- }
- }
-
- /** Called by OpenOffice process to notify property changes */
- public void notifyEvent(AccessibleEventObject event) {
- switch (event.EventId) {
- case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
- // text changes already handled along with ACCESSIBLE_NAME_EVENT
- break;
- default:
- super.notifyEvent(event);
- }
- }
+ protected Icon(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleIcon();
}
return accessibleContext;
}
- protected class AccessibleIcon extends AccessibleUNOComponent
- /* implements AccessibleExtendedComponent */ {
+ protected class AccessibleIcon extends AccessibleUNOComponent {
/**
* Though the class is abstract, this should be called by all sub-classes
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Label.java b/accessibility/bridge/org/openoffice/java/accessibility/Label.java
index 2cd1abb0ec93..f8a9ec1f8c7f 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Label.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Label.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Label.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:36 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,62 +57,29 @@
package org.openoffice.java.accessibility;
-import java.text.BreakIterator;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleAction;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
-import javax.accessibility.AccessibleText;
-import javax.swing.text.SimpleAttributeSet;
-import javax.swing.text.StyleConstants;
-
-import com.sun.star.awt.Point;
-import com.sun.star.awt.Rectangle;
-import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.*;
import drafts.com.sun.star.accessibility.*;
/**
*/
-public class Label extends Component implements Accessible {
+public class Label extends Component implements javax.accessibility.Accessible {
- protected Label(XAccessible accessible, XAccessibleComponent xAccessibleComponent) {
- super();
- initialize(accessible, xAccessibleComponent);
- }
-
- protected void initialize(XAccessible accessible, XAccessibleComponent xAccessibleComponent) {
- unoAccessible = accessible;
- unoAccessibleComponent = xAccessibleComponent;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleLabelListener());
- }
-
- protected class AccessibleLabelListener extends AccessibleUNOComponentListener {
-
- protected AccessibleLabelListener() {
- super();
- }
+ protected Label(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
- unoAccessibleContext = unoAccessible.getAccessibleContext();
- if (unoAccessibleContext != null) {
- accessibleContext = new AccessibleLabel();
- }
+ accessibleContext = new AccessibleLabel();
}
return accessibleContext;
}
- protected XAccessibleContext unoAccessibleContext = null;
-
- protected class AccessibleLabel extends AccessibleUNOComponent
- /* implements AccessibleExtendedComponent */ {
+ protected class AccessibleLabel extends AccessibleUNOComponent {
/**
* Though the class is abstract, this should be called by all sub-classes
@@ -138,7 +101,7 @@ public class Label extends Component implements Accessible {
public javax.accessibility.AccessibleText getAccessibleText() {
try {
XAccessibleText unoAccessibleText = (XAccessibleText)
- UnoRuntime.queryInterface(XAccessibleText.class,unoAccessibleComponent);
+ UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext);
if (unoAccessibleText != null) {
return new AccessibleTextImpl(unoAccessibleText);
} else {
@@ -199,4 +162,3 @@ public class Label extends Component implements Accessible {
}
}
-
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/List.java b/accessibility/bridge/org/openoffice/java/accessibility/List.java
index 2c3022536eec..24e9b1a6da67 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/List.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/List.java
@@ -2,10 +2,6 @@
*
* $RCSfile: List.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:37 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -70,17 +66,8 @@ import drafts.com.sun.star.accessibility.*;
public class List extends DescendantManager implements javax.accessibility.Accessible {
- protected List(XAccessible accessible, XAccessibleComponent component) {
- super();
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
- UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, component);
- if (broadcaster != null) {
- broadcaster.addEventListener(new AccessibleListListener());
- }
+ protected List(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
protected void setActiveDescendant(javax.accessibility.Accessible descendant) {
@@ -95,10 +82,20 @@ public class List extends DescendantManager implements javax.accessibility.Acces
try {
if (AnyConverter.isObject(any)) {
XAccessible unoAccessible = (XAccessible) AnyConverter.toObject(
- AbstractContainer.XAccessibleType, any);
+ Container.XAccessibleType, any);
if (unoAccessible != null) {
// FIXME: have to handle non transient objects here ..
descendant = new ListItem(unoAccessible);
+ if (Build.DEBUG) {
+ try {
+ if (Build.DEBUG) {
+ System.err.println("[List] retrieved active descendant event: new descendant is " +
+ unoAccessible.getAccessibleContext().getAccessibleName());
+ }
+ } catch (java.lang.NullPointerException e) {
+ System.err.println("*** ERROR *** new active descendant not accessible");
+ }
+ }
}
}
setActiveDescendant(descendant);
@@ -128,14 +125,14 @@ public class List extends DescendantManager implements javax.accessibility.Acces
protected void add(Object any) {
try {
- add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ add((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
protected void remove(Object any) {
try {
- remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ remove((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
@@ -173,6 +170,10 @@ public class List extends DescendantManager implements javax.accessibility.Acces
}
}
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleListListener();
+ }
+
/** Returns the AccessibleContext associated with this object */
public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
@@ -238,7 +239,7 @@ public class List extends DescendantManager implements javax.accessibility.Acces
public javax.accessibility.Accessible getAccessibleSelection(int i) {
javax.accessibility.Accessible child = null;
try {
- XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ XAccessible xAccessible = unoAccessibleSelection.getSelectedAccessibleChild(i);
if (xAccessible != null) {
// Re-use the active descandant wrapper if possible
javax.accessibility.Accessible activeDescendant = List.this.activeDescendant;
@@ -247,8 +248,13 @@ public class List extends DescendantManager implements javax.accessibility.Acces
} else {
child = new ListItem(xAccessible);
}
+ } else if (Build.DEBUG) {
+ System.out.println(i + "th selected child is not accessible");
}
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ if (Build.DEBUG) {
+ System.err.println("IndexOutOfBoundsException caught for AccessibleList.getAccessibleSelection(" + i + ")");
+ }
} catch (com.sun.star.uno.RuntimeException e) {
}
return child;
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Menu.java b/accessibility/bridge/org/openoffice/java/accessibility/Menu.java
index 9c27e382f266..0f8cbda163f1 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Menu.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Menu.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Menu.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 12:55:17 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,10 +57,6 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.AccessibleContext;
-import javax.accessibility.AccessibleState;
-import javax.accessibility.AccessibleStateSet;
-
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.UnoRuntime;
import drafts.com.sun.star.accessibility.*;
@@ -73,20 +65,13 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
private java.util.Vector children;
- protected Menu(XAccessible accessible, XAccessibleComponent component) {
- super();
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleMenuListener());
+ protected Menu(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
try {
- XAccessibleContext unoAccessibleContext = unoAccessible.getAccessibleContext();
// Create a vector with the correct initial capacity
int count = unoAccessibleContext.getAccessibleChildCount();
children = new java.util.Vector(count);
// Fill the vector with objects
- AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
for (int i=0; i < count; i++) {
java.awt.Component c = getComponent(unoAccessibleContext.getAccessibleChild(i));
if (c != null) {
@@ -111,7 +96,7 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
if (c != null) {
try {
children.add(unoAccessible.getAccessibleContext().getAccessibleIndexInParent(), c);
- firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
null, ((javax.accessibility.Accessible) c).getAccessibleContext());
} catch (com.sun.star.uno.RuntimeException e) {
}
@@ -125,7 +110,7 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
if (c != null) {
try {
children.remove(c);
- firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
((javax.accessibility.Accessible) c).getAccessibleContext(), null);
} catch (com.sun.star.uno.RuntimeException e) {
}
@@ -134,14 +119,14 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
protected void add(Object any) {
try {
- add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ add((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
protected void remove(Object any) {
try {
- remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ remove((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
@@ -151,10 +136,9 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
}
protected java.awt.Component getComponent(XAccessible unoAccessible) {
- AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
- java.awt.Component c = factory.getAccessibleComponent(unoAccessible);
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(unoAccessible);
if (c == null) {
- c = factory.createAccessibleComponent(unoAccessible);
+ c = AccessibleObjectFactory.createAccessibleComponent(unoAccessible);
if (c instanceof javax.accessibility.Accessible) {
((javax.accessibility.Accessible) c).getAccessibleContext().setAccessibleParent(this);
}
@@ -165,7 +149,7 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
/**
* Update the proxy objects appropriatly on property change events
*/
- protected class AccessibleMenuListener extends AccessibleAbstractButtonListener {
+ protected class AccessibleMenuListener extends AccessibleUNOComponentListener {
protected AccessibleMenuListener() {
super();
@@ -183,7 +167,7 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
}
break;
case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
- firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,null, null);
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null);
break;
default:
super.notifyEvent(event);
@@ -192,12 +176,16 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
}
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleMenuListener();
+ }
+
/** Returns the AccessibleContext associated with this object */
public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
try {
unoAccessibleSelection = (XAccessibleSelection) UnoRuntime.queryInterface(
- XAccessibleSelection.class, unoAccessibleComponent);
+ XAccessibleSelection.class, unoAccessibleContext);
if (unoAccessibleSelection != null) {
accessibleContext = new AccessibleMenu();
}
@@ -258,6 +246,22 @@ public class Menu extends AbstractButton implements javax.accessibility.Accessib
}
/*
+ * 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 = AccessibleObjectFactory.getAccessibleComponent(
+ unoAccessibleComponent.getAccessibleAt(new com.sun.star.awt.Point(p.x, p.y)));
+
+ return (javax.accessibility.Accessible) c;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /*
* AccessibleSelection
*/
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java b/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java
index 93f5622f138c..042d7269f999 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java
@@ -2,9 +2,9 @@
*
* $RCSfile: MenuItem.java,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:37 $
+ * last change: $Author: hr $ $Date: 2003-03-18 15:48:20 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,21 +61,17 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
-
import drafts.com.sun.star.accessibility.XAccessible;
import drafts.com.sun.star.accessibility.XAccessibleContext;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
class MenuItem extends ToggleButton {
- public MenuItem(XAccessible accessible, XAccessibleComponent component) {
- super(accessible, component);
+ public MenuItem(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleMenuItem();
}
@@ -94,7 +90,7 @@ class MenuItem extends ToggleButton {
if (getAccessibleParent() instanceof Menu) {
return ((Menu) getAccessibleParent()).indexOf(MenuItem.this);
} else {
- return -1;
+ return super.getAccessibleIndexInParent();
}
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java b/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java
index e07ba12a2abc..2463818ea568 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java
@@ -2,10 +2,6 @@
*
* $RCSfile: NativeFrame.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:38 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -64,6 +60,6 @@ package org.openoffice.java.accessibility;
public interface NativeFrame {
public java.awt.Component getInitialComponent();
public void setInitialComponent(java.awt.Component c);
- public Integer getHWND();
+// public Integer getHWND();
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java b/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java
index 42da06adb995..1182a12e46a7 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java
@@ -2,10 +2,6 @@
*
* $RCSfile: RadioButton.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:07 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,31 +57,25 @@
package org.openoffice.java.accessibility;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
class RadioButton extends ToggleButton {
- public RadioButton(XAccessible accessible, XAccessibleComponent component) {
- super(accessible, component);
+ public RadioButton(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleRadioButton();
- System.err.println("RadioButton created");
}
return accessibleContext;
}
protected class AccessibleRadioButton extends AccessibleToggleButton {
-/*
- protected AccessibleRadioButton() {
- }
-*/
-
/** Gets the role of this object */
public javax.accessibility.AccessibleRole getAccessibleRole() {
return javax.accessibility.AccessibleRole.RADIO_BUTTON;
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java b/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java
index 498783df0c2c..2bb2e3ed41b3 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java
@@ -2,10 +2,6 @@
*
* $RCSfile: ScrollBar.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:39 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,73 +57,30 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
import javax.swing.SwingConstants;
import com.sun.star.uno.*;
-import drafts.com.sun.star.accessibility.AccessibleEventId;
-import drafts.com.sun.star.accessibility.AccessibleEventObject;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleAction;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
-import drafts.com.sun.star.accessibility.XAccessibleValue;
+import drafts.com.sun.star.accessibility.*;
/**
*/
-public class ScrollBar extends Component implements SwingConstants, Accessible {
+public class ScrollBar extends Component implements SwingConstants, javax.accessibility.Accessible {
private int orientation = HORIZONTAL;
- public ScrollBar(XAccessible accessible, XAccessibleComponent component, int orientation) {
- super();
+ public ScrollBar(XAccessible xAccessible, XAccessibleContext xAccessibleContext, int orientation) {
+ super(xAccessible, xAccessibleContext);
this.orientation = orientation;
- initialize(accessible, component);
- }
-
- public ScrollBar(XAccessible accessible, XAccessibleComponent component) {
- super();
- initialize(accessible, component);
}
- protected void initialize(XAccessible accessible, XAccessibleComponent component) {
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleScrollBarListener());
- }
-
- protected void fireValuePropertyChanged(Number oldValue, Number newValue) {
- java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().invokeLater(
- new PropertyChangeBroadcaster(accessibleContext.ACCESSIBLE_VALUE_PROPERTY,
- oldValue, newValue));
- }
-
- protected class AccessibleScrollBarListener extends AccessibleUNOComponentListener {
- /** Passes the event to all registered listeners (if any) */
- protected void handleValueEvent(Number oldValue, Number newValue) {
- // Notify property event listeners
- ScrollBar.this.fireValuePropertyChanged(oldValue, newValue);
- }
-
- /** Called by OpenOffice process to notify property changes */
- public void notifyEvent(AccessibleEventObject event) {
- switch(event.EventId) {
- case AccessibleEventId.ACCESSIBLE_VALUE_EVENT:
- // Fire the appropriate PropertyChangeEvent
- handleValueEvent(toNumber(event.OldValue), toNumber(event.NewValue));
- break;
- default:
- super.notifyEvent(event);
- }
- }
+ public ScrollBar(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleScrollBar();
}
@@ -135,9 +88,8 @@ public class ScrollBar extends Component implements SwingConstants, Accessible {
}
protected class AccessibleScrollBar extends AccessibleUNOComponent implements
- javax.accessibility.AccessibleValue, javax.accessibility.AccessibleAction {
+ javax.accessibility.AccessibleAction {
- protected XAccessibleValue unoAccessibleValue;
protected XAccessibleAction unoAccessibleAction;
protected int actionCount = 0;
@@ -146,29 +98,17 @@ public class ScrollBar extends Component implements SwingConstants, Accessible {
*/
protected AccessibleScrollBar() {
super();
- unoAccessibleValue = (XAccessibleValue) UnoRuntime.queryInterface(
- XAccessibleValue.class, unoAccessibleComponent);
unoAccessibleAction = (XAccessibleAction) UnoRuntime.queryInterface(
- XAccessibleAction.class, ScrollBar.this.unoAccessibleComponent);
+ XAccessibleAction.class, unoAccessibleContext);
if (unoAccessibleAction != null) {
actionCount = unoAccessibleAction.getAccessibleActionCount();
}
}
- /** Gets the role of this object */
- public javax.accessibility.AccessibleRole getAccessibleRole() {
- return javax.accessibility.AccessibleRole.SCROLL_BAR;
- }
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
- /**
- * Get the state set of this object.
- *
- * @return an instance of AccessibleState containing the current state
- * of the object
- * @see AccessibleState
- */
- public AccessibleStateSet getAccessibleStateSet() {
- AccessibleStateSet states = super.getAccessibleStateSet();
switch (orientation) {
case HORIZONTAL:
states.add(AccessibleState.HORIZONTAL);
@@ -179,12 +119,29 @@ public class ScrollBar extends Component implements SwingConstants, Accessible {
default:
break;
}
+
return states;
}
- /** Gets the AccessibleValue associated with this object that supports a Numerical value */
+ /*
+ * AccessibleContext
+ */
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.SCROLL_BAR;
+ }
+
+ /** Gets the AccessibleValue associated with this object that has a graphical representation */
public javax.accessibility.AccessibleValue getAccessibleValue() {
- return this;
+ try {
+ XAccessibleValue unoAccessibleValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleContext);
+ return (unoAccessibleValue != null) ?
+ new AccessibleValueImpl(unoAccessibleValue) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
}
/** Gets the AccessibleAction associated with this object that supports one or more actions */
@@ -222,45 +179,6 @@ public class ScrollBar extends Component implements SwingConstants, Accessible {
public int getAccessibleActionCount() {
return actionCount;
}
-
- /*
- * AccessibleValue
- */
-
- /** Get the minimum value of this object as a Number */
- public java.lang.Number getMinimumAccessibleValue() {
- try {
- return toNumber(unoAccessibleValue.getMinimumValue());
- } catch (com.sun.star.uno.RuntimeException e) {
- return null;
- }
- }
-
- /** Get the value of this object as a Number */
- public java.lang.Number getCurrentAccessibleValue() {
- try {
- return toNumber(unoAccessibleValue.getCurrentValue());
- } catch (com.sun.star.uno.RuntimeException e) {
- return null;
- }
- }
- /** Get the maximum value of this object as a Number */
- public java.lang.Number getMaximumAccessibleValue() {
- try {
- return toNumber(unoAccessibleValue.getMaximumValue());
- } catch (com.sun.star.uno.RuntimeException e) {
- return null;
- }
- }
-
- /** Set the value of this object as a Number */
- public boolean setCurrentAccessibleValue(java.lang.Number number) {
- try {
- return unoAccessibleValue.setCurrentValue(number);
- } catch (com.sun.star.uno.RuntimeException e) {
- return false;
- }
- }
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Separator.java b/accessibility/bridge/org/openoffice/java/accessibility/Separator.java
index d4a1486fa647..54dd770281ac 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Separator.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Separator.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Separator.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:39 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,48 +57,32 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.Accessible;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import javax.accessibility.AccessibleStateSet;
import javax.swing.SwingConstants;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
/**
*/
-public class Separator extends Component implements SwingConstants, Accessible {
+public class Separator extends Component implements SwingConstants, javax.accessibility.Accessible {
private int orientation = HORIZONTAL;
- public Separator(XAccessible accessible, XAccessibleComponent component, int orientation) {
- super();
+ public Separator(XAccessible xAccessible, XAccessibleContext xAccessibleContext, int orientation) {
+ super(xAccessible, xAccessibleContext);
this.orientation = orientation;
- initialize(accessible, component);
- }
-
- public Separator(XAccessible accessible, XAccessibleComponent component) {
- super();
- initialize(accessible, component);
+ setFocusable(false);
}
- protected void initialize(XAccessible accessible, XAccessibleComponent component) {
+ public Separator(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
setFocusable(false);
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- }
-/*
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleSeparatorListener());
}
- protected class AccessibleSeparatorListener extends AccessibleUNOComponentListener {
- }
-*/
/** Returns the AccessibleContext associated with this object */
- public AccessibleContext getAccessibleContext() {
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleSeparator();
}
@@ -118,20 +98,10 @@ public class Separator extends Component implements SwingConstants, Accessible {
super();
}
- /** Gets the role of this object */
- public javax.accessibility.AccessibleRole getAccessibleRole() {
- return javax.accessibility.AccessibleRole.SEPARATOR;
- }
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
- /**
- * Get the state set of this object.
- *
- * @return an instance of AccessibleState containing the current state
- * of the object
- * @see AccessibleState
- */
- public AccessibleStateSet getAccessibleStateSet() {
- AccessibleStateSet states = super.getAccessibleStateSet();
switch (orientation) {
case HORIZONTAL:
states.add(AccessibleState.HORIZONTAL);
@@ -142,8 +112,18 @@ public class Separator extends Component implements SwingConstants, Accessible {
default:
break;
}
+
return states;
}
+
+ /*
+ * AccessibleContext
+ */
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.SEPARATOR;
+ }
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Table.java b/accessibility/bridge/org/openoffice/java/accessibility/Table.java
index 367766ac750b..e0f16e87c256 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Table.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Table.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Table.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 12:54:04 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,7 +57,6 @@
package org.openoffice.java.accessibility;
-import javax.accessibility.AccessibleContext;
import javax.accessibility.AccessibleState;
import com.sun.star.uno.AnyConverter;
@@ -70,23 +65,14 @@ import drafts.com.sun.star.accessibility.*;
public class Table extends DescendantManager implements javax.accessibility.Accessible {
- protected Table(XAccessible accessible, XAccessibleComponent component, boolean multiselectable) {
- super(multiselectable);
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
- UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, component);
- if (broadcaster != null) {
- broadcaster.addEventListener(new AccessibleTableListener());
- }
+ protected Table(XAccessible xAccessible, XAccessibleContext xAccessibleContext, boolean multiselectable) {
+ super(xAccessible, xAccessibleContext, multiselectable);
}
protected void setActiveDescendant(javax.accessibility.Accessible descendant) {
javax.accessibility.Accessible oldAD = activeDescendant;
activeDescendant = descendant;
- firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
oldAD, descendant);
}
@@ -95,7 +81,7 @@ public class Table extends DescendantManager implements javax.accessibility.Acce
try {
if (AnyConverter.isObject(any)) {
XAccessible unoAccessible = (XAccessible) AnyConverter.toObject(
- AbstractContainer.XAccessibleType, any);
+ Container.XAccessibleType, any);
if (unoAccessible != null) {
// FIXME: have to handle non transient objects here ..
descendant = new TableCell(unoAccessible);
@@ -111,7 +97,7 @@ public class Table extends DescendantManager implements javax.accessibility.Acce
TableCell cell = new TableCell(unoAccessible);
// The AccessBridge for Windows expects an instance of AccessibleContext
// as parameters
- firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
null, cell.getAccessibleContext());
}
}
@@ -121,21 +107,21 @@ public class Table extends DescendantManager implements javax.accessibility.Acce
TableCell cell = new TableCell(unoAccessible);
// The AccessBridge for Windows expects an instance of AccessibleContext
// as parameters
- firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ firePropertyChange(javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
cell.getAccessibleContext(), null);
}
}
protected void add(Object any) {
try {
- add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ add((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
protected void remove(Object any) {
try {
- remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ remove((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
@@ -169,6 +155,10 @@ public class Table extends DescendantManager implements javax.accessibility.Acce
}
}
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleTableListener();
+ }
+
/** Returns the AccessibleContext associated with this object */
public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
@@ -232,7 +222,7 @@ public class Table extends DescendantManager implements javax.accessibility.Acce
public javax.accessibility.Accessible getAccessibleSelection(int i) {
javax.accessibility.Accessible child = null;
try {
- XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ XAccessible xAccessible = unoAccessibleSelection.getSelectedAccessibleChild(i);
if (xAccessible != null) {
// Re-use the active descandant wrapper if possible
javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant;
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java b/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java
index 94a88b591ffa..3f7ff474297b 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java
@@ -2,10 +2,6 @@
*
* $RCSfile: TextComponent.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:08 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -71,15 +67,10 @@ public class TextComponent extends Component implements javax.accessibility.Acce
boolean multiLine = false;
boolean editable = false;
- protected TextComponent(XAccessible accessible, XAccessibleComponent xAccessibleComponent, XAccessibleStateSet xAccessibleStateSet) {
- super();
- unoAccessible = accessible;
- unoAccessibleComponent = xAccessibleComponent;
+ protected TextComponent(XAccessible xAccessible, XAccessibleContext xAccessibleContext, XAccessibleStateSet xAccessibleStateSet) {
+ super(xAccessible, xAccessibleContext);
editable = xAccessibleStateSet.contains(AccessibleStateType.EDITABLE);
multiLine = xAccessibleStateSet.contains(AccessibleStateType.MULTILINE);
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleTextComponentListener());
}
protected class AccessibleTextComponentListener extends AccessibleUNOComponentListener {
@@ -105,25 +96,10 @@ public class TextComponent extends Component implements javax.accessibility.Acce
break;
}
}
+ }
- /** Called by OpenOffice process to notify property changes */
- public void notifyEvent(AccessibleEventObject event) {
- switch (event.EventId) {
- case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
- firePropertyChange(accessibleContext.ACCESSIBLE_TEXT_PROPERTY,
- null, new Integer(0));
- break;
- case AccessibleEventId.ACCESSIBLE_CARET_EVENT:
- if (Build.DEBUG) {
- System.err.println("Caret event");
- }
- firePropertyChange(accessibleContext.ACCESSIBLE_CARET_PROPERTY,
- toNumber(event.OldValue), toNumber(event.NewValue));
- break;
- default:
- super.notifyEvent(event);
- }
- }
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleTextComponentListener();
}
/** Returns the AccessibleContext associated with this object */
@@ -143,6 +119,22 @@ public class TextComponent extends Component implements javax.accessibility.Acce
super();
}
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
+
+ if (editable) {
+ states.add(javax.accessibility.AccessibleState.EDITABLE);
+ }
+ if (multiLine) {
+ states.add(javax.accessibility.AccessibleState.MULTI_LINE);
+ } else {
+ states.add(javax.accessibility.AccessibleState.SINGLE_LINE);
+ }
+
+ return states;
+ }
+
/*
* AccessibleContext
*/
@@ -194,27 +186,6 @@ public class TextComponent extends Component implements javax.accessibility.Acce
}
}
- /**
- * Get the state set of this object.
- *
- * @return an instance of AccessibleState containing the current state
- * of the object
- * @see AccessibleState
- */
-
- public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
- javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSet();
- if (editable) {
- states.add(javax.accessibility.AccessibleState.EDITABLE);
- }
- if (multiLine) {
- states.add(javax.accessibility.AccessibleState.MULTI_LINE);
- } else {
- states.add(javax.accessibility.AccessibleState.SINGLE_LINE);
- }
- return states;
- }
-
/** Returns the relation set of this object */
public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() {
try {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java b/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java
index 85fd85d31a4e..9f46972d501f 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java
@@ -2,10 +2,6 @@
*
* $RCSfile: ToggleButton.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:40 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -61,28 +57,13 @@
package org.openoffice.java.accessibility;
-import com.sun.star.uno.UnoRuntime;
-import drafts.com.sun.star.accessibility.XAccessible;
-import drafts.com.sun.star.accessibility.XAccessibleComponent;
-import drafts.com.sun.star.accessibility.XAccessibleValue;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
class ToggleButton extends AbstractButton implements javax.accessibility.Accessible {
- public ToggleButton(XAccessible accessible, XAccessibleComponent component) {
- super();
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- addAccessibleEventListener(new AccessibleToggleButtonListener());
- }
-
- protected class AccessibleToggleButtonListener extends AccessibleAbstractButtonListener {
-/*
- protected AccessibleButtonListener() {
- super();
- }
-*/
+ public ToggleButton(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
/** Returns the AccessibleContext associated with this object */
@@ -94,11 +75,7 @@ class ToggleButton extends AbstractButton implements javax.accessibility.Accessi
}
protected class AccessibleToggleButton extends AccessibleAbstractButton {
-/*
- protected AccessibleToggleButton() {
- super();
- }
-*/
+
/** Gets the role of this object */
public javax.accessibility.AccessibleRole getAccessibleRole() {
return javax.accessibility.AccessibleRole.TOGGLE_BUTTON;
@@ -108,7 +85,7 @@ class ToggleButton extends AbstractButton implements javax.accessibility.Accessi
public javax.accessibility.AccessibleValue getAccessibleValue() {
try {
XAccessibleValue unoAccessibleValue = (XAccessibleValue)
- UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleComponent);
+ UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleContext);
return (unoAccessibleValue != null) ?
new AccessibleValueImpl(unoAccessibleValue) : null;
} catch (com.sun.star.uno.RuntimeException e) {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java b/accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java
new file mode 100644
index 000000000000..a47d6283ea43
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ToolTip.java
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * $RCSfile: ToolTip.java,v $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+package org.openoffice.java.accessibility;
+
+import javax.accessibility.AccessibleState;
+import javax.accessibility.AccessibleStateSet;
+
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
+
+/**
+ */
+public class ToolTip extends Component implements javax.accessibility.Accessible {
+
+ protected ToolTip(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleToolTip();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleToolTip extends AccessibleUNOComponent {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleToolTip() {
+ super();
+ }
+
+ /*
+ * AccessibleContext
+ */
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.TOOL_TIP;
+ }
+
+ /** Gets the AccessibleText associated with this object presenting text on the display */
+ public javax.accessibility.AccessibleText getAccessibleText() {
+ try {
+ XAccessibleText unoAccessibleText = (XAccessibleText)
+ UnoRuntime.queryInterface(XAccessibleText.class,unoAccessibleComponent);
+ if (unoAccessibleText != null) {
+ return new AccessibleTextImpl(unoAccessibleText);
+ } else {
+ return null;
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Get the state set of this object.
+ *
+ * @return an instance of AccessibleState containing the current state
+ * of the object
+ * @see AccessibleState
+ */
+/*
+ public AccessibleStateSet getAccessibleStateSet() {
+ AccessibleStateSet states = super.getAccessibleStateSet();
+ return states;
+ }
+*/
+ /** Returns the relation set of this object */
+/*
+ public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() {
+ try {
+ XAccessibleRelationSet unoAccessibleRelationSet = unoAccessibleContext.getAccessibleRelationSet();
+ if (unoAccessibleRelationSet == null) {
+ return null;
+ }
+
+ javax.accessibility.AccessibleRelationSet relationSet = new javax.accessibility.AccessibleRelationSet();
+ int count = unoAccessibleRelationSet.getRelationCount();
+ for (int i = 0; i < count; i++) {
+ AccessibleRelation unoAccessibleRelation = unoAccessibleRelationSet.getRelation(i);
+ switch (unoAccessibleRelation.RelationType) {
+ case AccessibleRelationType.LABEL_FOR:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.LABEL_FOR,
+ getAccessibleComponents(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.MEMBER_OF:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.MEMBER_OF,
+ getAccessibleComponents(unoAccessibleRelation.TargetSet)));
+ break;
+ default:
+ break;
+ }
+ }
+ return relationSet;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ return null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+*/
+ }
+}
+
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Tree.java b/accessibility/bridge/org/openoffice/java/accessibility/Tree.java
index e3cd26d40070..e3e25460a83b 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Tree.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Tree.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Tree.java,v $
*
- * $Revision: 1.1 $
- *
- * last change: $Author: obr $ $Date: 2002-12-06 11:25:41 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -70,17 +66,8 @@ import drafts.com.sun.star.accessibility.*;
public class Tree extends DescendantManager implements javax.accessibility.Accessible {
- protected Tree(XAccessible accessible, XAccessibleComponent component) {
- super();
- unoAccessible = accessible;
- unoAccessibleComponent = component;
- // To reflect focus and other component state changes, the accessibility
- // event listener must already be added here
- XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
- UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class, component);
- if (broadcaster != null) {
- broadcaster.addEventListener(new AccessibleTreeListener());
- }
+ protected Tree(XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
+ super(xAccessible, xAccessibleContext);
}
protected void setActiveDescendant(javax.accessibility.Accessible descendant) {
@@ -95,7 +82,7 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
try {
if (AnyConverter.isObject(any)) {
XAccessible unoAccessible = (XAccessible) AnyConverter.toObject(
- AbstractContainer.XAccessibleType, any);
+ Container.XAccessibleType, any);
if (unoAccessible != null) {
// FIXME: have to handle non transient objects here ..
descendant = new TreeItem(unoAccessible);
@@ -122,14 +109,14 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
protected void add(Object any) {
try {
- add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ add((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
protected void remove(Object any) {
try {
- remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ remove((XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
@@ -164,6 +151,10 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
}
}
+ protected XAccessibleEventListener createEventListener() {
+ return new AccessibleTreeListener();
+ }
+
/** Returns the AccessibleContext associated with this object */
public javax.accessibility.AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
@@ -190,6 +181,33 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
super();
}
+ /** Returns an AccessibleStateSet that contains corresponding Java states to the UAA state types */
+ protected javax.accessibility.AccessibleStateSet getAccessibleStateSetImpl(XAccessibleStateSet unoAS) {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSetImpl(unoAS);
+
+ try {
+ if (unoAS != null) {
+ if (unoAS.contains(AccessibleStateType.EXPANDABLE)) {
+ states.add(javax.accessibility.AccessibleState.EXPANDABLE);
+ }
+ if (unoAS.contains(AccessibleStateType.EXPANDED)) {
+ states.add(javax.accessibility.AccessibleState.EXPANDED);
+ }
+ if (unoAS.contains(AccessibleStateType.COLLAPSED)) {
+ states.add(javax.accessibility.AccessibleState.COLLAPSED);
+ }
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+
+ return states;
+ }
+
+
+ /*
+ * AccessibleContext
+ */
+
/** Gets the role of this object */
public javax.accessibility.AccessibleRole getAccessibleRole() {
return javax.accessibility.AccessibleRole.TREE;
@@ -216,8 +234,8 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
}
/*
- * AccessibleSelection
- */
+ * AccessibleSelection
+ */
/** Returns an Accessible representing the specified selected child of the object */
public javax.accessibility.Accessible getAccessibleSelection(int i) {
@@ -281,12 +299,16 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
return accessibleContext;
}
- protected class AccessibleTreeItem extends javax.accessibility.AccessibleContext {
+ protected class AccessibleTreeItem extends javax.accessibility.AccessibleContext
+ implements javax.accessibility.AccessibleSelection {
XAccessibleContext unoAccessibleContext;
+ XAccessibleSelection unoAccessibleSelection;
public AccessibleTreeItem(XAccessibleContext xAccessibleContext) {
unoAccessibleContext = xAccessibleContext;
+ unoAccessibleSelection = (XAccessibleSelection)
+ UnoRuntime.queryInterface(XAccessibleSelection.class, xAccessibleContext);
}
/** Returns the accessible name of this object */
@@ -411,6 +433,15 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTED)) {
stateSet.add(javax.accessibility.AccessibleState.SELECTED);
}
+ if (unoAccessibleStateSet.contains(AccessibleStateType.EXPANDABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.EXPANDABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.EXPANDED)) {
+ stateSet.add(javax.accessibility.AccessibleState.EXPANDED);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.COLLAPSED)) {
+ stateSet.add(javax.accessibility.AccessibleState.COLLAPSED);
+ }
return stateSet;
} catch (com.sun.star.uno.RuntimeException e) {
return null;
@@ -429,6 +460,11 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
}
}
+ /** Returns the AccessibleSelection interface for this object */
+ public javax.accessibility.AccessibleSelection getAccessibleSelection() {
+ return (unoAccessibleSelection != null) ? this : null;
+ }
+
/** Gets the AccessibleAction associated with this object that has a graphical representation */
public javax.accessibility.AccessibleAction getAccessibleAction() {
try {
@@ -478,6 +514,78 @@ public class Tree extends DescendantManager implements javax.accessibility.Acces
}
return null;
}
+
+ /*
+ * AccessibleSelection
+ */
+
+ /** Returns an Accessible representing the specified selected child of the object */
+ public javax.accessibility.Accessible getAccessibleSelection(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ if (xAccessible != null) {
+ child = new TreeItem(xAccessible);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /** Adds the specified Accessible child of the object to the object's selection */
+ public void addAccessibleSelection(int i) {
+ try {
+ unoAccessibleSelection.selectAccessibleChild(i);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Clears the selection in the object, so that no children in the object are selected */
+ public void clearAccessibleSelection() {
+ try {
+ unoAccessibleSelection.clearAccessibleSelection();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Returns the number of Accessible children currently selected */
+ public int getAccessibleSelectionCount() {
+ try {
+ return unoAccessibleSelection.getSelectedAccessibleChildCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Determines if the current child of this object is selected */
+ public boolean isAccessibleChildSelected(int i) {
+ try {
+ return unoAccessibleSelection.isAccessibleChildSelected(i);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ return false;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return false;
+ }
+ }
+
+ /** Removes the specified child of the object from the object's selection */
+ public void removeAccessibleSelection(int i) {
+ try {
+ unoAccessibleSelection.deselectSelectedAccessibleChild(i);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Causes every child of the object to be selected if the object supports multiple selection */
+ public void selectAllAccessibleSelection() {
+ try {
+ unoAccessibleSelection.selectAllAccessible();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
}
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Window.java b/accessibility/bridge/org/openoffice/java/accessibility/Window.java
index de6822595f3e..b846d5c973ab 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Window.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Window.java
@@ -2,10 +2,6 @@
*
* $RCSfile: Window.java,v $
*
- * $Revision: 1.2 $
- *
- * last change: $Author: obr $ $Date: 2003-01-13 11:00:08 $
- *
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
@@ -265,7 +261,7 @@ public class Window extends java.awt.Window implements javax.accessibility.Acces
/** Updates the internal child list and fires the appropriate PropertyChangeEvent */
protected void handleChildRemovedEvent(Object any) {
try {
- java.awt.Component c = AccessibleObjectFactory.getDefault().getAccessibleComponent(
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
(XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
if (c != null) {
Window.this.remove(c);
@@ -278,15 +274,14 @@ public class Window extends java.awt.Window implements javax.accessibility.Acces
/** Updates the internal child list and fires the appropriate PropertyChangeEvent */
protected void handleChildAddedEvent(Object any) {
try {
- XAccessible xAccessible = (XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any);
- AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
- java.awt.Component c = factory.getAccessibleComponent(xAccessible);
+ XAccessible xAccessible = (XAccessible) AnyConverter.toObject(Container.XAccessibleType, any);
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(xAccessible);
if (c != null) {
// Seems to be already in child list
if (this.equals(c.getParent()))
return;
} else {
- c = factory.createAccessibleComponent(xAccessible);
+ c = AccessibleObjectFactory.createAccessibleComponent(xAccessible);
}
if (c != null) {
Window.this.add(c, xAccessible.getAccessibleContext().
@@ -611,9 +606,16 @@ public class Window extends java.awt.Window implements javax.accessibility.Acces
// Not supported by UNO accessibility API
}
+ /** Returns the Accessible child, if one exists, contained at the local coordinate Point */
public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) {
- // Not supported by this implementation
- return null;
+ try {
+ java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
+ unoAccessibleComponent.getAccessibleAt(new com.sun.star.awt.Point(p.x, p.y)));
+
+ return (javax.accessibility.Accessible) c;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
}
public boolean isFocusTraversable() {
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/makefile.mk b/accessibility/bridge/org/openoffice/java/accessibility/makefile.mk
index 488dcfa68f8d..62d359d61ea3 100755
--- a/accessibility/bridge/org/openoffice/java/accessibility/makefile.mk
+++ b/accessibility/bridge/org/openoffice/java/accessibility/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.9 $
+# $Revision: 1.10 $
#
-# last change: $Author: obr $ $Date: 2002-12-06 11:19:00 $
+# last change: $Author: hr $ $Date: 2003-03-18 15:48:23 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -76,7 +76,6 @@ JAVADIR = $(OUT)$/misc$/java
JARFILES = sandbox.jar jurt.jar unoil.jar ridl.jar
JAVAFILES = \
AbstractButton.java \
- AbstractContainer.java \
AccessibleActionImpl.java \
AccessibleComponentImpl.java \
AccessibleEditableTextImpl.java \
@@ -85,6 +84,7 @@ JAVAFILES = \
AccessibleKeyBinding.java \
AccessibleObjectFactory.java \
AccessibleRoleAdapter.java \
+ AccessibleSelectionImpl.java \
AccessibleTextImpl.java \
AccessibleValueImpl.java \
Application.java \
@@ -95,22 +95,21 @@ JAVAFILES = \
Container.java \
DescendantManager.java \
Dialog.java \
+ FocusTraversalPolicy.java \
Frame.java \
Icon.java \
Label.java \
List.java \
Menu.java \
- MenuBar.java \
MenuItem.java \
NativeFrame.java \
- PageTabList.java \
- PopupMenu.java \
RadioButton.java \
ScrollBar.java \
Separator.java \
Table.java \
TextComponent.java \
ToggleButton.java \
+ ToolTip.java \
Tree.java \
Window.java
diff --git a/accessibility/prj/build.lst b/accessibility/prj/build.lst
index 0e88efa15b88..66acf2b75b81 100755
--- a/accessibility/prj/build.lst
+++ b/accessibility/prj/build.lst
@@ -5,4 +5,5 @@ ac accessibility\idl\ nmake - all ac_unomake
ac accessibility\bridge\org\openoffice\java\accessibility nmake - all ac_ooja ac_unomakers NULL
ac accessibility\bridge\source\remote nmake - all ac_abr ac_unomakers NULL
ac accessibility\bridge\org\openoffice\accessibility nmake - all ac_ooa ac_ooja NULL
+ac accessibility\bridge\source nmake - w ac_juab NULL