1 import com
.sun
.star
.accessibility
.*;
2 import java
.util
.Vector
;
4 import tools
.NameProvider
;
6 /** This singleton class creates nodes for given accessible objects.
10 public synchronized static NodeFactory
Instance ()
12 if (maInstance
== null)
14 maInstance
= new NodeFactory();
19 private NodeFactory ()
23 maContextHandler
= new AccessibleContextHandler();
24 maTextHandler
= new AccessibleTextHandler();
25 maEditableTextHandler
= new AccessibleEditableTextHandler();
26 maComponentHandler
= new AccessibleComponentHandler();
27 maExtendedComponentHandler
= new AccessibleExtendedComponentHandler();
28 maActionHandler
= new AccessibleActionHandler();
29 maImageHandler
= new AccessibleImageHandler();
30 maTableHandler
= new AccessibleTableHandler();
31 maCellHandler
= new AccessibleCellHandler();
32 maHypertextHandler
= new AccessibleHypertextHandler();
33 maHyperlinkHandler
= new AccessibleHyperlinkHandler();
34 maSelectionHandler
= new AccessibleSelectionHandler();
35 maRelationHandler
= new AccessibleRelationHandler();
36 maTreeHandler
= new AccessibleTreeHandler();
37 maUNOHandler
= new AccessibleUNOHandler();
41 /** add default handlers based on the supported interfaces */
42 private void addDefaultHandlers (AccTreeNode aNode
, XAccessibleContext xContext
)
46 // Slow but complete version: try each handler type separately.
47 aNode
.addHandler (maContextHandler
.createHandler (xContext
));
48 aNode
.addHandler (maTextHandler
.createHandler (xContext
));
49 aNode
.addHandler (maEditableTextHandler
.createHandler (xContext
));
50 aNode
.addHandler (maComponentHandler
.createHandler (xContext
));
51 aNode
.addHandler (maExtendedComponentHandler
.createHandler (xContext
));
52 aNode
.addHandler (maActionHandler
.createHandler (xContext
));
53 aNode
.addHandler (maImageHandler
.createHandler (xContext
));
54 aNode
.addHandler (maTableHandler
.createHandler (xContext
));
55 aNode
.addHandler (maCellHandler
.createHandler (xContext
));
56 aNode
.addHandler (maHypertextHandler
.createHandler (xContext
));
57 aNode
.addHandler (maHyperlinkHandler
.createHandler (xContext
));
58 aNode
.addHandler (maSelectionHandler
.createHandler (xContext
));
59 aNode
.addHandler (maRelationHandler
.createHandler (xContext
));
60 aNode
.addHandler (maUNOHandler
.createHandler (xContext
));
61 aNode
.addHandler (maTreeHandler
.createHandler (xContext
));
65 // Exploit dependencies between interfaces.
67 aNode
.addHandler (maContextHandler
.createHandler (xContext
));
69 aHandler
= maTextHandler
.createHandler (xContext
);
72 aNode
.addHandler (aHandler
);
73 aNode
.addHandler (maEditableTextHandler
.createHandler (xContext
));
74 aNode
.addHandler (maHypertextHandler
.createHandler (xContext
));
75 aNode
.addHandler (maHyperlinkHandler
.createHandler (xContext
));
77 aHandler
= maComponentHandler
.createHandler (xContext
);
80 aNode
.addHandler (aHandler
);
81 aNode
.addHandler (maExtendedComponentHandler
.createHandler (xContext
));
83 aNode
.addHandler (maActionHandler
.createHandler (xContext
));
84 aNode
.addHandler (maImageHandler
.createHandler (xContext
));
85 aNode
.addHandler (maTableHandler
.createHandler (xContext
));
86 aNode
.addHandler (maRelationHandler
.createHandler (xContext
));
87 aNode
.addHandler (maCellHandler
.createHandler (xContext
));
88 aNode
.addHandler (maSelectionHandler
.createHandler (xContext
));
89 aNode
.addHandler (maUNOHandler
.createHandler (xContext
));
90 aNode
.addHandler (maTreeHandler
.createHandler (xContext
));
94 /** create a node with the default handlers */
95 public AccTreeNode
createDefaultNode (XAccessible xAccessible
, AccessibleTreeNode aParent
)
97 // default: aObject + aDisplay
100 // if we are accessible, we use the context + name instead
101 XAccessibleContext xContext
= null;
102 if (xAccessible
!= null)
103 xContext
= xAccessible
.getAccessibleContext();
104 if (xContext
!= null)
106 sDisplay
= xContext
.getAccessibleName();
107 if (sDisplay
.length()==0)
109 sDisplay
= "<no name> Role: "
110 + NameProvider
.getRoleName (
111 xContext
.getAccessibleRole());
115 sDisplay
= new String ("not accessible");
118 // create node, and add default handlers
119 AccTreeNode aNode
= new AccTreeNode (xAccessible
, xContext
, sDisplay
, aParent
);
120 addDefaultHandlers (aNode
, xContext
);
123 System
.out
.println ("createDefaultNode == null");
127 private static NodeFactory maInstance
= null;
129 private boolean mbVerbose
;
132 private NodeHandler maContextHandler
= new AccessibleContextHandler();
133 private NodeHandler maTextHandler
= new AccessibleTextHandler();
134 private NodeHandler maEditableTextHandler
= new AccessibleEditableTextHandler();
135 private NodeHandler maComponentHandler
= new AccessibleComponentHandler();
136 private NodeHandler maExtendedComponentHandler
= new AccessibleExtendedComponentHandler();
137 private NodeHandler maActionHandler
= new AccessibleActionHandler();
138 private NodeHandler maImageHandler
= new AccessibleImageHandler();
139 private NodeHandler maTableHandler
= new AccessibleTableHandler();
140 private NodeHandler maCellHandler
= new AccessibleCellHandler();
141 private NodeHandler maHypertextHandler
= new AccessibleHypertextHandler();
142 private NodeHandler maHyperlinkHandler
= new AccessibleHyperlinkHandler();
143 private NodeHandler maSelectionHandler
= new AccessibleSelectionHandler();
144 private NodeHandler maRelationHandler
= new AccessibleRelationHandler();
145 private NodeHandler maTreeHandler
= new AccessibleTreeHandler();
146 private NodeHandler maUNOHandler
= new AccessibleUNOHandler();