Kaydet (Commit) dbd72b9e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

android: reset document dimensions when changing document part

Change-Id: I2f7967ee20ad71b58e2b0dc7f182769499910373
üst 240c6d90
......@@ -80,6 +80,7 @@ public class LOKitTileProvider implements TileProvider {
Log.i(LOGTAG, "Document part " + i + " name:'" + partName + "'");
mDocument.setPart(i);
resetDocumentSize();
final DocumentPartView partView = new DocumentPartView(i, partName, thumbnail(128));
LibreOfficeMainActivity.mAppContext.getDocumentPartView().add(partView);
}
......@@ -127,20 +128,28 @@ public class LOKitTileProvider implements TileProvider {
return false;
}
mWidthTwip = mDocument.getDocumentWidth();
mHeightTwip = mDocument.getDocumentHeight();
if (mWidthTwip == 0 || mHeightTwip == 0) {
Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError());
boolean result = resetDocumentSize();
if (!result) {
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
LibreOfficeMainActivity.mAppContext.showAlertDialog("Document has no size!");
LibreOfficeMainActivity.mAppContext.showAlertDialog("Document returned an invalid size or the document is empty!");
}
});
}
return result;
}
private boolean resetDocumentSize() {
mWidthTwip = mDocument.getDocumentWidth();
mHeightTwip = mDocument.getDocumentHeight();
if (mWidthTwip == 0 || mHeightTwip == 0) {
Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError());
return false;
} else {
Log.i(LOGTAG, "Document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight());
Log.i(LOGTAG, "Reset document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight());
}
return true;
......@@ -235,5 +244,6 @@ public class LOKitTileProvider implements TileProvider {
@Override
public void changePart(int partIndex) {
mDocument.setPart(partIndex);
resetDocumentSize();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment