[Libreoffice-commits] core.git: 8 commits - android/Bootstrap android/experimental desktop/source sd/source

Tomaž Vajngerl tomaz.vajngerl at collabora.com
Sun Aug 10 13:57:15 PDT 2014


 android/Bootstrap/src/org/libreoffice/kit/Document.java                                   |   24 +
 android/experimental/LOAndroid3/AndroidManifest.xml                                       |    8 
 android/experimental/LOAndroid3/Makefile                                                  |    2 
 android/experimental/LOAndroid3/res/layout/activity_main.xml                              |   38 +-
 android/experimental/LOAndroid3/res/layout/document_part_list_layout.xml                  |   20 +
 android/experimental/LOAndroid3/res/menu/main.xml                                         |    7 
 android/experimental/LOAndroid3/res/values/strings.xml                                    |    1 
 android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartView.java            |   14 
 android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartViewListAdpater.java |   41 ++
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java                  |    6 
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java                 |   33 +-
 android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java           |   41 ++
 android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java     |   80 +++--
 android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java            |   12 
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/GeckoEventListener.java        |   44 --
 android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/WidgetTileLayer.java       |  160 ----------
 desktop/source/lib/lokandroid.cxx                                                         |   16 +
 sd/source/ui/unoidl/unomodel.cxx                                                          |   12 
 18 files changed, 301 insertions(+), 258 deletions(-)

New commits:
commit 310ed3d39936270f085768726277346c325c900f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:58:28 2014 +0200

    copy android-support-v4 from SDK to libs at build
    
    Change-Id: I3adaf26624ffc46b304d35e0588e7253c20cb5ee

diff --git a/android/experimental/LOAndroid3/Makefile b/android/experimental/LOAndroid3/Makefile
index 08e933e..49879c0 100644
--- a/android/experimental/LOAndroid3/Makefile
+++ b/android/experimental/LOAndroid3/Makefile
@@ -19,6 +19,8 @@ build-ant: android_version_setup copy-stuff link-so properties
 #
 # Copy jar files we need
 #
+	cp $(ANDROID_SDK_HOME)/extras/android/support/v4/android-support-v4.jar libs
+
 	for F in java_uno \
 		 juh \
 		 jurt \
commit ba7578401b4fed4df7b255cf23bd674f86953436
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:56:44 2014 +0200

    LOKit: ensure DrawViewShell is available (prevent crash)
    
    Change-Id: Id143f5fabdcb8b7451d750563c76b77f9c3787a3

diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 97de832..79146e9 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -2303,12 +2303,18 @@ void SdXImpressDocument::setPartMode( LibreOfficeKitPartMode ePartMode )
 
 Size SdXImpressDocument::getDocumentSize()
 {
-    SdrPageView* pCurPageView = mpDoc->GetDocSh()->GetViewShell()->GetView()->GetSdrPageView();
+    DrawViewShell* pViewSh = dynamic_cast<DrawViewShell*>(mpDoc->GetDocSh()->GetViewShell());
+    if (!pViewSh)
+    {
+        SAL_WARN("sd", "DrawViewShell not available!");
+        return Size();
+    }
+
+    SdrPageView* pCurPageView = pViewSh->GetView()->GetSdrPageView();
     Size aSize = pCurPageView->GetPageRect().GetSize();
     // Convert the size in 100th mm to TWIP
     // See paintTile above for further info.
-    return Size( convertMm100ToTwip( aSize.getWidth() ),
-                 convertMm100ToTwip( aSize.getHeight() ) );
+    return Size(convertMm100ToTwip(aSize.getWidth()), convertMm100ToTwip(aSize.getHeight()));
 }
 
 
commit b69f5a1857d2dcad4b234ad84cde98b9fd436f90
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:53:21 2014 +0200

    LOAndroid3: Add a side drawer to show available parts (by name)
    
    Use DrawerLayer to show a side drawer with parts of the loaded
    document. The dawer consists of an image (could be changed by a
    thumbnail in the future) and the part name.
    
    Change-Id: I27fb6112d9f11e19f3295ace97103b89816591aa

