diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-06-05 00:22:16 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-06-05 14:16:36 -0400 |
commit | 503dd9c1eda024ae57e49b5c63a1fc9e9eb6d1c1 (patch) | |
tree | 30f6ef198450093e2b11e9047a1da4f0f4cdfae0 /vcl | |
parent | 7252dc55bce127b86b314b1197773cbef496b99b (diff) |
Intercept the window close event and end the preview when clicking 'x'.
This is to prevent the preview window from closing the whole document
when pressing the window frame's 'x' button. Instead, pressing the 'x'
will end the preview mode and bring it back to the normal Calc window.
Change-Id: If4d42928784e3e05bc6357d811a1954efb221f01
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/vcl/syswin.hxx | 3 | ||||
-rw-r--r-- | vcl/source/window/syswin.cxx | 11 | ||||
-rw-r--r-- | vcl/source/window/winproc.cxx | 32 |
3 files changed, 36 insertions, 10 deletions
diff --git a/vcl/inc/vcl/syswin.hxx b/vcl/inc/vcl/syswin.hxx index 7370280c53d1..4ca02c4b5c99 100644 --- a/vcl/inc/vcl/syswin.hxx +++ b/vcl/inc/vcl/syswin.hxx @@ -271,6 +271,9 @@ public: void SetScreenNumber( unsigned int nNewScreen ); void SetApplicationID( const rtl::OUString &rApplicationID ); + + void SetCloseHdl(const Link& rLink); + const Link& GetCloseHdl() const; }; #endif // _SV_SYSWIN_HXX diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index d4399432ef55..a7a8ce0dff75 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -57,6 +57,7 @@ public: TaskPaneList* mpTaskPaneList; Size maMaxOutSize; rtl::OUString maRepresentedURL; + Link maCloseHdl; }; SystemWindow::ImplData::ImplData() @@ -1034,4 +1035,14 @@ void SystemWindow::SetApplicationID(const rtl::OUString &rApplicationID) mpWindowImpl->mpFrame->SetApplicationID( rApplicationID ); } +void SystemWindow::SetCloseHdl(const Link& rLink) +{ + mpImplData->maCloseHdl = rLink; +} + +const Link& SystemWindow::GetCloseHdl() const +{ + return mpImplData->maCloseHdl; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index 076657ff88c2..b5096abcc8f6 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -1953,20 +1953,32 @@ void ImplHandleClose( Window* pWindow ) if ( pSVData->maWinData.mpTrackWin ) pSVData->maWinData.mpTrackWin->EndTracking( ENDTRACK_CANCEL | ENDTRACK_KEY ); - if( ! bWasPopup ) + if (bWasPopup) + return; + + Window *pWin = pWindow->ImplGetWindow(); + SystemWindow* pSysWin = dynamic_cast<SystemWindow*>(pWin); + if (pSysWin) { - Window *pWin = pWindow->ImplGetWindow(); - // check whether close is allowed - if ( !pWin->IsEnabled() || !pWin->IsInputEnabled() || pWin->IsInModalMode() ) - Sound::Beep( SOUND_DISABLE, pWin ); - else + // See if the custom close handler is set. + const Link& rLink = pSysWin->GetCloseHdl(); + if (rLink.IsSet()) { - DelayedCloseEvent* pEv = new DelayedCloseEvent; - pEv->pWindow = pWin; - pWin->ImplAddDel( &pEv->aDelData ); - Application::PostUserEvent( Link( pEv, DelayedCloseEventLink ) ); + rLink.Call(pSysWin); + return; } } + + // check whether close is allowed + if ( !pWin->IsEnabled() || !pWin->IsInputEnabled() || pWin->IsInModalMode() ) + Sound::Beep( SOUND_DISABLE, pWin ); + else + { + DelayedCloseEvent* pEv = new DelayedCloseEvent; + pEv->pWindow = pWin; + pWin->ImplAddDel( &pEv->aDelData ); + Application::PostUserEvent( Link( pEv, DelayedCloseEventLink ) ); + } } // ----------------------------------------------------------------------- |