android/source/src/java/org/libreoffice/LOKitTileProvider.java |   18 
++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

New commits:
commit 174229e4797b27eb795c6f2451ab1349c2c29ad8
Author: Mert Tümer <merttum...@gmail.com>
Date:   Tue Mar 20 23:15:28 2018 +0300

    tdf#116152 fix unsupported url exception on Android Viewer
    
    Change-Id: I39233369e754919aeb0dc46856a3746f33e89e9b
    Signed-off-by: Mert Tümer <merttum...@gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/51675
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java 
b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index 4a8720cb9d01..addbc16a9cf7 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -23,6 +23,9 @@ import org.mozilla.gecko.gfx.BufferedCairoImage;
 import org.mozilla.gecko.gfx.CairoImage;
 import org.mozilla.gecko.gfx.IntSize;
 
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.nio.ByteBuffer;
 
 /**
@@ -67,7 +70,16 @@ class LOKitTileProvider implements TileProvider {
         mInputFile = input;
 
         Log.i(LOGTAG, "====> Loading file '" + input + "'");
-        mDocument = mOffice.documentLoad(input);
+        File fileToBeEncoded = new File(input);
+        String encodedFileName = "";
+        try {
+            encodedFileName = 
URLEncoder.encode(fileToBeEncoded.getName(),"UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+        mDocument = mOffice.documentLoad(
+                (new 
File(fileToBeEncoded.getParent(),encodedFileName)).getPath()
+        );
 
         if (mDocument == null && !mContext.isPasswordProtected()) {
             Log.i(LOGTAG, "====> mOffice.documentLoad() returned null, trying 
to restart 'Office' and loading again");
@@ -80,7 +92,9 @@ class LOKitTileProvider implements TileProvider {
             mOffice.setMessageCallback(messageCallback);
             
mOffice.setOptionalFeatures(Document.LOK_FEATURE_DOCUMENT_PASSWORD);
             Log.i(LOGTAG, "====> setup Lokit callback and optional features 
(password support)");
-            mDocument = mOffice.documentLoad(input);
+            mDocument = mOffice.documentLoad(
+                    (new 
File(fileToBeEncoded.getParent(),encodedFileName)).getPath()
+            );
         }
 
         Log.i(LOGTAG, "====> mDocument = " + mDocument);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to