Skip to content

Commit

Permalink
Fix dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
tizianolattisi committed Sep 28, 2018
1 parent b481ff2 commit b00a991
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/main/java/com/axiastudio/ooops/Ooops.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ public OutputStream stream(){
return outStream;
} catch (com.sun.star.io.IOException ex) {
Logger.getLogger(Ooops.class.getName()).log(Level.SEVERE, null, ex);
} finally {
close();
}
return null;
}
Expand All @@ -403,6 +405,8 @@ public Boolean toUrl(String storeUrl){
return true;
} catch (com.sun.star.io.IOException ex) {
Logger.getLogger(Ooops.class.getName()).log(Level.SEVERE, null, ex);
} finally {
close();
}
return null;
}
Expand All @@ -413,26 +417,32 @@ public Boolean toStream(OutputStream outputStream){
return Boolean.TRUE;
} catch (java.io.IOException e) {
e.printStackTrace();
} finally {
close();
}
return Boolean.FALSE;
}

public byte[] toByteArray() {
OoopsOutputStream stream = (OoopsOutputStream) stream();
close();
return stream.toByteArray();
}


private void disposeComponent() {
XCloseable closeable = UnoRuntime.queryInterface(XCloseable.class, component);
if (closeable != null) {
try {
closeable.close(true);
} catch (CloseVetoException e) {
}
private void close() {
XModel model = UnoRuntime.queryInterface(XModel.class, component);
if (model!=null) {
XCloseable closeable = UnoRuntime.queryInterface(XCloseable.class, model);
if (closeable != null) {
try {
closeable.close(true);
} catch (CloseVetoException e) {

} else {
component.dispose();
}
} else {
component.dispose();
}
}
}

Expand Down

0 comments on commit b00a991

Please sign in to comment.