[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 4 commits - android/Bootstrap android/source desktop/source

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Wed Oct 21 11:14:17 PDT 2015


 android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java |   51 ---
 android/source/build.gradle                                          |    4 
 android/source/src/java/org/libreoffice/MockTileProvider.java        |  157 ----------
 android/source/src/java/org/libreoffice/TileProviderFactory.java     |   15 
 desktop/source/lib/init.cxx                                          |   19 -
 desktop/source/lib/lokandroid.cxx                                    |   28 -
 6 files changed, 19 insertions(+), 255 deletions(-)

New commits:
commit 9f5606a2c409991c5bf5954b08e1b1ed7c214fe7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Wed Oct 21 15:14:32 2015 +0200

    android: remove MockTileProvider
    
    Change-Id: I1b44c9fa4edfdc79e48f52ba95493f83f0421669
    (cherry picked from commit 075c4db2844146dd861a77c8d51fb8ac675f520f)

diff --git a/android/source/src/java/org/libreoffice/MockTileProvider.java b/android/source/src/java/org/libreoffice/MockTileProvider.java
deleted file mode 100644
index 19f7b48..0000000
--- a/android/source/src/java/org/libreoffice/MockTileProvider.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-package org.libreoffice;
-
-import android.graphics.Bitmap;
-import android.graphics.PointF;
-import android.view.KeyEvent;
-
-import org.mozilla.gecko.gfx.BufferedCairoImage;
-import org.mozilla.gecko.gfx.CairoImage;
-import org.mozilla.gecko.gfx.GeckoLayerClient;
-import org.mozilla.gecko.gfx.IntSize;
-
-public class MockTileProvider implements TileProvider {
-    private static final int TILE_SIZE = 256;
-    private final GeckoLayerClient mLayerClient;
-    private final String inputFile;
-
-    public MockTileProvider(GeckoLayerClient layerClient, String input) {
-        mLayerClient = layerClient;
-        this.inputFile = input;
-
-        for (int i = 0; i < 5; i++) {
-            String partName = "Part " + i;
-            final DocumentPartView partView = new DocumentPartView(i, partName);
-            LibreOfficeMainActivity.mAppContext.mMainHandler.post(new Runnable() {
-                @Override
-                public void run() {
-                    LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdapter().add(partView);
-                }
-            });
-        }
-        LibreOfficeMainActivity.mAppContext.mMainHandler.post(new Runnable() {
-            @Override
-            public void run() {
-                LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdapter().notifyDataSetChanged();
-            }
-        });
-    }
-
-    @Override
-    public int getPageWidth() {
-        return 549;
-    }
-
-    @Override
-    public int getPageHeight() {
-        return 630 * 5;
-    }
-
-    @Override
-    public boolean isReady() {
-        return true;
-    }
-
-    @Override
-    public CairoImage createTile(float x, float y, IntSize tileSize, float zoom) {
-        int tiles = (int) (getPageWidth() / TILE_SIZE) + 1;
-        int tileNumber = (int) ((y / TILE_SIZE) * tiles + (x / TILE_SIZE));
-        tileNumber %= 9;
-        tileNumber += 1; // 0 to 1 based numbering
-
-        String imageName = "d" + tileNumber;
-        Bitmap bitmap = mLayerClient.getView().getDrawable(imageName);
-
-        return new BufferedCairoImage(bitmap);
-    }
-
-    @Override
-    public void rerenderTile(CairoImage image, float x, float y, IntSize tileSize, float zoom) {
-    }
-
-    @Override
-    public Bitmap thumbnail(int size) {
-        return mLayerClient.getView().getDrawable("dummy_page");
-    }
-
-    @Override
-    public void close() {
-    }
-
-    @Override
-    public boolean isTextDocument() {
-        return true;
-    }
-
-    @Override
-    public boolean isSpreadsheet() {
-        return false;
-    }
-
-    @Override
-    public void sendKeyEvent(KeyEvent keyEvent) {
-    }
-
-    @Override
-    public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) {
-    }
-
-    @Override
-    public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) {
-    }
-
-    @Override
-    public void postUnoCommand(String command) {
-    }
-
-    @Override
-    public void setTextSelectionStart(PointF documentCoordinate) {
-    }
-
-    @Override
-    public void setTextSelectionEnd(PointF documentCoordinate) {
-    }
-
-    @Override
-    public void setTextSelectionReset(PointF documentCoordinate) {
-    }
-
-    @Override
-    public void setGraphicSelectionStart(PointF documentCoordinate) {
-    }
-
-    @Override
-    public void setGraphicSelectionEnd(PointF documentCoordinate) {
-    }
-
-    @Override
-    public void changePart(int partIndex) {
-    }
-
-    @Override
-    public int getCurrentPartNumber() {
-        return 0;
-    }
-
-    @Override
-    public int getPartsCount() {
-        return 0;
-    }
-
-    @Override
-    public void onSwipeLeft() {
-    }
-
-    @Override
-    public void onSwipeRight() {
-    }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/android/source/src/java/org/libreoffice/TileProviderFactory.java b/android/source/src/java/org/libreoffice/TileProviderFactory.java
index 003a714..45b10a9 100644
--- a/android/source/src/java/org/libreoffice/TileProviderFactory.java
+++ b/android/source/src/java/org/libreoffice/TileProviderFactory.java
@@ -16,27 +16,16 @@ import org.mozilla.gecko.gfx.GeckoLayerClient;
  * Create a desired instance of TileProvider.
  */
 public class TileProviderFactory {
-    private static TileProviderID currentTileProvider = TileProviderID.LOKIT;
 
     private TileProviderFactory() {
     }
 
     public static void initialize() {
-        if (currentTileProvider == TileProviderID.LOKIT) {
-            LibreOfficeKit.initializeLibrary();
-        }
+        LibreOfficeKit.initializeLibrary();
     }
 
     public static TileProvider create(GeckoLayerClient layerClient, InvalidationHandler invalidationHandler, String filename) {
-        if (currentTileProvider == TileProviderID.LOKIT) {
-            return new LOKitTileProvider(layerClient, invalidationHandler, filename);
-        } else {
-            return new MockTileProvider(layerClient, filename);
-        }
-    }
-
-    private enum TileProviderID {
-        MOCK, LOKIT
+         return new LOKitTileProvider(layerClient, invalidationHandler, filename);
     }
 }
 