diff --git a/android/experimental/LOAndroid3/res/layout/activity_main.xml b/android/experimental/LOAndroid3/res/layout/activity_main.xml
index 7b53d58..1d09af9 100644
--- a/android/experimental/LOAndroid3/res/layout/activity_main.xml
+++ b/android/experimental/LOAndroid3/res/layout/activity_main.xml
@@ -1,15 +1,35 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
+<android.support.v4.widget.DrawerLayout
+    android:id="@+id/drawer_layout"
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/main_layout"
-    android:background="#fff"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
+    android:layout_height="fill_parent"
+    android:background="#fff"
+    tools:context=".MainActivity">
 
     <RelativeLayout
-        android:id="@+id/gecko_layout"
-        android:layout_width="fill_parent"
-        android:layout_height="fill_parent"
-        android:layout_weight="1"/>
+        android:layout_width="match_parent"
+        android:layout_height="match_parent">
+
+        <RelativeLayout
+            android:id="@+id/gecko_layout"
+            android:layout_width="fill_parent"
+            android:layout_height="fill_parent"
+            android:layout_weight="1"/>
+
+        <View
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+
+    </RelativeLayout>
+
+    <ListView
+        android:id="@+id/left_drawer"
+        android:layout_width="240dp"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"
+        android:background="#9FFF"
+        android:choiceMode="singleChoice"/>
 
-</LinearLayout>
\ No newline at end of file
+</android.support.v4.widget.DrawerLayout>
diff --git a/android/experimental/LOAndroid3/res/layout/document_part_list_layout.xml b/android/experimental/LOAndroid3/res/layout/document_part_list_layout.xml
new file mode 100644
index 0000000..51ce0e0
--- /dev/null
+++ b/android/experimental/LOAndroid3/res/layout/document_part_list_layout.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:gravity="center_horizontal">
+
+    <ImageView
+        android:id="@+id/image"
+        android:layout_width="128dp"
+        android:layout_height="128dp"/>
+
+    <TextView
+        android:id="@+id/text"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Large Text"
+        android:textAppearance="?android:attr/textAppearanceLarge"/>
+</LinearLayout>
\ No newline at end of file
diff --git a/android/experimental/LOAndroid3/res/menu/main.xml b/android/experimental/LOAndroid3/res/menu/main.xml
index e9709c9..d51872b 100644
--- a/android/experimental/LOAndroid3/res/menu/main.xml
+++ b/android/experimental/LOAndroid3/res/menu/main.xml
@@ -1,8 +1,13 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
-    tools:context="org.libreoffice.MainActivity" >
+    tools:context="org.libreoffice.MainActivity">
+
     <item android:id="@+id/action_settings"
         android:title="@string/action_settings"
         android:orderInCategory="100" />
+
+    <item android:id="@+id/action_list"
+          android:title="@string/action_list"
+          android:orderInCategory="100" />
 </menu>
diff --git a/android/experimental/LOAndroid3/res/values/strings.xml b/android/experimental/LOAndroid3/res/values/strings.xml
index 93431ed..d776082 100644
--- a/android/experimental/LOAndroid3/res/values/strings.xml
+++ b/android/experimental/LOAndroid3/res/values/strings.xml
@@ -3,5 +3,6 @@
 
     <string name="app_name">LibreOffice</string>
     <string name="action_settings">Settings</string>
