diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-04-13 17:22:10 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-04-13 18:06:40 +0200 |
commit | aa818a0b977084af21667fb68d1728bd5f300c4b (patch) | |
tree | 79a88baf44132463fe72ec6fa9c5dfde4372353e /sw/source | |
parent | 739b63ea2b11b3c82939c5ea4e8ac682585ac1ec (diff) |
sw bibliography, refer to a page: fix biblio field relative URLs
Clicking always requires an absolute URL, so add functionality to get
the absolute URL (even if the field has a relative one) and use that
when handling a click.
Change-Id: I05f8b11937eac7b6032750557f4066181c6e4520
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114059
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/fields/authfld.cxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh2.cxx | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx index f57603509fd2..934f06f1243b 100644 --- a/sw/source/core/fields/authfld.cxx +++ b/sw/source/core/fields/authfld.cxx @@ -25,6 +25,7 @@ #include <i18nlangtag/languagetag.hxx> #include <o3tl/any.hxx> #include <osl/diagnose.h> +#include <tools/urlobj.hxx> #include <swtypes.hxx> #include <strings.hrc> #include <authfld.hxx> @@ -42,6 +43,7 @@ #include <IDocumentLayoutAccess.hxx> #include <unofldmid.h> #include <unoprnms.hxx> +#include <docsh.hxx> #include <com/sun/star/beans/PropertyValues.hpp> @@ -610,6 +612,16 @@ bool SwAuthorityField::HasURL() const return !rURL.isEmpty(); } +OUString SwAuthorityField::GetAbsoluteURL() const +{ + const OUString& rURL = GetAuthEntry()->GetAuthorField(AUTH_FIELD_URL); + SwDoc* pDoc = static_cast<SwAuthorityFieldType*>(GetTyp())->GetDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + OUString aBasePath = pDocShell->getDocumentBaseURL(); + return INetURLObject::GetAbsURL(aBasePath, rURL, INetURLObject::EncodeMechanism::WasEncoded, + INetURLObject::DecodeMechanism::WithCharset); +} + void SwAuthorityField::dumpAsXml(xmlTextWriterPtr pWriter) const { (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwAuthorityField")); diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx index 66b38c3d84ea..90f08fd33a81 100644 --- a/sw/source/uibase/wrtsh/wrtsh2.cxx +++ b/sw/source/uibase/wrtsh/wrtsh2.cxx @@ -411,7 +411,7 @@ void SwWrtShell::ClickToField(const SwField& rField, bool bExecHyperlinks) break; } - const OUString& rURL = pField->GetAuthEntry()->GetAuthorField(AUTH_FIELD_URL); + const OUString& rURL = pField->GetAbsoluteURL(); ::LoadURL(*this, rURL, LoadUrlFlags::NewView, /*rTargetFrameName=*/OUString()); } break; |