[Libreoffice-commits] core.git: Branch 'private/swe/libreoffice-5-2+backports' - 2 commits - sw/source writerfilter/source
Stephan Bergmann
sbergman at redhat.com
Tue Nov 21 21:39:28 UTC 2017
sw/source/uibase/wrtsh/wrtsh2.cxx | 21 +++++++++++++++++++--
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 22 ++++++++++++++++++++++
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 1 +
3 files changed, 42 insertions(+), 2 deletions(-)
New commits:
commit 8fc756f2ac76727419a987feac68eb752832676d
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Aug 17 11:36:10 2016 +0200
tdf#86087: Convert relative URLs to absolute upon import of docx etc.
...to fix the import part of tdf#86087. Apparently, "fragment-only" relative
same-document URLs (like <#anchor>) are supposed to remain relative; otherwise,
various tests like testFdo69548::Import in CppunitTest_sw_ooxmlimport fail.
(cherry picked from commit 0dd82f4ffe7ae462bae30b93d245d2234c55ef84)
Change-Id: I2dbba2f2f1e225f85e21600e68a3c4cffdb023b2
Reviewed-on: https://gerrit.libreoffice.org/45048
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index c5ca29a02510..142739559a6f 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -69,6 +69,7 @@
#include <com/sun/star/text/XTextColumns.hpp>
#include <oox/mathml/import.hxx>
+#include <rtl/uri.hxx>
#include <GraphicHelpers.hxx>
#include <dmapper/GraphicZOrderHelper.hxx>
@@ -245,6 +246,13 @@ DomainMapper_Impl::DomainMapper_Impl(
m_vTextFramesForChaining(),
m_bParaHadField(false)
{
+ m_aBaseUrl = rMediaDesc.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_DOCUMENTBASEURL(), OUString());
+ if (m_aBaseUrl.isEmpty()) {
+ m_aBaseUrl = rMediaDesc.getUnpackedValueOrDefault(
+ utl::MediaDescriptor::PROP_URL(), OUString());
+ }
+
appendTableManager( );
GetBodyText();
uno::Reference< text::XTextAppend > xBodyTextAppend( m_xBodyText, uno::UNO_QUERY );
@@ -3890,6 +3898,20 @@ void DomainMapper_Impl::CloseFieldCommand()
if (!sURL.isEmpty())
{
+ // Try to make absolute any relative URLs, except
+ // for relative same-document URLs that only contain
+ // a fragment part:
+ if (!sURL.startsWith("#")) {
+ try {
+ sURL = rtl::Uri::convertRelToAbs(
+ m_aBaseUrl, sURL);
+ } catch (rtl::MalformedUriException & e) {
+ SAL_WARN(
+ "writerfilter.dmapper",
+ "MalformedUriException "
+ << e.getMessage());
+ }
+ }
pContext->SetHyperlinkURL(sURL);
}
}
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 49b61d261b61..4886ad1e3800 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -394,6 +394,7 @@ public:
private:
SourceDocumentType m_eDocumentType;
DomainMapper& m_rDMapper;
+ OUString m_aBaseUrl;
css::uno::Reference<css::text::XTextDocument> m_xTextDocument;
css::uno::Reference<css::beans::XPropertySet> m_xDocumentSettings;
css::uno::Reference<css::lang::XMultiServiceFactory> m_xTextFactory;
commit 4680b23cd82cece4ecdae3e90e0ce524ab5ad732
Author: Szymon Kłos <szymon.klos at collabora.com>
Date: Tue Nov 14 19:29:33 2017 +0100
tdf#86087 Open relative links in Writer
(cherry picked from commit 4b9e237850efe36f7e35d65e14d6953f1e1f3a45)
Change-Id: I3f6caad559d92ec559b8ae1c66e7fea13f52cb76
Reviewed-on: https://gerrit.libreoffice.org/45047
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 0bb22aa093d9..ba873876e833 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -516,10 +516,27 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, sal_uInt16 nFilter,
if ( dynamic_cast<const SwCursorShell*>( &rVSh) == nullptr )
return;
+ OUString sFileURL = rURL;
+ INetURLObject aURL( sFileURL );
+ if( aURL.GetProtocol() == INetProtocol::NotValid && !sFileURL.startsWith("#") )
+ {
+ // May be the relative link -> try to convert to absolute path
+ OUString sParentPath =
+ rVSh.GetDoc()->GetDocShell()->GetMedium()->GetURLObject().GetPath();
+
+ bool bCorrectURL = true;
+ aURL = INetURLObject();
+ bCorrectURL &= aURL.setFSysPath( sParentPath, INetURLObject::FSYS_DETECT );
+ bCorrectURL &= aURL.insertName( sFileURL );
+
+ if( bCorrectURL )
+ sFileURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+ }
+
// We are doing tiledRendering, let the client handles the URL loading.
if (comphelper::LibreOfficeKit::isActive())
{
- rVSh.libreOfficeKitCallback(LOK_CALLBACK_HYPERLINK_CLICKED, rURL.toUtf8().getStr());
+ rVSh.libreOfficeKitCallback(LOK_CALLBACK_HYPERLINK_CLICKED, sFileURL.toUtf8().getStr());
return;
}
@@ -544,7 +561,7 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, sal_uInt16 nFilter,
sReferer = pDShell->GetMedium()->GetName();
SfxViewFrame* pViewFrame = rSh.GetView().GetViewFrame();
SfxFrameItem aView( SID_DOCFRAME, pViewFrame );
- SfxStringItem aName( SID_FILE_NAME, rURL );
+ SfxStringItem aName( SID_FILE_NAME, sFileURL );
SfxStringItem aTargetFrameName( SID_TARGETNAME, sTargetFrame );
SfxStringItem aReferer( SID_REFERER, sReferer );
More information about the Libreoffice-commits
mailing list