xref: /AOO41X/main/toolkit/test/accessibility/GeometryEventHandler.java (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible;
2*cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleEventObject;
3*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
4*cdf0e10cSrcweir 
5*cdf0e10cSrcweir import java.io.PrintStream;
6*cdf0e10cSrcweir import java.util.LinkedList;
7*cdf0e10cSrcweir 
8*cdf0e10cSrcweir class GeometryEventHandler
9*cdf0e10cSrcweir     extends EventHandler
10*cdf0e10cSrcweir {
11*cdf0e10cSrcweir     public GeometryEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)
12*cdf0e10cSrcweir     {
13*cdf0e10cSrcweir         super (aEvent, aTreeModel);
14*cdf0e10cSrcweir     }
15*cdf0e10cSrcweir 
16*cdf0e10cSrcweir     public void PrintOldAndNew (PrintStream out)
17*cdf0e10cSrcweir     {
18*cdf0e10cSrcweir         out.println ("   children not relevant");
19*cdf0e10cSrcweir     }
20*cdf0e10cSrcweir 
21*cdf0e10cSrcweir     public void Process ()
22*cdf0e10cSrcweir     {
23*cdf0e10cSrcweir         AccTreeNode aNode = maTreeModel.updateNode (mxEventSource,
24*cdf0e10cSrcweir             AccessibleComponentHandler.class,
25*cdf0e10cSrcweir             AccessibleExtendedComponentHandler.class);
26*cdf0e10cSrcweir 
27*cdf0e10cSrcweir         // Update the graphical representation of aNode in the Canvas.
28*cdf0e10cSrcweir         Canvas aCanvas = maTreeModel.getCanvas();
29*cdf0e10cSrcweir         if (aCanvas != null)
30*cdf0e10cSrcweir         {
31*cdf0e10cSrcweir             // Iterate over all nodes in the sub-tree rooted in aNode.
32*cdf0e10cSrcweir             LinkedList aShapeQueue = new LinkedList();
33*cdf0e10cSrcweir             aShapeQueue.addLast (aNode);
34*cdf0e10cSrcweir             while (aShapeQueue.size() > 0)
35*cdf0e10cSrcweir             {
36*cdf0e10cSrcweir                 // Remove the first node from the queue and update its
37*cdf0e10cSrcweir                 // graphical representation.
38*cdf0e10cSrcweir                 AccTreeNode aShapeNode = (AccTreeNode) aShapeQueue.getFirst();
39*cdf0e10cSrcweir                 aShapeQueue.removeFirst();
40*cdf0e10cSrcweir                 aCanvas.updateNodeGeometry (aShapeNode);
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir                 // Add the node's children to the queue.
43*cdf0e10cSrcweir                 int nChildCount = maTreeModel.getChildCount (aShapeNode);
44*cdf0e10cSrcweir                 for (int i=0; i<nChildCount; i++)
45*cdf0e10cSrcweir                 {
46*cdf0e10cSrcweir                     Object aTreeNode = maTreeModel.getChildNoCreate (aShapeNode, i);
47*cdf0e10cSrcweir                     if (aTreeNode instanceof AccTreeNode)
48*cdf0e10cSrcweir                         aShapeQueue.addLast (aTreeNode);
49*cdf0e10cSrcweir                 }
50*cdf0e10cSrcweir             }
51*cdf0e10cSrcweir             aCanvas.repaint ();
52*cdf0e10cSrcweir         }
53*cdf0e10cSrcweir     }
54*cdf0e10cSrcweir }
55