summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Glazounov <vg@openoffice.org>2003-04-11 16:10:08 +0000
committerVladimir Glazounov <vg@openoffice.org>2003-04-11 16:10:08 +0000
commitc6ac50480afd81f9bb8132b97138c467c00bf83f (patch)
tree3e321e5e7017d980e2d162d99b5a7ef12f1958f5
parente2954b5cd198d30071c87dcb285acf3257261bdc (diff)
INTEGRATION: CWS vcl07 (1.6.2); FILE ADDED
2003/04/08 14:28:37 obr 1.6.2.1: re-added accessibility workbench
-rw-r--r--toolkit/test/accessibility/AccessibleTreeHandler.java110
1 files changed, 110 insertions, 0 deletions
diff --git a/toolkit/test/accessibility/AccessibleTreeHandler.java b/toolkit/test/accessibility/AccessibleTreeHandler.java
new file mode 100644
index 000000000000..3e8fc0429c90
--- /dev/null
+++ b/toolkit/test/accessibility/AccessibleTreeHandler.java
@@ -0,0 +1,110 @@
+import drafts.com.sun.star.accessibility.XAccessible;
+import drafts.com.sun.star.accessibility.XAccessibleContext;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.IndexOutOfBoundsException;
+
+
+/**
+ * Map the tree of accessibility objects into their
+ * AccessibilityTreeModel counterparts.
+ */
+class AccessibleTreeHandler
+ extends NodeHandler
+{
+ protected XAccessibleContext mxContext;
+
+ public NodeHandler createHandler (XAccessibleContext xContext)
+ {
+ if (xContext != null)
+ return new AccessibleTreeHandler (xContext);
+ else
+ return null;
+ }
+
+ public AccessibleTreeHandler ()
+ {
+ super();
+ mxContext = null;
+ }
+
+ public AccessibleTreeHandler (XAccessibleContext xContext)
+ {
+ super();
+ mxContext = xContext;
+ if (mxContext != null)
+ // Add one to the number of children to include the string node
+ // that tells you how many children there are.
+ synchronized (maChildList)
+ {
+ maChildList.setSize (1 + mxContext.getAccessibleChildCount());
+ }
+ }
+
+ public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
+ {
+ AccessibleTreeNode aChild = null;
+ if (mxContext != null)
+ {
+ if (nIndex == 0)
+ aChild = new StringNode ("Child count: " + mxContext.getAccessibleChildCount(),
+ aParent);
+ else
+ {
+ // Lower index to skip the string node.
+ nIndex -= 1;
+ try
+ {
+ XAccessible xChild = mxContext.getAccessibleChild (nIndex);
+ aChild = NodeFactory.Instance().createDefaultNode (
+ xChild, aParent);
+ }
+ catch( IndexOutOfBoundsException e )
+ {
+ aChild = new StringNode ("ERROR: no child with index " + nIndex, aParent);
+ }
+ }
+ }
+ else
+ aChild = new StringNode ("XAccessibleContext interface not supported", aParent);
+ return aChild;
+ }
+
+ /** Try to add the specified accessible child into the lists of
+ children. The insertion position is determined from the
+ getIndexInParent method of the child.
+ */
+ public AccessibleTreeNode addAccessibleChild (AccessibleTreeNode aParent, XAccessible xChild)
+ {
+ AccessibleTreeNode aChild = null;
+
+ if (xChild != null)
+ {
+ XAccessibleContext xContext = xChild.getAccessibleContext();
+ if (xContext != null)
+ {
+ int nIndex = xContext.getAccessibleIndexInParent() + 1;
+ synchronized (maChildList)
+ {
+ if ((nIndex >= 0) || (nIndex <= maChildList.size()))
+ {
+ aChild = NodeFactory.Instance().createDefaultNode (xChild, aParent);
+ maChildList.insertElementAt (aChild, nIndex);
+ }
+ }
+ }
+ }
+ return aChild;
+ }
+
+
+ /** Update only the child count node. Trust on other ways to update the
+ accessible children.
+ */
+ public void update (AccessibleTreeNode aNode)
+ {
+ synchronized (maChildList)
+ {
+ maChildList.setElementAt (null, 0);
+ }
+ }
+}