diff options
author | Daniel Vogelheim <dvo@openoffice.org> | 2002-04-26 11:26:43 +0000 |
---|---|---|
committer | Daniel Vogelheim <dvo@openoffice.org> | 2002-04-26 11:26:43 +0000 |
commit | 8d47fec2ff417ee67c24e3bc13a61fbae537ae7a (patch) | |
tree | 608a88be2454a92132261dcd3663221bdd9cf355 | |
parent | 8c7d773975a32dead44baf2aadead07fc275d06e (diff) |
added support for XAccessibleRelation interface
-rw-r--r-- | toolkit/test/accessibility/AccessibilityTreeModel.java | 4 | ||||
-rw-r--r-- | toolkit/test/accessibility/AccessibleRelationHandler.java | 129 | ||||
-rw-r--r-- | toolkit/test/accessibility/makefile.mk | 1 |
3 files changed, 134 insertions, 0 deletions
diff --git a/toolkit/test/accessibility/AccessibilityTreeModel.java b/toolkit/test/accessibility/AccessibilityTreeModel.java index d2c18fb2b3a6..b8fa8d1756f3 100644 --- a/toolkit/test/accessibility/AccessibilityTreeModel.java +++ b/toolkit/test/accessibility/AccessibilityTreeModel.java @@ -52,6 +52,7 @@ public class AccessibilityTreeModel private static NodeHandler maHypertextHandler = new AccessibleHypertextHandler(); private static NodeHandler maHyperlinkHandler = new AccessibleHyperlinkHandler(); private static NodeHandler maSelectionHandler = new AccessibleSelectionHandler(); + private static NodeHandler maRelationHandler = new AccessibleRelationHandler(); private static NodeHandler maTreeHandler = new AccessibleTreeHandler(); private Canvas maCanvas; @@ -542,6 +543,7 @@ public class AccessibilityTreeModel aNode.addHandler (maHypertextHandler.createHandler (xContext)); aNode.addHandler (maHyperlinkHandler.createHandler (xContext)); aNode.addHandler (maSelectionHandler.createHandler (xContext)); + aNode.addHandler (maRelationHandler.createHandler (xContext)); aNode.addHandler (maTreeHandler.createHandler (xContext)); } else @@ -567,6 +569,7 @@ public class AccessibilityTreeModel aNode.addHandler (maActionHandler.createHandler (xContext)); aNode.addHandler (maImageHandler.createHandler (xContext)); aNode.addHandler (maTableHandler.createHandler (xContext)); + aNode.addHandler (maRelationHandler.createHandler (xContext)); aNode.addHandler (maCellHandler.createHandler (xContext)); aNode.addHandler (maSelectionHandler.createHandler (xContext)); aNode.addHandler (maTreeHandler.createHandler (xContext)); @@ -688,6 +691,7 @@ public class AccessibilityTreeModel "TABLE_SUMMARY_CHANGED", "TEXT", "VALUE", "VISIBLE_DATA", "CONTROLLED_BY_PROPERTY", "CONTROLLER_FOR_PROPERTY", "LABEL_FOR_PROPERTY", "LABELED_BY_PROPERTY", "MEMBER_OF_PROPERTY", + "CONTENT_FLOWS_FROM", "CONTENT_FLOWS_TO", "[UNKNOWN]" }; diff --git a/toolkit/test/accessibility/AccessibleRelationHandler.java b/toolkit/test/accessibility/AccessibleRelationHandler.java new file mode 100644 index 000000000000..2651a02e7956 --- /dev/null +++ b/toolkit/test/accessibility/AccessibleRelationHandler.java @@ -0,0 +1,129 @@ + +import com.sun.star.uno.UnoRuntime; +import drafts.com.sun.star.accessibility.XAccessible; +import drafts.com.sun.star.accessibility.XAccessibleContext; +import drafts.com.sun.star.accessibility.AccessibleRelation; +import drafts.com.sun.star.accessibility.XAccessibleRelationSet; +import drafts.com.sun.star.accessibility.AccessibleRelationType; +import com.sun.star.lang.IndexOutOfBoundsException; + + +class AccessibleRelationHandler + extends NodeHandler +{ + public NodeHandler createHandler( XAccessibleContext xContext ) + { + XAccessibleRelationSet xRelation = xContext.getAccessibleRelationSet(); + return (xRelation == null) ? null : + new AccessibleRelationHandler(xContext); + } + + public AccessibleRelationHandler() + { + } + + public AccessibleRelationHandler( XAccessibleContext xContext ) + { + XAccessibleRelationSet xRelation = xContext.getAccessibleRelationSet(); + if (xRelation != null) + maChildList.setSize( 1 ); + } + + public AccessibleTreeNode createChild( AccessibleTreeNode aParent, + int nIndex ) + { + XAccessibleRelationSet xRelation = null; + AccessibleTreeNode aChild = null; + + if( aParent instanceof AccTreeNode ) + { + xRelation = + ((AccTreeNode)aParent).getContext().getAccessibleRelationSet(); + } + if( xRelation == null ) + return aChild; + + + VectorNode aVNode = new VectorNode( "RelationSet", aParent); + int nCount = xRelation.getRelationCount(); + try + { + for( int i = 0; i < nCount; i++ ) + { + AccessibleRelation aRelation = xRelation.getRelation( i ); + + StringBuffer aBuffer = new StringBuffer(); + switch( aRelation.RelationType ) + { + case AccessibleRelationType.INVALID: + aBuffer.append( "INVALID" ); + break; + case AccessibleRelationType.CONTROLLED_BY: + aBuffer.append( "CONTROLLED_BY" ); + break; + case AccessibleRelationType.CONTROLLED_BY_PROPERTY: + aBuffer.append( "CONTROLLED_BY_PROPERTY" ); + break; + case AccessibleRelationType.CONTROLLER_FOR: + aBuffer.append( "CONTROLLER_FOR" ); + break; + case AccessibleRelationType.CONTROLLER_FOR_PROPERTY: + aBuffer.append( "CONTROLLER_FOR_PROPERTY" ); + break; + case AccessibleRelationType.LABEL_FOR: + aBuffer.append( "LABEL_FOR" ); + break; + case AccessibleRelationType.LABEL_FOR_PROPERTY: + aBuffer.append( "LABEL_FOR_PROPERTY" ); + break; + case AccessibleRelationType.LABELED_BY: + aBuffer.append( "LABELED_BY" ); + break; + case AccessibleRelationType.LABELED_BY_PROPERTY: + aBuffer.append( "LABELED_BY_PROPERTY" ); + break; + case AccessibleRelationType.MEMBER_OF: + aBuffer.append( "MEMBER_OF" ); + break; + case AccessibleRelationType.MEMBER_OF_PROPERTY: + aBuffer.append( "MEMBER_OF_PROPERTY" ); + break; + default: + aBuffer.append( aRelation.RelationType ); + break; + } + aBuffer.append( ": " ); + + for( int j = 0; j < aRelation.TargetSet.length; j++ ) + { + Object aTarget = aRelation.TargetSet[j]; + XAccessible xAccTarget = + (XAccessible)UnoRuntime.queryInterface( + XAccessible.class, aTarget ); + if( xAccTarget == null ) + { + aBuffer.append( aTarget.toString() ); + } + else + { + aBuffer.append( xAccTarget.getAccessibleContext(). + getAccessibleDescription() ); + } + aBuffer.append( ", " ); + } + aBuffer.delete( aBuffer.length() - 2, aBuffer.length() ); + + aVNode.addChild( new StringNode( aBuffer.toString(), + aParent ) ); + } + + aChild = aVNode; + } + catch( IndexOutOfBoundsException e ) + { + aChild = new StringNode( "IndexOutOfBounds", aParent ); + } + + return aChild; + } +} diff --git a/toolkit/test/accessibility/makefile.mk b/toolkit/test/accessibility/makefile.mk index 4362c830ad4d..44397ae1b26b 100644 --- a/toolkit/test/accessibility/makefile.mk +++ b/toolkit/test/accessibility/makefile.mk @@ -43,6 +43,7 @@ JAVA_FILES = \ AccessibleHypertextHandler.java \ AccessibleImageHandler.java \ AccessibleObject.java \ + AccessibleRelationHandler.java \ AccessibleSelectionHandler.java \ AccessibleTableHandler.java \ AccessibleTextHandler.java \ |