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
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
);
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)
64 com
.sun
.star
.awt
.Point aLocation
= xComponent
.getLocation();
65 aChild
= new StringNode (
66 "Location: " + aLocation
.X
+ ", " + aLocation
.Y
,
70 com
.sun
.star
.awt
.Point aScreenLocation
= xComponent
.getLocationOnScreen();
71 aChild
= new StringNode (
72 "Location on Screen: " + aScreenLocation
.X
+ ", " + aScreenLocation
.Y
,
76 com
.sun
.star
.awt
.Size aSize
= xComponent
.getSize();
77 aChild
= new StringNode (
78 "Size: "+ aSize
.Width
+ ", " + aSize
.Height
,
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
,
89 nColor
= xComponent
.getForeground();
90 aChild
= new StringNode ("Foreground color: R"
92 + "G" + (nColor
>>8&0xff)
93 + "B" + (nColor
>>0&0xff)
94 + "A" + (nColor
>>24&0xff),
98 nColor
= xComponent
.getBackground();
99 aChild
= new StringNode ("Background color: R"
101 + "G" + (nColor
>>8&0xff)
102 + "B" + (nColor
>>0&0xff)
103 + "A" + (nColor
>>24&0xff),
112 public void update (AccessibleTreeNode aNode
)
115 if (aNode
instanceof AccTreeNode
)
116 if (((AccTreeNode
)aNode
).getComponent() != null)
117 maChildList
.setSize (4);