diff options
author | Andre Fischer <af@openoffice.org> | 2002-04-05 08:45:11 +0000 |
---|---|---|
committer | Andre Fischer <af@openoffice.org> | 2002-04-05 08:45:11 +0000 |
commit | 3efd182bbb419c386f1a078c0659e3f6211f06de (patch) | |
tree | a899b926218f4f0dee21cde8dd22fc5b1bc30c4e /toolkit/test/accessibility/AccessibleTextHandler.java | |
parent | d2e64c317a8ee9ac0fd63fd1484437b2fcb5e8e1 (diff) |
#97772# Moved shortcuts to different interfaces of one XAccessible into AccTreeNode.
Diffstat (limited to 'toolkit/test/accessibility/AccessibleTextHandler.java')
-rw-r--r-- | toolkit/test/accessibility/AccessibleTextHandler.java | 53 |
1 files changed, 20 insertions, 33 deletions
diff --git a/toolkit/test/accessibility/AccessibleTextHandler.java b/toolkit/test/accessibility/AccessibleTextHandler.java index 5eb86b5213bb..43fb5004298b 100644 --- a/toolkit/test/accessibility/AccessibleTextHandler.java +++ b/toolkit/test/accessibility/AccessibleTextHandler.java @@ -26,8 +26,6 @@ import javax.swing.text.JTextComponent; class AccessibleTextHandler extends NodeHandler { - private XAccessibleText mxText; - public NodeHandler createHandler (XAccessibleContext xContext) { XAccessibleText xText = (XAccessibleText) UnoRuntime.queryInterface ( @@ -44,32 +42,16 @@ class AccessibleTextHandler extends NodeHandler public AccessibleTextHandler (XAccessibleText xText) { - mxText = xText; - if (mxText != null) + if (xText != null) maChildList.setSize (12); } - protected XAccessibleText getText( Object aObject ) - { - return mxText; - } - - protected XAccessibleEditableText getEditText( Object aObject ) - { - XAccessibleEditableText xText = - (XAccessibleEditableText) UnoRuntime.queryInterface ( - XAccessibleEditableText.class, aObject); - return xText; - } - - - public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) { AccessibleTreeNode aChild = null; XAccessibleText xText = null; if (aParent instanceof AccTreeNode) - xText = getText (((AccTreeNode)aParent).getContext()); + xText = ((AccTreeNode)aParent).getText(); try { @@ -293,24 +275,29 @@ class AccessibleTextHandler extends NodeHandler new String[] { "select...", "copy...", "cut...", "paste...", "edit..." }; - public String[] getActions(Object aObject) + public String[] getActions (AccessibleTreeNode aNode) { - XAccessibleEditableText xEText = getEditText( aObject ); + XAccessibleEditableText xEText = null; + if (aNode instanceof AccTreeNode) + xEText = ((AccTreeNode)aNode).getEditText (); return (xEText == null) ? aTextActions : aEditableTextActions; } - public void performAction(Object aObject, int nIndex) + public void performAction (AccessibleTreeNode aNode, int nIndex) { + if ( ! (aNode instanceof AccTreeNode)) + return; + TextActionDialog aDialog = null; - XAccessibleText xText = getText( aObject ); + XAccessibleText xText = ((AccTreeNode)aNode).getText(); // create proper dialog switch( nIndex ) { case 0: - aDialog = new TextActionDialog( aObject, + aDialog = new TextActionDialog( aNode, "Select range:", xText.getText(), "select" ) @@ -318,14 +305,14 @@ class AccessibleTextHandler extends NodeHandler void action( JTextComponent aText, Object aObject ) throws IndexOutOfBoundsException { - getText( aObject ).setSelection( + ((AccTreeNode)aObject).getText().setSelection( aText.getSelectionStart(), aText.getSelectionEnd() ); } }; break; case 1: - aDialog = new TextActionDialog( aObject, + aDialog = new TextActionDialog( aNode, "Select range and copy:", xText.getText(), "copy" ) @@ -333,14 +320,14 @@ class AccessibleTextHandler extends NodeHandler void action( JTextComponent aText, Object aObject ) throws IndexOutOfBoundsException { - getText( aObject ).copyText( + ((AccTreeNode)aObject).getText().copyText( aText.getSelectionStart(), aText.getSelectionEnd() ); } }; break; case 2: - aDialog = new TextActionDialog( aObject, + aDialog = new TextActionDialog( aNode, "Select range and cut:", xText.getText(), "cut" ) @@ -348,14 +335,14 @@ class AccessibleTextHandler extends NodeHandler void action( JTextComponent aText, Object aObject ) throws IndexOutOfBoundsException { - getEditText( aObject ).cutText( + ((AccTreeNode)aObject).getEditText().cutText( aText.getSelectionStart(), aText.getSelectionEnd() ); } }; break; case 3: - aDialog = new TextActionDialog( aObject, + aDialog = new TextActionDialog( aNode, "Place Caret and paste:", xText.getText(), "paste" ) @@ -363,13 +350,13 @@ class AccessibleTextHandler extends NodeHandler void action( JTextComponent aText, Object aObject ) throws IndexOutOfBoundsException { - getEditText( aObject ).pasteText( + ((AccTreeNode)aObject).getEditText().pasteText( aText.getCaretPosition() ); } }; break; case 4: - aDialog = new TextEditDialog( aObject, "Edit text:", + aDialog = new TextEditDialog( aNode, "Edit text:", xText.getText(), "edit" ); break; } |