diff --git a/build.gradle b/build.gradle index c8909f0166a..cf6c8f11f08 100644 --- a/build.gradle +++ b/build.gradle @@ -594,7 +594,8 @@ javadoc { version = false author = false addMultilineStringsOption("-add-exports").setValue([ - 'javafx.controls/com.sun.javafx.scene.control=org.jabref' + 'javafx.controls/com.sun.javafx.scene.control=org.jabref', + 'org.controlsfx.controls/impl.org.controlsfx.skin=org.jabref' ]) } } 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 e9c611f02ec..eaa4e099f31 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLCitationOOAdapter.java @@ -54,14 +54,14 @@ public void insertCitation(XTextCursor cursor, CitationStyle selectedStyle, List String style = selectedStyle.getSource(); boolean isAlphanumeric = isAlphanumericStyle(selectedStyle); - String inTextCitation; + String citation; if (isAlphanumeric) { - inTextCitation = CSLFormatUtils.generateAlphanumericCitation(entries, bibDatabaseContext); + citation = CSLFormatUtils.generateAlphanumericCitation(entries, bibDatabaseContext); } else { - inTextCitation = CitationStyleGenerator.generateCitation(entries, style, CSLFormatUtils.OUTPUT_FORMAT, bibDatabaseContext, bibEntryTypesManager).getText(); + citation = CitationStyleGenerator.generateCitation(entries, style, CSLFormatUtils.OUTPUT_FORMAT, bibDatabaseContext, bibEntryTypesManager).getText(); } - String formattedCitation = CSLFormatUtils.transformHTML(inTextCitation); + String formattedCitation = CSLFormatUtils.transformHTML(citation); if (selectedStyle.isNumericStyle()) { formattedCitation = updateSingleOrMultipleCitationNumbers(formattedCitation, entries); @@ -75,7 +75,7 @@ public void insertCitation(XTextCursor cursor, CitationStyle selectedStyle, List * Inserts in-text citations for a group of entries. * Comparable to LaTeX's \citet command. * - * @implNote Very similar to the {@link #insertCitation(XTextCursor, CitationStyle, List, BibDatabaseContext, BibEntryTypesManager)} method.insertInText method + * @implNote Very similar to the {@link #insertCitation(XTextCursor, CitationStyle, List, BibDatabaseContext, BibEntryTypesManager) insertCitation} method. */ public void insertInTextCitation(XTextCursor cursor, CitationStyle selectedStyle, List entries, BibDatabaseContext bibDatabaseContext, BibEntryTypesManager bibEntryTypesManager) throws IOException, CreationException, Exception { @@ -152,22 +152,22 @@ public void insertBibliography(XTextCursor cursor, CitationStyle selectedStyle, entries.sort(Comparator.comparingInt(entry -> markManager.getCitationNumber(entry.getCitationKey().orElse("")))); for (BibEntry entry : entries) { - String citation = CitationStyleGenerator.generateBibliography(List.of(entry), style, CSLFormatUtils.OUTPUT_FORMAT, bibDatabaseContext, bibEntryTypesManager).getFirst(); + String bibliographyEntry = CitationStyleGenerator.generateBibliography(List.of(entry), style, CSLFormatUtils.OUTPUT_FORMAT, bibDatabaseContext, bibEntryTypesManager).getFirst(); String citationKey = entry.getCitationKey().orElse(""); int currentNumber = markManager.getCitationNumber(citationKey); - String formattedCitation = CSLFormatUtils.updateSingleBibliographyNumber(CSLFormatUtils.transformHTML(citation), currentNumber); - OOText ooText = OOFormat.setLocaleNone(OOText.fromString(formattedCitation)); + String formattedBibliographyEntry = CSLFormatUtils.updateSingleBibliographyNumber(CSLFormatUtils.transformHTML(bibliographyEntry), currentNumber); + OOText ooText = OOFormat.setLocaleNone(OOText.fromString(formattedBibliographyEntry)); OOTextIntoOO.write(document, cursor, ooText); } } else { // Ordering will be according to citeproc item data provider (default) - List citations = CitationStyleGenerator.generateBibliography(entries, style, CSLFormatUtils.OUTPUT_FORMAT, bibDatabaseContext, bibEntryTypesManager); + List bibliographyEntries = CitationStyleGenerator.generateBibliography(entries, style, CSLFormatUtils.OUTPUT_FORMAT, bibDatabaseContext, bibEntryTypesManager); - for (String citation : citations) { - String formattedCitation = CSLFormatUtils.transformHTML(citation); - OOText ooText = OOFormat.setLocaleNone(OOText.fromString(formattedCitation)); + for (String bibliographyEntry : bibliographyEntries) { + String formattedBibliographyEntry = CSLFormatUtils.transformHTML(bibliographyEntry); + OOText ooText = OOFormat.setLocaleNone(OOText.fromString(formattedBibliographyEntry)); OOTextIntoOO.write(document, cursor, ooText); } } 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 525a1803be5..51be704a014 100644 --- a/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java +++ b/src/main/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtils.java @@ -36,7 +36,7 @@ public class CSLFormatUtils { /** * Transforms provided HTML into a format that can be fully parsed and inserted into an OO document. - * Context: The HTML produced by {@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} or {@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} is not directly (completely) parsable by by {@link OOTextIntoOO#write(XTextDocument, XTextCursor, OOText) write}. + * Context: The HTML produced by {@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} or {@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} is not directly (completely) parsable by {@link OOTextIntoOO#write(XTextDocument, XTextCursor, OOText) write}. * For more details, read the documentation for the {@link OOTextIntoOO} class. * Additional Information. * @@ -122,7 +122,7 @@ public static String generateAlphanumericCitation(List entries, BibDat /** * Method to update citation number of a bibliographic entry (to be inserted in the list of references). - * By default, citeproc-java ({@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} always starts the numbering of a list of citations with "1". + * By default, citeproc-java ({@link org.jabref.logic.citationstyle.CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography}) always starts the numbering of a list of references with "1". * If a citation doesn't correspond to the first cited entry, the number should be changed to the appropriate current citation number. * The numbers should be globally unique. If an entry has been cited before, the older citation number corresponding to it should be reused. * The number can be enclosed in different formats, such as "1", "1.", "1)", "(1)" or "[1]". diff --git a/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java b/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java index 69df8bb42f1..dc43b0d26cb 100644 --- a/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java +++ b/src/test/java/org/jabref/logic/openoffice/oocsltext/CSLFormatUtilsTest.java @@ -142,9 +142,8 @@ static Stream ooHTMLTransformFromRawHTML() { /** * Test to check correct transformation of raw CSL bibliography generated by citeproc-java methods into OO-ready text. - *

- * Precondition: This test assumes that {@link CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} works as expected. - *

+ * + * @implSpec Assumes that {@link CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} works as expected. */ @ParameterizedTest @MethodSource @@ -254,9 +253,8 @@ static Stream ooHTMLTransformFromRawBibliography() { /** * Test to check correct transformation of raw CSL citation with a single entry generated by citeproc-java methods into OO-ready text. - *

- * Precondition: This test assumes that {@link CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} works as expected. - *

+ * + * @implSpec Assumes that {@link CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} works as expected. */ @ParameterizedTest @MethodSource @@ -356,9 +354,8 @@ static Stream ooHTMLTransformFromCitationWithSingleEntry() { /** * Test to check correct transformation of raw CSL citations with multiple entries generated by citeproc-java methods into OO-ready text. - *

- * Precondition: This test assumes that {@link CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} works as expected. - *

+ * + * @implSpec Assumes that {@link CitationStyleGenerator#generateCitation(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateCitation} works as expected. */ @ParameterizedTest @MethodSource @@ -482,10 +479,13 @@ static Stream ooHTMLTransformFromCitationWithMultipleEntries() { * Test for modifying the number (index) of a numeric citation. * The numeric index should change to the provided "current number". * The rest of the citation should stay as it is (other numbers in the body shouldn't be affected). - *

- * Precondition 1: This test assumes that {@link CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} works as expected.
- * Precondition 2: This test assumes that the method {@link CSLFormatUtils#transformHTML(String) transformHTML} works as expected.
- * Precondition 3: Run this test ONLY on numeric Citation Styles.

+ * + * @implSpec + *
    + *
  1. Assumes that {@link CitationStyleGenerator#generateBibliography(List, String, CitationStyleOutputFormat, BibDatabaseContext, BibEntryTypesManager) generateBibliography} works as expected.
  2. + *
  3. Assumes that the method {@link CSLFormatUtils#transformHTML(String) transformHTML} works as expected.
  4. + *
  5. Run this test ONLY on numeric Citation Styles.
  6. + *
*/ @ParameterizedTest @MethodSource @@ -593,8 +593,8 @@ private static Stream ChangeToInText() { /** * Test for proper generation of alphanumeric citations (currently supported: DIN 1505-2). - *

- * Precondition: This test assumes that the method {@link org.jabref.logic.citationkeypattern.BracketedPattern#authorsAlpha authorsAlpha} works as expected.

+ * + * @implSpec Assumes that the method {@link org.jabref.logic.citationkeypattern.BracketedPattern#authorsAlpha authorsAlpha} works as expected.

*/ @ParameterizedTest @MethodSource