diff options
-rw-r--r-- | sw/source/uibase/wrtsh/wrtsh2.cxx | 21 |
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 ); |