[Libreoffice-commits] core.git: android/source
Michael Weghorn (via logerrit)
logerrit at kemper.freedesktop.org
Wed Mar 31 04:58:16 UTC 2021
android/source/src/java/org/libreoffice/LOKitThread.java | 10 ------
android/source/src/java/org/libreoffice/LOKitTileProvider.java | 15 ++++++++++
android/source/src/java/org/libreoffice/TileProvider.java | 8 ++++-
3 files changed, 23 insertions(+), 10 deletions(-)
New commits:
commit 4dbc9c87a09922072c0250e4e932228de93961db
Author: Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Tue Mar 30 11:40:21 2021 +0200
Commit: Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Wed Mar 31 06:57:34 2021 +0200
android: TileKitProvider: Optionally detect file type from document
Add an overload for the 'saveDocumentAs' method that takes just one
parameter and auto-detects the file type to use from the document.
Use it when creating new documents.
Change-Id: I0f275ce159176292ffa1e52ed37673a486ab9428
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113374
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index 03b7070e783a..e80e5af6c990 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -265,15 +265,7 @@ class LOKitThread extends Thread {
refresh();
LOKitShell.hideProgressSpinner(mContext);
- if (fileType.matches(LibreOfficeUIActivity.NEW_WRITER_STRING_KEY))
- mTileProvider.saveDocumentAs(filePath, "odt");
- else if (fileType.matches(LibreOfficeUIActivity.NEW_CALC_STRING_KEY))
- mTileProvider.saveDocumentAs(filePath, "ods");
- else if (fileType.matches(LibreOfficeUIActivity.NEW_IMPRESS_STRING_KEY))
- mTileProvider.saveDocumentAs(filePath, "odp");
- else
- mTileProvider.saveDocumentAs(filePath, "odg");
-
+ mTileProvider.saveDocumentAs(filePath);
} else {
closeDocument();
}
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index 0e2649337322..a887118c6aaa 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -356,6 +356,21 @@ class LOKitTileProvider implements TileProvider {
LOKitShell.hideProgressSpinner(mContext);
}
+ @Override
+ public void saveDocumentAs(final String filePath) {
+ final int docType = mDocument.getDocumentType();
+ if (docType == Document.DOCTYPE_TEXT)
+ saveDocumentAs(filePath, "odt");
+ else if (docType == Document.DOCTYPE_SPREADSHEET)
+ saveDocumentAs(filePath, "ods");
+ else if (docType == Document.DOCTYPE_PRESENTATION)
+ saveDocumentAs(filePath, "odp");
+ else if (docType == Document.DOCTYPE_DRAWING)
+ saveDocumentAs(filePath, "odg");
+ else
+ Log.w(LOGTAG, "Cannot determine file format from document. Not saving.");
+ }
+
public void exportToPDF(boolean print){
String dir = Environment.getExternalStorageDirectory().getAbsolutePath()+"/Documents";
File docDir = new File(dir);
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index dabf30b834f7..a848b4ae98d0 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -22,10 +22,16 @@ import org.mozilla.gecko.gfx.IntSize;
public interface TileProvider {
/**
- * Save the current document.
+ * Save the current document under the given path.
*/
void saveDocumentAs(String filePath, String format);
+ /**
+ * Saves the current document under the given path,
+ * using the default file format.
+ */
+ void saveDocumentAs(String filePath);
+
/**
* Returns the page width in pixels.
*/
More information about the Libreoffice-commits
mailing list