summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Braun <obr@openoffice.org>2002-12-06 10:25:41 +0000
committerOliver Braun <obr@openoffice.org>2002-12-06 10:25:41 +0000
commit9df11d876f65cb54b7faab25f0832659a0467d01 (patch)
tree48001e0289f157bd516f658f506f027e47ceba8d
parente2e672057a694324bf33088b9c432971b707ae69 (diff)
#100456# post all events to the Java event queue
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java223
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java105
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java258
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java401
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java70
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java107
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java555
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleRelationAdapter.java98
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java208
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java493
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java130
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Application.java79
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Button.java100
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java92
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java246
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Component.java546
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Container.java130
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java220
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Dialog.java529
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Frame.java534
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Icon.java179
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Label.java202
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/List.java499
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Menu.java329
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java102
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java69
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java94
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java266
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Separator.java150
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Table.java546
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java255
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java120
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Tree.java484
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Window.java507
34 files changed, 8526 insertions, 400 deletions
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java b/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java
new file mode 100644
index 000000000000..890c45fd1a89
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AbstractButton.java
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * $RCSfile: AbstractButton.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:30 $
+ *
+ * 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 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 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 abstract class AccessibleAbstractButton extends AccessibleUNOComponent
+ implements AccessibleAction /*, AccessibleExtendedComponent */ {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleAbstractButton() {
+ super();
+ }
+
+ /*
+ * AccessibleContext
+ */
+
+ /**
+ * 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();
+ 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);
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ } catch (NullPointerException e) {
+ }
+ return states;
+ }
+
+ /** Gets the AccessibleAction associated with this object that supports one or more actions */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ return this;
+ }
+
+ /** 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;
+ }
+ }
+
+ /** 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
+ */
+
+ /** Performs the specified Action on the object */
+ public boolean doAccessibleAction(int param) {
+ if (param == 0) {
+ // Actions of MenuItems may also be performed if the item is not
+ // visible, so just try ..
+ try {
+ XAccessibleComponent xAccessibleComponent = AbstractButton.this.unoAccessibleComponent;
+ if (xAccessibleComponent != null) {
+ // Query for XAccessibleValue interface
+ XAccessibleAction xAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class,
+ xAccessibleComponent);
+
+ if (xAccessibleAction != null) {
+ return xAccessibleAction.doAccessibleAction(0);
+ }
+ }
+ }
+
+ // Catch any type of uno exception
+ catch(com.sun.star.uno.Exception e) {
+ return false;
+ }
+ }
+
+ return false;
+ }
+
+ /** Returns a description of the specified action of the object */
+ public java.lang.String getAccessibleActionDescription(int param) {
+ return javax.swing.UIManager.getString("AbstractButton.clickText");
+ }
+
+ /** Returns the number of accessible actions available in this object */
+ public int getAccessibleActionCount() {
+ return 1;
+ }
+ }
+}
+
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java
new file mode 100644
index 000000000000..22bc17dd9c4e
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleActionImpl.java
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleActionImpl.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:30 $
+ *
+ * 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.XAccessibleAction;
+
+/** The AccessibleActionWrapper maps the calls to the java AccessibleAction interface
+ * to the corresponding methods of the UNO XAccessibleAction interface.
+ */
+public class AccessibleActionImpl implements javax.accessibility.AccessibleAction {
+
+ protected XAccessibleAction unoObject;
+
+ /** Creates new AccessibleActionWrapper */
+ public AccessibleActionImpl(XAccessibleAction xAccessibleAction) {
+ unoObject = xAccessibleAction;
+ }
+
+ public boolean doAccessibleAction(int param) {
+ try {
+ return unoObject.doAccessibleAction(param);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ return false;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return false;
+ }
+ }
+
+ public java.lang.String getAccessibleActionDescription(int param) {
+ try {
+ return unoObject.getAccessibleActionDescription(param);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ return null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public int getAccessibleActionCount() {
+ try {
+ return unoObject.getAccessibleActionCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java
new file mode 100644
index 000000000000..538695132916
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleComponentImpl.java
@@ -0,0 +1,258 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleComponentImpl.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:31 $
+ *
+ * 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.AccessibleStateType;
+import drafts.com.sun.star.accessibility.XAccessibleContext;
+import drafts.com.sun.star.accessibility.XAccessibleComponent;
+// import drafts.com.sun.star.accessibility.XAccessibleExtendedComponent;
+import com.sun.star.uno.UnoRuntime;
+
+public class AccessibleComponentImpl implements javax.accessibility.AccessibleComponent {
+
+ protected XAccessibleComponent unoObject;
+// protected XAccessibleExtendedComponent unoAccessibleExtendedComponent = null;
+
+ /** Creates new AccessibleComponentImpl */
+ public AccessibleComponentImpl(XAccessibleComponent xAccessibleComponent) {
+ unoObject = xAccessibleComponent;
+ }
+
+ protected boolean hasState(short state) {
+ try {
+ XAccessibleContext unoAccessibleContext = (XAccessibleContext)
+ UnoRuntime.queryInterface(XAccessibleContext.class, unoObject);
+ // All UNO accessibility implementations must support XAccessibleContext
+ // and return a valid XAccessibleStateSet ..
+ return unoAccessibleContext.getAccessibleStateSet().contains(state);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return false;
+ } catch (java.lang.NullPointerException e) {
+ System.err.println("XAccessibleContext unsupported or no XAccessibleStateSet returned.");
+ return false;
+ }
+ }
+
+ /*
+ * XAccessibleComponent
+ */
+
+ public java.awt.Color getBackground() {
+ try {
+ return new java.awt.Color(unoObject.getBackground());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public void setBackground(java.awt.Color c) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Color getForeground() {
+ try {
+ return new java.awt.Color(unoObject.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 hasState(AccessibleStateType.ENABLED);
+ }
+
+ public void setEnabled(boolean b) {
+ // Not supported by UNO accessibility API
+ }
+
+ public boolean isVisible() {
+ return hasState(AccessibleStateType.VISIBLE);
+ }
+
+ public void setVisible(boolean b) {
+ // Not supported by UNO accessibility API
+ }
+
+ public boolean isShowing() {
+ return hasState(AccessibleStateType.SHOWING);
+ }
+
+ public boolean contains(java.awt.Point p) {
+ try {
+ return unoObject.contains(new com.sun.star.awt.Point(p.x, p.y));
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return false;
+ }
+ }
+
+ public java.awt.Point getLocationOnScreen() {
+ try {
+ com.sun.star.awt.Point unoPoint = unoObject.getLocationOnScreen();
+ return new java.awt.Point(unoPoint.X, unoPoint.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public java.awt.Point getLocation() {
+ try {
+ com.sun.star.awt.Point unoPoint = unoObject.getLocation();
+ return new java.awt.Point( unoPoint.X, unoPoint.Y );
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public void setLocation(java.awt.Point p) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Rectangle getBounds() {
+ try {
+ com.sun.star.awt.Rectangle unoRect = unoObject.getBounds();
+ return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public void setBounds(java.awt.Rectangle r) {
+ // Not supported by UNO accessibility API
+ }
+
+ public java.awt.Dimension getSize() {
+ try {
+ com.sun.star.awt.Size unoSize = unoObject.getSize();
+ return new java.awt.Dimension(unoSize.Width, unoSize.Height);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public void setSize(java.awt.Dimension d) {
+ // Not supported by UNO accessibility API
+ }
+
+ public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) {
+ // Not supported by this implementation
+ return null;
+ }
+
+ public boolean isFocusTraversable() {
+ return hasState(AccessibleStateType.FOCUSABLE);
+ }
+
+ public void requestFocus() {
+ unoObject.grabFocus();
+ }
+
+ /**
+ * Adds the specified focus listener to receive focus events from
+ * this component when this component gains input focus.
+ * If listener <code>l</code> is <code>null</code>,
+ * no exception is thrown and no action is performed.
+ */
+
+ public void addFocusListener(java.awt.event.FocusListener l) {
+ // Not supported by this implementation
+ }
+
+ /**
+ * Removes the specified focus listener so that it no longer
+ * receives focus events from this component. This method performs
+ * no function, nor does it throw an exception, if the listener
+ * specified by the argument was not previously added to this component.
+ * If listener <code>l</code> is <code>null</code>,
+ * no exception is thrown and no action is performed.
+ */
+
+ public void removeFocusListener(java.awt.event.FocusListener l) {
+ // Not supported by this implementation
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java
new file mode 100644
index 000000000000..5ecc9119c000
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleEditableTextImpl.java
@@ -0,0 +1,401 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleEditableTextImpl.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:31 $
+ *
+ * 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 com.sun.star.awt.*;
+import com.sun.star.style.*;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.AccessibleTextType;
+import drafts.com.sun.star.accessibility.XAccessibleEditableText;
+
+import javax.accessibility.AccessibleText;
+import javax.swing.text.StyleConstants;
+
+/** The GenericAccessibleEditableText mapps the calls to the java AccessibleEditableText
+ * interface to the corresponding methods of the UNO XAccessibleEditableText interface.
+ */
+public class AccessibleEditableTextImpl extends AccessibleTextImpl implements javax.accessibility.AccessibleEditableText {
+ final static double toPointFactor = 1 / (7/10 + 34.5);
+
+ /** Creates new GenericAccessibleEditableText object */
+ public AccessibleEditableTextImpl(XAccessibleEditableText xAccessibleEditableText) {
+ super(xAccessibleEditableText);
+ }
+
+ /** Cuts the text between two indices into the system clipboard */
+ public void cut(int startIndex, int endIndex) {
+ try {
+ ((XAccessibleEditableText) unoObject).cutText(startIndex, endIndex);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Deletes the text between two indices */
+ public void delete(int startIndex, int endIndex) {
+ try {
+ ((XAccessibleEditableText) unoObject).deleteText(startIndex, endIndex);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Returns the text range between two indices */
+ public String getTextRange(int startIndex, int endIndex) {
+ try {
+ return unoObject.getTextRange(startIndex, endIndex);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return null;
+ }
+
+ /** Inserts the specified string at the given index */
+ public void insertTextAtIndex(int index, String s){
+ try {
+ ((XAccessibleEditableText) unoObject).insertText(s, index);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Pastes the text form the system clipboard into the text starting at the specified index */
+ public void paste(int startIndex) {
+ try {
+ ((XAccessibleEditableText) unoObject).pasteText(startIndex);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Replaces the text between two indices with the specified string */
+ public void replaceText(int startIndex, int endIndex, String s) {
+ try {
+ ((XAccessibleEditableText) unoObject).replaceText(startIndex, endIndex, s);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Selects the text between two indices */
+ public void selectText(int startIndex, int endIndex) {
+ try {
+ unoObject.setSelection(startIndex, endIndex);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Sets the attributes for the text between two indices */
+ public void setAttributes(int startIndex, int endIndex, javax.swing.text.AttributeSet as) {
+ java.util.Vector propertyValues = new java.util.Vector();
+
+ // Convert Alignment attribute
+ Object attribute = as.getAttribute(StyleConstants.Alignment);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaAdjust";
+
+ switch (StyleConstants.getAlignment(as)) {
+ case StyleConstants.ALIGN_RIGHT:
+ propertyValue.Value = ParagraphAdjust.RIGHT;
+ break;
+ case StyleConstants.ALIGN_CENTER:
+ propertyValue.Value = ParagraphAdjust.CENTER;
+ break;
+ case StyleConstants.ALIGN_JUSTIFIED:
+ propertyValue.Value = ParagraphAdjust.BLOCK;
+ break;
+ default:
+ propertyValue.Value = ParagraphAdjust.LEFT;
+ break;
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ // Convert Background attribute
+ attribute = as.getAttribute(StyleConstants.Background);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharBackColor";
+ propertyValue.Value = new Integer(StyleConstants.getBackground(as).getRGB());
+ propertyValues.add(propertyValue);
+ }
+
+ // FIXME: BidiLevel
+
+ // Set Bold attribute
+ attribute = as.getAttribute(StyleConstants.Bold);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharWeight";
+ if (StyleConstants.isBold(as)) {
+ propertyValue.Value = new Float(150);
+ } else {
+ propertyValue.Value = new Float(100);
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ // FIXME: Java 1.4 ComponentAttribute, ComponentElementName, ComposedTextAttribute
+
+ // Set FirstLineIndent attribute
+ attribute = as.getAttribute(StyleConstants.FirstLineIndent);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaFirstLineIndent";
+ propertyValue.Value = new Double(StyleConstants.getFirstLineIndent(as) / toPointFactor);
+ propertyValues.add(propertyValue);
+ }
+
+ // Set font family attribute
+ attribute = as.getAttribute(StyleConstants.FontFamily);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharFontPitch";
+
+ if (StyleConstants.getFontFamily(as).equals( "Proportional" )) {
+ propertyValue.Value = new Short("2");
+ } else {
+ propertyValue.Value = new Short("1");
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ // Set font size attribute
+ attribute = as.getAttribute(StyleConstants.FontSize);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharHeight";
+ propertyValue.Value = new Integer(StyleConstants.getFontSize(as));
+ propertyValues.add(propertyValue);
+ }
+
+ // Map foreground color
+ attribute = as.getAttribute(StyleConstants.Foreground);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharColor";
+ propertyValue.Value = new Integer (StyleConstants.getForeground(as).getRGB());
+ propertyValues.add(propertyValue);
+ }
+
+ // FIXME: IconAttribute, IconElementName
+
+ // Set italic attribute
+ attribute = as.getAttribute(StyleConstants.Italic);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharPosture";
+
+ if (StyleConstants.isItalic(as)) {
+ propertyValue.Value = FontSlant.ITALIC;
+ } else {
+ propertyValue.Value = FontSlant.DONTKNOW;
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ // Set left indent attribute
+ attribute = as.getAttribute(StyleConstants.LeftIndent);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaFirstLeftMargin";
+ propertyValue.Value = new Integer(new Double(StyleConstants.getLeftIndent(as) / toPointFactor).intValue());
+ propertyValues.add(propertyValue);
+ }
+
+ // Set right indent attribute
+ attribute = as.getAttribute(StyleConstants.RightIndent);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaFirstRightMargin";
+ propertyValue.Value = new Integer(new Double(StyleConstants.getRightIndent(as) / toPointFactor).intValue());
+ propertyValues.add(propertyValue);
+ }
+
+ // Set line spacing attribute
+ attribute = as.getAttribute(StyleConstants.LineSpacing);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaLineSpacing";
+ propertyValue.Value = new Integer(new Double(StyleConstants.getLineSpacing(as) / toPointFactor).intValue());
+ propertyValues.add(propertyValue);
+ }
+
+ // FIXME: Java 1.4 NameAttribute, Orientation, ResolveAttribute
+
+ // Set space above attribute
+ attribute = as.getAttribute(StyleConstants.SpaceAbove);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaTopMargin";
+ propertyValue.Value = new Integer(new Double( StyleConstants.getSpaceAbove(as) / toPointFactor).intValue());
+ propertyValues.add(propertyValue);
+ }
+
+ // Set space below attribute
+ attribute = as.getAttribute(StyleConstants.SpaceBelow);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaBottomMargin";
+ propertyValue.Value = new Integer(new Double(StyleConstants.getSpaceBelow(as) / toPointFactor).intValue());
+ propertyValues.add(propertyValue);
+ }
+
+ // Set strike through attribute
+ attribute = as.getAttribute(StyleConstants.StrikeThrough);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharPosture";
+ if (StyleConstants.isStrikeThrough(as)) {
+ propertyValue.Value = new Short(FontStrikeout.SINGLE);
+ } else {
+ propertyValue.Value = new Short(FontStrikeout.NONE);
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ // Set sub-/superscript attribute
+ attribute = as.getAttribute(StyleConstants.Superscript);
+ if (null == attribute) {
+ attribute = as.getAttribute(StyleConstants.Subscript);
+ }
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharEscapement";
+
+ if (StyleConstants.isSuperscript(as)) {
+ propertyValue.Value = new Short( "1" );
+ } else if (StyleConstants.isSubscript(as)) {
+ propertyValue.Value = new Short( "-1" );
+ } else {
+ propertyValue.Value = new Short( "0" );
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ // Set tabset attribute
+ attribute = as.getAttribute(StyleConstants.TabSet);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "ParaTabStops";
+
+ javax.swing.text.TabSet tabSet = StyleConstants.getTabSet(as);
+ java.util.ArrayList tabStops = new java.util.ArrayList(tabSet.getTabCount());
+
+ for (int i = 0, max = tabSet.getTabCount(); i < max; i++) {
+ javax.swing.text.TabStop tab = tabSet.getTab(i);
+ com.sun.star.style.TabStop unoTab = new com.sun.star.style.TabStop();
+
+ unoTab.Position = new Double(tab.getPosition() / toPointFactor).intValue();
+
+ switch (tab.getAlignment()) {
+ case javax.swing.text.TabStop.ALIGN_CENTER:
+ unoTab.Alignment = TabAlign.CENTER;
+ break;
+ case javax.swing.text.TabStop.ALIGN_RIGHT:
+ unoTab.Alignment = TabAlign.RIGHT;
+ break;
+ case javax.swing.text.TabStop.ALIGN_DECIMAL:
+ unoTab.Alignment = TabAlign.DECIMAL;
+ break;
+ default:
+ unoTab.Alignment = TabAlign.LEFT;
+ break;
+ }
+
+ tabStops.add(unoTab);
+ }
+ propertyValue.Value = (com.sun.star.style.TabStop[]) tabStops.toArray();
+ propertyValues.add(propertyValue);
+ }
+
+ // Set underline attribute
+ attribute = as.getAttribute(StyleConstants.Underline);
+ if (null != attribute) {
+ com.sun.star.beans.PropertyValue propertyValue = new com.sun.star.beans.PropertyValue();
+ propertyValue.Name = "CharUnderline";
+
+ if (StyleConstants.isUnderline(as)) {
+ propertyValue.Value = new Short(FontUnderline.SINGLE);
+ } else {
+ propertyValue.Value = new Short(FontUnderline.NONE);
+ }
+ propertyValues.add(propertyValue);
+ }
+
+ try {
+ ((XAccessibleEditableText) unoObject).setAttributes(startIndex, endIndex, (com.sun.star.beans.PropertyValue[]) propertyValues.toArray());
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Sets the text contents to the specified string */
+ public void setTextContents(String s) {
+ try {
+ ((XAccessibleEditableText) unoObject).setText(s);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java
new file mode 100644
index 000000000000..860ccf871d33
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleExtendedState.java
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleExtendedState.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:31 $
+ *
+ * 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 AccessibleExtendedState extends javax.accessibility.AccessibleState {
+ public static final AccessibleExtendedState MANAGES_DESCENDANTS = new AccessibleExtendedState("managesDescendants");
+
+ protected AccessibleExtendedState(String key) {
+ super(key);
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java
new file mode 100644
index 000000000000..c8498aea6fec
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleIconImpl.java
@@ -0,0 +1,107 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleIconImpl.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:32 $
+ *
+ * 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.XAccessibleImage;
+
+/**
+ */
+public class AccessibleIconImpl implements javax.accessibility.AccessibleIcon {
+
+ XAccessibleImage unoAccessibleImage;
+
+ public AccessibleIconImpl(XAccessibleImage xImage) {
+ unoAccessibleImage = xImage;
+ }
+
+ /** Gets the description of the icon */
+ public String getAccessibleIconDescription() {
+ try {
+ return unoAccessibleImage.getAccessibleImageDescription();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the height of the icon */
+ public int getAccessibleIconHeight() {
+ try {
+ return unoAccessibleImage.getAccessibleImageHeight();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Gets the width of the icon */
+ public int getAccessibleIconWidth() {
+ try {
+ return unoAccessibleImage.getAccessibleImageWidth();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Sets the description of the icon */
+ public void setAccessibleIconDescription(String s) {
+ // Not supported
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java
index d72fe0fc0c61..260a09287253 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleObjectFactory.java
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleObjectFactory.java,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: sab $ $Date: 2002-11-19 13:53:10 $
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:32 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,22 +68,16 @@ import javax.accessibility.Accessible;
import javax.accessibility.AccessibleStateSet;
import com.sun.star.uno.*;
-import drafts.com.sun.star.accessibility.AccessibleRole;
-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.XAccessibleStateSet;
+import drafts.com.sun.star.accessibility.*;
/**
*/
-public class AccessibleObjectFactory implements XGlobalFocusListener {
+public class AccessibleObjectFactory extends java.awt.FocusTraversalPolicy {
// This type is needed for conversions from/to uno Any
- public static final Type XAccessibleType = new Type(XAccessible.class);
public static boolean autoPopulate = true;
java.util.Hashtable objectList = new java.util.Hashtable();
- XAccessibilityInformationProvider infoProvider;
private static AccessibleObjectFactory defaultFactory = new AccessibleObjectFactory();
@@ -97,48 +91,42 @@ public class AccessibleObjectFactory implements XGlobalFocusListener {
return defaultFactory;
}
- /** Sets a new AccessibleInformationProvider to be used by this factory object */
- public void setInformationProvider(XAccessibilityInformationProvider provider) {
- infoProvider = provider;
-// provider.setGlobalFocusListener(this);
+ /** 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 AccessibleInformationProvider currently used by this factory object */
- public XAccessibilityInformationProvider getInformationProvider() {
- return infoProvider;
+ /** 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;
}
- public AccessibleObject getAccessibleObject(XAccessible xAccessible, boolean create, Accessible parent) {
- AccessibleObject o = null;
-
- if(xAccessible != null) {
- // Retrieve unique id for the original UNO object to be used as a hash key
- String oid = UnoRuntime.generateOid(xAccessible);
-
- // Check if we already have a wrapper object for this context
- synchronized (objectList) {
- WeakReference r = (WeakReference) objectList.get(oid);
- if(r != null) {
- o = (AccessibleObject) r.get();
- }
- }
+ /** Returns the default Component to focus */
+ public java.awt.Component getDefaultComponent(java.awt.Container focusCycleRoot) {
+ return null;
+ }
- if( o == null && create ) {
- o = new AccessibleObject(xAccessible, parent);
+ /** Returns the first Component in the traversal cycle */
+ public java.awt.Component getFirstComponent(java.awt.Container focusCycleRoot) {
+ return null;
+ }
- // Add the newly created object to the cache list
- synchronized (objectList) {
- objectList.put(oid, new WeakReference(o));
- if( Build.DEBUG ) {
-// System.out.println("Object cache now contains " + objectList.size() + " objects.");
- }
- }
- }
+ /** 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;
+ }
- return o;
+ /** Returns the last Component in the traversal cycle */
+ public java.awt.Component getLastComponent(java.awt.Container focusCycleRoot) {
+ return null;
}
+/*
public AccessibleUNOComponent createAccessibleContext(XAccessibleContext xAccessibleContext) {
AccessibleUNOComponent ac = null;
@@ -149,21 +137,10 @@ public class AccessibleObjectFactory implements XGlobalFocusListener {
XAccessibleStateSet xStateSet = null;
switch(role) {
- case AccessibleRole.CHECKBOX:
- ac = new AccessibleButton(
- javax.accessibility.AccessibleRole.CHECK_BOX,
- javax.accessibility.AccessibleState.CHECKED,
- xAccessibleContext
- );
- break;
- case AccessibleRole.COMBOBOX:
- ac = new AccessibleComboBox(xAccessibleContext);
- break;
case AccessibleRole.LIST:
ac = new AccessibleList(xAccessibleContext);
break;
case AccessibleRole.MENUBAR:
- case AccessibleRole.PAGETABLIST:
case AccessibleRole.POPUPMENU:
ac = new AccessibleContainer(
AccessibleRoleMap.toAccessibleRole(role),
@@ -214,29 +191,12 @@ public class AccessibleObjectFactory implements XGlobalFocusListener {
case AccessibleRole.PARAGRAPH:
ac = new AccessibleParagraph(xAccessibleContext);
break;
- case AccessibleRole.PUSHBUTTON:
- ac = new AccessibleButton(
- javax.accessibility.AccessibleRole.PUSH_BUTTON,
- javax.accessibility.AccessibleState.SELECTED,
- xAccessibleContext
- );
- break;
- case AccessibleRole.RADIOBUTTON:
- ac = new AccessibleButton(
- javax.accessibility.AccessibleRole.RADIO_BUTTON,
- javax.accessibility.AccessibleState.CHECKED,
- xAccessibleContext
- );
- break;
case AccessibleRole.SCROLLBAR:
ac = new AccessibleScrollBar(xAccessibleContext);
break;
- case AccessibleRole.SEPARATOR:
- ac = new AccessibleSeparator(xAccessibleContext);
- break;
case AccessibleRole.TABLE:
xStateSet = xAccessibleContext.getAccessibleStateSet();
- if(xStateSet != null && ! xStateSet.contains(AccessibleStateType.MANAGES_DESCENDANT)) {
+ if(xStateSet != null && ! xStateSet.contains(AccessibleStateType.CHILDREN_TRANSIENT)) {
ac = new AccessibleTextTable(xAccessibleContext);
} else {
ac = new AccessibleSpreadsheet(xAccessibleContext);
@@ -255,16 +215,9 @@ public class AccessibleObjectFactory implements XGlobalFocusListener {
case AccessibleRole.FOOTER:
case AccessibleRole.FOOTNOTE:
case AccessibleRole.HEADER:
- case AccessibleRole.LAYEREDPANE:
- case AccessibleRole.OPTIONPANE:
- case AccessibleRole.PAGETAB:
+ case AccessibleRole.PAGETABLIST:
case AccessibleRole.PANEL:
- case AccessibleRole.ROOTPANE:
- case AccessibleRole.SCROLLPANE:
- case AccessibleRole.SPLITPANE:
- case AccessibleRole.STATUSBAR:
case AccessibleRole.TOOLBAR:
- case AccessibleRole.WINDOW:
ac = new AccessibleWindow(
AccessibleRoleMap.toAccessibleRole(role),
xAccessibleContext
@@ -275,10 +228,6 @@ public class AccessibleObjectFactory implements XGlobalFocusListener {
System.out.println("Unmapped role: " + AccessibleRoleMap.toAccessibleRole(role)
+ " (id = " + role + ")");
}
- ac = new AccessibleWindow(
- AccessibleRoleMap.toAccessibleRole(role),
- xAccessibleContext
- );
break;
}
@@ -288,152 +237,364 @@ public class AccessibleObjectFactory implements XGlobalFocusListener {
listener = (AccessibleEventListener) ac;
}
- /* The accessible event broadcaster will never be removed by a removeEventListener
- * call. This requires that the UNO accessibility objects get activly destructed
- * using dispose().
- */
- ac.initialize(infoProvider.getAccessibleContextInfo(xAccessibleContext, listener));
- }
-
- catch(com.sun.star.uno.RuntimeException e) {
- }
- }
-
- if( Build.DEBUG && ac == null ) {
- System.out.println("AccessibleObjectFactory: returning null object");
- }
- return ac;
}
-/*
- public AccessibleObject removeAccessibleObject(XAccessible xAccessible) {
- XAccessibleContext xAccessibleContext = null;
-
- if(xAccessible == null) {
- return null;
- }
+*/
+ private java.awt.EventQueue eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
- // Save the round trip to C++ UNO if possible
- if(xAccessible instanceof XAccessibleContext) {
- xAccessibleContext = (XAccessibleContext) xAccessible;
- } else {
- xAccessibleContext = xAccessible.getAccessibleContext();
- }
+ public java.awt.EventQueue getEventQueue() {
+ return eventQueue;
+ }
- // Ensure that we really got an UNO accessible context
- if(xAccessibleContext == null) {
- return null;
- }
+ public 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
+ String oid = UnoRuntime.generateOid(xAccessible);
- // Retrieve unique id for the original UNO object to be used as a hash key
- String oid = UnoRuntime.generateOid(xAccessibleContext);
- AccessibleObject o = null;
- // Check if we already have a wrapper object for this context
- synchronized (objectList) {
- // Do not remove the object from the list, may need to recycle
- // them as long as they are do garbage collected
- WeakReference r = (WeakReference) objectList.get(oid);
- if(r != null) {
- o = (AccessibleObject) r.get();
+ // Check if we already have a wrapper object for this context
+ synchronized (objectList) {
+ WeakReference r = (WeakReference) objectList.get(oid);
+ if(r != null) {
+ c = (java.awt.Component) r.get();
+ }
}
}
-
- // FIXME create dummy for objects not found.
-
- return null;
+ return c;
}
-*/
- public static XAccessible toXAccessible(Object any) {
- if(AnyConverter.isObject(any)) {
+
+ /**
+ * returns the child component that has the initial input focus
+ */
+ protected void populateContainer(java.awt.Container parent, XAccessibleContext parentAC, java.awt.Window frame) {
+ if (parentAC != null) {
try {
- return (XAccessible) AnyConverter.toObject(XAccessibleType, any);
+ int childCount = parentAC.getAccessibleChildCount();
+ for (int i=0; i<childCount; i++) {
+ XAccessible child = parentAC.getAccessibleChild(i);
+ if (child != null) {
+ XAccessibleContext childAC = child.getAccessibleContext();
+ java.awt.Component c = createAccessibleComponent(child, childAC, frame);
+ if (c != null) {
+ if (c instanceof java.awt.Container) {
+ populateContainer((java.awt.Container) c, childAC, frame);
+ }
+ parent.add(c);
+ }
+ } else if (Build.DEBUG) {
+ System.err.println("ignoring not accessible child " + i);
+ }
+ }
}
- catch(com.sun.star.lang.IllegalArgumentException e) {
- // FIXME: output
+ catch (java.lang.Exception e) {
+ System.err.println("Exception caught: " + e.getMessage());
+ e.printStackTrace();
}
}
-
- return null;
}
- public java.lang.Object[] getAccessibleObjectSet(java.lang.Object o) {
- java.lang.Object[] list = null;
-
- if( o instanceof java.lang.Object[] ) {
- list = (java.lang.Object[]) o;
- } else if( o instanceof com.sun.star.uno.Any && AnyConverter.isArray(o) ) {
+ protected java.awt.Component createAccessibleComponent(XAccessible xAccessible) {
+ if (xAccessible != null) {
try {
- list = (java.lang.Object[]) AnyConverter.toArray(o);
- }
-
- catch(com.sun.star.lang.IllegalArgumentException e) {
- // this should never happen
- }
- }
-
- if( list != null ) {
- java.util.ArrayList set = new java.util.ArrayList(list.length);
-
- for(int i=0; i<list.length; i++) {
- AccessibleObject ao = getAccessibleObject(toXAccessible(list[i]), true, null);
- if( ao != null ) {
- set.add(ao);
+ XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext();
+ if (xAccessibleContext != null) {
+ java.awt.Component c = createAccessibleComponentImpl(xAccessible,
+ xAccessibleContext.getAccessibleRole(), (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class,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) {
}
-
- set.trimToSize();
- return set.toArray();
}
-
return null;
}
- public void releaseAccessibleObject(AccessibleObject o) {
- synchronized (objectList) {
- objectList.remove(o.toString());
- if( Build.DEBUG ) {
- System.out.println("Object cache now contains " + objectList.size() + " objects.");
+ protected 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);
+ 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);
+ }
+ }
+ return c;
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ System.err.println("Exception caught: " + e.getMessage());
+ e.printStackTrace();
}
}
+ return null;
}
- // Traverses the accessibility hierarchy to ensure global focus event notifications
- public static void populate(javax.accessibility.AccessibleContext ac) {
- // ignore objects that have transient state
- if( ac != null ) {
- AccessibleStateSet as = ac.getAccessibleStateSet();
- if( null != as &&
- !as.contains(javax.accessibility.AccessibleState.TRANSIENT) &&
- !as.contains(AccessibleStateTypeMap.get(AccessibleStateType.MANAGES_DESCENDANT))
- )
- {
- int n = ac.getAccessibleChildrenCount();
- for( int i = 0; i < n; i++ ) {
- Accessible a = ac.getAccessibleChild(i);
- if( a != null ) {
- populate(a.getAccessibleContext());
- }
+ protected java.awt.Component createAccessibleComponentImpl(XAccessible xAccessible, short role,
+ XAccessibleComponent xAccessibleComponent, XAccessibleStateSet xAccessibleStateSet) {
+ java.awt.Component c = null;
+ switch (role) {
+ case AccessibleRole.CANVAS:
+ c = new Container(javax.accessibility.AccessibleRole.CANVAS,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.CHECKBOX:
+ c = new CheckBox(xAccessible, xAccessibleComponent);
+ 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);
+ }
+ break;
+ case AccessibleRole.DOCUMENT:
+ c = new Container(javax.accessibility.AccessibleRole.CANVAS,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.EMBEDDED_OBJECT:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.ENDNOTE:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.FILLER:
+ c = new Container(javax.accessibility.AccessibleRole.FILLER,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.FOOTNOTE:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.FOOTER:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.GRAPHIC:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.HEADER:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.ICON:
+ c = new Icon(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.LABEL:
+ c = new Label(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.LAYEREDPANE:
+ c = new Container(javax.accessibility.AccessibleRole.LAYERED_PANE,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.LIST:
+ c = new List(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.MENU:
+ c = new Menu(xAccessible, xAccessibleComponent);
+ // !!! FIXME !!!
+ // Menu items are always visible, but change SHOWING state
+// if (!xAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
+// c.setVisible(false);
+// }
+ break;
+ case AccessibleRole.MENUBAR:
+ c = new MenuBar(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.MENUITEM:
+ c = new MenuItem(xAccessible, xAccessibleComponent);
+ c.setFocusable(false);
+ // Menu items are always visible, but change SHOWING state
+// if (!xAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
+// c.setVisible(false);
+// }
+ break;
+ case AccessibleRole.POPUPMENU:
+ c = new PopupMenu(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.OPTIONPANE:
+ c = new Container(javax.accessibility.AccessibleRole.OPTION_PANE,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.PAGETAB:
+ c = new Container(javax.accessibility.AccessibleRole.PAGE_TAB,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.PAGETABLIST:
+ c = new PageTabList(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.PARAGRAPH:
+ case AccessibleRole.HEADING:
+ c = new TextComponent(xAccessible, xAccessibleComponent, true);
+ break;
+ case AccessibleRole.PANEL:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.PUSHBUTTON:
+ c = new Button(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.RADIOBUTTON:
+ c = new RadioButton(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.ROOTPANE:
+ c = new Container(javax.accessibility.AccessibleRole.ROOT_PANE,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.SCROLLBAR:
+ if (xAccessibleStateSet.contains(AccessibleStateType.VERTICAL)) {
+ c = new ScrollBar(xAccessible, xAccessibleComponent,
+ javax.swing.SwingConstants.VERTICAL);
+ } else {
+ c = new ScrollBar(xAccessible, xAccessibleComponent);
+ }
+ break;
+ case AccessibleRole.SCROLLPANE:
+ c = new Container(javax.accessibility.AccessibleRole.SCROLL_PANE,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.SEPARATOR:
+ if (xAccessibleStateSet.contains(AccessibleStateType.VERTICAL)) {
+ c = new Separator(xAccessible, xAccessibleComponent,
+ javax.swing.SwingConstants.VERTICAL);
+ } else {
+ c = new Separator(xAccessible, xAccessibleComponent);
+ }
+ break;
+ case AccessibleRole.SHAPE:
+ c = new Container(javax.accessibility.AccessibleRole.CANVAS,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.SPLITPANE:
+ c = new Container(javax.accessibility.AccessibleRole.SPLIT_PANE,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.STATUSBAR:
+ c = new Container(javax.accessibility.AccessibleRole.STATUS_BAR,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.TABLE:
+ c = new Table(xAccessible, xAccessibleComponent,
+ xAccessibleStateSet.contains(AccessibleStateType.MULTISELECTABLE));
+ break;
+ case AccessibleRole.TEXT:
+ c = new TextComponent(xAccessible, xAccessibleComponent,
+ xAccessibleStateSet.contains(AccessibleStateType.MULTILINE));
+ break;
+ case AccessibleRole.TEXT_FRAME:
+ c = new Container(javax.accessibility.AccessibleRole.PANEL,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.TOGGLEBUTTON:
+ c = new ToggleButton(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.TOOLBAR:
+ c = new Container(javax.accessibility.AccessibleRole.TOOL_BAR,
+ xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.TREE:
+ c = new Tree(xAccessible, xAccessibleComponent);
+ break;
+ case AccessibleRole.VIEWPORT:
+ c = new Container(javax.accessibility.AccessibleRole.VIEWPORT,
+ xAccessible, xAccessibleComponent);
+ 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);
+ break;
+ }
+ if (c != null) {
+ // Add the newly created object to the cache list
+ synchronized (objectList) {
+ objectList.put(c.toString(), new WeakReference(c));
+ if (Build.DEBUG) {
+// System.out.println("Object cache now contains " + objectList.size() + " objects.");
}
}
+ // Set the boundings of the component if it is visible ..
+ if (xAccessibleStateSet.contains(AccessibleStateType.VISIBLE)) {
+ com.sun.star.awt.Rectangle r = xAccessibleComponent.getBounds();
+ c.setBounds(r.X, r.Y, r.Width, r.Height);
+ } else {
+ c.setVisible(false);
+ }
+ // Set the components' enabled enabled..
+ if (!xAccessibleStateSet.contains(AccessibleStateType.ENABLED)) {
+ c.setEnabled(false);
+ }
}
- }
- /*
- * XGlobalFocusListener
- */
-
- public void focusGained(XAccessible xAccessible) {
- AccessibleObject ao = getAccessibleObject(xAccessible, true, null);
- if( ao != null ) {
- ao.processFocusGained();
- }
+ return c;
}
- public void focusLost(XAccessible xAccessible) {
- AccessibleObject ao = getAccessibleObject(xAccessible, false, null);
- if( ao != null ) {
- ao.processFocusLost();
+/*
+ protected java.? createTransientObject()
+*/
+ public java.awt.Window getTopWindow(XAccessible xAccessible) {
+ XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext();
+
+ if (xAccessibleContext != null) {
+ short role = xAccessibleContext.getAccessibleRole();
+ XAccessibleStateSet xAccessibleStateSet = xAccessibleContext.getAccessibleStateSet();
+ XAccessibleComponent xAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class, xAccessibleContext);
+
+ java.awt.Window w;
+ if (role == AccessibleRole.DIALOG) {
+ w = new Dialog(new Application(),
+ xAccessibleContext.getAccessibleName(),
+ xAccessibleStateSet.contains(AccessibleStateType.MODAL),
+ xAccessibleComponent);
+ } else if (role == AccessibleRole.FRAME) {
+ w = new Frame(xAccessibleContext.getAccessibleName(),
+ xAccessibleComponent);
+ } else if (role == AccessibleRole.WINDOW) {
+ w = new Window(new Application(), xAccessibleComponent);
+ } else {
+ if (Build.DEBUG) {
+ System.err.println("invalid role for toplevel window: " + role);
+ }
+ w = new Window(new Application(), xAccessibleComponent);
+// return null;
+ }
+ populateContainer(w, xAccessibleContext, w);
+ w.setFocusTraversalPolicy(this);
+ w.setVisible(true);
+ // Post window gained focus event to let the frame/dialog become active
+ if (xAccessibleStateSet.contains(AccessibleStateType.ACTIVE)) {
+ getEventQueue().postEvent(new java.awt.event.WindowEvent(w, java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS));
+ }
+ return w;
}
+
+ return null;
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRelationAdapter.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRelationAdapter.java
new file mode 100644
index 000000000000..be0611093156
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRelationAdapter.java
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleRelationAdapter.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:32 $
+ *
+ * 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.Accessible;
+import drafts.com.sun.star.accessibility.AccessibleRelation;
+import drafts.com.sun.star.accessibility.XAccessible;
+
+/**
+ */
+public abstract class AccessibleRelationTypeMap {
+
+ final static String[] data = {
+ null,
+ javax.accessibility.AccessibleRelation.CONTROLLED_BY,
+ javax.accessibility.AccessibleRelation.CONTROLLED_BY_PROPERTY,
+ javax.accessibility.AccessibleRelation.CONTROLLER_FOR,
+ javax.accessibility.AccessibleRelation.CONTROLLER_FOR_PROPERTY,
+ javax.accessibility.AccessibleRelation.LABEL_FOR,
+ javax.accessibility.AccessibleRelation.LABEL_FOR_PROPERTY,
+ javax.accessibility.AccessibleRelation.LABELED_BY,
+ javax.accessibility.AccessibleRelation.LABELED_BY_PROPERTY,
+ javax.accessibility.AccessibleRelation.MEMBER_OF,
+ javax.accessibility.AccessibleRelation.MEMBER_OF_PROPERTY
+ };
+
+ public static void fillAccessibleRelationSet(javax.accessibility.AccessibleRelationSet s, AccessibleRelation[] relations) {
+ AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
+ for(int i=0; i<relations.length; i++) {
+ if( relations[i].RelationType < data.length && data[relations[i].RelationType] != null ) {
+ javax.accessibility.AccessibleRelation r =
+ new javax.accessibility.AccessibleRelation(data[relations[i].RelationType]);
+
+ r.setTarget(factory.getAccessibleObjectSet(relations[i].TargetSet));
+ s.add(r);
+ }
+ }
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java
new file mode 100644
index 000000000000..46e641ca8749
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleRoleAdapter.java
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleRoleAdapter.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:32 $
+ *
+ * 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.XAccessible;
+
+/** This class maps the AccessibleRole(s) of the UNO accessibility API
+ * to the corresponding javax.accessibility objects.
+ */
+public abstract class AccessibleRoleAdapter {
+
+ /* This array is used as a mapping between the UNO AccessibleRole
+ * and the AccessibleRole objects of the Java accessibility API.
+ */
+ public static final javax.accessibility.AccessibleRole[] data = {
+ javax.accessibility.AccessibleRole.UNKNOWN,
+ javax.accessibility.AccessibleRole.ALERT,
+ javax.accessibility.AccessibleRole.AWT_COMPONENT,
+ javax.accessibility.AccessibleRole.COLUMN_HEADER,
+ javax.accessibility.AccessibleRole.CANVAS,
+ javax.accessibility.AccessibleRole.CHECK_BOX,
+ javax.accessibility.AccessibleRole.COLOR_CHOOSER,
+ javax.accessibility.AccessibleRole.COMBO_BOX,
+ javax.accessibility.AccessibleRole.DATE_EDITOR,
+ javax.accessibility.AccessibleRole.DESKTOP_ICON,
+ javax.accessibility.AccessibleRole.DESKTOP_PANE,
+ javax.accessibility.AccessibleRole.DIRECTORY_PANE,
+ javax.accessibility.AccessibleRole.DIALOG,
+ javax.accessibility.AccessibleRole.FILE_CHOOSER,
+ javax.accessibility.AccessibleRole.FILLER,
+ javax.accessibility.AccessibleRole.FONT_CHOOSER,
+ javax.accessibility.AccessibleRole.FRAME,
+ javax.accessibility.AccessibleRole.GLASS_PANE,
+ javax.accessibility.AccessibleRole.GROUP_BOX,
+ javax.accessibility.AccessibleRole.HYPERLINK,
+ javax.accessibility.AccessibleRole.ICON,
+ javax.accessibility.AccessibleRole.INTERNAL_FRAME,
+ javax.accessibility.AccessibleRole.LABEL,
+ javax.accessibility.AccessibleRole.LAYERED_PANE,
+ javax.accessibility.AccessibleRole.LIST,
+ javax.accessibility.AccessibleRole.LIST_ITEM,
+ javax.accessibility.AccessibleRole.MENU,
+ javax.accessibility.AccessibleRole.MENU_BAR,
+ javax.accessibility.AccessibleRole.MENU_ITEM,
+ javax.accessibility.AccessibleRole.OPTION_PANE,
+ javax.accessibility.AccessibleRole.PAGE_TAB,
+ javax.accessibility.AccessibleRole.PAGE_TAB_LIST,
+ javax.accessibility.AccessibleRole.PANEL,
+ javax.accessibility.AccessibleRole.PASSWORD_TEXT,
+ javax.accessibility.AccessibleRole.POPUP_MENU,
+ javax.accessibility.AccessibleRole.PUSH_BUTTON,
+ javax.accessibility.AccessibleRole.PROGRESS_BAR,
+ javax.accessibility.AccessibleRole.RADIO_BUTTON,
+ javax.accessibility.AccessibleRole.ROW_HEADER,
+ javax.accessibility.AccessibleRole.ROOT_PANE,
+ javax.accessibility.AccessibleRole.SCROLL_BAR,
+ javax.accessibility.AccessibleRole.SCROLL_PANE,
+ javax.accessibility.AccessibleRole.SEPARATOR,
+ javax.accessibility.AccessibleRole.SLIDER,
+ javax.accessibility.AccessibleRole.SPIN_BOX,
+ javax.accessibility.AccessibleRole.SPLIT_PANE,
+ javax.accessibility.AccessibleRole.STATUS_BAR,
+ javax.accessibility.AccessibleRole.SWING_COMPONENT,
+ javax.accessibility.AccessibleRole.TABLE,
+ javax.accessibility.AccessibleRole.TEXT,
+ javax.accessibility.AccessibleRole.TOGGLE_BUTTON,
+ javax.accessibility.AccessibleRole.TOOL_BAR,
+ javax.accessibility.AccessibleRole.TOOL_TIP,
+ javax.accessibility.AccessibleRole.TREE,
+ javax.accessibility.AccessibleRole.VIEWPORT,
+ javax.accessibility.AccessibleRole.WINDOW,
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ null, // RESERVED
+ javax.accessibility.AccessibleRole.CANVAS, // DOCUMENT
+ javax.accessibility.AccessibleRole.PANEL, // HEADER
+ javax.accessibility.AccessibleRole.PANEL, // FOOTER
+ javax.accessibility.AccessibleRole.TEXT, // PARAGRAPH
+ javax.accessibility.AccessibleRole.TEXT, // HEADING
+ javax.accessibility.AccessibleRole.LABEL, // TABLE_CELL - required by ZoomText
+ javax.accessibility.AccessibleRole.PANEL, // TEXT_FRAME
+ javax.accessibility.AccessibleRole.PANEL, // GRAPHIC
+ javax.accessibility.AccessibleRole.PANEL, // EMBEDDED_OBJECT
+ javax.accessibility.AccessibleRole.PANEL, // ENDNOTE
+ javax.accessibility.AccessibleRole.PANEL, // FOOTNOTE
+ javax.accessibility.AccessibleRole.CANVAS // SHAPE
+ };
+
+ public static javax.accessibility.AccessibleRole getAccessibleRole(short role) {
+ if(role < data.length) {
+ if(data[role] == null) {
+ System.err.println("Unmapped role: " + role);
+ }
+ return data[role];
+ }
+ // FIXME: remove debug out
+ System.err.println("Unmappable role: " + role);
+ return null;
+ }
+
+ public static javax.accessibility.AccessibleRole getAccessibleRole(XAccessible unoAccessible) {
+ try {
+ return getAccessibleRole(unoAccessible.getAccessibleContext().getAccessibleRole());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return javax.accessibility.AccessibleRole.UNKNOWN;
+ }
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java
index 47ff94a607d9..174c1e5025be 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleTextImpl.java
@@ -2,9 +2,9 @@
*
* $RCSfile: AccessibleTextImpl.java,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: obr $ $Date: 2002-10-08 06:48:02 $
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:33 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,280 +61,367 @@
package org.openoffice.java.accessibility;
-import java.text.BreakIterator;
-import java.util.Locale;
-import javax.accessibility.AccessibleContext;
-import javax.accessibility.AccessibleComponent;
+import com.sun.star.awt.*;
+import com.sun.star.style.*;
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
+
import javax.accessibility.AccessibleText;
-import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
-import org.openoffice.accessibility.internal.*;
-
-import com.sun.star.awt.Point;
-import com.sun.star.awt.Rectangle;
-import com.sun.star.uno.UnoRuntime;
-
-import drafts.com.sun.star.accessibility.XAccessibleText;
-
-/** This class mapps the methods of a AccessibleText the corresponding UNO
- XAccessibleText methods with two exceptions: because the gnome java
- accessbridge relies on the behavior of the java word iterator that
- handles punctuation characters as word (see java docu for details),
- for objects not implementing AccessibleEditableText, the iteration
- is done locally. Also the character attributes are calculated through
- the AccessibleContext interface ..
-*/
+/** The GenericAccessibleEditableText mapps the calls to the java AccessibleEditableText
+ * interface to the corresponding methods of the UNO XAccessibleEditableText interface.
+ */
public class AccessibleTextImpl implements javax.accessibility.AccessibleText {
- XAccessibleText unoAccessibleText;
+ XAccessibleText unoObject;
- AccessibleContext context;
- String text;
+ final static double toPointFactor = 1 / (7/10 + 34.5);
- public AccessibleTextImpl(XAccessibleText xText, AccessibleContext ac) {
- unoAccessibleText = xText;
- context = ac;
-
- if( unoAccessibleText != null ) {
- text = unoAccessibleText.getText();
- } else {
- text = "";
- }
+ /** Creates new GenericAccessibleEditableText object */
+ public AccessibleTextImpl(XAccessibleText xAccessibleText) {
+ unoObject = xAccessibleText;
}
- public void update() {
- if( unoAccessibleText != null ) {
- text = unoAccessibleText.getText();
- }
- }
-
- /*
- * AccessibleText
- */
-
- /** Returns the string after a given index */
- public java.lang.String getAfterIndex(int part, int index) {
- BreakIterator bi;
- int start;
- int end;
-
+ protected static short toTextType(int part) {
+ short type = 0;
switch (part) {
case AccessibleText.CHARACTER:
- start = index + 1;
- end = index + 2;
+ type = AccessibleTextType.CHARACTER;
break;
case AccessibleText.WORD:
- bi = BreakIterator.getWordInstance(context.getLocale());
- bi.setText(text);
- start = bi.following(index);
- end = bi.next();
+ type = AccessibleTextType.WORD;
break;
case AccessibleText.SENTENCE:
- bi = BreakIterator.getSentenceInstance(context.getLocale());
- bi.setText(text);
- start = bi.following(index);
- end = bi.next();
+ type = AccessibleTextType.SENTENCE;
break;
default:
- throw new IllegalArgumentException();
- }
-
- // Ensure start is in valid range
- if( start < 0 ) {
- start = 0;
+ break;
}
+ return type;
+ }
- // Ensure end is in valid range
- if( end > text.length() ) {
- end = text.length();
+ /** Returns the string after a given index */
+ public String getAfterIndex(int part, int index) {
+ 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
+ String s = unoObject.getTextBehindIndex(index, type);
+ if ((part == AccessibleText.WORD) && (s.length() == 0)) {
+ s = " ";
+ }
+ return s;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
}
-
- return text.substring(start, end);
+ return null;
}
/** Returns the zero-based offset of the caret */
public int getCaretPosition() {
- // A fixed text does not really have a caret
- return -1;
+ try {
+// if (Build.DEBUG) {
+// System.err.println(this + "getCaretPosition() returns " + unoObject.getCaretPosition());
+// }
+ return unoObject.getCaretPosition();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return -1;
+ }
}
/** Returns the start offset within the selected text */
public int getSelectionStart() {
- // In fixed text nothing can be selected, so return the caret position as specified
- // in AccessibleText docu.
- return getCaretPosition();
+ try {
+ int index = unoObject.getSelectionStart();
+ if (index == -1) {
+ index = getCaretPosition();
+ }
+ return index;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return -1;
+ }
}
- /** Returns the AttributSet for a given character at a given index */
- public javax.swing.text.AttributeSet getCharacterAttribute(int index) {
- if( index > 0 && index < getCharCount() ) {
- SimpleAttributeSet as = new SimpleAttributeSet();
- AccessibleComponent ac = context.getAccessibleComponent();
-
- // Fixed text has always the default colors
- StyleConstants.setBackground(as, ac.getBackground());
- StyleConstants.setForeground(as, ac.getForeground());
-
- // Retrieve the information by querying the UI font
- java.awt.Font f = ac.getFont();
- if(f != null) {
- StyleConstants.setFontFamily(as, f.getFamily());
- StyleConstants.setFontSize(as, f.getSize());
- StyleConstants.setBold(as, f.isBold());
- StyleConstants.setItalic(as, f.isItalic());
+ protected static 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.equals(ParagraphAdjust.LEFT)) {
+ StyleConstants.setAlignment(as, StyleConstants.ALIGN_LEFT);
+ } else if (adjust.equals(ParagraphAdjust.RIGHT)) {
+ StyleConstants.setAlignment(as, StyleConstants.ALIGN_RIGHT);
+ } else if (adjust.equals(ParagraphAdjust.CENTER)) {
+ StyleConstants.setAlignment(as, StyleConstants.ALIGN_CENTER);
+ } else if (adjust.equals(ParagraphAdjust.BLOCK) || adjust.equals(ParagraphAdjust.STRETCH)) {
+ StyleConstants.setAlignment(as, StyleConstants.ALIGN_JUSTIFIED);
+ }
+
+ // Map background color
+ } else if (property.Name.equals("CharBackColor")) {
+ StyleConstants.setBackground(as, new java.awt.Color(AnyConverter.toInt(property.Value)));
+
+ // FIXME: BidiLevel
+
+ // Set bold attribute
+ } else if (property.Name.equals("CharWeight")) {
+ boolean isBold = AnyConverter.toFloat(property.Value) > 125;
+ StyleConstants.setBold(as, isBold);
+
+ // FIXME: Java 1.4 ComponentAttribute, ComponentElementName, ComposedTextAttribute
+
+ // Set FirstLineIndent attribute
+ } else if (property.Name.equals("ParaFirstLineIndent")) {
+ StyleConstants.setFirstLineIndent(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
+
+ // Set font family attribute
+ } else if (property.Name.equals("CharFontPitch")) {
+ if (AnyConverter.toShort (property.Value) == 2) {
+ StyleConstants.setFontFamily(as, "Proportional");
+ }
+
+ // Set font size attribute
+ } else if (property.Name.equals("CharHeight")) {
+ StyleConstants.setFontSize(as, (int) AnyConverter.toFloat(property.Value));
+
+ // Map foreground color
+ } else if (property.Name.equals("CharColor")) {
+ StyleConstants.setForeground(as, new java.awt.Color(AnyConverter.toInt(property.Value)));
+
+ // FIXME: IconAttribute, IconElementName
+
+ // 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);
+
+ // Set left indent attribute
+ } else if (property.Name.equals("ParaLeftMargin")) {
+ StyleConstants.setLeftIndent(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
+
+ // Set right indent attribute
+ } else if (property.Name.equals("ParaRightMargin")) {
+ StyleConstants.setRightIndent(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
}
- // Retrieve the real character attributes from the live object
- // StyleConstants.setUnderline(as, 0 != (attributes & CharacterAttributes.UNDERLINE));
-
- return as;
- }
+ // Set line spacing attribute
+ else if (property.Name.equals("ParaLineSpacing")) {
+ StyleConstants.setLineSpacing(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
+ }
- return null;
- }
+ // FIXME: Java 1.4 NameAttribute, Orientation, ResolveAttribute
- /** Given a point in local ccordinates, return the zero-based index of the character under that point */
- public int getIndexAtPoint(java.awt.Point point) {
- int ret = -1;
+ // Set space above attribute
+ else if (property.Name.equals("ParaTopMargin")) {
+ StyleConstants.setSpaceAbove(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
+ }
- try {
- if( unoAccessibleText != null ) {
- ret = unoAccessibleText.getIndexAtPoint(new Point( point.x, point.y ));
+ // Set space below attribute
+ else if (property.Name.equals("ParaBottomMargin")) {
+ StyleConstants.setSpaceBelow(as, (float) (toPointFactor * AnyConverter.toInt(property.Value)));
+
+ // Set strike through attribute
+ } else if (property.Name.equals("CharStrikeout")) {
+ boolean isStrikeThrough = (FontStrikeout.NONE != AnyConverter.toShort(property.Value));
+ StyleConstants.setStrikeThrough(as, isStrikeThrough);
+
+ // Set sub-/superscript attribute
+ } else if (property.Name.equals("CharEscapement")) {
+ short value = AnyConverter.toShort(property.Value);
+ if (value > 0) {
+ StyleConstants.setSuperscript(as, true);
+ } else if (value < 0) {
+ StyleConstants.setSubscript(as, true);
+ }
+
+ // Set tabset attribute
+ } else if (property.Name.equals("ParaTabStops")) {
+ TabStop[] unoTabStops = (TabStop[]) AnyConverter.toArray(property.Value);
+ java.util.ArrayList tabStops = new java.util.ArrayList(unoTabStops.length);
+
+ for (int index2 = 0; index2 < unoTabStops.length; index2++) {
+ float pos = (float) (toPointFactor * unoTabStops[index2].Position);
+
+ if (unoTabStops[index2].Alignment.equals(TabAlign.LEFT)) {
+ tabStops.add(new javax.swing.text.TabStop(pos,
+ javax.swing.text.TabStop.ALIGN_LEFT,
+ javax.swing.text.TabStop.LEAD_NONE)
+ );
+ }
+ else if (unoTabStops[index2].Alignment.equals(TabAlign.CENTER)) {
+ tabStops.add(new javax.swing.text.TabStop(pos,
+ javax.swing.text.TabStop.ALIGN_CENTER,
+ javax.swing.text.TabStop.LEAD_NONE)
+ );
+ }
+ else if (unoTabStops[index2].Alignment.equals(TabAlign.RIGHT)) {
+ tabStops.add(new javax.swing.text.TabStop(pos,
+ javax.swing.text.TabStop.ALIGN_RIGHT,
+ javax.swing.text.TabStop.LEAD_NONE)
+ );
+ }
+ else if (unoTabStops[index2].Alignment.equals(TabAlign.DECIMAL)) {
+ tabStops.add(new javax.swing.text.TabStop(pos,
+ javax.swing.text.TabStop.ALIGN_DECIMAL,
+ javax.swing.text.TabStop.LEAD_NONE)
+ );
+ }
+ else {
+ tabStops.add(new javax.swing.text.TabStop(pos));
+ }
+ }
+
+ StyleConstants.setTabSet(as, new javax.swing.text.TabSet((javax.swing.text.TabStop[]) tabStops.toArray()));
+
+ // Set underline attribute
+ } else if (property.Name.equals("CharUnderline")) {
+ boolean isUnderline = (FontUnderline.NONE != AnyConverter.toShort(property.Value));
+ StyleConstants.setUnderline(as, isUnderline);
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ if (Build.DEBUG) {
+ System.err.println(e.getMessage());
}
}
+ }
- catch(com.sun.star.uno.RuntimeException e) {
- if( Build.DEBUG ) {
- System.err.println("Exception caught for getIndexAtPoint(" + point.x + ", " + point.y + ")");
+ /** Returns the AttributSet for a given character at a given index */
+ public javax.swing.text.AttributeSet getCharacterAttribute(int param) {
+ try {
+ com.sun.star.beans.PropertyValue[] propertyValues = unoObject.getCharacterAttributes(param);
+ 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]);
+ }
+ }
+ return attributeSet;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ if (Build.DEBUG) {
System.err.println(e.getMessage());
}
+ return null;
}
+ }
- catch(Exception e) {
- if( Build.DEBUG ) {
+ /** Given a point in local coordinates, return the zero-based index of the character under that point */
+ public int getIndexAtPoint(java.awt.Point point) {
+ try {
+// if (Build.DEBUG) {
+// System.err.println(this + "getIndexAtPoint(" + point.x + ", " + point.y + ") returns " +
+// unoObject.getIndexAtPoint(new Point(point.x, point.y)));
+// }
+ return unoObject.getIndexAtPoint(new Point(point.x, point.y));
+ } catch (com.sun.star.uno.RuntimeException e) {
+ if (Build.DEBUG) {
System.err.println("Exception caught for getIndexAtPoint(" + point.x + ", " + point.y + ")");
System.err.println(e.getMessage());
}
+ return -1;
}
-
- return ret;
}
/** Returns the end offset within the selected text */
public int getSelectionEnd() {
- // In fixed text nothing can be selected, so return the caret position as specified
- // in AccessibleText docu.
- return getCaretPosition();
+ try {
+ int index = unoObject.getSelectionEnd();
+ if (index == -1) {
+ index = getCaretPosition();
+ }
+ return index;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return -1;
+ }
}
/** Returns the string before a given index */
public java.lang.String getBeforeIndex(int part, int index) {
- BreakIterator bi;
- int start;
- int end;
-
- switch (part) {
- case AccessibleText.CHARACTER:
- start = index - 1;
- end = index;
- break;
- case AccessibleText.WORD:
- bi = BreakIterator.getWordInstance(context.getLocale());
- bi.setText(text);
- end = bi.preceding(index);
- start = bi.previous();
- break;
- case AccessibleText.SENTENCE:
- bi = BreakIterator.getSentenceInstance(context.getLocale());
- bi.setText(text);
- end = bi.preceding(index);
- start = bi.previous();
- break;
- default:
- throw new IllegalArgumentException();
- }
-
- // Ensure start is in valid range
- if( start < 0 ) {
- start = 0;
- }
-
- // Ensure end is in valid range
- if( end > text.length() ) {
- end = text.length();
+ 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
+ String s = unoObject.getTextBeforeIndex(index, type);
+ if ((part == AccessibleText.WORD) && (s.length() == 0)) {
+ s = " ";
+ }
+ return s;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
}
-
- return text.substring(start, end);
+ return null;
}
/** Returns the string at a given index */
- public java.lang.String getAtIndex(int part, int index) {
- BreakIterator bi;
- int start;
- int end;
-
- switch (part) {
- case AccessibleText.CHARACTER:
- start = index;
- end = index + 1;
- break;
- case AccessibleText.WORD:
- bi = BreakIterator.getWordInstance(context.getLocale());
- bi.setText(text);
- end = bi.following(index);
- start = bi.previous();
- break;
- case AccessibleText.SENTENCE:
- bi = BreakIterator.getSentenceInstance(context.getLocale());
- bi.setText(text);
- end = bi.following(index);
- start = bi.previous();
- break;
- default:
- throw new IllegalArgumentException();
- }
-
- // Ensure start is in valid range
- if( start < 0 ) {
- start = 0;
- }
-
- // Ensure end is in valid range
- if( end > text.length() ) {
- end = text.length();
+ public java.lang.String getAtIndex(int part, int index) {
+ 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
+ String s = unoObject.getTextAtIndex(index, type);
+ if ((part == AccessibleText.WORD) && (s.length() == 0)) {
+ s = " ";
+ }
+ return s;
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
}
-
- return text.substring(start, end);
+ return null;
}
/** Returns the number of characters (valid indicies) */
public int getCharCount() {
- return text.length();
+ try {
+ return unoObject.getCharacterCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return 0;
}
/** Returns the portion of the text that is selected */
public java.lang.String getSelectedText() {
- // Nothing selected
+ try {
+ return unoObject.getSelectedText();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
return null;
}
/** Determines the bounding box of the character at the given index into the string */
public java.awt.Rectangle getCharacterBounds(int index) {
- if( index < text.length() ) {
- try {
- Rectangle unoRect = unoAccessibleText.getCharacterBounds(index);
- return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height);
- }
-
- catch ( com.sun.star.lang.IndexOutOfBoundsException exception ) {
- // FIXME: The java AccessBridge currently does not handle such exceptions gracefully
- // throw new IndexOutOfBoundsException( exception.getMessage() );
- }
+ try {
+ Rectangle unoRect = unoObject.getCharacterBounds(index);
+ return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height);
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return null;
+ }
- catch ( NullPointerException e ) {
+ public String toString() {
+ try {
+ XAccessibleContext unoAccessibleContext = (XAccessibleContext)
+ UnoRuntime.queryInterface(XAccessibleContext.class, unoObject);
+ if (unoAccessibleContext != null) {
+ return "[" + AccessibleRoleAdapter.getAccessibleRole(unoAccessibleContext.getAccessibleRole()) + "] " +
+ unoAccessibleContext.getAccessibleName() + ": ";
+ } else {
+ return super.toString();
}
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return super.toString();
}
-
- return new java.awt.Rectangle();
}
}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java
new file mode 100644
index 000000000000..2f51de72da14
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/AccessibleValueImpl.java
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * $RCSfile: AccessibleValueImpl.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:33 $
+ *
+ * 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.XAccessibleValue;
+import com.sun.star.uno.AnyConverter;
+
+/** The AccessibleValueImpl mappes the calls to the java AccessibleValue
+ * interface to the corresponding methods of the UNO XAccessibleValue interface
+ */
+public class AccessibleValueImpl implements javax.accessibility.AccessibleValue {
+ protected XAccessibleValue unoObject;
+
+ /** Creates new AccessibleValueImpl */
+ public AccessibleValueImpl(XAccessibleValue xAccessibleValue) {
+ unoObject = xAccessibleValue;
+ }
+
+ public static java.lang.Number toNumber(java.lang.Object any) {
+ try {
+ if(AnyConverter.isByte(any)) {
+ return new Byte(AnyConverter.toByte(any));
+ } else if (AnyConverter.isShort(any)) {
+ return new Short(AnyConverter.toShort(any));
+ } else if (AnyConverter.isInt(any)) {
+ return new Integer(AnyConverter.toInt(any));
+ } else if (AnyConverter.isLong(any)) {
+ return new Long(AnyConverter.toLong(any));
+ } else if (AnyConverter.isFloat(any)) {
+ return new Float(AnyConverter.toFloat(any));
+ } else if (AnyConverter.isDouble(any)) {
+ return new Double(AnyConverter.toDouble(any));
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+
+ return null;
+ }
+
+ public java.lang.Number getMinimumAccessibleValue() {
+ try {
+ return toNumber(unoObject.getMinimumValue());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public java.lang.Number getCurrentAccessibleValue() {
+ try {
+ return toNumber(unoObject.getCurrentValue());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public java.lang.Number getMaximumAccessibleValue() {
+ try {
+ return toNumber(unoObject.getMaximumValue());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ public boolean setCurrentAccessibleValue(java.lang.Number number) {
+ try {
+ return unoObject.setCurrentValue(number);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return false;
+ }
+ }
+}
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Application.java b/accessibility/bridge/org/openoffice/java/accessibility/Application.java
new file mode 100644
index 000000000000..96f53c9b6d51
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Application.java
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * $RCSfile: Application.java,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: obr $ $Date: 2002-12-06 11:25:33 $
+ *
+ * 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.Accessible;
+import javax.accessibility.AccessibleContext;
+
+public class Application extends java.awt.Frame implements Accessible {
+
+ protected AccessibleContext accessibleContext = null;
+
+ protected Application() {
+ super();
+ }
+
+ public boolean isShowing() {
+ return true;
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Button.java b/accessibility/bridge/org/openoffice/java/accessibility/Button.java
new file mode 100644
index 000000000000..a5cc63a3faf2
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Button.java
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.Accessible;
+import javax.accessibility.AccessibleContext;
+
+import drafts.com.sun.star.accessibility.XAccessible;
+import drafts.com.sun.star.accessibility.XAccessibleComponent;
+
+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());
+ }
+
+ protected class AccessibleButtonListener extends AccessibleAbstractButtonListener {
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleButton();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleButton extends AccessibleAbstractButton {
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.PUSH_BUTTON;
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java b/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java
new file mode 100644
index 000000000000..bfc4fa521f00
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/CheckBox.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.Accessible;
+import javax.accessibility.AccessibleContext;
+
+import drafts.com.sun.star.accessibility.XAccessible;
+import drafts.com.sun.star.accessibility.XAccessibleComponent;
+
+class CheckBox extends ToggleButton {
+
+ public CheckBox(XAccessible accessible, XAccessibleComponent component) {
+ super(accessible, component);
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleCheckBox();
+ }
+ return accessibleContext;
+ }
+
+ 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
new file mode 100644
index 000000000000..9f3ad9cac350
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ComboBox.java
@@ -0,0 +1,246 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.AccessibleContext;
+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;
+
+/**
+ */
+public class ComboBox extends Component implements javax.accessibility.Accessible {
+
+ 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();
+ }
+
+ 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;
+ }
+
+ /** 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() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleComboBox();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleComboBox extends AccessibleUNOComponent
+ implements javax.accessibility.AccessibleAction {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleComboBox() {
+ 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;
+ }
+ default:
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleAction associated with this object that supports one or more actions */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ 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
+ */
+
+ /** Performs the specified Action on the object */
+ public boolean doAccessibleAction(int param) {
+ if (param == 0) {
+ try {
+ return unoAccessibleAction.doAccessibleAction(0);
+ } catch(com.sun.star.uno.Exception e) {
+ }
+ }
+
+ return false;
+ }
+
+ /** Returns a description of the specified action of the object */
+ public java.lang.String getAccessibleActionDescription(int param) {
+ return javax.swing.UIManager.getString("ComboBox.togglePopupText");
+ }
+
+ /** Returns the number of accessible actions available in this object */
+ public int getAccessibleActionCount() {
+ return 1;
+ }
+ }
+}
+
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Component.java b/accessibility/bridge/org/openoffice/java/accessibility/Component.java
new file mode 100644
index 000000000000..cac63f231787
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Component.java
@@ -0,0 +1,546 @@
+/*************************************************************************
+ *
+ * $RCSfile: Component.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
+ *
+ * - 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.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;
+
+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);
+
+ protected XAccessible unoAccessible = null;
+ protected XAccessibleComponent unoAccessibleComponent = null;
+
+ protected Component() {
+ super();
+// enableEvents(java.awt.AWTEvent.FOCUS_EVENT_MASK);
+ }
+
+ /**
+ * Determines whether this <code>Component</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>Component</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>Component</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() {
+ }
+
+ /** Requests focus for this object */
+ public void requestFocus() {
+ if (isShowing()) {
+ try {
+ unoAccessibleComponent.grabFocus();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ }
+ /** Requests focus for this object */
+ protected boolean requestFocus(boolean temporary) {
+ // Must be a no-op to make focus handling work
+ return true;
+ }
+
+ /** Returns the location of the object on the screen. */
+ public java.awt.Point getLocationOnScreen() {
+ java.awt.Container parent = getParent();
+ if (parent != null) {
+ // Retrieve location of the parent object
+ java.awt.Point p = parent.getLocationOnScreen();
+
+ // Add relative coordinates of the object
+ if (p != null) {
+ p.translate(getX(), getY());
+ return p;
+ }
+ }
+
+ return null;
+ }
+
+ /** Returns the foreground color of the object */
+ public java.awt.Color getForeground() {
+ if (isShowing()) {
+ try {
+ return new java.awt.Color(unoAccessibleComponent.getForeground());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ /** Returns the background color of the object */
+ public java.awt.Color getBackground() {
+ if (isShowing()) {
+ try {
+ return new java.awt.Color(unoAccessibleComponent.getBackground());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ 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(
+ (XAccessible) UnoRuntime.queryInterface(XAccessible.class, targetSet[i]));
+ if (c != null) {
+ list.add(c);
+ }
+ }
+ list.trimToSize();
+ return list.toArray();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ 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();
+ }
+
+ 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() {
+ 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());
+ }
+ }
+ }
+
+ 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 abstract class AccessibleUNOComponentListener implements XAccessibleEventListener {
+
+ protected AccessibleUNOComponentListener() {
+ }
+
+ 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(
+ Component.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:
+ if (enable) {
+ // Query bounding boxes if component becomes visible
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Component.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ }
+// fireStatePropertyChange(AccessibleState.SHOWING, enable);
+ break;
+ case AccessibleStateType.VISIBLE:
+ if (enable) {
+ // Query bounding boxes if component becomes visible
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Component.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ }
+ Component.this.setVisible(enable);
+ break;
+ default:
+ if (Build.DEBUG) {
+ System.err.println("[component]: " + getName() + "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) {
+ }
+ }
+
+ /** Fires a visible data property change event */
+ protected void handleVisibleDataEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Component.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Updates internal bounding box cache */
+ protected void handleBoundRectEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Component.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** 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_VISIBLE_DATA_EVENT:
+ handleVisibleDataEvent();
+ firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY, null, null);
+ break;
+ case AccessibleEventId.ACCESSIBLE_BOUNDRECT_EVENT:
+ handleBoundRectEvent();
+ break;
+ case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
+ // FIXME: enhance text information ..
+ firePropertyChange(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY, null, new Integer(0));
+ 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) {
+ }
+ }
+
+ protected AccessibleContext accessibleContext = null;
+
+ protected abstract class AccessibleUNOComponent extends java.awt.Component.AccessibleAWTComponent {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleUNOComponent() {
+ 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);
+ }
+ }
+
+ 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) {
+ AccessibleUNOComponent.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ AccessibleState.VISIBLE, null);
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ AccessibleUNOComponent.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 AccessibleComponentHandler
+
+ 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) {
+ AccessibleUNOComponent.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, AccessibleState.FOCUSED);
+ if (Build.DEBUG) {
+ System.err.println("[" + getAccessibleRole() + "] " + getAccessibleName() + " is now focused");
+ }
+ }
+ public void focusLost(java.awt.event.FocusEvent event) {
+ AccessibleUNOComponent.this.firePropertyChange(
+ AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ AccessibleState.FOCUSED, null);
+ if (Build.DEBUG) {
+ System.err.println("[" + getAccessibleRole() + "] " + getAccessibleName() + " is no longer focused");
+ }
+ }
+ } // inner class AccessibleFocusHandler
+
+ 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) {
+ accessibleComponentHandler = new AccessibleComponentHandler();
+ Component.this.addComponentListener(accessibleComponentHandler);
+
+ accessibleFocusHandler = new AccessibleFocusHandler();
+ Component.this.addFocusListener(accessibleFocusHandler);
+ }
+ 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) {
+ Component.this.removeComponentListener(accessibleComponentHandler);
+ accessibleComponentHandler = null;
+
+ Component.this.removeFocusListener(accessibleFocusHandler);
+ accessibleFocusHandler = null;
+ }
+ super.removePropertyChangeListener(listener);
+ }
+ }
+
+ // Extract a number from a UNO any
+ public static java.lang.Number toNumber(java.lang.Object any) {
+ try {
+ if (AnyConverter.isByte(any)) {
+ return new Byte(AnyConverter.toByte(any));
+ } else if (AnyConverter.isShort(any)) {
+ return new Short(AnyConverter.toShort(any));
+ } else if (AnyConverter.isInt(any)) {
+ return new Integer(AnyConverter.toInt(any));
+ } else if (AnyConverter.isLong(any)) {
+ return new Long(AnyConverter.toLong(any));
+ } else if (AnyConverter.isFloat(any)) {
+ return new Float(AnyConverter.toFloat(any));
+ } else if (AnyConverter.isDouble(any)) {
+ return new Double(AnyConverter.toDouble(any));
+ }
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ return null;
+ }
+
+ public String toString() {
+ return UnoRuntime.generateOid(unoAccessible);
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Container.java b/accessibility/bridge/org/openoffice/java/accessibility/Container.java
new file mode 100644
index 000000000000..d267f46d7b65
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Container.java
@@ -0,0 +1,130 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.AccessibleContext;
+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;
+
+public class Container extends AbstractContainer implements javax.accessibility.Accessible {
+
+ protected AccessibleRole accessibleRole;
+
+ protected Container(AccessibleRole role, XAccessible accessible, XAccessibleComponent component) {
+ super();
+ accessibleRole = role;
+ 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 AccessibleContainerListener());
+ }
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleContainerListener extends AccessibleAbstractContainerListener {
+ protected AccessibleContainerListener() {
+ super();
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleContainer();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleContainer extends AccessibleAbstractContainer {
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleContainer() {
+ super();
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return accessibleRole;
+ }
+ }
+
+ public String toString() {
+ return UnoRuntime.generateOid(unoAccessible);
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java b/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java
new file mode 100644
index 000000000000..4a7940b12856
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/DescendantManager.java
@@ -0,0 +1,220 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.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;
+
+public abstract class DescendantManager extends Component {
+ final static String monitorClassName =
+ "com.sun.java.accessibility.util.AccessibilityEventMonitor$AccessibilityEventListener";
+
+ protected javax.accessibility.Accessible activeDescendant = null;
+ protected boolean multiselectable = false;
+
+ protected DescendantManager() {
+ super();
+ }
+
+ protected DescendantManager(boolean multiselectable) {
+ super();
+ 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
+ */
+ protected class AccessibleDescendantManagerListener extends AccessibleUNOComponentListener {
+
+ protected AccessibleDescendantManagerListener() {
+ super();
+ }
+
+ /** Called by OpenOffice process to notify property changes */
+ public void notifyEvent(AccessibleEventObject event) {
+ switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
+ firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY, null, null);
+ break;
+ default:
+ super.notifyEvent(event);
+ }
+ }
+ }
+
+ protected XAccessibleContext unoAccessibleContext = null;
+ protected XAccessibleSelection unoAccessibleSelection = null;
+
+ protected abstract class AccessibleDescendantManager extends AccessibleUNOComponent
+ implements javax.accessibility.AccessibleSelection {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleDescendantManager() {
+ 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;
+ }
+
+ try {
+ return unoAccessibleContext.getAccessibleChildCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Returns the AccessibleSelection interface for this object */
+ public javax.accessibility.AccessibleSelection getAccessibleSelection() {
+ 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
+ */
+
+ /** 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/Dialog.java b/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java
new file mode 100644
index 000000000000..9d1a5d318c9c
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Dialog.java
@@ -0,0 +1,529 @@
+/*************************************************************************
+ *
+ * $RCSfile: Dialog.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
+ *
+ * - 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 java.awt.event.WindowEvent;
+
+import javax.accessibility.AccessibleState;
+
+import com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
+
+public class Dialog extends java.awt.Dialog implements javax.accessibility.Accessible, NativeFrame {
+ protected XAccessibleComponent unoAccessibleComponent;
+
+ // The coordinates of this frame on screen
+ java.awt.Point location = null;
+
+ boolean opened = false;
+ boolean visible = false;
+
+ java.awt.EventQueue eventQueue = null;
+
+ protected Dialog(java.awt.Frame owner, XAccessibleComponent xAccessibleComponent) {
+ super(owner);
+ initialize(xAccessibleComponent);
+ }
+
+ protected Dialog(java.awt.Frame owner, String name, XAccessibleComponent xAccessibleComponent) {
+ super(owner, name);
+ initialize(xAccessibleComponent);
+ }
+
+ protected Dialog(java.awt.Frame owner, String name, boolean modal, XAccessibleComponent xAccessibleComponent) {
+ super(owner, name, modal);
+ initialize(xAccessibleComponent);
+ }
+
+ private void initialize(XAccessibleComponent xAccessibleComponent) {
+ unoAccessibleComponent = xAccessibleComponent;
+ eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
+ XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
+ UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class,
+ xAccessibleComponent);
+ if (broadcaster != null) {
+ broadcaster.addEventListener(new AccessibleDialogListener());
+ }
+ }
+
+ java.awt.Component initialComponent = null;
+
+ public java.awt.Component getInitialComponent() {
+ return initialComponent;
+ }
+
+ 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;
+ }
+
+ public Integer getHWND() {
+ return null;
+ }
+
+ /**
+ * Determines whether this <code>Component</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>Component</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() {
+// createHierarchyEvents(0, null, null, 0, false);
+ }
+
+ /**
+ * Makes this <code>Component</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() {
+ }
+
+ /**
+ * Determines if the object is visible. Note: this means that the
+ * object intends to be visible; however, it may not in fact be
+ * showing on the screen because one of the objects that this object
+ * is contained by is not visible. To determine if an object is
+ * showing on the screen, use <code>isShowing</code>.
+ *
+ * @return true if object is visible; otherwise, false
+ */
+ public boolean isVisible(){
+ return visible;
+ }
+
+ /**
+ * Shows or hides this component depending on the value of parameter
+ * <code>b</code>.
+ * @param b if <code>true</code>, shows this component;
+ * otherwise, hides this component
+ * @see #isVisible
+ * @since JDK1.1
+ */
+ public void setVisible(boolean b) {
+ if (visible != b){
+ visible = b;
+ if (b) {
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+
+ // If it is the first show, fire WINDOW_OPENED event
+ if (!opened) {
+ System.err.println("Posting Window opened");
+ postWindowEvent(WindowEvent.WINDOW_OPENED);
+ opened = true;
+ }
+ } else {
+ location = null;
+ }
+ }
+ }
+
+ protected void postWindowEvent(int i) {
+ eventQueue.postEvent(new WindowEvent(this, i));
+ }
+
+ /** Returns the location of the object on the screen. */
+ public java.awt.Point getLocationOnScreen() {
+ if (visible) {
+ return new java.awt.Point(location);
+ }
+ return null;
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleDialogListener implements XAccessibleEventListener {
+
+ protected AccessibleDialogListener() {
+ }
+
+ protected void setComponentState(short state, boolean enable) {
+ switch (state) {
+ case AccessibleStateType.ACTIVE:
+ postWindowEvent(enable ?
+ java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS :
+ java.awt.event.WindowEvent.WINDOW_LOST_FOCUS);
+ break;
+ case AccessibleStateType.ICONIFIED:
+ postWindowEvent(enable ?
+ java.awt.event.WindowEvent.WINDOW_ICONIFIED :
+ java.awt.event.WindowEvent.WINDOW_DEICONIFIED);
+ break;
+ case AccessibleStateType.VISIBLE:
+ Dialog.this.setVisible(enable);
+ break;
+ default:
+ if (Build.DEBUG) {
+ System.err.println("[dialog]: " + getTitle() + "unexpected state change " + state);
+ }
+ break;
+ }
+ }
+
+ /** Updates the accessible name and fires the appropriate PropertyChangedEvent */
+ protected void handleNameChangedEvent(Object any) {
+ try {
+ Dialog.this.setTitle(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.getDefault().getAccessibleComponent(
+ (XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
+ if (c != null) {
+ Dialog.this.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) {
+ 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);
+ if (c != null) {
+ // Seems to be already in child list
+ if (c.getParent().equals(this))
+ return;
+ } else {
+ c = factory.createAccessibleComponent(xAccessible);
+ }
+ if (c != null) {
+ Dialog.this.add(c, xAccessible.getAccessibleContext().
+ getAccessibleIndexInParent());
+ }
+ }
+
+ catch (com.sun.star.uno.Exception e) {
+ // FIXME: output
+ }
+ }
+
+
+ /** Fires a visible data property change event */
+ protected void handleVisibleDataEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Dialog.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Updates internal bounding box cache */
+ protected void handleBoundRectEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Dialog.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** 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:
+ handleVisibleDataEvent();
+ break;
+ case AccessibleEventId.ACCESSIBLE_BOUNDRECT_EVENT:
+ handleBoundRectEvent();
+ 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) {
+ }
+ }
+
+ javax.accessibility.AccessibleContext accessibleContext = null;
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleDialog();
+ accessibleContext.setAccessibleName(getTitle());
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleDialog extends java.awt.Dialog.AccessibleAWTDialog {
+ protected AccessibleDialog() {
+ super();
+ }
+
+ 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) {
+ AccessibleDialog.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ javax.accessibility.AccessibleState.VISIBLE, null);
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ AccessibleDialog.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, javax.accessibility.AccessibleState.VISIBLE);
+ }
+
+ public void componentMoved(java.awt.event.ComponentEvent e) {
+ }
+
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ }
+ } // inner class AccessibleComponentHandler
+
+ protected java.awt.event.WindowFocusListener accessibleWindowFocusHandler = null;
+
+ /**
+ * Fire PropertyChange listener, if one is registered,
+ * when focus events happen
+ */
+ protected class AccessibleWindowFocusHandler implements java.awt.event.WindowFocusListener {
+ public void windowGainedFocus(java.awt.event.WindowEvent e) {
+ AccessibleDialog.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, javax.accessibility.AccessibleState.ACTIVE);
+ if (Build.DEBUG) {
+ System.err.println("[dialog] " + getTitle() + " is now active");
+ }
+ }
+ public void windowLostFocus(java.awt.event.WindowEvent e) {
+ AccessibleDialog.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ javax.accessibility.AccessibleState.ACTIVE, null);
+ if (Build.DEBUG) {
+ System.err.println("[dialog] " + getTitle() + " is no longer active");
+ }
+ }
+ } // 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) {
+ AccessibleDialog.this.firePropertyChange(
+ javax.accessibility.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) {
+ AccessibleDialog.this.firePropertyChange(
+ javax.accessibility.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) {
+ accessibleWindowFocusHandler = new AccessibleWindowFocusHandler();
+ Dialog.this.addWindowFocusListener(accessibleWindowFocusHandler);
+
+ accessibleContainerHandler = new AccessibleContainerHandler();
+ Dialog.this.addContainerListener(accessibleContainerHandler);
+
+ accessibleComponentHandler = new AccessibleComponentHandler();
+ Dialog.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) {
+ Dialog.this.removeComponentListener(accessibleComponentHandler);
+ accessibleComponentHandler = null;
+
+ Dialog.this.removeContainerListener(accessibleContainerHandler);
+ accessibleContainerHandler = null;
+
+ Dialog.this.removeWindowFocusListener(accessibleWindowFocusHandler);
+ accessibleWindowFocusHandler = null;
+ }
+ super.removePropertyChangeListener(listener);
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Frame.java b/accessibility/bridge/org/openoffice/java/accessibility/Frame.java
new file mode 100644
index 000000000000..7071b8e4a9d1
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Frame.java
@@ -0,0 +1,534 @@
+/*************************************************************************
+ *
+ * $RCSfile: Frame.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
+ *
+ * - 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 com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
+
+public class Frame extends java.awt.Frame implements javax.accessibility.Accessible, NativeFrame {
+ protected XAccessibleComponent unoAccessibleComponent;
+
+ // The coordinates of this frame on screen
+ java.awt.Point location = null;
+
+ boolean opened = false;
+ boolean visible = false;
+
+ java.awt.EventQueue eventQueue = null;
+
+ protected Frame(XAccessibleComponent xAccessibleComponent) {
+ super();
+ initialize(xAccessibleComponent);
+ }
+
+ protected Frame(String name, XAccessibleComponent xAccessibleComponent) {
+ super(name);
+ initialize(xAccessibleComponent);
+ }
+
+ private void initialize(XAccessibleComponent xAccessibleComponent) {
+ unoAccessibleComponent = xAccessibleComponent;
+ eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
+ XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
+ UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class,
+ unoAccessibleComponent);
+ if (broadcaster != null) {
+ broadcaster.addEventListener(new AccessibleFrameListener());
+ }
+ }
+
+ java.awt.Component initialComponent = null;
+
+ public java.awt.Component getInitialComponent() {
+ return initialComponent;
+ }
+
+ 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;
+ }
+
+ public Integer getHWND() {
+ return null;
+ }
+
+ /**
+ * Determines whether this <code>Component</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>Component</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() {
+// createHierarchyEvents(0, null, null, 0, false);
+ }
+
+ /**
+ * Makes this <code>Component</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() {
+ }
+
+ /**
+ * Determines if the object is visible. Note: this means that the
+ * object intends to be visible; however, it may not in fact be
+ * showing on the screen because one of the objects that this object
+ * is contained by is not visible. To determine if an object is
+ * showing on the screen, use <code>isShowing</code>.
+ *
+ * @return true if object is visible; otherwise, false
+ */
+ public boolean isVisible(){
+ return visible;
+ }
+
+ /**
+ * Shows or hides this component depending on the value of parameter
+ * <code>b</code>.
+ * @param b if <code>true</code>, shows this component;
+ * otherwise, hides this component
+ * @see #isVisible
+ * @since JDK1.1
+ */
+ public void setVisible(boolean b) {
+ if (visible != b){
+ visible = b;
+ if (b) {
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+
+ // If it is the first show, fire WINDOW_OPENED event
+ if (!opened) {
+ postWindowEvent(java.awt.event.WindowEvent.WINDOW_OPENED);
+ opened = true;
+ }
+ } else {
+ location = null;
+ }
+ }
+ }
+
+ protected void postWindowEvent(int i) {
+ eventQueue.postEvent(new java.awt.event.WindowEvent(this, i));
+ }
+
+ /** Returns the location of the object on the screen. */
+ public java.awt.Point getLocationOnScreen() {
+ if (visible) {
+ return new java.awt.Point(location);
+ }
+ return null;
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleFrameListener implements XAccessibleEventListener {
+
+ protected AccessibleFrameListener() {
+ }
+
+ // The only expected state changes are ACTIVE and VISIBLE
+ protected void setComponentState(short state, boolean enable) {
+ switch (state) {
+ case AccessibleStateType.ACTIVE:
+ postWindowEvent(enable ?
+ java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS :
+ java.awt.event.WindowEvent.WINDOW_LOST_FOCUS);
+ break;
+ case AccessibleStateType.ICONIFIED:
+ postWindowEvent(enable ?
+ java.awt.event.WindowEvent.WINDOW_ICONIFIED :
+ java.awt.event.WindowEvent.WINDOW_DEICONIFIED);
+ break;
+ case AccessibleStateType.VISIBLE:
+ Frame.this.setVisible(enable);
+ break;
+ default:
+ if (Build.DEBUG) {
+ System.err.println("[frame]: " + getTitle() + "unexpected state change " + state);
+ }
+ break;
+ }
+ }
+
+ /** Updates the accessible name and fires the appropriate PropertyChangedEvent */
+ protected void handleNameChangedEvent(Object any) {
+ try {
+ Frame.this.setTitle(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.getDefault().getAccessibleComponent(
+ (XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
+ if (c != null) {
+ Frame.this.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(AbstractContainer.XAccessibleType, any);
+ AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
+ java.awt.Component c = factory.getAccessibleComponent(xAccessible);
+ if (c != null) {
+ // Seems to be already in child list
+ if (c.getParent().equals(this))
+ return;
+ } else {
+ c = factory.createAccessibleComponent(xAccessible);
+ }
+ if (c != null) {
+ Frame.this.add(c, xAccessible.getAccessibleContext().
+ getAccessibleIndexInParent());
+ }
+ }
+
+ catch (com.sun.star.uno.Exception e) {
+ // FIXME: output
+ }
+ }
+
+ /** Fires a visible data property change event */
+ protected void handleVisibleDataEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Frame.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Updates internal bounding box cache */
+ protected void handleBoundRectEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Frame.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** 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:
+ handleVisibleDataEvent();
+ break;
+ case AccessibleEventId.ACCESSIBLE_BOUNDRECT_EVENT:
+ handleBoundRectEvent();
+ 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) {
+ }
+ }
+
+ protected javax.accessibility.AccessibleContext accessibleContext = null;
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleFrame();
+ accessibleContext.setAccessibleName(getTitle());
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleFrame extends java.awt.Frame.AccessibleAWTFrame {
+ protected AccessibleFrame() {
+ super();
+ }
+
+ 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) {
+ AccessibleFrame.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ javax.accessibility.AccessibleState.VISIBLE, null);
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ AccessibleFrame.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, javax.accessibility.AccessibleState.VISIBLE);
+ }
+
+ public void componentMoved(java.awt.event.ComponentEvent e) {
+ }
+
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ }
+ } // inner class AccessibleComponentHandler
+
+ protected java.awt.event.WindowFocusListener accessibleWindowFocusHandler = null;
+
+ /**
+ * Fire PropertyChange listener, if one is registered,
+ * when focus events happen
+ */
+ protected class AccessibleWindowFocusHandler implements java.awt.event.WindowFocusListener {
+ public void windowGainedFocus(java.awt.event.WindowEvent e) {
+ AccessibleFrame.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, javax.accessibility.AccessibleState.ACTIVE);
+ if (Build.DEBUG) {
+ System.err.println("[frame] " + getTitle() + " is now active");
+ }
+ }
+ public void windowLostFocus(java.awt.event.WindowEvent e) {
+ AccessibleFrame.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ javax.accessibility.AccessibleState.ACTIVE, null);
+ if (Build.DEBUG) {
+ System.err.println("[frame] " + getTitle() + " is no longer active");
+ }
+ }
+ } // 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) {
+ AccessibleFrame.this.firePropertyChange(
+ javax.accessibility.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) {
+ AccessibleFrame.this.firePropertyChange(
+ javax.accessibility.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) {
+ accessibleWindowFocusHandler = new AccessibleWindowFocusHandler();
+ Frame.this.addWindowFocusListener(accessibleWindowFocusHandler);
+
+ accessibleContainerHandler = new AccessibleContainerHandler();
+ Frame.this.addContainerListener(accessibleContainerHandler);
+
+ accessibleComponentHandler = new AccessibleComponentHandler();
+ Frame.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) {
+ Frame.this.removeComponentListener(accessibleComponentHandler);
+ accessibleComponentHandler = null;
+
+ Frame.this.removeContainerListener(accessibleContainerHandler);
+ accessibleContainerHandler = null;
+
+ Frame.this.removeWindowFocusListener(accessibleWindowFocusHandler);
+ accessibleWindowFocusHandler = null;
+ }
+ super.removePropertyChangeListener(listener);
+ }
+
+ /**
+ * 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 ((getExtendedState() & java.awt.Frame.ICONIFIED) > 0) {
+ states.add(javax.accessibility.AccessibleState.ICONIFIED);
+ }
+ return states;
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Icon.java b/accessibility/bridge/org/openoffice/java/accessibility/Icon.java
new file mode 100644
index 000000000000..d6f3e73e3f54
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Icon.java
@@ -0,0 +1,179 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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 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;
+
+/**
+ */
+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();
+ }
+
+ /** 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);
+ }
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleIcon();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleIcon extends AccessibleUNOComponent
+ /* implements AccessibleExtendedComponent */ {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleIcon() {
+ super();
+ }
+
+ /** Gets the AccessibleText associated with this object presenting text on the display */
+ public javax.accessibility.AccessibleIcon[] getAccessibleIcon() {
+ try {
+ XAccessibleImage unoAccessibleImage = (XAccessibleImage)
+ UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleComponent);
+ if (unoAccessibleImage != null) {
+ javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) };
+ return icons;
+ }
+ } 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;
+ }
+*/
+ }
+}
+
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Label.java b/accessibility/bridge/org/openoffice/java/accessibility/Label.java
new file mode 100644
index 000000000000..2cd1abb0ec93
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Label.java
@@ -0,0 +1,202 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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 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 {
+
+ 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();
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ unoAccessibleContext = unoAccessible.getAccessibleContext();
+ if (unoAccessibleContext != null) {
+ accessibleContext = new AccessibleLabel();
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected XAccessibleContext unoAccessibleContext = null;
+
+ protected class AccessibleLabel extends AccessibleUNOComponent
+ /* implements AccessibleExtendedComponent */ {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleLabel() {
+ super();
+ }
+
+ /*
+ * AccessibleContext
+ */
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.LABEL;
+ }
+
+ /** 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/List.java b/accessibility/bridge/org/openoffice/java/accessibility/List.java
new file mode 100644
index 000000000000..2c3022536eec
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/List.java
@@ -0,0 +1,499 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.AccessibleContext;
+import javax.accessibility.AccessibleState;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+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 void setActiveDescendant(javax.accessibility.Accessible descendant) {
+ javax.accessibility.Accessible oldAD = activeDescendant;
+ activeDescendant = descendant;
+ firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
+ oldAD, descendant);
+ }
+
+ protected void setActiveDescendant(Object any) {
+ javax.accessibility.Accessible descendant = null;
+ try {
+ if (AnyConverter.isObject(any)) {
+ XAccessible unoAccessible = (XAccessible) AnyConverter.toObject(
+ AbstractContainer.XAccessibleType, any);
+ if (unoAccessible != null) {
+ // FIXME: have to handle non transient objects here ..
+ descendant = new ListItem(unoAccessible);
+ }
+ }
+ setActiveDescendant(descendant);
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void add(XAccessible unoAccessible) {
+ if (unoAccessible != null) {
+ ListItem item = new ListItem(unoAccessible);
+ // The AccessBridge for Windows expects an instance of AccessibleContext
+ // as parameters
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ null, item.getAccessibleContext());
+ }
+ }
+
+ protected void remove(XAccessible unoAccessible) {
+ if (unoAccessible != null) {
+ ListItem item = new ListItem(unoAccessible);
+ // The AccessBridge for Windows expects an instance of AccessibleContext
+ // as parameters
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ item.getAccessibleContext(), null);
+ }
+ }
+
+ protected void add(Object any) {
+ try {
+ add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void remove(Object any) {
+ try {
+ remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleListListener extends AccessibleDescendantManagerListener {
+
+ protected AccessibleListListener() {
+ super();
+ }
+
+ /** Called by OpenOffice process to notify property changes */
+ public void notifyEvent(AccessibleEventObject event) {
+ switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_ACTIVE_DESCENDANT_EVENT:
+ setActiveDescendant(event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
+ if (AnyConverter.isObject(event.OldValue)) {
+ remove(event.OldValue);
+ }
+ if (AnyConverter.isObject(event.NewValue)) {
+ add(event.NewValue);
+ }
+ break;
+ case AccessibleEventId.ACCESSIBLE_ALL_CHILDREN_CHANGED_EVENT:
+ // Since List items a transient a child events are mostly used
+ // to attach/detach listeners, it is save to ignore it here
+ break;
+ default:
+ super.notifyEvent(event);
+ }
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ unoAccessibleContext = unoAccessible.getAccessibleContext();
+ unoAccessibleSelection = (XAccessibleSelection) UnoRuntime.queryInterface(
+ XAccessibleSelection.class, unoAccessibleContext);
+ if (unoAccessibleSelection != null) {
+ accessibleContext = new AccessibleList();
+ } else if (Build.DEBUG) {
+ System.err.println("List does not support accessible selection");
+ accessibleContext = new AccessibleList();
+ }
+ } catch (java.lang.NullPointerException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ if (Build.DEBUG) {
+ System.err.println("RuntimeException caught: " + e.getMessage());
+ }
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleList extends AccessibleDescendantManager {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleList() {
+ super();
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.LIST;
+ }
+
+ /** Returns the specified Accessible child of the object */
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ if (xAccessible != null) {
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = List.this.activeDescendant;
+ if ((activeDescendant instanceof ListItem) && xAccessible.equals(((ListItem) activeDescendant).unoAccessible)) {
+ child = activeDescendant;
+ } else {
+ child = new ListItem(xAccessible);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /*
+ * 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) {
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = List.this.activeDescendant;
+ if ((activeDescendant instanceof ListItem) && xAccessible.equals(((ListItem) activeDescendant).unoAccessible)) {
+ child = activeDescendant;
+ } else {
+ child = new ListItem(xAccessible);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+ }
+
+ class ListItem implements javax.accessibility.Accessible {
+
+ protected XAccessible unoAccessible;
+
+ public ListItem(XAccessible xAccessible) {
+ unoAccessible = xAccessible;
+ }
+
+ public Object[] create(Object[] targetSet) {
+ try {
+ java.util.ArrayList list = new java.util.ArrayList(targetSet.length);
+ for (int i=0; i < targetSet.length; i++) {
+ XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, targetSet[i]);
+ if (xAccessible != null) {
+ list.add(new ListItem(xAccessible));
+ }
+ }
+ list.trimToSize();
+ return list.toArray();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ javax.accessibility.AccessibleContext accessibleContext = null;
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext();
+ if (xAccessibleContext != null) {
+ accessibleContext = new AccessibleListItem(xAccessibleContext);
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleListItem extends javax.accessibility.AccessibleContext {
+
+ XAccessibleContext unoAccessibleContext;
+
+ public AccessibleListItem(XAccessibleContext xAccessibleContext) {
+ unoAccessibleContext = xAccessibleContext;
+ }
+
+ /** Returns the accessible name of this object */
+ public String getAccessibleName() {
+ try {
+ return unoAccessibleContext.getAccessibleName();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Sets the accessible name of this object */
+ public void setAccessibleName(String name) {
+ // Not supported
+ }
+
+ /** Returns the accessible name of this object */
+ public String getAccessibleDescription() {
+ try {
+ return unoAccessibleContext.getAccessibleDescription();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Sets the accessible name of this object */
+ public void setAccessibleDescription(String name) {
+ // Not supported
+ }
+
+ /** Returns the accessible role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ try {
+ javax.accessibility.AccessibleRole role = AccessibleRoleAdapter.getAccessibleRole(
+ unoAccessibleContext.getAccessibleRole());
+ return (role != null) ? role : javax.accessibility.AccessibleRole.LABEL;
+ } 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 = unoAccessibleContext.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 List.this.getLocale();
+ }
+ }
+
+ /** Gets the 0-based index of this object in its accessible parent */
+ public int getAccessibleIndexInParent() {
+ try {
+ return unoAccessibleContext.getAccessibleIndexInParent();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return -1;
+ }
+ }
+
+ /** Returns the number of accessible children of the object. */
+ public int getAccessibleChildrenCount() {
+ try {
+ return unoAccessibleContext.getAccessibleChildCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Returns the specified Accessible child of the object. */
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = List.this.activeDescendant;
+ if ((activeDescendant instanceof ListItem) && ((ListItem) activeDescendant).unoAccessible.equals(xAccessible)) {
+ child = activeDescendant;
+ } else if (xAccessible != null) {
+ child = new ListItem(xAccessible);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /** Returns the state set of this object */
+ public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ try {
+ javax.accessibility.AccessibleStateSet stateSet = new javax.accessibility.AccessibleStateSet();
+ // table cells are transient and so neither focusable nor focused
+ stateSet.add(javax.accessibility.AccessibleState.TRANSIENT);
+
+ XAccessibleStateSet unoAccessibleStateSet = unoAccessibleContext.getAccessibleStateSet();
+ if (unoAccessibleStateSet.contains(AccessibleStateType.ENABLED)) {
+ stateSet.add(javax.accessibility.AccessibleState.ENABLED);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.OPAQUE)) {
+ stateSet.add(javax.accessibility.AccessibleState.OPAQUE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.RESIZABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.RESIZABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
+ stateSet.add(javax.accessibility.AccessibleState.SHOWING);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.VISIBLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.VISIBLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SINGLE_LINE)) {
+ stateSet.add(javax.accessibility.AccessibleState.SINGLE_LINE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.MULTILINE)) {
+ stateSet.add(javax.accessibility.AccessibleState.MULTI_LINE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.SELECTABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTED)) {
+ stateSet.add(javax.accessibility.AccessibleState.SELECTED);
+ }
+ return stateSet;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleComponent associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleComponent getAccessibleComponent() {
+ try {
+ XAccessibleComponent unoAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class, unoAccessibleContext);
+ return (unoAccessibleComponent != null) ?
+ new AccessibleComponentImpl(unoAccessibleComponent) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleAction associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ try {
+ XAccessibleAction unoAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext);
+ return (unoAccessibleAction != null) ?
+ new AccessibleActionImpl(unoAccessibleAction) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleText associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleText getAccessibleText() {
+ try {
+ XAccessibleText unoAccessibleText = (XAccessibleText)
+ UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext);
+ return (unoAccessibleText != null) ?
+ new AccessibleTextImpl(unoAccessibleText) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleValue associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleValue getAccessibleValue() {
+ 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 AccessibleText associated with this object presenting text on the display */
+ public javax.accessibility.AccessibleIcon[] getAccessibleIcon() {
+ try {
+ XAccessibleImage unoAccessibleImage = (XAccessibleImage)
+ UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleContext);
+ if (unoAccessibleImage != null) {
+ javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) };
+ return icons;
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return null;
+ }
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Menu.java b/accessibility/bridge/org/openoffice/java/accessibility/Menu.java
new file mode 100644
index 000000000000..dab01ba7c99a
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Menu.java
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * $RCSfile: Menu.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
+ *
+ * - 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.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.*;
+
+public class Menu extends AbstractButton implements javax.accessibility.Accessible {
+
+ 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());
+ 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 < children.size(); i++) {
+ java.awt.Component c = getComponent(unoAccessibleContext.getAccessibleChild(i));
+ if (c != null) {
+ children.add(c);
+ }
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ if (children == null) {
+ children = new java.util.Vector(0);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ }
+ }
+
+ protected synchronized void add(XAccessible unoAccessible) {
+ // The AccessBridge for Windows expects an instance of AccessibleContext
+ // as parameters
+ java.awt.Component c = getComponent(unoAccessible);
+ if (c != null) {
+ try {
+ children.add(unoAccessible.getAccessibleContext().getAccessibleIndexInParent(), c);
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ null, ((javax.accessibility.Accessible) c).getAccessibleContext());
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ }
+
+ protected synchronized void remove(XAccessible unoAccessible) {
+ // The AccessBridge for Windows expects an instance of AccessibleContext
+ // as parameters
+ java.awt.Component c = getComponent(unoAccessible);
+ if (c != null) {
+ try {
+ children.remove(c);
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ ((javax.accessibility.Accessible) c).getAccessibleContext(), null);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ }
+
+ protected void add(Object any) {
+ try {
+ add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void remove(Object any) {
+ try {
+ remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected synchronized int indexOf(Object child) {
+ return children.indexOf(child);
+ }
+
+ protected java.awt.Component getComponent(XAccessible unoAccessible) {
+ AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
+ java.awt.Component c = factory.getAccessibleComponent(unoAccessible);
+ if (c == null) {
+ c = factory.createAccessibleComponent(unoAccessible);
+ if (c instanceof javax.accessibility.Accessible) {
+ ((javax.accessibility.Accessible) c).getAccessibleContext().setAccessibleParent(this);
+ }
+ }
+ return c;
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleMenuListener extends AccessibleAbstractButtonListener {
+
+ protected AccessibleMenuListener() {
+ super();
+ }
+
+ /** Called by OpenOffice process to notify property changes */
+ public void notifyEvent(AccessibleEventObject event) {
+ switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
+ if (AnyConverter.isObject(event.OldValue)) {
+ remove(event.OldValue);
+ }
+ if (AnyConverter.isObject(event.NewValue)) {
+ add(event.NewValue);
+ }
+ break;
+ case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
+ firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,null, null);
+ break;
+ default:
+ super.notifyEvent(event);
+ }
+ }
+
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ unoAccessibleSelection = (XAccessibleSelection) UnoRuntime.queryInterface(
+ XAccessibleSelection.class, unoAccessibleComponent);
+ if (unoAccessibleSelection != null) {
+ accessibleContext = new AccessibleMenu();
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected XAccessibleSelection unoAccessibleSelection = null;
+
+ protected class AccessibleMenu extends AccessibleAbstractButton implements javax.accessibility.AccessibleSelection {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleMenu() {
+ super();
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.MENU;
+ }
+
+ /** Gets the 0-based index of this object in its accessible parent */
+ public int getAccessibleIndexInParent() {
+ if (getAccessibleParent() instanceof Menu) {
+ return ((Menu) getAccessibleParent()).indexOf(Menu.this);
+ } else {
+ return super.getAccessibleIndexInParent();
+ }
+ }
+
+ /** Returns the number of accessible children of the object */
+ public synchronized int getAccessibleChildrenCount() {
+ return children.size();
+ }
+
+ /** Returns the specified Accessible child of the object */
+ public synchronized javax.accessibility.Accessible getAccessibleChild(int i) {
+ return (javax.accessibility.Accessible) children.get(i);
+ }
+
+ /** Returns the AccessibleSelection interface for this object */
+ public javax.accessibility.AccessibleSelection getAccessibleSelection() {
+ // This method is called to determine the SELECTABLE state of every
+ // child, so don't do the query interface here.
+ return this;
+ }
+
+ /*
+ * AccessibleSelection
+ */
+
+ /** Returns an Accessible representing the specified selected child of the object */
+ public javax.accessibility.Accessible getAccessibleSelection(int i) {
+ try {
+ return (javax.accessibility.Accessible)
+ getComponent(unoAccessibleSelection.getSelectedAccessibleChild(i));
+ } catch (java.lang.Exception e) {
+ /*
+ * Possible exceptions are:
+ * java.lang.NullPointerException
+ * com.sun.star.uno.RuntimeException
+ * com.sun.star.lang.IndexOutOfBoundsException
+ */
+ 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 (java.lang.Exception e) {
+ /*
+ * Possible exceptions are:
+ * java.lang.NullPointerException
+ * com.sun.star.uno.RuntimeException
+ * com.sun.star.lang.IndexOutOfBoundsException
+ */
+ }
+ }
+
+ /** 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 (java.lang.Exception e) {
+ /*
+ * Possible exceptions are:
+ * java.lang.NullPointerException
+ * com.sun.star.uno.RuntimeException
+ * com.sun.star.lang.IndexOutOfBoundsException
+ */
+ return false;
+ }
+ }
+
+ /** Removes the specified child of the object from the object's selection */
+ public void removeAccessibleSelection(int i) {
+ if (isAccessibleChildSelected(i)) {
+ clearAccessibleSelection();
+ }
+ }
+
+ /** Causes every child of the object to be selected if the object supports multiple selection */
+ public void selectAllAccessibleSelection() {
+ // not supported
+ }
+
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java b/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java
new file mode 100644
index 000000000000..93f5622f138c
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/MenuItem.java
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * $RCSfile: MenuItem.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
+ *
+ * - 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.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);
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleMenuItem();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleMenuItem extends AccessibleToggleButton {
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.MENU_ITEM;
+ }
+
+ /** Gets the 0-based index of this object in its accessible parent */
+ public int getAccessibleIndexInParent() {
+ if (getAccessibleParent() instanceof Menu) {
+ return ((Menu) getAccessibleParent()).indexOf(MenuItem.this);
+ } else {
+ return -1;
+ }
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java b/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java
new file mode 100644
index 000000000000..e07ba12a2abc
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/NativeFrame.java
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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 interface NativeFrame {
+ public java.awt.Component getInitialComponent();
+ public void setInitialComponent(java.awt.Component c);
+ public Integer getHWND();
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java b/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java
new file mode 100644
index 000000000000..18ca352a8160
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/RadioButton.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * $RCSfile: RadioButton.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
+ *
+ * - 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.XAccessible;
+import drafts.com.sun.star.accessibility.XAccessibleComponent;
+
+class RadioButton extends ToggleButton {
+
+ public RadioButton(XAccessible accessible, XAccessibleComponent component) {
+ super(accessible, component);
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleRadioButton();
+ }
+ 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
new file mode 100644
index 000000000000..498783df0c2c
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ScrollBar.java
@@ -0,0 +1,266 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.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;
+
+/**
+ */
+public class ScrollBar extends Component implements SwingConstants, Accessible {
+
+ private int orientation = HORIZONTAL;
+
+ public ScrollBar(XAccessible accessible, XAccessibleComponent component, int orientation) {
+ super();
+ 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);
+ }
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleScrollBar();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleScrollBar extends AccessibleUNOComponent implements
+ javax.accessibility.AccessibleValue, javax.accessibility.AccessibleAction {
+
+ protected XAccessibleValue unoAccessibleValue;
+ protected XAccessibleAction unoAccessibleAction;
+ protected int actionCount = 0;
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleScrollBar() {
+ super();
+ unoAccessibleValue = (XAccessibleValue) UnoRuntime.queryInterface(
+ XAccessibleValue.class, unoAccessibleComponent);
+ unoAccessibleAction = (XAccessibleAction) UnoRuntime.queryInterface(
+ XAccessibleAction.class, ScrollBar.this.unoAccessibleComponent);
+ if (unoAccessibleAction != null) {
+ actionCount = unoAccessibleAction.getAccessibleActionCount();
+ }
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.SCROLL_BAR;
+ }
+
+ /**
+ * 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);
+ break;
+ case VERTICAL:
+ states.add(AccessibleState.VERTICAL);
+ break;
+ default:
+ break;
+ }
+ return states;
+ }
+
+ /** Gets the AccessibleValue associated with this object that supports a Numerical value */
+ public javax.accessibility.AccessibleValue getAccessibleValue() {
+ return this;
+ }
+
+ /** Gets the AccessibleAction associated with this object that supports one or more actions */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ return this;
+ }
+
+ /*
+ * AccessibleAction
+ */
+
+ /** Performs the specified Action on the object */
+ public boolean doAccessibleAction(int param) {
+ if (param < actionCount) {
+ try {
+ return unoAccessibleAction.doAccessibleAction(param);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ }
+ }
+ return false;
+ }
+
+ /** Returns a description of the specified action of the object */
+ public java.lang.String getAccessibleActionDescription(int param) {
+ if(param < actionCount) {
+ try {
+ return unoAccessibleAction.getAccessibleActionDescription(param);
+ } catch(com.sun.star.lang.IndexOutOfBoundsException e) {
+ }
+ }
+ return null;
+ }
+
+ /** Returns the number of accessible actions available in this object */
+ 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
new file mode 100644
index 000000000000..d4a1486fa647
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Separator.java
@@ -0,0 +1,150 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.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;
+
+/**
+ */
+public class Separator extends Component implements SwingConstants, Accessible {
+
+ private int orientation = HORIZONTAL;
+
+ public Separator(XAccessible accessible, XAccessibleComponent component, int orientation) {
+ super();
+ this.orientation = orientation;
+ initialize(accessible, component);
+ }
+
+ public Separator(XAccessible accessible, XAccessibleComponent component) {
+ super();
+ initialize(accessible, component);
+ }
+
+ protected void initialize(XAccessible accessible, XAccessibleComponent component) {
+ 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() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleSeparator();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleSeparator extends AccessibleUNOComponent {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleSeparator() {
+ super();
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.SEPARATOR;
+ }
+
+ /**
+ * 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);
+ break;
+ case VERTICAL:
+ states.add(AccessibleState.VERTICAL);
+ break;
+ default:
+ break;
+ }
+ return states;
+ }
+ }
+}
+
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Table.java b/accessibility/bridge/org/openoffice/java/accessibility/Table.java
new file mode 100644
index 000000000000..1b75a4ff79e3
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Table.java
@@ -0,0 +1,546 @@
+/*************************************************************************
+ *
+ * $RCSfile: Table.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
+ *
+ * - 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.AccessibleContext;
+import javax.accessibility.AccessibleState;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+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 void setActiveDescendant(javax.accessibility.Accessible descendant) {
+ javax.accessibility.Accessible oldAD = activeDescendant;
+ activeDescendant = descendant;
+ if (Build.DEBUG) {
+ System.err.println("Firing ACTIVE_DESCENDANT property change");
+ }
+ firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
+ oldAD, descendant);
+ }
+
+ protected void setActiveDescendant(Object any) {
+ javax.accessibility.Accessible descendant = null;
+ try {
+ if (AnyConverter.isObject(any)) {
+ XAccessible unoAccessible = (XAccessible) AnyConverter.toObject(
+ AbstractContainer.XAccessibleType, any);
+ if (unoAccessible != null) {
+ // FIXME: have to handle non transient objects here ..
+ descendant = new TableCell(unoAccessible);
+ }
+ }
+ setActiveDescendant(descendant);
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void add(XAccessible unoAccessible) {
+ if (unoAccessible != null) {
+ TableCell cell = new TableCell(unoAccessible);
+ // The AccessBridge for Windows expects an instance of AccessibleContext
+ // as parameters
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ null, cell.getAccessibleContext());
+ }
+ }
+
+ protected void remove(XAccessible unoAccessible) {
+ if (unoAccessible != null) {
+ TableCell cell = new TableCell(unoAccessible);
+ // The AccessBridge for Windows expects an instance of AccessibleContext
+ // as parameters
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ cell.getAccessibleContext(), null);
+ }
+ }
+
+ protected void add(Object any) {
+ try {
+ add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void remove(Object any) {
+ try {
+ remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleTableListener extends AccessibleDescendantManagerListener {
+
+ protected AccessibleTableListener() {
+ super();
+ }
+
+ /** Called by OpenOffice process to notify property changes */
+ public void notifyEvent(AccessibleEventObject event) {
+ switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_ACTIVE_DESCENDANT_EVENT:
+ setActiveDescendant(event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
+ if (AnyConverter.isObject(event.OldValue)) {
+ remove(event.OldValue);
+ }
+ if (AnyConverter.isObject(event.NewValue)) {
+ add(event.NewValue);
+ }
+ break;
+ default:
+ super.notifyEvent(event);
+ }
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ unoAccessibleContext = unoAccessible.getAccessibleContext();
+ unoAccessibleSelection = (XAccessibleSelection) UnoRuntime.queryInterface(
+ XAccessibleSelection.class, unoAccessibleContext);
+ accessibleContext = new AccessibleTable();
+ } catch (java.lang.NullPointerException e) {
+ if (Build.DEBUG) {
+ System.err.println("NullPointerException caught: " + e.getMessage());
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ if (Build.DEBUG) {
+ System.err.println("RuntimeException caught: " + e.getMessage());
+ }
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleTable extends AccessibleDescendantManager {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleTable() {
+ super();
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.TABLE;
+ }
+
+ /** Returns the specified Accessible child of the object */
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ if (xAccessible != null) {
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant;
+ if ((activeDescendant instanceof TableCell) && xAccessible.equals(((TableCell) activeDescendant).unoAccessible)) {
+ child = activeDescendant;
+ } else {
+ child = new TableCell(xAccessible);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /*
+ * 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) {
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant;
+ if ((activeDescendant instanceof TableCell) && xAccessible.equals(((TableCell) activeDescendant).unoAccessible)) {
+ child = activeDescendant;
+ } else {
+ child = new TableCell(xAccessible);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+ }
+
+ class TableCell implements javax.accessibility.Accessible {
+
+ protected XAccessible unoAccessible;
+
+ public TableCell(XAccessible xAccessible) {
+ unoAccessible = xAccessible;
+ }
+
+ public Object[] create(Object[] targetSet) {
+ try {
+ java.util.ArrayList list = new java.util.ArrayList(targetSet.length);
+ for (int i=0; i < targetSet.length; i++) {
+ XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, targetSet[i]);
+ if (xAccessible != null) {
+ list.add(new TableCell(xAccessible));
+ }
+ }
+ list.trimToSize();
+ return list.toArray();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ javax.accessibility.AccessibleContext accessibleContext = null;
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext();
+ if (xAccessibleContext != null) {
+ accessibleContext = new AccessibleTableCell(xAccessibleContext);
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleTableCell extends javax.accessibility.AccessibleContext {
+
+ XAccessibleContext unoAccessibleContext;
+
+ public AccessibleTableCell(XAccessibleContext xAccessibleContext) {
+ unoAccessibleContext = xAccessibleContext;
+ }
+
+ /** Returns the accessible name of this object */
+ public String getAccessibleName() {
+ try {
+ return unoAccessibleContext.getAccessibleName();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Sets the accessible name of this object */
+ public void setAccessibleName(String name) {
+ // Not supported
+ }
+
+ /** Returns the accessible name of this object */
+ public String getAccessibleDescription() {
+ try {
+ return unoAccessibleContext.getAccessibleDescription();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Sets the accessible name of this object */
+ public void setAccessibleDescription(String name) {
+ // Not supported
+ }
+
+ /** Returns the accessible role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ try {
+ javax.accessibility.AccessibleRole role = AccessibleRoleAdapter.getAccessibleRole(
+ unoAccessibleContext.getAccessibleRole());
+ return (role != null) ? role : javax.accessibility.AccessibleRole.LABEL;
+ } 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 = unoAccessibleContext.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 Table.this.getLocale();
+ }
+ }
+
+ /** Gets the 0-based index of this object in its accessible parent */
+ public int getAccessibleIndexInParent() {
+ try {
+ return unoAccessibleContext.getAccessibleIndexInParent();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return -1;
+ }
+ }
+
+ /** Returns the number of accessible children of the object. */
+ public int getAccessibleChildrenCount() {
+ try {
+ return unoAccessibleContext.getAccessibleChildCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Returns the specified Accessible child of the object. */
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = Table.this.activeDescendant;
+ if ((activeDescendant instanceof TableCell) && ((TableCell) activeDescendant).unoAccessible.equals(xAccessible)) {
+ child = activeDescendant;
+ } else if (xAccessible != null) {
+ child = new TableCell(xAccessible);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /** Returns the state set of this object */
+ public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ try {
+ javax.accessibility.AccessibleStateSet stateSet = new javax.accessibility.AccessibleStateSet();
+ // table cells are transient and so neither focusable nor focused
+ stateSet.add(javax.accessibility.AccessibleState.TRANSIENT);
+
+ XAccessibleStateSet unoAccessibleStateSet = unoAccessibleContext.getAccessibleStateSet();
+ if (unoAccessibleStateSet.contains(AccessibleStateType.ENABLED)) {
+ stateSet.add(javax.accessibility.AccessibleState.ENABLED);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.OPAQUE)) {
+ stateSet.add(javax.accessibility.AccessibleState.OPAQUE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.RESIZABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.RESIZABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
+ stateSet.add(javax.accessibility.AccessibleState.SHOWING);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.VISIBLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.VISIBLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SINGLE_LINE)) {
+ stateSet.add(javax.accessibility.AccessibleState.SINGLE_LINE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.MULTILINE)) {
+ stateSet.add(javax.accessibility.AccessibleState.MULTI_LINE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.SELECTABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTED)) {
+ stateSet.add(javax.accessibility.AccessibleState.SELECTED);
+ }
+ return stateSet;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** 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.CONTROLLED_BY:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.CONTROLLED_BY,
+ create(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.CONTROLLER_FOR:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.CONTROLLER_FOR,
+ create(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.LABELED_BY:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.LABELED_BY,
+ create(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.LABEL_FOR:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.LABEL_FOR,
+ create(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.MEMBER_OF:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.MEMBER_OF,
+ create(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;
+ }
+ }
+
+ /** Gets the AccessibleComponent associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleComponent getAccessibleComponent() {
+ try {
+ XAccessibleComponent unoAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class, unoAccessibleContext);
+ return (unoAccessibleComponent != null) ?
+ new AccessibleComponentImpl(unoAccessibleComponent) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleAction associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ try {
+ XAccessibleAction unoAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext);
+ return (unoAccessibleAction != null) ?
+ new AccessibleActionImpl(unoAccessibleAction) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleText associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleText getAccessibleText() {
+ try {
+ XAccessibleText unoAccessibleText = (XAccessibleText)
+ UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext);
+ return (unoAccessibleText != null) ?
+ new AccessibleTextImpl(unoAccessibleText) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleValue associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleValue getAccessibleValue() {
+ 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 AccessibleText associated with this object presenting text on the display */
+ public javax.accessibility.AccessibleIcon[] getAccessibleIcon() {
+ try {
+ XAccessibleImage unoAccessibleImage = (XAccessibleImage)
+ UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleContext);
+ if (unoAccessibleImage != null) {
+ javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) };
+ return icons;
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return null;
+ }
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java b/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java
new file mode 100644
index 000000000000..444bfe42e9f4
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/TextComponent.java
@@ -0,0 +1,255 @@
+/*************************************************************************
+ *
+ * $RCSfile: TextComponent.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
+ *
+ * - 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 com.sun.star.uno.UnoRuntime;
+import drafts.com.sun.star.accessibility.*;
+
+/**
+ */
+public class TextComponent extends Component implements javax.accessibility.Accessible {
+
+ protected TextComponent(XAccessible accessible, XAccessibleComponent xAccessibleComponent, boolean multiLine) {
+ super();
+ initialize(accessible, xAccessibleComponent);
+ }
+
+ protected TextComponent(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 AccessibleTextComponentListener());
+ }
+
+ protected class AccessibleTextComponentListener extends AccessibleUNOComponentListener {
+
+ protected AccessibleTextComponentListener() {
+ super();
+ }
+
+ /** 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:
+ firePropertyChange(accessibleContext.ACCESSIBLE_CARET_PROPERTY,
+ toNumber(event.OldValue), toNumber(event.NewValue));
+ break;
+ default:
+ super.notifyEvent(event);
+ }
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleTextComponent();
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleTextComponent extends AccessibleUNOComponent {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleTextComponent() {
+ super();
+ }
+
+ /*
+ * AccessibleContext
+ */
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.TEXT;
+ }
+
+ /** 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;
+ }
+ }
+
+ /** Gets the AccessibleEditableText associated with this object presenting text on the display */
+ public javax.accessibility.AccessibleEditableText getAccessibleEditableText() {
+ try {
+ XAccessibleEditableText unoAccessibleText = (XAccessibleEditableText)
+ UnoRuntime.queryInterface(XAccessibleEditableText.class,unoAccessibleComponent);
+ if (unoAccessibleText != null) {
+ return new AccessibleEditableTextImpl(unoAccessibleText);
+ } else {
+ return null;
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleAction associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ try {
+ XAccessibleAction unoAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleComponent);
+ return (unoAccessibleAction != null) ?
+ new AccessibleActionImpl(unoAccessibleAction) : 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 javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ javax.accessibility.AccessibleStateSet states = super.getAccessibleStateSet();
+ try {
+ XAccessibleStateSet unoAccessibleStateSet =
+ unoAccessible.getAccessibleContext().getAccessibleStateSet();
+
+ if (unoAccessibleStateSet.contains(AccessibleStateType.EDITABLE)) {
+ states.add(javax.accessibility.AccessibleState.EDITABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.MULTILINE)) {
+ states.add(javax.accessibility.AccessibleState.MULTI_LINE);
+ } else {
+ states.add(javax.accessibility.AccessibleState.SINGLE_LINE);
+ }
+ } catch (NullPointerException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return states;
+ }
+
+ /** Returns the relation set of this object */
+ public javax.accessibility.AccessibleRelationSet getAccessibleRelationSet() {
+ try {
+ XAccessibleRelationSet unoAccessibleRelationSet =
+ unoAccessible.getAccessibleContext().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.CONTROLLED_BY:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.CONTROLLED_BY,
+ getAccessibleComponents(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.CONTROLLER_FOR:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.CONTROLLER_FOR,
+ getAccessibleComponents(unoAccessibleRelation.TargetSet)));
+ break;
+ case AccessibleRelationType.LABELED_BY:
+ relationSet.add(new javax.accessibility.AccessibleRelation(
+ javax.accessibility.AccessibleRelation.LABELED_BY,
+ 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/ToggleButton.java b/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java
new file mode 100644
index 000000000000..85fd85d31a4e
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/ToggleButton.java
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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 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;
+
+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();
+ }
+*/
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleToggleButton();
+ }
+ return accessibleContext;
+ }
+
+ 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;
+ }
+
+ /** Gets the AccessibleValue associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleValue getAccessibleValue() {
+ try {
+ XAccessibleValue unoAccessibleValue = (XAccessibleValue)
+ UnoRuntime.queryInterface(XAccessibleValue.class, unoAccessibleComponent);
+ return (unoAccessibleValue != null) ?
+ new AccessibleValueImpl(unoAccessibleValue) : 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
new file mode 100644
index 000000000000..e3cd26d40070
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Tree.java
@@ -0,0 +1,484 @@
+/*************************************************************************
+ *
+ * $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
+ *
+ * - 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.AccessibleContext;
+import javax.accessibility.AccessibleState;
+
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+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 void setActiveDescendant(javax.accessibility.Accessible descendant) {
+ javax.accessibility.Accessible oldAD = activeDescendant;
+ activeDescendant = descendant;
+ firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
+ oldAD, descendant);
+ }
+
+ protected void setActiveDescendant(Object any) {
+ javax.accessibility.Accessible descendant = null;
+ try {
+ if (AnyConverter.isObject(any)) {
+ XAccessible unoAccessible = (XAccessible) AnyConverter.toObject(
+ AbstractContainer.XAccessibleType, any);
+ if (unoAccessible != null) {
+ // FIXME: have to handle non transient objects here ..
+ descendant = new TreeItem(unoAccessible);
+ }
+ }
+ setActiveDescendant(descendant);
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void add(XAccessible unoAccessible) {
+ if (unoAccessible != null) {
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ null, new TreeItem(unoAccessible));
+ }
+ }
+
+ protected void remove(XAccessible unoAccessible) {
+ if (unoAccessible != null) {
+ firePropertyChange(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ new TreeItem(unoAccessible), null);
+ }
+ }
+
+ protected void add(Object any) {
+ try {
+ add((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ protected void remove(Object any) {
+ try {
+ remove((XAccessible) AnyConverter.toObject(AbstractContainer.XAccessibleType, any));
+ } catch (com.sun.star.lang.IllegalArgumentException e) {
+ }
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleTreeListener extends AccessibleDescendantManagerListener {
+
+ protected AccessibleTreeListener() {
+ super();
+ }
+
+ /** Called by OpenOffice process to notify property changes */
+ public void notifyEvent(AccessibleEventObject event) {
+ switch (event.EventId) {
+ case AccessibleEventId.ACCESSIBLE_ACTIVE_DESCENDANT_EVENT:
+ setActiveDescendant(event.NewValue);
+ break;
+ case AccessibleEventId.ACCESSIBLE_CHILD_EVENT:
+ if (AnyConverter.isObject(event.OldValue)) {
+ remove(event.OldValue);
+ }
+ if (AnyConverter.isObject(event.NewValue)) {
+ add(event.NewValue);
+ }
+ break;
+
+ default:
+ super.notifyEvent(event);
+ }
+ }
+ }
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ unoAccessibleContext = unoAccessible.getAccessibleContext();
+ unoAccessibleSelection = (XAccessibleSelection) UnoRuntime.queryInterface(
+ XAccessibleSelection.class, unoAccessibleContext);
+ if (unoAccessibleSelection != null) {
+ accessibleContext = new AccessibleTree();
+ }
+ } catch (java.lang.NullPointerException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleTree extends AccessibleDescendantManager {
+
+ /**
+ * Though the class is abstract, this should be called by all sub-classes
+ */
+ protected AccessibleTree() {
+ super();
+ }
+
+ /** Gets the role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ return javax.accessibility.AccessibleRole.TREE;
+ }
+
+ /** Returns the specified Accessible child of the object */
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ if (xAccessible != null) {
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant;
+ if ((activeDescendant instanceof TreeItem) && xAccessible.equals(((TreeItem) activeDescendant).unoAccessible)) {
+ child = activeDescendant;
+ } else {
+ child = new TreeItem(xAccessible);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /*
+ * 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) {
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant;
+ if ((activeDescendant instanceof TreeItem) && xAccessible.equals(((TreeItem) activeDescendant).unoAccessible)) {
+ child = activeDescendant;
+ } else {
+ child = new TreeItem(xAccessible);
+ }
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+ }
+
+ class TreeItem implements javax.accessibility.Accessible {
+
+ protected XAccessible unoAccessible;
+
+ public TreeItem(XAccessible xAccessible) {
+ unoAccessible = xAccessible;
+ }
+
+ public Object[] create(Object[] targetSet) {
+ try {
+ java.util.ArrayList list = new java.util.ArrayList(targetSet.length);
+ for (int i=0; i < targetSet.length; i++) {
+ XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface(
+ XAccessible.class, targetSet[i]);
+ if (xAccessible != null) {
+ list.add(new TreeItem(xAccessible));
+ }
+ }
+ list.trimToSize();
+ return list.toArray();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ javax.accessibility.AccessibleContext accessibleContext = null;
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ try {
+ XAccessibleContext xAccessibleContext = unoAccessible.getAccessibleContext();
+ if (xAccessibleContext != null) {
+ accessibleContext = new AccessibleTreeItem(xAccessibleContext);
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleTreeItem extends javax.accessibility.AccessibleContext {
+
+ XAccessibleContext unoAccessibleContext;
+
+ public AccessibleTreeItem(XAccessibleContext xAccessibleContext) {
+ unoAccessibleContext = xAccessibleContext;
+ }
+
+ /** Returns the accessible name of this object */
+ public String getAccessibleName() {
+ try {
+ return unoAccessibleContext.getAccessibleName();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Sets the accessible name of this object */
+ public void setAccessibleName(String name) {
+ // Not supported
+ }
+
+ /** Returns the accessible name of this object */
+ public String getAccessibleDescription() {
+ try {
+ return unoAccessibleContext.getAccessibleDescription();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Sets the accessible name of this object */
+ public void setAccessibleDescription(String name) {
+ // Not supported
+ }
+
+ /** Returns the accessible role of this object */
+ public javax.accessibility.AccessibleRole getAccessibleRole() {
+ try {
+ javax.accessibility.AccessibleRole role = AccessibleRoleAdapter.getAccessibleRole(
+ unoAccessibleContext.getAccessibleRole());
+ return (role != null) ? role : javax.accessibility.AccessibleRole.LABEL;
+ } 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 = unoAccessibleContext.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 Tree.this.getLocale();
+ }
+ }
+
+ /** Gets the 0-based index of this object in its accessible parent */
+ public int getAccessibleIndexInParent() {
+ try {
+ return unoAccessibleContext.getAccessibleIndexInParent();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return -1;
+ }
+ }
+
+ /** Returns the number of accessible children of the object. */
+ public int getAccessibleChildrenCount() {
+ try {
+ return unoAccessibleContext.getAccessibleChildCount();
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return 0;
+ }
+ }
+
+ /** Returns the specified Accessible child of the object. */
+ public javax.accessibility.Accessible getAccessibleChild(int i) {
+ javax.accessibility.Accessible child = null;
+ try {
+ XAccessible xAccessible = unoAccessibleContext.getAccessibleChild(i);
+ // Re-use the active descandant wrapper if possible
+ javax.accessibility.Accessible activeDescendant = Tree.this.activeDescendant;
+ if ((activeDescendant instanceof TreeItem) && ((TreeItem) activeDescendant).unoAccessible.equals(xAccessible)) {
+ child = activeDescendant;
+ } else if (xAccessible != null) {
+ child = new TreeItem(xAccessible);
+ }
+ } catch (com.sun.star.lang.IndexOutOfBoundsException e) {
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return child;
+ }
+
+ /** Returns the state set of this object */
+ public javax.accessibility.AccessibleStateSet getAccessibleStateSet() {
+ try {
+ javax.accessibility.AccessibleStateSet stateSet = new javax.accessibility.AccessibleStateSet();
+ // table cells are transient and so neither focusable nor focused
+ stateSet.add(javax.accessibility.AccessibleState.TRANSIENT);
+
+ XAccessibleStateSet unoAccessibleStateSet = unoAccessibleContext.getAccessibleStateSet();
+ if (unoAccessibleStateSet.contains(AccessibleStateType.ENABLED)) {
+ stateSet.add(javax.accessibility.AccessibleState.ENABLED);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.OPAQUE)) {
+ stateSet.add(javax.accessibility.AccessibleState.OPAQUE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.RESIZABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.RESIZABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SHOWING)) {
+ stateSet.add(javax.accessibility.AccessibleState.SHOWING);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.VISIBLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.VISIBLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SINGLE_LINE)) {
+ stateSet.add(javax.accessibility.AccessibleState.SINGLE_LINE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.MULTILINE)) {
+ stateSet.add(javax.accessibility.AccessibleState.MULTI_LINE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTABLE)) {
+ stateSet.add(javax.accessibility.AccessibleState.SELECTABLE);
+ }
+ if (unoAccessibleStateSet.contains(AccessibleStateType.SELECTED)) {
+ stateSet.add(javax.accessibility.AccessibleState.SELECTED);
+ }
+ return stateSet;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleComponent associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleComponent getAccessibleComponent() {
+ try {
+ XAccessibleComponent unoAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class, unoAccessibleContext);
+ return (unoAccessibleComponent != null) ?
+ new AccessibleComponentImpl(unoAccessibleComponent) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleAction associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleAction getAccessibleAction() {
+ try {
+ XAccessibleAction unoAccessibleAction = (XAccessibleAction)
+ UnoRuntime.queryInterface(XAccessibleAction.class, unoAccessibleContext);
+ return (unoAccessibleAction != null) ?
+ new AccessibleActionImpl(unoAccessibleAction) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleText associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleText getAccessibleText() {
+ try {
+ XAccessibleText unoAccessibleText = (XAccessibleText)
+ UnoRuntime.queryInterface(XAccessibleText.class, unoAccessibleContext);
+ return (unoAccessibleText != null) ?
+ new AccessibleTextImpl(unoAccessibleText) : null;
+ } catch (com.sun.star.uno.RuntimeException e) {
+ return null;
+ }
+ }
+
+ /** Gets the AccessibleValue associated with this object that has a graphical representation */
+ public javax.accessibility.AccessibleValue getAccessibleValue() {
+ 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 AccessibleText associated with this object presenting text on the display */
+ public javax.accessibility.AccessibleIcon[] getAccessibleIcon() {
+ try {
+ XAccessibleImage unoAccessibleImage = (XAccessibleImage)
+ UnoRuntime.queryInterface(XAccessibleImage.class, unoAccessibleContext);
+ if (unoAccessibleImage != null) {
+ javax.accessibility.AccessibleIcon[] icons = { new AccessibleIconImpl(unoAccessibleImage) };
+ return icons;
+ }
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ return null;
+ }
+ }
+ }
+}
+
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Window.java b/accessibility/bridge/org/openoffice/java/accessibility/Window.java
new file mode 100644
index 000000000000..b8f6fb6258ec
--- /dev/null
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Window.java
@@ -0,0 +1,507 @@
+/*************************************************************************
+ *
+ * $RCSfile: Window.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
+ *
+ * - 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 com.sun.star.uno.*;
+import drafts.com.sun.star.accessibility.*;
+
+public class Window extends java.awt.Window implements javax.accessibility.Accessible, NativeFrame {
+ protected XAccessibleComponent unoAccessibleComponent;
+
+ // The coordinates of this frame on screen
+ java.awt.Point location = null;
+
+ boolean opened = false;
+ boolean visible = false;
+
+ java.awt.EventQueue eventQueue = null;
+
+ public Window(java.awt.Frame owner, XAccessibleComponent xAccessibleComponent) {
+ super(owner);
+ initialize(xAccessibleComponent);
+ }
+
+ private void initialize(XAccessibleComponent xAccessibleComponent) {
+ unoAccessibleComponent = xAccessibleComponent;
+ eventQueue = java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
+ XAccessibleEventBroadcaster broadcaster = (XAccessibleEventBroadcaster)
+ UnoRuntime.queryInterface(XAccessibleEventBroadcaster.class,
+ unoAccessibleComponent);
+ if (broadcaster != null) {
+ broadcaster.addEventListener(new AccessibleWindowListener());
+ }
+ }
+
+ java.awt.Component initialComponent = null;
+
+ public java.awt.Component getInitialComponent() {
+ return initialComponent;
+ }
+
+ public void setInitialComponent(java.awt.Component c) {
+ initialComponent = c;
+ }
+
+ public Integer getHWND() {
+ return null;
+ }
+
+ /**
+ * Determines whether this <code>Component</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>Component</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() {
+// createHierarchyEvents(0, null, null, 0, false);
+ }
+
+ /**
+ * Makes this <code>Component</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() {
+ }
+
+ /**
+ * Determines if the object is visible. Note: this means that the
+ * object intends to be visible; however, it may not in fact be
+ * showing on the screen because one of the objects that this object
+ * is contained by is not visible. To determine if an object is
+ * showing on the screen, use <code>isShowing</code>.
+ *
+ * @return true if object is visible; otherwise, false
+ */
+ public boolean isVisible(){
+ return visible;
+ }
+
+ /**
+ * Shows or hides this component depending on the value of parameter
+ * <code>b</code>.
+ * @param b if <code>true</code>, shows this component;
+ * otherwise, hides this component
+ * @see #isVisible
+ * @since JDK1.1
+ */
+ public void setVisible(boolean b) {
+ if (visible != b){
+ visible = b;
+ if (b) {
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+
+ // If it is the first show, fire WINDOW_OPENED event
+ if (!opened) {
+ postWindowEvent(java.awt.event.WindowEvent.WINDOW_OPENED);
+ opened = true;
+ }
+ } else {
+ location = null;
+ }
+ }
+ }
+
+ protected void postWindowEvent(int i) {
+ eventQueue.postEvent(new java.awt.event.WindowEvent(this, i));
+ }
+
+ /** Returns the location of the object on the screen. */
+ public java.awt.Point getLocationOnScreen() {
+ if (visible) {
+ return new java.awt.Point(location);
+ }
+ return null;
+ }
+
+ /**
+ * Update the proxy objects appropriatly on property change events
+ */
+ protected class AccessibleWindowListener implements XAccessibleEventListener {
+
+ protected AccessibleWindowListener() {
+ }
+
+ // The only expected state changes are ACTIVE and VISIBLE
+ protected void setComponentState(short state, boolean enable) {
+ switch (state) {
+ case AccessibleStateType.ACTIVE:
+ postWindowEvent(enable ?
+ java.awt.event.WindowEvent.WINDOW_GAINED_FOCUS :
+ java.awt.event.WindowEvent.WINDOW_LOST_FOCUS);
+ break;
+ case AccessibleStateType.ICONIFIED:
+ Window.this.postWindowEvent(enable ?
+ java.awt.event.WindowEvent.WINDOW_ICONIFIED :
+ java.awt.event.WindowEvent.WINDOW_DEICONIFIED);
+ break;
+ case AccessibleStateType.SHOWING:
+ case AccessibleStateType.VISIBLE:
+ Window.this.setVisible(enable);
+ break;
+ default:
+ if (Build.DEBUG) {
+// System.err.println("[frame]: " + getTitle() + "unexpected state change " + state);
+ }
+ break;
+ }
+ }
+
+ /** Updates the accessible name and fires the appropriate PropertyChangedEvent */
+ protected void handleNameChangedEvent(Object any) {
+ try {
+// Window.this.setTitle(AnyConverter.toString(any));
+ 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.getDefault().getAccessibleComponent(
+ (XAccessible) AnyConverter.toObject(Container.XAccessibleType, any));
+ if (c != null) {
+ Window.this.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(AbstractContainer.XAccessibleType, any);
+ AccessibleObjectFactory factory = AccessibleObjectFactory.getDefault();
+ java.awt.Component c = factory.getAccessibleComponent(xAccessible);
+ if (c != null) {
+ // Seems to be already in child list
+ if (c.getParent().equals(this))
+ return;
+ } else {
+ c = factory.createAccessibleComponent(xAccessible);
+ }
+ if (c != null) {
+ Window.this.add(c, xAccessible.getAccessibleContext().
+ getAccessibleIndexInParent());
+ }
+ }
+
+ catch (com.sun.star.uno.Exception e) {
+ // FIXME: output
+ }
+ }
+
+ /** Fires a visible data property change event */
+ protected void handleVisibleDataEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Window.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** Updates internal bounding box cache */
+ protected void handleBoundRectEvent() {
+ try {
+ com.sun.star.awt.Rectangle r = unoAccessibleComponent.getBounds();
+ Window.this.setBounds(r.X, r.Y, r.Width, r.Height);
+ com.sun.star.awt.Point p = unoAccessibleComponent.getLocationOnScreen();
+ location = new java.awt.Point(p.X, p.Y);
+ } catch (com.sun.star.uno.RuntimeException e) {
+ }
+ }
+
+ /** 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:
+ handleVisibleDataEvent();
+ break;
+ case AccessibleEventId.ACCESSIBLE_BOUNDRECT_EVENT:
+ handleBoundRectEvent();
+ 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) {
+ }
+ }
+
+ protected javax.accessibility.AccessibleContext accessibleContext = null;
+
+ /** Returns the AccessibleContext associated with this object */
+ public javax.accessibility.AccessibleContext getAccessibleContext() {
+ if (accessibleContext == null) {
+ accessibleContext = new AccessibleWindow();
+// accessibleContext.setAccessibleName(getTitle());
+ }
+ return accessibleContext;
+ }
+
+ protected class AccessibleWindow extends java.awt.Window.AccessibleAWTWindow {
+ protected AccessibleWindow() {
+ super();
+ }
+
+ 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) {
+ AccessibleWindow.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ javax.accessibility.AccessibleState.VISIBLE, null);
+ }
+
+ public void componentShown(java.awt.event.ComponentEvent e) {
+ AccessibleWindow.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, javax.accessibility.AccessibleState.VISIBLE);
+ }
+
+ public void componentMoved(java.awt.event.ComponentEvent e) {
+ }
+
+ public void componentResized(java.awt.event.ComponentEvent e) {
+ }
+ } // inner class AccessibleComponentHandler
+
+ protected java.awt.event.WindowFocusListener accessibleWindowFocusHandler = null;
+
+ /**
+ * Fire PropertyChange listener, if one is registered,
+ * when focus events happen
+ */
+ protected class AccessibleWindowFocusHandler implements java.awt.event.WindowFocusListener {
+ public void windowGainedFocus(java.awt.event.WindowEvent e) {
+ AccessibleWindow.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ null, javax.accessibility.AccessibleState.ACTIVE);
+ }
+ public void windowLostFocus(java.awt.event.WindowEvent e) {
+ AccessibleWindow.this.firePropertyChange(
+ javax.accessibility.AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
+ javax.accessibility.AccessibleState.ACTIVE, 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) {
+ AccessibleWindow.this.firePropertyChange(
+ javax.accessibility.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) {
+ AccessibleWindow.this.firePropertyChange(
+ javax.accessibility.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) {
+ accessibleWindowFocusHandler = new AccessibleWindowFocusHandler();
+ Window.this.addWindowFocusListener(accessibleWindowFocusHandler);
+
+ accessibleContainerHandler = new AccessibleContainerHandler();
+ Window.this.addContainerListener(accessibleContainerHandler);
+
+ accessibleComponentHandler = new AccessibleComponentHandler();
+ Window.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) {
+ Window.this.removeComponentListener(accessibleComponentHandler);
+ accessibleComponentHandler = null;
+
+ Window.this.removeContainerListener(accessibleContainerHandler);
+ accessibleContainerHandler = null;
+
+ Window.this.removeWindowFocusListener(accessibleWindowFocusHandler);
+ accessibleWindowFocusHandler = null;
+ }
+ super.removePropertyChangeListener(listener);
+ }
+ }
+}
+