summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMert Tümer <merttumer7@gmail.com>2018-02-06 18:30:13 +0300
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-02-24 14:58:00 +0100
commitddd49295d19f76c63ea61dc64af08a797dbafa9b (patch)
tree0798a6e179b3fc1fecedad8464de1fdf53d9ce6f
parenta6e46a240267a6d7082f65629b2bc1dcd1313f89 (diff)
[Pardus] tdf#112481 Ability to add worksheets on Calc
This patch is sponsored by ULAKBIM/PARDUS project. Signed-off-by: Mert Tümer <merttumer7@gmail.com> Change-Id: Id67e3c400971b47738fe2f628955534f34839493 Reviewed-on: https://gerrit.libreoffice.org/49294 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--android/source/res/menu/main.xml5
-rw-r--r--android/source/res/values/strings.xml1
-rw-r--r--android/source/src/java/org/libreoffice/LOKitTileProvider.java25
-rw-r--r--android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java2
-rw-r--r--android/source/src/java/org/libreoffice/ToolbarController.java5
5 files changed, 35 insertions, 3 deletions
diff --git a/android/source/res/menu/main.xml b/android/source/res/menu/main.xml
index 432c374b3997..229c20aed68c 100644
--- a/android/source/res/menu/main.xml
+++ b/android/source/res/menu/main.xml
@@ -40,6 +40,11 @@
android:title="@string/action_add_slide"
android:orderInCategory="100"
android:enabled="false" />
+
+ <item android:id="@+id/action_add_worksheet"
+ android:title="@string/action_add_worksheet"
+ android:orderInCategory="100"
+ android:enabled="false" />
</group>
diff --git a/android/source/res/values/strings.xml b/android/source/res/values/strings.xml
index c55b5a61f53b..2e885fee5e1a 100644
--- a/android/source/res/values/strings.xml
+++ b/android/source/res/values/strings.xml
@@ -155,6 +155,7 @@
<string name="calc_optimal_length_confirm">OK</string>
<string name="calc_optimal_length_default_text">Enter Extra Length in 100th/mm</string>
<string name="calc_alert_double_click_optimal_length">Hint: Double tap on a header sets optimal width/height.</string>
+ <string name="action_add_worksheet">Add Worksheet</string>
<!-- Password dialog strings -->
<string name="action_pwd_dialog_OK">OK</string>
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index bdf00ff77e2d..be16d8d1ebbe 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -13,6 +13,8 @@ import android.graphics.PointF;
import android.util.Log;
import android.view.KeyEvent;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.libreoffice.kit.DirectBufferAllocator;
import org.libreoffice.kit.Document;
import org.libreoffice.kit.LibreOfficeKit;
@@ -116,6 +118,9 @@ class LOKitTileProvider implements TileProvider {
mContext.getToolbarController().disableMenuItem(R.id.action_presentation, false);
mContext.getToolbarController().disableMenuItem(R.id.action_add_slide, false);
}
+ if (mDocument.getDocumentType() == Document.DOCTYPE_SPREADSHEET) {
+ mContext.getToolbarController().disableMenuItem(R.id.action_add_worksheet, false);
+ }
// Writer documents always have one part, so hide the navigation drawer.
if (mDocument.getDocumentType() != Document.DOCTYPE_TEXT) {
@@ -163,7 +168,25 @@ class LOKitTileProvider implements TileProvider {
public void addPart(){
int parts = mDocument.getParts();
- LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:InsertPage"));
+ if(mDocument.getDocumentType() == Document.DOCTYPE_SPREADSHEET){
+ try{
+ JSONObject jsonObject = new JSONObject();
+ JSONObject values = new JSONObject();
+ JSONObject values2 = new JSONObject();
+ values.put("type", "long");
+ values.put("value", 0); //add to the last
+ values2.put("type", "string");
+ values2.put("value", "");
+ jsonObject.put("Name", values2);
+ jsonObject.put("Index", values);
+ LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:Insert", jsonObject.toString()));
+ }catch (JSONException e) {
+ e.printStackTrace();
+ }
+ } else if (mDocument.getDocumentType() == Document.DOCTYPE_PRESENTATION){
+ LOKitShell.sendEvent(new LOEvent(LOEvent.UNO_COMMAND, ".uno:InsertPage"));
+ }
+
String partName = mDocument.getPartName(parts);
if (partName.isEmpty()) {
partName = getGenericPartName(parts);
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 655bb13f42d7..3d9e13f343ad 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -691,7 +691,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
aboutDialogFragment.show(getSupportFragmentManager(), "AboutDialogFragment");
}
- public void addSlide(){
+ public void addPart(){
mTileProvider.addPart();
mDocumentPartViewListAdapter.notifyDataSetChanged();
setDocumentChanged(true);
diff --git a/android/source/src/java/org/libreoffice/ToolbarController.java b/android/source/src/java/org/libreoffice/ToolbarController.java
index b8faae379f83..87a84f0878d1 100644
--- a/android/source/src/java/org/libreoffice/ToolbarController.java
+++ b/android/source/src/java/org/libreoffice/ToolbarController.java
@@ -136,7 +136,10 @@ public class ToolbarController implements Toolbar.OnMenuItemClickListener {
mContext.preparePresentation();
return true;
case R.id.action_add_slide:
- mContext.addSlide();
+ mContext.addPart();
+ return true;
+ case R.id.action_add_worksheet:
+ mContext.addPart();
return true;
}
return false;