diff --git a/src/main/java/pro/litvinovg/w2phtml/gui/Document.java b/src/main/java/pro/litvinovg/w2phtml/gui/Document.java index 484b301..c65036a 100644 --- a/src/main/java/pro/litvinovg/w2phtml/gui/Document.java +++ b/src/main/java/pro/litvinovg/w2phtml/gui/Document.java @@ -83,31 +83,34 @@ public class Document { } XStorable storable = UnoRuntime.queryInterface(XStorable.class, textDoc); - if (storable == null || storable.isReadonly()) { - Debug.printLog("Document is read only", componentContext); - } else { - //Debug.printLog("Document is in rw mode", componentContext); - } + /* + * if (storable == null || storable.isReadonly()) { + * Debug.printLog("Document is read only", componentContext); } else { + * Debug.printLog("Document is in rw mode", componentContext); } + */ + XModifiable modifieable = UnoRuntime.queryInterface(XModifiable.class, textDoc); if (modifieable == null || modifieable.isModified()) { - Debug.printLog("Document is modified", componentContext); + Debug.printLog("Document is modified. Save changes before conversion.", componentContext); } else { //Debug.printLog("Document isn't modified", componentContext); } - - String url = model.getURL(); - URI uri = new URI(url); - File file = new File(uri); - if (file.exists() && file.canRead()) { - //Debug.printLog("File exists!", componentContext); - fileName = file.getAbsolutePath(); + if (!storable.hasLocation()) { + Debug.printLog("Document is not saved. Save document before conversion.", componentContext); + return; } + 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."); - e.printStackTrace(); - System.exit(1); + Debug.printLog(e.getStackTrace().toString(), componentContext); + return; } }