xref: /AOO41X/main/toolkit/test/accessibility/GeometryEventHandler.java (revision 1b0aaa91df402a6f20c4769a008573eb958e886d)
1*1b0aaa91SAndrew Rist /**************************************************************
2*1b0aaa91SAndrew Rist  *
3*1b0aaa91SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1b0aaa91SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1b0aaa91SAndrew Rist  * distributed with this work for additional information
6*1b0aaa91SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1b0aaa91SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1b0aaa91SAndrew Rist  * "License"); you may not use this file except in compliance
9*1b0aaa91SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1b0aaa91SAndrew Rist  *
11*1b0aaa91SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1b0aaa91SAndrew Rist  *
13*1b0aaa91SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1b0aaa91SAndrew Rist  * software distributed under the License is distributed on an
15*1b0aaa91SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1b0aaa91SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1b0aaa91SAndrew Rist  * specific language governing permissions and limitations
18*1b0aaa91SAndrew Rist  * under the License.
19*1b0aaa91SAndrew Rist  *
20*1b0aaa91SAndrew Rist  *************************************************************/
21*1b0aaa91SAndrew Rist 
22cdf0e10cSrcweir import com.sun.star.accessibility.XAccessible;
23cdf0e10cSrcweir import com.sun.star.accessibility.AccessibleEventObject;
24cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime;
25cdf0e10cSrcweir 
26cdf0e10cSrcweir import java.io.PrintStream;
27cdf0e10cSrcweir import java.util.LinkedList;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir class GeometryEventHandler
30cdf0e10cSrcweir     extends EventHandler
31cdf0e10cSrcweir {
GeometryEventHandler(AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)32cdf0e10cSrcweir     public GeometryEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)
33cdf0e10cSrcweir     {
34cdf0e10cSrcweir         super (aEvent, aTreeModel);
35cdf0e10cSrcweir     }
36cdf0e10cSrcweir 
PrintOldAndNew(PrintStream out)37cdf0e10cSrcweir     public void PrintOldAndNew (PrintStream out)
38cdf0e10cSrcweir     {
39cdf0e10cSrcweir         out.println ("   children not relevant");
40cdf0e10cSrcweir     }
41cdf0e10cSrcweir 
Process()42cdf0e10cSrcweir     public void Process ()
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         AccTreeNode aNode = maTreeModel.updateNode (mxEventSource,
45cdf0e10cSrcweir             AccessibleComponentHandler.class,
46cdf0e10cSrcweir             AccessibleExtendedComponentHandler.class);
47cdf0e10cSrcweir 
48cdf0e10cSrcweir         // Update the graphical representation of aNode in the Canvas.
49cdf0e10cSrcweir         Canvas aCanvas = maTreeModel.getCanvas();
50cdf0e10cSrcweir         if (aCanvas != null)
51cdf0e10cSrcweir         {
52cdf0e10cSrcweir             // Iterate over all nodes in the sub-tree rooted in aNode.
53cdf0e10cSrcweir             LinkedList aShapeQueue = new LinkedList();
54cdf0e10cSrcweir             aShapeQueue.addLast (aNode);
55cdf0e10cSrcweir             while (aShapeQueue.size() > 0)
56cdf0e10cSrcweir             {
57cdf0e10cSrcweir                 // Remove the first node from the queue and update its
58cdf0e10cSrcweir                 // graphical representation.
59cdf0e10cSrcweir                 AccTreeNode aShapeNode = (AccTreeNode) aShapeQueue.getFirst();
60cdf0e10cSrcweir                 aShapeQueue.removeFirst();
61cdf0e10cSrcweir                 aCanvas.updateNodeGeometry (aShapeNode);
62cdf0e10cSrcweir 
63cdf0e10cSrcweir                 // Add the node's children to the queue.
64cdf0e10cSrcweir                 int nChildCount = maTreeModel.getChildCount (aShapeNode);
65cdf0e10cSrcweir                 for (int i=0; i<nChildCount; i++)
66cdf0e10cSrcweir                 {
67cdf0e10cSrcweir                     Object aTreeNode = maTreeModel.getChildNoCreate (aShapeNode, i);
68cdf0e10cSrcweir                     if (aTreeNode instanceof AccTreeNode)
69cdf0e10cSrcweir                         aShapeQueue.addLast (aTreeNode);
70cdf0e10cSrcweir                 }
71cdf0e10cSrcweir             }
72cdf0e10cSrcweir             aCanvas.repaint ();
73cdf0e10cSrcweir         }
74cdf0e10cSrcweir     }
75cdf0e10cSrcweir }
76