diff options
author | Michael Brauer <mib@openoffice.org> | 2002-04-17 13:15:15 +0000 |
---|---|---|
committer | Michael Brauer <mib@openoffice.org> | 2002-04-17 13:15:15 +0000 |
commit | 920c392506c83fdc9b2c6edf03d10497b4f7a079 (patch) | |
tree | c3d2e6e08b2ea100a25ed52ff2255f1ec07dcd84 /toolkit/test/accessibility | |
parent | 0a13a726a53c280e65d9e399562343a439e6d4ce (diff) |
#95586#: table support
Diffstat (limited to 'toolkit/test/accessibility')
-rw-r--r-- | toolkit/test/accessibility/AccTreeNode.java | 10 | ||||
-rw-r--r-- | toolkit/test/accessibility/AccessibilityTreeModel.java | 3 | ||||
-rw-r--r-- | toolkit/test/accessibility/AccessibleCellHandler.java | 150 | ||||
-rw-r--r-- | toolkit/test/accessibility/AccessibleTableHandler.java | 54 | ||||
-rw-r--r-- | toolkit/test/accessibility/makefile.mk | 1 |
5 files changed, 216 insertions, 2 deletions
diff --git a/toolkit/test/accessibility/AccTreeNode.java b/toolkit/test/accessibility/AccTreeNode.java index 947c49ecaa5c..9e0facbacb78 100644 --- a/toolkit/test/accessibility/AccTreeNode.java +++ b/toolkit/test/accessibility/AccTreeNode.java @@ -29,6 +29,7 @@ class AccTreeNode private XAccessibleContext mxContext; private XAccessibleComponent mxComponent; private XAccessibleText mxText; + private XAccessibleTable mxTable; public AccTreeNode (XAccessibleContext xContext, AccessibleTreeNode aParent) { @@ -98,6 +99,15 @@ class AccTreeNode XAccessibleEditableText.class, mxContext); } + public XAccessibleTable getTable () + { + if (mxTable == null && mxContext != null) + mxTable = (XAccessibleTable)UnoRuntime.queryInterface( + XAccessibleTable.class, mxContext); + return mxTable; + } + + public XAccessible getAccessible() { if ((mxAccessible == null) && (mxContext != null)) diff --git a/toolkit/test/accessibility/AccessibilityTreeModel.java b/toolkit/test/accessibility/AccessibilityTreeModel.java index 83bc6b44f1dc..83dac2076fa3 100644 --- a/toolkit/test/accessibility/AccessibilityTreeModel.java +++ b/toolkit/test/accessibility/AccessibilityTreeModel.java @@ -47,6 +47,7 @@ public class AccessibilityTreeModel private static NodeHandler maActionHandler = new AccessibleActionHandler(); private static NodeHandler maImageHandler = new AccessibleImageHandler(); private static NodeHandler maTableHandler = new AccessibleTableHandler(); + private static NodeHandler maCellHandler = new AccessibleCellHandler(); private static NodeHandler maHypertextHandler = new AccessibleHypertextHandler(); private static NodeHandler maHyperlinkHandler = new AccessibleHyperlinkHandler(); private static NodeHandler maSelectionHandler = new AccessibleSelectionHandler(); @@ -535,6 +536,7 @@ public class AccessibilityTreeModel aNode.addHandler (maActionHandler.createHandler (xContext)); aNode.addHandler (maImageHandler.createHandler (xContext)); aNode.addHandler (maTableHandler.createHandler (xContext)); + aNode.addHandler (maCellHandler.createHandler (xContext)); aNode.addHandler (maHypertextHandler.createHandler (xContext)); aNode.addHandler (maHyperlinkHandler.createHandler (xContext)); aNode.addHandler (maSelectionHandler.createHandler (xContext)); @@ -563,6 +565,7 @@ public class AccessibilityTreeModel aNode.addHandler (maActionHandler.createHandler (xContext)); aNode.addHandler (maImageHandler.createHandler (xContext)); aNode.addHandler (maTableHandler.createHandler (xContext)); + aNode.addHandler (maCellHandler.createHandler (xContext)); aNode.addHandler (maSelectionHandler.createHandler (xContext)); aNode.addHandler (maTreeHandler.createHandler (xContext)); } diff --git a/toolkit/test/accessibility/AccessibleCellHandler.java b/toolkit/test/accessibility/AccessibleCellHandler.java new file mode 100644 index 000000000000..1545d00adef6 --- /dev/null +++ b/toolkit/test/accessibility/AccessibleCellHandler.java @@ -0,0 +1,150 @@ + +import com.sun.star.uno.UnoRuntime; +import drafts.com.sun.star.accessibility.XAccessibleContext; +import drafts.com.sun.star.accessibility.XAccessibleTable; +import drafts.com.sun.star.accessibility.XAccessible; + + +class AccessibleCellHandler extends NodeHandler +{ + public NodeHandler createHandler (XAccessibleContext xContext) + { + XAccessibleContext xParent = + xContext.getAccessibleParent().getAccessibleContext(); + XAccessibleTable xTable = + (XAccessibleTable) UnoRuntime.queryInterface ( + XAccessibleTable.class, xParent); + if (xTable != null) + return new AccessibleCellHandler (xTable); + else + return null; + } + + public AccessibleCellHandler () + { + } + + public AccessibleCellHandler (XAccessibleTable xTable) + { + if (xTable != null) + maChildList.setSize (8); + } + + protected static XAccessibleTable getTable(Object aObject) + { + return (XAccessibleTable) UnoRuntime.queryInterface ( + XAccessibleTable.class, aObject); + } + + public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) + { + AccessibleTreeNode aChild = null; + XAccessibleTable xTable = null; + XAccessibleContext xContext = null; + AccessibleTreeNode aGrandParent = aParent.getParent(); + if (aGrandParent instanceof AccTreeNode) + { + xTable = ((AccTreeNode)aGrandParent).getTable(); + xContext = ((AccTreeNode)aGrandParent).getContext(); + } + if (aParent instanceof AccTreeNode) + { + xContext = ((AccTreeNode)aParent).getContext(); + } + try + { + if( xTable != null && xContext != null ) + { + switch( nIndex ) + { + case 0: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nRow = xTable.getAccessibleRow( nChild ); + + aChild = new StringNode ("# table row: " + nRow, aParent); + } + break; + case 1: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nCol = xTable.getAccessibleColumn( nChild ); + + aChild = new StringNode ("# table column: " + nCol, aParent); + } + break; + case 2: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nRow = xTable.getAccessibleRow( nChild ); + int nCol = xTable.getAccessibleColumn( nChild ); + int nExt = xTable.getAccessibleRowExtentAt( nRow, nCol ); + + aChild = new StringNode ("# table row extend: " + nExt, aParent); + } + break; + case 3: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nRow = xTable.getAccessibleRow( nChild ); + int nCol = xTable.getAccessibleColumn( nChild ); + int nExt = xTable.getAccessibleColumnExtentAt( nRow, nCol ); + + aChild = new StringNode ("# table column extend: " + nExt, aParent); + } + break; + case 4: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nRow = xTable.getAccessibleRow( nChild ); + int nCol = xTable.getAccessibleColumn( nChild ); + XAccessible xChild = + xTable.getAccessibleCellAt( nRow, nCol ); + + aChild = new StringNode ("# cell name retrieved from table: " + xChild.getAccessibleContext().getAccessibleName(), aParent); + } + break; + case 5: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nRow = xTable.getAccessibleRow( nChild ); + int nCol = xTable.getAccessibleColumn( nChild ); + boolean bSelected = + xTable.isAccessibleSelected( nRow, nCol ); + + aChild = new StringNode ("cell is selected: " + bSelected, aParent); + } + break; + case 6: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nRow = xTable.getAccessibleRow( nChild ); + boolean bSelected = + xTable.isAccessibleRowSelected( nRow ); + + aChild = new StringNode ("table row is selected: " + bSelected, aParent); + } + break; + case 7: + { + int nChild = xContext.getAccessibleIndexInParent(); + int nCol = xTable.getAccessibleColumn( nChild ); + boolean bSelected = + xTable.isAccessibleColumnSelected( nCol ); + + aChild = new StringNode ("table column is selected: " + bSelected, aParent); + } + break; + default: + aChild = new StringNode ("unknown child index " + nIndex, aParent); + } + } + } + catch (Exception e) + { + // Return empty child. + } + + return aChild; + } +} diff --git a/toolkit/test/accessibility/AccessibleTableHandler.java b/toolkit/test/accessibility/AccessibleTableHandler.java index 8d281f83b786..84e754dde8b0 100644 --- a/toolkit/test/accessibility/AccessibleTableHandler.java +++ b/toolkit/test/accessibility/AccessibleTableHandler.java @@ -24,7 +24,7 @@ class AccessibleTableHandler extends NodeHandler public AccessibleTableHandler (XAccessibleTable xTable) { if (xTable != null) - maChildList.setSize (1); + maChildList.setSize (4); } protected static XAccessibleTable getTable(Object aObject) @@ -35,6 +35,56 @@ class AccessibleTableHandler extends NodeHandler public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) { - return new StringNode ("interface XAccessibleTable is supported", aParent); + AccessibleTreeNode aChild = null; + XAccessibleTable xTable = null; + if (aParent instanceof AccTreeNode) + xTable = ((AccTreeNode)aParent).getTable(); + try + { + if( xTable != null ) + { + switch( nIndex ) + { + case 0: + aChild = new StringNode ("# table rows: " + xTable.getAccessibleRowCount(), aParent); + break; + case 1: + aChild = new StringNode ("# table columns: " + xTable.getAccessibleColumnCount(), aParent); + break; + case 2: + { + String sText = "selected rows: "; + int[] aSelected = xTable.getSelectedAccessibleRows(); + for( int i=0; i < aSelected.length; i++ ) + { + sText += aSelected[i]; + sText += " "; + } + aChild = new StringNode (sText, aParent); + } + break; + case 3: + { + String sText = "selected columns: "; + int[] aSelected = xTable.getSelectedAccessibleColumns(); + for( int i=0; i < aSelected.length; i++ ) + { + sText += aSelected[i]; + sText += " "; + } + aChild = new StringNode (sText, aParent); + } + break; + default: + aChild = new StringNode ("unknown child index " + nIndex, aParent); + } + } + } + catch (Exception e) + { + // Return empty child. + } + + return aChild; } } diff --git a/toolkit/test/accessibility/makefile.mk b/toolkit/test/accessibility/makefile.mk index 70f885e9abf2..4362c830ad4d 100644 --- a/toolkit/test/accessibility/makefile.mk +++ b/toolkit/test/accessibility/makefile.mk @@ -34,6 +34,7 @@ JAVA_FILES = \ AccessibilityTreeModel.java \ AccessibilityWorkBench.java \ AccessibleActionHandler.java \ + AccessibleCellHandler.java \ AccessibleComponentHandler.java \ AccessibleContextHandler.java \ AccessibleEditableTextHandler.java \ |