1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
30 import com
.sun
.star
.awt
.Point
;
31 import com
.sun
.star
.awt
.XTopWindow
;
32 import com
.sun
.star
.awt
.XWindow
;
33 import com
.sun
.star
.text
.XTextDocument
;
34 import com
.sun
.star
.uno
.UnoRuntime
;
36 import com
.sun
.star
.frame
.XModel
;
37 import com
.sun
.star
.uno
.XInterface
;
38 import com
.sun
.star
.accessibility
.XAccessible
;
39 import com
.sun
.star
.accessibility
.XAccessibleAction
;
40 import com
.sun
.star
.accessibility
.AccessibleRole
;
41 import com
.sun
.star
.accessibility
.XAccessibleComponent
;
42 import com
.sun
.star
.awt
.XExtendedToolkit
;
43 import com
.sun
.star
.accessibility
.XAccessibleContext
;
44 import com
.sun
.star
.accessibility
.XAccessibleEditableText
;
45 import com
.sun
.star
.accessibility
.XAccessibleSelection
;
46 import com
.sun
.star
.accessibility
.XAccessibleText
;
47 import com
.sun
.star
.accessibility
.XAccessibleValue
;
48 import com
.sun
.star
.lang
.XMultiServiceFactory
;
49 import java
.awt
.Robot
;
50 import java
.awt
.event
.InputEvent
;
51 import java
.io
.PrintWriter
;
52 import java
.util
.Vector
;
53 import util
.AccessibilityTools
;
57 * This class supports some functions to handle easily accessible objects
59 public class UITools
{
61 private static final AccessibilityTools mAT
= new AccessibilityTools();
62 private final XAccessible mXRoot
;
63 private final XMultiServiceFactory mMSF
;
65 public UITools(XMultiServiceFactory msf
, XModel xModel
)
68 mXRoot
= makeRoot(mMSF
, xModel
);
71 public UITools(XMultiServiceFactory msf
, XTextDocument xTextDoc
)
74 XModel xModel
= (XModel
) UnoRuntime
.queryInterface(XModel
.class, xTextDoc
);
75 mXRoot
= makeRoot(mMSF
, xModel
);
78 public UITools(XMultiServiceFactory msf
, XWindow xWindow
)
81 mXRoot
= makeRoot(xWindow
);
84 private static XAccessible
makeRoot(XMultiServiceFactory msf
, XModel aModel
)
86 XWindow xWindow
= mAT
.getCurrentWindow(msf
, aModel
);
87 return mAT
.getAccessibleObject(xWindow
);
91 private static String
getString(XInterface xInt
)
93 XAccessibleText oText
= (XAccessibleText
)
94 UnoRuntime
.queryInterface(XAccessibleText
.class, xInt
);
95 return oText
.getText();
98 private static void setString(XInterface xInt
, String cText
)
100 XAccessibleEditableText oText
= (XAccessibleEditableText
)
101 UnoRuntime
.queryInterface(XAccessibleEditableText
.class, xInt
);
103 oText
.setText(cText
);
106 private static Object
getValue(XInterface xInt
)
108 XAccessibleValue oValue
= (XAccessibleValue
)
109 UnoRuntime
.queryInterface(XAccessibleValue
.class, xInt
);
110 return oValue
.getCurrentValue();
113 private static XAccessible
makeRoot(XWindow xWindow
)
115 return mAT
.getAccessibleObject(xWindow
);
119 * get the root element of the accessible tree
120 * @return the root element
122 public XAccessible
getRoot()
128 * Helper mathod: set a text into AccessibleEdit field
129 * @param textfiledName is the name of the text field
130 * @param stringToSet is the string to set
131 * @throws java.lang.Exception if something fail
133 public void setTextEditFiledText(String textfiledName
, String stringToSet
)
134 throws java
.lang
.Exception
136 XInterface oTextField
= mAT
.getAccessibleObjectForRole(mXRoot
,
137 AccessibleRole
.TEXT
, textfiledName
);
138 setString(oTextField
, stringToSet
);
142 * returns the button by the given name
143 * @param buttonName is name name of the button to get
144 * @return a XAccessibleContext of the button
145 * @throws java.lang.Exception if something fail
147 public XAccessibleContext
getButton(String buttonName
) throws java
.lang
.Exception
149 return mAT
.getAccessibleObjectForRole
150 (mXRoot
, AccessibleRole
.PUSH_BUTTON
, buttonName
);
154 * Helper method: gets button via accessibility and 'click' it</code>
155 * @param buttonName is name name of the button to click
156 * @throws java.lang.Exception if something fail
159 public void clickButton(String buttonName
) throws java
.lang
.Exception
162 XAccessibleContext oButton
=mAT
.getAccessibleObjectForRole
163 (mXRoot
, AccessibleRole
.PUSH_BUTTON
, buttonName
);
164 if (oButton
== null){
165 throw new Exception("Could not get button '" + buttonName
+ "'");
167 XAccessibleAction oAction
= (XAccessibleAction
)
168 UnoRuntime
.queryInterface(XAccessibleAction
.class, oButton
);
170 // "click" the button
172 oAction
.doAccessibleAction(0);
173 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
174 throw new Exception("Could not do accessible action with '" +
175 buttonName
+ "'" + e
.toString());
182 * Helper method: gets button via accessibility and 'click' it
183 * @param buttonName The name of the button in the accessibility tree
184 * @param toBePressed desired state of the toggle button
186 * @return true if the state of the button could be changed in the desired manner
188 private boolean clickToggleButton(String buttonName
, boolean toBePressed
)
190 XAccessibleContext oButton
=mAT
.getAccessibleObjectForRole
191 (mXRoot
, AccessibleRole
.TOGGLE_BUTTON
, buttonName
);
193 if (oButton
!= null){
194 boolean isChecked
= oButton
.getAccessibleStateSet().contains(com
.sun
.star
.accessibility
.AccessibleStateType
.CHECKED
);
195 if((isChecked
&& !toBePressed
) || (!isChecked
&& toBePressed
)){
196 XAccessibleAction oAction
= (XAccessibleAction
)
197 UnoRuntime
.queryInterface(XAccessibleAction
.class, oButton
);
199 // "click" the button
200 oAction
.doAccessibleAction(0);
202 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
203 System
.out
.println("Could not do accessible action with '"
204 + buttonName
+ "'" + e
.toString());
208 //no need to press togglebar, do nothing
211 System
.out
.println("Could not get button '" + buttonName
+ "'");
217 * Deactivates toggle button via Accessibility
218 * @param buttonName The name of the button in the Accessibility tree
220 * @return true if the button could be set to deactivated
222 public boolean deactivateToggleButton(String buttonName
){
223 return clickToggleButton(buttonName
, false);
227 * Activates toggle button via Accessibility
228 * @param buttonName The name of the button in the Accessibility tree
230 * @return true if the button could be set to activated
232 public boolean activateToggleButton(String buttonName
){
233 return clickToggleButton(buttonName
, true);
237 * returns the value of named radio button
238 * @param buttonName the name of the button to get the value of
239 * @throws java.lang.Exception if something fail
242 public Integer
getRadioButtonValue(String buttonName
)
243 throws java
.lang
.Exception
246 XInterface xRB
=mAT
.getAccessibleObjectForRole(mXRoot
,
247 AccessibleRole
.RADIO_BUTTON
, buttonName
);
249 return (Integer
) getValue(xRB
);
250 } catch (Exception e
) {
251 throw new Exception("Could not get value from RadioButton '"
252 + buttonName
+ "' : " + e
.toString());
257 * returns the named graphic
258 * @param GraphicName the name of the graphic
260 * @throws java.lang.Exception if something fail
262 public XInterface
getGraphic(String GraphicName
) throws java
.lang
.Exception
264 return mAT
.getAccessibleObjectForRole(mXRoot
, AccessibleRole
.GRAPHIC
,
270 * set a named radio button the a given value
271 * @param buttonName the name of the button to set
272 * @param iValue the value to set
273 * @throws java.lang.Exception if something fail
275 public void setRadioButtonValue(String buttonName
, int iValue
)
276 throws java
.lang
.Exception
279 XInterface xRB
=mAT
.getAccessibleObjectForRole(mXRoot
, AccessibleRole
.RADIO_BUTTON
, buttonName
);
281 System
.out
.println("AccessibleObjectForRole couldn't be found for " + buttonName
);
282 XAccessibleValue oValue
= (XAccessibleValue
)
283 UnoRuntime
.queryInterface(XAccessibleValue
.class, xRB
);
285 System
.out
.println("XAccessibleValue couldn't be queried for " + buttonName
);
286 oValue
.setCurrentValue(new Integer(iValue
));
287 } catch (Exception e
) {
290 throw new Exception("Could not set value to RadioButton '"
291 + buttonName
+ "' : " + e
.toString());
297 * select an item in nanmed listbox
298 * @param ListBoxName the name of the listbox
299 * @param nChildIndex the index of the item to set
300 * @throws java.lang.Exception if something fail
302 public void selectListboxItem(String ListBoxName
, int nChildIndex
)
303 throws java
.lang
.Exception
306 XAccessibleContext xListBox
= null;
308 xListBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
309 AccessibleRole
.COMBO_BOX
, ListBoxName
);
310 if (xListBox
== null){
311 xListBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
312 AccessibleRole
.PANEL
, ListBoxName
);
314 XAccessible xListBoxAccess
= (XAccessible
)
315 UnoRuntime
.queryInterface(XAccessible
.class, xListBox
);
317 // if a List is not pulled to be open all entries are not visiblle, therefore the
319 XAccessibleContext xList
=mAT
.getAccessibleObjectForRole(
320 xListBoxAccess
, AccessibleRole
.LIST
, true);
321 XAccessibleSelection xListSelect
= (XAccessibleSelection
)
322 UnoRuntime
.queryInterface(XAccessibleSelection
.class, xList
);
324 xListSelect
.selectAccessibleChild(nChildIndex
);
326 } catch (Exception e
) {
327 throw new Exception("Could not select item '" +nChildIndex
+
328 "' in listbox '" + ListBoxName
+ "' : " + e
.toString());
333 * This method returns all entries as XInterface of a list box
334 * @param ListBoxName the name of the listbox
335 * @return Object[] containing XInterface
336 * @throws java.lang.Exception if something fail
339 public Object
[] getListBoxObjects(String ListBoxName
)
340 throws java
.lang
.Exception
342 Vector Items
= new Vector();
344 XAccessibleContext xListBox
= null;
345 XAccessibleContext xList
= null;
347 xListBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
348 AccessibleRole
.COMBO_BOX
, ListBoxName
);
349 if (xListBox
== null){
350 xListBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
351 AccessibleRole
.PANEL
, ListBoxName
);
354 if (xListBox
== null){
355 // get the list of TreeListBox
356 xList
=mAT
.getAccessibleObjectForRole(mXRoot
,
357 AccessibleRole
.TREE
, ListBoxName
);
359 // all other list boxes have a children of kind of LIST
362 XAccessible xListBoxAccess
= (XAccessible
)
363 UnoRuntime
.queryInterface(XAccessible
.class, xListBox
);
364 // if a List is not pulled to be open all entries are not visiblle, therefore the
366 xList
=mAT
.getAccessibleObjectForRole(
367 xListBoxAccess
, AccessibleRole
.LIST
, true);
370 for (int i
=0;i
<xList
.getAccessibleChildCount();i
++) {
372 XAccessible xChild
= xList
.getAccessibleChild(i
);
373 XAccessibleContext xChildCont
=
374 xChild
.getAccessibleContext();
375 XInterface xChildInterface
= (XInterface
)
376 UnoRuntime
.queryInterface(XInterface
.class, xChildCont
);
377 Items
.add(xChildInterface
);
379 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
380 throw new Exception("Could not get child form list of '"
381 + ListBoxName
+ "' : " + e
.toString());
385 } catch (Exception e
) {
386 throw new Exception("Could not get list of items from '"
387 + ListBoxName
+ "' : " + e
.toString());
389 Object
[]ret
= new XInterface
[Items
.size()];
390 for (int i
=0;i
<Items
.size();i
++){
391 ret
[i
] = Items
.get(i
);
397 * Helper method: returns the entry manes of a List-Box
398 * @param ListBoxName the name of the listbox
399 * @return the listbox entry names
400 * @throws java.lang.Exception if something fail
403 public String
[] getListBoxItems(String ListBoxName
)
404 throws java
.lang
.Exception
406 Vector Items
= new Vector();
408 XAccessibleContext xListBox
= null;
409 XAccessibleContext xList
= null;
411 xListBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
412 AccessibleRole
.COMBO_BOX
, ListBoxName
);
413 if (xListBox
== null){
414 xListBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
415 AccessibleRole
.PANEL
, ListBoxName
);
418 if (xListBox
== null){
419 // get the list of TreeListBox
420 xList
=mAT
.getAccessibleObjectForRole(mXRoot
,
421 AccessibleRole
.TREE
, ListBoxName
);
423 // all other list boxes have a children of kind of LIST
426 XAccessible xListBoxAccess
= (XAccessible
)
427 UnoRuntime
.queryInterface(XAccessible
.class, xListBox
);
428 // if a List is not pulled to be open all entries are not visiblle, therefore the
430 xList
=mAT
.getAccessibleObjectForRole(
431 xListBoxAccess
, AccessibleRole
.LIST
, true);
434 for (int i
=0;i
<xList
.getAccessibleChildCount();i
++) {
436 XAccessible xChild
= xList
.getAccessibleChild(i
);
437 XAccessibleContext xChildCont
=
438 xChild
.getAccessibleContext();
439 XInterface xChildInterface
= (XInterface
)
440 UnoRuntime
.queryInterface(XInterface
.class, xChildCont
);
441 Items
.add(getString(xChildInterface
));
443 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
444 throw new Exception("Could not get child form list of '"
445 + ListBoxName
+ "' : " + e
.toString());
449 } catch (Exception e
) {
450 throw new Exception("Could not get list of items from '"
451 + ListBoxName
+ "' : " + e
.toString());
453 String
[]ret
= new String
[Items
.size()];
454 return (String
[])Items
.toArray(ret
);
457 * set to a named nureric filed a given value
458 * @param NumericFieldName the name of the nureic field
459 * @param cValue the value to set
460 * @throws java.lang.Exception if something fail
462 public void setNumericFieldValue(String NumericFieldName
, String cValue
)
463 throws java
.lang
.Exception
466 XInterface xNumericField
=mAT
.getAccessibleObjectForRole(
467 mXRoot
, AccessibleRole
.TEXT
, NumericFieldName
);
468 //util.dbg.printInterfaces(xNumericField);
469 XAccessibleEditableText oValue
= (XAccessibleEditableText
)
470 UnoRuntime
.queryInterface(
471 XAccessibleEditableText
.class, xNumericField
);
473 setString(xNumericField
, cValue
);
474 } catch (Exception e
) {
475 throw new Exception("Could not set value '" + cValue
+
476 "' into NumericField '" + NumericFieldName
+ "' : " + e
.toString());
481 * returns the value of a numeric field
482 * @param NumericFieldName the name of the numreic field
483 * @throws java.lang.Exception if something fail
484 * @return the value of the named numeric filed
486 public String
getNumericFieldValue(String NumericFieldName
)
487 throws java
.lang
.Exception
490 XInterface xNumericField
=mAT
.getAccessibleObjectForRole(
491 mXRoot
, AccessibleRole
.TEXT
, NumericFieldName
);
492 return (String
) getString(xNumericField
);
494 } catch (Exception e
) {
495 throw new Exception("Could get value from NumericField '"
496 + NumericFieldName
+ "' : " + e
.toString());
500 private String
removeCharactersFromCurrencyString(String stringVal
)
501 throws java
.lang
.Exception
506 boolean startFound
= false;
507 // find the first numeric character in stringVal
508 for(int i
= 0; i
< stringVal
.length(); i
++){
509 int numVal
= Character
.getNumericValue(stringVal
.charAt(i
));
510 // if ascii is a numeric value
516 // find the last numeric character in stringVal
517 for(int i
= stringVal
.length()-1; i
> 0; i
--){
518 int numVal
= Character
.getNumericValue(stringVal
.charAt(i
));
524 String currencyVal
= stringVal
.substring(beginIndex
, endIndex
);
526 currencyVal
= currencyVal
.substring(0, currencyVal
.length()-3) +
527 "#" + currencyVal
.substring(currencyVal
.length()-2);
529 currencyVal
= utils
.replaceAll13(currencyVal
, ",", "");
530 currencyVal
= utils
.replaceAll13(currencyVal
, "\\.", "");
531 currencyVal
= utils
.replaceAll13(currencyVal
, "#", ".");
534 } catch (Exception e
) {
535 throw new Exception("Could get remove characters from currency string '"
536 + stringVal
+ "' : " + e
.toString());
542 * returns the numeric value of a numeric filed. This is needed ie. for
543 * fileds include the moneytary unit.
544 * @param NumericFieldName the name of the numeric filed
545 * @return the value of the numeric filed
546 * @throws java.lang.Exception if something fail
548 public Double
getNumericFieldNumericValue(String NumericFieldName
)
549 throws java
.lang
.Exception
552 Double retValue
= null;
553 String sValue
= getNumericFieldValue(NumericFieldName
);
554 String sAmount
= removeCharactersFromCurrencyString(sValue
);
555 retValue
= retValue
.valueOf(sAmount
);
559 } catch (Exception e
) {
560 throw new Exception("Could get numeric value from NumericField '"
561 + NumericFieldName
+ "' : " + e
.toString());
567 * returns the content of a TextBox
568 * @param TextFieldName the name of the textbox
569 * @return the value of the text box
570 * @throws java.lang.Exception if something fail
572 public String
getTextBoxText(String TextFieldName
)
573 throws java
.lang
.Exception
575 String TextFieldText
= null;
577 XAccessibleContext xTextField
=mAT
.getAccessibleObjectForRole(mXRoot
,
578 AccessibleRole
.SCROLL_PANE
, TextFieldName
);
579 XAccessible xTextFieldAccess
= (XAccessible
)
580 UnoRuntime
.queryInterface(XAccessible
.class, xTextField
);
581 XAccessibleContext xFrame
=mAT
.getAccessibleObjectForRole(
582 xTextFieldAccess
, AccessibleRole
.TEXT_FRAME
);
583 for (int i
=0;i
<xFrame
.getAccessibleChildCount();i
++) {
585 XAccessible xChild
= xFrame
.getAccessibleChild(i
);
586 XAccessibleContext xChildCont
=
587 xChild
.getAccessibleContext();
588 XInterface xChildInterface
= (XInterface
)
589 UnoRuntime
.queryInterface(XInterface
.class, xChildCont
);
590 TextFieldText
+= (getString(xChildInterface
));
592 } catch (com
.sun
.star
.lang
.IndexOutOfBoundsException e
) {
593 throw new Exception("Could not get child fom TextFrame of '"
594 + TextFieldName
+ "' : " + e
.toString());
597 return TextFieldText
;
598 } catch (Exception e
) {
599 throw new Exception("Could not get content fom Textbox '"
600 + TextFieldName
+ "' : " + e
.toString());
605 * set a value to a named check box
606 * @param CheckBoxName the name of the check box
607 * @param Value the value to set
609 * <li>0: not checked </li>
610 * <li>1: checked </li>
611 * <li>2: don't know </li>
613 * @throws java.lang.Exception if something fail
615 public void setCheckBoxValue(String CheckBoxName
, Integer Value
)
616 throws java
.lang
.Exception
619 XInterface xCheckBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
620 AccessibleRole
.CHECK_BOX
, CheckBoxName
);
621 XAccessibleValue xCheckBoxValue
= (XAccessibleValue
)
622 UnoRuntime
.queryInterface(XAccessibleValue
.class, xCheckBox
);
623 xCheckBoxValue
.setCurrentValue(Value
);
625 } catch (Exception e
) {
626 throw new Exception("Could not set value to CheckBox '"
627 + CheckBoxName
+ "' : " + e
.toString());
632 * returns the value of the named check box
633 * @param CheckBoxName the name of the check box
634 * @return the value of the check box
635 * @throws java.lang.Exception if something fail
637 public Integer
getCheckBoxValue(String CheckBoxName
)
638 throws java
.lang
.Exception
641 XInterface xCheckBox
=mAT
.getAccessibleObjectForRole(mXRoot
,
642 AccessibleRole
.CHECK_BOX
, CheckBoxName
);
643 XAccessibleValue xCheckBoxValue
= (XAccessibleValue
)
644 UnoRuntime
.queryInterface(XAccessibleValue
.class, xCheckBox
);
646 return (Integer
) xCheckBoxValue
.getCurrentValue();
647 } catch (Exception e
) {
648 throw new Exception("Could not set value to CheckBox '"
649 + CheckBoxName
+ "' : " + e
.toString());
654 * returns the message of a Basic-MessageBox
655 * @return the message of a Basic-MessageBox
656 * @throws java.lang.Exception if something fail
658 public String
getMsgBoxText()
659 throws java
.lang
.Exception
661 String cMessage
= null;
663 XAccessibleContext xMessage
=mAT
.getAccessibleObjectForRole(mXRoot
,
664 AccessibleRole
.LABEL
);
666 XInterface xMessageInterface
= (XInterface
)
667 UnoRuntime
.queryInterface(XInterface
.class, xMessage
);
668 cMessage
+= (getString(xMessageInterface
));
672 } catch (Exception e
) {
673 throw new Exception("Could not get message from Basic-MessageBox: " + e
.toString());
678 * fetch the window which is equal to the given <CODE>WindowName</CODE>
679 * @return the named window
680 * @throws java.lang.Exception if something fail
682 public XWindow
getTopWindow(String WindowName
, boolean debug
) throws java
.lang
.Exception
684 XInterface xToolKit
= null;
686 xToolKit
= (XInterface
) mMSF
.createInstance("com.sun.star.awt.Toolkit") ;
687 } catch (com
.sun
.star
.uno
.Exception e
) {
688 throw new Exception("Could not toolkit: " + e
.toString());
690 XExtendedToolkit tk
= (XExtendedToolkit
)
691 UnoRuntime
.queryInterface(XExtendedToolkit
.class, xToolKit
);
693 int count
= tk
.getTopWindowCount();
695 XTopWindow retWindow
= null;
697 if (debug
) System
.out
.println("getTopWindow ->");
699 for (int i
=0; i
< count
; i
++){
700 XTopWindow xTopWindow
= tk
.getTopWindow(i
);
701 XAccessible xAcc
= mAT
.getAccessibleObject(xTopWindow
);
702 String accName
= xAcc
.getAccessibleContext().getAccessibleName();
705 System
.out
.println("AccessibleName: " + accName
);
708 if (WindowName
.equals(accName
)){
709 if (debug
) System
.out
.println("-> found window with name '" + WindowName
+ "'");
710 retWindow
= xTopWindow
;
716 if (retWindow
== null) System
.out
.println("could not found window with name '" + WindowName
+ "'");
717 System
.out
.println("<- getTopWindow ");
719 return (XWindow
) UnoRuntime
.queryInterface(XWindow
.class, retWindow
);
722 public void clickMiddleOfAccessibleObject(short role
, String name
){
724 XAccessibleContext xAcc
=mAT
.getAccessibleObjectForRole(mXRoot
, role
, name
);
725 XAccessibleComponent aComp
= (XAccessibleComponent
) UnoRuntime
.queryInterface(
726 XAccessibleComponent
.class, xAcc
);
728 System
.out
.println(xAcc
.getAccessibleRole() + "," +
729 xAcc
.getAccessibleName() + "(" +
730 xAcc
.getAccessibleDescription() + "):" +
731 utils
.getImplName(xAcc
));
734 Point location
= aComp
.getLocationOnScreen();
735 String bounds
= "(" + aComp
.getBounds().X
+ "," +
736 aComp
.getBounds().Y
+ ")" + " (" +
737 aComp
.getBounds().Width
+ "," +
738 aComp
.getBounds().Height
+ ")";
739 System
.out
.println("The boundary Rectangle is " + bounds
);
741 Robot rob
= new Robot();
742 int x
= aComp
.getLocationOnScreen().X
+ (aComp
.getBounds().Width
/ 2);
743 int y
= aComp
.getLocationOnScreen().Y
+ (aComp
.getBounds().Height
/ 2);
744 System
.out
.println("try to click mouse button on x/y " + x
+ "/" + y
);
746 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
747 rob
.mouseRelease(InputEvent
.BUTTON1_MASK
);
748 } catch (java
.awt
.AWTException e
) {
749 System
.out
.println("couldn't press mouse button");
755 public void doubleClickMiddleOfAccessibleObject(short role
, String name
) {
756 XAccessibleContext xAcc
=mAT
.getAccessibleObjectForRole(mXRoot
, role
, name
);
757 XAccessibleComponent aComp
= (XAccessibleComponent
) UnoRuntime
.queryInterface(
758 XAccessibleComponent
.class, xAcc
);
760 System
.out
.println(xAcc
.getAccessibleRole() + "," +
761 xAcc
.getAccessibleName() + "(" +
762 xAcc
.getAccessibleDescription() + "):" +
763 utils
.getImplName(xAcc
));
766 Point location
= aComp
.getLocationOnScreen();
767 String bounds
= "(" + aComp
.getBounds().X
+ "," +
768 aComp
.getBounds().Y
+ ")" + " (" +
769 aComp
.getBounds().Width
+ "," +
770 aComp
.getBounds().Height
+ ")";
771 System
.out
.println("The boundary Rectangle is " + bounds
);
773 Robot rob
= new Robot();
774 int x
= aComp
.getLocationOnScreen().X
+ (aComp
.getBounds().Width
/ 2);
775 int y
= aComp
.getLocationOnScreen().Y
+ (aComp
.getBounds().Height
/ 2);
776 System
.out
.println("try to double click mouse button on x/y " + x
+ "/" + y
);
778 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
779 rob
.mouseRelease(InputEvent
.BUTTON1_MASK
);
780 utils
.shortWait(100);
781 rob
.mousePress(InputEvent
.BUTTON1_MASK
);
782 rob
.mouseRelease(InputEvent
.BUTTON1_MASK
);
783 } catch (java
.awt
.AWTException e
) {
784 System
.out
.println("couldn't press mouse button");
792 * Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE>
793 * this function does not work anymore.
794 * @deprecated Since <CODE>AccessibilityTools</CODE> handle parameter <CODE>debugIsActive</CODE>
795 * this function does not work anymore.
796 * @param log logWriter
798 public void printAccessibleTree(PrintWriter log
)
800 mAT
.printAccessibleTree(log
, mXRoot
);
805 * Prints the accessible tree to the <CODE>logWriter</CODE> only if <CODE>debugIsActive</CODE>
806 * is set to <CODE>true</CODE>
807 * @param log logWriter
808 * @param debugIsActive prints only if this parameter is set to TRUE
810 public void printAccessibleTree(PrintWriter log
, boolean debugIsActive
) {
811 mAT
.printAccessibleTree(log
, mXRoot
, debugIsActive
);