Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


I would just not go down the troubled road of attempting to support whatever platform-specific file pathname notation in an interface supposedly designed to take URLs (i.e., stop calling osl::FileBase::getFileURLFromSystemPath on aURL), and then---if there is indeed demand to support relative URLs in your interface---use rtl::Uri::convertRelToAbs for reliable conversion, instead of resorting to guesswork like indexOf("://").

On 07/03/2015 06:18 PM, Jan Holesovsky wrote:
commit e83cb37cf7546e8bc46d0d49b487dcd352b67093
Author: Jan Holesovsky <kendy@collabora.com>
Date:   Fri Jul 3 18:14:31 2015 +0200

     LOK: Don't try to absolutize URL's.

     Based on a patch by Henry Castro.

     Change-Id: Ia7aca20feb8f6095adf7dfe510ed78b1e9882740

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index ee47cd8..3a0ce67 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -161,13 +161,18 @@ static OUString getUString(const char* pString)
      return OStringToOUString(sString, RTL_TEXTENCODING_UTF8);
  }

-// Try to convert a relative URL to an absolute one
+/// Try to convert a relative URL to an absolute one, unless it already looks like an URL.
  static OUString getAbsoluteURL(const char* pURL)
  {
-    OUString aURL( getUString( pURL ) );
+    OUString aURL(getUString(pURL));
+
+    // return unchanged if it likely is an URL already
+    if (aURL.indexOf("://") > 0)
+        return aURL;
+
      OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;

-    // FIXME: this would appear to kill non-file URLs.
+    // convert relative paths to absolute ones
      osl_getProcessWorkingDir(&sWorkingDir.pData);
      osl::FileBase::getFileURLFromSystemPath( aURL, sDocPathUrl );
      osl::FileBase::getAbsoluteFileURL(sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
@@ -343,7 +348,7 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis,

      SolarMutexGuard aGuard;

-    OUString aURL = getAbsoluteURL(pURL);
+    OUString aURL(getAbsoluteURL(pURL));

      pLib->maLastExceptionMsg.clear();

@@ -409,7 +414,7 @@ static int doc_saveAs(LibreOfficeKitDocument* pThis, const char* sUrl, const cha
      LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);

      OUString sFormat = getUString(pFormat);
-    OUString aURL = getAbsoluteURL(sUrl);
+    OUString aURL(getAbsoluteURL(sUrl));

      try
      {

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.