Branch libreoffice-5-0-4
[LibreOffice.git] / toolkit / test / accessibility / GeometryEventHandler.java
blobc55ee3acc4b13d0a1fb79adee7c1587f9f9a1a50
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import com.sun.star.accessibility.AccessibleEventObject;
20 import java.io.PrintStream;
21 import java.util.LinkedList;
23 class GeometryEventHandler
24 extends EventHandler
26 public GeometryEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)
28 super (aEvent, aTreeModel);
31 @Override
32 public void PrintOldAndNew (PrintStream out)
34 out.println (" children not relevant");
37 @Override
38 public void Process ()
40 AccTreeNode aNode = maTreeModel.updateNode (mxEventSource,
41 AccessibleComponentHandler.class,
42 AccessibleExtendedComponentHandler.class);
44 // Update the graphical representation of aNode in the Canvas.
45 Canvas aCanvas = maTreeModel.getCanvas();
46 if (aCanvas != null)
48 // Iterate over all nodes in the sub-tree rooted in aNode.
49 LinkedList<Object> aShapeQueue = new LinkedList<Object>();
50 aShapeQueue.addLast (aNode);
51 while (aShapeQueue.size() > 0)
53 // Remove the first node from the queue and update its
54 // graphical representation.
55 AccTreeNode aShapeNode = (AccTreeNode) aShapeQueue.getFirst();
56 aShapeQueue.removeFirst();
57 aCanvas.updateNodeGeometry (aShapeNode);
59 // Add the node's children to the queue.
60 int nChildCount = maTreeModel.getChildCount (aShapeNode);
61 for (int i=0; i<nChildCount; i++)
63 Object aTreeNode = maTreeModel.getChildNoCreate (aShapeNode, i);
64 if (aTreeNode instanceof AccTreeNode)
65 aShapeQueue.addLast (aTreeNode);
68 aCanvas.repaint ();