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