diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-11-29 09:19:25 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-11-29 10:35:14 +0000 |
commit | 5d846ebeb55b1e295fb53f473f0fb2b88712e001 (patch) | |
tree | 46b0125e6e24c9c584f5d5a069528361d6708964 | |
parent | 625f1cd72e834910342790195f19c3930988c34e (diff) |
Install a Cancel callback, don't rely on vcl searching for a parent to close
If there is no cancel callback for a Cancel button, it's monstrous to dig
around the hierarchy looking for a parent to call EndDialog/Close on. Really
messes up attempts to refactor dialogs.
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 7 | ||||
-rw-r--r-- | vcl/source/control/button.cxx | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 9c216565ff34..108e46df3efa 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -518,6 +518,7 @@ void SfxTabDialog::Init_Impl( sal_Bool bFmtFlag, const String* pUserButtonText ) { aOKBtn.SetClickHdl( LINK( this, SfxTabDialog, OkHdl ) ); + aCancelBtn.SetClickHdl( LINK( this, SfxTabDialog, CancelHdl ) ); aResetBtn.SetClickHdl( LINK( this, SfxTabDialog, ResetHdl ) ); aResetBtn.SetText( String( SfxResId( STR_RESET ) ) ); aTabCtrl.SetActivatePageHdl( @@ -601,7 +602,6 @@ void SfxTabDialog::StartExecuteModal( const Link& rEndDialogHdl ) void SfxTabDialog::Start( sal_Bool bShow ) { - aCancelBtn.SetClickHdl( LINK( this, SfxTabDialog, CancelHdl ) ); pImpl->bModal = sal_False; Start_Impl(); @@ -956,10 +956,9 @@ short SfxTabDialog::Ok() // ----------------------------------------------------------------------- -IMPL_LINK( SfxTabDialog, CancelHdl, Button*, pButton ) +IMPL_LINK( SfxTabDialog, CancelHdl, Button*, EMPTYARG ) { - (void)pButton; //unused - Close(); + EndDialog( RET_USER_CANCEL ); return 0; } diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx index ac88195eca9c..25e8de594664 100644 --- a/vcl/source/control/button.cxx +++ b/vcl/source/control/button.cxx @@ -1772,6 +1772,7 @@ OKButton::OKButton( Window* pParent, const ResId& rResId ) : void OKButton::Click() { + SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for OKButton"); // Ist kein Link gesetzt, dann schliesse Parent if ( !GetClickHdl() ) { @@ -1838,6 +1839,7 @@ CancelButton::CancelButton( Window* pParent, const ResId& rResId ) : void CancelButton::Click() { + SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for CancelButton"); // Ist kein Link gesetzt, dann schliesse Parent if ( !GetClickHdl() ) { @@ -1904,6 +1906,7 @@ HelpButton::HelpButton( Window* pParent, const ResId& rResId ) : void HelpButton::Click() { + SAL_WARN_IF(!GetClickHdl(), "vcl", "No handler installed for HelpButton"); // Ist kein Link gesetzt, loese Hilfe aus if ( !GetClickHdl() ) { |