diff options
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/inc/txmsrt.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/tox/txmsrt.cxx | 22 |
2 files changed, 21 insertions, 3 deletions
diff --git a/sw/source/core/inc/txmsrt.hxx b/sw/source/core/inc/txmsrt.hxx index 873e683c451e..ac89aab96c1b 100644 --- a/sw/source/core/inc/txmsrt.hxx +++ b/sw/source/core/inc/txmsrt.hxx @@ -299,7 +299,7 @@ public: OUString GetText(sal_uInt16 nAuthField, const SwRootFrame* pLayout) const; /// Gets the URL of the underlying SwAuthEntry, ignoring its page number. - static OUString GetSourceURL(const OUString& rText); + OUString GetSourceURL(const OUString& rText) const; }; #endif // INCLUDED_SW_SOURCE_CORE_INC_TXMSRT_HXX diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index 881ea6e3c686..dade7ad0c5b2 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -42,6 +42,7 @@ #include <strings.hrc> #include <reffld.hxx> +#include <docsh.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -842,15 +843,32 @@ OUString SwTOXAuthority::GetText(sal_uInt16 nAuthField, const SwRootFrame* pLayo return sText; } -OUString SwTOXAuthority::GetSourceURL(const OUString& rText) +OUString SwTOXAuthority::GetSourceURL(const OUString& rText) const { OUString aText = rText; - INetURLObject aObject(aText); + + SwDoc* pDoc = static_cast<SwAuthorityFieldType*>(m_rField.GetField()->GetTyp())->GetDoc(); + SwDocShell* pDocShell = pDoc->GetDocShell(); + OUString aBasePath = pDocShell->getDocumentBaseURL(); + OUString aAbs + = INetURLObject::GetAbsURL(aBasePath, aText, INetURLObject::EncodeMechanism::WasEncoded, + INetURLObject::DecodeMechanism::WithCharset); + bool bRelative = aAbs != aText; + + INetURLObject aObject(aAbs); if (aObject.GetMark().startsWith("page=")) { aObject.SetMark(OUString()); aText = aObject.GetMainURL(INetURLObject::DecodeMechanism::NONE); } + + if (bRelative) + { + aText + = INetURLObject::GetRelURL(aBasePath, aText, INetURLObject::EncodeMechanism::WasEncoded, + INetURLObject::DecodeMechanism::WithCharset); + } + return aText; } |