From bf8dd0d248854ebd6e9d2d6a95f95e54abc99bea Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 17 Oct 2019 21:45:31 +0200 Subject: [PATCH 1/6] Valid OOStyle need to inlcude a default layout Display correct layout for article and book Fixes #54527 --- .../jabref/gui/openoffice/StyleSelectDialogView.java | 5 +++-- .../java/org/jabref/logic/openoffice/OOBibStyle.java | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java index 814a02e840b..10a06ae4671 100644 --- a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java +++ b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialogView.java @@ -24,6 +24,7 @@ import org.jabref.logic.openoffice.StyleLoader; import org.jabref.logic.util.TestEntry; import org.jabref.model.database.BibDatabaseContext; +import org.jabref.model.entry.types.StandardEntryType; import org.jabref.preferences.PreferencesService; import com.airhacks.afterburner.views.ViewLoader; @@ -118,8 +119,8 @@ private void initialize() { EasyBind.subscribe(viewModel.selectedItemProperty(), style -> { tvStyles.getSelectionModel().select(style); - previewArticle.setLayout(new TextBasedPreviewLayout(style.getStyle().getDefaultBibLayout())); - previewBook.setLayout(new TextBasedPreviewLayout(style.getStyle().getDefaultBibLayout())); + previewArticle.setLayout(new TextBasedPreviewLayout(style.getStyle().getReferenceFormat(StandardEntryType.Article))); + previewBook.setLayout(new TextBasedPreviewLayout(style.getStyle().getReferenceFormat(StandardEntryType.Book))); }); } diff --git a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java index b42252ac914..c28c30da8a1 100644 --- a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java @@ -122,6 +122,7 @@ public class OOBibStyle implements Comparable { private File styleFile; private long styleFileModificationTime = Long.MIN_VALUE; private String localCopy; + private boolean setDefault; public OOBibStyle(File styleFile, LayoutFormatterPreferences prefs, Charset encoding) throws IOException { this.prefs = Objects.requireNonNull(prefs); @@ -143,7 +144,7 @@ public OOBibStyle(String resourcePath, LayoutFormatterPreferences prefs) throws } public Layout getDefaultBibLayout() { - return defaultBibLayout; + return defaultBibLayout ; } private void setDefaultProperties() { @@ -272,7 +273,7 @@ private void readFormatFile(Reader in) throws IOException { if (!line.isEmpty() && (line.charAt(line.length() - 1) == '\r')) { line = line.substring(0, line.length() - 1); } - // Check for empty line or comment: + // Check for empty lin e or comment: if (line.trim().isEmpty() || (line.charAt(0) == '#')) { continue; } @@ -321,13 +322,11 @@ private void readFormatFile(Reader in) throws IOException { } } - // Set validity boolean based on whether we found anything interesting // in the file: - if (mode != BibStyleMode.NONE) { + if ((mode != BibStyleMode.NONE) && setDefault) { valid = true; } - } /** @@ -350,7 +349,7 @@ private void handleStructureLine(String line) { int index = line.indexOf('='); if ((index > 0) && (index < (line.length() - 1))) { String formatString = line.substring(index + 1); - boolean setDefault = line.substring(0, index).equals(OOBibStyle.DEFAULT_MARK); + setDefault = line.substring(0, index).equals(OOBibStyle.DEFAULT_MARK); EntryType type = EntryTypeFactory.parse(line.substring(0, index)); try { Layout layout = new LayoutHelper(new StringReader(formatString), this.prefs).getLayoutFromText(); From 29c8fe71d580ff6dad11d5372badcd0071213ee4 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 17 Oct 2019 21:50:47 +0200 Subject: [PATCH 2/6] fix semicolon --- src/main/java/org/jabref/logic/openoffice/OOBibStyle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java index c28c30da8a1..735ec953baf 100644 --- a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java @@ -144,7 +144,7 @@ public OOBibStyle(String resourcePath, LayoutFormatterPreferences prefs) throws } public Layout getDefaultBibLayout() { - return defaultBibLayout ; + return defaultBibLayout; } private void setDefaultProperties() { From 852b487697b539db134e756ff572908875d69ea0 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 17 Oct 2019 22:09:16 +0200 Subject: [PATCH 3/6] Fix indent and rename var --- src/main/java/org/jabref/logic/openoffice/OOBibStyle.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java index 735ec953baf..52ce354d51b 100644 --- a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java @@ -122,7 +122,7 @@ public class OOBibStyle implements Comparable { private File styleFile; private long styleFileModificationTime = Long.MIN_VALUE; private String localCopy; - private boolean setDefault; + private boolean isDefaultLayoutPresent; public OOBibStyle(File styleFile, LayoutFormatterPreferences prefs, Charset encoding) throws IOException { this.prefs = Objects.requireNonNull(prefs); @@ -324,7 +324,7 @@ private void readFormatFile(Reader in) throws IOException { } // Set validity boolean based on whether we found anything interesting // in the file: - if ((mode != BibStyleMode.NONE) && setDefault) { + if ((mode != BibStyleMode.NONE) && isDefaultLayoutPresent) { valid = true; } } @@ -349,11 +349,11 @@ private void handleStructureLine(String line) { int index = line.indexOf('='); if ((index > 0) && (index < (line.length() - 1))) { String formatString = line.substring(index + 1); - setDefault = line.substring(0, index).equals(OOBibStyle.DEFAULT_MARK); + isDefaultLayoutPresent = line.substring(0, index).equals(OOBibStyle.DEFAULT_MARK); EntryType type = EntryTypeFactory.parse(line.substring(0, index)); try { Layout layout = new LayoutHelper(new StringReader(formatString), this.prefs).getLayoutFromText(); - if (setDefault) { + if (isDefaultLayoutPresent) { defaultBibLayout = layout; } else { bibLayout.put(type, layout); From fafdad79da22407ffab9802cce42c3908ec0b955 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Thu, 17 Oct 2019 22:19:11 +0200 Subject: [PATCH 4/6] add changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7979b1a365d..a57d985edb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a short DOI field formatter which shortens DOI to more human-readable form. [koppor#343](https://github.com/koppor/jabref/issues/343) - We improved the display of group memberships by adding multiple colored bars if the entry belongs to more than one group. [#4574](https://github.com/JabRef/jabref/issues/4574) - We added an option to show the preview as an extra tab in the entry editor (instead of in a split view). [#5244](https://github.com/JabRef/jabref/issues/5244) +- A custom Open/LibreOffice jstyle file now requires a layout line for the entry type `default` [#5452](https://github.com/JabRef/jabref/issues/5452) ### Fixed @@ -43,6 +44,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed some display errors in the preferences dialog and replaced some of the controls [#5033](https://github.com/JabRef/jabref/pull/5033) [#5047](https://github.com/JabRef/jabref/pull/5047) [#5062](https://github.com/JabRef/jabref/pull/5062) [#5141](https://github.com/JabRef/jabref/pull/5141) [#5185](https://github.com/JabRef/jabref/pull/5185) [#5265](https://github.com/JabRef/jabref/pull/5265) [#5315](https://github.com/JabRef/jabref/pull/5315) [#5360](https://github.com/JabRef/jabref/pull/5360) - We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447) - After successful import of one or multiple bib entries the main table scrolls to the first imported entry [#5383](https://github.com/JabRef/jabref/issues/5383) +- We fixed an exception which occurred when an invalid jstyle was loaded [#5452](https://github.com/JabRef/jabref/issues/5452) ### Removed From 3a0e6af932611a9fc87811c8355398250962b3e7 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 17 Oct 2019 22:25:37 +0200 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a57d985edb9..f2c1c794c94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed some display errors in the preferences dialog and replaced some of the controls [#5033](https://github.com/JabRef/jabref/pull/5033) [#5047](https://github.com/JabRef/jabref/pull/5047) [#5062](https://github.com/JabRef/jabref/pull/5062) [#5141](https://github.com/JabRef/jabref/pull/5141) [#5185](https://github.com/JabRef/jabref/pull/5185) [#5265](https://github.com/JabRef/jabref/pull/5265) [#5315](https://github.com/JabRef/jabref/pull/5315) [#5360](https://github.com/JabRef/jabref/pull/5360) - We fixed an exception which occurred when trying to import entries without an open library. [#5447](https://github.com/JabRef/jabref/issues/5447) - After successful import of one or multiple bib entries the main table scrolls to the first imported entry [#5383](https://github.com/JabRef/jabref/issues/5383) -- We fixed an exception which occurred when an invalid jstyle was loaded [#5452](https://github.com/JabRef/jabref/issues/5452) +- We fixed an exception which occurred when an invalid jstyle was loaded. [#5452](https://github.com/JabRef/jabref/issues/5452) ### Removed From 918b26333aa7462358ec3115b309d1b36b3713da Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 17 Oct 2019 22:26:02 +0200 Subject: [PATCH 6/6] Update src/main/java/org/jabref/logic/openoffice/OOBibStyle.java Co-Authored-By: Tobias Diez --- src/main/java/org/jabref/logic/openoffice/OOBibStyle.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java index 52ce354d51b..6b2156047ee 100644 --- a/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/OOBibStyle.java @@ -273,7 +273,7 @@ private void readFormatFile(Reader in) throws IOException { if (!line.isEmpty() && (line.charAt(line.length() - 1) == '\r')) { line = line.substring(0, line.length() - 1); } - // Check for empty lin e or comment: + // Check for empty line or comment: if (line.trim().isEmpty() || (line.charAt(0) == '#')) { continue; }