summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorIlhan Yesil <ilhanyesil@gmx.de>2021-05-31 15:10:47 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2021-09-03 11:45:21 +0200
commite72a7368b368a822d2400ee7db60312226ad3195 (patch)
tree6ca2bc8fffc68e219bb27cfe530c4817ecc69c02 /android
parentclang-tidy:readability-redundant-member-init (diff)
downloadcore-e72a7368b368a822d2400ee7db60312226ad3195.tar.gz
core-e72a7368b368a822d2400ee7db60312226ad3195.zip
tdf#131548 Android: jump to cell
Added LOK_CALLBACK_SC_FOLLOW_JUMP: fire this signal to jump to cell cursor in android viewer. Payload format same as LOK_CALLBACK_INVALIDATE_TILES. Change-Id: Ic896baccf1327d6ccdf104811446e3454a42679e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116448 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'android')
-rw-r--r--android/Bootstrap/src/org/libreoffice/kit/Document.java1
-rw-r--r--android/source/src/java/org/libreoffice/InvalidationHandler.java54
2 files changed, 51 insertions, 4 deletions
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 69f8f76c3eb4..ed7208da5924 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -92,6 +92,7 @@ public class Document {
public static final int CALLBACK_COMMENT = 32;
public static final int CALLBACK_INVALIDATE_HEADER = 33;
public static final int CALLBACK_CELL_ADDRESS = 34;
+ public static final int CALLBACK_SC_FOLLOW_JUMP = 52;
/**
* Set text selection types
diff --git a/android/source/src/java/org/libreoffice/InvalidationHandler.java b/android/source/src/java/org/libreoffice/InvalidationHandler.java
index d74f150bfb44..0f3f1dd7b889 100644
--- a/android/source/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/source/src/java/org/libreoffice/InvalidationHandler.java
@@ -55,6 +55,7 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
&& messageID != Document.CALLBACK_DOCUMENT_PASSWORD
&& messageID != Document.CALLBACK_HYPERLINK_CLICKED
&& messageID != Document.CALLBACK_SEARCH_RESULT_SELECTION
+ && messageID != Document.CALLBACK_SC_FOLLOW_JUMP
&& messageID != Document.CALLBACK_TEXT_SELECTION
&& messageID != Document.CALLBACK_TEXT_SELECTION_START
&& messageID != Document.CALLBACK_TEXT_SELECTION_END)
@@ -114,6 +115,9 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
case Document.CALLBACK_CELL_CURSOR:
invalidateCellCursor(payload);
break;
+ case Document.CALLBACK_SC_FOLLOW_JUMP:
+ jumpToCell(payload);
+ break;
case Document.CALLBACK_INVALIDATE_HEADER:
invalidateHeader();
break;
@@ -214,6 +218,14 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
}
}
+ private void jumpToCell(String payload) {
+ RectF cellCursorRect = convertPayloadCellToRectangle(payload);
+
+ if (cellCursorRect != null) {
+ moveViewportToMakeSelectionVisible(cellCursorRect);
+ }
+ }
+
/**
* Handles the search result selection message, which is a JSONObject
*
@@ -368,6 +380,40 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
if (coordinates.length != 4) {
return null;
}
+ return convertPayloadToRectangle(coordinates);
+ }
+
+ /**
+ * Parses the payload text with rectangle coordinates and converts to rectangle in pixel coordinates
+ *
+ * @param payload - invalidation message payload text
+ * @return rectangle in pixel coordinates
+ */
+ public RectF convertPayloadCellToRectangle(String payload) {
+ String payloadWithoutWhitespace = payload.replaceAll("\\s", ""); // remove all whitespace from the string
+
+ if (payloadWithoutWhitespace.isEmpty() || payloadWithoutWhitespace.equals("EMPTY")) {
+ return null;
+ }
+
+ String[] coordinates = payloadWithoutWhitespace.split(",");
+
+ if (coordinates.length != 6 ) {
+ return null;
+ }
+ return convertPayloadToRectangle(coordinates);
+ }
+
+ /**
+ * Converts rectangle coordinates to rectangle in pixel coordinates
+ *
+ * @param coordinates - the first four items defines the rectangle
+ * @return rectangle in pixel coordinates
+ */
+ public RectF convertPayloadToRectangle(String[] coordinates) {
+ if (coordinates.length < 4 ) {
+ return null;
+ }
int x = Integer.decode(coordinates[0]);
int y = Integer.decode(coordinates[1]);
@@ -377,10 +423,10 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
float dpi = LOKitShell.getDpi(mContext);
return new RectF(
- LOKitTileProvider.twipToPixel(x, dpi),
- LOKitTileProvider.twipToPixel(y, dpi),
- LOKitTileProvider.twipToPixel(x + width, dpi),
- LOKitTileProvider.twipToPixel(y + height, dpi)
+ LOKitTileProvider.twipToPixel(x, dpi),
+ LOKitTileProvider.twipToPixel(y, dpi),
+ LOKitTileProvider.twipToPixel(x + width, dpi),
+ LOKitTileProvider.twipToPixel(y + height, dpi)
);
}