+    <string name="action_list">Parts</string>
 
 </resources>
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartView.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartView.java
new file mode 100644
index 0000000..436e37e
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartView.java
@@ -0,0 +1,14 @@
+package org.libreoffice;
+
+
+public class DocumentPartView {
+    private String partName;
+
+    public DocumentPartView(String partName) {
+        this.partName = partName;
+    }
+
+    public String getPartName() {
+        return partName;
+    }
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartViewListAdpater.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartViewListAdpater.java
new file mode 100644
index 0000000..5ec49e1
--- /dev/null
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/DocumentPartViewListAdpater.java
@@ -0,0 +1,41 @@
+package org.libreoffice;
+
+import android.app.Activity;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.List;
+
+public class DocumentPartViewListAdpater extends ArrayAdapter<DocumentPartView> {
+    private static final String LOGTAG = DocumentPartViewListAdpater.class.getSimpleName();
+
+    private final Activity activity;
+
+    public DocumentPartViewListAdpater(Activity activity, int resource, List<DocumentPartView> objects) {
+        super(activity, resource, objects);
+        this.activity = activity;
+    }
+
+    @Override
+    public View getView(int position, View view, ViewGroup parent) {
+        if (view == null) {
+            LayoutInflater layoutInflater = activity.getLayoutInflater();
+            view = layoutInflater.inflate(R.layout.document_part_list_layout, null);
+        }
+
+        DocumentPartView documentPartView = getItem(position);
+        TextView textView = (TextView) view.findViewById(R.id.text);
+        textView.setText(documentPartView.getPartName());
+        Log.i(LOGTAG, "getView - " + documentPartView.getPartName());
+
+        ImageView imageView = (ImageView) view.findViewById(R.id.image);
+        imageView.setImageResource(R.drawable.writer);
+
+        return view;
+    }
+}
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
index 4ceeddc..0d44d66 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitShell.java
@@ -1,6 +1,7 @@
 package org.libreoffice;
 
 
+import android.os.Handler;
 import android.util.DisplayMetrics;
 
 public class LOKitShell {
@@ -32,4 +33,9 @@ public class LOKitShell {
     public static void scheduleResumeComposition() {
 
     }
+
+    // Get a Handler for the main java thread
+    public static Handler getMainHandler() {
+        return LibreOfficeMainActivity.mAppContext.mMainHandler;
+    }
 }
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index c5e2621..4758b70 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -55,6 +55,22 @@ public class LOKitTileProvider implements TileProvider {
             if (parts >= 1) {
                 mDocument.setPart(0);
             }
+            for (int i = 0; i < parts; i++) {
+                String partName = mDocument.getPartName(i);
+                if (partName.isEmpty()) {
+                    partName = "Part " + (i + 1);
+                }
+                Log.i(LOGTAG, "Document part " + i + " name:'" + partName + "'");
+                final DocumentPartView partView = new DocumentPartView(partName);
+                LibreOfficeMainActivity.mAppContext.getDocumentPartView().add(partView);
+            }
+
+            LibreOfficeMainActivity.mAppContext.mMainHandler.post(new Runnable() {
+                @Override
+                public void run() {
+                    LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdpater().notifyDataSetChanged();
+                }
+            });
         }
     }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 888db32..c50fba4 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -2,35 +2,53 @@ package org.libreoffice;
 
 import android.app.Activity;
 import android.os.Bundle;
-import android.os.SystemClock;
+import android.os.Handler;
+import android.support.v4.widget.DrawerLayout;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.Menu;
 import android.view.MenuItem;
-import android.widget.LinearLayout;
+import android.widget.ListView;
 import android.widget.RelativeLayout;
 
 import org.mozilla.gecko.gfx.GeckoLayerClient;
 import org.mozilla.gecko.gfx.LayerController;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class LibreOfficeMainActivity extends Activity {
 
     private static final String LOGTAG = "LibreOfficeMainActivity";
     private static final String DEFAULT_DOC_PATH = "/assets/test1.odt";
 
-    private LinearLayout mMainLayout;
-    private RelativeLayout mGeckoLayout;
+    public static LibreOfficeMainActivity mAppContext;
+
     private static LayerController mLayerController;
     private static GeckoLayerClient mLayerClient;
     private static LOKitThread sLOKitThread;
 
-    public static LibreOfficeMainActivity mAppContext;
+    public Handler mMainHandler;
+
+    private DrawerLayout mDrawerLayout;
+    private RelativeLayout mGeckoLayout;
+    private ListView mDrawerList;
+    private List<DocumentPartView> mDocumentPartView = new ArrayList<DocumentPartView>();
+    private DocumentPartViewListAdpater mDocumentPartViewListAdpater;
+
+    public static GeckoLayerClient getLayerClient() {
+        return mLayerClient;
+    }
+
+    public static LayerController getLayerController() {
+        return mLayerController;
+    }
 
     @Override
     public boolean onCreateOptionsMenu(Menu menu) {
         // Inflate the menu; this adds items to the action bar if it is present.
         getMenuInflater().inflate(R.menu.main, menu);
-        return true;
+        return super.onCreateOptionsMenu(menu);
     }
 
     @Override
@@ -45,36 +63,47 @@ public class LibreOfficeMainActivity extends Activity {
         return super.onOptionsItemSelected(item);
     }
 
+    @Override
+    public boolean onPrepareOptionsMenu(Menu menu) {
+        // If the nav drawer is open, hide action items related to the content view
+        boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList);
+        menu.findItem(R.id.action_list).setVisible(!drawerOpen);
+        return super.onPrepareOptionsMenu(menu);
+    }
+
     public DisplayMetrics getDisplayMetrics() {
         DisplayMetrics metrics = new DisplayMetrics();
         getWindowManager().getDefaultDisplay().getMetrics(metrics);
         return metrics;
     }
 
-    /**
-     * Called when the activity is first created.
-     */
     @Override
     public void onCreate(Bundle savedInstanceState) {
         mAppContext = this;
 
+        mMainHandler = new Handler();
+
         super.onCreate(savedInstanceState);
 
-        Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
+        String inputFile;
 
-        String inputFile = new String();
         if (getIntent().getData() != null) {
             inputFile = getIntent().getData().getEncodedPath();
-        }
-        else {
+        } else {
             inputFile = DEFAULT_DOC_PATH;
         }
 
         setContentView(R.layout.activity_main);
 
-        // setup gecko layout
+        getActionBar().setDisplayHomeAsUpEnabled(false);
+        getActionBar().setHomeButtonEnabled(false);
+
         mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
-        mMainLayout = (LinearLayout) findViewById(R.id.main_layout);
+        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+        mDrawerList = (ListView) findViewById(R.id.left_drawer);
+
+        mDocumentPartViewListAdpater = new DocumentPartViewListAdpater(this, R.layout.document_part_list_layout, mDocumentPartView);
+        mDrawerList.setAdapter(mDocumentPartViewListAdpater);
 
         if (mLayerController == null) {
             mLayerController = new LayerController(this);
@@ -90,19 +119,28 @@ public class LibreOfficeMainActivity extends Activity {
         sLOKitThread = new LOKitThread(inputFile);
         sLOKitThread.start();
 
-        Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - UI almost up");
+        Log.w(LOGTAG, "UI almost up");
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
     }
 
     public LOKitThread getLOKitThread() {
         return sLOKitThread;
     }
 
-    public static GeckoLayerClient getLayerClient() {
-        return mLayerClient;
+    public List<DocumentPartView> getDocumentPartView() {
+        return mDocumentPartView;
     }
-
-    public static LayerController getLayerController() {
-        return mLayerController;
+    public DocumentPartViewListAdpater getDocumentPartViewListAdpater() {
+        return mDocumentPartViewListAdpater;
     }
 }
 
diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
index 1515d9c..e7ced82 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/MockTileProvider.java
@@ -15,6 +15,18 @@ public class MockTileProvider implements TileProvider {
     public MockTileProvider(LayerController layerController, String inputFile) {
         this.layerController = layerController;
         this.inputFile = inputFile;
+
+        for (int i = 0; i < 5; i++) {
+            String partName = "Part " + i;
+            DocumentPartView partView = new DocumentPartView(partName);
+            LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdpater().add(partView);
+        }
+        LibreOfficeMainActivity.mAppContext.mMainHandler.post(new Runnable() {
+            @Override
+            public void run() {
+                LibreOfficeMainActivity.mAppContext.getDocumentPartViewListAdpater().notifyDataSetChanged();
+            }
+        });
     }
 
     @Override
commit 5af2c260488f04696f01adcf26c24036820f96ff
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:42:39 2014 +0200

    LOAndroid3: correctly calculate the tile view rect
    
    Because the tile view rect wasn't correctly calculated, some tiles
    were deleted and in the same call immediately created again. With
    this fix the performance increases.
    Additionally inflate tile view rect by one tile to minimize the
    undrawn tiles when scrolling.
    
    Change-Id: I4b5b2bb31dd4f55babf87503dd37e396f6a5e200

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
index a195da0..d56f451 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitThread.java
@@ -21,6 +21,7 @@ public class LOKitThread extends Thread {
     private TileProvider mTileProvider;
     private ViewportMetrics mViewportMetrics;
     private String mInputFile;
+    private Rect mOldRect;
 
     LOKitThread(String inputFile) {
         mInputFile = inputFile;
@@ -40,7 +41,22 @@ public class LOKitThread extends Thread {
         return new Rect(minX, minY, maxX, maxY);
     }
 
+    Rect inflate(Rect rect, int inflateSize) {
+        Rect newRect = new Rect(rect);
+        newRect.left -= inflateSize;
+        newRect.left = newRect.left < 0 ? 0 : newRect.left;
+
+        newRect.top -= inflateSize;
+        newRect.top = newRect.top < 0 ? 0 : newRect.top;
+
+        newRect.right += inflateSize;
+        newRect.bottom += inflateSize;
+
+        return newRect;
+    }
+
     private boolean draw() throws InterruptedException {
+        Log.i(LOGTAG, "tilerender draw");
         int pageWidth = mTileProvider.getPageWidth();
         int pageHeight = mTileProvider.getPageHeight();
 
@@ -56,18 +72,25 @@ public class LOKitThread extends Thread {
 
         ViewportMetrics metrics = mApplication.getLayerController().getViewportMetrics();
         RectF viewport = normlizeRect(metrics);
-        Rect rect = roundToTileSize(viewport, TILE_SIZE);
+        Rect rect = inflate(roundToTileSize(viewport, TILE_SIZE), TILE_SIZE);
+
+        mOldRect = rect;
+
+        Log.i(LOGTAG, "tilerender rect: " + rect);
 
         ArrayList<SubTile> removeTiles = new ArrayList<SubTile>();
         for (SubTile tile : layerClient.getTiles()) {
-            if (!rect.intersects(tile.x, tile.y, tile.x + TILE_SIZE, tile.y + TILE_SIZE)) {
+            Rect tileRect = new Rect(tile.x, tile.y, tile.x + TILE_SIZE, tile.y + TILE_SIZE);
+            if (!Rect.intersects(rect, tileRect)) {
+                Log.i(LOGTAG, "tilerender delete " + tileRect);
                 removeTiles.add(tile);
             }
         }
+
         layerClient.getTiles().removeAll(removeTiles);
 
-        for (int y = rect.top; y <= rect.bottom; y += TILE_SIZE) {
-            for (int x = rect.left; x <= rect.right; x += TILE_SIZE) {
+        for (int y = rect.top; y < rect.bottom; y += TILE_SIZE) {
+            for (int x = rect.left; x < rect.right; x += TILE_SIZE) {
                 if (x > pageWidth) {
                     continue;
                 }
@@ -88,7 +111,7 @@ public class LOKitThread extends Thread {
         }
 
         layerClient.endDrawing();
-
+        Log.i(LOGTAG, "tilerender end draw");
         return true;
     }
 
commit b58777c8b2b2075a071a25bf9fed0ce7fc0c4401
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:38:30 2014 +0200

    LOAndroid3: Check if document has been loaded correctly
    
    Change-Id: If4ef82fa18aaa8719391773971d0cde07c0fbcce

diff --git a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
index 5e79a77..c5e2621 100644
--- a/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/experimental/LOAndroid3/src/java/org/libreoffice/LOKitTileProvider.java
@@ -14,7 +14,7 @@ import org.mozilla.gecko.gfx.SubTile;
 import java.nio.ByteBuffer;
 
 public class LOKitTileProvider implements TileProvider {
-    private static final String LOGTAG = LOKitShell.class.getSimpleName();
+    private static final String LOGTAG = LOKitTileProvider.class.getSimpleName();
 
     private final LayerController mLayerController;
 
@@ -49,15 +49,28 @@ public class LOKitTileProvider implements TileProvider {
 
         mDocument = mOffice.documentLoad(input);
 
-        if(mDocument == null) {
-            Log.e(LOGTAG, "Error: " + mOffice.getError());
-        } else {
-            Log.i(LOGTAG, "Document parts: " + mDocument.getParts());
-            if (mDocument.getParts() >= 1) {
+        if (checkDocument()) {
+            int parts = mDocument.getParts();
+            Log.i(LOGTAG, "Document parts: " + parts);
+            if (parts >= 1) {
                 mDocument.setPart(0);
             }
+        }
+    }
+
+    private boolean checkDocument() {
+        if(mDocument == null || !mOffice.getError().isEmpty()) {
+            Log.e(LOGTAG, "Error at loading: " + mOffice.getError());
+            return false;
+        }
+
+        if (mDocument.getDocumentWidth() == 0 && mDocument.getDocumentHeight() == 0) {
+            Log.e(LOGTAG, "Document size zero - last error: " + mOffice.getError());
+        } else {
             Log.i(LOGTAG, "Document size: " + mDocument.getDocumentWidth() + " x " + mDocument.getDocumentHeight());
         }
+
+        return true;
     }
 
     @Override
commit c1b793d501de2c13bd75d28420af4ea772ab336a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:28:59 2014 +0200

    LOAndroid3: remove unused GeckoEventListener and WidgetTileLayer
    
    Change-Id: Id5c245d308221975f4071c96fb275c41348dce68

diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/GeckoEventListener.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/GeckoEventListener.java
deleted file mode 100644
index 670513f..0000000
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/GeckoEventListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Android code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2009-2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Sriram Ramasubramanian <sriram at mozilla.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-package org.mozilla.gecko;
-
-import org.json.JSONObject;
-
-public interface GeckoEventListener {
-    public void handleMessage(String event, JSONObject message);
-}
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/WidgetTileLayer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/WidgetTileLayer.java
deleted file mode 100644
index b123d55..0000000
--- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/WidgetTileLayer.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Android code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2009-2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   James Willcox <jwillcox at mozilla.com>
- *   Arkady Blyakher <rkadyb at mit.edu>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-package org.mozilla.gecko.gfx;
-
-import org.libreoffice.LOKitShell;
-import org.mozilla.gecko.gfx.LayerController;
-import org.mozilla.gecko.gfx.SingleTileLayer;
-//import org.mozilla.gecko.GeckoAppShell;
-import android.graphics.RectF;
-import android.util.Log;
-import android.opengl.GLES20;
-import java.nio.FloatBuffer;
-
-/**
- * Encapsulates the logic needed to draw the single-tiled Gecko texture
- */
-public class WidgetTileLayer extends Layer {
-    private static final String LOGTAG = "WidgetTileLayer";
-
-    private int[] mTextureIDs;
-    private CairoImage mImage;
-
-    public WidgetTileLayer(CairoImage image) {
-        mImage = image;
-    }
-
-    protected boolean initialized() { return mTextureIDs != null; }
-
-    @Override
-    public IntSize getSize() { return mImage.getSize(); }
-
-    protected void bindAndSetGLParameters() {
-        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[0]);
-        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
-        GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
-    }
-
-    @Override
-    protected void finalize() throws Throwable {
-        if (mTextureIDs != null)
-            TextureReaper.get().add(mTextureIDs);
-    }
-
-    @Override
-    protected boolean performUpdates(RenderContext context) {
-        super.performUpdates(context);
-
-        if (mTextureIDs == null) {
-            mTextureIDs = new int[1];
-            GLES20.glGenTextures(1, mTextureIDs, 0);
-        }
-
-        bindAndSetGLParameters();
-        LOKitShell.bindWidgetTexture();
-
-        return true;
-    }
-
-    @Override
-    public void draw(RenderContext context) {
-        // mTextureIDs may be null here during startup if Layer.java's draw method
-        // failed to acquire the transaction lock and call performUpdates.
-        if (!initialized())
-            return;
-
-        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTextureIDs[0]);
-
-        RectF bounds;
-        int[] cropRect;
-        IntSize size = getSize();
-        RectF viewport = context.viewport;
-
-        bounds = getBounds(context, new FloatSize(size));
-        cropRect = new int[] { 0, 0, size.width, size.height };
-        bounds.offset(-viewport.left, -viewport.top);
-
-        float top = viewport.height() - (bounds.top + bounds.height());
-
-        // There may be errors from a previous GL call, so clear them first because
-        // we want to check for one below
-        while (GLES20.glGetError() != GLES20.GL_NO_ERROR);
-
-        float[] coords = {
-                //x, y, z, texture_x, texture_y
-                bounds.left/viewport.width(), top/viewport.height(), 0,
-                cropRect[0]/size.width, cropRect[1]/size.height,
-
-                bounds.left/viewport.width(), (top+bounds.height())/viewport.height(), 0,
-                cropRect[0]/size.width, cropRect[3]/size.height,
-
-                (bounds.left+bounds.width())/viewport.width(), top/viewport.height(), 0,
-                cropRect[2]/size.width, cropRect[1]/size.height,
-
-                (bounds.left+bounds.width())/viewport.width(), (top+bounds.height())/viewport.height(),
-                0,
-                cropRect[2]/size.width, cropRect[3]/size.height
-        };
-
-        // Get the buffer and handles from the context
-        FloatBuffer coordBuffer = context.coordBuffer;
-        int positionHandle = context.positionHandle;
-        int textureHandle = context.textureHandle;
-
-        // Make sure we are at position zero in the buffer in case other draw methods did not clean
-        // up after themselves
-        coordBuffer.position(0);
-        coordBuffer.put(coords);
-
-        // Vertex coordinates are x,y,z starting at position 0 into the buffer.
-        coordBuffer.position(0);
-        GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20, coordBuffer);
-
-        // Texture coordinates are texture_x, texture_y starting at position 3 into the buffer.
-        coordBuffer.position(3);
-        GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20, coordBuffer);
-        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
-
-        int error = GLES20.glGetError();
-        if (error != GLES20.GL_NO_ERROR) {
-            Log.i(LOGTAG, "Failed to draw texture: " + error);
-        }
-    }
-}
-
commit d8f5616f1ab7c9ba03552403b77cc60faa5a2fbf
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:17:54 2014 +0200

    LOAndroid3: increase SDK level
    
    Change-Id: Ice1c975cce2de98a0c02b0772c07278648a0088d

diff --git a/android/experimental/LOAndroid3/AndroidManifest.xml b/android/experimental/LOAndroid3/AndroidManifest.xml
index f4c122c..635e399 100644
--- a/android/experimental/LOAndroid3/AndroidManifest.xml
+++ b/android/experimental/LOAndroid3/AndroidManifest.xml
@@ -6,9 +6,8 @@
     android:versionName="1.0">
 
     <!-- App requires OpenGL ES 2.0 -->
-    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11"/>
-
     <uses-feature android:glEsVersion="0x00020000" android:required="true" />
+    <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="17"/>
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 
     <application
@@ -17,9 +16,9 @@
         android:icon="@drawable/main"
         android:label="@string/app_name"
         android:hardwareAccelerated="true"
-        android:theme="@style/AppTheme" >
+        android:theme="@style/AppTheme">
         <activity
-            android:name="LibreOfficeMainActivity"
+            android:name="org.libreoffice.LibreOfficeMainActivity"
             android:label="@string/app_name" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -71,4 +70,5 @@
             </intent-filter>
         </activity>
     </application>
+
 </manifest>
commit 81f1c259275a43308636d8e9a4c48e67eadaae60
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date:   Sun Aug 10 22:16:24 2014 +0200

    LOKit android: add support for setPartMode and getPartName
    
    Change-Id: Idd8bd4d4b148e88c7badd06fefb7cfcfc24ec9ea

diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 124f768..d0d30f1 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -12,21 +12,35 @@ package org.libreoffice.kit;
 import java.nio.ByteBuffer;
 
 public class Document {
+    public static final int PART_MODE_DEFAULT = 0;
+    public static final int PART_MODE_SLIDE = 1;
+    public static final int PART_MODE_NOTES = 2;
+    public static final int PART_MODE_SLIDENOTES = 3;
+    public static final int PART_MODE_EMBEDDEDOBJ = 4;
 
     private final long handle;
 
-    public native void setPart(int part);
+    public Document(long handle) {
+        this.handle = handle;
+    }
+
     public native int getPart();
+
+    public native void setPart(int partIndex);
+
     public native int getParts();
+
+    public native String getPartName(int partIndex);
+
+    public native void setPartMode(int partMode);
+
     public native long getDocumentHeight();
+
     public native long getDocumentWidth();
 
     private native int getDocumentTypeNative();
-    private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
 
-    public Document(long handle) {
-        this.handle = handle;
-    }
+    private native void paintTileNative(ByteBuffer buffer, int canvasWidth, int canvasHeight, int tilePositionX, int tilePositionY, int tileWidth, int tileHeight);
 
     public int getDocumentType() {
         return getDocumentTypeNative();
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 68ebfdf..16e7217 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -89,6 +89,22 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Document_getPart
     return (jint) pDocument->pClass->getParts(pDocument);
 }
 
+extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Document_getPartName
+    (JNIEnv* pEnv, jobject aObject, jint nPartIndex)
+{
+    LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+    char* pPartName = pDocument->pClass->getPartName(pDocument, nPartIndex);
+    return pEnv->NewStringUTF(pPartName);
+}
+
+extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setPartMode
+    (JNIEnv* pEnv, jobject aObject, jint nPartMode)
+{
+    LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+
+    pDocument->pClass->setPartMode(pDocument, (LibreOfficeKitPartMode) nPartMode);
+}
+
 extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Document_getDocumentTypeNative
     (JNIEnv* pEnv, jobject aObject)
 {


More information about the Libreoffice-commits mailing list