Kaydet (Commit) e71b15cc authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl Kaydeden (comit) Miklos Vajna

tdf#87098 don't adjust zoom/position for spreadsheets

Change-Id: Ieb908980a931b123e2c48fe3ecdc7830b48810ed
üst 57697340
...@@ -63,16 +63,27 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation ...@@ -63,16 +63,27 @@ public class LOKitThread extends Thread implements TileProvider.TileInvalidation
mViewportMetrics = mLayerClient.getViewportMetrics(); mViewportMetrics = mLayerClient.getViewportMetrics();
mLayerClient.setViewportMetrics(mViewportMetrics); mLayerClient.setViewportMetrics(mViewportMetrics);
if (mTileProvider.isTextDocument()) { zoomAndRepositionTheDocument();
mLayerClient.forceRedraw();
}
private void zoomAndRepositionTheDocument() {
if (mTileProvider.isSpreadsheet()) {
// Don't do anything for spreadsheets - show at 100%
} else if (mTileProvider.isTextDocument()) {
// Always zoom text document to the beginning of the document and centered by width
float centerY = mViewportMetrics.getCssViewport().centerY(); float centerY = mViewportMetrics.getCssViewport().centerY();
mLayerClient.zoomTo(new RectF (0, centerY, mTileProvider.getPageWidth(), centerY)); mLayerClient.zoomTo(new RectF(0, centerY, mTileProvider.getPageWidth(), centerY));
} else if (mViewportMetrics.getViewport().width() < mViewportMetrics.getViewport().height()) {
mLayerClient.zoomTo(mTileProvider.getPageWidth(), 0);
} else { } else {
mLayerClient.zoomTo(0, mTileProvider.getPageHeight()); // Other documents - always show the whole document on the screen,
// regardless of document shape and orientation.
if (mViewportMetrics.getViewport().width() < mViewportMetrics.getViewport().height()) {
mLayerClient.zoomTo(mTileProvider.getPageWidth(), 0);
} else {
mLayerClient.zoomTo(0, mTileProvider.getPageHeight());
}
} }
mLayerClient.forceRedraw();
} }
/** Invalidate everything + handle the geometry change */ /** Invalidate everything + handle the geometry change */
......
...@@ -270,6 +270,11 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback ...@@ -270,6 +270,11 @@ public class LOKitTileProvider implements TileProvider, Document.MessageCallback
return mDocument != null && mDocument.getDocumentType() == Document.DOCTYPE_TEXT; return mDocument != null && mDocument.getDocumentType() == Document.DOCTYPE_TEXT;
} }
@Override
public boolean isSpreadsheet() {
return mDocument != null && mDocument.getDocumentType() == Document.DOCTYPE_SPREADSHEET;
}
/** /**
* Register the tile invalidation callback. * Register the tile invalidation callback.
*/ */
......
...@@ -84,6 +84,11 @@ public class MockTileProvider implements TileProvider { ...@@ -84,6 +84,11 @@ public class MockTileProvider implements TileProvider {
return true; return true;
} }
@Override
public boolean isSpreadsheet() {
return false;
}
@Override @Override
public void registerInvalidationCallback(TileInvalidationCallback tileInvalidationCallback) { public void registerInvalidationCallback(TileInvalidationCallback tileInvalidationCallback) {
} }
......
...@@ -53,6 +53,11 @@ public interface TileProvider { ...@@ -53,6 +53,11 @@ public interface TileProvider {
*/ */
boolean isTextDocument(); boolean isTextDocument();
/**
* Returns true if the current open document is a spreadsheet.
*/
boolean isSpreadsheet();
/** /**
* Register a callback that is invoked when a tile invalidation is * Register a callback that is invoked when a tile invalidation is
* required. * required.
......
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