From 5a58fb16159c07b7d3a074da35609f94d4dbbe39 Mon Sep 17 00:00:00 2001 From: Andre Fischer Date: Fri, 15 Feb 2002 12:53:43 +0000 Subject: Initial revision of Uno Accessibility API test tool. --- toolkit/test/accessibility/AccessibilityTree.java | 414 ++++++++++++++ .../test/accessibility/AccessibilityWorkBench.java | 605 +++++++++++++++++++++ toolkit/test/accessibility/Canvas.java | 181 ++++++ toolkit/test/accessibility/InformationWriter.java | 420 ++++++++++++++ toolkit/test/accessibility/Print.java | 5 + toolkit/test/accessibility/SimpleOffice.java | 352 ++++++++++++ 6 files changed, 1977 insertions(+) create mode 100755 toolkit/test/accessibility/AccessibilityTree.java create mode 100755 toolkit/test/accessibility/AccessibilityWorkBench.java create mode 100755 toolkit/test/accessibility/Canvas.java create mode 100755 toolkit/test/accessibility/InformationWriter.java create mode 100755 toolkit/test/accessibility/Print.java create mode 100755 toolkit/test/accessibility/SimpleOffice.java (limited to 'toolkit') diff --git a/toolkit/test/accessibility/AccessibilityTree.java b/toolkit/test/accessibility/AccessibilityTree.java new file mode 100755 index 000000000000..a0610dddb69b --- /dev/null +++ b/toolkit/test/accessibility/AccessibilityTree.java @@ -0,0 +1,414 @@ +import AccessibleObject; +import MessageInterface; + +import drafts.com.sun.star.accessibility.XAccessible; +import drafts.com.sun.star.accessibility.XAccessibleContext; +import drafts.com.sun.star.accessibility.XAccessibleComponent; +import drafts.com.sun.star.accessibility.XAccessibleExtendedComponent; +import drafts.com.sun.star.accessibility.XAccessibleAction; +import drafts.com.sun.star.accessibility.XAccessibleImage; +import drafts.com.sun.star.accessibility.XAccessibleRelationSet; +import drafts.com.sun.star.accessibility.XAccessibleStateSet; + +import com.sun.star.lang.XServiceInfo; +import com.sun.star.uno.UnoRuntime; + +import java.util.Vector; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.tree.*; +import javax.swing.event.*; + + + +/** This class is a start to collect the handling of a JTree and a DefaultTreeModel. +*/ +public class AccessibilityTree extends JTree +{ + public static void main (String args[]) + { + new AccessibilityWorkBench (); + } + + + + + /** Local class used to store the accessible object with every tree node. + */ + protected class TreeNode extends DefaultMutableTreeNode + { + public AccessibleObject aAccessibleObject; + public TreeNode (String sName) + { + super (sName); + aAccessibleObject = null; + } + } + + /** Create a new accessibility tree. Use the specified message display + for displaying messages and the specified canvas to draw the + graphical representations of accessible objects on. + */ + public AccessibilityTree ( + MessageInterface aMessageDisplay, + Canvas aCanvas) + { + maMessageDisplay = aMessageDisplay; + maCanvas = aCanvas; + + maRoot = new DefaultMutableTreeNode ("Accessibility Tree"); + maTreeModel = new DefaultTreeModel (maRoot); + setModel (maTreeModel); + + setEditable (true); + + MouseListener ml = new MouseAdapter() { + public void mousePressed(MouseEvent e) { + int selRow = getRowForLocation(e.getX(), e.getY()); + TreePath selPath = getPathForLocation(e.getX(), e.getY()); + if(selRow != -1) { + if (e.getClickCount() == 2) + { + System.out.println ("double click : " + selRow + " , " + selPath); + Object aObject = selPath.getLastPathComponent(); + if (TreeNode.class.isInstance (aObject)) + { + TreeNode aNode = (TreeNode)aObject; + createTree (aNode.aAccessibleObject.getAccessible(), + selPath); + expandShapes (); + } + } + } + } + }; + addMouseListener (ml); + } + + + + + public void createTree (XAccessible xRoot, TreePath aPath) + { + System.out.println ("creating accessibility tree for root " + xRoot + " under path " + + aPath); + TreeNode aTree = createAccessibilityTree ( + xRoot, + 0, + new java.awt.Point(0,0), + aPath); + DefaultMutableTreeNode aRoot = (DefaultMutableTreeNode)aPath.getLastPathComponent(); + aRoot.insert (aTree, aRoot.getChildCount()); + maTreeModel.reload (); + } + + + + public void createTree (XAccessible xRoot) + { + createTree (xRoot, new TreePath (maRoot)); + } + + + + + public DefaultMutableTreeNode getRoot () + { + return maRoot; + } + + + + + protected TreeNode createAccessibilityTree ( + XAccessible xRoot, int depth, java.awt.Point aOrigin, TreePath aPath) + { + TreeNode aRoot = null; + + try + { + aRoot = newTreeNode (xRoot, depth); + TreePath aNewPath = aPath.pathByAddingChild (aRoot); + + if (depth >= 0) + { + AccessibleObject aObject = new AccessibleObject (xRoot, aNewPath); + aRoot.aAccessibleObject = aObject; + message ("creating accessibility tree at depth " + depth + ": " + + aObject.toString()); + + if (maCanvas != null) + { + if (aObject.getOrigin().x != 0 || aObject.getOrigin().y != 0) + { + maCanvas.addAccessible (aObject); + System.out.println ("adding object " + aObject.toString() + " to canvas"); + } + } + else + System.out.println ("no canvas"); + + aOrigin = aObject.getOrigin (); + } + + // Iterate over children and show them. + XAccessibleContext xContext = xRoot.getAccessibleContext(); + if (xContext != null) + { + int n = xContext.getAccessibleChildCount(); + for (int i=0; i>16&0xff) + +"G"+ (nColor>>8&0xff) + +"B"+ (nColor>>0&0xff))); + nColor = xEComponent.getBackground(); + aNode.add (new DefaultMutableTreeNode ( + "Background color: R" + + (nColor>>16&0xff) + +"G"+ (nColor>>8&0xff) + +"B"+ (nColor>>0&0xff))); + } + else + aNode.add (new DefaultMutableTreeNode ( + "XAccessibleExtendedComponent not supported")); + + XAccessibleAction xAction = + (XAccessibleAction) UnoRuntime.queryInterface ( + XAccessibleAction.class, xContext); + if (xAction != null) + { + int nActions = xAction.getAccessibleActionCount(); + aNode.add ( + new DefaultMutableTreeNode ( + "Actions: " + nActions)); + for (int i=0; i 0) + { + for (int i=0; i= 100) + { + TreePath aPath = new TreePath (aNode.getPath()); + expandPath (aPath); + if ( ! mbFirstShapeSeen) + { + mbFirstShapeSeen = true; + makeVisible (aPath); + } + } + } + // Descent into tree strucuture. + expandShapes (aChild); + } + } + } + catch (Exception e) + { + System.out.println ("caught exception while expanding shape nodes: " + e); + } + } + + + + + public void addDocument (XAccessible xAccessible, String sURL) + { + if (maTreeModel != null && maRoot != null) + { + System.out.println ("Trying to add node at position " + maRoot.getChildCount() + + " into root node"); + if (sURL.length() == 0) + sURL = ""; + TreeNode aNode = new TreeNode ("Document: " + sURL); + aNode.aAccessibleObject = new AccessibleObject (xAccessible, + new TreePath (maRoot).pathByAddingChild(aNode)); + maRoot.insert (aNode, maRoot.getChildCount()); + } + maTreeModel.reload (); + } + + + public void clear () + { + maRoot.removeAllChildren(); + } + + + protected void message (String message) + { + maMessageDisplay.message (message); + } + + + protected MessageInterface + maMessageDisplay; + + private DefaultMutableTreeNode + maRoot; + private DefaultTreeModel + maTreeModel; + private Canvas + maCanvas; + private boolean + mbFirstShapeSeen; +} diff --git a/toolkit/test/accessibility/AccessibilityWorkBench.java b/toolkit/test/accessibility/AccessibilityWorkBench.java new file mode 100755 index 000000000000..80240afb025b --- /dev/null +++ b/toolkit/test/accessibility/AccessibilityWorkBench.java @@ -0,0 +1,605 @@ +import SimpleOffice; +import InformationWriter; +import Print; +import Canvas; +import AccessibilityTree; + +import com.sun.star.awt.XWindow; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertyChangeListener; +import com.sun.star.beans.PropertyChangeEvent; +import com.sun.star.container.XEnumerationAccess; +import com.sun.star.container.XEnumeration; +import com.sun.star.document.XEventListener; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawView; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.frame.XFrameActionListener; +import com.sun.star.frame.FrameActionEvent; +import com.sun.star.frame.FrameAction; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.frame.XDesktop; +import com.sun.star.frame.XModel; +import com.sun.star.uno.UnoRuntime; + +import drafts.com.sun.star.accessibility.XAccessible; +import drafts.com.sun.star.accessibility.XAccessibleContext; +import drafts.com.sun.star.accessibility.XAccessibleComponent; +import drafts.com.sun.star.accessibility.XAccessibleExtendedComponent; +import drafts.com.sun.star.accessibility.XAccessibleRelationSet; +import drafts.com.sun.star.accessibility.XAccessibleStateSet; + + +import java.util.Vector; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.tree.*; + + +public class AccessibilityWorkBench + extends JFrame + implements ActionListener, + Print, + MessageInterface, + XEventListener, + XFrameActionListener, + XPropertyChangeListener +{ + public String msFileName; + /*WinFilename + // = "file:///d|/tmp/impress-test-document.sxi"; + = "file:///d|/tmp/writer-test-document.sxw"; + // = "file:///d|/tmp/calc-test-document.sxc"; + final public String sUnxFilename + = "file:///tmp/impress-test-document.sxi"; + //= "file:///tmp/draw-test-document.sxd"; + */ + + public static void main (String args[]) + { + int nPortNumber = 5678; + String sFileName = "file:///tmp/impress-test-document.sxi"; + + for (int i=0; i*"); + System.out.println ("options:"); + System.out.println (" -p Port on which to connect to StarOffice."); + System.out.println (" Defaults to 5678."); + System.out.println (" -f URL of document file which is loaded when"); + System.out.println (" clicking on the Load button. Don't forget"); + System.out.println (" the file:// prefix!"); + System.exit (0); + } + else if (args[i].equals ("-p")) + { + nPortNumber = Integer.parseInt (args[++i]); + } + else if (args[i].equals ("-f")) + { + sFileName = args[++i]; + } + } + + new AccessibilityWorkBench (nPortNumber, sFileName); + } + + + + + public AccessibilityWorkBench (int nPortNumber, String sFileName) + { + msFileName = sFileName; + + Layout (); + + println (System.getProperty ("os.name") + " / " + + System.getProperty ("os.arch") + " / " + + System.getProperty ("os.version")); + println ("Using port " + nPortNumber + " and document file name " + msFileName); + office = new SimpleOffice (this, nPortNumber); + info = new InformationWriter (this); + + addWindowListener (new WindowAdapter () + { public void windowClosing (WindowEvent e) + { System.exit(0); } + }); + + initialize (); + } + + + + + /** Create and arrange the widgets of the GUI. + */ + public void Layout () + { + setSize (new Dimension (1024,768)); + maMainPanel = new JPanel(); + this.getContentPane().add (maMainPanel); + GridBagLayout aLayout = new GridBagLayout (); + JScrollPane aScrollPane; + + // Text output area. + maOutputArea = new JTextArea (5,50); + maScrollPane = new JScrollPane(maOutputArea, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + GridBagConstraints constraints = new GridBagConstraints (); + constraints.gridx = 1; + constraints.gridy = 1; + constraints.gridwidth = 1; + constraints.gridheight = 1; + constraints.weightx = 3; + constraints.weighty = 1; + constraints.fill = GridBagConstraints.BOTH; + aLayout.addLayoutComponent (maScrollPane, constraints); + maMainPanel.add (maScrollPane); + + // Message output area. + maMessageArea = new JTextArea (5,20); + constraints = new GridBagConstraints (); + constraints.gridx = 0; + constraints.gridy = 2; + constraints.gridwidth = 2; + constraints.gridheight = 1; + constraints.weightx = 3; + constraints.weighty = 0; + constraints.fill = GridBagConstraints.BOTH; + aLayout.addLayoutComponent (maMessageArea, constraints); + maMainPanel.add (maMessageArea); + + // Canvas. + maCanvas = new Canvas (this, maTree); + maCanvas.setPreferredSize (new Dimension (1050,1050)); + aScrollPane = new JScrollPane(maCanvas, + JScrollPane.VERTICAL_SCROLLBAR_ALWAYS/*AS_NEEDED*/, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS/*AS_NEEDED*/); + constraints = new GridBagConstraints (); + constraints.gridx = 1; + constraints.gridy = 0; + constraints.gridwidth = 1; + constraints.gridheight = 1; + constraints.weightx = 3; + constraints.weighty = 3; + constraints.fill = GridBagConstraints.BOTH; + aLayout.addLayoutComponent (aScrollPane, constraints); + maMainPanel.add (aScrollPane); + + // Accessible Tree. + maTree = new AccessibilityTree (this, maCanvas); + aScrollPane = new JScrollPane(maTree, + JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + constraints = new GridBagConstraints (); + constraints.gridx = 0; + constraints.gridy = 0; + constraints.gridwidth = 1; + constraints.gridheight = 2; + constraints.weightx = 2; + constraints.weighty = 1; + constraints.fill = GridBagConstraints.BOTH; + aLayout.addLayoutComponent (aScrollPane, constraints); + maMainPanel.add (aScrollPane); + + // Button bar. + maButtonBar = new JPanel(); + GridBagLayout aButtonLayout = new GridBagLayout (); + maButtonBar.setLayout (aLayout); + constraints = new GridBagConstraints (); + constraints.gridx = 0; + constraints.gridy = 3; + constraints.gridwidth = 3; + constraints.weightx = 1; + constraints.anchor = GridBagConstraints.WEST; + constraints.fill = GridBagConstraints.BOTH; + aLayout.setConstraints (maButtonBar, constraints); + maMainPanel.add (maButtonBar); + + // Buttons. + aConnectButton = createButton ("Connect", "connect"); + aLoadButton = createButton ("Load", "load"); + aRunButton = createButton ("Run", "run"); + aUpdateButton = createButton ("Update", "update"); + aQuitButton = createButton ("Quit", "quit"); + + maMainPanel.setLayout (aLayout); + getContentPane().add ("Center", maMainPanel); + maMainPanel.setVisible (true); + setVisible (true); + setTitle("Accessibility Workbench"); + } + + + + /** Create a new button and place at the right most position into the + button bar. + */ + public JButton createButton (String title, String command) + { + JButton aButton = new JButton (title); + aButton.setActionCommand (command); + aButton.addActionListener (this); + GridBagConstraints constraints = new GridBagConstraints (); + constraints.gridx = maButtonBar.getComponentCount(); + constraints.gridy = 0; + GridBagLayout aLayout = (GridBagLayout)maButtonBar.getLayout(); + + aLayout.setConstraints (aButton, constraints); + maButtonBar.add (aButton); + return aButton; + } + + + protected void initialize () + { + // Clear the accessibility tree. + maTree.clear (); + + // Delete the graphical representations. + maCanvas.clear (); + + // Add entries for open documents to tree. + addOpenDocumentsToTree (); + } + + + /** Callback for GUI actions from the buttons. + */ + public void actionPerformed (java.awt.event.ActionEvent e) + { + if (e.getActionCommand().equals("connect")) + { + office.connect(); + initialize (); + } + else if (e.getActionCommand().equals("quit")) + { + System.exit (0); + } + else if (e.getActionCommand().equals("load")) + { + print ("Loading file " + msFileName); + mxModel = office.loadDocument (msFileName); + if (mxModel == null) + println (": could not be loaded"); + else + { + println ("."); + XWindow xWindow = office.getCurrentWindow (mxModel); + XAccessible xRoot = office.getAccessibleRoot (xWindow); + maTree.addDocument (xRoot, msFileName); + } + } + else if (e.getActionCommand().equals("run")) + { + run (mxModel); + } + else if (e.getActionCommand().equals("update")) + { + initialize (); + run (mxModel); + } + else + { + System.err.println("unknown command " + e.getActionCommand()); + } + } + + + + + public void test (XModel xModel) + { + println ("Test:"); + try + { + if (xModel == null) + { + XDrawView xView = office.getCurrentView (); + if (xView == null) + println ("no current view"); + else + xModel = office.getModel (xView); + } + info.showProperties (xModel); + + XWindow xWindow = office.getCurrentWindow (xModel); + if (xWindow != null) + { + println ("current window:"); + com.sun.star.awt.Rectangle aRectangle = xWindow.getPosSize(); + println (aRectangle.X + " " + aRectangle.Y + " " + + aRectangle.Width + " " + aRectangle.Height); + } + else + println ("Can't get window"); + + XPropertySet xSet = (XPropertySet) UnoRuntime.queryInterface ( + XPropertySet.class, xModel); + if (xSet != null) + { + com.sun.star.awt.Rectangle aRectangle = + (com.sun.star.awt.Rectangle) xSet.getPropertyValue ( + "VisibleArea"); + println (aRectangle.X + " " + aRectangle.Y + " " + + aRectangle.Width + " " + aRectangle.Height); + } + else + println ("model does not support XPropertySet"); + } + catch (Exception e) + { + System.out.println ("caught exception in test: " + e); + } + println ("Test finished."); + } + + + + + /** Get the accessibility tree for the specified model. + */ + protected void run (XModel xModel) + { + try + { + addListeners (xModel); + XWindow xWindow = office.getCurrentWindow (xModel); + XAccessible xRoot = office.getAccessibleRoot (xWindow); + if (xRoot != null) + { + println ("window is accessible"); + } + else + { + println ("window is not accessible."); + return; + } + + message ("creating accessibility tree"); + maTree.createTree (xRoot); + maTree.expandShapes (); + } + catch (Exception e) + { + System.out.println ("caught exception in run: " + e); + } + } + + + + + + /** Experimental. Add list of currently open (and named) documents to + the tree widget. + */ + public void addOpenDocumentsToTree () + { + try + { + XDesktop xDesktop = office.getDesktop(); + if (xDesktop == null) + { + println ("can't get desktop to retrieve open documents"); + return; + } + + XEnumerationAccess xEA = xDesktop.getComponents(); + if (xEA == null) + { + println ("Can't get list of components from desktop"); + return; + } + XEnumeration xE = xEA.createEnumeration(); + while (xE.hasMoreElements()) + { + XComponent xComponent = (XComponent) UnoRuntime.queryInterface( + XComponent.class, xE.nextElement()); + XModel xModel = (XModel) UnoRuntime.queryInterface( + XModel.class, xComponent); + if (xModel != null) + { + println (xModel.getURL()); + XWindow xWindow = office.getCurrentWindow (xModel); + XAccessible xRoot = office.getAccessibleRoot (xWindow); + maTree.addDocument (xRoot, xModel.getURL()); + } + else + println ("can't cast component to model"); + } + println ("finished getting named documents"); + } + catch (Exception e) + { + System.out.println ("caught exception while getting document names: " + e); + } + } + + + + + /** Add various listeners to the model and other Office objects. + */ + protected void addListeners (XModel xModel) + { + + com.sun.star.document.XEventBroadcaster xBr = + (com.sun.star.document.XEventBroadcaster)UnoRuntime.queryInterface( + com.sun.star.document.XEventBroadcaster.class, xModel); + if( xBr != null ) + xBr.addEventListener (this); + + XController xController = xModel.getCurrentController(); + if (xController != null) + { + XFrame xFrame = xController.getFrame(); + if (xFrame != null) + { + xFrame.addFrameActionListener( this ); + System.out.println("[DONE]"); + } + connectListener( xController ); + } + } + + + + public boolean connectListener( XController xController ) + { + System.out.println("connecting to controller..."); + + XServiceInfo oObj = (XServiceInfo)UnoRuntime.queryInterface(XServiceInfo.class, xController); + String[] names = oObj.getSupportedServiceNames(); + for (int i=0;iaddAccessible member function. +*/ +class Canvas + extends JPanel + implements MouseListener, MouseMotionListener +{ + public MessageInterface maMessageDisplay; + public final int nMaximumWidth = 1000; + public final int nMaximumHeight = 1000; + + public Canvas (MessageInterface aMessageDisplay, JTree aTree) + { + super (true); + maObjects = new Vector (); + addMouseListener (this); + addMouseMotionListener (this); + maBoundingBox = new Rectangle (0,0,100,100); + setPreferredSize (maBoundingBox.getSize()); + setSize (nMaximumWidth,nMaximumHeight); + maMessageDisplay = aMessageDisplay; + maTree = aTree; + mnXOffset = 0; + mnYOffset = 0; + mnScaleFactor = 1; + } + + public void addAccessible (AccessibleObject aObject) + { + maObjects.add (aObject); + maBoundingBox = maBoundingBox.union (aObject.getBBox()); + } + + public void clear () + { + maObjects.clear(); + } + + public void paintComponent (Graphics g) + { + Rectangle r = g.getClipBounds(); + g.clearRect (r.x,r.y,r.width,r.height); + + // Recalculate scale and offset so that all accessible objects fit + // into the area specified by nMaximum(Width,Height) + double nXScale = 1, + nYScale = 1; + if (maBoundingBox.getWidth() > nMaximumWidth) + nXScale = 1.0 * nMaximumWidth / maBoundingBox.getWidth(); + if (maBoundingBox.getHeight() > nMaximumHeight) + nYScale = 1.0 * nMaximumHeight / maBoundingBox.getHeight(); + if (nXScale < nYScale) + mnScaleFactor = nXScale; + else + mnScaleFactor = nYScale; + + int n = maObjects.size(); + for (int i=0; i 0) + sIndent += " "; + + // Get XAccessibleContext object if given object does not + // already support this interface. + XAccessibleContext xContext + = (XAccessibleContext) UnoRuntime.queryInterface ( + XAccessibleContext.class, xObject); + if (xContext == null) + { + XAccessible xAccessible + = (XAccessible) UnoRuntime.queryInterface ( + XAccessible.class, xObject); + if (xAccessible == null) + { + println (sIndent + "given object " + xObject + + " is not accessible"); + return false; + } + else + xContext = xAccessible.getAccessibleContext(); + } + + // Print information about the accessible context. + if (xContext != null) + { + println (sIndent + "Name : " + + xContext.getAccessibleName()); + println (sIndent + "Description : " + + xContext.getAccessibleDescription()); + println (sIndent + "Role : " + + xContext.getAccessibleRole()); + String sHasParent; + if (xContext.getAccessibleParent() != null) + { + println (sIndent + "Has parent : yes"); + println (sIndent + "Parent index : " + + xContext.getAccessibleIndexInParent()); + } + else + println (sIndent + "Has parent : no"); + println (sIndent + "Child count : " + + xContext.getAccessibleChildCount()); + print (sIndent + "Relation set : "); + XAccessibleRelationSet xRelationSet + = xContext.getAccessibleRelationSet(); + if (xRelationSet != null) + { + print (xRelationSet.getRelationCount() + " ("); + for (int i=0; i 0) + print (", "); + print (xRelationSet.getRelation(i).toString()); + } + println (")"); + } + else + println ("no relation set"); + + print (sIndent + "State set : "); + XAccessibleStateSet xStateSet = + xContext.getAccessibleStateSet(); + if (xStateSet != null) + { + XIndexAccess xStates = + (XIndexAccess) UnoRuntime.queryInterface ( + XIndexAccess.class, xStateSet); + print (xStates.getCount() + " ("); + for (int i=0; i 0) + print (", "); + print (xStates.getByIndex(i).toString()); + } + println (")"); + } + else + println ("no state set"); + + showAccessibleComponent (xContext, sIndent); + } + else + println ("object has no accessible context."); + + // showInfo (xContext); + // showServices (xContext); + // showInterfaces (xContext); + } + catch (Exception e) + { + System.out.println ("caught exception in showAccessibility :" + e); + } + return true; + } + + + + + /** @descr Print information about the given accessible component. + */ + public void showAccessibleComponent (XInterface xObject, String sIndent) + { + try + { + XAccessibleComponent xComponent = + (XAccessibleComponent) UnoRuntime.queryInterface ( + XAccessibleComponent.class, xObject); + + // Print information about the accessible context. + if (xComponent != null) + { + println (sIndent + "Position : " + + xComponent.getLocation().X+", " + + xComponent.getLocation().Y); + println (sIndent + "Screen position : " + + xComponent.getLocationOnScreen().X+", " + + xComponent.getLocationOnScreen().Y); + println (sIndent + "Size : " + + xComponent.getSize().Width+", " + + xComponent.getSize().Height); + } + } + catch (Exception e) + { + System.out.println ( + "caught exception in showAccessibleComponent : " + e); + } + } + + + public boolean showAccessibilityTree (XAccessible xRoot, int depth) + { + if ( ! showAccessibility (xRoot, depth)) + return false; + + String sIndent = ""; + for (int i=0; i 0) + { + // All shapes return as accessible object the document window's + // accessible object. This is, of course, a hack and will be + // removed as soon as the missing infrastructure for obtaining + // the object directly is implemented. + XShape xShape = null; + try{ + xShape = (XShape) UnoRuntime.queryInterface( + XShape.class, xShapeList.getByIndex (0)); + } catch (Exception e) + {} + XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface ( + XAccessible.class, xShape); + return xAccessible; + } + else + return null; + } + + + + + public void print (String text) + { + maPrinter.print (text); + } + + public void println (String text) + { + maPrinter.println (text); + } +} -- cgit