From c6ee5979422e32f049acd32626d45dcdec2ae5bb Mon Sep 17 00:00:00 2001 From: Subhramit Basu Bhowmick Date: Sun, 1 Sep 2024 22:02:05 +0530 Subject: [PATCH 01/10] Fix: Auto-sync bibliography for JStyle (#11690) * Fix: Sync bibliography for JStyle, refactoring, todo comments for alwaysCitedOnPages * Changelog entry * Collapse if block * remove newline * Better changelog entry --- CHANGELOG.md | 1 + .../org/jabref/gui/openoffice/OOBibBase.java | 24 +++++-------------- .../gui/openoffice/OpenOfficePanel.java | 4 ++++ 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e7175ba2ec..bb55b134ed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the entry preview highlight was not working when searching before opening the entry editor. [#11659](https://github.com/JabRef/jabref/pull/11659) - We fixed an issue where text in Dark mode inside "Citation information" was not readable. [#11512](https://github.com/JabRef/jabref/issues/11512) - We fixed an issue where the selection of an entry in the table lost after searching for a group. [#3176](https://github.com/JabRef/jabref/issues/3176) +- We fixed the non-functionality of the option "Automatically sync bibliography when inserting citations" in the OpenOffice panel, when enabled in case of JStyles. [#11684](https://github.com/JabRef/jabref/issues/11684) ### Removed diff --git a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java index 8c1b6233ce4..2a19cfe7149 100644 --- a/src/main/java/org/jabref/gui/openoffice/OOBibBase.java +++ b/src/main/java/org/jabref/gui/openoffice/OOBibBase.java @@ -68,11 +68,8 @@ public class OOBibBase { private final DialogService dialogService; - // After inserting a citation, if ooPrefs.getSyncWhenCiting() returns true, shall we also update the bibliography? - private final boolean refreshBibliographyDuringSyncWhenCiting; - // Shall we add "Cited on pages: ..." to resolved bibliography entries? - private final boolean alwaysAddCitedOnPages; + private final boolean alwaysAddCitedOnPages; // TODO (see comment above) private final OOBibBaseConnect connection; @@ -86,7 +83,6 @@ public OOBibBase(Path loPath, DialogService dialogService) this.dialogService = dialogService; this.connection = new OOBibBaseConnect(loPath, dialogService); - this.refreshBibliographyDuringSyncWhenCiting = false; this.alwaysAddCitedOnPages = false; } @@ -576,27 +572,19 @@ public void guiActionInsertEntry(List entries, } /* - * For sync we need a FunctionalTextViewCursor. + * For sync we need a FunctionalTextViewCursor and an open database. */ OOResult fcursor = null; if (syncOptions.isPresent()) { fcursor = getFunctionalTextViewCursor(doc, errorTitle); - if (testDialog(errorTitle, fcursor.asVoidResult())) { - return; - } - } - - syncOptions - .map(e -> e.setUpdateBibliography(this.refreshBibliographyDuringSyncWhenCiting)) - .map(e -> e.setAlwaysAddCitedOnPages(this.alwaysAddCitedOnPages)); - - if (syncOptions.isPresent()) { - if (testDialog(databaseIsRequired(syncOptions.get().databases, + if (testDialog(errorTitle, fcursor.asVoidResult()) || testDialog(databaseIsRequired(syncOptions.get().databases, OOError::noDataBaseIsOpenForSyncingAfterCitation))) { return; } } + syncOptions.map(e -> e.setAlwaysAddCitedOnPages(this.alwaysAddCitedOnPages)); // TODO: Provide option to user: this is always false + try { UnoUndo.enterUndoContext(doc, "Insert citation"); @@ -873,7 +861,7 @@ public void guiActionUpdateDocument(List databases, OOStyle style) Update.SyncOptions syncOptions = new Update.SyncOptions(databases); syncOptions .setUpdateBibliography(true) - .setAlwaysAddCitedOnPages(this.alwaysAddCitedOnPages); + .setAlwaysAddCitedOnPages(this.alwaysAddCitedOnPages); // TODO: Provide option to user: this is always false unresolvedKeys = Update.synchronizeDocument(doc, frontend, jStyle, fcursor.get(), syncOptions); } finally { diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 4e51e6ec5c1..c4416876ed8 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -553,6 +553,10 @@ private void pushEntries(CitationType citationType, boolean addPageInfo) { ? Optional.of(new Update.SyncOptions(getBaseList())) : Optional.empty(); + // Sync options are non-null only when "Automatically sync bibliography when inserting citations" is enabled + if (syncOptions.isPresent() && preferencesService.getOpenOfficePreferences().getSyncWhenCiting()) { + syncOptions.get().setUpdateBibliography(true); + } ooBase.guiActionInsertEntry(entries, bibDatabaseContext, entryTypesManager, From 24df6d24e65ab76f09a4a253222d5764d743766f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:16:26 +0000 Subject: [PATCH 02/10] Bump org.apache.commons:commons-lang3 from 3.16.0 to 3.17.0 (#11692) Bumps org.apache.commons:commons-lang3 from 3.16.0 to 3.17.0. --- updated-dependencies: - dependency-name: org.apache.commons:commons-lang3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6252c37b26e..cad43bbf822 100644 --- a/build.gradle +++ b/build.gradle @@ -172,7 +172,7 @@ dependencies { implementation "org.apache.lucene:lucene-highlighter:$luceneVersion" implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.11.0' - implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.16.0' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0' implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0' implementation 'commons-logging:commons-logging:1.3.3' implementation 'com.h2database:h2-mvstore:2.3.232' From ff93daad4aa2a4735a2cce17e1913a547d5a7a3e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:19:34 +0000 Subject: [PATCH 03/10] Bump org.jetbrains.kotlin:kotlin-stdlib-jdk8 from 2.0.10 to 2.0.20 (#11693) Bumps [org.jetbrains.kotlin:kotlin-stdlib-jdk8](https://github.com/JetBrains/kotlin) from 2.0.10 to 2.0.20. - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v2.0.10...v2.0.20) --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-stdlib-jdk8 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index cad43bbf822..a87ace93722 100644 --- a/build.gradle +++ b/build.gradle @@ -340,7 +340,7 @@ dependencies { exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jdk8' } // GemxFX also (transitively) depends on kotlin - implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.10' + implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.20' implementation 'commons-io:commons-io:2.16.1' From 7cefa2eb2debc833e8d55aebc4429a9e02fff7e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:24:01 +0000 Subject: [PATCH 04/10] Bump commons-logging:commons-logging from 1.3.3 to 1.3.4 (#11694) Bumps commons-logging:commons-logging from 1.3.3 to 1.3.4. --- updated-dependencies: - dependency-name: commons-logging:commons-logging dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index a87ace93722..3ab158b5674 100644 --- a/build.gradle +++ b/build.gradle @@ -174,7 +174,7 @@ dependencies { implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.11.0' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0' implementation group: 'org.apache.commons', name: 'commons-text', version: '1.12.0' - implementation 'commons-logging:commons-logging:1.3.3' + implementation 'commons-logging:commons-logging:1.3.4' implementation 'com.h2database:h2-mvstore:2.3.232' // required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635 From c7751e8095f74cb77920d3427c9d526d30058e2b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:27:37 +0000 Subject: [PATCH 05/10] Bump commons-cli:commons-cli from 1.8.0 to 1.9.0 (#11696) Bumps commons-cli:commons-cli from 1.8.0 to 1.9.0. --- updated-dependencies: - dependency-name: commons-cli:commons-cli dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3ab158b5674..1965357cf55 100644 --- a/build.gradle +++ b/build.gradle @@ -180,7 +180,7 @@ dependencies { // required for reading write-protected PDFs - see https://github.com/JabRef/jabref/pull/942#issuecomment-209252635 implementation 'org.bouncycastle:bcprov-jdk18on:1.78.1' - implementation 'commons-cli:commons-cli:1.8.0' + implementation 'commons-cli:commons-cli:1.9.0' // region: LibreOffice implementation 'org.libreoffice:unoloader:24.2.3' From 8f08d786e191c40cfacf3d1309127d39b5624a4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 16:48:57 +0200 Subject: [PATCH 06/10] Bump src/main/resources/csl-styles from `35ac18d` to `2b15b1f` (#11698) Bumps [src/main/resources/csl-styles](https://github.com/citation-style-language/styles) from `35ac18d` to `2b15b1f`. - [Release notes](https://github.com/citation-style-language/styles/releases) - [Commits](https://github.com/citation-style-language/styles/compare/35ac18dc5f6376a0ecf2858f429e8539bab7f276...2b15b1fbc190e003b555486f46ce1112fd95defc) --- updated-dependencies: - dependency-name: src/main/resources/csl-styles dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/main/resources/csl-styles | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/csl-styles b/src/main/resources/csl-styles index 35ac18dc5f6..2b15b1fbc19 160000 --- a/src/main/resources/csl-styles +++ b/src/main/resources/csl-styles @@ -1 +1 @@ -Subproject commit 35ac18dc5f6376a0ecf2858f429e8539bab7f276 +Subproject commit 2b15b1fbc190e003b555486f46ce1112fd95defc From 6fd1e2361a2fd376f1486828933bb76258c30ecf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:28:36 +0000 Subject: [PATCH 07/10] Bump org.mockito:mockito-core from 5.12.0 to 5.13.0 (#11695) Bumps [org.mockito:mockito-core](https://github.com/mockito/mockito) from 5.12.0 to 5.13.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v5.12.0...v5.13.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1965357cf55..d348f85ac69 100644 --- a/build.gradle +++ b/build.gradle @@ -348,7 +348,7 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter:5.11.0' testImplementation 'org.junit.platform:junit-platform-launcher:1.10.3' - testImplementation 'org.mockito:mockito-core:5.12.0' + testImplementation 'org.mockito:mockito-core:5.13.0' testImplementation 'org.xmlunit:xmlunit-core:2.10.0' testImplementation 'org.xmlunit:xmlunit-matchers:2.10.0' testRuntimeOnly 'com.tngtech.archunit:archunit-junit5-engine:1.3.0' From 46e50724c7c0ccb31f5d7eb31521087df8cba97c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 14:48:23 +0000 Subject: [PATCH 08/10] Bump src/main/resources/csl-locales from `195bef8` to `7eeb362` (#11697) Bumps [src/main/resources/csl-locales](https://github.com/citation-style-language/locales) from `195bef8` to `7eeb362`. - [Release notes](https://github.com/citation-style-language/locales/releases) - [Commits](https://github.com/citation-style-language/locales/compare/195bef843f87fc917be45ab3eca60536e4ef4626...7eeb36257a68cb1907bd04f0eaa08d9ed238cbe6) --- updated-dependencies: - dependency-name: src/main/resources/csl-locales dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- src/main/resources/csl-locales | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/csl-locales b/src/main/resources/csl-locales index 195bef843f8..7eeb36257a6 160000 --- a/src/main/resources/csl-locales +++ b/src/main/resources/csl-locales @@ -1 +1 @@ -Subproject commit 195bef843f87fc917be45ab3eca60536e4ef4626 +Subproject commit 7eeb36257a68cb1907bd04f0eaa08d9ed238cbe6 From b186efb0fed0c3b89dc73eeb7f5bc2d82774b6da Mon Sep 17 00:00:00 2001 From: Subhramit Basu Bhowmick Date: Mon, 2 Sep 2024 23:40:53 +0530 Subject: [PATCH 09/10] Change ADR title (#11699) * Change ADR title * Remove quotes --- .../0031-use-current-tab-for-deciding-style-type-for-oo.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/decisions/0031-use-current-tab-for-deciding-style-type-for-oo.md b/docs/decisions/0031-use-current-tab-for-deciding-style-type-for-oo.md index c8a78bd9f34..05c9e8481bf 100644 --- a/docs/decisions/0031-use-current-tab-for-deciding-style-type-for-oo.md +++ b/docs/decisions/0031-use-current-tab-for-deciding-style-type-for-oo.md @@ -2,7 +2,7 @@ nav_order: 31 parent: Decision Records --- -# Use currently active Style tab in Select Style Dialog to decide which style to activate +# Use currently active tab in Select style (OO Panel) to decide style type ## Context and Problem Statement From 419d2a7e1e0f8e9caaf2d3355d040a7d62b4bd60 Mon Sep 17 00:00:00 2001 From: Subhramit Basu Bhowmick Date: Tue, 3 Sep 2024 23:51:33 +0530 Subject: [PATCH 10/10] Refactor magic string (#11700) --- .../jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java | 2 +- .../org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java index 0ae03cf03e3..9b529754431 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java @@ -148,7 +148,7 @@ public void insertBibliography(XTextCursor cursor, CitationStyle selectedStyle, OOText title = OOFormat.paragraph(OOText.fromString(CSLFormatUtils.DEFAULT_BIBLIOGRAPHY_TITLE), CSLFormatUtils.DEFAULT_BIBLIOGRAPHY_HEADER_PARAGRAPH_FORMAT); OOTextIntoOO.write(document, cursor, OOText.fromString(title.toString())); - OOText ooBreak = OOFormat.paragraph(OOText.fromString(""), "Body Text"); + OOText ooBreak = OOFormat.paragraph(OOText.fromString(""), CSLFormatUtils.DEFAULT_BIBLIOGRAPHY_BODY_PARAGRAPH_FORMAT); OOTextIntoOO.write(document, cursor, ooBreak); String style = selectedStyle.getSource(); diff --git a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java index 0666a411cf7..0ae50cb4716 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java @@ -29,6 +29,8 @@ public class CSLFormatUtils { public static final String DEFAULT_BIBLIOGRAPHY_TITLE = "References"; public static final String DEFAULT_BIBLIOGRAPHY_HEADER_PARAGRAPH_FORMAT = "Heading 2"; + public static final String DEFAULT_BIBLIOGRAPHY_BODY_PARAGRAPH_FORMAT = "Body Text"; + public static final CitationStyleOutputFormat OUTPUT_FORMAT = CitationStyleOutputFormat.HTML; private static final Pattern YEAR_IN_CITATION_PATTERN = Pattern.compile("(.)(.*), (\\d{4}.*)");