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