[Libreoffice-commits] core.git: android/source

Mert Tümer merttumer7 at gmail.com
Tue Mar 27 13:24:59 UTC 2018


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

New commits:
commit 174229e4797b27eb795c6f2451ab1349c2c29ad8
Author: Mert Tümer <merttumer7 at 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 <merttumer7 at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/51675
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at 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);


More information about the Libreoffice-commits mailing list