Kaydet (Commit) 9d1c68ae authored tarafından Caolán McNamara's avatar Caolán McNamara

replace StartExecuteModal with StartExecuteAsync

Change-Id: I2c0e0266f6bb468ebb5285f95d1824cf12100812
Reviewed-on: https://gerrit.libreoffice.org/62690
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 97be9270
......@@ -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" );
......
......@@ -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>();
}
......
......@@ -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
......
......@@ -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:
......
......@@ -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);
});
}
......
......@@ -222,7 +222,7 @@ protected:
void prepareExecute( );
DECL_LINK( DialogClosedHdl, Dialog&, void );
void DialogClosedHdl(sal_Int32 nResult);
};
// SvtRemoteFilePicker
......
......@@ -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();
......
......@@ -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();
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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();
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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>();
}
......
......@@ -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)
......
......@@ -1051,15 +1051,6 @@ short Dialog::Execute()
#endif
}
// 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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment