diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-31 11:57:38 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-31 22:08:07 +0100 |
commit | 9d1c68ae17ef566b9034478c7b29411c62684289 (patch) | |
tree | 265f9e7decdbe9dc77ff7a108d878b68ed9887a6 | |
parent | 97be9270868990d3d45b29724c8fdc3598d2a64c (diff) |
replace StartExecuteModal with StartExecuteAsync
Change-Id: I2c0e0266f6bb468ebb5285f95d1824cf12100812
Reviewed-on: https://gerrit.libreoffice.org/62690
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | cui/source/dialogs/cuigaldlg.cxx | 30 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.cxx | 12 | ||||
-rw-r--r-- | cui/source/factory/dlgfact.hxx | 2 | ||||
-rw-r--r-- | cui/source/inc/cuigaldlg.hxx | 8 | ||||
-rw-r--r-- | fpicker/source/office/OfficeFilePicker.cxx | 15 | ||||
-rw-r--r-- | fpicker/source/office/OfficeFilePicker.hxx | 2 | ||||
-rw-r--r-- | fpicker/source/office/OfficeFolderPicker.cxx | 11 | ||||
-rw-r--r-- | fpicker/source/office/OfficeFolderPicker.hxx | 4 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 9 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.hxx | 2 | ||||
-rw-r--r-- | include/sfx2/tabdlg.hxx | 1 | ||||
-rw-r--r-- | include/vcl/dialog.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/tabdlg.cxx | 9 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.cxx | 10 | ||||
-rw-r--r-- | sw/source/ui/dialog/swdlgfact.hxx | 2 | ||||
-rw-r--r-- | vcl/source/window/dialog.cxx | 9 |
16 files changed, 48 insertions, 80 deletions
diff --git a/cui/source/dialogs/cuigaldlg.cxx b/cui/source/dialogs/cuigaldlg.cxx index a04340bbc80e..3bb5d6154677 100644 --- a/cui/source/dialogs/cuigaldlg.cxx +++ b/cui/source/dialogs/cuigaldlg.cxx @@ -236,7 +236,6 @@ IMPL_LINK_NOARG(SearchProgress, CleanUpHdl, void*, void) disposeOnce(); } - short SearchProgress::Execute() { OSL_FAIL( "SearchProgress cannot be executed via Dialog::Execute!\n" @@ -245,17 +244,15 @@ short SearchProgress::Execute() return RET_CANCEL; } - -void SearchProgress::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) +bool SearchProgress::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) { assert(!maSearchThread.is()); maSearchThread = new SearchThread( this, static_cast< TPGalleryThemeProperties * >(parent_.get()), startUrl_); maSearchThread->launch(); - ModalDialog::StartExecuteModal( rEndDialogHdl ); + return ModalDialog::StartExecuteAsync(rCtx); } - TakeThread::TakeThread( TakeProgress* pProgress, TPGalleryThemeProperties* pBrowser, @@ -400,7 +397,6 @@ IMPL_LINK_NOARG(TakeProgress, CleanUpHdl, void*, void) disposeOnce(); } - short TakeProgress::Execute() { OSL_FAIL( "TakeProgress cannot be executed via Dialog::Execute!\n" @@ -409,17 +405,15 @@ short TakeProgress::Execute() return RET_CANCEL; } - -void TakeProgress::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) +bool TakeProgress::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) { assert(!maTakeThread.is()); maTakeThread = new TakeThread( this, static_cast< TPGalleryThemeProperties * >(window_.get()), maTakenList); maTakeThread->launch(); - ModalDialog::StartExecuteModal( rEndDialogHdl ); + return ModalDialog::StartExecuteAsync(rCtx); } - ActualizeProgress::ActualizeProgress(vcl::Window* pWindow, GalleryTheme* pThm) : ModalDialog(pWindow, "GalleryUpdateProgress", "cui/ui/galleryupdateprogress.ui") @@ -923,7 +917,9 @@ void TPGalleryThemeProperties::SearchFiles() pProgress->SetDirectory( INetURLObject() ); pProgress->Update(); - pProgress->StartExecuteModal( LINK( this, TPGalleryThemeProperties, EndSearchProgressHdl ) ); + pProgress->StartExecuteAsync([=](sal_Int32 nResult){ + EndSearchProgressHdl(nResult); + }); } @@ -962,7 +958,6 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, ClickSearchHdl, Button*, void) } } - void TPGalleryThemeProperties::TakeFiles() { if( m_pLbxFound->GetSelectedEntryCount() || ( bTakeAll && bEntriesFound ) ) @@ -970,9 +965,10 @@ void TPGalleryThemeProperties::TakeFiles() VclPtrInstance<TakeProgress> pTakeProgress( this ); pTakeProgress->Update(); - pTakeProgress->StartExecuteModal( - Link<Dialog&,void>() /* no postprocessing needed, pTakeProgress - will be disposed in TakeProgress::CleanupHdl */ ); + pTakeProgress->StartExecuteAsync([=](sal_Int32 /*nResult*/){ + /* no postprocessing needed, pTakeProgress + will be disposed in TakeProgress::CleanupHdl */ + }); } } @@ -1107,8 +1103,7 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, PreviewTimerHdl, Timer *, void) DoPreview(); } - -IMPL_LINK_NOARG(TPGalleryThemeProperties, EndSearchProgressHdl, Dialog&, void) +void TPGalleryThemeProperties::EndSearchProgressHdl(sal_Int32 /*nResult*/) { if( !aFoundList.empty() ) { @@ -1126,7 +1121,6 @@ IMPL_LINK_NOARG(TPGalleryThemeProperties, EndSearchProgressHdl, Dialog&, void) } } - IMPL_LINK( TPGalleryThemeProperties, DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, pEvt, void ) { DBG_ASSERT( xFolderPicker.is(), "TPGalleryThemeProperties::DialogClosedHdl(): no folder picker" ); diff --git a/cui/source/factory/dlgfact.cxx b/cui/source/factory/dlgfact.cxx index 138d5427b0a8..067e91c7657b 100644 --- a/cui/source/factory/dlgfact.cxx +++ b/cui/source/factory/dlgfact.cxx @@ -297,8 +297,9 @@ void VclAbstractDialog2_Impl::dispose() void VclAbstractDialog2_Impl::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) { m_aEndDlgHdl = rEndDialogHdl; - m_pDlg->StartExecuteModal( - LINK( this, VclAbstractDialog2_Impl, EndDialogHdl ) ); + m_pDlg->StartExecuteAsync([=](sal_Int32 nResult){ + EndDialogHdl(nResult); + }); } // virtual @@ -307,13 +308,8 @@ sal_Int32 VclAbstractDialog2_Impl::GetResult() return m_pDlg->GetResult(); } -IMPL_LINK( VclAbstractDialog2_Impl, EndDialogHdl, Dialog&, rDlg, void ) +void VclAbstractDialog2_Impl::EndDialogHdl(sal_Int32 /*nResult*/) { - if ( &rDlg != m_pDlg ) - { - SAL_WARN( "cui.factory", "VclAbstractDialog2_Impl::EndDialogHdl(): wrong dialog" ); - } - m_aEndDlgHdl.Call( *m_pDlg ); m_aEndDlgHdl = Link<Dialog&,void>(); } diff --git a/cui/source/factory/dlgfact.hxx b/cui/source/factory/dlgfact.hxx index bbf336099475..d780da073e28 100644 --- a/cui/source/factory/dlgfact.hxx +++ b/cui/source/factory/dlgfact.hxx @@ -91,7 +91,7 @@ public: virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override; virtual sal_Int32 GetResult() override; private: - DECL_LINK( EndDialogHdl, Dialog&, void ); + void EndDialogHdl(sal_Int32 nResult); }; class CuiVclAbstractDialog_Impl : public VclAbstractDialog diff --git a/cui/source/inc/cuigaldlg.hxx b/cui/source/inc/cuigaldlg.hxx index fd36e8b314a3..85b465065da7 100644 --- a/cui/source/inc/cuigaldlg.hxx +++ b/cui/source/inc/cuigaldlg.hxx @@ -97,7 +97,8 @@ public: DECL_LINK( CleanUpHdl, void*, void ); virtual short Execute() override; - virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override; + using ModalDialog::StartExecuteAsync; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; void SetFileType( const OUString& rType ) { m_pFtSearchType->SetText( rType ); } void SetDirectory( const INetURLObject& rURL ) { m_pFtSearchDir->SetText( GetReducedString( rURL, 30 ) ); } }; @@ -143,7 +144,8 @@ public: void SetFile( const INetURLObject& rURL ) { m_pFtTakeFile->SetText( GetReducedString( rURL, 30 ) ); } virtual short Execute() override; - virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override; + using ModalDialog::StartExecuteAsync; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; }; class ActualizeProgress : public ModalDialog @@ -264,6 +266,7 @@ class TPGalleryThemeProperties : public SfxTabPage void SearchFiles(); void TakeFiles(); void DoPreview(); + void EndSearchProgressHdl(sal_Int32 nResult); DECL_LINK( ClickPreviewHdl, Button*, void ); DECL_LINK( ClickSearchHdl, Button*, void ); @@ -273,7 +276,6 @@ class TPGalleryThemeProperties : public SfxTabPage DECL_LINK( SelectFileTypeHdl, ComboBox&, void ); DECL_LINK( DClickFoundHdl, ListBox&, void ); DECL_LINK( PreviewTimerHdl, Timer*, void ); - DECL_LINK( EndSearchProgressHdl, Dialog&, void ); DECL_LINK( DialogClosedHdl, css::ui::dialogs::DialogClosedEvent*, void ); public: diff --git a/fpicker/source/office/OfficeFilePicker.cxx b/fpicker/source/office/OfficeFilePicker.cxx index 8966e7f9f426..6f22961fdf8d 100644 --- a/fpicker/source/office/OfficeFilePicker.cxx +++ b/fpicker/source/office/OfficeFilePicker.cxx @@ -212,22 +212,18 @@ void SvtFilePicker::prepareExecute() } - -IMPL_LINK( SvtFilePicker, DialogClosedHdl, Dialog&, rDlg, void ) +void SvtFilePicker::DialogClosedHdl(sal_Int32 nResult) { if ( m_xDlgClosedListener.is() ) { - sal_Int16 nRet = static_cast< sal_Int16 >( rDlg.GetResult() ); + sal_Int16 nRet = static_cast< sal_Int16 >(nResult); css::ui::dialogs::DialogClosedEvent aEvent( *this, nRet ); m_xDlgClosedListener->dialogClosed( aEvent ); m_xDlgClosedListener.clear(); } } - // SvtFilePicker - - PickerFlags SvtFilePicker::getPickerFlags() { // set the winbits for creating the filedialog @@ -505,8 +501,11 @@ void SAL_CALL SvtFilePicker::startExecuteModal( const Reference< css::ui::dialog m_xDlgClosedListener = xListener; prepareDialog(); prepareExecute(); - getDialog()->EnableAutocompletion(); - getDialog()->StartExecuteModal( LINK( this, SvtFilePicker, DialogClosedHdl ) ); + SvtFileDialog_Base* pDialog = getDialog(); + pDialog->EnableAutocompletion(); + pDialog->StartExecuteAsync([=](sal_Int32 nResult){ + DialogClosedHdl(nResult); + }); } diff --git a/fpicker/source/office/OfficeFilePicker.hxx b/fpicker/source/office/OfficeFilePicker.hxx index af60daa9ee0b..9df75d019fb7 100644 --- a/fpicker/source/office/OfficeFilePicker.hxx +++ b/fpicker/source/office/OfficeFilePicker.hxx @@ -222,7 +222,7 @@ protected: void prepareExecute( ); - DECL_LINK( DialogClosedHdl, Dialog&, void ); + void DialogClosedHdl(sal_Int32 nResult); }; // SvtRemoteFilePicker diff --git a/fpicker/source/office/OfficeFolderPicker.cxx b/fpicker/source/office/OfficeFolderPicker.cxx index 5ace5400eedf..06703055fb4b 100644 --- a/fpicker/source/office/OfficeFolderPicker.cxx +++ b/fpicker/source/office/OfficeFolderPicker.cxx @@ -63,8 +63,11 @@ void SAL_CALL SvtFolderPicker::startExecuteModal( const Reference< css::ui::dial m_xListener = xListener; prepareDialog(); prepareExecute(); - getDialog()->EnableAutocompletion(); - getDialog()->StartExecuteModal( LINK( this, SvtFolderPicker, DialogClosedHdl ) ); + SvtFileDialog_Base* pDialog = getDialog(); + pDialog->EnableAutocompletion(); + pDialog->StartExecuteAsync([=](sal_Int32 nResult){ + DialogClosedHdl(nResult); + }); } VclPtr<SvtFileDialog_Base> SvtFolderPicker::implCreateDialog( vcl::Window* _pParent ) @@ -96,11 +99,11 @@ void SvtFolderPicker::prepareExecute() } } -IMPL_LINK( SvtFolderPicker, DialogClosedHdl, Dialog&, rDlg, void ) +void SvtFolderPicker::DialogClosedHdl(sal_Int32 nResult) { if ( m_xListener.is() ) { - sal_Int16 nRet = static_cast< sal_Int16 >( rDlg.GetResult() ); + sal_Int16 nRet = static_cast<sal_Int16>(nResult); css::ui::dialogs::DialogClosedEvent aEvent( *this, nRet ); m_xListener->dialogClosed( aEvent ); m_xListener.clear(); diff --git a/fpicker/source/office/OfficeFolderPicker.hxx b/fpicker/source/office/OfficeFolderPicker.hxx index 4dd96a833151..7a44881c05f8 100644 --- a/fpicker/source/office/OfficeFolderPicker.hxx +++ b/fpicker/source/office/OfficeFolderPicker.hxx @@ -45,8 +45,8 @@ private: css::uno::Reference< css::ui::dialogs::XDialogClosedListener > m_xListener; - void prepareExecute( ); - DECL_LINK( DialogClosedHdl, Dialog&, void ); + void prepareExecute(); + void DialogClosedHdl(sal_Int32 nResult); public: SvtFolderPicker(); diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index 18714773cdf3..c7211f330a00 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -1685,17 +1685,15 @@ short SvtFileDialog::Execute() return nResult; } - -void SvtFileDialog::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) +bool SvtFileDialog::StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) { if (!PrepareExecute()) - return; + return false; // start of the dialog - ModalDialog::StartExecuteModal( rEndDialogHdl ); + return ModalDialog::StartExecuteAsync(rCtx); } - void SvtFileDialog::onAsyncOperationStarted() { EnableUI( false ); @@ -1704,7 +1702,6 @@ void SvtFileDialog::onAsyncOperationStarted() pImpl->_pBtnCancel->GrabFocus(); } - void SvtFileDialog::onAsyncOperationFinished() { EnableUI( true ); diff --git a/fpicker/source/office/iodlg.hxx b/fpicker/source/office/iodlg.hxx index 3cb4f631e307..165e8426086a 100644 --- a/fpicker/source/office/iodlg.hxx +++ b/fpicker/source/office/iodlg.hxx @@ -173,7 +173,7 @@ public: virtual void dispose() override; virtual short Execute() override; - virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; void FileSelect(); void FilterSelect() override; diff --git a/include/sfx2/tabdlg.hxx b/include/sfx2/tabdlg.hxx index 3247da37e62f..f57fc5949ace 100644 --- a/include/sfx2/tabdlg.hxx +++ b/include/sfx2/tabdlg.hxx @@ -183,7 +183,6 @@ public: void RemoveStandardButton(); short Execute() override; - void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) override; bool StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx ) override; void Start(); diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index 66d6e2bccd6f..8d4c2c6e0ee2 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -140,7 +140,6 @@ public: // Dialog::Execute replacement API public: - virtual void StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ); long GetResult() const; private: bool ImplStartExecuteModal(); @@ -148,7 +147,6 @@ private: void ImplSetModalInputMode(bool bModal); public: - // FIXME: Need to remove old StartExecuteModal in favour of this one. /// Returns true if the dialog successfully starts bool StartExecuteAsync(const std::function<void(sal_Int32)> &rEndDialogFn) { diff --git a/sfx2/source/dialog/tabdlg.cxx b/sfx2/source/dialog/tabdlg.cxx index 56143ef5ae36..b5e2719c4830 100644 --- a/sfx2/source/dialog/tabdlg.cxx +++ b/sfx2/source/dialog/tabdlg.cxx @@ -580,15 +580,6 @@ bool SfxTabDialog::StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx ) return TabDialog::StartExecuteAsync( rCtx ); } -void SfxTabDialog::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) -{ - if ( !m_pTabCtrl->GetPageCount() ) - return; - Start_Impl(); - TabDialog::StartExecuteModal( rEndDialogHdl ); -} - - void SfxTabDialog::Start() { m_pImpl->bModal = false; diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 15a96a671249..39db3b0a1f10 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -724,8 +724,9 @@ void AbstractMailMergeWizard_Impl::dispose() void AbstractMailMergeWizard_Impl::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) { aEndDlgHdl = rEndDialogHdl; - pDlg->StartExecuteModal( - LINK( this, AbstractMailMergeWizard_Impl, EndDialogHdl ) ); + pDlg->StartExecuteAsync([=](sal_Int32 nResult){ + EndDialogHdl(nResult); + }); } sal_Int32 AbstractMailMergeWizard_Impl::GetResult() @@ -733,11 +734,8 @@ sal_Int32 AbstractMailMergeWizard_Impl::GetResult() return pDlg->GetResult(); } -IMPL_LINK( AbstractMailMergeWizard_Impl, EndDialogHdl, Dialog&, rDialog, void ) +void AbstractMailMergeWizard_Impl::EndDialogHdl(sal_Int32 /*nResult*/) { - OSL_ENSURE( &rDialog == pDlg, "wrong dialog passed to EndDialogHdl!" ); - (void) rDialog; // unused in non-debug - aEndDlgHdl.Call( *pDlg ); aEndDlgHdl = Link<Dialog&,void>(); } diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 78d79677c0ed..8f2cf77a04c3 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -572,7 +572,7 @@ class AbstractMailMergeWizard_Impl : public AbstractMailMergeWizard VclPtr<SwMailMergeWizard> pDlg; Link<Dialog&,void> aEndDlgHdl; - DECL_LINK( EndDialogHdl, Dialog&, void ); + void EndDialogHdl(sal_Int32 nResult); public: explicit AbstractMailMergeWizard_Impl( SwMailMergeWizard* p ) : pDlg(p) diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index a03ea6021d33..d1da54c5d3ed 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -1052,15 +1052,6 @@ short Dialog::Execute() } // virtual -void Dialog::StartExecuteModal( const Link<Dialog&,void>& rEndDialogHdl ) -{ - VclAbstractDialog::AsyncContext aCtx; - VclPtr<Dialog> ref(this); - aCtx.maEndDialogFn = [ref,rEndDialogHdl](sal_Int32){ rEndDialogHdl.Call(*ref.get()); }; - StartExecuteAsync(aCtx); -} - -// virtual bool Dialog::StartExecuteAsync( VclAbstractDialog::AsyncContext &rCtx ) { if ( !ImplStartExecuteModal() ) |