diff options
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r-- | qadevOOo/runner/util/AccessibilityTools.java | 100 |
1 files changed, 14 insertions, 86 deletions
diff --git a/qadevOOo/runner/util/AccessibilityTools.java b/qadevOOo/runner/util/AccessibilityTools.java index c7cb483674c9..85cd442a3b84 100644 --- a/qadevOOo/runner/util/AccessibilityTools.java +++ b/qadevOOo/runner/util/AccessibilityTools.java @@ -17,7 +17,6 @@ */ package util; -import com.sun.star.accessibility.AccessibleStateType; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleComponent; import com.sun.star.accessibility.XAccessibleContext; @@ -33,7 +32,7 @@ import java.io.PrintWriter; public class AccessibilityTools { - private XAccessible SearchedAccessible = null; + public static XAccessible SearchedAccessible = null; private static boolean debug = false; public AccessibilityTools() { @@ -92,12 +91,15 @@ public class AccessibilityTools { public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc, short role) { + SearchedAccessible = null; return getAccessibleObjectForRole_(xacc, role); } public static XAccessibleContext getAccessibleObjectForRole(XAccessible xacc, short role, boolean ignoreShowing) { + SearchedAccessible = null; + if (ignoreShowing) { return getAccessibleObjectForRoleIgnoreShowing_(xacc, role); } else { @@ -105,49 +107,12 @@ public class AccessibilityTools { } } - public XAccessible getSearchedAccessibleObjectForRole(XAccessible xacc, - short role, - boolean ignoreShowing) { - SearchedAccessible = null; - getSearchedAccessibleObjectForRole_(xacc, role, ignoreShowing); - return SearchedAccessible; - } - - private XAccessibleContext getSearchedAccessibleObjectForRole_(XAccessible xacc, - short role, boolean ignoreShowing) { - XAccessibleContext ac = xacc.getAccessibleContext(); - boolean isShowing = isShowing(ac); - - if ((ac.getAccessibleRole() == role) && (!ignoreShowing || isShowing)) { - SearchedAccessible = xacc; - return ac; - } else { - int k = ac.getAccessibleChildCount(); - - if (ac.getAccessibleChildCount() > 100) { - k = 50; - } - - for (int i = 0; i < k; i++) { - try { - XAccessibleContext ac2 = getSearchedAccessibleObjectForRole_(ac.getAccessibleChild(i), role, ignoreShowing); - - if (ac2 != null) { - return ac2; - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.out.println("Couldn't get Child"); - } - } - return null; - } - } - public static XAccessibleContext getAccessibleObjectForRoleIgnoreShowing_(XAccessible xacc, short role) { XAccessibleContext ac = xacc.getAccessibleContext(); if (ac.getAccessibleRole() == role) { + SearchedAccessible = xacc; return ac; } else { int k = ac.getAccessibleChildCount(); @@ -175,9 +140,11 @@ public class AccessibilityTools { public static XAccessibleContext getAccessibleObjectForRole_(XAccessible xacc, short role) { XAccessibleContext ac = xacc.getAccessibleContext(); - boolean isShowing = isShowing(ac); + boolean isShowing = ac.getAccessibleStateSet() + .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING); if ((ac.getAccessibleRole() == role) && isShowing) { + SearchedAccessible = xacc; return ac; } else { int k = ac.getAccessibleChildCount(); @@ -227,6 +194,7 @@ public class AccessibilityTools { if ((ac.getAccessibleRole() == role) && (ac.getAccessibleName().indexOf(name) > -1) && (utils.getImplName(ac).indexOf(implName) > -1)) { + SearchedAccessible = xacc; //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing); return ac; @@ -260,7 +228,8 @@ public class AccessibilityTools { String name, String implName) { XAccessibleContext ac = xacc.getAccessibleContext(); - boolean isShowing = isShowing(ac); + boolean isShowing = ac.getAccessibleStateSet() + .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING); // hotfix for i91828: // if role to search is 0 then ignore the role. @@ -268,6 +237,7 @@ public class AccessibilityTools { (ac.getAccessibleName().indexOf(name) > -1) && (utils.getImplName(ac).indexOf(implName) > -1) && isShowing) { + SearchedAccessible = xacc; //System.out.println("FOUND the desired component -- "+ ac.getAccessibleName() +isShowing); return ac; } else { @@ -295,45 +265,6 @@ public class AccessibilityTools { return null; } - public XAccessible getSearchedAccessibleObjectForRole(XAccessible xacc, - short role, - String name, - String implName) { - XAccessibleContext ac = xacc.getAccessibleContext(); - boolean isShowing = isShowing(ac); - - // hotfix for i91828: - // if role to search is 0 then ignore the role. - if ( (role == 0 || ac.getAccessibleRole() == role) && - (ac.getAccessibleName().indexOf(name) > -1) && - (utils.getImplName(ac).indexOf(implName) > -1) && - isShowing) { - SearchedAccessible = xacc; - } else { - int k = ac.getAccessibleChildCount(); - - if (ac.getAccessibleChildCount() > 100) { - k = 50; - } - - for (int i = 0; i < k; i++) { - try { - XAccessibleContext ac1 = getAccessibleObjectForRole( - ac.getAccessibleChild(i), - role, name, implName); - - if (ac1 != null) { - break; - } - } catch (com.sun.star.lang.IndexOutOfBoundsException e) { - System.out.println("Couldn't get Child"); - } - } - } - - return SearchedAccessible; - } - /** * This methods retunrs the <CODE>XAccessibleContext</CODE> of a named Sheet-Cell like "G5".<p> * @param xSheetAcc The <CODE>XAccessibleContext</CODE> of a Sheet @@ -414,7 +345,8 @@ public class AccessibilityTools { logging(log,indent + indent + bounds); } - boolean isShowing = isShowing(ac); + boolean isShowing = ac.getAccessibleStateSet() + .contains(com.sun.star.accessibility.AccessibleStateType.SHOWING); logging(log,indent + indent + "StateType contains SHOWING: " + isShowing); @@ -511,8 +443,4 @@ public class AccessibilityTools { private static void logging(PrintWriter log, String content){ if (debug) log.println(content); } - - private static boolean isShowing(XAccessibleContext ac) { - return ac.getAccessibleStateSet().contains(AccessibleStateType.SHOWING); - } }
\ No newline at end of file |