Fix storing recent directory for Extension->Add dialog

Need to use the filedialoghelper methods, otherwise the
directory will not be stored properly.

Change-Id: Ib5f380ccd46d8c6c1cfa007cfe745a0aad43963e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185504
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Samuel Mehrbrodt
2025-05-19 11:45:36 +02:00
parent 72e93e138a
commit 83ce76aff6
@@ -636,8 +636,7 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
{
sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get());
aDlgHelper.SetContext(sfx2::FileDialogHelper::ExtensionManager);
const uno::Reference<ui::dialogs::XFilePicker3>& xFilePicker = aDlgHelper.GetFilePicker();
xFilePicker->setTitle( m_sAddPackages );
aDlgHelper.SetTitle( m_sAddPackages );
// collect and set filter list:
typedef std::map< OUString, OUString > t_string2string;
@@ -674,26 +673,26 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker()
}();
// All files at top:
xFilePicker->appendFilter( StrAllFiles, u"*.*"_ustr );
xFilePicker->appendFilter( DpResId(RID_STR_ALL_SUPPORTED), supportedFilters.makeStringAndClear() );
aDlgHelper.AddFilter( StrAllFiles, u"*.*"_ustr );
aDlgHelper.AddFilter( DpResId(RID_STR_ALL_SUPPORTED), supportedFilters.makeStringAndClear() );
// then supported ones:
for (auto const& elem : title2filter)
{
try
{
xFilePicker->appendFilter( elem.first, elem.second );
aDlgHelper.AddFilter( elem.first, elem.second );
}
catch (const lang::IllegalArgumentException &)
{
TOOLS_WARN_EXCEPTION( "desktop", "" );
}
}
xFilePicker->setCurrentFilter( DpResId(RID_STR_ALL_SUPPORTED) );
aDlgHelper.SetCurrentFilter( DpResId(RID_STR_ALL_SUPPORTED) );
if ( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
if ( aDlgHelper.Execute() == ERRCODE_ABORT )
return uno::Sequence<OUString>(); // cancelled
uno::Sequence< OUString > files( xFilePicker->getSelectedFiles() );
uno::Sequence< OUString > files( aDlgHelper.GetSelectedFiles() );
OSL_ASSERT( files.hasElements() );
return files;
}