()
| 1368 | public void windowClosed(WindowEvent event) { } |
| 1369 | |
| 1370 | public void save() { |
| 1371 | cancelSearch(); |
| 1372 | |
| 1373 | SaveOptionsDialog dialog = new SaveOptionsDialog(this); |
| 1374 | dialog.populate(); |
| 1375 | dialog.setLocationRelativeTo(this); |
| 1376 | dialog.setVisible(true); |
| 1377 | dialog.dispose(); |
| 1378 | |
| 1379 | final String options = dialog.getOptions(); |
| 1380 | if (options == null) |
| 1381 | { |
| 1382 | pageCanvas.requestFocusInWindow(); |
| 1383 | return; |
| 1384 | } |
| 1385 | |
| 1386 | FileDialog fileDialog = new FileDialog(this, "MuPDF Save File", FileDialog.SAVE); |
| 1387 | fileDialog.setDirectory(System.getProperty("user.dir")); |
| 1388 | fileDialog.setFilenameFilter(new FilenameFilter() { |
| 1389 | public boolean accept(File dir, String name) { |
| 1390 | return Document.recognize(name); |
| 1391 | } |
| 1392 | }); |
| 1393 | fileDialog.setFile(doc.documentPath); |
| 1394 | fileDialog.setVisible(true); |
| 1395 | fileDialog.dispose(); |
| 1396 | |
| 1397 | if (fileDialog.getFile() == null) |
| 1398 | { |
| 1399 | pageCanvas.requestFocusInWindow(); |
| 1400 | return; |
| 1401 | } |
| 1402 | |
| 1403 | final String selectedPath = new StringBuffer(fileDialog.getDirectory()).append(File.separatorChar).append(fileDialog.getFile()).toString(); |
| 1404 | OCRmeter = new OCRProgressmeter(this, "Saving...", pages); |
| 1405 | OCRmeter.setLocationRelativeTo(this); |
| 1406 | OCRmeter.setVisible(true); |
| 1407 | pageCanvas.requestFocusInWindow(); |
| 1408 | |
| 1409 | if (options.indexOf("ocr-language=") < 0) |
| 1410 | doc.save(selectedPath, options, OCRmeter, new ViewerCore.OnException() { |
| 1411 | public void run(Throwable t) { |
| 1412 | if (t instanceof IOException) |
| 1413 | exception(t); |
| 1414 | else if (t instanceof RuntimeException && !OCRmeter.cancelled) |
| 1415 | exception(t); |
| 1416 | } |
| 1417 | }); |
| 1418 | else |
| 1419 | { |
| 1420 | try { |
| 1421 | FileStream fs = new FileStream(selectedPath, "rw"); |
| 1422 | doc.save(fs, options, OCRmeter, new ViewerCore.OnException() { |
| 1423 | public void run(Throwable t) { |
| 1424 | if (t instanceof RuntimeException && !OCRmeter.cancelled) |
| 1425 | exception(t); |
| 1426 | } |
| 1427 | }); |
no test coverage detected