From d875b5acdd50588d0d570890bd7eef6abb208199 Mon Sep 17 00:00:00 2001 From: Vladislav Tarakanov Date: Fri, 12 Jul 2024 04:22:21 +0400 Subject: tdf#158510 Launch media from a presentation dir path Added a check for the existence of a file at a given URL. If the specified file could not be found, the path formed from the directory containing the presentation file and the file name is used. Change-Id: Ia4124f4fa5e5cef19c81f325676749a2540e486a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164023 Tested-by: Jenkins Reviewed-by: Mike Kaganski (cherry picked from commit fe897b36aef28dfe175461c43614e22588fcfd84) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170473 Reviewed-by: Xisco Fauli --- svx/source/unodraw/unoshap4.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'svx') diff --git a/svx/source/unodraw/unoshap4.cxx b/svx/source/unodraw/unoshap4.cxx index 58ad9a6b2db0..712c43560803 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_ ); } } -- cgit 1'>distro/collabora/co-2021 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2019-10-04add gbuild function for a common PCH and use it in sc/ and sax/Luboš Luňák
2017-08-01move resmgr to unotoolsCaolán McNamara
2017-07-21migrate to boost::gettextCaolán McNamara
2017-04-21gbuild: Remove MSVC 2013 legacy codeDavid Ostrovsky