[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - 9 commits - android/Bootstrap android/source desktop/source include/LibreOfficeKit
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Sun Nov 1 23:58:17 PST 2015
android/Bootstrap/src/fi/iki/tml/CommandLine.java | 176 ---------
android/Bootstrap/src/org/libreoffice/kit/Document.java | 55 ++-
android/Bootstrap/src/org/libreoffice/kit/Office.java | 3
android/source/build.gradle | 1
android/source/res/drawable-hdpi/handle_alias_end.xml | 5
android/source/res/drawable-hdpi/handle_alias_middle.xml | 5
android/source/res/drawable-hdpi/handle_alias_start.xml | 5
android/source/res/drawable-hdpi/handle_image_end.png |binary
android/source/res/drawable-hdpi/handle_image_middle.png |binary
android/source/res/drawable-hdpi/handle_image_start.png |binary
android/source/res/drawable-xhdpi/handle_image_end.png |binary
android/source/res/drawable-xhdpi/handle_image_middle.png |binary
android/source/res/drawable-xhdpi/handle_image_start.png |binary
android/source/res/drawable/handle_end_level.xml | 14
android/source/res/drawable/handle_image_end.png |binary
android/source/res/drawable/handle_image_middle.png |binary
android/source/res/drawable/handle_image_start.png |binary
android/source/res/drawable/handle_start_level.xml | 14
android/source/res/values/colors.xml | 177 +++++-----
android/source/src/java/org/libreoffice/InvalidationHandler.java | 4
android/source/src/java/org/libreoffice/LOEvent.java | 13
android/source/src/java/org/libreoffice/LOKitThread.java | 2
android/source/src/java/org/libreoffice/LOKitTileProvider.java | 16
android/source/src/java/org/libreoffice/TileProvider.java | 2
android/source/src/java/org/libreoffice/canvas/SelectionHandleEnd.java | 2
android/source/src/java/org/libreoffice/canvas/SelectionHandleMiddle.java | 2
android/source/src/java/org/libreoffice/canvas/SelectionHandleStart.java | 2
android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java | 5
android/source/src/java/org/mozilla/gecko/gfx/TextureReaper.java | 23 -
desktop/source/lib/init.cxx | 34 +
desktop/source/lib/lokandroid.cxx | 50 ++
dev/null |binary
include/LibreOfficeKit/LibreOfficeKit.hxx | 5
33 files changed, 272 insertions(+), 343 deletions(-)
New commits:
commit b577b5b505138ecb90e1e9e6405de86b503afd59
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Nov 1 23:28:43 2015 +0100
android: chanhe handles to use alias, tint handles with color
Change-Id: I86ad5eefd70bc8b768780cac66ca466aa0926dc4
(cherry picked from commit 74463457b39c9def1add630b7b0581dc195549c8)
diff --git a/android/source/res/drawable-hdpi/handle_alias_end.xml b/android/source/res/drawable-hdpi/handle_alias_end.xml
new file mode 100644
index 0000000..8319861
--- /dev/null
+++ b/android/source/res/drawable-hdpi/handle_alias_end.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/handle_image_end"
+ android:tint="@color/handle_color"/>
\ No newline at end of file
diff --git a/android/source/res/drawable-hdpi/handle_alias_middle.xml b/android/source/res/drawable-hdpi/handle_alias_middle.xml
new file mode 100644
index 0000000..a8587f6
--- /dev/null
+++ b/android/source/res/drawable-hdpi/handle_alias_middle.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/handle_image_middle"
+ android:tint="@color/handle_color"/>
\ No newline at end of file
diff --git a/android/source/res/drawable-hdpi/handle_alias_start.xml b/android/source/res/drawable-hdpi/handle_alias_start.xml
new file mode 100644
index 0000000..df10470
--- /dev/null
+++ b/android/source/res/drawable-hdpi/handle_alias_start.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
+ android:src="@drawable/handle_image_start"
+ android:tint="@color/handle_color"/>
\ No newline at end of file
diff --git a/android/source/res/drawable-hdpi/handle_end.png b/android/source/res/drawable-hdpi/handle_image_end.png
similarity index 100%
rename from android/source/res/drawable-hdpi/handle_end.png
rename to android/source/res/drawable-hdpi/handle_image_end.png
diff --git a/android/source/res/drawable-hdpi/handle_middle.png b/android/source/res/drawable-hdpi/handle_image_middle.png
similarity index 100%
rename from android/source/res/drawable-hdpi/handle_middle.png
rename to android/source/res/drawable-hdpi/handle_image_middle.png
diff --git a/android/source/res/drawable-hdpi/handle_start.png b/android/source/res/drawable-hdpi/handle_image_start.png
similarity index 100%
rename from android/source/res/drawable-hdpi/handle_start.png
rename to android/source/res/drawable-hdpi/handle_image_start.png
diff --git a/android/source/res/drawable-xhdpi/handle_end.png b/android/source/res/drawable-xhdpi/handle_image_end.png
similarity index 100%
rename from android/source/res/drawable-xhdpi/handle_end.png
rename to android/source/res/drawable-xhdpi/handle_image_end.png
diff --git a/android/source/res/drawable-xhdpi/handle_middle.png b/android/source/res/drawable-xhdpi/handle_image_middle.png
similarity index 100%
rename from android/source/res/drawable-xhdpi/handle_middle.png
rename to android/source/res/drawable-xhdpi/handle_image_middle.png
diff --git a/android/source/res/drawable-xhdpi/handle_start.png b/android/source/res/drawable-xhdpi/handle_image_start.png
similarity index 100%
rename from android/source/res/drawable-xhdpi/handle_start.png
rename to android/source/res/drawable-xhdpi/handle_image_start.png
diff --git a/android/source/res/drawable/handle_end_level.xml b/android/source/res/drawable/handle_end_level.xml
deleted file mode 100644
index 40a512b..0000000
--- a/android/source/res/drawable/handle_end_level.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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/. -->
-
-<level-list xmlns:android="http://schemas.android.com/apk/res/android">
-
- <!-- LTR -->
- <item android:maxLevel="0" android:drawable="@drawable/handle_end"/>
-
- <!-- RTL -->
- <item android:maxLevel="1" android:drawable="@drawable/handle_start"/>
-
-</level-list>
diff --git a/android/source/res/drawable/handle_end.png b/android/source/res/drawable/handle_image_end.png
similarity index 100%
rename from android/source/res/drawable/handle_end.png
rename to android/source/res/drawable/handle_image_end.png
diff --git a/android/source/res/drawable/handle_middle.png b/android/source/res/drawable/handle_image_middle.png
similarity index 100%
rename from android/source/res/drawable/handle_middle.png
rename to android/source/res/drawable/handle_image_middle.png
diff --git a/android/source/res/drawable/handle_start.png b/android/source/res/drawable/handle_image_start.png
similarity index 100%
rename from android/source/res/drawable/handle_start.png
rename to android/source/res/drawable/handle_image_start.png
diff --git a/android/source/res/drawable/handle_start_level.xml b/android/source/res/drawable/handle_start_level.xml
deleted file mode 100644
index 2294513..0000000
--- a/android/source/res/drawable/handle_start_level.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 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/. -->
-
-<level-list xmlns:android="http://schemas.android.com/apk/res/android">
-
- <!-- LTR -->
- <item android:maxLevel="0" android:drawable="@drawable/handle_start"/>
-
- <!-- RTL -->
- <item android:maxLevel="1" android:drawable="@drawable/handle_end"/>
-
-</level-list>
diff --git a/android/source/res/values/colors.xml b/android/source/res/values/colors.xml
index 6321906..3e1cd21 100644
--- a/android/source/res/values/colors.xml
+++ b/android/source/res/values/colors.xml
@@ -91,5 +91,8 @@
<color name="home_last_tab_bar_bg">#FFF5F7F9</color>
<color name="panel_grid_item_image_background">#D1D9E1</color>
+
+ <color name="handle_color">#40A040</color>
+
</resources>
diff --git a/android/source/src/java/org/libreoffice/canvas/SelectionHandleEnd.java b/android/source/src/java/org/libreoffice/canvas/SelectionHandleEnd.java
index 7d4d635..f0b68ee 100644
--- a/android/source/src/java/org/libreoffice/canvas/SelectionHandleEnd.java
+++ b/android/source/src/java/org/libreoffice/canvas/SelectionHandleEnd.java
@@ -9,7 +9,7 @@ import org.libreoffice.R;
*/
public class SelectionHandleEnd extends SelectionHandle {
public SelectionHandleEnd(Context context) {
- super(getBitmapForDrawable(context, R.drawable.handle_end));
+ super(getBitmapForDrawable(context, R.drawable.handle_alias_end));
}
/**
diff --git a/android/source/src/java/org/libreoffice/canvas/SelectionHandleMiddle.java b/android/source/src/java/org/libreoffice/canvas/SelectionHandleMiddle.java
index b7f6e26..409c3f2 100644
--- a/android/source/src/java/org/libreoffice/canvas/SelectionHandleMiddle.java
+++ b/android/source/src/java/org/libreoffice/canvas/SelectionHandleMiddle.java
@@ -9,7 +9,7 @@ import org.libreoffice.R;
*/
public class SelectionHandleMiddle extends SelectionHandle {
public SelectionHandleMiddle(Context context) {
- super(getBitmapForDrawable(context, R.drawable.handle_middle));
+ super(getBitmapForDrawable(context, R.drawable.handle_alias_middle));
}
/**
diff --git a/android/source/src/java/org/libreoffice/canvas/SelectionHandleStart.java b/android/source/src/java/org/libreoffice/canvas/SelectionHandleStart.java
index ac6e089..66b109f 100644
--- a/android/source/src/java/org/libreoffice/canvas/SelectionHandleStart.java
+++ b/android/source/src/java/org/libreoffice/canvas/SelectionHandleStart.java
@@ -9,7 +9,7 @@ import org.libreoffice.R;
*/
public class SelectionHandleStart extends SelectionHandle {
public SelectionHandleStart(Context context) {
- super(getBitmapForDrawable(context, R.drawable.handle_start));
+ super(getBitmapForDrawable(context, R.drawable.handle_alias_start));
}
/**
commit bfa841269d13baa46dbd55fe72371f4fa3ee3e50
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Nov 1 23:17:52 2015 +0100
andorid: use 4 spaces for indent in color.xml
Change-Id: I2435e8ce93383a1a40996a81ef65c1823606609a
(cherry picked from commit d38abe1da2a42bc20a986d43f96142e15c1b3bef)
diff --git a/android/source/res/values/colors.xml b/android/source/res/values/colors.xml
index f8e207d..6321906 100644
--- a/android/source/res/values/colors.xml
+++ b/android/source/res/values/colors.xml
@@ -4,92 +4,92 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<resources>
- <color name="background_light">#FFECF0F3</color>
- <color name="background_normal">#FFCED7DE</color>
- <color name="background_private">#FF292C29</color>
- <color name="background_tabs">#FF363B40</color>
- <color name="highlight">#33000000</color>
- <color name="highlight_focused">#1A000000</color>
- <color name="highlight_dark">#33FFFFFF</color>
- <color name="highlight_dark_focused">#1AFFFFFF</color>
-
- <!-- highlight on shaped button: 20% white over background_tabs -->
- <color name="highlight_shaped">#FF696D71</color>
-
- <!-- highlight-focused on shaped button: 10% white over background_tabs -->
- <color name="highlight_shaped_focused">#FF565B60</color>
-
- <!-- highlight on nav button: 20% black over background_normal -->
- <color name="highlight_nav">#FFA5ACB2</color>
-
- <!-- highlight-focused on nav button: 10% black over background_normal -->
- <color name="highlight_nav_focused">#FFB9C1C7</color>
-
- <!-- highlight on private nav button: 20% white over background_private -->
- <color name="highlight_nav_pb">#FF545654</color>
-
- <!-- highlight-focused on private nav button: 10% white over background_private -->
- <color name="highlight_nav_focused_pb">#FF3F423F</color>
-
- <!--
- Application theme colors
- -->
- <!-- Default colors -->
- <color name="text_color_primary">#222222</color>
- <color name="text_color_secondary">#777777</color>
- <color name="text_color_tertiary">#9198A1</color>
-
- <!-- Default inverse colors -->
- <color name="text_color_primary_inverse">#FFFFFF</color>
- <color name="text_color_secondary_inverse">#DDDDDD</color>
- <color name="text_color_tertiary_inverse">#A4A7A9</color>
-
- <!-- Disabled colors -->
- <color name="text_color_primary_disable_only">#999999</color>
-
- <!-- Hint colors -->
- <color name="text_color_hint">#666666</color>
- <color name="text_color_hint_inverse">#7F828A</color>
-
- <!-- Highlight colors -->
- <color name="text_color_highlight">#FF9500</color>
- <color name="text_color_highlight_inverse">#D06BFF</color>
-
- <!-- Link colors -->
- <color name="text_color_link">#22629E</color>
-
- <color name="splash_background">#000000</color>
- <color name="splash_msgfont">#ffffff</color>
- <color name="splash_urlfont">#000000</color>
- <color name="splash_content">#ffffff</color>
-
- <color name="doorhanger_text">#FF222222</color>
- <color name="doorhanger_link">#FF2AA1FE</color>
- <color name="doorhanger_divider_light">#FFD1D5DA</color>
- <color name="doorhanger_divider_dark">#FFB3C2CE</color>
- <color name="doorhanger_background_dark">#FFDDE4EA</color>
-
- <color name="validation_message_text">#ffffff</color>
- <color name="url_bar_text_highlight">#FFFF9500</color>
- <color name="url_bar_text_highlight_pb">#FFD06BFF</color>
- <color name="suggestion_primary">#dddddd</color>
- <color name="suggestion_pressed">#bbbbbb</color>
- <color name="tab_row_pressed">#4D000000</color>
- <color name="dialogtitle_textcolor">#ffffff</color>
-
- <color name="textbox_background">#FFF</color>
- <color name="textbox_background_disabled">#DDD</color>
- <color name="textbox_stroke">#000</color>
- <color name="textbox_stroke_disabled">#666</color>
-
- <color name="url_bar_urltext">#A6A6A6</color>
- <color name="url_bar_domaintext">#000</color>
- <color name="url_bar_domaintext_private">#FFF</color>
- <color name="url_bar_blockedtext">#b14646</color>
- <color name="url_bar_shadow">#12000000</color>
-
- <color name="home_last_tab_bar_bg">#FFF5F7F9</color>
-
- <color name="panel_grid_item_image_background">#D1D9E1</color>
+ <color name="background_light">#FFECF0F3</color>
+ <color name="background_normal">#FFCED7DE</color>
+ <color name="background_private">#FF292C29</color>
+ <color name="background_tabs">#FF363B40</color>
+ <color name="highlight">#33000000</color>
+ <color name="highlight_focused">#1A000000</color>
+ <color name="highlight_dark">#33FFFFFF</color>
+ <color name="highlight_dark_focused">#1AFFFFFF</color>
+
+ <!-- highlight on shaped button: 20% white over background_tabs -->
+ <color name="highlight_shaped">#FF696D71</color>
+
+ <!-- highlight-focused on shaped button: 10% white over background_tabs -->
+ <color name="highlight_shaped_focused">#FF565B60</color>
+
+ <!-- highlight on nav button: 20% black over background_normal -->
+ <color name="highlight_nav">#FFA5ACB2</color>
+
+ <!-- highlight-focused on nav button: 10% black over background_normal -->
+ <color name="highlight_nav_focused">#FFB9C1C7</color>
+
+ <!-- highlight on private nav button: 20% white over background_private -->
+ <color name="highlight_nav_pb">#FF545654</color>
+
+ <!-- highlight-focused on private nav button: 10% white over background_private -->
+ <color name="highlight_nav_focused_pb">#FF3F423F</color>
+
+ <!--
+ Application theme colors
+ -->
+ <!-- Default colors -->
+ <color name="text_color_primary">#222222</color>
+ <color name="text_color_secondary">#777777</color>
+ <color name="text_color_tertiary">#9198A1</color>
+
+ <!-- Default inverse colors -->
+ <color name="text_color_primary_inverse">#FFFFFF</color>
+ <color name="text_color_secondary_inverse">#DDDDDD</color>
+ <color name="text_color_tertiary_inverse">#A4A7A9</color>
+
+ <!-- Disabled colors -->
+ <color name="text_color_primary_disable_only">#999999</color>
+
+ <!-- Hint colors -->
+ <color name="text_color_hint">#666666</color>
+ <color name="text_color_hint_inverse">#7F828A</color>
+
+ <!-- Highlight colors -->
+ <color name="text_color_highlight">#FF9500</color>
+ <color name="text_color_highlight_inverse">#D06BFF</color>
+
+ <!-- Link colors -->
+ <color name="text_color_link">#22629E</color>
+
+ <color name="splash_background">#000000</color>
+ <color name="splash_msgfont">#ffffff</color>
+ <color name="splash_urlfont">#000000</color>
+ <color name="splash_content">#ffffff</color>
+
+ <color name="doorhanger_text">#FF222222</color>
+ <color name="doorhanger_link">#FF2AA1FE</color>
+ <color name="doorhanger_divider_light">#FFD1D5DA</color>
+ <color name="doorhanger_divider_dark">#FFB3C2CE</color>
+ <color name="doorhanger_background_dark">#FFDDE4EA</color>
+
+ <color name="validation_message_text">#ffffff</color>
+ <color name="url_bar_text_highlight">#FFFF9500</color>
+ <color name="url_bar_text_highlight_pb">#FFD06BFF</color>
+ <color name="suggestion_primary">#dddddd</color>
+ <color name="suggestion_pressed">#bbbbbb</color>
+ <color name="tab_row_pressed">#4D000000</color>
+ <color name="dialogtitle_textcolor">#ffffff</color>
+
+ <color name="textbox_background">#FFF</color>
+ <color name="textbox_background_disabled">#DDD</color>
+ <color name="textbox_stroke">#000</color>
+ <color name="textbox_stroke_disabled">#666</color>
+
+ <color name="url_bar_urltext">#A6A6A6</color>
+ <color name="url_bar_domaintext">#000</color>
+ <color name="url_bar_domaintext_private">#FFF</color>
+ <color name="url_bar_blockedtext">#b14646</color>
+ <color name="url_bar_shadow">#12000000</color>
+
+ <color name="home_last_tab_bar_bg">#FFF5F7F9</color>
+
+ <color name="panel_grid_item_image_background">#D1D9E1</color>
</resources>
commit b3a91cf20bae871ef8438101425d5f176d0b0135
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Nov 1 23:06:09 2015 +0100
android: don't crash in LO when SurfaceView layout is 0 width
Change-Id: I49be19b273d0c263637369e9b095f374b345191b
(cherry picked from commit 37d41674c2b1a706c95c2c326cbfbd06b0c1a655)
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java b/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
index e11c91c..e902a06 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/ComposedTileLayer.java
@@ -149,6 +149,11 @@ public abstract class ComposedTileLayer extends Layer implements ComponentCallba
RectF newViewPort = getViewPort(viewportMetrics);
float newZoom = getZoom(viewportMetrics);
+ // When
+ if (newZoom <= 0.0 || Float.isNaN(newZoom)) {
+ return;
+ }
+
if (currentViewport.equals(newViewPort) && FloatUtils.fuzzyEquals(currentZoom, newZoom)) {
return;
}
commit 7c5580234f785f20db097b49317dc3ff50d26b4f
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Nov 1 22:57:53 2015 +0100
android: don't crash in TextureReaper when Integer is null
Change-Id: I1514aa7a3fbab682b0d282ba0f504470943d7e4a
(cherry picked from commit 9a52bad40ab96a58bc817fbfe1145a6766d75940)
diff --git a/android/source/src/java/org/mozilla/gecko/gfx/TextureReaper.java b/android/source/src/java/org/mozilla/gecko/gfx/TextureReaper.java
index 3063e5b..1a8a504 100644
--- a/android/source/src/java/org/mozilla/gecko/gfx/TextureReaper.java
+++ b/android/source/src/java/org/mozilla/gecko/gfx/TextureReaper.java
@@ -6,6 +6,7 @@
package org.mozilla.gecko.gfx;
import android.opengl.GLES20;
+import android.util.Log;
import java.util.ArrayList;
@@ -14,28 +15,30 @@ import java.util.ArrayList;
*/
public class TextureReaper {
private static TextureReaper sSharedInstance;
- private ArrayList<Integer> mDeadTextureIDs;
+ private ArrayList<Integer> mDeadTextureIDs = new ArrayList<Integer>();
+ private static final String LOGTAG = TextureReaper.class.getSimpleName();
private TextureReaper() {
- mDeadTextureIDs = new ArrayList<Integer>();
}
public static TextureReaper get() {
- if (sSharedInstance == null)
+ if (sSharedInstance == null) {
sSharedInstance = new TextureReaper();
+ }
return sSharedInstance;
}
public void add(int[] textureIDs) {
- for (int textureID : textureIDs)
+ for (int textureID : textureIDs) {
add(textureID);
+ }
}
- public void add(int textureID) {
+ public synchronized void add(int textureID) {
mDeadTextureIDs.add(textureID);
}
- public void reap() {
+ public synchronized void reap() {
int numTextures = mDeadTextureIDs.size();
// Adreno 200 will generate INVALID_VALUE if len == 0 is passed to glDeleteTextures,
// even though it's not supposed to.
@@ -44,7 +47,13 @@ public class TextureReaper {
int[] deadTextureIDs = new int[numTextures];
for (int i = 0; i < numTextures; i++) {
- deadTextureIDs[i] = mDeadTextureIDs.get(i);
+ Integer id = mDeadTextureIDs.get(i);
+ if (id == null) {
+ deadTextureIDs[i] = 0;
+ Log.e(LOGTAG, "Dead texture id is null");
+ } else {
+ deadTextureIDs[i] = mDeadTextureIDs.get(i);
+ }
}
mDeadTextureIDs.clear();
commit 9085b5f6d40031e164d776fcd9daa0305b4e5a23
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Nov 1 22:52:24 2015 +0100
android: update JNI facade, rename mouse/keyboard event flags
Change-Id: Ia2b9a812717d05c7d98d47bf0fe5fd293029d045
(cherry picked from commit 6d9124de6fac2dea39427978993e68155291cc9c)
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Document.java b/android/Bootstrap/src/org/libreoffice/kit/Document.java
index 6c0ee54..669ca94 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Document.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Document.java
@@ -12,12 +12,12 @@ 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;
+ public static final int PART_MODE_SLIDE = 0;
+ public static final int PART_MODE_NOTES = 1;
+ /**
+ * Document types
+ */
public static final int DOCTYPE_TEXT = 0;
public static final int DOCTYPE_SPREADSHEET = 1;
public static final int DOCTYPE_PRESENTATION = 2;
@@ -27,10 +27,15 @@ public class Document {
/**
* Mouse event types
*/
- public static final int MOUSE_BUTTON_DOWN = 0;
- public static final int MOUSE_BUTTON_UP = 1;
- public static final int MOUSE_MOVE = 2;
+ public static final int MOUSE_EVENT_BUTTON_DOWN = 0;
+ public static final int MOUSE_EVENT_BUTTON_UP = 1;
+ public static final int MOUSE_EVENT_MOVE = 2;
+ /**
+ * Key event types
+ */
+ public static final int KEY_EVENT_PRESS = 0;
+ public static final int KEY_EVENT_RELEASE = 1;
/**
* State change types
@@ -40,6 +45,11 @@ public class Document {
public static final int UNDERLINE = 2;
public static final int STRIKEOUT = 3;
+ public static final int ALIGN_LEFT= 4;
+ public static final int ALIGN_CENTER = 5;
+ public static final int ALIGN_RIGHT= 6;
+ public static final int ALIGN_JUSTIFY= 7;
+
/**
* Callback message types
*/
@@ -52,6 +62,13 @@ public class Document {
public static final int CALLBACK_GRAPHIC_SELECTION = 6;
public static final int CALLBACK_HYPERLINK_CLICKED = 7;
public static final int CALLBACK_STATE_CHANGED = 8;
+ public static final int CALLBACK_STATUS_INTICATOR_START = 9;
+ public static final int CALLBACK_STATUS_INTICATOR_SET_VALUE = 10;
+ public static final int CALLBACK_STATUS_INTICATOR_FINISH = 11;
+ public static final int CALLBACK_SEARCH_NOT_FOUND = 12;
+ public static final int CALLBACK_DOCUMENT_SIZE_CHANGED = 13;
+ public static final int CALLBACK_SET_PART = 14;
+ public static final int CALLBACK_SEARCH_RESULT_SELECTION = 15;
/**
* Set text selection types
@@ -66,6 +83,19 @@ public class Document {
public static final int SET_GRAPHIC_SELECTION_START = 0;
public static final int SET_GRAPHIC_SELECTION_END = 1;
+ /**
+ * Mouse button type
+ */
+ public static final int MOUSE_BUTTON_LEFT = 1;
+ public static final int MOUSE_BUTTON_MIDDLE = 2;
+ public static final int MOUSE_BUTTON_RIGHT = 4;
+
+ public static final int KEYBOARD_MODIFIER_NONE = 0x0000;
+ public static final int KEYBOARD_MODIFIER_SHIFT = 0x1000;
+ public static final int KEYBOARD_MODIFIER_MOD1 = 0x2000;
+ public static final int KEYBOARD_MODIFIER_MOD2 = 0x4000;
+ public static final int KEYBOARD_MODIFIER_MOD3 = 0x8000;
+
private final ByteBuffer handle;
private MessageCallback messageCallback = null;
@@ -105,6 +135,8 @@ public class Document {
public native void setPartMode(int partMode);
+ public native String getPartPageRectangles();
+
public native long getDocumentHeight();
public native long getDocumentWidth();
@@ -140,13 +172,14 @@ public class Document {
* @param y - y coordinate
* @param count - number of events
*/
- public native void postMouseEvent(int type, int x, int y, int count);
+ public native void postMouseEvent(int type, int x, int y, int count, int button, int modifier);
/**
* Post a .uno: command to LOK
* @param command - the command, like ".uno:Bold"
+ * @param arguments
*/
- public native void postUnoCommand(String command);
+ public native void postUnoCommand(String command, String arguments);
/**
* Change text selection.
@@ -169,6 +202,8 @@ public class Document {
*/
public native void resetSelection();
+ public native String getCommandValues(String command);
+
/**
* Callback to retrieve messages from LOK
*/
diff --git a/android/Bootstrap/src/org/libreoffice/kit/Office.java b/android/Bootstrap/src/org/libreoffice/kit/Office.java
index 86eda5c..8c616d0 100644
--- a/android/Bootstrap/src/org/libreoffice/kit/Office.java
+++ b/android/Bootstrap/src/org/libreoffice/kit/Office.java
@@ -12,9 +12,6 @@ package org.libreoffice.kit;
import java.nio.ByteBuffer;
public class Office {
- public static final int KEY_PRESS = 0;
- public static final int KEY_RELEASE = 1;
-
private ByteBuffer handle;
public Office(ByteBuffer handle) {
diff --git a/android/source/src/java/org/libreoffice/InvalidationHandler.java b/android/source/src/java/org/libreoffice/InvalidationHandler.java
index 307dcd8..b7f0a5e 100644
--- a/android/source/src/java/org/libreoffice/InvalidationHandler.java
+++ b/android/source/src/java/org/libreoffice/InvalidationHandler.java
@@ -208,7 +208,7 @@ public class InvalidationHandler implements Document.MessageCallback {
float newTop = moveToRect.top;
if (cursorRectangle.right < moveToRect.left || cursorRectangle.left < moveToRect.left) {
- newLeft = cursorRectangle.left - (moveToRect.width() * 0.1f);
+ newLeft = cursorRectangle.left - (moveToRect.width() * 0.1f);
} else if (cursorRectangle.right > moveToRect.right || cursorRectangle.left > moveToRect.right) {
newLeft = cursorRectangle.right - (moveToRect.width() * 0.9f);
}
@@ -306,6 +306,7 @@ public class InvalidationHandler implements Document.MessageCallback {
/**
* Trigger a transition to a new overlay state.
+ *
* @param next - new state to transition to
*/
public synchronized void changeStateTo(OverlayState next) {
@@ -314,6 +315,7 @@ public class InvalidationHandler implements Document.MessageCallback {
/**
* Executes a transition from old overlay state to a new overlay state.
+ *
* @param previous - old state
* @param next - new state
*/
diff --git a/android/source/src/java/org/libreoffice/LOEvent.java b/android/source/src/java/org/libreoffice/LOEvent.java
index 7067714..2155121 100644
--- a/android/source/src/java/org/libreoffice/LOEvent.java
+++ b/android/source/src/java/org/libreoffice/LOEvent.java
@@ -47,6 +47,7 @@ public class LOEvent implements Comparable<LOEvent> {
public KeyEvent mKeyEvent;
public RectF mInvalidationRect;
public SelectionHandle.HandleType mHandleType;
+ public String mValue;
public LOEvent(int type) {
mType = type;
@@ -58,10 +59,18 @@ public class LOEvent implements Comparable<LOEvent> {
mComposedTileLayer = composedTileLayer;
}
- public LOEvent(int type, String filename) {
+ public LOEvent(int type, String someString) {
mType = type;
mTypeString = "String";
- mString = filename;
+ mString = someString;
+ mValue = null;
+ }
+
+ public LOEvent(int type, String key, String value) {
+ mType = type;
+ mTypeString = "key / value";
+ mString = key;
+ mValue = value;
}
public LOEvent(int type, int partIndex) {
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 1a14e7c..5a784c7 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -243,7 +243,7 @@ public class LOKitThread extends Thread {
mInvalidationHandler.changeStateTo(InvalidationHandler.OverlayState.NONE);
break;
case LOEvent.UNO_COMMAND:
- mTileProvider.postUnoCommand(event.mString);
+ mTileProvider.postUnoCommand(event.mString, event.mValue);
break;
}
}
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index 6b7759d..f859b7a 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -388,12 +388,12 @@ public class LOKitTileProvider implements TileProvider {
String keyString = keyEvent.getCharacters();
for (int i = 0; i < keyString.length(); i++) {
int codePoint = keyString.codePointAt(i);
- mDocument.postKeyEvent(Office.KEY_PRESS, codePoint, getKeyCode(keyEvent));
+ mDocument.postKeyEvent(Document.KEY_EVENT_PRESS, codePoint, getKeyCode(keyEvent));
}
} else if (keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
- mDocument.postKeyEvent(Office.KEY_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent));
+ mDocument.postKeyEvent(Document.KEY_EVENT_PRESS, getCharCode(keyEvent), getKeyCode(keyEvent));
} else if (keyEvent.getAction() == KeyEvent.ACTION_UP) {
- mDocument.postKeyEvent(Office.KEY_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent));
+ mDocument.postKeyEvent(Document.KEY_EVENT_RELEASE, getCharCode(keyEvent), getKeyCode(keyEvent));
}
}
@@ -401,7 +401,7 @@ public class LOKitTileProvider implements TileProvider {
int x = (int) pixelToTwip(inDocument.x, mDPI);
int y = (int) pixelToTwip(inDocument.y, mDPI);
- mDocument.postMouseEvent(type, x, y, numberOfClicks);
+ mDocument.postMouseEvent(type, x, y, numberOfClicks, Document.MOUSE_BUTTON_LEFT, Document.KEYBOARD_MODIFIER_NONE);
}
/**
@@ -409,7 +409,7 @@ public class LOKitTileProvider implements TileProvider {
*/
@Override
public void mouseButtonDown(PointF documentCoordinate, int numberOfClicks) {
- mouseButton(Document.MOUSE_BUTTON_DOWN, documentCoordinate, numberOfClicks);
+ mouseButton(Document.MOUSE_EVENT_BUTTON_DOWN, documentCoordinate, numberOfClicks);
}
/**
@@ -417,12 +417,12 @@ public class LOKitTileProvider implements TileProvider {
*/
@Override
public void mouseButtonUp(PointF documentCoordinate, int numberOfClicks) {
- mouseButton(Document.MOUSE_BUTTON_UP, documentCoordinate, numberOfClicks);
+ mouseButton(Document.MOUSE_EVENT_BUTTON_UP, documentCoordinate, numberOfClicks);
}
@Override
- public void postUnoCommand(String command) {
- mDocument.postUnoCommand(command);
+ public void postUnoCommand(String command, String arguments) {
+ mDocument.postUnoCommand(command, arguments);
}
private void setTextSelection(int type, PointF documentCoordinate) {
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index cf9173a..3104172 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -114,7 +114,7 @@ public interface TileProvider {
*
* @param command - the .uno: command, like ".uno:Bold"
*/
- void postUnoCommand(String command);
+ void postUnoCommand(String command, String arguments);
/**
* Send text selection start coordinate.
diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx
index 6142f5a..9d7ce6e 100644
--- a/desktop/source/lib/lokandroid.cxx
+++ b/desktop/source/lib/lokandroid.cxx
@@ -183,6 +183,14 @@ extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Document_getPart
return (jint) pDocument->pClass->getPart(pDocument);
}
+extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Document_getPartPageRectangles
+ (JNIEnv* pEnv, jobject aObject)
+{
+ LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+ char* pRectangles = pDocument->pClass->getPartPageRectangles(pDocument);
+ return pEnv->NewStringUTF(pRectangles);
+}
+
extern "C" SAL_JNI_EXPORT jint JNICALL Java_org_libreoffice_kit_Document_getParts
(JNIEnv* pEnv, jobject aObject)
{
@@ -277,22 +285,27 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postKey
}
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postMouseEvent
- (JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y, jint count)
+ (JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y, jint count, jint button, jint modifier)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
- pDocument->pClass->postMouseEvent(pDocument, type, x, y, count, MOUSE_LEFT, 0);
+ pDocument->pClass->postMouseEvent(pDocument, type, x, y, count, button, modifier);
}
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_postUnoCommand
- (JNIEnv* pEnv, jobject aObject, jstring command)
+ (JNIEnv* pEnv, jobject aObject, jstring command, jstring arguments)
{
LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
const char* pCommand = pEnv->GetStringUTFChars(command, NULL);
+ const char* pArguments = nullptr;
+ if (arguments != NULL)
+ pArguments = pEnv->GetStringUTFChars(arguments, NULL);
- pDocument->pClass->postUnoCommand(pDocument, pCommand, 0);
+ pDocument->pClass->postUnoCommand(pDocument, pCommand, pArguments);
pEnv->ReleaseStringUTFChars(command, pCommand);
+ if (arguments != NULL)
+ pEnv->ReleaseStringUTFChars(arguments, pArguments);
}
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setTextSelection
@@ -302,6 +315,22 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setText
pDocument->pClass->setTextSelection(pDocument, type, x, y);
}
+extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Document_getTextSelection
+ (JNIEnv* pEnv, jobject aObject, jstring mimeType)
+{
+ LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+
+ const char* pMimeType = pEnv->GetStringUTFChars(mimeType, NULL);
+
+ char* pUsedMimeType = 0;
+ char* pSelection = pDocument->pClass->getTextSelection(pDocument, pMimeType, &pUsedMimeType);
+ free(pUsedMimeType);
+
+ pEnv->ReleaseStringUTFChars(mimeType, pMimeType);
+
+ return pEnv->NewStringUTF(pSelection);
+}
+
extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_setGraphicSelection
(JNIEnv* pEnv, jobject aObject, jint type, jint x, jint y)
{
@@ -316,4 +345,17 @@ extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Document_resetSe
pDocument->pClass->resetSelection(pDocument);
}
+extern "C" SAL_JNI_EXPORT jstring JNICALL Java_org_libreoffice_kit_Document_getCommandValues
+ (JNIEnv* pEnv, jobject aObject, jstring command)
+{
+ LibreOfficeKitDocument* pDocument = getHandle<LibreOfficeKitDocument>(pEnv, aObject);
+
+ const char* pCommand = pEnv->GetStringUTFChars(command, NULL);
+
+ char* pValue = pDocument->pClass->getCommandValues(pDocument, pCommand);
+
+ pEnv->ReleaseStringUTFChars(command, pCommand);
+
+ return pEnv->NewStringUTF(pValue);
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 15943cbaf1ec46e86aaad55784822dbddf9ddb87
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Nov 1 22:37:12 2015 +0100
add LOKit interface missing description
Change-Id: Ia9e33704cfffd2094606e6fd166796bd8cd5d4fe
(cherry picked from commit 3d34594138c42ec4b253a25c403ef9346265a28f)
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 4055250..b4ee8c2 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -128,8 +128,7 @@ public:
* @param nTileWidth logical width of the rendered rectangle, in TWIPs.
* @param nTileHeight logical height of the rendered rectangle, in TWIPs.
*/
- inline void paintTile(
- unsigned char* pBuffer,
+ inline void paintTile(unsigned char* pBuffer,
const int nCanvasWidth,
const int nCanvasHeight,
const int nTilePosX,
@@ -191,6 +190,8 @@ public:
* @param nX horizontal position in document coordinates
* @param nY vertical position in document coordinates
* @param nCount number of clicks: 1 for single click, 2 for double click
+ * @param nButtons: which mouse buttons: 1 for left, 2 for middle, 4 right
+ * @param nModifier: which keyboard modifier: (see include/rsc/rsc-vcl-shared-types.hxx for possible values)
*/
inline void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
{
commit 8475e6e34f19d9cd36175766c14deae6fd0cc8bc
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 31 13:59:46 2015 +0100
android: don't use alpha VDev when painting tiles on Android
Improves tile rendering speed.
Change-Id: I6a4b87fbc1d9ed284f5c4a781d769eeacd9bc2ca
(cherry picked from commit e0d68da3ff3ae81e35f4e7393fb998a41886831d)
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2217992..2f4e547 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -782,7 +782,30 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
-#ifndef IOS
+#if defined(IOS)
+ 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);
+#elif defined(ANDROID)
+ InitSvpForLibreOfficeKit();
+
+ ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)32) ;
+
+ boost::shared_array<sal_uInt8> aBuffer(pBuffer, NoDelete< sal_uInt8 >());
+
+ boost::shared_array<sal_uInt8> aAlphaBuffer;
+
+ pDevice->SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, aAlphaBuffer, true);
+
+ pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+#else
InitSvpForLibreOfficeKit();
ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), (sal_uInt16)32) ;
@@ -815,15 +838,6 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
pBuffer[nOffset * 4 +3] = 0xff - aAlpha[nOffset];
}
}
-
-#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;
commit cdafa26ffdbf4f6b4b7e42f9ef8d77d1468e885b
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 31 13:54:43 2015 +0100
android: add desing library
Change-Id: I6468a5cf66715516764c779ecc080fb2c1bd7382
(cherry picked from commit 50ffbe8557dbecda187cd6d9c93c2fdf916a6f75)
diff --git a/android/source/build.gradle b/android/source/build.gradle
index d3c4a1a..4bb1442 100644
--- a/android/source/build.gradle
+++ b/android/source/build.gradle
@@ -25,6 +25,7 @@ dependencies {
compile files("${liboInstdir}/${liboShareJavaFolder}/unoil.jar")
compile files("${liboWorkdir}/UnpackedTarball/owncloud_android_lib/bin/owncloud-android-library.jar")
compile 'com.android.support:appcompat-v7:23.0.1'
+ compile 'com.android.support:design:23.1.0'
}
android {
commit c4c67b882182081a3b594007d3d71610c2c61d7c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Oct 31 13:53:59 2015 +0100
android: remove CommandLine.java as we don't use it anymore
Change-Id: Ib487d4f948dde2027bebc914bb3fe43b55c6d50b
(cherry picked from commit f70254caf4d58022e7ec338328c45b372e6d8de8)
diff --git a/android/Bootstrap/src/fi/iki/tml/CommandLine.java b/android/Bootstrap/src/fi/iki/tml/CommandLine.java
deleted file mode 100644
index fb5adec..0000000
--- a/android/Bootstrap/src/fi/iki/tml/CommandLine.java
+++ /dev/null
@@ -1,176 +0,0 @@
-// -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-
-// Copyright (C) 2011 Tor Lillqvist <tml at iki.fi>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-
-package fi.iki.tml;
-
-import java.util.*;
-
-public class CommandLine
- implements Iterable<String>
-{
- private String commandLine;
-
- public class Tokenizer
- implements Iterator<String>
- {
- private int index = 0;
- private String savedNext = null;
-
- public Tokenizer()
- {
- }
-
- public boolean hasNext()
- {
- if (savedNext != null)
- return true;
- try {
- savedNext = next();
- return true;
- }
- catch (NoSuchElementException e) {
- }
- return false;
- }
-
- public String next()
- {
- if (savedNext != null) {
- String result = savedNext;
- savedNext = null;
- return result;
- }
-
- StringBuffer sb = new StringBuffer(commandLine.length());
-
- while (index < commandLine.length() &&
- commandLine.charAt(index) == ' ')
- index++;
-
- if (index == commandLine.length())
- throw new NoSuchElementException();
-
- while (index < commandLine.length() &&
- commandLine.charAt(index) != ' ') {
- char c = commandLine.charAt(index);
- if (c == '\'') {
- index++;
- while (index < commandLine.length() &&
- commandLine.charAt(index) != '\'') {
- sb.append(commandLine.charAt(index));
- index++;
- }
- } else if (c == '"') {
- index++;
- while (index < commandLine.length() &&
- commandLine.charAt(index) != '\"') {
- if (commandLine.charAt(index) == '\\') {
- index++;
- if (index < commandLine.length())
- sb.append(commandLine.charAt(index));
- } else {
- sb.append(commandLine.charAt(index));
- }
- index++;
- }
- } else if (c == '\\') {
- index++;
- if (index < commandLine.length())
- sb.append(commandLine.charAt(index));
- } else {
- sb.append(c);
- }
- index++;
- }
- return sb.toString();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- }
-
- public Iterator<String> iterator()
- {
- return new Tokenizer();
- }
-
- public CommandLine(String commandLine)
- {
- this.commandLine = commandLine;
- }
-
- public String[] split()
- {
- ArrayList<String> argv = new ArrayList<String>(10);
-
- try {
- for (String s : this)
- argv.add(s);
- }
- catch (NoSuchElementException e) {
- }
-
- return argv.toArray(new String[0]);
- }
-
- public static String[] split(String commandLine)
- {
- return new CommandLine(commandLine).split();
- }
-
- public static void main(String[] args)
- {
- class Test
- {
- Test(String commandLine)
- {
- String[] argv = split(commandLine);
- System.out.println("Split of " + commandLine + ":");
- int n = 0;
- for (String s : argv) {
- System.out.println("argv[" + n + "}: length " + s.length() + ": \"" + s + "\"");
- n++;
- }
- }
- }
-
- new Test("");
- new Test(" ");
- new Test(" ");
- new Test(" '' ");
- new Test("abc def");
- new Test("abc '' def");
- new Test("abc \"\" def");
- new Test(" abc def ");
- new Test(" abc def ");
- new Test("abc\" \"def");
- new Test("abc\" \"def \"gh\\i\\\" jkl\"");
- new Test("abc' def' '\\ghi jkl'");
- }
-}
-
-// vim:set shiftwidth=4 softtabstop=4 expandtab:
More information about the Libreoffice-commits
mailing list