summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorMihai Varga <mihai.varga@collabora.com>2015-11-06 14:34:28 +0200
committerMihai Varga <mihai.mv13@gmail.com>2015-11-13 09:55:19 +0200
commit96cd2abd748ed24e5aba50cc4c300cf06e512db3 (patch)
treea1e6636aef83f49a1d9ee81c87d0a9f71c88b5d2 /android
parent249f8b1cc9897ac9666dd5c69dc22fae7586c207 (diff)
LOK: setClientZoom() - sets the client zoom level
We need to know the client's view level to correctly handle the mouse events in calc. PaintTile() set a zoom level that corresponds to the requested tiles and previously postMouseEvent would call SetZoom(1,1). Now we can make use of knowing the client's view level and call SetZoom() with the correct parameters Change-Id: I34b5afcdcc06a671a8ac92c03e87404e42adf4cd Conflicts: sc/source/ui/unoobj/docuno.cxx
Diffstat (limited to 'android')
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/Document.java2
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java13
-rw-r--r--android/source/src/java/org/libreoffice/LOKitTileProvider.java11
-rw-r--r--android/source/src/java/org/libreoffice/TileProvider.java4
-rw-r--r--android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java4
5 files changed, 21 insertions, 13 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 4cc4ba345c04..dcc315faca4c 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -143,6 +143,8 @@ public class Document {
private native int getDocumentTypeNative();
+ public native void setClientZoom(int nTilePixelWidth, int nTilePixelHeight, int nTileTwipWidth, int nTileTwipHeight);
+
private native void saveAs(String url, String format, String options);
private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index a8f4d303293c..978056dab1d7 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -299,17 +299,18 @@ public class LOKitThread extends Thread {
// to handle hyperlinks, enable single tap even in the Viewer
boolean editing = LOKitShell.isEditingEnabled();
+ float zoomFactor = mViewportMetrics.getZoomFactor();
if (touchType.equals("LongPress") && editing) {
mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.TRANSITION);
- mTileProvider.mouseButtonDown(documentCoordinate, 1);
- mTileProvider.mouseButtonUp(documentCoordinate, 1);
- mTileProvider.mouseButtonDown(documentCoordinate, 2);
- mTileProvider.mouseButtonUp(documentCoordinate, 2);
+ mTileProvider.mouseButtonDown(documentCoordinate, 1, zoomFactor);
+ mTileProvider.mouseButtonUp(documentCoordinate, 1, zoomFactor);
+ mTileProvider.mouseButtonDown(documentCoordinate, 2, zoomFactor);
+ mTileProvider.mouseButtonUp(documentCoordinate, 2, zoomFactor);
} else if (touchType.equals("SingleTap")) {
mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.TRANSITION);
- mTileProvider.mouseButtonDown(documentCoordinate, 1);
- mTileProvider.mouseButtonUp(documentCoordinate, 1);
+ mTileProvider.mouseButtonDown(documentCoordinate, 1, zoomFactor);
+ mTileProvider.mouseButtonUp(documentCoordinate, 1, zoomFactor);
} else if (touchType.equals("GraphicSelectionStart") && editing) {
mTileProvider.setGraphicSelectionStart(documentCoordinate);
} else if (touchType.equals("GraphicSelectionEnd") && editing) {
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index f859b7a1bc62..b70e8524ecc3 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -397,10 +397,11 @@ public class LOKitTileProvider implements TileProvider {
}
}
- private void mouseButton(int type, PointF inDocument, int numberOfClicks) {
+ private void mouseButton(int type, PointF inDocument, int numberOfClicks, float zoomFactor) {
int x = (int) pixelToTwip(inDocument.x, mDPI);
int y = (int) pixelToTwip(inDocument.y, mDPI);
+ mDocument.setClientZoom(TILE_SIZE, TILE_SIZE, (int) (mTileWidth / zoomFactor), (int) (mTileHeight / zoomFactor));
mDocument.postMouseEvent(type, x, y, numberOfClicks, Document.MOUSE_BUTTON_LEFT, Document.KEYBOARD_MODIFIER_NONE);
}
@@ -408,16 +409,16 @@ public class LOKitTileProvider implements TileProvider {
* @see TileProvider#mouseButtonDown(android.graphics.PointF, int)
*/
@Override
- public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) {
- mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks);
+ public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks, float zoomFactor) {
+ mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks, zoomFactor);
}
/**
* @see TileProvider#mouseButtonUp(android.graphics.PointF, int)
*/
@Override
- public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) {
- mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks);
+ public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks, float zoomFactor) {
+ mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks, zoomFactor);
}
@Override
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index 3104172ef5cf..0ab5a1f641c9 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -88,7 +88,7 @@ public interface TileProvider {
* @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
* @param numberOfClicks - number of clicks (1 - single click, 2 - double click)
*/
- void mouseButtonDown(PointF documentCoordinate, int numberOfClicks);
+ void mouseButtonDown(PointF documentCoordinate, int numberOfClicks, float zoomFactor);
/**
@@ -107,7 +107,7 @@ public interface TileProvider {
* @param documentCoordinate - coordinate relative to the document where the mouse button should be triggered
* @param numberOfClicks - number of clicks (1 - single click, 2 - double click)
*/
- void mouseButtonUp(PointF documentCoordinate, int numberOfClicks);
+ void mouseButtonUp(PointF documentCoordinate, int numberOfClicks, float zoomFactor);
/**
* Post a UNO command to LOK.
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java b/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
index 35b417593acf..f90580fbee8c 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/ImmutableViewportMetrics.java
@@ -106,6 +106,10 @@ public class ImmutableViewportMetrics {
return new RectF(cssPageRectLeft, cssPageRectTop, cssPageRectRight, cssPageRectBottom);
}
+ public float getZoomFactor() {
+ return zoomFactor;
+ }
+
/*
* Returns the viewport metrics that represent a linear transition between "this" and "to" at
* time "t", which is on the scale [0, 1). This function interpolates all values stored in