summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/source/src/java/org/libreoffice/LOEvent.java1
-rw-r--r--android/source/src/java/org/libreoffice/LOKitShell.java4
-rw-r--r--android/source/src/java/org/libreoffice/LOKitThread.java11
-rw-r--r--android/source/src/java/org/libreoffice/LOKitTileProvider.java26
-rw-r--r--android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java4
-rw-r--r--android/source/src/java/org/libreoffice/TileProvider.java12
6 files changed, 40 insertions, 18 deletions
diff --git a/android/source/src/java/org/libreoffice/LOEvent.java b/android/source/src/java/org/libreoffice/LOEvent.java
index 4db48a5bbd6d..74a09c92cc1d 100644
--- a/android/source/src/java/org/libreoffice/LOEvent.java
+++ b/android/source/src/java/org/libreoffice/LOEvent.java
@@ -42,6 +42,7 @@ public class LOEvent implements Comparable<LOEvent> {
public static final int REFRESH = 21;
public static final int PAGE_SIZE_CHANGED = 22;
public static final int UNO_COMMAND_NOTIFY = 23;
+ public static final int SAVE_COPY_AS = 24;
public final int mType;
diff --git a/android/source/src/java/org/libreoffice/LOKitShell.java b/android/source/src/java/org/libreoffice/LOKitShell.java
index 46ca256c7993..75b2fb09b260 100644
--- a/android/source/src/java/org/libreoffice/LOKitShell.java
+++ b/android/source/src/java/org/libreoffice/LOKitShell.java
@@ -119,6 +119,10 @@ public class LOKitShell {
LOKitShell.sendEvent(new LOEvent(filePath, fileFormat, LOEvent.SAVE_AS));
}
+ public static void sendSaveCopyAsEvent(String filePath, String fileFormat) {
+ LOKitShell.sendEvent(new LOEvent(filePath, fileFormat, LOEvent.SAVE_COPY_AS));
+ }
+
public static void sendResumeEvent(String inputFile, int partIndex) {
LOKitShell.sendEvent(new LOEvent(LOEvent.RESUME, inputFile, partIndex));
}
diff --git a/android/source/src/java/org/libreoffice/LOKitThread.java b/android/source/src/java/org/libreoffice/LOKitThread.java
index e80e5af6c990..c20365d58fad 100644
--- a/android/source/src/java/org/libreoffice/LOKitThread.java
+++ b/android/source/src/java/org/libreoffice/LOKitThread.java
@@ -265,7 +265,7 @@ class LOKitThread extends Thread {
refresh();
LOKitShell.hideProgressSpinner(mContext);
- mTileProvider.saveDocumentAs(filePath);
+ mTileProvider.saveDocumentAs(filePath, false);
} else {
closeDocument();
}
@@ -274,11 +274,11 @@ class LOKitThread extends Thread {
/**
* Save the currently loaded document.
*/
- private void saveDocumentAs(String filePath, String fileType) {
+ private void saveDocumentAs(String filePath, String fileType, boolean bTakeOwnership) {
if (mTileProvider == null) {
Log.e(LOGTAG, "Error in saving, Tile Provider instance is null");
} else {
- mTileProvider.saveDocumentAs(filePath, fileType);
+ mTileProvider.saveDocumentAs(filePath, fileType, bTakeOwnership);
}
}
@@ -305,7 +305,10 @@ class LOKitThread extends Thread {
loadNewDocument(event.filePath, event.fileType);
break;
case LOEvent.SAVE_AS:
- saveDocumentAs(event.filePath, event.fileType);
+ saveDocumentAs(event.filePath, event.fileType, true);
+ break;
+ case LOEvent.SAVE_COPY_AS:
+ saveDocumentAs(event.filePath, event.fileType, false);
break;
case LOEvent.RESUME:
resumeDocument(event.mString, event.mPartIndex);
diff --git a/android/source/src/java/org/libreoffice/LOKitTileProvider.java b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
index a887118c6aaa..0a9ad6a90685 100644
--- a/android/source/src/java/org/libreoffice/LOKitTileProvider.java
+++ b/android/source/src/java/org/libreoffice/LOKitTileProvider.java
@@ -42,7 +42,7 @@ class LOKitTileProvider implements TileProvider {
private static int TILE_SIZE = 256;
private final float mTileWidth;
private final float mTileHeight;
- private final String mInputFile;
+ private String mInputFile;
private Office mOffice;
private Document mDocument;
private boolean mIsReady = false;
@@ -298,11 +298,16 @@ class LOKitTileProvider implements TileProvider {
@Override
- public void saveDocumentAs(final String filePath, String format) {
+ public void saveDocumentAs(final String filePath, String format, boolean takeOwnership) {
+ String options = "";
+ if (takeOwnership) {
+ options = "TakeOwnership";
+ }
+
final String newFilePath = "file://" + filePath;
Log.d("saveFilePathURL", newFilePath);
LOKitShell.showProgressSpinner(mContext);
- mDocument.saveAs(newFilePath, format, "");
+ mDocument.saveAs(newFilePath, format, options);
if (!mOffice.getError().isEmpty()){
Log.e("Save Error", mOffice.getError());
if (format.equals("svg")) {
@@ -344,6 +349,7 @@ class LOKitTileProvider implements TileProvider {
}
});
} else {
+ mInputFile = filePath;
LOKitShell.getMainHandler().post(new Runnable() {
@Override
public void run() {
@@ -357,16 +363,16 @@ class LOKitTileProvider implements TileProvider {
}
@Override
- public void saveDocumentAs(final String filePath) {
+ public void saveDocumentAs(final String filePath, boolean takeOwnership) {
final int docType = mDocument.getDocumentType();
if (docType == Document.DOCTYPE_TEXT)
- saveDocumentAs(filePath, "odt");
+ saveDocumentAs(filePath, "odt", takeOwnership);
else if (docType == Document.DOCTYPE_SPREADSHEET)
- saveDocumentAs(filePath, "ods");
+ saveDocumentAs(filePath, "ods", takeOwnership);
else if (docType == Document.DOCTYPE_PRESENTATION)
- saveDocumentAs(filePath, "odp");
+ saveDocumentAs(filePath, "odp", takeOwnership);
else if (docType == Document.DOCTYPE_DRAWING)
- saveDocumentAs(filePath, "odg");
+ saveDocumentAs(filePath, "odg", takeOwnership);
else
Log.w(LOGTAG, "Cannot determine file format from document. Not saving.");
}
@@ -385,7 +391,7 @@ class LOKitTileProvider implements TileProvider {
mDocument.saveAs("file://"+cacheFile,"pdf","");
printDocument(cacheFile);
}else{
- saveDocumentAs(dir+"/"+file,"pdf");
+ saveDocumentAs(dir+"/"+file,"pdf", false);
}
}
@@ -435,7 +441,7 @@ class LOKitTileProvider implements TileProvider {
File input = new File(mInputFile);
final String cacheFile = cacheDir + "/lo_cached_" + input.getName();
String path = input.getAbsolutePath();
- saveDocumentAs(path, format);
+ saveDocumentAs(path, format, true);
(new File(cacheFile)).delete();
}else{
mContext.saveDocument();
diff --git a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
index 368d19af1375..210b2bf2ffd5 100644
--- a/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
+++ b/android/source/src/java/org/libreoffice/LibreOfficeMainActivity.java
@@ -365,7 +365,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
* Save a new document
* */
public void saveAs(){
- LOKitShell.sendSaveAsEvent(mInputFile.getPath(), FileUtilities.getExtension(mInputFile.getPath()).substring(1));
+ LOKitShell.sendSaveCopyAsEvent(mInputFile.getPath(), FileUtilities.getExtension(mInputFile.getPath()).substring(1));
}
/**
@@ -1057,7 +1057,7 @@ public class LibreOfficeMainActivity extends AppCompatActivity implements Settin
if (mTempSlideShowFile.exists() && !isDocumentChanged) {
startPresentation("file://" + tempPath);
} else {
- LOKitShell.sendSaveAsEvent(tempPath, "svg");
+ LOKitShell.sendSaveCopyAsEvent(tempPath, "svg");
}
}
}
diff --git a/android/source/src/java/org/libreoffice/TileProvider.java b/android/source/src/java/org/libreoffice/TileProvider.java
index a848b4ae98d0..1a20c8b080d0 100644
--- a/android/source/src/java/org/libreoffice/TileProvider.java
+++ b/android/source/src/java/org/libreoffice/TileProvider.java
@@ -23,14 +23,22 @@ public interface TileProvider {
/**
* Save the current document under the given path.
+ * @param takeOwnership Whether to take ownership of the new file,
+ * i.e. whether the current document is changed to the
+ * newly saved document (takeOwnership = true),
+ * as compared to just saving a copy of the current document
+ * or exporting to a different file format.
+ * Must be 'false' when using this method for export to e.g. PNG or PDF.
*/
- void saveDocumentAs(String filePath, String format);
+ void saveDocumentAs(String filePath, String format, boolean takeOwnership);
/**
* Saves the current document under the given path,
* using the default file format.
+ * @param takeOwnership (s. documentation for
+ * 'saveDocumentAs(String filePath, String format, boolean takeOwnership)')
*/
- void saveDocumentAs(String filePath);
+ void saveDocumentAs(String filePath, boolean takeOwnership);
/**
* Returns the page width in pixels.