2003-01-27 09:27:53 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 01:34:41 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
2008-04-10 01:34:41 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
2008-04-10 01:34:41 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
2008-04-10 01:34:41 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
2008-04-10 01:34:41 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
2008-04-10 01:34:41 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2003-01-27 09:27:53 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
package util;
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
import com.sun.star.accessibility.XAccessible;
|
|
|
|
import com.sun.star.accessibility.XAccessibleComponent;
|
|
|
|
import com.sun.star.accessibility.XAccessibleContext;
|
2003-01-27 09:27:53 -06:00
|
|
|
import com.sun.star.awt.XWindow;
|
|
|
|
import com.sun.star.frame.XController;
|
|
|
|
import com.sun.star.frame.XFrame;
|
|
|
|
import com.sun.star.frame.XModel;
|
|
|
|
import com.sun.star.lang.XMultiServiceFactory;
|
2004-03-19 08:56:28 -06:00
|
|
|
import com.sun.star.uno.UnoRuntime;
|
|
|
|
import com.sun.star.uno.XInterface;
|
|
|
|
|
|
|
|
import java.io.PrintWriter;
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
|
|
|
|
public class AccessibilityTools {
|
2004-03-19 08:56:28 -06:00
|
|
|
public static XAccessibleContext SearchedContext = null;
|
|
|
|
public static XAccessible SearchedAccessible = null;
|
2004-11-02 04:47:31 -06:00
|
|
|
private static boolean debug = false;
|
2003-01-27 09:27:53 -06:00
|
|
|
|
|
|
|
public AccessibilityTools() {
|
|
|
|
//done = false;
|
|
|
|
SearchedContext = null;
|
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
public static XAccessible getAccessibleObject(XInterface xObject) {
|
2010-02-24 04:08:28 -06:00
|
|
|
return UnoRuntime.queryInterface(XAccessible.class, xObject);
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
|
|
|
|
2004-07-23 04:43:42 -05:00
|
|
|
public static XWindow getCurrentContainerWindow(XMultiServiceFactory msf,
|
2007-06-04 07:31:30 -05:00
|
|
|
XModel xModel) {
|
2004-07-23 04:43:42 -05:00
|
|
|
return getWindow(msf, xModel, true);
|
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
public static XWindow getCurrentWindow(XMultiServiceFactory msf,
|
2007-06-04 07:31:30 -05:00
|
|
|
XModel xModel) {
|
2004-07-23 04:43:42 -05:00
|
|
|
return getWindow(msf, xModel, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static XWindow getWindow(XMultiServiceFactory msf, XModel xModel,
|
2007-06-04 07:31:30 -05:00
|
|
|
boolean containerWindow) {
|
2003-01-27 09:27:53 -06:00
|
|
|
XWindow xWindow = null;
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
try {
|
|
|
|
if (xModel == null) {
|
|
|
|
System.out.println("invalid model (==null)");
|
|
|
|
}
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
XController xController = xModel.getCurrentController();
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (xController == null) {
|
|
|
|
System.out.println("can't get controller from model");
|
|
|
|
}
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
XFrame xFrame = xController.getFrame();
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (xFrame == null) {
|
|
|
|
System.out.println("can't get frame from controller");
|
|
|
|
}
|
|
|
|
|
2004-07-23 04:43:42 -05:00
|
|
|
if (containerWindow)
|
|
|
|
xWindow = xFrame.getContainerWindow();
|
|
|
|
else
|
|
|
|
xWindow = xFrame.getComponentWindow();
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (xWindow == null) {
|
|
|
|
System.out.println("can't get window from frame");
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
System.out.println("caught exception while getting current window" + e);
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return xWindow;
|
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role) {
|
2004-03-19 08:56:28 -06:00
|
|
|
SearchedContext = null;
|
|
|
|
SearchedAccessible = null;
|
|
|
|
getAccessibleObjectForRole_(xacc, role);
|
|
|
|
|
|
|
|
return SearchedContext;
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role,
|
|
|
|
boolean ignoreShowing) {
|
2003-01-27 09:27:53 -06:00
|
|
|
SearchedContext = null;
|
|
|
|
SearchedAccessible = null;
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (ignoreShowing) {
|
|
|
|
getAccessibleObjectForRoleIgnoreShowing_(xacc, role);
|
|
|
|
} else {
|
|
|
|
getAccessibleObjectForRole_(xacc, role);
|
|
|
|
}
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
return SearchedContext;
|
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
public static void getAccessibleObjectForRoleIgnoreShowing_(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role) {
|
2004-03-19 08:56:28 -06:00
|
|
|
XAccessibleContext ac = xacc.getAccessibleContext();
|
|
|
|
|
|
|
|
if (ac.getAccessibleRole() == role) {
|
|
|
|
SearchedContext = ac;
|
|
|
|
SearchedAccessible = xacc;
|
|
|
|
} else {
|
|
|
|
int k = ac.getAccessibleChildCount();
|
|
|
|
|
|
|
|
if (ac.getAccessibleChildCount() > 100) {
|
|
|
|
k = 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < k; i++) {
|
|
|
|
try {
|
|
|
|
getAccessibleObjectForRoleIgnoreShowing_(
|
2007-06-04 07:31:30 -05:00
|
|
|
ac.getAccessibleChild(i), role);
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (SearchedContext != null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't get Child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void getAccessibleObjectForRole_(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role) {
|
2003-01-27 09:27:53 -06:00
|
|
|
XAccessibleContext ac = xacc.getAccessibleContext();
|
2004-03-19 08:56:28 -06:00
|
|
|
boolean isShowing = ac.getAccessibleStateSet()
|
2007-06-04 07:31:30 -05:00
|
|
|
.contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if ((ac.getAccessibleRole() == role) && isShowing) {
|
2003-01-27 09:27:53 -06:00
|
|
|
SearchedContext = ac;
|
|
|
|
SearchedAccessible = xacc;
|
|
|
|
} else {
|
|
|
|
int k = ac.getAccessibleChildCount();
|
2004-03-19 08:56:28 -06:00
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
if (ac.getAccessibleChildCount() > 100) {
|
2004-03-19 08:56:28 -06:00
|
|
|
k = 50;
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
for (int i = 0; i < k; i++) {
|
2003-01-27 09:27:53 -06:00
|
|
|
try {
|
2004-03-19 08:56:28 -06:00
|
|
|
getAccessibleObjectForRole_(ac.getAccessibleChild(i), role);
|
|
|
|
|
|
|
|
if (SearchedContext != null) {
|
|
|
|
return;
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't get Child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role,
|
|
|
|
String name) {
|
2003-01-27 09:27:53 -06:00
|
|
|
return getAccessibleObjectForRole(xacc, role, name, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role,
|
|
|
|
String name,
|
|
|
|
boolean ignoreShowing) {
|
2004-03-19 08:56:28 -06:00
|
|
|
if (ignoreShowing) {
|
|
|
|
return getAccessibleObjectForRoleIgnoreShowing(xacc, role, name,
|
2007-06-04 07:31:30 -05:00
|
|
|
"");
|
2004-03-19 08:56:28 -06:00
|
|
|
} else {
|
|
|
|
return getAccessibleObjectForRole(xacc, role, name, "");
|
|
|
|
}
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
public static XAccessibleContext getAccessibleObjectForRoleIgnoreShowing(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role,
|
|
|
|
String name,
|
|
|
|
String implName) {
|
2003-01-27 09:27:53 -06:00
|
|
|
XAccessibleContext ac = xacc.getAccessibleContext();
|
2004-03-19 08:56:28 -06:00
|
|
|
if ((ac.getAccessibleRole() == role) &&
|
2007-06-04 07:31:30 -05:00
|
|
|
(ac.getAccessibleName().indexOf(name) > -1) &&
|
|
|
|
(utils.getImplName(ac).indexOf(implName) > -1)) {
|
2003-01-27 09:27:53 -06:00
|
|
|
SearchedAccessible = xacc;
|
2004-03-19 08:56:28 -06:00
|
|
|
|
2004-02-04 04:23:24 -06:00
|
|
|
//System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
|
2003-01-27 09:27:53 -06:00
|
|
|
return ac;
|
|
|
|
} else {
|
|
|
|
int k = ac.getAccessibleChildCount();
|
2004-03-19 08:56:28 -06:00
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
if (ac.getAccessibleChildCount() > 100) {
|
2004-03-19 08:56:28 -06:00
|
|
|
k = 50;
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
for (int i = 0; i < k; i++) {
|
2003-01-27 09:27:53 -06:00
|
|
|
try {
|
2004-03-19 08:56:28 -06:00
|
|
|
XAccessibleContext ac1 = getAccessibleObjectForRoleIgnoreShowing(
|
2007-06-04 07:31:30 -05:00
|
|
|
ac.getAccessibleChild(i),
|
|
|
|
role, name, implName);
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (ac1 != null) {
|
|
|
|
return ac1;
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't get Child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc,
|
2007-06-04 07:31:30 -05:00
|
|
|
short role,
|
|
|
|
String name,
|
|
|
|
String implName) {
|
2004-03-19 08:56:28 -06:00
|
|
|
XAccessibleContext ac = xacc.getAccessibleContext();
|
|
|
|
boolean isShowing = ac.getAccessibleStateSet()
|
2007-06-04 07:31:30 -05:00
|
|
|
.contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
|
2008-09-30 02:44:27 -05:00
|
|
|
|
|
|
|
// hotfix for i91828:
|
|
|
|
// if role to serach is 0 then ignore the role.
|
|
|
|
if ( (role == 0 || ac.getAccessibleRole() == role) &&
|
2007-06-04 07:31:30 -05:00
|
|
|
(ac.getAccessibleName().indexOf(name) > -1) &&
|
|
|
|
(utils.getImplName(ac).indexOf(implName) > -1) &&
|
|
|
|
isShowing) {
|
2004-03-19 08:56:28 -06:00
|
|
|
SearchedAccessible = xacc;
|
|
|
|
//System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing);
|
|
|
|
return ac;
|
|
|
|
} else {
|
|
|
|
int k = ac.getAccessibleChildCount();
|
|
|
|
|
|
|
|
if (ac.getAccessibleChildCount() > 100) {
|
|
|
|
k = 50;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < k; i++) {
|
|
|
|
try {
|
|
|
|
XAccessibleContext ac1 = getAccessibleObjectForRole(
|
2007-06-04 07:31:30 -05:00
|
|
|
ac.getAccessibleChild(i),
|
|
|
|
role, name, implName);
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (ac1 != null) {
|
|
|
|
return ac1;
|
|
|
|
}
|
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't get Child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
|
|
|
|
2007-06-04 07:31:30 -05:00
|
|
|
/**
|
|
|
|
* This methods retunrs the <CODE>XAccessibleContext</CODE> of a named Sheet-Cell like "G5".<p>
|
|
|
|
* @param xSheetAcc The <CODE>XAccessibleContext</CODE> of a Sheet
|
|
|
|
* @param cellName The name of a cell like "A5"
|
|
|
|
* @return the <CODE>XAccessiblecontext</CODE> of the named cell
|
|
|
|
*/
|
|
|
|
public static XAccessibleContext getSheetCell(XAccessibleContext xSheetAcc, String cellName){
|
|
|
|
|
|
|
|
int cellIndex = 0;
|
|
|
|
int column =0;
|
|
|
|
int charMem = 0;
|
|
|
|
for (int n=0; n<cellName.length(); n++){
|
|
|
|
String cha = cellName.substring(n,n+1);
|
|
|
|
System.out.println("char: " + cha + " ");
|
|
|
|
|
|
|
|
byte[] bytes = cha.getBytes();
|
|
|
|
|
|
|
|
if ((bytes[0] >= 'A') && (bytes[0] <= 'Z')){
|
|
|
|
charMem = bytes[0]-64;
|
|
|
|
column++;
|
|
|
|
if ( column == 2 ){
|
|
|
|
cellIndex += charMem * 26;
|
|
|
|
}
|
|
|
|
cellIndex= cellIndex+ (bytes[0]-65);
|
|
|
|
} else {
|
|
|
|
String sNumb = cellName.substring(n, cellName.length());
|
|
|
|
int iNumb = new Integer(0).valueOf(sNumb).intValue();
|
|
|
|
cellIndex += (iNumb-1) * 256;
|
|
|
|
System.out.println("numb:" + (iNumb-1) * 256);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//System.out.println("cellName: " + cellName + " cellIndex: " + cellIndex);
|
|
|
|
|
|
|
|
try {
|
|
|
|
XAccessibleContext ac = xSheetAcc.getAccessibleChild(cellIndex).getAccessibleContext();
|
|
|
|
System.out.println(ac.getAccessibleRole() + "," +
|
|
|
|
ac.getAccessibleName() + "(" +
|
|
|
|
ac.getAccessibleDescription() + "):" +
|
|
|
|
utils.getImplName(ac));
|
|
|
|
|
|
|
|
return ac;
|
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException ex) {
|
|
|
|
System.out.println("ERROR: could not get child at index " + cellIndex +"': " + ex.toString());
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-02 04:47:31 -06:00
|
|
|
public static void printAccessibleTree(PrintWriter log, XAccessible xacc, boolean debugIsActive) {
|
|
|
|
debug = debugIsActive;
|
2005-02-24 10:22:34 -06:00
|
|
|
if (debug) printAccessibleTree(log, xacc, "");
|
2004-11-02 04:47:31 -06:00
|
|
|
}
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
public static void printAccessibleTree(PrintWriter log, XAccessible xacc) {
|
|
|
|
printAccessibleTree(log, xacc, "");
|
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
protected static void printAccessibleTree(PrintWriter log,
|
2007-06-04 07:31:30 -05:00
|
|
|
XAccessible xacc, String indent) {
|
2005-02-24 10:22:34 -06:00
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
XAccessibleContext ac = xacc.getAccessibleContext();
|
|
|
|
|
2004-11-02 04:47:31 -06:00
|
|
|
logging(log,indent + ac.getAccessibleRole() + "," +
|
2007-06-04 07:31:30 -05:00
|
|
|
ac.getAccessibleName() + "(" +
|
|
|
|
ac.getAccessibleDescription() + "):" +
|
|
|
|
utils.getImplName(ac));
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
XAccessibleComponent aComp = (XAccessibleComponent) UnoRuntime.queryInterface(
|
2007-06-04 07:31:30 -05:00
|
|
|
XAccessibleComponent.class, xacc);
|
2003-01-27 09:27:53 -06:00
|
|
|
|
2003-02-21 01:27:34 -06:00
|
|
|
if (aComp != null) {
|
2004-03-19 08:56:28 -06:00
|
|
|
String bounds = "(" + aComp.getBounds().X + "," +
|
2007-06-04 07:31:30 -05:00
|
|
|
aComp.getBounds().Y + ")" + " (" +
|
|
|
|
aComp.getBounds().Width + "," +
|
|
|
|
aComp.getBounds().Height + ")";
|
2004-03-19 08:56:28 -06:00
|
|
|
bounds = "The boundary Rectangle is " + bounds;
|
2004-11-02 04:47:31 -06:00
|
|
|
logging(log,indent + indent + bounds);
|
2003-02-21 01:27:34 -06:00
|
|
|
}
|
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
boolean isShowing = ac.getAccessibleStateSet()
|
2007-06-04 07:31:30 -05:00
|
|
|
.contains(com.sun.star.accessibility.AccessibleStateType.SHOWING);
|
2004-11-02 04:47:31 -06:00
|
|
|
logging(log,indent + indent + "StateType contains SHOWING: " +
|
2007-06-04 07:31:30 -05:00
|
|
|
isShowing);
|
2003-02-21 01:27:34 -06:00
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
int k = ac.getAccessibleChildCount();
|
|
|
|
|
|
|
|
if (ac.getAccessibleChildCount() > 100) {
|
2004-03-19 08:56:28 -06:00
|
|
|
k = 50;
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
for (int i = 0; i < k; i++) {
|
2003-01-27 09:27:53 -06:00
|
|
|
try {
|
2004-03-19 08:56:28 -06:00
|
|
|
printAccessibleTree(log, ac.getAccessibleChild(i),
|
2007-06-04 07:31:30 -05:00
|
|
|
indent + " ");
|
2003-01-27 09:27:53 -06:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't get Child");
|
|
|
|
}
|
|
|
|
}
|
2004-03-19 08:56:28 -06:00
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
if (ac.getAccessibleChildCount() > 100) {
|
2004-03-19 08:56:28 -06:00
|
|
|
k = ac.getAccessibleChildCount();
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
int st = ac.getAccessibleChildCount() - 50;
|
2004-11-02 04:47:31 -06:00
|
|
|
logging(log,indent + " " + " ...... [skipped] ......");
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
for (int i = st; i < k; i++) {
|
2003-01-27 09:27:53 -06:00
|
|
|
try {
|
2004-03-19 08:56:28 -06:00
|
|
|
printAccessibleTree(log, ac.getAccessibleChild(i),
|
2007-06-04 07:31:30 -05:00
|
|
|
indent + " ");
|
2003-01-27 09:27:53 -06:00
|
|
|
} catch (com.sun.star.lang.IndexOutOfBoundsException e) {
|
|
|
|
System.out.println("Couldn't get Child");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String accessibleToString(Object AC) {
|
2004-03-19 08:56:28 -06:00
|
|
|
XAccessibleContext xAC = (XAccessibleContext) UnoRuntime.queryInterface(
|
2007-06-04 07:31:30 -05:00
|
|
|
XAccessibleContext.class, AC);
|
2004-03-19 08:56:28 -06:00
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
if (xAC != null) {
|
2004-03-19 08:56:28 -06:00
|
|
|
return "" + xAC.getAccessibleRole() + "," +
|
2007-06-04 07:31:30 -05:00
|
|
|
xAC.getAccessibleName() + "(" +
|
|
|
|
xAC.getAccessibleDescription() + "):";
|
2004-03-19 08:56:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
XAccessible xA = (XAccessible) UnoRuntime.queryInterface(
|
2007-06-04 07:31:30 -05:00
|
|
|
XAccessible.class, AC);
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
if (xA == null) {
|
|
|
|
return "(Not supported)";
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
xAC = xA.getAccessibleContext();
|
2004-03-19 08:56:28 -06:00
|
|
|
|
|
|
|
return "" + xAC.getAccessibleRole() + "," + xAC.getAccessibleName() +
|
2007-06-04 07:31:30 -05:00
|
|
|
"(" + xAC.getAccessibleDescription() + ")";
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean equals(XAccessible c1, XAccessible c2) {
|
2004-03-19 08:56:28 -06:00
|
|
|
if ((c1 == null) || (c2 == null)) {
|
|
|
|
return c1 == c2;
|
|
|
|
}
|
|
|
|
|
2003-01-27 09:27:53 -06:00
|
|
|
return AccessibilityTools.equals(c1.getAccessibleContext(),
|
2007-06-04 07:31:30 -05:00
|
|
|
c2.getAccessibleContext());
|
2003-01-27 09:27:53 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean equals(XAccessibleContext c1, XAccessibleContext c2) {
|
2004-03-19 08:56:28 -06:00
|
|
|
if ((c1 == null) || (c2 == null)) {
|
|
|
|
return c1 == c2;
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
if (c1.getAccessibleRole() != c2.getAccessibleRole()) {
|
|
|
|
return false;
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
if (!c1.getAccessibleName().equals(c2.getAccessibleName())) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!c1.getAccessibleDescription()
|
2007-06-04 07:31:30 -05:00
|
|
|
.equals(c2.getAccessibleDescription())) {
|
2004-03-19 08:56:28 -06:00
|
|
|
return false;
|
|
|
|
}
|
2003-01-27 09:27:53 -06:00
|
|
|
|
2004-03-19 08:56:28 -06:00
|
|
|
if (c1.getAccessibleChildCount() != c2.getAccessibleChildCount()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return AccessibilityTools.equals(c1.getAccessibleParent(),
|
2007-06-04 07:31:30 -05:00
|
|
|
c2.getAccessibleParent());
|
2004-03-19 08:56:28 -06:00
|
|
|
}
|
2004-11-02 04:47:31 -06:00
|
|
|
|
2007-06-04 07:31:30 -05:00
|
|
|
private static void logging(PrintWriter log, String content){
|
|
|
|
if (debug) log.println(content);
|
|
|
|
}
|
2003-04-28 06:31:17 -05:00
|
|
|
}
|