commit e1ab55f23b68c2907e35d0d1764f71d614cd72b2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Wed Oct 21 12:42:03 2015 +0200

    android: remove the native DirectBufferAllocator
    
    Change-Id: I41d25d288253f1b35c268ba70b8384812fa567e5
    (cherry picked from commit c8dcec92470745f07c51074404ce4250428f2255)

diff --git a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
index de90303..99cb3a4 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/DirectBufferAllocator.java
@@ -5,14 +5,12 @@
 
 package org.libreoffice.kit;
 
-//
-// We must manually allocate direct buffers in JNI to work around a bug where Honeycomb's
-// ByteBuffer.allocateDirect() grossly overallocates the direct buffer size.
-// https://code.google.com/p/android/issues/detail?id=16941
-//
-
 import java.nio.ByteBuffer;
 
+/**
+ * This is the common code for allocation and freeing of memory. For this direct ByteBuffer is used but
+ * in the past it was possible to use a JNI version of allocation because of a bug in old Android version.
+ */
 public final class DirectBufferAllocator {
 
     private static final String LOGTAG = DirectBufferAllocator.class.getSimpleName();
@@ -20,46 +18,7 @@ public final class DirectBufferAllocator {
     private DirectBufferAllocator() {
     }
 
-    private static native ByteBuffer allocateDirectBufferNative(int size);
-
-    private static native void freeDirectBufferNative(ByteBuffer aBuffer);
-
     public static ByteBuffer allocate(int size) {
-        return allocateVM(size);
-    }
-
-    public static ByteBuffer free(ByteBuffer buffer) {
-        return freeVM(buffer);
-    }
-
-    private static ByteBuffer allocateJNI(int size) {
-        ByteBuffer directBuffer = allocateDirectBufferNative(size);
-        if (directBuffer == null) {
-            if (size <= 0) {
-                throw new IllegalArgumentException("Invalid allocation size: " + size);
-            } else {
-                throw new OutOfMemoryError("allocateDirectBuffer() returned null");
-            }
-        } else if (!directBuffer.isDirect()) {
-            throw new AssertionError("allocateDirectBuffer() did not return a direct buffer");
-        }
-        return directBuffer;
-    }
-
-    private static ByteBuffer freeJNI(ByteBuffer buffer) {
-        if (buffer == null) {
-            return null;
-        }
-
-        if (!buffer.isDirect()) {
-            throw new IllegalArgumentException("ByteBuffer must be direct");
-        }
-
-        freeDirectBufferNative(buffer);
-        return null;
-    }
-
-    private static ByteBuffer allocateVM(int size) {
         ByteBuffer directBuffer = ByteBuffer.allocateDirect(size);
         if (directBuffer == null) {
             if (size <= 0) {
@@ -74,7 +33,7 @@ public final class DirectBufferAllocator {
         return directBuffer;
     }
 
-    private static ByteBuffer freeVM(ByteBuffer buffer) {
+    public static ByteBuffer free(ByteBuffer buffer) {
         if (buffer == null) {
             return null;
         }
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 1db7945..6142f5a 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -316,32 +316,4 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_resetSe
     pDocument->pClass->resetSelection(pDocument);
 }
 
-/* DirectBufferAllocator */
-
-extern "C" SAL_JNI_EXPORT jobject JNICALL Java_org_libreoffice_kit_DirectBufferAllocator_allocateDirectBufferNative
-    (JNIEnv* pEnv, jclass /*aClass*/, jint nSize)
-{
-    jobject aBuffer = NULL;
-
-    if (nSize > 0)
-    {
-        void* pMemory = malloc(nSize);
-        if (pMemory != NULL)
-        {
-            aBuffer = pEnv->NewDirectByteBuffer(pMemory, nSize);
-            if (aBuffer == NULL)
-            {
-                free(pMemory);
-            }
-        }
-    }
-    return aBuffer;
-}
-
-extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_DirectBufferAllocator_freeDirectBufferNative
-    (JNIEnv* pEnv, jclass, jobject aBuffer)
-{
-    free(pEnv->GetDirectBufferAddress(aBuffer));
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 74dd8be2918bc7931a7494936f951b26cb39a13a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Tue Oct 20 20:39:05 2015 +0200

    android: typo in gradle build script (app crashed on key press)
    
    Change-Id: Icf3973d20455fd9ccde3a448b9596457ef5308a3
    (cherry picked from commit 030891701c2f2d32b7d5848ddc955801560dd081)

diff --git a/android/source/build.gradle b/android/source/build.gradle
index 80772b2..d3c4a1a 100644
--- a/android/source/build.gradle
+++ b/android/source/build.gradle
@@ -169,14 +169,14 @@ task createFullConfig(type: Copy) {
 }
 
 task createStrippedConfig {
-    def preserveDir = file("assets_strippedUI/share/share/config/soffice.cfg/empty")
+    def preserveDir = file("assets_strippedUI/share/config/soffice.cfg/empty")
     outputs.dir "assets_strippedUI"
     outputs.dir "assets_strippedUI/share/registry/res"
     outputs.file preserveDir
 
     doLast {
         file('assets_strippedUI/share/registry/res').mkdirs()
-        file("assets_strippedUI/share/share/config/soffice.cfg").mkdirs()
+        file("assets_strippedUI/share/config/soffice.cfg").mkdirs()
         // just empty file
         preserveDir.text = ""
     }
commit 9845e8e0e3e5c8e02b106a63d5707da8ead60246
Author: Tor Lillqvist <tml at collabora.com>
Date:   Wed Oct 7 21:25:50 2015 +0300

    Make this compile for iOS again
    
    Change-Id: I36f88d7e1114096d1e7a7a1d29077c387c21a10a
    (cherry picked from commit 3c9da1fbfae9c00a5eb9ddcb106a01b075703fcd)

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 49a3352..b7a4252 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -789,15 +789,6 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
 
     pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
                     nTilePosX, nTilePosY, nTileWidth, nTileHeight);
-#else
-    SystemGraphicsData aData;
-    aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer);
-    // the Size argument is irrelevant, I hope
-    ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), (sal_uInt16)0);
-
-    pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
-                    nTilePosX, nTilePosY, nTileWidth, nTileHeight);
-#endif
 
     // Overwrite pBuffer's alpha channel with the separate alpha buffer.
     for (int nRow = 0; nRow < nCanvasHeight; ++nRow)
@@ -810,6 +801,16 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
         }
     }
 
+#else
+    SystemGraphicsData aData;
+    aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer);
+    // the Size argument is irrelevant, I hope
+    ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), (sal_uInt16)0);
+
+    pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
+                    nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+#endif
+
     static bool bDebug = getenv("LOK_DEBUG") != 0;
     if (bDebug)
     {


More information about the Libreoffice-commits mailing list