From d0c3c24da2506bff1719a276f2eff34589fa7663 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 6 Jun 2012 01:28:55 -0400 Subject: Check if the system window has a close handler, and if yes, call it. This allows the close event in the preview window to be handled in a custom fashion, instead of having it call the normal "close window" command. Change-Id: Id324c4f5c96d0222bf82caa8029aa1c724262c32 --- framework/inc/dispatch/closedispatcher.hxx | 4 ++++ framework/source/dispatch/closedispatcher.cxx | 23 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'framework') diff --git a/framework/inc/dispatch/closedispatcher.hxx b/framework/inc/dispatch/closedispatcher.hxx index eabad8c7c56e..9ec937c6ab91 100644 --- a/framework/inc/dispatch/closedispatcher.hxx +++ b/framework/inc/dispatch/closedispatcher.hxx @@ -60,6 +60,8 @@ //_______________________________________________ // namespace +class SystemWindow; + namespace framework{ //----------------------------------------------- @@ -135,6 +137,8 @@ class CloseDispatcher : public css::lang::XTypeProvider /** @short holded alive for internaly asynchronous operations! */ css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener; + SystemWindow* m_pSysWindow; + //------------------------------------------- // native interface diff --git a/framework/source/dispatch/closedispatcher.cxx b/framework/source/dispatch/closedispatcher.cxx index cf81fa5d1554..4a5413158443 100644 --- a/framework/source/dispatch/closedispatcher.cxx +++ b/framework/source/dispatch/closedispatcher.cxx @@ -53,12 +53,15 @@ #include #include +#include "vcl/syswin.hxx" #include #include //_______________________________________________ // namespace +using namespace com::sun::star; + namespace framework{ #ifdef fpf @@ -96,8 +99,19 @@ CloseDispatcher::CloseDispatcher(const css::uno::Reference< css::lang::XMultiSer , m_xSMGR (xSMGR ) , m_aAsyncCallback (LINK( this, CloseDispatcher, impl_asyncCallback)) , m_lStatusListener (m_aLock.getShareableOslMutex() ) + , m_pSysWindow(NULL) { - m_xCloseFrame = CloseDispatcher::static_impl_searchRightTargetFrame(xFrame, sTarget); + uno::Reference xTarget = static_impl_searchRightTargetFrame(xFrame, sTarget); + m_xCloseFrame = xTarget; + + // Try to retrieve the system window instance of the closing frame. + uno::Reference xWindow = xTarget->getContainerWindow(); + if (xWindow.is()) + { + Window* pWindow = VCLUnoHelper::GetWindow(xWindow); + if (pWindow->IsSystemWindow()) + m_pSysWindow = dynamic_cast(pWindow); + } } //----------------------------------------------- @@ -211,6 +225,13 @@ void SAL_CALL CloseDispatcher::dispatchWithNotification(const css::util::URL& return; } + if (m_pSysWindow && m_pSysWindow->GetCloseHdl().IsSet()) + { + // The closing frame has its own close handler. Call it instead. + m_pSysWindow->GetCloseHdl().Call(m_pSysWindow); + return; + } + // OK - URLs are the right ones. // But we cant execute synchronously :-) // May we are called from a generic key-input handler, -- cgit