diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-04-14 11:06:00 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-04-14 12:08:49 +0200 |
commit | 7526e77820956238a1a903d73ff15a49c082d6de (patch) | |
tree | 0dbd3b655b12a27aa0e66c3f3b157dcf7fa7a736 /sw/source/ui | |
parent | 9dda49734b65875d7b916a1867d86f8c161b32e8 (diff) |
sw define bibliography entry dialog: recognize relative file URLs
So that in case a file:// document has relative URLs, we show the type
as local file (with a file picker), not as "www document".
Change-Id: Id7a5d181dc6b2b9e6165d83bd294d7350bd4ce24
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114078
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source/ui')
-rw-r--r-- | sw/source/ui/index/swuiidxmrk.cxx | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx index 9d5a41f05075..464614f7eeb3 100644 --- a/sw/source/ui/index/swuiidxmrk.cxx +++ b/sw/source/ui/index/swuiidxmrk.cxx @@ -72,6 +72,20 @@ using namespace com::sun::star::lang; using namespace com::sun::star::util; using namespace ::comphelper; +namespace +{ +/// Similar to comphelper::isFileUrl(), but handles relative URLs as well. +bool IsFileUrl(SwWrtShell& rWrtSh, const OUString& rUrl) +{ + SwDocShell* pDocShell = rWrtSh.GetDoc()->GetDocShell(); + OUString aBaseUrl = pDocShell->getDocumentBaseURL(); + OUString aAbs = INetURLObject::GetAbsURL(aBaseUrl, rUrl, + INetURLObject::EncodeMechanism::WasEncoded, + INetURLObject::DecodeMechanism::WithCharset); + return comphelper::isFileUrl(aAbs); +} +} + // dialog to insert a directory selection SwIndexMarkPane::SwIndexMarkPane(const std::shared_ptr<weld::Dialog>& rDialog, weld::Builder& rBuilder, bool bNewDlg, SwWrtShell* pWrtShell) @@ -1557,7 +1571,7 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent, if(!pFields[aCurInfo.nToxField].isEmpty()) { int nPos = pFields[aCurInfo.nToxField].toInt32(); - if (nPos == AUTH_TYPE_WWW && comphelper::isFileUrl(pFields[AUTH_FIELD_URL])) + if (nPos == AUTH_TYPE_WWW && IsFileUrl(rWrtSh, pFields[AUTH_FIELD_URL])) { // Map file URL to local file. nPos = AUTH_TYPE_END; @@ -1626,7 +1640,7 @@ SwCreateAuthEntryDlg_Impl::SwCreateAuthEntryDlg_Impl(weld::Window* pParent, } } else if (aCurInfo.nToxField == AUTH_FIELD_URL - && comphelper::isFileUrl(pFields[aCurInfo.nToxField])) + && IsFileUrl(rWrtSh, pFields[aCurInfo.nToxField])) { m_xBrowseButton = m_aBuilders.back()->weld_button("browse"); m_xBrowseButton->connect_clicked(LINK(this, SwCreateAuthEntryDlg_Impl, BrowseHdl)); @@ -1725,7 +1739,7 @@ IMPL_LINK_NOARG(SwCreateAuthEntryDlg_Impl, BrowseHdl, weld::Button&, void) bool bSaveRelFSys = officecfg::Office::Common::Save::URL::FileSystem::get(); if (!aPath.isEmpty()) { - if (bSaveRelFSys && !comphelper::isFileUrl(aPath)) + if (bSaveRelFSys && !IsFileUrl(rWrtSh, aPath)) { SwDocShell* pDocShell = rWrtSh.GetDoc()->GetDocShell(); OUString aBasePath = pDocShell->getDocumentBaseURL(); |