1 import com
.sun
.star
.uno
.UnoRuntime
;
2 import com
.sun
.star
.accessibility
.XAccessible
;
3 import com
.sun
.star
.accessibility
.XAccessibleContext
;
4 import com
.sun
.star
.accessibility
.AccessibleRelation
;
5 import com
.sun
.star
.accessibility
.XAccessibleRelationSet
;
6 import com
.sun
.star
.accessibility
.AccessibleRelationType
;
7 import com
.sun
.star
.lang
.IndexOutOfBoundsException
;
9 import tools
.NameProvider
;
11 class AccessibleRelationHandler
14 public NodeHandler
createHandler( XAccessibleContext xContext
)
16 AccessibleRelationHandler aHandler
= null;
19 XAccessibleRelationSet xRelation
= xContext
.getAccessibleRelationSet();
20 if (xRelation
!= null)
21 aHandler
= new AccessibleRelationHandler(xContext
);
26 public AccessibleRelationHandler()
30 public AccessibleRelationHandler( XAccessibleContext xContext
)
32 XAccessibleRelationSet xRelation
= xContext
.getAccessibleRelationSet();
33 if (xRelation
!= null)
34 maChildList
.setSize( 1 );
37 public AccessibleTreeNode
createChild( AccessibleTreeNode aParent
,
40 XAccessibleRelationSet xRelation
= null;
41 AccessibleTreeNode aChild
= null;
43 if( aParent
instanceof AccTreeNode
)
46 ((AccTreeNode
)aParent
).getContext().getAccessibleRelationSet();
48 if( xRelation
== null )
52 VectorNode aVNode
= new VectorNode( "RelationSet", aParent
);
53 int nCount
= xRelation
.getRelationCount();
56 for( int i
= 0; i
< nCount
; i
++ )
58 AccessibleRelation aRelation
= xRelation
.getRelation( i
);
60 StringBuffer aBuffer
= new StringBuffer();
61 aBuffer
.append (NameProvider
.getRelationName (aRelation
.RelationType
));
62 aBuffer
.append( ": " );
64 for( int j
= 0; j
< aRelation
.TargetSet
.length
; j
++ )
66 Object aTarget
= aRelation
.TargetSet
[j
];
67 XAccessible xAccTarget
=
68 (XAccessible
)UnoRuntime
.queryInterface(
69 XAccessible
.class, aTarget
);
70 if( xAccTarget
== null )
72 aBuffer
.append( aTarget
.toString() );
76 aBuffer
.append( xAccTarget
.getAccessibleContext().
77 getAccessibleName() );
79 aBuffer
.append( ", " );
81 aBuffer
.delete( aBuffer
.length() - 2, aBuffer
.length() );
83 aVNode
.addChild( new StringNode( aBuffer
.toString(),
89 catch( IndexOutOfBoundsException e
)
91 aChild
= new StringNode( "IndexOutOfBounds", aParent
);