diff options
author | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-08 05:50:25 +0200 |
---|---|---|
committer | Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de> | 2021-07-12 14:31:20 +0200 |
commit | d157c1bd70d630a58db33910d550bb8dee9fe62e (patch) | |
tree | 6a7d4a63cc524fcbbdcdfd8c4271fcbb7cd3c983 /sc | |
parent | c62bb20032cef7479e9293e84a8d57a2c74399d0 (diff) |
tdf#126665 Remember last used file picker directory
This introduces internal tracking of last used directories.
Each caller of the file picker can pass a "context". The selected
directory will then be saved & restored when opening the file picker
with the same context again.
After ffa636ba74b04b3258ec9a696bc4eac33581fa24 , the Windows file picker
no longer tracks the last used directory itself.
This is a replacement and an improvement at the same time, since there is not
one global last used directory, but one per context.
Change-Id: I10650cfb9359922690954fa65c89b4e47477e2c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118597
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Samuel Mehrbrodt <samuel.mehrbrodt@allotropia.de>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/miscdlgs/dataproviderdlg.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/miscdlgs/datastreamdlg.cxx | 1 | ||||
-rw-r--r-- | sc/source/ui/xmlsource/xmlsourcedlg.cxx | 19 |
3 files changed, 9 insertions, 12 deletions
diff --git a/sc/source/ui/miscdlgs/dataproviderdlg.cxx b/sc/source/ui/miscdlgs/dataproviderdlg.cxx index 40186b65ccd4..8ad7dd2177aa 100644 --- a/sc/source/ui/miscdlgs/dataproviderdlg.cxx +++ b/sc/source/ui/miscdlgs/dataproviderdlg.cxx @@ -785,6 +785,7 @@ IMPL_LINK_NOARG(ScDataProviderDlg, ApplyBtnHdl, weld::Button&, void) IMPL_LINK_NOARG(ScDataProviderDlg, BrowseBtnHdl, weld::Button&, void) { sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, m_xDialog.get()); + aFileDialog.SetContext(sfx2::FileDialogHelper::CalcDataProvider); if (aFileDialog.Execute() != ERRCODE_NONE) return; diff --git a/sc/source/ui/miscdlgs/datastreamdlg.cxx b/sc/source/ui/miscdlgs/datastreamdlg.cxx index a713b9723a3e..cd03a3e66c53 100644 --- a/sc/source/ui/miscdlgs/datastreamdlg.cxx +++ b/sc/source/ui/miscdlgs/datastreamdlg.cxx @@ -51,6 +51,7 @@ DataStreamDlg::~DataStreamDlg() {} IMPL_LINK_NOARG(DataStreamDlg, BrowseHdl, weld::Button&, void) { sfx2::FileDialogHelper aFileDialog(0, FileDialogFlags::NONE, m_xDialog.get()); + aFileDialog.SetContext(sfx2::FileDialogHelper::CalcDataStream); if (aFileDialog.Execute() != ERRCODE_NONE) return; diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx index edc8ca3d5dcb..0bbfa9d200b8 100644 --- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx +++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx @@ -163,21 +163,16 @@ void ScXMLSourceDlg::SelectSourceFile() { sfx2::FileDialogHelper aDlgHelper(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, FileDialogFlags::NONE, m_xDialog.get()); + aDlgHelper.SetContext(sfx2::FileDialogHelper::CalcXMLSource); uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = aDlgHelper.GetFilePicker(); - if (maSrcPath.isEmpty()) - // Use default path. - xFilePicker->setDisplayDirectory(SvtPathOptions().GetWorkPath()); - else - { - // Use the directory of current source file. - INetURLObject aURL(maSrcPath); - aURL.removeSegment(); - aURL.removeFinalSlash(); - OUString aPath = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); - xFilePicker->setDisplayDirectory(aPath); - } + // Use the directory of current source file. + INetURLObject aURL(maSrcPath); + aURL.removeSegment(); + aURL.removeFinalSlash(); + OUString aPath = aURL.GetMainURL(INetURLObject::DecodeMechanism::NONE); + xFilePicker->setDisplayDirectory(aPath); if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK) // File picker dialog cancelled. |