summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-06-05 00:22:16 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-06-05 12:16:24 -0400
commit80fb93fe6c08f25a404ff2afa989fca246ac9efd (patch)
treeaad95dd4c2b914065fa9050ca98a1098ccce2344 /vcl
parent1227601d74ecddb06dcbe69e260aa32835900ed3 (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.hxx3
-rw-r--r--vcl/source/window/syswin.cxx11
-rw-r--r--vcl/source/window/winproc.cxx32
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 ) );
+ }
}
// -----------------------------------------------------------------------