From 68f3bc4d183e56e09975c3e41aceaeba95ddac46 Mon Sep 17 00:00:00 2001 From: Jan Holesovsky Date: Fri, 3 Jul 2015 18:14:31 +0200 Subject: [PATCH 065/398] LOK: Don't try to absolutize URL's. Based on a patch by Henry Castro. (cherry picked from commit e83cb37cf7546e8bc46d0d49b487dcd352b67093) Change-Id: Ia7aca20feb8f6095adf7dfe510ed78b1e9882740 --- desktop/source/lib/init.cxx | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index aa8e27c7f48f..c08f1eec85de 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -166,23 +166,19 @@ static OUString getUString(const char* pString) static OUString getAbsoluteURL(const char* pURL) { OUString aURL(getUString(pURL)); - if (aURL.isEmpty()) + + // return unchanged if it likely is an URL already + if (aURL.indexOf("://") > 0) return aURL; - // convert relative paths to absolute ones - OUString aWorkingDir; - osl_getProcessWorkingDir(&aWorkingDir.pData); - if (!aWorkingDir.endsWith("/")) - aWorkingDir += "/"; + OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl; - try { - return rtl::Uri::convertRelToAbs(aWorkingDir, aURL); - } - catch (const rtl::MalformedUriException &) - { - } + // convert relative paths to absolute ones + osl_getProcessWorkingDir(&sWorkingDir.pData); + osl::FileBase::getFileURLFromSystemPath( aURL, sDocPathUrl ); + osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl); - return OUString(); + return sAbsoluteDocUrl; } extern "C" @@ -354,12 +350,6 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, SolarMutexGuard aGuard; OUString aURL(getAbsoluteURL(pURL)); - if (aURL.isEmpty()) - { - pLib->maLastExceptionMsg = "Filename to load was not provided."; - SAL_INFO("lok", "URL for load is empty"); - return NULL; - } pLib->maLastExceptionMsg.clear(); @@ -426,12 +416,6 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha OUString sFormat = getUString(pFormat); OUString aURL(getAbsoluteURL(sUrl)); - if (aURL.isEmpty()) - { - gImpl->maLastExceptionMsg = "Filename to save to was not provided."; - SAL_INFO("lok", "URL for save is empty"); - return false; - } try { -- 2.12.0