Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into importerbackgroun…
Browse files Browse the repository at this point in the history
…dtask

* upstream/master:
  Fix typo for small pi (#7296)
  Fix Normalize pages formatter not replacing dashes (#7243)
  Simplify LO connection and fix threading errors (#7271)
  Fix for issue 7287 (#7290)

# Conflicts:
#	src/main/resources/l10n/JabRef_en.properties
  • Loading branch information
Siedlerchr committed Jan 5, 2021
2 parents 6bc4acb + 0d995d6 commit 9e7544a
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 507 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where the "Normalize page numbers" formatter did not replace en-dashes or em-dashes with a hyphen-minus sign. [#7239](https://github.com/JabRef/jabref/issues/7239)
- We fixed an issue with the style of highlighted check boxes while searching in preferences. [#7226](https://github.com/JabRef/jabref/issues/7226)
- We fixed an issue where the option "Move file to file directory" was disabled in the entry editor for all files [#7194](https://github.com/JabRef/jabref/issues/7194)
- We fixed an issue where application dialogs were opening in the wrong display when using multiple screens [#7273](https://github.com/JabRef/jabref/pull/7273)
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/jabref/gui/JabRefDialogService.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ public Optional<ButtonType> showCustomDialogAndWait(String title, DialogPane con

@Override
public <R> Optional<R> showCustomDialogAndWait(javafx.scene.control.Dialog<R> dialog) {
dialog.initOwner(mainWindow);
if (dialog.getOwner() == null) {
dialog.initOwner(mainWindow);
}
return dialog.showAndWait();
}

Expand Down Expand Up @@ -398,7 +400,9 @@ public Optional<Path> showFileOpenFromArchiveDialog(Path archivePath) throws IOE

@Override
public void showCustomDialog(BaseDialog<?> aboutDialogView) {
aboutDialogView.initOwner(mainWindow);
if (aboutDialogView.getOwner() == null) {
aboutDialogView.initOwner(mainWindow);
}
aboutDialogView.show();
}
}
20 changes: 5 additions & 15 deletions src/main/java/org/jabref/gui/openoffice/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
package org.jabref.gui.openoffice;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.URLClassLoader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
Expand Down Expand Up @@ -254,10 +253,9 @@ public static final XComponentContext defaultBootstrap_InitialComponentContext(S
* @throws BootstrapException if things go awry.
* @since UDK 3.1.0
*/
public static final XComponentContext bootstrap(URLClassLoader loader) throws BootstrapException {

public static final XComponentContext bootstrap(Path ooPath) throws BootstrapException {
String[] defaultArgArray = getDefaultOptions();
return bootstrap(defaultArgArray, loader);
return bootstrap(defaultArgArray, ooPath);
}

/**
Expand All @@ -269,7 +267,7 @@ public static final XComponentContext bootstrap(URLClassLoader loader) throws Bo
* @see #getDefaultOptions()
* @since LibreOffice 5.1
*/
public static final XComponentContext bootstrap(String[] argArray, URLClassLoader loader) throws BootstrapException {
public static final XComponentContext bootstrap(String[] argArray, Path path) throws BootstrapException {

XComponentContext xContext = null;

Expand All @@ -280,18 +278,10 @@ public static final XComponentContext bootstrap(String[] argArray, URLClassLoade
throw new BootstrapException("no local component context!");
}

// find office executable relative to this class's class loader
String sOffice = System.getProperty("os.name").startsWith("Windows") ? "soffice.exe" : "soffice";

File fOffice = NativeLibraryLoader.getResource(loader, sOffice);
if (fOffice == null) {
throw new BootstrapException("no office executable found!");
}

// create call with arguments
// We need a socket, pipe does not work. https://api.libreoffice.org/examples/examples.html
String[] cmdArray = new String[argArray.length + 2];
cmdArray[0] = fOffice.getPath();
cmdArray[0] = path.toAbsolutePath().toString();
cmdArray[1] = ("--accept=socket,host=localhost,port=2083" + ";urp;");

System.arraycopy(argArray, 0, cmdArray, 2, argArray.length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.jabref.gui.desktop.os.NativeDesktop;
import org.jabref.gui.util.DirectoryDialogConfiguration;
import org.jabref.logic.l10n.Localization;
import org.jabref.logic.openoffice.OpenOfficeFileSearch;
import org.jabref.logic.openoffice.OpenOfficePreferences;
import org.jabref.logic.util.OS;
import org.jabref.logic.util.io.FileUtil;
Expand All @@ -32,15 +31,11 @@ public DetectOpenOfficeInstallation(PreferencesService preferencesService, Dialo
this.ooPrefs = preferencesService.getOpenOfficePreferences();
}

public boolean isInstalled() {
return autoDetectPaths();
}

public boolean isExecutablePathDefined() {
return checkAutoDetectedPaths(ooPrefs);
}

private Optional<Path> selectInstallationPath() {
public Optional<Path> selectInstallationPath() {

final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop();

Expand All @@ -52,32 +47,19 @@ private Optional<Path> selectInstallationPath() {
return dialogService.showDirectorySelectionDialog(dirDialogConfiguration);
}

private boolean autoDetectPaths() {
List<Path> installations = OpenOfficeFileSearch.detectInstallations();

// manually add installation path
if (installations.isEmpty()) {
selectInstallationPath().ifPresent(installations::add);
}

// select among multiple installations
Optional<Path> actualFile = chooseAmongInstallations(installations);
if (actualFile.isPresent()) {
return setOpenOfficePreferences(actualFile.get());
}

return false;
}

/**
* Checks whether the executablePath exists
*/
private boolean checkAutoDetectedPaths(OpenOfficePreferences openOfficePreferences) {
String executablePath = openOfficePreferences.getExecutablePath();

if (OS.LINUX && (System.getenv("FLATPAK_SANDBOX_DIR") != null)) {
executablePath = OpenOfficePreferences.DEFAULT_LINUX_FLATPAK_EXEC_PATH;
}
return !StringUtil.isNullOrEmpty(executablePath) && Files.exists(Path.of(executablePath));
}

private boolean setOpenOfficePreferences(Path installDir) {
public boolean setOpenOfficePreferences(Path installDir) {
Optional<Path> execPath = Optional.empty();

if (OS.WINDOWS) {
Expand All @@ -88,20 +70,16 @@ private boolean setOpenOfficePreferences(Path installDir) {
execPath = FileUtil.find(OpenOfficePreferences.LINUX_EXECUTABLE, installDir);
}

Optional<Path> jarFilePath = FileUtil.find(OpenOfficePreferences.OO_JARS.get(0), installDir);

if (execPath.isPresent() && jarFilePath.isPresent()) {
ooPrefs.setInstallationPath(installDir.toString());
if (execPath.isPresent()) {
ooPrefs.setExecutablePath(execPath.get().toString());
ooPrefs.setJarsPath(jarFilePath.get().getParent().toString());
preferencesService.setOpenOfficePreferences(ooPrefs);
return true;
}

return false;
}

private Optional<Path> chooseAmongInstallations(List<Path> installDirs) {
public Optional<Path> chooseAmongInstallations(List<Path> installDirs) {
if (installDirs.isEmpty()) {
return Optional.empty();
}
Expand Down
49 changes: 0 additions & 49 deletions src/main/java/org/jabref/gui/openoffice/ManualConnectDialog.fxml

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9e7544a

Please sign in to comment.