fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / AccessibleTableHandler.java
blob372c2cb5a26f15f618053c009e89625a30910d41
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.XAccessibleTable;
24 class AccessibleTableHandler extends NodeHandler
26 public NodeHandler createHandler (XAccessibleContext xContext)
28 XAccessibleTable xTable =
29 UnoRuntime.queryInterface (
30 XAccessibleTable.class, xContext);
31 if (xTable != null)
32 return new AccessibleTableHandler (xTable);
33 else
34 return null;
37 public AccessibleTableHandler ()
41 public AccessibleTableHandler (XAccessibleTable xTable)
43 if (xTable != null)
44 maChildList.setSize (4);
47 protected static XAccessibleTable getTable(Object aObject)
49 return UnoRuntime.queryInterface (
50 XAccessibleTable.class, aObject);
53 public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex)
55 AccessibleTreeNode aChild = null;
56 XAccessibleTable xTable = null;
57 if (aParent instanceof AccTreeNode)
58 xTable = ((AccTreeNode)aParent).getTable();
59 try
61 if( xTable != null )
63 switch( nIndex )
65 case 0:
66 aChild = new StringNode ("# table rows: " + xTable.getAccessibleRowCount(), aParent);
67 break;
68 case 1:
69 aChild = new StringNode ("# table columns: " + xTable.getAccessibleColumnCount(), aParent);
70 break;
71 case 2:
73 String sText = "selected rows: ";
74 int[] aSelected = xTable.getSelectedAccessibleRows();
75 for( int i=0; i < aSelected.length; i++ )
77 sText += aSelected[i];
78 sText += " ";
80 aChild = new StringNode (sText, aParent);
82 break;
83 case 3:
85 String sText = "selected columns: ";
86 int[] aSelected = xTable.getSelectedAccessibleColumns();
87 for( int i=0; i < aSelected.length; i++ )
89 sText += aSelected[i];
90 sText += " ";
92 aChild = new StringNode (sText, aParent);
94 break;
95 default:
96 aChild = new StringNode ("unknown child index " + nIndex, aParent);
100 catch (Exception e)
102 // Return empty child.
105 return aChild;