Exemplo n.º 1
0
  private void saveDoc(XInterface xDoc, String sURL) {
    m_aLog.log(Protocol.TYPE_SCOPE_OPEN, "saveDoc('" + sURL + "') started ...");
    try {
      URL[] aURL = new URL[1];
      aURL[0] = new URL();
      aURL[0].Complete = ".uno:SaveAs";
      m_xURLParser.parseStrict(aURL);

      XModel xModel = UnoRuntime.queryInterface(XModel.class, xDoc);
      XDispatchProvider xProvider =
          UnoRuntime.queryInterface(XDispatchProvider.class, xModel.getCurrentController());
      XDispatch xDispatch = xProvider.queryDispatch(aURL[0], "_self", 0);

      PropertyValue[] lArgs = new PropertyValue[3];
      lArgs[0] = new PropertyValue();
      lArgs[0].Name = "URL";
      lArgs[0].Value = sURL;
      lArgs[1] = new PropertyValue();
      lArgs[1].Name = "Overwrite";
      lArgs[1].Value = Boolean.TRUE;
      lArgs[2] = new PropertyValue();
      lArgs[2].Name = "StoreTo";
      lArgs[2].Value = Boolean.TRUE;

      xDispatch.dispatch(aURL[0], lArgs);

      m_aLog.log(Protocol.TYPE_OK, "saveDoc('" + sURL + "') = OK.");
    } catch (Throwable ex) {
      m_aLog.log(ex);
    }
    m_aLog.log(Protocol.TYPE_SCOPE_CLOSE, "saveDoc('" + sURL + "') finished.");
  }
Exemplo n.º 2
0
 private XDispatch getXDispatcher(com.sun.star.util.URL oURL) {
   try {
     com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1];
     oURLArray[0] = oURL;
     XDispatchProvider xDispatchProvider =
         UnoRuntime.queryInterface(XDispatchProvider.class, getCurrentFrame());
     XDispatch xDispatch =
         xDispatchProvider.queryDispatch(oURLArray[0], "_top", FrameSearchFlag.ALL); // "_self"
     return xDispatch;
   } catch (Exception e) {
     e.printStackTrace(System.err);
     return null;
   }
 }
Exemplo n.º 3
0
  /**
   * Implementation of interface XDispatchProvider These functions are called from our master if he
   * willn't handle the outstanding request. Given parameter should be checked if they are right for
   * us. If it's true, the returned dispatcher should be this implementation himself; otherwise call
   * should be forwarded to the slave.
   *
   * @param aURL describes the request, which should be handled
   * @param sTarget specifies the target frame for this request
   * @param nSearchFlags optional search flags, if sTarget isn't a special one
   * @return [XDispatch] a dispatch object, which can handle the given URL May be NULL!
   */
  public com.sun.star.frame.XDispatch queryDispatch(
      /*IN*/ com.sun.star.util.URL aURL, /*IN*/ String sTarget, /*IN*/ int nSearchFlags) {
    synchronized (this) {
      if (m_bDead) return null;
    }

    // intercept loading empty documents into new created frames
    if ((sTarget.compareTo("_blank") == 0) && (aURL.Complete.startsWith("private:factory"))) {
      System.out.println("intercept private:factory");
      return this;
    }

    // intercept opening the SaveAs dialog
    if (aURL.Complete.startsWith(".uno:SaveAs")) {
      System.out.println("intercept SaveAs by returning null!");
      return null;
    }

    // intercept "File->Exit" inside the menu
    if ((aURL.Complete.startsWith("slot:5300")) || (aURL.Complete.startsWith(".uno:Quit"))) {
      System.out.println("intercept File->Exit");
      return this;
    }

    synchronized (this) {
      if (m_xSlave != null) return m_xSlave.queryDispatch(aURL, sTarget, nSearchFlags);
    }

    return null;
  }
