diff options
-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); |