Added check for not saved documents

This commit is contained in:
Georgy Litvinov 2020-08-03 13:11:12 +02:00
parent 14be21dbce
commit ff29c7c8cb

View file

@ -83,31 +83,34 @@ public class Document {
} }
XStorable storable = UnoRuntime.queryInterface(XStorable.class, textDoc); XStorable storable = UnoRuntime.queryInterface(XStorable.class, textDoc);
if (storable == null || storable.isReadonly()) { /*
Debug.printLog("Document is read only", componentContext); * if (storable == null || storable.isReadonly()) {
} else { * Debug.printLog("Document is read only", componentContext); } else {
//Debug.printLog("Document is in rw mode", componentContext); * Debug.printLog("Document is in rw mode", componentContext); }
} */
XModifiable modifieable = UnoRuntime.queryInterface(XModifiable.class, textDoc); XModifiable modifieable = UnoRuntime.queryInterface(XModifiable.class, textDoc);
if (modifieable == null || modifieable.isModified()) { if (modifieable == null || modifieable.isModified()) {
Debug.printLog("Document is modified", componentContext); Debug.printLog("Document is modified. Save changes before conversion.", componentContext);
} else { } else {
//Debug.printLog("Document isn't modified", componentContext); //Debug.printLog("Document isn't modified", componentContext);
} }
if (!storable.hasLocation()) {
String url = model.getURL(); Debug.printLog("Document is not saved. Save document before conversion.", componentContext);
URI uri = new URI(url); return;
File file = new File(uri);
if (file.exists() && file.canRead()) {
//Debug.printLog("File exists!", componentContext);
fileName = file.getAbsolutePath();
} }
String url = model.getURL();
URI uri = new URI(url);
File file = new File(uri);
if (file.exists() && file.canRead()) {
fileName = file.getAbsolutePath();
}
} catch (Exception e) { } catch (Throwable e) {
System.out.println("xDesktop inaccessible. Can not proceed."); System.out.println("xDesktop inaccessible. Can not proceed.");
e.printStackTrace(); Debug.printLog(e.getStackTrace().toString(), componentContext);
System.exit(1); return;
} }
} }