From 43cc8ad33e815522e2b23ac87a4a9c4526cd85c9 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 19 Dec 2014 16:03:41 +0200 Subject: java: remove dead code found by UCDetector Change-Id: I6b0f49529379072da566e927b86815f173e7a90b --- toolkit/test/accessibility/AccTreeNode.java | 37 -- toolkit/test/accessibility/AccessibilityTree.java | 5 - .../test/accessibility/AccessibilityTreeModel.java | 21 -- .../test/accessibility/AccessibleCellHandler.java | 6 - .../accessibility/AccessibleContextHandler.java | 2 - .../AccessibleEditableTextHandler.java | 6 - .../accessibility/AccessibleHyperlinkHandler.java | 8 - .../accessibility/AccessibleHypertextHandler.java | 8 - .../test/accessibility/AccessibleTableHandler.java | 6 - .../accessibility/AccessibleTreeCellRenderer.java | 108 ------ toolkit/test/accessibility/AccessibleTreeNode.java | 5 - toolkit/test/accessibility/CanvasShape.java | 28 -- toolkit/test/accessibility/EventLogger.java | 47 --- .../test/accessibility/FrameActionListener.java | 32 -- toolkit/test/accessibility/HelpWindow.java | 14 - toolkit/test/accessibility/InformationWriter.java | 406 --------------------- toolkit/test/accessibility/MessageArea.java | 11 - toolkit/test/accessibility/NodeHandler.java | 10 - toolkit/test/accessibility/NodeMap.java | 13 - toolkit/test/accessibility/OfficeConnection.java | 8 - toolkit/test/accessibility/Options.java | 10 - toolkit/test/accessibility/SimpleOffice.java | 251 +------------ toolkit/test/accessibility/TextLogger.java | 59 --- toolkit/test/accessibility/TextUpdateListener.java | 144 -------- toolkit/test/accessibility/ov/SelectionView.java | 244 ------------- 25 files changed, 1 insertion(+), 1488 deletions(-) delete mode 100644 toolkit/test/accessibility/AccessibleTreeCellRenderer.java delete mode 100644 toolkit/test/accessibility/EventLogger.java delete mode 100644 toolkit/test/accessibility/FrameActionListener.java delete mode 100644 toolkit/test/accessibility/InformationWriter.java delete mode 100644 toolkit/test/accessibility/TextLogger.java delete mode 100644 toolkit/test/accessibility/TextUpdateListener.java delete mode 100644 toolkit/test/accessibility/ov/SelectionView.java (limited to 'toolkit/test') diff --git a/toolkit/test/accessibility/AccTreeNode.java b/toolkit/test/accessibility/AccTreeNode.java index f728d8536869..aae3ed5758d4 100644 --- a/toolkit/test/accessibility/AccTreeNode.java +++ b/toolkit/test/accessibility/AccTreeNode.java @@ -23,7 +23,6 @@ import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleComponent; import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.accessibility.XAccessibleEditableText; -import com.sun.star.accessibility.XAccessibleExtendedComponent; import com.sun.star.accessibility.XAccessibleSelection; import com.sun.star.accessibility.XAccessibleTable; import com.sun.star.accessibility.XAccessibleText; @@ -52,24 +51,17 @@ class AccTreeNode private ArrayList maHandlers; // The accessible context of this node. - private XAccessible mxAccessible; private XAccessibleContext mxContext; private XAccessibleComponent mxComponent; private XAccessibleText mxText; private XAccessibleTable mxTable; - public AccTreeNode (XAccessible xAccessible, XAccessibleContext xContext, AccessibleTreeNode aParent) - { - this (xAccessible, xContext, xContext, aParent); - } - public AccTreeNode (XAccessible xAccessible, XAccessibleContext xContext, Object aDisplay, AccessibleTreeNode aParent) { super (aDisplay, aParent); maHandlers = new ArrayList(5); mxContext = xContext; - mxAccessible = xAccessible; } /** Update the internal data extracted from the corresponding accessible @@ -102,17 +94,6 @@ class AccTreeNode return mxComponent; } - public XAccessibleExtendedComponent getExtendedComponent () - { - if (mxComponent == null) - getComponent(); - if (mxComponent != null) - return UnoRuntime.queryInterface( - XAccessibleExtendedComponent.class, mxComponent); - else - return null; - } - public XAccessibleText getText () { if (mxText == null && mxContext != null) @@ -136,14 +117,6 @@ class AccTreeNode } - public XAccessible getAccessible() - { - if ((mxAccessible == null) && (mxContext != null)) - mxAccessible = UnoRuntime.queryInterface( - XAccessible.class, mxContext); - return mxAccessible; - } - public XAccessibleSelection getSelection () { return UnoRuntime.queryInterface( @@ -348,16 +321,6 @@ class AccTreeNode return null; } - /** Update the specified handlers. - @return - The returned array contains the indices of the updated children - and can be used to create a TreeModelEvent. - */ - public java.util.List updateChildren (java.lang.Class class1) - { - return updateChildren (class1, null); - } - public java.util.List updateChildren (java.lang.Class class1, java.lang.Class class2) { ArrayList aChildIndices = new ArrayList(); diff --git a/toolkit/test/accessibility/AccessibilityTree.java b/toolkit/test/accessibility/AccessibilityTree.java index 867fdbfa5ca0..d750bf75c811 100644 --- a/toolkit/test/accessibility/AccessibilityTree.java +++ b/toolkit/test/accessibility/AccessibilityTree.java @@ -204,11 +204,6 @@ public class AccessibilityTree - public void disposing (com.sun.star.lang.EventObject e) - { - System.out.println ("disposing " + e); - } - /* public Dimension getPreferredSize () { diff --git a/toolkit/test/accessibility/AccessibilityTreeModel.java b/toolkit/test/accessibility/AccessibilityTreeModel.java index 4bf258ce7f55..bc6abf8457eb 100644 --- a/toolkit/test/accessibility/AccessibilityTreeModel.java +++ b/toolkit/test/accessibility/AccessibilityTreeModel.java @@ -71,21 +71,6 @@ public class AccessibilityTreeModel } - - - /** Inform all listeners (especially the renderer) of a change of the - tree's structure. - @param aNode This node specifies the sub tree in which all changes - take place. - */ - public void FireTreeStructureChanged (AccessibleTreeNode aNode) - { - } - - - - - @Override public synchronized void setRoot (AccessibleTreeNode aRoot) { @@ -339,12 +324,6 @@ public class AccessibilityTreeModel } } - protected TreeModelEvent createEvent (XAccessibleContext xParent) - { - AccessibleTreeNode aParentNode = maNodeMap.GetNode (xParent); - return new TreeModelEvent (this, createPath (aParentNode)); - } - /** Create a TreeModelEvent object that informs listeners that one child has been removed from or inserted into its parent. */ diff --git a/toolkit/test/accessibility/AccessibleCellHandler.java b/toolkit/test/accessibility/AccessibleCellHandler.java index c52532d8555c..c251f679064c 100644 --- a/toolkit/test/accessibility/AccessibleCellHandler.java +++ b/toolkit/test/accessibility/AccessibleCellHandler.java @@ -53,12 +53,6 @@ class AccessibleCellHandler extends NodeHandler maChildList.setSize (8); } - protected static XAccessibleTable getTable(Object aObject) - { - return UnoRuntime.queryInterface ( - XAccessibleTable.class, aObject); - } - @Override public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) { diff --git a/toolkit/test/accessibility/AccessibleContextHandler.java b/toolkit/test/accessibility/AccessibleContextHandler.java index 9483c5c79b9a..3b3d351086c7 100644 --- a/toolkit/test/accessibility/AccessibleContextHandler.java +++ b/toolkit/test/accessibility/AccessibleContextHandler.java @@ -24,8 +24,6 @@ import tools.NameProvider; class AccessibleContextHandler extends NodeHandler { - protected int nChildrenCount; - @Override public NodeHandler createHandler (XAccessibleContext xContext) { diff --git a/toolkit/test/accessibility/AccessibleEditableTextHandler.java b/toolkit/test/accessibility/AccessibleEditableTextHandler.java index a31073b22af5..ae5df14618ec 100644 --- a/toolkit/test/accessibility/AccessibleEditableTextHandler.java +++ b/toolkit/test/accessibility/AccessibleEditableTextHandler.java @@ -45,12 +45,6 @@ class AccessibleEditableTextHandler extends NodeHandler maChildList.setSize (1); } - protected static XAccessibleEditableText getEText (AccTreeNode aNode) - { - return UnoRuntime.queryInterface ( - XAccessibleEditableText.class, aNode.getContext()); - } - @Override public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) { diff --git a/toolkit/test/accessibility/AccessibleHyperlinkHandler.java b/toolkit/test/accessibility/AccessibleHyperlinkHandler.java index 9af7390e9749..41a161ac5a74 100644 --- a/toolkit/test/accessibility/AccessibleHyperlinkHandler.java +++ b/toolkit/test/accessibility/AccessibleHyperlinkHandler.java @@ -45,14 +45,6 @@ class AccessibleHyperlinkHandler extends AccessibleTreeHandler maChildList.setSize (1); } - protected XAccessibleHyperlink getHyperlink(Object aObject) - { - XAccessibleHyperlink xHyperlink = - UnoRuntime.queryInterface ( - XAccessibleHyperlink.class, aObject); - return xHyperlink; - } - @Override public AccessibleTreeNode getChild (AccessibleTreeNode aParent, int nIndex) { diff --git a/toolkit/test/accessibility/AccessibleHypertextHandler.java b/toolkit/test/accessibility/AccessibleHypertextHandler.java index 7021c2abc77e..603d68997d87 100644 --- a/toolkit/test/accessibility/AccessibleHypertextHandler.java +++ b/toolkit/test/accessibility/AccessibleHypertextHandler.java @@ -45,14 +45,6 @@ class AccessibleHypertextHandler extends AccessibleTreeHandler maChildList.setSize (1); } - protected static XAccessibleHypertext getHypertext (AccTreeNode aNode) - { - XAccessibleHypertext xHypertext = - UnoRuntime.queryInterface ( - XAccessibleHypertext.class, aNode.getContext()); - return xHypertext; - } - @Override public AccessibleTreeNode getChild (AccessibleTreeNode aParent, int nIndex) { diff --git a/toolkit/test/accessibility/AccessibleTableHandler.java b/toolkit/test/accessibility/AccessibleTableHandler.java index 8697a52a0232..a72fe61a3587 100644 --- a/toolkit/test/accessibility/AccessibleTableHandler.java +++ b/toolkit/test/accessibility/AccessibleTableHandler.java @@ -45,12 +45,6 @@ class AccessibleTableHandler extends NodeHandler maChildList.setSize (4); } - protected static XAccessibleTable getTable(Object aObject) - { - return UnoRuntime.queryInterface ( - XAccessibleTable.class, aObject); - } - @Override public AccessibleTreeNode createChild (AccessibleTreeNode aParent, int nIndex) { diff --git a/toolkit/test/accessibility/AccessibleTreeCellRenderer.java b/toolkit/test/accessibility/AccessibleTreeCellRenderer.java deleted file mode 100644 index 3a1f7150b5e6..000000000000 --- a/toolkit/test/accessibility/AccessibleTreeCellRenderer.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -import java.awt.Color; -import java.awt.Component; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JTree; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.TreePath; - - -public class AccessibleTreeCellRenderer - extends DefaultTreeCellRenderer -{ - private Color - maDefaultColor, - maChangedColor; - private ArrayList - maChangedLines; - - - - public AccessibleTreeCellRenderer () - { - maDefaultColor = Color.black; - maChangedColor = Color.red; - maChangedLines = new ArrayList (); - } - - @Override - public Component getTreeCellRendererComponent ( - JTree tree, - Object value, - boolean sel, - boolean expanded, - boolean leaf, - int row, - boolean hasFocus) - { - super.getTreeCellRendererComponent( - tree, value, sel, - expanded, leaf, row, - hasFocus); - - if (maChangedLines.size()<=row || maChangedLines.get (row) == null) - setTextNonSelectionColor (maDefaultColor); - else - setTextNonSelectionColor (maChangedColor); - - return this; - } - - /** Tell the cell renderer that no changes shall be displayed anymore. - */ - public void clearAllChanges () - { - maChangedLines.clear(); - } - - /** Inform the cell renderer of a new changed line which to paint - highlighted when asked to paint it the next time. - */ - private void addChangedLine (int nRow) - { - while (maChangedLines.size() <= nRow) { - maChangedLines.add(null); - } - nRow -= 1; // row index is one to large for some reason. - maChangedLines.set (nRow, true); - } - - /** Inform the cell renderer of a set of changed line which to paint - highlighted when asked to paint them the next time. - @param aChangedNodes - The set of changed nodes. Each entry is a TreePath. - @param aTree - The JTree that is used to transform the given TreePath objects - into rows. - */ - public void addChangedNodes (List aChangedNodes, JTree aTree) - { - for (int i=0; i 0) { - sIndent += " "; - } - - // Get XAccessibleContext object if given object does not - // already support this interface. - XAccessibleContext xContext - = UnoRuntime.queryInterface ( - XAccessibleContext.class, xObject); - if (xContext == null) - { - XAccessible xAccessible - = UnoRuntime.queryInterface ( - XAccessible.class, xObject); - if (xAccessible == null) - { - MessageArea.println (sIndent + "given object " + xObject - + " is not accessible"); - return false; - } - else - xContext = xAccessible.getAccessibleContext(); - } - - // Print information about the accessible context. - if (xContext != null) - { - MessageArea.println (sIndent + "Name : " - + xContext.getAccessibleName()); - MessageArea.println (sIndent + "Description : " - + xContext.getAccessibleDescription()); - MessageArea.println (sIndent + "Role : " - + xContext.getAccessibleRole()); - if (xContext.getAccessibleParent() != null) - { - MessageArea.println (sIndent + "Has parent : yes"); - MessageArea.println (sIndent + "Parent index : " - + xContext.getAccessibleIndexInParent()); - } - else - MessageArea.println (sIndent + "Has parent : no"); - MessageArea.println (sIndent + "Child count : " - + xContext.getAccessibleChildCount()); - MessageArea.print (sIndent + "Relation set : "); - XAccessibleRelationSet xRelationSet - = xContext.getAccessibleRelationSet(); - if (xRelationSet != null) - { - MessageArea.print (xRelationSet.getRelationCount() + " ("); - for (int i=0; i 0) - MessageArea.print (", "); - MessageArea.print (xRelationSet.getRelation(i).toString()); - } - MessageArea.println (")"); - } - else - MessageArea.println ("no relation set"); - - MessageArea.print (sIndent + "State set : "); - XAccessibleStateSet xStateSet = - xContext.getAccessibleStateSet(); - if (xStateSet != null) - { - XIndexAccess xStates = - UnoRuntime.queryInterface ( - XIndexAccess.class, xStateSet); - MessageArea.print (xStates.getCount() + " ("); - for (int i=0; i 0) - MessageArea.print (", "); - MessageArea.print (xStates.getByIndex(i).toString()); - } - MessageArea.println (")"); - } - else - MessageArea.println ("no state set"); - - showAccessibleComponent (xContext, sIndent); - } - else - MessageArea.println ("object has no accessible context."); - - } - catch (Exception e) - { - System.out.println ("caught exception in showAccessibility :" + e); - } - return true; - } - - - - - /** @descr Print information about the given accessible component. - */ - private void showAccessibleComponent (XInterface xObject, String sIndent) - { - try - { - XAccessibleComponent xComponent = - UnoRuntime.queryInterface ( - XAccessibleComponent.class, xObject); - - // Print information about the accessible context. - if (xComponent != null) - { - MessageArea.println (sIndent + "Position : " - + xComponent.getLocation().X+", " - + xComponent.getLocation().Y); - MessageArea.println (sIndent + "Screen position : " - + xComponent.getLocationOnScreen().X+", " - + xComponent.getLocationOnScreen().Y); - MessageArea.println (sIndent + "Size : " - + xComponent.getSize().Width+", " - + xComponent.getSize().Height); - } - } - catch (Exception e) - { - System.out.println ( - "caught exception in showAccessibleComponent : " + e); - } - } - - - /** Show a textual representation of the accessibility subtree rooted in - xRoot. - */ - public boolean showAccessibilityTree (XAccessible xRoot, int depth) - { - try - { - if ( ! showAccessibility (xRoot, depth)) - return false; - - String sIndent = ""; - for (int i=0; i (); } - /** Clear the cache of child objects. - */ - public void clear () - { - synchronized (maChildList) - { - maChildList.clear(); - } - } - /** return the number of children this object has */ public int getChildCount() { diff --git a/toolkit/test/accessibility/NodeMap.java b/toolkit/test/accessibility/NodeMap.java index aaf4baafff02..b8e8b3bf3300 100644 --- a/toolkit/test/accessibility/NodeMap.java +++ b/toolkit/test/accessibility/NodeMap.java @@ -106,19 +106,6 @@ class NodeMap return null; } - XAccessibleContext GetAccessible (AccessibleTreeNode aNode) - { - if ((aNode != null) && (aNode instanceof AccTreeNode)) - return ((AccTreeNode)aNode).getContext(); - else - return null; - } - - boolean IsMember (XAccessibleContext xContext) - { - return maXAccessibleToNode.containsKey(xContext); - } - boolean ValueIsMember (AccessibleTreeNode aNode) { return maXAccessibleToNode.containsValue(aNode); diff --git a/toolkit/test/accessibility/OfficeConnection.java b/toolkit/test/accessibility/OfficeConnection.java index eb43847f95db..4ecb98ba0b47 100644 --- a/toolkit/test/accessibility/OfficeConnection.java +++ b/toolkit/test/accessibility/OfficeConnection.java @@ -43,14 +43,6 @@ public class OfficeConnection return maServiceManager; } - /** @descr Return a flag that indicates if the constructor has been able to - establish a valid connection. - */ - public boolean connectionIsValid () - { - return getServiceManager() != null; - } - /** @descr Connect to an already running LibreOffice application. */ private void connect () diff --git a/toolkit/test/accessibility/Options.java b/toolkit/test/accessibility/Options.java index 3b9e5372c160..bbe7d608a7d3 100644 --- a/toolkit/test/accessibility/Options.java +++ b/toolkit/test/accessibility/Options.java @@ -34,16 +34,6 @@ class Options return saOptions; } - static public void SetString (String sName, String sValue) - { - Instance().setProperty (sName, sValue); - } - - static public String GetString (String sName) - { - return Instance().getProperty (sName); - } - static public void SetBoolean (String sName, boolean bValue) { Instance().setProperty (sName, Boolean.toString(bValue)); diff --git a/toolkit/test/accessibility/SimpleOffice.java b/toolkit/test/accessibility/SimpleOffice.java index e588e5b9e2fd..ecb16a6e3877 100644 --- a/toolkit/test/accessibility/SimpleOffice.java +++ b/toolkit/test/accessibility/SimpleOffice.java @@ -16,30 +16,11 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -import com.sun.star.awt.XWindow; - -import com.sun.star.beans.PropertyValue; -import com.sun.star.container.XIndexAccess; -import com.sun.star.container.XEnumerationAccess; -import com.sun.star.container.XEnumeration; - -import com.sun.star.frame.XComponentLoader; -import com.sun.star.frame.XController; import com.sun.star.frame.XDesktop; -import com.sun.star.frame.XFrame; -import com.sun.star.frame.XModel; -import com.sun.star.frame.XTasksSupplier; -import com.sun.star.frame.XTask; - -import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; -import com.sun.star.drawing.XDrawView; -import com.sun.star.drawing.XDrawPage; -import com.sun.star.drawing.XShape; import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; import com.sun.star.awt.XExtendedToolkit; @@ -66,80 +47,15 @@ public class SimpleOffice getDesktop (); } - public XModel loadDocument (String URL) - { - XModel xModel = null; - try - { - // Load the document from the specified URL. - XComponentLoader xLoader = - UnoRuntime.queryInterface( - XComponentLoader.class, mxDesktop); - XComponent xComponent = xLoader.loadComponentFromURL ( - URL, - "_blank", - 0, - new PropertyValue[0] - ); - xModel = UnoRuntime.queryInterface( - XModel.class, xComponent); - } - catch (NullPointerException e) - { - MessageArea.println ("caught exception while loading " - + URL + " : " + e); - } - catch (Exception e) - { - MessageArea.println ("caught exception while loading " - + URL + " : " + e); - } - return xModel; - } - public XModel getModel (String name) - { - XModel xModel = null; - try - { - XTasksSupplier xTasksSupplier = - UnoRuntime.queryInterface( - XTasksSupplier.class, mxDesktop); - XEnumerationAccess xEA = xTasksSupplier.getTasks(); - XEnumeration xE = xEA.createEnumeration(); - while (xE.hasMoreElements()) - { - XTask xTask = UnoRuntime.queryInterface( - XTask.class, xE.nextElement()); - MessageArea.print (xTask.getName()); - } - } - catch (Exception e) - { - MessageArea.println ("caught exception while getting Model " + name - + ": " + e); - } - return xModel; - } - public XModel getModel (XDrawView xView) - { - XController xController = UnoRuntime.queryInterface( - XController.class, xView); - if (xController != null) - return xController.getModel(); - else - { - MessageArea.println ("can't cast view to controller"); - return null; - } - } + public XDesktop getDesktop () { @@ -218,171 +134,6 @@ public class SimpleOffice return xAccessible; } - /** Return the root object of the accessibility hierarchy. - */ - public XAccessible getAccessibleRoot (XAccessible xAccessible) - { - try - { - XAccessible xParent = null; - do - { - XAccessibleContext xContext = xAccessible.getAccessibleContext(); - if (xContext != null) - xParent = xContext.getAccessibleParent(); - if (xParent != null) - xAccessible = xParent; - } - while (xParent != null); - } - catch (Exception e) - { - MessageArea.println ( - "caught exception while getting accessible root" + e); - e.printStackTrace(); - } - return xAccessible; - } - - - - - /** @descr Return the current window associated with the given - model. - */ - public XWindow getCurrentWindow () - { - return getCurrentWindow (UnoRuntime.queryInterface( - XModel.class, getDesktop())); - } - - - - - - private XWindow getCurrentWindow (XModel xModel) - { - XWindow xWindow = null; - try - { - if (xModel == null) - MessageArea.println ("invalid model (==null)"); - XController xController = xModel.getCurrentController(); - if (xController == null) - MessageArea.println ("can't get controller from model"); - XFrame xFrame = xController.getFrame(); - if (xFrame == null) - MessageArea.println ("can't get frame from controller"); - xWindow = xFrame.getComponentWindow (); - if (xWindow == null) - MessageArea.println ("can't get window from frame"); - } - catch (Exception e) - { - MessageArea.println ("caught exception while getting current window" + e); - } - - return xWindow; - } - - - /** @descr Return the current draw page of the given desktop. - */ - public XDrawPage getCurrentDrawPage () - { - return getCurrentDrawPage (UnoRuntime.queryInterface( - XDrawView.class, getCurrentView())); - } - - - - - private XDrawPage getCurrentDrawPage (XDrawView xView) - { - XDrawPage xPage = null; - try - { - if (xView == null) - MessageArea.println ("can't get current draw page from null view"); - else - xPage = xView.getCurrentPage(); - } - catch (Exception e) - { - MessageArea.println ("caught exception while getting current draw page : " + e); - } - - return xPage; - } - - - /** @descr Return the current view of the given desktop. - */ - private XDrawView getCurrentView () - { - return getCurrentView (getDesktop()); - } - - private XDrawView getCurrentView (XDesktop xDesktop) - { - if (xDesktop == null) - MessageArea.println ("can't get desktop to retrieve current view"); - - XDrawView xView = null; - try - { - XComponent xComponent = xDesktop.getCurrentComponent(); - if (xComponent == null) - MessageArea.println ("can't get component to retrieve current view"); - - XFrame xFrame = xDesktop.getCurrentFrame(); - if (xFrame == null) - MessageArea.println ("can't get frame to retrieve current view"); - - XController xController = xFrame.getController(); - if (xController == null) - MessageArea.println ("can't get controller to retrieve current view"); - - xView = UnoRuntime.queryInterface( - XDrawView.class, xController); - if (xView == null) - MessageArea.println ("could not cast controller into view"); - } - catch (Exception e) - { - MessageArea.println ("caught exception while getting current view : " + e); - } - - return xView; - } - - - - - // Return the accessible object of the document window. - public static XAccessible getAccessibleDocumentWindow (XDrawPage xPage) - { - XIndexAccess xShapeList = UnoRuntime.queryInterface( - XIndexAccess.class, xPage); - if (xShapeList.getCount() > 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 = UnoRuntime.queryInterface( - XShape.class, xShapeList.getByIndex (0)); - } catch (Exception e) - {} - XAccessible xAccessible = UnoRuntime.queryInterface ( - XAccessible.class, xShape); - return xAccessible; - } - else - return null; - } } diff --git a/toolkit/test/accessibility/TextLogger.java b/toolkit/test/accessibility/TextLogger.java deleted file mode 100644 index 952d14015973..000000000000 --- a/toolkit/test/accessibility/TextLogger.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkListener; -import javax.swing.event.HyperlinkEvent; - -class TextLogger - extends JEditorPane -{ - public TextLogger () - throws java.io.IOException - { - super ("http://localhost"); - - setEditable (false); - final JEditorPane finalPane = this; - addHyperlinkListener (new HyperlinkListener() - { - public void hyperlinkUpdate (HyperlinkEvent e) - { - try - { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) - finalPane.setPage (e.getURL()); - } - catch (java.io.IOException ex) - { - ex.printStackTrace(System.err); - } - } - }); - } - - public void appendText (String sText) - { - try - { - getDocument().insertString (getDocument().getLength(), sText, null); - } - catch (javax.swing.text.BadLocationException e) - {} - } -} diff --git a/toolkit/test/accessibility/TextUpdateListener.java b/toolkit/test/accessibility/TextUpdateListener.java deleted file mode 100644 index ef590f1a7106..000000000000 --- a/toolkit/test/accessibility/TextUpdateListener.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -import com.sun.star.accessibility.*; -import com.sun.star.uno.UnoRuntime; - -import javax.swing.tree.*; -import javax.swing.event.*; - -/** listen to tree model changes in order to update XAccessibleText objects -*/ -class TextUpdateListener implements TreeModelListener -{ - public void treeNodesChanged(TreeModelEvent e) - { - try { - // if the change is to the first child of a DefaultMutableTreeNode - // with an XAccessibleText child, then we call updateText - int[] aIndices = e.getChildIndices(); - if (aIndices == null || aIndices.length >= 0) { - return; - } - // we have a parent... lets check for XAccessibleText then - DefaultMutableTreeNode aParent = (DefaultMutableTreeNode) (e - .getTreePath().getLastPathComponent()); - DefaultMutableTreeNode aNode = (DefaultMutableTreeNode) (aParent - .getChildAt(aIndices[0])); - if (aParent.getUserObject() instanceof XAccessibleText) { - // aha! we have an xText. So we can now check for - // the various cases we support - XAccessibleText xText = (XAccessibleText) aParent - .getUserObject(); - - if (aIndices[0] == 0) { - // first child! Then we call updateText - updateText(xText, aNode.toString()); - } - } - } catch (com.sun.star.lang.IndexOutOfBoundsException aException) { - } - } - - // don't care: - public void treeNodesInserted(TreeModelEvent e) { } - public void treeNodesRemoved(TreeModelEvent e) { } - public void treeStructureChanged(TreeModelEvent e) { } - - /** update the text */ - boolean updateText( XAccessibleText xText, String sNew ) - throws com.sun.star.lang.IndexOutOfBoundsException - { - // is this text editable? if not, fudge you and return - XAccessibleEditableText xEdit = - UnoRuntime.queryInterface ( - XAccessibleEditableText.class, xText); - if (xEdit == null) - return false; - - String sOld = xText.getText(); - - // false alarm? Early out if no change was done! - if( sOld.equals( sNew ) ) - return false; - - // get the minimum length of both strings - int nMinLength = sOld.length(); - if( sNew.length() < nMinLength ) - nMinLength = sNew.length(); - - // count equal characters from front and end - int nFront = 0; - while( (nFront < nMinLength) && - (sNew.charAt(nFront) == sOld.charAt(nFront)) ) { - nFront++; - } - int nBack = 0; - while( (nBack < nMinLength) && - ( sNew.charAt(sNew.length()-nBack-1) == - sOld.charAt(sOld.length()-nBack-1) ) ) { - nBack++; - } - if( nFront + nBack > nMinLength ) - nBack = nMinLength - nFront; - - // so... the first nFront and the last nBack characters - // are the same. Change the others! - String sDel = sOld.substring( nFront, sOld.length() - nBack ); - String sIns = sNew.substring( nFront, sNew.length() - nBack ); - - System.out.println("edit text: " + - sOld.substring(0, nFront) + - " [ " + sDel + " -> " + sIns + " ] " + - sOld.substring(sOld.length() - nBack) ); - - boolean bRet = false; - try - { - // edit the text, and use - // (set|insert|delete|replace)Text as needed - if( nFront+nBack == 0 ) - bRet = xEdit.setText( sIns ); - else if( sDel.length() == 0 ) - bRet = xEdit.insertText( sIns, nFront ); - else if( sIns.length() == 0 ) - bRet = xEdit.deleteText( nFront, sOld.length()-nBack ); - else - bRet = xEdit.replaceText(nFront, sOld.length()-nBack,sIns); - } - catch( IndexOutOfBoundsException e ) - { - bRet = false; - } - - return bRet; - } - - boolean setSelection( XAccessibleText xText, int p1, int p2 ) - { - try - { - return xText.setSelection( p1, p2 ); - } - catch( com.sun.star.lang.IndexOutOfBoundsException f ) - { - return false; - } - } - -} diff --git a/toolkit/test/accessibility/ov/SelectionView.java b/toolkit/test/accessibility/ov/SelectionView.java deleted file mode 100644 index 0d84579eb844..000000000000 --- a/toolkit/test/accessibility/ov/SelectionView.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -package ov; - -import java.awt.event.ActionListener; -import java.awt.event.ActionEvent; - -import java.awt.Dimension; -import java.awt.GridBagLayout; -import java.awt.GridBagConstraints; - -import javax.swing.BoxLayout; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JRadioButton; -import javax.swing.JScrollPane; -import javax.swing.JToggleButton; -import com.sun.star.accessibility.AccessibleEventId; -import com.sun.star.accessibility.AccessibleEventObject; -import com.sun.star.accessibility.AccessibleStateType; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.accessibility.XAccessibleSelection; -import com.sun.star.accessibility.XAccessibleStateSet; - -import com.sun.star.uno.UnoRuntime; -import com.sun.star.lang.IndexOutOfBoundsException; - - -/** Display a list of children and select/deselect buttons -*/ -class SelectionView - extends ListeningObjectView - implements ActionListener -{ - static public ObjectView Create ( - ObjectViewContainer aContainer, - XAccessibleContext xContext) - { - XAccessibleSelection xSelection = UnoRuntime.queryInterface( - XAccessibleSelection.class, xContext); - if (xSelection != null) - return new SelectionView(aContainer); - else - return null; - } - - public SelectionView (ObjectViewContainer aContainer) - { - super (aContainer); - Layout(); - } - - @Override - public String GetTitle () - { - return "Selection"; - } - - /** Create and arrange the widgets for this view. - */ - private void Layout () - { - setLayout (new GridBagLayout()); - - GridBagConstraints aConstraints = new GridBagConstraints(); - - // Label that shows wheter the selection is multi selectable. - aConstraints.gridx = 0; - aConstraints.gridy = 0; - aConstraints.anchor = GridBagConstraints.WEST; - maTypeLabel = new JLabel (); - add (maTypeLabel, aConstraints); - - // the JListBox - maChildrenSelector = new JPanel (); - maChildrenSelector.setPreferredSize (new Dimension (100,100)); - maChildrenSelector.setLayout (new BoxLayout (maChildrenSelector, BoxLayout.Y_AXIS)); - - aConstraints.gridx = 0; - aConstraints.gridwidth = 4; - aConstraints.gridy = 1; - aConstraints.fill = GridBagConstraints.HORIZONTAL; - add (new JScrollPane (maChildrenSelector, - JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), - aConstraints); - - JButton aButton; - aButton = new JButton( "Select all" ); - aButton.setActionCommand( "Select all" ); - aButton.addActionListener( this ); - aConstraints.gridx = 0; - aConstraints.gridwidth = 1; - aConstraints.gridy = 2; - aConstraints.fill = GridBagConstraints.NONE; - aConstraints.anchor = GridBagConstraints.WEST; - add (aButton, aConstraints); - - aButton = new JButton( "Clear Selection" ); - aButton.setActionCommand( "Clear Selection" ); - aButton.addActionListener( this ); - aConstraints.gridx = 1; - aConstraints.gridy = 2; - aConstraints.weightx = 1; - add (aButton, aConstraints); - - setSize (getPreferredSize()); - } - - - @Override - public void SetObject (XAccessibleContext xContext) - { - mxSelection = UnoRuntime.queryInterface( - XAccessibleSelection.class, xContext); - super.SetObject (xContext); - } - - - @Override - public void Update () - { - maChildrenSelector.removeAll (); - - // Determine whether multi selection is possible. - XAccessibleStateSet aStateSet = mxContext.getAccessibleStateSet(); - boolean bMultiSelectable = false; - ButtonGroup aButtonGroup = null; - if (aStateSet!=null && aStateSet.contains(AccessibleStateType.MULTI_SELECTABLE)) - { - bMultiSelectable = true; - maTypeLabel.setText ("multi selectable"); - } - else - { - maTypeLabel.setText ("single selectable"); - aButtonGroup = new ButtonGroup (); - } - - int nCount = mxContext.getAccessibleChildCount(); - for (int i=0; i