summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--toolkit/test/accessibility/AccTreeNode.java31
-rw-r--r--toolkit/test/accessibility/AccessibilityTreeModel.java177
-rw-r--r--toolkit/test/accessibility/AccessibleComponentHandler.java34
-rw-r--r--toolkit/test/accessibility/AccessibleContextHandler.java10
-rw-r--r--toolkit/test/accessibility/NodeHandler.java6
5 files changed, 186 insertions, 72 deletions
diff --git a/toolkit/test/accessibility/AccTreeNode.java b/toolkit/test/accessibility/AccTreeNode.java
index 36d656676176..e3564b8b1105 100644
--- a/toolkit/test/accessibility/AccTreeNode.java
+++ b/toolkit/test/accessibility/AccTreeNode.java
@@ -275,4 +275,35 @@ class AccTreeNode
}
return null;
}
+
+ /** Update the specified handlers. This results in re-reading the
+ information regarding the XAccessibleComponentInterface.
+ @return
+ The returned array containes the indices of the updated children
+ and can be used to create a TreeModelEvent.
+ */
+ public Vector update (java.lang.Class class1)
+ {return update (class1, null); }
+ public Vector update (java.lang.Class class1, java.lang.Class class2)
+ {
+ Vector aChildIndices = new Vector();
+ int nOffset = 0;
+ for(int i=0; i < maHandlers.size(); i++)
+ {
+ HandlerDescriptor aDescriptor = getHandlerDescriptor (i);
+ if ((class1.isInstance(aDescriptor.maHandler))
+ || (class2 !=null && class2.isInstance(aDescriptor.maHandler)))
+ {
+ aDescriptor.maHandler.update(this);
+ // Get updated number of children.
+ int nChildCount = aDescriptor.maHandler.getChildCount (this);
+ aDescriptor.mnChildCount = nChildCount;
+ // Fill in the indices of the updated children.
+ for (int j=0; j<nChildCount; j++)
+ aChildIndices.add(new Integer(j+nOffset));
+ }
+ nOffset += aDescriptor.mnChildCount;
+ }
+ return aChildIndices;
+ }
}
diff --git a/toolkit/test/accessibility/AccessibilityTreeModel.java b/toolkit/test/accessibility/AccessibilityTreeModel.java
index 978f64a314e0..9533043ef311 100644
--- a/toolkit/test/accessibility/AccessibilityTreeModel.java
+++ b/toolkit/test/accessibility/AccessibilityTreeModel.java
@@ -51,6 +51,9 @@ public class AccessibilityTreeModel
private static NodeHandler maHyperlinkHandler = new AccessibleHyperlinkHandler();
private static NodeHandler maTreeHandler = new AccessibleTreeHandler();
+ private Canvas maCanvas;
+
+
public AccessibilityTreeModel (AccessibleTreeNode aRoot, MessageInterface aMessageArea, Print aPrinter)
{
// create default node (unless we have a 'proper' node)
@@ -271,18 +274,25 @@ public class AccessibilityTreeModel
*/
protected AccessibleTreeNode addChild (AccTreeNode aParentNode, XAccessible xNewChild)
{
- boolean bRet = false;
+ AccessibleTreeNode aChildNode = null;
+ try
+ {
+ boolean bRet = false;
- // First make sure that the accessible object does not already have
- // a representation.
- AccessibleTreeNode aChildNode = (AccessibleTreeNode)maXAccessibleToNode.get (xNewChild);
- if (aChildNode == null)
- return aParentNode.addAccessibleChild (xNewChild);
- else
+ // First make sure that the accessible object does not already have
+ // a representation.
+ aChildNode = (AccessibleTreeNode)maXAccessibleToNode.get (xNewChild);
+ if (aChildNode == null)
+ aChildNode = aParentNode.addAccessibleChild (xNewChild);
+ else
+ System.out.println ("node already present");
+ }
+ catch (Exception e)
{
- System.out.println ("node already present");
- return aChildNode;
+ System.out.println ("caught exception while adding child " + xNewChild
+ + " to parent " + aParentNode + ": " + e);
}
+ return aChildNode;
}
@@ -293,20 +303,26 @@ public class AccessibilityTreeModel
protected boolean addNode (AccessibleTreeNode aNode)
{
boolean bRet = false;
-
- if (aNode instanceof AccTreeNode)
+ try
{
- AccTreeNode aChild = (AccTreeNode)aNode;
- XAccessible xChild = aChild.getAccessible();
- if (maXAccessibleToNode.get (xChild) == null)
+ if (aNode instanceof AccTreeNode)
{
- registerAccListener (aChild);
+ AccTreeNode aChild = (AccTreeNode)aNode;
+ XAccessible xChild = aChild.getAccessible();
+ if (maXAccessibleToNode.get (xChild) == null)
+ {
+ registerAccListener (aChild);
maXAccessibleToNode.put (xChild, aChild);
addToCanvas (aChild);
+ }
+ bRet = true;
}
- bRet = true;
- }
+ }
+ catch (Exception e)
+ {
+ System.out.println ("caught exception while adding node " + aNode + ": " + e);
+ }
return bRet;
}
@@ -380,7 +396,8 @@ public class AccessibilityTreeModel
protected TreeModelEvent createEvent (XAccessible xParent)
{
- return createEvent (xParent, null );
+ AccessibleTreeNode aParentNode = (AccessibleTreeNode)maXAccessibleToNode.get (xParent);
+ return new TreeModelEvent (this, createPath (aParentNode));
}
/** Create a TreeModelEvent object that informs listeners that one child
@@ -390,6 +407,7 @@ public class AccessibilityTreeModel
{
// get parent node and create the tree path
AccessibleTreeNode aParentNode = (AccessibleTreeNode)maXAccessibleToNode.get (xParent);
+ System.out.println (xParent);
Object[] aPathToParent = createPath (aParentNode);
AccessibleTreeNode aChildNode = null;
@@ -399,8 +417,6 @@ public class AccessibilityTreeModel
if (xChild != null)
nIndexInParent = aParentNode.indexOf (aChildNode);
- System.out.println (aParentNode + " " + aChildNode);
-
if (nIndexInParent == -1)
// This event may be passed only to treeStructureChanged of the listeners.
return new TreeModelEvent (this,
@@ -413,6 +429,29 @@ public class AccessibilityTreeModel
new Object[] {aChildNode} );
}
+ /** Create a TreeModelEvent that indicates changes at those children of
+ the specified node with the specified indices.
+ */
+ protected TreeModelEvent createChangeEvent (AccTreeNode aNode, Vector aChildIndices)
+ {
+ // Build a list of child objects that are indicated by the given indices.
+ int nCount = aChildIndices.size();
+ Object aChildObjects[] = new Object[nCount];
+ int nChildIndices[] = new int[nCount];
+ for (int i=0; i<nCount; i++)
+ {
+ int nIndex = ((Integer)aChildIndices.elementAt(i)).intValue();
+ aChildObjects[i] = aNode.getChild (nIndex);
+ nChildIndices[i] = nIndex;
+ }
+
+ return new TreeModelEvent (this,
+ createPath(aNode),
+ nChildIndices,
+ aChildObjects);
+ }
+
+
/**
* broadcast a tree event in a seperate Thread
@@ -565,6 +604,8 @@ public class AccessibilityTreeModel
private static String objectToString(Object aObject)
{
+ return aObject.toString();
+ /*
if( aObject instanceof Any )
aObject = ((Any)aObject).getObject();
@@ -578,12 +619,14 @@ public class AccessibilityTreeModel
}
return (aObject != null) ? aObject.toString() : null;
+ */
}
public void disposing( EventObject aEvent)
{
- /* System.out.println("dispose: " + objectToString(aEvent.Source));
-
+ System.out.println("dispose: " + objectToString(aEvent.Source));
+ removeChild ((AccessibleTreeNode)maXAccessibleToNode.get (aEvent.Source));
+ /*
if( knowsNode( aEvent.Source ) )
{
System.out.println("ERROR: Dispose for living node called! " +
@@ -593,6 +636,21 @@ public class AccessibilityTreeModel
}
*/
}
+ private void handleEvent (XAccessible xSource, java.lang.Class class1)
+ { handleEvent (xSource, class1,null); }
+ private void handleEvent (XAccessible xSource, java.lang.Class class1, java.lang.Class class2)
+ {
+ AccessibleTreeNode aNode = (AccessibleTreeNode)maXAccessibleToNode.get (xSource);
+ if (aNode instanceof AccTreeNode)
+ {
+ Vector aChildIndices = ((AccTreeNode)aNode).update (
+ class1, class2);
+ fireTreeNodesChanged (
+ createChangeEvent ((AccTreeNode)aNode, aChildIndices));
+ updateOnCanvas ((AccTreeNode)aNode);
+ maCanvas.repaint ();
+ }
+ }
static final String[] aEventNames =
{
@@ -621,8 +679,8 @@ public class AccessibilityTreeModel
nId = 0;
System.out.println( "notify: " + aEvent.EventId + " "
- + aEventNames[nId] + ": "
- + objectToString(aEvent.Source) + " "
+ + aEventNames[nId] + ": ["
+ + objectToString(aEvent.Source) + "] "
+ objectToString(aEvent.OldValue) + "->"
+ objectToString(aEvent.NewValue) );
@@ -663,7 +721,7 @@ public class AccessibilityTreeModel
AccessibleTreeNode aChild = addChild ((AccTreeNode)aParentNode, xNew);
if (addNode (aChild))
{
- ((AccTreeNode)aParentNode).update ();
+ // ((AccTreeNode)aParentNode).update ();
updateOnCanvas ((AccTreeNode)aParentNode);
// A call to fireTreeNodesInserted for xNew
@@ -673,7 +731,8 @@ public class AccessibilityTreeModel
// index relative to its parent. Therefore the
// more expensive fireTreeStructureChanged is
// necessary.
- fireTreeStructureChanged (createEvent (xSource));
+ fireTreeNodesInserted (createEvent (xSource, xNew));
+ handleEvent (xSource, AccessibleTreeHandler.class);
}
}
}
@@ -690,42 +749,47 @@ public class AccessibilityTreeModel
break;
case AccessibleEventId.ACCESSIBLE_VISIBLE_DATA_EVENT:
- case AccessibleEventId.ACCESSIBLE_ACTIVE_DESCENDANT_EVENT:
- case AccessibleEventId.ACCESSIBLE_ACTION_EVENT:
- case AccessibleEventId.ACCESSIBLE_CARET_EVENT:
- case AccessibleEventId.ACCESSIBLE_DESCRIPTION_EVENT:
- case AccessibleEventId.ACCESSIBLE_HYPERTEXT_OFFSET:
+ handleEvent (xSource,
+ AccessibleComponentHandler.class,
+ AccessibleExtendedComponentHandler.class);
+ break;
+
+
case AccessibleEventId.ACCESSIBLE_NAME_EVENT:
- case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
+ case AccessibleEventId.ACCESSIBLE_DESCRIPTION_EVENT:
case AccessibleEventId.ACCESSIBLE_STATE_EVENT:
+ case AccessibleEventId.CONTROLLED_BY_PROPERTY:
+ case AccessibleEventId.CONTROLLER_FOR_PROPERTY:
+ case AccessibleEventId.LABEL_FOR_PROPERTY:
+ case AccessibleEventId.LABELED_BY_PROPERTY:
+ case AccessibleEventId.MEMBER_OF_PROPERTY:
+ case AccessibleEventId.ACCESSIBLE_SELECTION_EVENT:
+ handleEvent (xSource, AccessibleContextHandler.class);
+ break;
+
case AccessibleEventId.ACCESSIBLE_TABLE_CAPTION_CHANGED:
case AccessibleEventId.ACCESSIBLE_TABLE_COLUMN_DESCRIPTION_CHANGED:
case AccessibleEventId.ACCESSIBLE_TABLE_COLUMN_HEADER_CHANGED:
case AccessibleEventId.ACCESSIBLE_TABLE_ROW_DESCRIPTION_CHANGED:
case AccessibleEventId.ACCESSIBLE_TABLE_ROW_HEADER_CHANGED:
case AccessibleEventId.ACCESSIBLE_TABLE_SUMMARY_CHANGED:
- case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
- case AccessibleEventId.ACCESSIBLE_VALUE_EVENT:
- case AccessibleEventId.CONTROLLED_BY_PROPERTY:
- case AccessibleEventId.CONTROLLER_FOR_PROPERTY:
- case AccessibleEventId.LABEL_FOR_PROPERTY:
- case AccessibleEventId.LABELED_BY_PROPERTY:
- case AccessibleEventId.MEMBER_OF_PROPERTY:
- // fireTreeNodesChanged (createEvent
- // (xSource));
- // Some child(s) of xSource have changed. We do not know
- // which so all we can do is send a structure change event
- // to all listeners.
- AccessibleTreeNode aNode = (AccessibleTreeNode)maXAccessibleToNode.get (xSource);
- fireTreeStructureChanged (createEvent (xSource));
- if (aNode instanceof AccTreeNode)
- {
- updateOnCanvas ((AccTreeNode)aNode);
- maCanvas.repaint ();
- }
+ handleEvent (xSource, AccessibleTableHandler.class);
+ break;
+
+ case AccessibleEventId.ACCESSIBLE_ACTION_EVENT:
+ handleEvent (xSource, AccessibleActionHandler.class);
break;
+ case AccessibleEventId.ACCESSIBLE_HYPERTEXT_OFFSET:
+ handleEvent (xSource, AccessibleHypertextHandler.class);
+ break;
+ case AccessibleEventId.ACCESSIBLE_ACTIVE_DESCENDANT_EVENT:
+ case AccessibleEventId.ACCESSIBLE_CARET_EVENT:
+ case AccessibleEventId.ACCESSIBLE_TEXT_EVENT:
+ case AccessibleEventId.ACCESSIBLE_VALUE_EVENT:
+ handleEvent (xSource, AccessibleTextHandler.class);
+ break;
default:
break;
@@ -737,22 +801,11 @@ public class AccessibilityTreeModel
// canvas
//
- private Canvas maCanvas;
-
public void setCanvas( Canvas aCanvas )
{
maCanvas = aCanvas;
}
-
- private XAccessibleContext getContext(Object aObject)
- {
- XAccessibleContext xAcc =
- (XAccessibleContext)UnoRuntime.queryInterface(
- XAccessibleContext.class, aObject);
- return xAcc;
- }
-
protected void addToCanvas (AccTreeNode aNode)
{
if (maCanvas != null)
diff --git a/toolkit/test/accessibility/AccessibleComponentHandler.java b/toolkit/test/accessibility/AccessibleComponentHandler.java
index d0ec5367d1aa..92869aae2d21 100644
--- a/toolkit/test/accessibility/AccessibleComponentHandler.java
+++ b/toolkit/test/accessibility/AccessibleComponentHandler.java
@@ -27,7 +27,7 @@ class AccessibleComponentHandler
public AccessibleComponentHandler (XAccessibleComponent xComponent)
{
if (xComponent != null)
- maChildList.setSize (4);
+ maChildList.setSize (5);
}
public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
@@ -43,21 +43,31 @@ class AccessibleComponentHandler
switch (nIndex)
{
case 0:
- aChild = new StringNode ("Location: "+ xComponent.getLocation().X +
- ", " + xComponent.getLocation().Y, aParent);
+ com.sun.star.awt.Point aLocation = xComponent.getLocation();
+ aChild = new StringNode (
+ "Location: " + aLocation.X + ", " + aLocation.Y,
+ aParent);
break;
case 1:
- aChild = new StringNode ("Location on Screen: "
- + xComponent.getLocationOnScreen().X + ", "
- + xComponent.getLocationOnScreen().Y,
+ com.sun.star.awt.Point aScreenLocation = xComponent.getLocationOnScreen();
+ aChild = new StringNode (
+ "Location on Screen: " + aScreenLocation.X + ", " + aScreenLocation.Y,
aParent);
break;
case 2:
- aChild = new StringNode ("Size: "+ xComponent.getSize().Width + ", "
- + xComponent.getSize().Height,
+ com.sun.star.awt.Size aSize = xComponent.getSize();
+ aChild = new StringNode (
+ "Size: "+ aSize.Width + ", " + aSize.Height,
aParent);
break;
case 3:
+ com.sun.star.awt.Rectangle aBBox = xComponent.getBounds();
+ aChild = new StringNode (
+ "Bounding Box: "+ aBBox.X + ", " + aBBox.Y + ","
+ + aBBox.Width + ", " + aBBox.Height,
+ aParent);
+ break;
+ case 4:
boolean bVisible = xComponent.isVisible();
boolean bShowing = xComponent.isShowing();
String sText;
@@ -76,4 +86,12 @@ class AccessibleComponentHandler
}
return aChild;
}
+
+ public void update (AccessibleTreeNode aNode)
+ {
+ maChildList.clear();
+ if (aNode instanceof AccTreeNode)
+ if (((AccTreeNode)aNode).getComponent() != null)
+ maChildList.setSize (5);
+ }
}
diff --git a/toolkit/test/accessibility/AccessibleContextHandler.java b/toolkit/test/accessibility/AccessibleContextHandler.java
index 521a3f47d5fb..742dde3977e1 100644
--- a/toolkit/test/accessibility/AccessibleContextHandler.java
+++ b/toolkit/test/accessibility/AccessibleContextHandler.java
@@ -47,8 +47,14 @@ class AccessibleContextHandler
sChild = "Role: " + xContext.getAccessibleRole();
break;
case 2:
- sChild = "Has parent: " +
- (xContext.getAccessibleParent()!=null ? "yes" : "no");
+ XAccessible xParent = xContext.getAccessibleParent();
+ sChild = "Has parent: " + (xParent!=null ? "yes" : "no");
+ /* if (xParent != ((AccTreeNode)aParent).getAccessible())
+ {
+ sChild += " but that is inconsistent"
+ + "#" + xParent + " # " + ((AccTreeNode)aParent).getAccessible();
+ }
+ */
break;
/* case 3:
sChild = "Child count: " + xContext.getAccessibleChildCount();
diff --git a/toolkit/test/accessibility/NodeHandler.java b/toolkit/test/accessibility/NodeHandler.java
index 39a6a68a2c2c..802ed83baf96 100644
--- a/toolkit/test/accessibility/NodeHandler.java
+++ b/toolkit/test/accessibility/NodeHandler.java
@@ -108,4 +108,10 @@ abstract class NodeHandler
public void performAction (AccessibleTreeNode aNode, int nIndex)
{
}
+
+ /** Update all children.
+ */
+ public void update (AccessibleTreeNode aNode)
+ {
+ }
}