diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-06-21 13:01:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-06-21 16:06:56 +0200 |
commit | 203d96787969f707c78101be18d51b44ace98f93 (patch) | |
tree | 83c609c3dcf4c42e159804b7b97f76a2cd4137bb /sfx2 | |
parent | a8f97e5fca148804056295db2e3910aaa5c68ce8 (diff) |
give folderpicker an optional parent
so, like a file picker, it can make its parent modal while its
operating. Otherwise its possible to interact with the parent dialog in
undesirable ways, e.g. file, export as, export as epub, the folder
picker of 'media directory'
Change-Id: Ib61f8e630e176b6d81e80798fd0d282d16e8c086
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117582
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/dialog/filedlghelper.cxx | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx index 482b2146afdf..b9750c142967 100644 --- a/sfx2/source/dialog/filedlghelper.cxx +++ b/sfx2/source/dialog/filedlghelper.cxx @@ -785,7 +785,7 @@ ErrCode FileDialogHelper_Impl::getGraphic( Graphic& rGraphic ) const return nRet; } -static bool lcl_isSystemFilePicker( const uno::Reference< XFilePicker3 >& _rxFP ) +static bool lcl_isSystemFilePicker( const uno::Reference< XExecutableDialog >& _rxFP ) { try { @@ -1132,9 +1132,34 @@ FileDialogHelper_Impl::FileDialogHelper_Impl( mxFileDlg->addFilePickerListener( this ); } -css::uno::Reference<css::ui::dialogs::XFolderPicker2> createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Window* /*pPreferredParent*/) +css::uno::Reference<css::ui::dialogs::XFolderPicker2> createFolderPicker(const css::uno::Reference<css::uno::XComponentContext>& rContext, weld::Window* pPreferredParent) { - return css::ui::dialogs::FolderPicker::create(rContext); + auto xRet = css::ui::dialogs::FolderPicker::create(rContext); + + // see FileDialogHelper_Impl::FileDialogHelper_Impl (above) for args to FilePicker + // reuse the same arguments for FolderPicker + if (pPreferredParent && lcl_isSystemFilePicker(xRet)) + { + uno::Reference< XInitialization > xInit(xRet, UNO_QUERY); + if (xInit.is()) + { + Sequence<Any> aInitArguments(2); + + aInitArguments[0] <<= sal_Int32(0); + aInitArguments[1] <<= pPreferredParent->GetXWindow(); + + try + { + xInit->initialize(aInitArguments); + } + catch (const Exception&) + { + OSL_FAIL( "createFolderPicker: could not initialize the picker!" ); + } + } + } + + return xRet; } FileDialogHelper_Impl::~FileDialogHelper_Impl() |