sfx2/source/dialog/filedlghelper.cxx | 35 ++++++++++++++++++++++------------- sfx2/source/dialog/filedlgimpl.hxx | 3 ++- 2 files changed, 24 insertions(+), 14 deletions(-)
New commits: commit c08d8be8f96a69c5ca3d768789d7c0aa594619c0 Author: Jan-Marek Glogowski <glo...@fbihome.de> AuthorDate: Sun Oct 31 11:59:12 2021 +0100 Commit: Jan-Marek Glogowski <glo...@fbihome.de> CommitDate: Sun Oct 31 21:06:51 2021 +0100 Support system async file pickers Query XAsynchronousExecutableDialog and don't depend on the "com.sun.star.ui.dialogs.SystemFilePicker" service for the decision. Change-Id: I199ab55a40afaeca7870513829105e47d258420d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124511 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de> diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 23c2b097a23c..918b9c1869b7 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -807,6 +807,19 @@ static bool lcl_isSystemFilePicker( const uno::Reference< XExecutableDialog >& _ namespace { +bool lcl_isAsyncFilePicker( const uno::Reference< XExecutableDialog >& _rxFP ) +{ + try + { + uno::Reference<XAsynchronousExecutableDialog> xSI(_rxFP, UNO_QUERY); + return xSI.is(); + } + catch( const Exception& ) + { + } + return false; +} + enum open_or_save_t {OPEN, SAVE, UNDEFINED}; } @@ -917,6 +930,7 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( // create the picker component mxFileDlg.set(xFactory->createInstance( aService ), css::uno::UNO_QUERY); mbSystemPicker = lcl_isSystemFilePicker( mxFileDlg ); + mbAsyncPicker = lcl_isAsyncFilePicker(mxFileDlg); uno::Reference< XInitialization > xInit( mxFileDlg, UNO_QUERY ); @@ -1328,23 +1342,18 @@ void FileDialogHelper_Impl::implStartExecute() { DBG_ASSERT( mxFileDlg.is(), "invalid file dialog" ); + assert(mbAsyncPicker); preExecute(); - if ( mbSystemPicker ) + try { + uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( mxFileDlg, UNO_QUERY ); + if ( xAsyncDlg.is() ) + xAsyncDlg->startExecuteModal( this ); } - else + catch( const Exception& ) { - try - { - uno::Reference< XAsynchronousExecutableDialog > xAsyncDlg( mxFileDlg, UNO_QUERY ); - if ( xAsyncDlg.is() ) - xAsyncDlg->startExecuteModal( this ); - } - catch( const Exception& ) - { - TOOLS_WARN_EXCEPTION( "sfx.dialog", "FileDialogHelper_Impl::implDoExecute" ); - } + TOOLS_WARN_EXCEPTION( "sfx.dialog", "FileDialogHelper_Impl::implDoExecute" ); } } @@ -2592,7 +2601,7 @@ void FileDialogHelper::StartExecuteModal( const Link<FileDialogHelper*,void>& rE { m_aDialogClosedLink = rEndDialogHdl; m_nError = ERRCODE_NONE; - if ( mpImpl->isSystemFilePicker() ) + if (!mpImpl->isAsyncFilePicker()) Application::PostUserEvent( LINK( this, FileDialogHelper, ExecuteSystemFilePicker ) ); else mpImpl->implStartExecute(); diff --git a/sfx2/source/dialog/filedlgimpl.hxx b/sfx2/source/dialog/filedlgimpl.hxx index 15fc3b2decbb..01411f23e9e4 100644 --- a/sfx2/source/dialog/filedlgimpl.hxx +++ b/sfx2/source/dialog/filedlgimpl.hxx @@ -87,6 +87,7 @@ namespace sfx2 bool mbDeleteMatcher : 1; bool mbInsert : 1; bool mbSystemPicker : 1; + bool mbAsyncPicker : 1; bool mbPwdCheckBoxState : 1; bool mbSelection : 1; bool mbSelectionEnabled : 1; @@ -206,7 +207,7 @@ namespace sfx2 void SetContext( FileDialogHelper::Context _eNewContext ); OUString getInitPath( const OUString& _rFallback, const sal_Int32 _nFallbackToken ); - bool isSystemFilePicker() const { return mbSystemPicker; } + bool isAsyncFilePicker() const { return mbAsyncPicker; } bool isPasswordEnabled() const { return mbIsPwdEnabled; } css::uno::Reference<css::awt::XWindow> GetFrameInterface();