bump product version to 7.2.5.1
[LibreOffice.git] / toolkit / test / accessibility / AccessibleComponentHandler.java
blob229612b8dd11c6ea7dd564f55d402d40d536840a
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.uno.UnoRuntime;
20 import com.sun.star.accessibility.XAccessibleContext;
21 import com.sun.star.accessibility.XAccessibleComponent;
24 class AccessibleComponentHandler
25 extends NodeHandler
28 @Override
29 public NodeHandler createHandler (XAccessibleContext xContext)
31 XAccessibleComponent xComponent =
32 UnoRuntime.queryInterface (
33 XAccessibleComponent.class, xContext);
34 if (xComponent != null)
35 return new AccessibleComponentHandler (xComponent);
36 else
37 return null;
41 public AccessibleComponentHandler ()
45 private AccessibleComponentHandler (XAccessibleComponent xComponent)
47 if (xComponent != null)
48 maChildList.setSize (6);
51 @Override
52 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
54 AccessibleTreeNode aChild = null;
55 if (aParent instanceof AccTreeNode)
57 XAccessibleComponent xComponent =
58 ((AccTreeNode)aParent).getComponent();
60 if (xComponent != null)
62 int nColor;
63 switch (nIndex)
65 case 0:
66 com.sun.star.awt.Point aLocation = xComponent.getLocation();
67 aChild = new StringNode (
68 "Location: " + aLocation.X + ", " + aLocation.Y,
69 aParent);
70 break;
71 case 1:
72 com.sun.star.awt.Point aScreenLocation = xComponent.getLocationOnScreen();
73 aChild = new StringNode (
74 "Location on Screen: " + aScreenLocation.X + ", " + aScreenLocation.Y,
75 aParent);
76 break;
77 case 2:
78 com.sun.star.awt.Size aSize = xComponent.getSize();
79 aChild = new StringNode (
80 "Size: "+ aSize.Width + ", " + aSize.Height,
81 aParent);
82 break;
83 case 3:
84 com.sun.star.awt.Rectangle aBBox = xComponent.getBounds();
85 aChild = new StringNode (
86 "Bounding Box: "+ aBBox.X + ", " + aBBox.Y + ","
87 + aBBox.Width + ", " + aBBox.Height,
88 aParent);
89 break;
90 case 4:
91 nColor = xComponent.getForeground();
92 aChild = new StringNode ("Foreground color: R"
93 + (nColor>>16&0xff)
94 + "G" + (nColor>>8&0xff)
95 + "B" + (nColor&0xff)
96 + "A" + (nColor>>24&0xff),
97 aParent);
98 break;
99 case 5:
100 nColor = xComponent.getBackground();
101 aChild = new StringNode ("Background color: R"
102 + (nColor>>16&0xff)
103 + "G" + (nColor>>8&0xff)
104 + "B" + (nColor&0xff)
105 + "A" + (nColor>>24&0xff),
106 aParent);
107 break;
111 return aChild;
114 @Override
115 public void update (AccessibleTreeNode aNode)
117 maChildList.clear();
118 if (aNode instanceof AccTreeNode && ((AccTreeNode)aNode).getComponent() != null)
119 maChildList.setSize (4);