summaryrefslogtreecommitdiff
path: root/toolkit/test/accessibility/AccessibleComponentHandler.java
blob: 699043ddacd906859982f368914b6995005ce73e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

import com.sun.star.uno.UnoRuntime;
import drafts.com.sun.star.accessibility.XAccessibleComponent;


class AccessibleComponentHandler extends AccessibleTreeHandler
{
    private XAccessibleComponent getComponent(Object aObject)
    {
        return (XAccessibleComponent) UnoRuntime.queryInterface (
            XAccessibleComponent.class, aObject);
    }

    public int getChildCount(Object aObject)
    {
        return (getComponent(aObject) == null) ? 0 : 3;
    }

    public Object getChild(Object aObject, int nIndex)
    {
        XAccessibleComponent xComponent = getComponent(aObject);

        Object aRet = null;
        if( xComponent != null )
        {
            switch( nIndex )
            {
                case 0:
                    aRet = "Location: "+ xComponent.getLocation().X +
                        ", " + xComponent.getLocation().Y;
                    break;
                case 1:
                    aRet = "Location on Screen: "+
                        xComponent.getLocationOnScreen().X + ", " +
                        xComponent.getLocationOnScreen().Y;
                    break;
                case 2:
                    aRet =  "Size: "+ xComponent.getSize().Width + ", " +
                        xComponent.getSize().Height;
                    break;
            }
        }
        return aRet;
    }
}