fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / AccessibleComponentHandler.java
blob2c4476417893d45f1eb73f4fcb5f03e0cd337601
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 public NodeHandler createHandler (XAccessibleContext xContext)
30 XAccessibleComponent xComponent =
31 UnoRuntime.queryInterface (
32 XAccessibleComponent.class, xContext);
33 if (xComponent != null)
34 return new AccessibleComponentHandler (xComponent);
35 else
36 return null;
40 public AccessibleComponentHandler ()
44 public AccessibleComponentHandler (XAccessibleComponent xComponent)
46 if (xComponent != null)
47 maChildList.setSize (6);
50 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
52 AccessibleTreeNode aChild = null;
53 if (aParent instanceof AccTreeNode)
55 XAccessibleComponent xComponent =
56 ((AccTreeNode)aParent).getComponent();
58 if (xComponent != null)
60 int nColor;
61 switch (nIndex)
63 case 0:
64 com.sun.star.awt.Point aLocation = xComponent.getLocation();
65 aChild = new StringNode (
66 "Location: " + aLocation.X + ", " + aLocation.Y,
67 aParent);
68 break;
69 case 1:
70 com.sun.star.awt.Point aScreenLocation = xComponent.getLocationOnScreen();
71 aChild = new StringNode (
72 "Location on Screen: " + aScreenLocation.X + ", " + aScreenLocation.Y,
73 aParent);
74 break;
75 case 2:
76 com.sun.star.awt.Size aSize = xComponent.getSize();
77 aChild = new StringNode (
78 "Size: "+ aSize.Width + ", " + aSize.Height,
79 aParent);
80 break;
81 case 3:
82 com.sun.star.awt.Rectangle aBBox = xComponent.getBounds();
83 aChild = new StringNode (
84 "Bounding Box: "+ aBBox.X + ", " + aBBox.Y + ","
85 + aBBox.Width + ", " + aBBox.Height,
86 aParent);
87 break;
88 case 4:
89 nColor = xComponent.getForeground();
90 aChild = new StringNode ("Foreground color: R"
91 + (nColor>>16&0xff)
92 + "G" + (nColor>>8&0xff)
93 + "B" + (nColor>>0&0xff)
94 + "A" + (nColor>>24&0xff),
95 aParent);
96 break;
97 case 5:
98 nColor = xComponent.getBackground();
99 aChild = new StringNode ("Background color: R"
100 + (nColor>>16&0xff)
101 + "G" + (nColor>>8&0xff)
102 + "B" + (nColor>>0&0xff)
103 + "A" + (nColor>>24&0xff),
104 aParent);
105 break;
109 return aChild;
112 public void update (AccessibleTreeNode aNode)
114 maChildList.clear();
115 if (aNode instanceof AccTreeNode)
116 if (((AccTreeNode)aNode).getComponent() != null)
117 maChildList.setSize (4);