summaryrefslogtreecommitdiff
path: root/android/source/src/java/org/libreoffice/InvalidationHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/source/src/java/org/libreoffice/InvalidationHandler.java')
-rw-r--r--android/source/src/java/org/libreoffice/InvalidationHandler.java66
1 files changed, 56 insertions, 10 deletions
diff --git a/android/source/src/java/org/libreoffice/InvalidationHandler.java b/android/source/src/java/org/libreoffice/InvalidationHandler.java
index 32e9b56656dd..c48127cce67f 100644
--- a/android/source/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/source/src/java/org/libreoffice/InvalidationHandler.java
@@ -25,12 +25,12 @@ import java.util.List;
* Parses (interprets) and handles invalidation messages from LibreOffice.
*/
public class InvalidationHandler implements Document.MessageCallback, Office.MessageCallback {
- private static String LOGTAG = InvalidationHandler.class.getSimpleName();
+ private static final String LOGTAG = InvalidationHandler.class.getSimpleName();
private final DocumentOverlay mDocumentOverlay;
private final GeckoLayerClient mLayerClient;
private OverlayState mState;
private boolean mKeyEvent = false;
- private LibreOfficeMainActivity mContext;
+ private final LibreOfficeMainActivity mContext;
private int currentTotalPageNumber = 0; // total page number of the current document
@@ -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;
@@ -139,7 +143,7 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
JSONObject payloadObject = new JSONObject(payload);
if (payloadObject.getString("commandName").equals(".uno:Save")) {
if (payloadObject.getString("success").equals("true")) {
- mContext.saveFilesToCloud();
+ mContext.saveFileToOriginalSource();
}
}else if(payloadObject.getString("commandName").equals(".uno:Name") ||
payloadObject.getString("commandName").equals(".uno:RenamePage")){
@@ -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
*
@@ -330,7 +342,7 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
mContext.getFormattingController().onToggleStateChanged(Document.NUMBERED_LIST, pressed);
} else if (parts[0].equals(".uno:Color")) {
mContext.getFontController().colorPaletteListener.updateColorPickerPosition(Integer.parseInt(value));
- } else if (mContext.getTileProvider().isTextDocument() && parts[0].equals(".uno:BackColor")) {
+ } else if (mContext.getTileProvider().isTextDocument() && (parts[0].equals(".uno:BackColor") || parts[0].equals(".uno:CharBackColor"))) {
mContext.getFontController().backColorPaletteListener.updateColorPickerPosition(Integer.parseInt(value));
} else if (mContext.getTileProvider().isPresentation() && parts[0].equals(".uno:CharBackColor")) {
mContext.getFontController().backColorPaletteListener.updateColorPickerPosition(Integer.parseInt(value));
@@ -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)
);
}
@@ -505,7 +551,7 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
changeStateTo(OverlayState.TRANSITION);
}
mDocumentOverlay.changeSelections(Collections.<RectF>emptyList());
- if (mContext.isSpreadsheet()) {
+ if (mContext.getTileProvider().isSpreadsheet()) {
mDocumentOverlay.showHeaderSelection(null);
}
mContext.getToolbarController().showHideClipboardCutAndCopy(false);
@@ -516,7 +562,7 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
}
changeStateTo(OverlayState.SELECTION);
mDocumentOverlay.changeSelections(rectangles);
- if (mContext.isSpreadsheet()) {
+ if (mContext.getTileProvider().isSpreadsheet()) {
mDocumentOverlay.showHeaderSelection(rectangles.get(0));
}
String selectedText = mContext.getTileProvider().getTextSelection("");