/** * 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(); }
/** * 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(); }