diff --git a/CHANGELOG.md b/CHANGELOG.md index 4279e277754..44012b3400e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,9 +42,10 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed the failure to Copy citation key and link. [#5835](https://github.com/JabRef/jabref/issues/5835) - We fixed an issue where the sort order of the entry table was reset after a restart of JabRef. [#6898](https://github.com/JabRef/jabref/pull/6898) - We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907). -- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog [#6934](https://github.com/JabRef/jabref/issues/6934) -- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906) -- We fixed an issue with the python script used by browser plugins that failed to locate JabRef if not installed in its default location. +- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog. [#6934](https://github.com/JabRef/jabref/issues/6934) +- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog. [6906](https://github.com/JabRef/jabref/issues/6906) +- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX. [#6970](https://github.com/JabRef/jabref/pull/6970) +- We fixed an issue with the python script used by browser plugins that failed to locate JabRef if not installed in its default location. [#6963](https://github.com/JabRef/jabref/pull/6963/files) ### Removed diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 41adef02303..921ff24d050 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -48,6 +48,7 @@ import org.jabref.logic.openoffice.OpenOfficePreferences; import org.jabref.logic.openoffice.StyleLoader; import org.jabref.logic.openoffice.UndefinedParagraphFormatException; +import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; @@ -430,9 +431,13 @@ private List findOpenOfficeJars(Path configurationPath) throws IOException throw new IOException("(Not all) required Open Office Jars were found inside installation path. Searched for " + OpenOfficePreferences.OO_JARS + " in " + configurationPath); } - List jarURLs = new ArrayList<>(OpenOfficePreferences.OO_JARS.size()); + List jarURLs = new ArrayList<>(OpenOfficePreferences.OO_JARS.size() + 1); for (Optional jarPath : filePaths) { jarURLs.add((jarPath.get().toUri().toURL())); + // For Mac OSX we need to add the "Contents/MacOS", because otherwise we cannot connect to LO + if (OS.OS_X) { + jarURLs.add(configurationPath.resolve("Contents/MacOS/").toUri().toURL()); + } } return jarURLs; } diff --git a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java index e9369087c4a..309096b08cf 100644 --- a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java +++ b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java @@ -1,18 +1,27 @@ package org.jabref.logic.openoffice; -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.function.BiPredicate; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class OpenOfficeFileSearch { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenOfficeFileSearch.class); + /** * Detects existing installation of OpenOffice and LibreOffice. * @@ -33,19 +42,18 @@ public static List detectInstallations() { } private static List findOpenOfficeDirectories(List programDirectories) { - List result = new ArrayList<>(); - - for (Path programDir : programDirectories) { - File[] subDirs = programDir.toFile().listFiles(File::isDirectory); - if (subDirs != null) { - for (File dir : subDirs) { - if (dir.getPath().toLowerCase(Locale.ROOT).contains("openoffice") || dir.getPath().toLowerCase(Locale.ROOT).contains("libreoffice")) { - result.add(dir.toPath()); - } - } + + BiPredicate filePredicate = (path, attr) -> attr.isDirectory() && (path.toString().toLowerCase(Locale.ROOT).contains("openoffice") + || path.toString().toLowerCase(Locale.ROOT).contains("libreoffice")); + + return programDirectories.stream().flatMap(dirs -> { + try { + return Files.find(dirs, 1, filePredicate); + } catch (IOException e) { + LOGGER.error("Problem searching for openoffice/libreoffice install directory", e); + return Stream.empty(); } - } - return result; + }).collect(Collectors.toList()); } private static List findWindowsOpenOfficeDirs() {