diff options
author | Mert Tümer <merttumer7@gmail.com> | 2018-03-20 23:15:28 +0300 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2018-03-27 15:23:54 +0200 |
commit | 174229e4797b27eb795c6f2451ab1349c2c29ad8 (patch) | |
tree | 4dbc59dd7faea20adeb7de61f2bb7116cdd0bece /android | |
parent | e97ab52a83d2440ca42c85229ef794549208cb7d (diff) |
tdf#116152 fix unsupported url exception on Android Viewer
Change-Id: I39233369e754919aeb0dc46856a3746f33e89e9b
Signed-off-by: Mert Tümer <merttumer7@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/51675
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/LOKitTileProvider.java | 18 |
1 files changed, 16 insertions, 2 deletions
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); |