diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 19cb3c318986..5f25660c0d3f 100644 --- a/svx/source/unodraw/unoshap4.cxx +++ b/svx/source/unodraw/unoshap4.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -822,6 +823,17 @@ bool SvxMediaShape::setPropertyValueImpl( const OUString& rName, const SfxItemPr if( rValue >>= aURL ) { bOk = true; + if ( aURL.startsWith("file:///") && !comphelper::DirectoryHelper::fileExists(aURL) ) + { + comphelper::IEmbeddedHelper* pPersist = GetSdrObject()->getSdrModelFromSdrObject().GetPersist(); + auto fileDirectoryEndIdx = pPersist->getDocumentBaseURL().lastIndexOf("/"); + auto fileNameStartIdx = aURL.lastIndexOf("/"); + if (fileDirectoryEndIdx != -1 && fileNameStartIdx != -1) + { + aURL = OUString::Concat(pPersist->getDocumentBaseURL().subView(0, fileDirectoryEndIdx + 1)) + + aURL.subView(fileNameStartIdx + 1); + } + } aItem.setURL( aURL, u""_ustr, referer_ ); } }