From b58777c8b2b2075a071a25bf9fed0ce7fc0c4401 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 10 Aug 2014 22:38:30 +0200 Subject: LOAndroid3: Check if document has been loaded correctly Change-Id: If4ef82fa18aaa8719391773971d0cde07c0fbcce --- .../java/org/libreoffice/LOKitTileProvider.java | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'android') diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java index 5e79a77d46c6..c5e2621a0cb5 100644 --- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java +++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java @@ -14,7 +14,7 @@ import org.mozilla.gecko.gfx.SubTile; import java.nio.ByteBuffer; public class LOKitTileProvider implements TileProvider { - private static final String LOGTAG = LOKitShell.class.getSimpleName(); + private static final String LOGTAG = LOKitTileProvider.class.getSimpleName(); private final LayerController mLayerController; @@ -49,15 +49,28 @@ public class LOKitTileProvider implements TileProvider { mDocument = mOffice.documentLoad(input); - if(mDocument == null) { - Log.e(LOGTAG, "Error: " + mOffice.getError()); - } else { - Log.i(LOGTAG, "Document parts: " + mDocument.getParts()); - if (mDocument.getParts() >= 1) { + if (checkDocument()) { + int parts = mDocument.getParts(); + Log.i(LOGTAG, "Document parts: " + parts); + if (parts >= 1) { mDocument.setPart(0); } + } + } + + private boolean checkDocument() { + if(mDocument == null || !mOffice.getError().isEmpty()) { + Log.e(LOGTAG, "Error at loading: " + mOffice.getError()); + return false; + } + + if (mDocument.getDocumentWidth() == 0 && mDocument.getDocumentHeight() == 0) { + Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError()); + } else { Log.i(LOGTAG, "Document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight()); } + + return true; } @Override -- cgit