return false;
}
}
public static boolean export(ComboFrame frame, Document doc) {
ImageExportOptions oldOptions = doc.getExportOptions();
ImageMetadata meta = doc.getMetadata();
final Engine engine = doc.getEngine();
Dimension size = engine.getNaturalSize();
ImageExportOptions newOptions;
if (oldOptions != null) {
// This Document has been exported before.
newOptions = ExportLogic.getDefaultExportOptions(
oldOptions, size
);
}
else if (LastExportOptions != null) {
// This Document has never been exported, but export has been used.
File file = doc.getFile();
if (file != null) {
// This Document has been saved:
newOptions = ExportLogic.getDefaultExportOptions(
LastExportOptions, meta, size, file.getName()
);
}
else {
// This Document not has been saved:
newOptions = ExportLogic.getDefaultExportOptions(
LastExportOptions, meta, size
);
}
}
else {
// Export has never been used.
newOptions = ExportLogic.getDefaultExportOptions(
meta, size
);
}
// Show the export dialog using these defaults:
FileChooser chooser = Platform.getPlatform().getFileChooser();
ImageExportOptions options = chooser.exportFile(newOptions, frame);
// User cancelled:
if (options == null) {
return false;
}
// Do the write:
boolean success;
frame.pause();
try {
success = DocumentWriter.exportWithDialog(
engine, options, LOCALE.get("ExportMessage"), frame
);
}
catch (Throwable e) { // IOException, unchecked Exceptions
showError(
LOCALE.get("ExportError", options.getExportFile().toString()),
e, frame
);
success = false;
}
finally {
frame.resume();
}
if (! success) {
// User canceled.
File file = options.getExportFile();
if (file != null) {
file.delete();
}
return false;
}
doc.setExportOptions(options);
LastExportOptions = options;
addToRecentFiles(options.getExportFile());
savePrefs();
return true;
}