Exemplo n.º 1
0
  /**
   * Indicates using of us as an interceptor. Now we have to react for the requests, we are
   * registered. That means: load new empty documents - triggered by the new menu of the office.
   * Because it's oneway - use thread for loading!
   *
   * @seealso impl_dispatch()
   * @param aURL describes the document, which should be loaded
   * @param lArguments optional parameters for loading
   */
  public /*ONEWAY*/ void dispatch(
      /*IN*/ com.sun.star.util.URL aURL, /*IN*/ com.sun.star.beans.PropertyValue[] lArguments) {
    synchronized (this) {
      if (m_bDead) return;
    }

    com.sun.star.util.URL[] lInURL = new com.sun.star.util.URL[1];
    com.sun.star.beans.PropertyValue[][] lInArguments = new com.sun.star.beans.PropertyValue[1][];
    lInURL[0] = aURL;
    lInArguments[0] = lArguments;

    ArrayList<Object> lOutParams = OnewayExecutor.encodeDispatch(lInURL, lInArguments);
    OnewayExecutor aExecutor =
        new OnewayExecutor(this, OnewayExecutor.REQUEST_DISPATCH, lOutParams);
    aExecutor.start();
  }
Exemplo n.º 2
0
  /**
   * call back for frame action events We use it to update our interception. Because if a new
   * component was loaded into the frame or another interceptor was registered, we should refresh
   * our connection to the frame. Otherwhise we can't guarantee full functionality here.
   *
   * <p>Note: Don't react synchronous in an asynchronous listener callback. So use a thread here to
   * update anything.
   *
   * @seealso impl_frameAction()
   * @param aEvent describes the action
   */
  public /*ONEWAY*/ void frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent) {
    synchronized (this) {
      if (m_bDead) return;
    }

    boolean bHandle = false;
    switch (aEvent.Action.getValue()) {
      case com.sun.star.frame.FrameAction.COMPONENT_ATTACHED_value:
        bHandle = true;
        break;
      case com.sun.star.frame.FrameAction.COMPONENT_DETACHING_value:
        bHandle = true;
        break;
      case com.sun.star.frame.FrameAction.COMPONENT_REATTACHED_value:
        bHandle = true;
        break;
        // Don't react for CONTEXT_CHANGED here. Ok it indicates, that may another interceptor
        // was registered at the frame ... but if we register ourself there - we get a context
        // changed too :-( Best way to produce a never ending recursion ...
        // May be that somewhere find a safe mechanism to detect own produced frame action events
        // and ignore it.
      case com.sun.star.frame.FrameAction.CONTEXT_CHANGED_value:
        System.out.println(
            "Time to update interception ... but may it will start a recursion. So I let it :-(");
        bHandle = false;
        break;
    }

    // ignore some events
    if (!bHandle) return;

    // pack the event and start thread - which call us back later
    ArrayList<Object> lOutParams = new ArrayList<Object>();
    lOutParams.add(aEvent);

    OnewayExecutor aExecutor =
        new OnewayExecutor(this, OnewayExecutor.REQUEST_FRAMEACTION, lOutParams);
    aExecutor.start();
  }
Exemplo n.º 3
0
  /**
   * In case we got an oneway listener callback - we had to use the office asynchronous then. This
   * method is the callback from the started thread (started inside the original oneway method). We
   * found all parameters of the original request packed inside a vector. Here we unpack it and call
   * the right internal helper method, which implements the right funtionality.
   *
   * @seealso frameAction()
   * @seealso dispatch()
   * @param nRequest indicates, which was the original request (identifies the original called
   *     method)
   * @param lParams the vector with all packed parameters of the original request
   */
  public void execOneway(/*IN*/ int nRequest, /*IN*/ ArrayList<Object> lParams) {
    synchronized (this) {
      if (m_bDead) return;
    }

    // was it frameAction()?
    if (nRequest == OnewayExecutor.REQUEST_FRAMEACTION) {
      impl_frameAction((FrameActionEvent) lParams.get(0));
    } else
    // was it dispatch()?
    if (nRequest == OnewayExecutor.REQUEST_DISPATCH) {
      com.sun.star.util.URL[] lOutURL = new com.sun.star.util.URL[1];
      com.sun.star.beans.PropertyValue[][] lOutProps = new com.sun.star.beans.PropertyValue[1][];

      OnewayExecutor.decodeDispatch(lParams, lOutURL, lOutProps);
      impl_dispatch(lOutURL[0], lOutProps[0]);
    }
  }