diff --git a/iped-app/src/main/java/iped/app/bootstrap/Bootstrap.java b/iped-app/src/main/java/iped/app/bootstrap/Bootstrap.java index 9669b7efd1..8644f3ae0d 100644 --- a/iped-app/src/main/java/iped/app/bootstrap/Bootstrap.java +++ b/iped-app/src/main/java/iped/app/bootstrap/Bootstrap.java @@ -145,10 +145,7 @@ protected void run(String args[]) { classpath += separator + pluginConfig.getPluginFolder().getAbsolutePath() + "/*"; } - // user can't open analysis UI w/ --nogui, so no need to load libreoffice jars - if (!iped.getCmdLineArgs().isNogui()) { - classpath = fillClassPathWithLibreOfficeJars(iped, classpath); - } + classpath = fillClassPathWithLibreOfficeJars(iped, classpath, iped.getCmdLineArgs().isNogui()); String javaBin = "java"; if (SystemUtils.IS_OS_WINDOWS) { @@ -278,14 +275,14 @@ private static List getSystemProperties() { return props; } - private static String fillClassPathWithLibreOfficeJars(Main iped, String classpath) + private static String fillClassPathWithLibreOfficeJars(Main iped, String classpath, boolean isNogui) throws URISyntaxException, IOException { System.setProperty(IOfficeApplication.NOA_NATIVE_LIB_PATH, new File(iped.getRootPath(), "lib/nativeview").getAbsolutePath()); LibreOfficeFinder loFinder = new LibreOfficeFinder(new File(iped.getRootPath())); - if (loFinder.getLOPath() != null) { + if (loFinder.getLOPath(isNogui) != null) { List jars = new ArrayList<>(); - UNOLibFinder.addUNOJars(loFinder.getLOPath(), jars); + UNOLibFinder.addUNOJars(loFinder.getLOPath(isNogui), jars); for (File jar : jars) { classpath += separator + jar.getCanonicalPath(); } diff --git a/iped-app/src/main/java/iped/app/ui/ViewerController.java b/iped-app/src/main/java/iped/app/ui/ViewerController.java index d056ad6e34..852eeb77d7 100644 --- a/iped-app/src/main/java/iped/app/ui/ViewerController.java +++ b/iped-app/src/main/java/iped/app/ui/ViewerController.java @@ -116,7 +116,7 @@ public void run() { URI jarUri = URLUtil.getURL(LibreOfficeViewer.class).toURI(); File moduledir = new File(jarUri).getParentFile().getParentFile(); LibreOfficeFinder loFinder = new LibreOfficeFinder(moduledir); - final String pathLO = loFinder.getLOPath(); + final String pathLO = loFinder.getLOPath(false); if (pathLO != null) { SwingUtilities.invokeAndWait(new Runnable() { @Override diff --git a/iped-engine/src/main/java/iped/engine/task/DocThumbTask.java b/iped-engine/src/main/java/iped/engine/task/DocThumbTask.java index 98753a8d9d..bea7aca9d1 100644 --- a/iped-engine/src/main/java/iped/engine/task/DocThumbTask.java +++ b/iped-engine/src/main/java/iped/engine/task/DocThumbTask.java @@ -94,7 +94,7 @@ public void init(ConfigurationManager configurationManager) throws Exception { URL url = URLUtil.getURL(this.getClass()); File jarDir = new File(url.toURI()).getParentFile(); LibreOfficeFinder loFinder = new LibreOfficeFinder(jarDir); - loPath = loFinder.getLOPath(); + loPath = loFinder.getLOPath(true); logger.info("LibreOffice Path: " + loPath); } diff --git a/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LOExtractor.java b/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LOExtractor.java index 6de5ea345d..ddeadf26d5 100644 --- a/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LOExtractor.java +++ b/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LOExtractor.java @@ -32,7 +32,7 @@ public LOExtractor(File input, File output) { this.input = input; } - public boolean decompressLO() { + public boolean decompressLO(boolean isNogui) { try { if (output.exists()) { @@ -44,14 +44,16 @@ public boolean decompressLO() { } if (input.exists()) { - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - progressMonitor = new ProgressDialog(null, LOExtractor.this); - progressMonitor.setMaximum(numSubitens); - progressMonitor.setNote(Messages.getString("LOExtractor.DecompressingLO")); //$NON-NLS-1$ - } - }); + if (!isNogui) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + progressMonitor = new ProgressDialog(null, LOExtractor.this); + progressMonitor.setMaximum(numSubitens); + progressMonitor.setNote(Messages.getString("LOExtractor.DecompressingLO")); //$NON-NLS-1$ + } + }); + } try (ZipFile zip = new ZipFile(input)) { Enumeration e = zip.getEntries(); @@ -69,15 +71,17 @@ public void run() { if (++progress == numSubitens) completed = true; - progressMonitor.setProgress(progress); - - if (progressMonitor.isCanceled()) - break; + if (progressMonitor != null) { + progressMonitor.setProgress(progress); + + if (progressMonitor.isCanceled()) + break; + } } } } - if (!progressMonitor.isCanceled()) { + if (progressMonitor != null && !progressMonitor.isCanceled()) { progressMonitor.close(); } diff --git a/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LibreOfficeFinder.java b/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LibreOfficeFinder.java index 51170b7a23..c23283bb80 100644 --- a/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LibreOfficeFinder.java +++ b/iped-viewers/iped-viewers-impl/src/main/java/iped/viewers/util/LibreOfficeFinder.java @@ -36,7 +36,7 @@ public LibreOfficeFinder(File baseFolder) { baseDir = baseFolder; } - public String getLOPath() { + public String getLOPath(boolean isNogui) { if (detectedPath == null) { detectedPath = System.getProperty("libreOfficePath"); if (detectedPath != null) @@ -62,7 +62,7 @@ public String getLOPath() { if (winPathLO.exists() || compressedLO.exists()) { // $NON-NLS-1$ //$NON-NLS-2$ LOExtractor extractor = new LOExtractor(compressedLO, winPathLO); - if (extractor.decompressLO()) + if (extractor.decompressLO(isNogui)) detectedPath = winPathLO.getAbsolutePath(); } }