/** * Internal call back for frame action events, triggered by the used OnewayExecutor thread we * started in frameAction(). We use it to update our interception on the internal saved frame. * * @param aEvent describes the action */ private void impl_frameAction(/*IN*/ com.sun.star.frame.FrameActionEvent aEvent) { synchronized (this) { if (m_bDead) return; } // deregistration will be done every time... // But may it's not necessary to establish a new registration! // Don't look for ignoring actions - it was done already inside original frameAction() call! boolean bRegister = false; // analyze the event and decide which reaction is useful switch (aEvent.Action.getValue()) { case com.sun.star.frame.FrameAction.COMPONENT_ATTACHED_value: bRegister = true; break; case com.sun.star.frame.FrameAction.COMPONENT_REATTACHED_value: bRegister = true; break; case com.sun.star.frame.FrameAction.COMPONENT_DETACHING_value: bRegister = false; break; } com.sun.star.frame.XFrame xFrame = null; boolean bIsRegistered = false; synchronized (this) { bIsRegistered = m_bIsRegistered; m_bIsRegistered = false; xFrame = m_xFrame; } com.sun.star.frame.XDispatchProviderInterception xRegistration = UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProviderInterception.class, xFrame); if (xRegistration == null) return; if (bIsRegistered) xRegistration.releaseDispatchProviderInterceptor(this); if (!bRegister) return; xRegistration.registerDispatchProviderInterceptor(this); synchronized (this) { m_bIsRegistered = true; } }
/** * If this java application shutdown - we must cancel all current existing listener connections. * Otherwhise the office will run into some DisposedExceptions if it tries to use these forgotten * listener references. And of course it can die doing that. We are registered at a central object * to be informed if the VM will exit. So we can react. */ public void shutdown() { com.sun.star.frame.XFrame xFrame = null; boolean bIsRegistered = false; boolean bIsActionListener = false; synchronized (this) { // don't react a second time here! if (m_bDead) return; m_bDead = true; bIsRegistered = m_bIsRegistered; m_bIsRegistered = false; bIsActionListener = m_bIsActionListener; m_bIsActionListener = false; xFrame = m_xFrame; m_xFrame = null; } // it's a good idea to cancel listening for frame action events // before(!) we deregister us as an interceptor. // Because registration and deregistratio nof interceptor objects // will force sending of frame action events...! if (bIsActionListener) xFrame.removeFrameActionListener(this); if (bIsRegistered) { com.sun.star.frame.XDispatchProviderInterception xRegistration = UnoRuntime.queryInterface(com.sun.star.frame.XDispatchProviderInterception.class, xFrame); if (xRegistration != null) xRegistration.releaseDispatchProviderInterceptor(this); } xFrame = null; synchronized (this) { m_xMaster = null; m_xSlave = null; } }