summaryrefslogtreecommitdiff
path: root/toolkit/test/accessibility/AccessibleActionHandler.java
blob: e0c5b6cbb56acff03524f3e6dcca88d57f38f8df (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.XAccessibleAction;
import com.sun.star.lang.IndexOutOfBoundsException;

class AccessibleActionHandler extends NodeHandler
{
    protected XAccessibleAction getAction(Object aObject)
    {
        return (XAccessibleAction) UnoRuntime.queryInterface (
            XAccessibleAction.class, aObject);
    }

    public int getChildCount(Object aObject)
    {
        XAccessibleAction xAction = getAction(aObject);
        return (xAction == null) ? 0 : 1 + xAction.getAccessibleActionCount();
    }

    public Object getChild(Object aObject, int nIndex)
    {
        Object aRet = null;

        XAccessibleAction xAction = getAction(aObject);
        if( xAction != null )
        {
            if( nIndex == 1 )
                aRet = "Actions: " + xAction.getAccessibleActionCount();
            else
            {
                try
                {
                    aRet = "Action " + (nIndex-1) + " : " +
                        xAction.getAccessibleActionDescription(nIndex-1);
                }
                catch( IndexOutOfBoundsException e )
                {
                    aRet = "ERROR";
                }
            }
        }

        return aRet;
    }
}