diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2021-03-30 11:40:21 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2021-03-31 06:57:34 +0200 |
commit | 4dbc9c87a09922072c0250e4e932228de93961db (patch) | |
tree | e0f03ca08a79187b4b4a0a9340053093fe122da4 /android | |
parent | 6b3f0866e9eddd5553857741862ca0d7d5b2ec2b (diff) |
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@posteo.de>
Diffstat (limited to 'android')
3 files changed, 23 insertions, 10 deletions
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,11 +22,17 @@ 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. */ int getPageWidth(); |