/** Disposes Writer document. */
  protected void cleanup(TestParameters tParam, PrintWriter log) {
    // closing the appearing dialog before disposing the document
    XInterface toolkit = null;

    try {
      toolkit =
          (XInterface)
              ((XMultiServiceFactory) tParam.getMSF()).createInstance("com.sun.star.awt.Toolkit");
    } catch (com.sun.star.uno.Exception e) {
      log.println("Couldn't get toolkit");
      e.printStackTrace(log);
      throw new StatusException("Couldn't get toolkit", e);
    }

    XExtendedToolkit tk = UnoRuntime.queryInterface(XExtendedToolkit.class, toolkit);

    Object atw = tk.getActiveTopWindow();

    XWindow xWindow = UnoRuntime.queryInterface(XWindow.class, atw);

    XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);

    XInterface button =
        AccessibilityTools.getAccessibleObjectForRole(xRoot, AccessibleRole.PUSH_BUTTON);

    XAccessibleAction action = UnoRuntime.queryInterface(XAccessibleAction.class, button);

    try {
      action.doAccessibleAction(0);
    } catch (com.sun.star.lang.IndexOutOfBoundsException iob) {
      log.println("couldn't close dialog");
    } catch (com.sun.star.lang.DisposedException e) {
      log.println("couldn't close dialog");
    }

    log.println("    disposing xTextDoc ");

    try {
      XCloseable closer = UnoRuntime.queryInterface(XCloseable.class, xTextDoc);
      closer.close(true);
    } catch (com.sun.star.util.CloseVetoException e) {
      log.println("couldn't close document");
    } catch (com.sun.star.lang.DisposedException e) {
      log.println("couldn't close document");
    }
  }
Esempio n. 2
0
  protected void actionPerformImpl(GComponent gComponent) {

    XAccessible xAccessible = getAccessible(gComponent);

    XAccessibleContext xAccessibleContext = xAccessible.getAccessibleContext();
    if (xAccessibleContext == null) return;

    XAccessibleAction xAction =
        (XAccessibleAction) UnoRuntime.queryInterface(XAccessibleAction.class, xAccessibleContext);

    if (xAction == null) return;
    try {
      int nActions = xAction.getAccessibleActionCount();
      for (int j = 0; j < nActions; j++) {
        xAction.doAccessibleAction(j);
      }
    } catch (IndexOutOfBoundsException e) {
      System.err.println("Cannot click");
      e.printStackTrace();
    }
  }