extensions/source/bibliography/general.cxx | 14 ++++++++++++++ sw/source/ui/index/swuiidxmrk.cxx | 8 ++++++++ 2 files changed, 22 insertions(+)
New commits: commit f966b9e8bb2b5e7e563807d16088a9f3784f01fe Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Aug 13 15:37:49 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Fri Aug 13 18:31:11 2021 +0200 bibliography, local URL: better starting directory when picking a new file Improve the case when we have no old file, so we can't take its old parent directory as a starting point in the file picker, opened by the browse button. It turns out both places that open that file picker have access to the base URL of the current document, so can open the directory of that instead. Change-Id: I4db84b6036771f48962d49ae5e4c46a99c306def Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120455 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index 3992f55e5ebc..08880534eea6 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -46,6 +46,7 @@ #include <algorithm> #include <tools/urlobj.hxx> #include <sfx2/filedlghelper.hxx> +#include <sfx2/objsh.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -363,6 +364,19 @@ IMPL_LINK_NOARG(BibGeneralPage, BrowseHdl, weld::Button&, void) { aFileDlg.SetDisplayDirectory(aPath); } + else + { + SfxObjectShell* pShell = SfxObjectShell::Current(); + OUString aBaseURL; + if (pShell) + { + aBaseURL = pShell->getDocumentBaseURL(); + } + if (!aBaseURL.isEmpty()) + { + aFileDlg.SetDisplayDirectory(aBaseURL); + } + } if (aFileDlg.Execute() != ERRCODE_NONE) { diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 7b0787caf5ff..fb5ae141563c 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -1810,6 +1810,14 @@ IMPL_LINK(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, rButton, void) { aFileDlg.SetDisplayDirectory(aPath); } + else + { + OUString aBaseURL = rWrtSh.GetDoc()->GetDocShell()->getDocumentBaseURL(); + if (!aBaseURL.isEmpty()) + { + aFileDlg.SetDisplayDirectory(aBaseURL); + } + } if (aFileDlg.Execute() != ERRCODE_NONE) {