[Libreoffice-commits] core.git: android/source

Mert Tümer merttumer7 at gmail.com
Tue Mar 13 23:43:37 UTC 2018


 android/source/src/java/org/libreoffice/InvalidationHandler.java |    9 +++++++++
 android/source/src/java/org/libreoffice/LOEvent.java             |    9 +++++++++
 android/source/src/java/org/libreoffice/LOKitThread.java         |    8 ++++++++
 android/source/src/java/org/libreoffice/LOKitTileProvider.java   |    6 ++++++
 android/source/src/java/org/libreoffice/TileProvider.java        |    6 ++++++
 5 files changed, 38 insertions(+)

New commits:
commit 7105ad16e7e7bfde4193dc174568ebb8a293cc87
Author: Mert Tümer <merttumer7 at gmail.com>
Date:   Mon Jan 8 12:07:44 2018 +0300

    [Pardus] tdf#107026 render the new page without reopen the document
    
    This patch is sponsored by ULAKBIM/Pardus project.
    Signed-off-by: Mert Tümer <merttumer7 at gmail.com>
    
    Change-Id: I91c902bfd1acc5cc70ad30f16e0719e7a325702b
    Reviewed-on: https://gerrit.libreoffice.org/47636
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/android/source/src/java/org/libreoffice/InvalidationHandler.java b/android/source/src/java/org/libreoffice/InvalidationHandler.java
index 6c582550ff81..eb22f6c8f3d3 100644
--- a/android/source/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/source/src/java/org/libreoffice/InvalidationHandler.java
@@ -113,6 +113,8 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
             case Document.CALLBACK_DOCUMENT_PASSWORD:
                 documentPassword();
                 break;
+            case Document.CALLBACK_DOCUMENT_SIZE_CHANGED:
+                pageSizeChanged(payload);
             default:
                 Log.d(LOGTAG, "LOK_CALLBACK uncaught: " + messageID + " : " + payload);
         }
@@ -231,6 +233,13 @@ public class InvalidationHandler implements Document.MessageCallback, Office.Mes
         LOKitShell.moveViewportTo(mContext, new PointF(newLeft, newTop), newZoom);
     }
 
+    private void pageSizeChanged(String payload){
+        String[] bounds = payload.split(",");
+        int pageWidth = Integer.parseInt(bounds[0]);
+        int pageHeight = Integer.parseInt(bounds[1].trim());
+        LOKitShell.sendEvent(new LOEvent(LOEvent.PAGE_SIZE_CHANGED, pageWidth, pageHeight));
+    }
+
     private void stateChanged(String payload) {
         String[] parts = payload.split("=");
         if (parts.length < 2) {
diff --git a/android/source/src/java/org/libreoffice/LOEvent.java b/android/source/src/java/org/libreoffice/LOEvent.java
index 4d081e61c0f2..979d8ba29ed7 100644
--- a/android/source/src/java/org/libreoffice/LOEvent.java
+++ b/android/source/src/java/org/libreoffice/LOEvent.java
@@ -40,6 +40,7 @@ public class LOEvent implements Comparable<LOEvent> {
     public static final int UPDATE_ZOOM_CONSTRAINTS = 19;
     public static final int UPDATE_CALC_HEADERS = 20;
     public static final int REFRESH = 21;
+    public static final int PAGE_SIZE_CHANGED = 22;
 
     public final int mType;
     public int mPriority = 0;
@@ -57,6 +58,8 @@ public class LOEvent implements Comparable<LOEvent> {
     public RectF mInvalidationRect;
     public SelectionHandle.HandleType mHandleType;
     public String mValue;
+    public int mPageWidth;
+    public int mPageHeight;
 
     public LOEvent(int type) {
         mType = type;
@@ -139,6 +142,12 @@ public class LOEvent implements Comparable<LOEvent> {
         mDocumentCoordinate = documentCoordinate;
     }
 
+    public LOEvent(int type, int pageWidth, int pageHeight){
+        mType = type;
+        mPageWidth = pageWidth;
+        mPageHeight = pageHeight;
+    }
+
     public String getTypeString() {
         if (mTypeString == null) {
             return "Event type: " + mType;
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index c4146fcb6b29..63f49dc6253f 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -175,6 +175,11 @@ class LOKitThread extends Thread {
         mContext.getDocumentOverlay().setPartPageRectangles(partPageRectangles);
     }
 
+    private void updatePageSize(int pageWidth, int pageHeight){
+        mTileProvider.setDocumentSize(pageWidth, pageHeight);
+        redraw();
+    }
+
     private void updateZoomConstraints() {
         if (mTileProvider == null) return;
         mLayerClient = mContext.getLayerClient();
@@ -364,6 +369,9 @@ class LOKitThread extends Thread {
             case LOEvent.REFRESH:
                 refresh();
                 break;
+            case LOEvent.PAGE_SIZE_CHANGED:
+                updatePageSize(event.mPageWidth, event.mPageHeight);
+                break;
         }
     }
 
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index 24456ebf9cb1..4a8720cb9d01 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -367,6 +367,12 @@ class LOKitTileProvider implements TileProvider {
         return true;
     }
 
+    @Override
+    public void setDocumentSize(int pageWidth, int pageHeight){
+        mWidthTwip = pageWidth;
+        mHeightTwip = pageHeight;
+    }
+
     /**
      * @see TileProvider#getPageWidth()
      */
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index 609fb62c708a..10d578337680 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -13,6 +13,7 @@ import android.graphics.Bitmap;
 import android.graphics.PointF;
 import android.view.KeyEvent;
 
+import org.libreoffice.kit.Document;
 import org.mozilla.gecko.gfx.CairoImage;
 import org.mozilla.gecko.gfx.IntSize;
 
@@ -162,6 +163,11 @@ public interface TileProvider {
      * Send a request to change end the change of graphic selection..
      */
     void setGraphicSelectionEnd(PointF documentCoordinate);
+
+    /**
+     * Set the new page size of the document when changed
+     */
+    void setDocumentSize(int pageWidth, int pageHeight);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list