summaryrefslogtreecommitdiff
path: root/accessibility/bridge/org/openoffice/java/accessibility/Container.java
diff options
context:
space:
mode:
Diffstat (limited to 'accessibility/bridge/org/openoffice/java/accessibility/Container.java')
-rw-r--r--accessibility/bridge/org/openoffice/java/accessibility/Container.java226
1 files changed, 113 insertions, 113 deletions
diff --git a/accessibility/bridge/org/openoffice/java/accessibility/Container.java b/accessibility/bridge/org/openoffice/java/accessibility/Container.java
index 257cdab8b757..b047075607ae 100644
--- a/accessibility/bridge/org/openoffice/java/accessibility/Container.java
+++ b/accessibility/bridge/org/openoffice/java/accessibility/Container.java
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -34,7 +34,7 @@ import com.sun.star.uno.*;
import com.sun.star.accessibility.*;
public class Container extends java.awt.Container implements javax.accessibility.Accessible {
-
+
protected XAccessible unoAccessible;
protected XAccessibleContext unoAccessibleContext;
protected XAccessibleComponent unoAccessibleComponent = null;
@@ -42,14 +42,14 @@ public class Container extends java.awt.Container implements javax.accessibility
protected javax.accessibility.AccessibleRole accessibleRole;
protected javax.accessibility.AccessibleText accessibleText;
protected boolean disposed = false;
-
+
protected Container(javax.accessibility.AccessibleRole role,
XAccessible xAccessible, XAccessibleContext xAccessibleContext) {
accessibleRole = role;
unoAccessible = xAccessible;
unoAccessibleContext = xAccessibleContext;
- unoAccessibleComponent = (XAccessibleComponent)
- UnoRuntime.queryInterface(XAccessibleComponent.class,
+ unoAccessibleComponent = (XAccessibleComponent)
+ UnoRuntime.queryInterface(XAccessibleComponent.class,
xAccessibleContext);
// Add the event listener right away, because the global focus notification doesn't
@@ -61,10 +61,10 @@ public class Container extends java.awt.Container implements javax.accessibility
broadcaster.addEventListener(createEventListener());
}
}
-
+
/**
- * Determines whether this <code>Container</code> is showing on screen.
- * This means that the component must be visible, and it must be in a
+ * Determines whether this <code>Container</code> is showing on screen.
+ * This means that the component must be visible, and it must be in a
* <code>container</code> that is visible and showing.
* @see #addNotify
* @see #removeNotify
@@ -77,10 +77,10 @@ public class Container extends java.awt.Container implements javax.accessibility
}
return false;
}
-
+
/**
* Makes this <code>Container</code> displayable by connecting it to a
- * native screen resource.
+ * native screen resource.
* This method is called internally by the toolkit and should
* not be called directly by programs.
* @see #isDisplayable
@@ -89,10 +89,10 @@ public class Container extends java.awt.Container implements javax.accessibility
*/
public void addNotify() {
}
-
- /**
+
+ /**
* Makes this <code>Container</code> undisplayable by destroying it native
- * screen resource.
+ * screen resource.
* This method is called by the toolkit internally and should
* not be called directly by programs.
* @see #isDisplayable
@@ -111,27 +111,27 @@ public class Container extends java.awt.Container implements javax.accessibility
/** Requests focus for this object */
public void requestFocus() {
}
-
+
/** Requests focus for this object */
public boolean requestFocus(boolean temporary) {
// Must be a no-op to make focus handling work
return true;
}
-
+
/** Requests the focus for this object in the containing window */
public boolean requestFocusInWindow() {
return requestFocusInWindow(false);
}
-
+
/** Requests the focus for this object in the containing window */
protected boolean requestFocusInWindow(boolean temporary) {
if (isFocusable() && isVisible()) {
- getEventQueue().postEvent(new java.awt.event.FocusEvent(this, java.awt.event.FocusEvent.FOCUS_GAINED, temporary));
+ getEventQueue().postEvent(new java.awt.event.FocusEvent(this, java.awt.event.FocusEvent.FOCUS_GAINED, temporary));
return true;
}
return false;
}
-
+
public Object[] getAccessibleComponents(Object[] targetSet) {
try {
java.util.ArrayList list = new java.util.ArrayList(targetSet.length);
@@ -148,22 +148,22 @@ public class Container extends java.awt.Container implements javax.accessibility
return null;
}
}
-
+
protected java.awt.EventQueue getEventQueue() {
return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
}
-
+
protected class PropertyChangeBroadcaster implements Runnable {
String propertyName;
Object oldValue;
Object newValue;
-
+
public PropertyChangeBroadcaster(String name, Object param1, Object param2) {
propertyName = name;
oldValue = param1;
newValue = param2;
}
-
+
public void run() {
// Because this code is executed in the DispatchThread, it is better tocatch every
// exception that might occur
@@ -180,11 +180,11 @@ public class Container extends java.awt.Container implements javax.accessibility
}
}
}
-
+
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) {
@@ -198,19 +198,19 @@ public class Container extends java.awt.Container implements javax.accessibility
}
getEventQueue().invokeLater(broadcaster);
}
-
+
/**
* Update the proxy objects appropriatly on property change events
*/
protected class AccessibleContainerListener implements XAccessibleEventListener {
-
+
protected AccessibleContainerListener() {
}
-
+
protected java.awt.EventQueue getEventQueue() {
return java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue();
}
-
+
protected void setComponentState(short state, boolean enable) {
switch (state) {
case AccessibleStateType.ACTIVE:
@@ -224,8 +224,8 @@ public class Container extends java.awt.Container implements javax.accessibility
break;
case AccessibleStateType.FOCUSED:
getEventQueue().postEvent(new java.awt.event.FocusEvent(
- Container.this, enable ?
- java.awt.event.FocusEvent.FOCUS_GAINED :
+ Container.this, enable ?
+ java.awt.event.FocusEvent.FOCUS_GAINED :
java.awt.event.FocusEvent.FOCUS_LOST));
break;
case AccessibleStateType.SELECTED:
@@ -257,7 +257,7 @@ public class Container extends java.awt.Container implements javax.accessibility
} catch (com.sun.star.lang.IllegalArgumentException e) {
}
}
-
+
/** Updates the accessible description and fires the appropriate PropertyChangedEvent */
protected void handleDescriptionChangedEvent(Object any) {
try {
@@ -270,21 +270,21 @@ public class Container extends java.awt.Container implements javax.accessibility
} 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) {
}
}
-
+
/* This event is only necessary because some objects in the office don't know their parent
* and are therefor unable to revoke and re-insert themselves.
*/
@@ -293,15 +293,15 @@ public class Container extends java.awt.Container implements javax.accessibility
if (parent != null) {
javax.accessibility.AccessibleContext parentAC = parent.getAccessibleContext();
if (parentAC != null) {
-
+
parentAC.firePropertyChange(
javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
Container.this,
null);
-
- AccessibleObjectFactory.clearContainer(Container.this);
+
+ AccessibleObjectFactory.clearContainer(Container.this);
AccessibleObjectFactory.populateContainer(Container.this, unoAccessibleContext);
-
+
parentAC.firePropertyChange(
javax.accessibility.AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
null,
@@ -309,12 +309,12 @@ public class Container extends java.awt.Container implements javax.accessibility
}
}
}
-
+
/** Called by OpenOffice process to notify property changes */
public void notifyEvent(AccessibleEventObject event) {
-
+
if ( !disposed ) {
-
+
switch (event.EventId) {
case AccessibleEventId.NAME_CHANGED:
// Set the accessible name for the corresponding context, which will fire a property
@@ -332,7 +332,7 @@ public class Container extends java.awt.Container implements javax.accessibility
break;
case AccessibleEventId.TEXT_CHANGED:
firePropertyChange(AccessibleContext.ACCESSIBLE_TEXT_PROPERTY,
- AccessibleTextImpl.convertTextSegment(event.OldValue),
+ AccessibleTextImpl.convertTextSegment(event.OldValue),
AccessibleTextImpl.convertTextSegment(event.NewValue));
break;
case AccessibleEventId.CHILD:
@@ -365,20 +365,20 @@ public class Container extends java.awt.Container implements javax.accessibility
}
}
}
-
+
/** Called by OpenOffice process to notify that the UNO component is disposing */
public void disposing(com.sun.star.lang.EventObject eventObject) {
disposed = true;
AccessibleObjectFactory.disposing(Container.this);
}
}
-
+
protected XAccessibleEventListener createEventListener() {
return new AccessibleContainerListener();
}
-
+
protected javax.accessibility.AccessibleContext accessibleContext = null;
-
+
/** This method actually creates the AccessibleContext object returned by
* getAccessibleContext().
*/
@@ -392,7 +392,7 @@ public class Container extends java.awt.Container implements javax.accessibility
try {
AccessibleContext ac = createAccessibleContext();
if (ac != null) {
- // Set accessible name and description here to avoid
+ // Set accessible name and description here to avoid
// unnecessary property change events later ..
ac.setAccessibleName(unoAccessibleContext.getAccessibleName());
ac.setAccessibleDescription(unoAccessibleContext.getAccessibleDescription());
@@ -403,11 +403,11 @@ public class Container extends java.awt.Container implements javax.accessibility
}
return accessibleContext;
}
-
- protected class AccessibleContainer extends java.awt.Container.AccessibleAWTContainer {
+
+ protected class AccessibleContainer extends java.awt.Container.AccessibleAWTContainer {
protected AccessibleContainer() {
- /* Since getAccessibleText() is heavily used by the java access
+ /* Since getAccessibleText() is heavily used by the java access
* bridge for gnome and the gnome at-tools, we do a query interface
* here and remember the result.
*/
@@ -416,13 +416,13 @@ public class Container extends java.awt.Container implements javax.accessibility
protected AccessibleContainer(boolean query) {
/* This constructor is explicitly for subclasses that implement
- * AccessibleHypertext and therefor the default constructor would
+ * AccessibleHypertext and therefor the default constructor would
* bring unnecessary overhead.
*/
}
-
+
protected java.awt.event.ComponentListener accessibleComponentHandler = null;
-
+
/**
* Fire PropertyChange listener, if one is registered,
* when shown/hidden..
@@ -433,22 +433,22 @@ public class Container extends java.awt.Container implements javax.accessibility
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
AccessibleState.VISIBLE, null);
}
-
+
public void componentShown(java.awt.event.ComponentEvent e) {
AccessibleContainer.this.firePropertyChange(
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
null, AccessibleState.VISIBLE);
}
-
+
public void componentMoved(java.awt.event.ComponentEvent e) {
}
-
+
public void componentResized(java.awt.event.ComponentEvent e) {
}
} // inner class AccessibleContainerHandler
-
+
protected java.awt.event.FocusListener accessibleFocusHandler = null;
-
+
/**
* Fire PropertyChange listener, if one is registered,
* when focus events happen
@@ -471,20 +471,20 @@ public class Container extends java.awt.Container implements javax.accessibility
}
}
} // inner class AccessibleFocusHandler
-
+
protected java.awt.event.ContainerListener accessibleContainerHandler = null;
-
+
/**
* Fire PropertyChange listener, if one is registered,
* when children added/removed.
*/
-
+
protected class AccessibleContainerHandler implements java.awt.event.ContainerListener {
public void componentAdded(java.awt.event.ContainerEvent e) {
java.awt.Component c = e.getChild();
if (c != null && c instanceof javax.accessibility.Accessible) {
AccessibleContainer.this.firePropertyChange(
- AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
null, ((javax.accessibility.Accessible) c).getAccessibleContext());
}
}
@@ -492,14 +492,14 @@ public class Container extends java.awt.Container implements javax.accessibility
java.awt.Component c = e.getChild();
if (c != null && c instanceof javax.accessibility.Accessible) {
AccessibleContainer.this.firePropertyChange(
- AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
- ((javax.accessibility.Accessible) c).getAccessibleContext(), null);
+ AccessibleContext.ACCESSIBLE_CHILD_PROPERTY,
+ ((javax.accessibility.Accessible) c).getAccessibleContext(), null);
}
}
}
-
+
protected int propertyChangeListenerCount = 0;
-
+
/**
* Add a PropertyChangeListener to the listener list.
*
@@ -509,16 +509,16 @@ public class Container extends java.awt.Container implements javax.accessibility
if (propertyChangeListenerCount++ == 0) {
accessibleFocusHandler = new AccessibleFocusHandler();
Container.this.addFocusListener(accessibleFocusHandler);
-
+
accessibleContainerHandler = new AccessibleContainerHandler();
Container.this.addContainerListener(accessibleContainerHandler);
-
+
accessibleComponentHandler = new AccessibleComponentHandler();
Container.this.addComponentListener(accessibleComponentHandler);
}
super.addPropertyChangeListener(listener);
}
-
+
/**
* Remove a PropertyChangeListener from the listener list.
* This removes a PropertyChangeListener that was registered
@@ -530,30 +530,30 @@ public class Container extends java.awt.Container implements javax.accessibility
if (--propertyChangeListenerCount == 0) {
Container.this.removeComponentListener(accessibleComponentHandler);
accessibleComponentHandler = null;
-
+
Container.this.removeContainerListener(accessibleContainerHandler);
accessibleContainerHandler = null;
-
+
Container.this.removeFocusListener(accessibleFocusHandler);
accessibleFocusHandler = null;
}
super.removePropertyChangeListener(listener);
}
-
+
/** Gets the role of this object */
public javax.accessibility.AccessibleRole getAccessibleRole() {
return accessibleRole;
}
-
+
/** Gets the AccessibleText associated with this object presenting text on the display */
public javax.accessibility.AccessibleText getAccessibleText() {
-
+
if (disposed)
return null;
-
+
return accessibleText;
}
-
+
/**
* Gets the current state set of this object.
*
@@ -572,21 +572,21 @@ public class Container extends java.awt.Container implements javax.accessibility
return AccessibleStateAdapter.getDefunctStateSet();
}
}
-
+
/** Returns the AccessibleSelection interface for this object */
public javax.accessibility.AccessibleSelection getAccessibleSelection() {
try {
- XAccessibleSelection unoAccessibleSelection = (XAccessibleSelection)
+ XAccessibleSelection unoAccessibleSelection = (XAccessibleSelection)
UnoRuntime.queryInterface(XAccessibleSelection.class, unoAccessibleContext);
if (unoAccessibleSelection != null) {
return new AccessibleSelectionImpl(unoAccessibleSelection);
}
} catch (com.sun.star.uno.RuntimeException e) {
}
-
+
return null;
}
-
+
/** Gets the locale of the component */
public java.util.Locale getLocale() throws java.awt.IllegalComponentStateException {
try {
@@ -598,11 +598,11 @@ public class Container extends java.awt.Container implements javax.accessibility
return super.getLocale();
}
}
-
+
/*
* AccessibleComponent
*/
-
+
/** Returns the background color of the object */
public java.awt.Color getBackground() {
try {
@@ -611,11 +611,11 @@ public class Container extends java.awt.Container implements javax.accessibility
return null;
}
}
-
+
public void setBackground(java.awt.Color c) {
// Not supported by UNO accessibility API
}
-
+
/** Returns the foreground color of the object */
public java.awt.Color getForeground() {
try {
@@ -624,138 +624,138 @@ public class Container extends java.awt.Container implements javax.accessibility
return null;
}
}
-
+
public void setForeground(java.awt.Color c) {
// Not supported by UNO accessibility API
}
-
+
public java.awt.Cursor getCursor() {
// Not supported by UNO accessibility API
return null;
}
-
+
public void setCursor(java.awt.Cursor cursor) {
// Not supported by UNO accessibility API
}
-
+
public java.awt.Font getFont() {
// FIXME
return null;
}
-
+
public void setFont(java.awt.Font f) {
// Not supported by UNO accessibility API
}
-
+
public java.awt.FontMetrics getFontMetrics(java.awt.Font f) {
// FIXME
return null;
}
-
+
public boolean isEnabled() {
return Container.this.isEnabled();
}
-
+
public void setEnabled(boolean b) {
// Not supported by UNO accessibility API
}
-
+
public boolean isVisible() {
return Container.this.isVisible();
}
-
+
public void setVisible(boolean b) {
// Not supported by UNO accessibility API
}
-
+
public boolean isShowing() {
return Container.this.isShowing();
}
-
+
public boolean contains(java.awt.Point p) {
try {
- return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y));
+ return unoAccessibleComponent.containsPoint(new com.sun.star.awt.Point(p.x, p.y));
} catch (com.sun.star.uno.RuntimeException e) {
return false;
}
}
-
+
/** Returns the location of the object on the screen. */
public java.awt.Point getLocationOnScreen() {
try {
- com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen();
+ com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocationOnScreen();
return new java.awt.Point(unoPoint.X, unoPoint.Y);
} catch (com.sun.star.uno.RuntimeException e) {
return null;
}
}
-
+
/** Gets the location of this component in the form of a point specifying the component's top-left corner */
public java.awt.Point getLocation() {
try {
- com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation();
+ com.sun.star.awt.Point unoPoint = unoAccessibleComponent.getLocation();
return new java.awt.Point( unoPoint.X, unoPoint.Y );
} catch (com.sun.star.uno.RuntimeException e) {
return null;
}
}
-
+
/** Moves this component to a new location */
public void setLocation(java.awt.Point p) {
// Not supported by UNO accessibility API
}
-
+
/** Gets the bounds of this component in the form of a Rectangle object */
public java.awt.Rectangle getBounds() {
try {
- com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds();
+ com.sun.star.awt.Rectangle unoRect = unoAccessibleComponent.getBounds();
return new java.awt.Rectangle(unoRect.X, unoRect.Y, unoRect.Width, unoRect.Height);
} catch (com.sun.star.uno.RuntimeException e) {
return null;
}
}
-
+
/** Moves and resizes this component to conform to the new bounding rectangle r */
public void setBounds(java.awt.Rectangle r) {
// Not supported by UNO accessibility API
}
-
+
/** Returns the size of this component in the form of a Dimension object */
public java.awt.Dimension getSize() {
try {
- com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize();
+ com.sun.star.awt.Size unoSize = unoAccessibleComponent.getSize();
return new java.awt.Dimension(unoSize.Width, unoSize.Height);
} catch (com.sun.star.uno.RuntimeException e) {
return null;
}
}
-
+
/** Resizes this component so that it has width d.width and height d.height */
public void setSize(java.awt.Dimension d) {
// Not supported by UNO accessibility API
}
- /** Returns the Accessible child, if one exists, contained at the local coordinate Point */
+ /** Returns the Accessible child, if one exists, contained at the local coordinate Point */
public javax.accessibility.Accessible getAccessibleAt(java.awt.Point p) {
try {
java.awt.Component c = AccessibleObjectFactory.getAccessibleComponent(
unoAccessibleComponent.getAccessibleAtPoint(new com.sun.star.awt.Point(p.x, p.y)));
-
+
return (javax.accessibility.Accessible) c;
} catch (com.sun.star.uno.RuntimeException e) {
return null;
}
}
-
+
public boolean isFocusTraversable() {
return Container.this.isFocusable();
}
-
+
public void requestFocus() {
unoAccessibleComponent.grabFocus();
}
}
-
+
public String toString() {
return UnoRuntime.generateOid(unoAccessible);
}