summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2017-11-14 19:29:33 +0100
committerSzymon Kłos <szymon.klos@collabora.com>2017-11-19 18:16:55 +0100
commit4b9e237850efe36f7e35d65e14d6953f1e1f3a45 (patch)
tree46281518c46207cce740c84c6bd68156aeb58d4f /sw
parentf9d1de6c7b135e36ae23095029d6dbaa044d881e (diff)
tdf#86087 Open relative links in Writer
Change-Id: I3f6caad559d92ec559b8ae1c66e7fea13f52cb76 Reviewed-on: https://gerrit.libreoffice.org/44734 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/wrtsh/wrtsh2.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index 011f96d17d71..5076f8604bd9 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -514,10 +514,27 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags 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, FSysStyle::Detect );
+ bCorrectURL &= aURL.insertName( sFileURL );
+
+ if( bCorrectURL )
+ sFileURL = aURL.GetMainURL( INetURLObject::DecodeMechanism::WithCharset );
+ }
+
// We are doing tiledRendering, let the client handles the URL loading.
if (comphelper::LibreOfficeKit::isActive())
{
- rVSh.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, rURL.toUtf8().getStr());
+ rVSh.GetSfxViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_HYPERLINK_CLICKED, sFileURL.toUtf8().getStr());
return;
}
@@ -542,7 +559,7 @@ void LoadURL( SwViewShell& rVSh, const OUString& rURL, LoadUrlFlags 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 );