Exemplo n.º 4
0
  public static void dispatchCommand(String command) throws java.lang.Exception {

    com.sun.star.frame.XFrame xFrame = SpeechOO.m_xFrame.getController().getFrame();
    lParams[0] = new com.sun.star.beans.PropertyValue();
    lParams[0].Name = "nodepath";
    lParams[0].Value = "/org.openoffice.Office.Commands/Execute/Disabled";
    xRemoteContext =
        (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, SpeechOO.m_xContext);
    xRemoteServiceManager = xRemoteContext.getServiceManager();
    Object transformer =
        xRemoteServiceManager.createInstanceWithContext(
            "com.sun.star.util.URLTransformer", xRemoteContext);
    xTransformer =
        (com.sun.star.util.XURLTransformer)
            UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, transformer);
    XDispatchProvider xDispatchProvider =
        (com.sun.star.frame.XDispatchProvider)
            UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProvider.class, xFrame);
    com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1];
    aURL[0] = new com.sun.star.util.URL();
    com.sun.star.frame.XDispatch xDispatch = null;
    aURL[0].Complete = command;
    xTransformer.parseSmart(aURL, ".uno");
    xDispatch = xDispatchProvider.queryDispatch(aURL[0], "", 0);
    com.sun.star.frame.XNotifyingDispatch xNotifyingDispatcher =
        (com.sun.star.frame.XNotifyingDispatch)
            UnoRuntime.queryInterface(com.sun.star.frame.XNotifyingDispatch.class, xDispatch);
    if (xDispatch != null) {
      xNotifyingDispatcher.dispatchWithNotification(
          aURL[0],
          lParams,
          new XDispatchResultListener() {

            public void dispatchFinished(DispatchResultEvent arg0) {
              System.out.println(arg0);
              throw new UnsupportedOperationException("Not supported yet.");
            }

            public void disposing(EventObject eo) {
              throw new UnsupportedOperationException("Not supported yet.");
            }
          });
    }
    // SpeechOO.m_xFrame.setComponent(null, null);
  }
Exemplo n.º 5
0
  /**
   * Called to create an instance of <code>TestEnvironment</code> with an object to test and related
   * objects. Subclasses should implement this method to provide the implementation and related
   * objects. The method is called from <code>getTestEnvironment()</code>.
   *
   * @param tParam test parameters
   * @param log writer to log information while testing
   * @see TestEnvironment
   * @see #getTestEnvironment
   */
  @Override
  protected TestEnvironment createTestEnvironment(TestParameters tParam, PrintWriter log)
      throws Exception {

    log.println("creating a test environment");

    if (xTextDoc != null) {
      xTextDoc.dispose(); // get a soffice factory object
    }
    SOfficeFactory SOF = SOfficeFactory.getFactory(tParam.getMSF());

    log.println("creating a text document");
    xTextDoc = SOF.createTextDoc(null);

    util.utils.waitForEventIdle(tParam.getMSF());

    XModel aModel1 = UnoRuntime.queryInterface(XModel.class, xTextDoc);

    XController secondController = aModel1.getCurrentController();

    XDispatchProvider aProv = UnoRuntime.queryInterface(XDispatchProvider.class, secondController);

    XDispatch getting = null;

    log.println("opening DatasourceBrowser");
    URL the_url = new URL();
    the_url.Complete = ".component:DB/DataSourceBrowser";
    getting = aProv.queryDispatch(the_url, "_beamer", 12);
    PropertyValue[] noArgs = new PropertyValue[0];
    getting.dispatch(the_url, noArgs);

    util.utils.waitForEventIdle(tParam.getMSF());

    XFrame the_frame1 = the_Desk.getCurrentFrame();

    if (the_frame1 == null) {
      log.println("Current frame was not found !!!");
    }

    XFrame the_frame2 = the_frame1.findFrame("_beamer", 4);

    the_frame2.setName("DatasourceBrowser");

    XInterface oObj = null;

    final XSelectionSupplier xSelect =
        UnoRuntime.queryInterface(XSelectionSupplier.class, the_frame2.getController());

    PropertyValue[] params =
        new PropertyValue[] {new PropertyValue(), new PropertyValue(), new PropertyValue()};
    params[0].Name = "DataSourceName";
    params[0].Value = "Bibliography";
    params[1].Name = "CommandType";
    params[1].Value = Integer.valueOf(com.sun.star.sdb.CommandType.TABLE);
    params[2].Name = "Command";
    params[2].Value = "biblio";

    final PropertyValue[] fParams = params;

    util.utils.waitForEventIdle(tParam.getMSF());

    XWindow xWindow = secondController.getFrame().getContainerWindow();

    XAccessible xRoot = AccessibilityTools.getAccessibleObject(xWindow);

    AccessibilityTools.printAccessibleTree(
        log, xRoot, tParam.getBool(util.PropertyName.DEBUG_IS_ACTIVE));

    oObj =
        AccessibilityTools.getAccessibleObjectForRole(
            xRoot, AccessibleRole.PANEL, "", "AccessibleBrowseBox");

    log.println("ImplementationName: " + util.utils.getImplName(oObj));

    TestEnvironment tEnv = new TestEnvironment(oObj);

    tEnv.addObjRelation(
        "EventProducer",
        new ifc.accessibility._XAccessibleEventBroadcaster.EventProducer() {

          public void fireEvent() {
            try {
              xSelect.select(fParams);
            } catch (com.sun.star.lang.IllegalArgumentException e) {
              e.printStackTrace();
            }
          }
        });

    return tEnv;
  }