From 6c938696710137b30d9a375effa6537a0ad91e4d Mon Sep 17 00:00:00 2001 From: luklehnert Date: Tue, 30 Jan 2024 17:17:34 +0100 Subject: [PATCH 1/2] New boolean to the style files for Openoffice/Libreoffice integration to switch between ZERO_WIDTH_SPACE (default) and no space added --- CHANGELOG.md | 1 + .../logic/openoffice/frontend/UpdateCitationMarkers.java | 7 +++++-- .../java/org/jabref/logic/openoffice/style/OOBibStyle.java | 6 ++++++ .../org/jabref/logic/openoffice/style/test.jstyle | 1 + .../openoffice/style/testWithDefaultAtFirstLIne.jstyle | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8783e3c4ba0..3e670e8f2f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a fetcher for [ISIDORE](https://isidore.science/), simply paste in the link into the text field or the last 6 digits in the link that identify that paper. [#10423](https://github.com/JabRef/jabref/issues/10423) - When importing entries form the "Citation relations" tab, the field [cites](https://docs.jabref.org/advanced/entryeditor/entrylinks) is now filled according to the relationship between the entries. [#10572](https://github.com/JabRef/jabref/pull/10752) - We added a new group icon column to the main table showing the icons of the entry's groups. [#10801](https://github.com/JabRef/jabref/pull/10801) +- We added a new boolean to the style files for Openoffice/Libreoffice integration to switch between ZERO_WIDTH_SPACE (default) and no space. ### Changed diff --git a/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java b/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java index 3993afdf9a0..9f5f1eeb99d 100644 --- a/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java +++ b/src/main/java/org/jabref/logic/openoffice/frontend/UpdateCitationMarkers.java @@ -78,8 +78,11 @@ public static void fillCitationMarkInCursor(XTextDocument doc, if (withText) { OOText citationText2 = style.decorateCitationMarker(citationText); - // inject a ZERO_WIDTH_SPACE to hold the initial character format - final String ZERO_WIDTH_SPACE = "\u200b"; + String ZERO_WIDTH_SPACE = ""; + if (style.spaceBeforeCitation()) { + // inject a ZERO_WIDTH_SPACE to hold the initial character format + ZERO_WIDTH_SPACE = "\u200b"; + } citationText2 = OOText.fromString(ZERO_WIDTH_SPACE + citationText2.toString()); OOTextIntoOO.write(doc, cursor, citationText2); } else { diff --git a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java index d0e5fa605ab..36650dc662b 100644 --- a/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java +++ b/src/main/java/org/jabref/logic/openoffice/style/OOBibStyle.java @@ -109,6 +109,7 @@ public class OOBibStyle implements Comparable { private static final String AUTHOR_FIELD = "AuthorField"; private static final String BRACKET_AFTER = "BracketAfter"; private static final String BRACKET_BEFORE = "BracketBefore"; + private static final String SPACE_BEFORE = "SpaceBefore"; private static final String IS_NUMBER_ENTRIES = "IsNumberEntries"; private static final String IS_SORT_BY_POSITION = "IsSortByPosition"; private static final String SORT_ALGORITHM = "SortAlgorithm"; @@ -203,6 +204,7 @@ private void setDefaultProperties() { citProperties.put(IN_TEXT_YEAR_SEPARATOR, " "); citProperties.put(BRACKET_BEFORE, "("); citProperties.put(BRACKET_AFTER, ")"); + citProperties.put(SPACE_BEFORE, Boolean.TRUE); citProperties.put(CITATION_SEPARATOR, "; "); citProperties.put(PAGE_INFO_SEPARATOR, "; "); citProperties.put(GROUPED_NUMBERS_SEPARATOR, "-"); @@ -493,6 +495,10 @@ public boolean isFormatCitations() { return (Boolean) citProperties.get(FORMAT_CITATIONS); } + public boolean spaceBeforeCitation() { + return (Boolean) citProperties.get(SPACE_BEFORE); + } + public boolean isCitationKeyCiteMarkers() { return (Boolean) citProperties.get(CITATION_KEY_CITATIONS); } diff --git a/src/test/resources/org/jabref/logic/openoffice/style/test.jstyle b/src/test/resources/org/jabref/logic/openoffice/style/test.jstyle index 3ecd9bfbf08..7d81444002c 100644 --- a/src/test/resources/org/jabref/logic/openoffice/style/test.jstyle +++ b/src/test/resources/org/jabref/logic/openoffice/style/test.jstyle @@ -27,6 +27,7 @@ FormatCitations="false" CitationCharacterFormat="Default" PageInfoSeparator="; " OxfordComma="," +SpaceBefore="true" LAYOUT article=\format[Authors(LastFirst,Semicolon)]{\author} (\year\uniq). \title, \journal \volume\begin{pages} : \format[FormatPagesForHTML]{\pages}\end{pages}. diff --git a/src/test/resources/org/jabref/logic/openoffice/style/testWithDefaultAtFirstLIne.jstyle b/src/test/resources/org/jabref/logic/openoffice/style/testWithDefaultAtFirstLIne.jstyle index 2a4dcf7a697..f2d7d13611a 100644 --- a/src/test/resources/org/jabref/logic/openoffice/style/testWithDefaultAtFirstLIne.jstyle +++ b/src/test/resources/org/jabref/logic/openoffice/style/testWithDefaultAtFirstLIne.jstyle @@ -27,6 +27,7 @@ FormatCitations="false" CitationCharacterFormat="Default" PageInfoSeparator="; " OxfordComma="," +SpaceBefore="true" LAYOUT From f969dea560bd3ae15d77e9633b7bddfad04c8b02 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 30 Jan 2024 20:32:29 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e670e8f2f0..9e91f5ae991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We added a fetcher for [ISIDORE](https://isidore.science/), simply paste in the link into the text field or the last 6 digits in the link that identify that paper. [#10423](https://github.com/JabRef/jabref/issues/10423) - When importing entries form the "Citation relations" tab, the field [cites](https://docs.jabref.org/advanced/entryeditor/entrylinks) is now filled according to the relationship between the entries. [#10572](https://github.com/JabRef/jabref/pull/10752) - We added a new group icon column to the main table showing the icons of the entry's groups. [#10801](https://github.com/JabRef/jabref/pull/10801) -- We added a new boolean to the style files for Openoffice/Libreoffice integration to switch between ZERO_WIDTH_SPACE (default) and no space. +- We added a new boolean to the style files for Openoffice/Libreoffice integration to switch between ZERO_WIDTH_SPACE (default) and no space. [#10843](https://github.com/JabRef/jabref/pull/10843) ### Changed