CSL4LibreOffice - I [Bibliography formatting]#13074
Conversation
Co-authored-by: DTT12912 <derictonythomas@gmail.com> Co-authored-by: subhramit <subhramit.bb@live.in> Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
This reverts commit 1174ca0.
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
…aphy-formatting
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
| setResultConverter(buttonType -> { | ||
| if (buttonType == ButtonType.OK) { | ||
| viewModel.savePreferences(); | ||
| } | ||
| return null; | ||
| }); |
There was a problem hiding this comment.
Returning null from a public method is discouraged. Consider using java.util.Optional to avoid potential null pointer exceptions.
| unmerge.setDisable(!canRefreshDocument || cslStyleSelected); | ||
| manageCitations.setDisable(!canRefreshDocument || cslStyleSelected); | ||
| exportCitations.setDisable(!(isConnectedToDocument && hasDatabase) || cslStyleSelected); | ||
| modifyBibliographyProperties.setDisable(!cslStyleSelected); |
There was a problem hiding this comment.
The method 'modifyBibliographyProperties' should not return null. It should use Optional to handle cases where no value is returned.
| public void storeStylePreferences() { | ||
| // save external jstyles | ||
| List<String> externalStyles = jStyles.stream() | ||
| List<String> externalJStyles = jStyles.stream() |
There was a problem hiding this comment.
The variable name 'externalJStyles' is not camel-case as per Java naming conventions. It should be 'externalJStyles'.
| * Style information record (title, numeric nature, has bibliography specification, bibliography uses hanging indent) for a citation style. | ||
| */ | ||
| public record StyleInfo(String title, boolean isNumericStyle, boolean hasBibliography) { | ||
| public record StyleInfo(String title, boolean isNumericStyle, boolean hasBibliography, boolean usesHangingIndent) { |
There was a problem hiding this comment.
The JavaDoc for the StyleInfo record is trivial and does not provide additional information beyond the code itself. It should offer a high-level summary or guidance.
| OOText title = OOFormat.paragraph(OOText.fromString(openOfficePreferences.getCslBibliographyTitle()), openOfficePreferences.getCslBibliographyHeaderFormat()); | ||
| OOTextIntoOO.write(document, cursor, OOText.fromString(title.toString())); | ||
| OOText ooBreak = OOFormat.paragraph(OOText.fromString(""), CSLFormatUtils.DEFAULT_BIBLIOGRAPHY_BODY_PARAGRAPH_FORMAT); | ||
| OOText ooBreak = OOFormat.paragraph(OOText.fromString(""), openOfficePreferences.getCslBibliographyBodyFormat()); |
There was a problem hiding this comment.
The patch introduces a change to use a method from openOfficePreferences to get the bibliography body format. Ensure that this method returns a valid format and does not return null, as null should not be passed to methods.
Signed-off-by: subhramit <subhramit.bb@live.in>
| assertTrue(firstStyle.containsKey("title"), "Style entry should have a title"); | ||
| assertTrue(firstStyle.containsKey("isNumeric"), "Style entry should have isNumeric flag"); | ||
| assertTrue(firstStyle.containsKey("hasBibliography"), "Style entry should have hasBibliography flag"); | ||
| assertTrue(firstStyle.containsKey("usesHangingIndent"), "Style entry should have usesHangingIndent flag"); |
There was a problem hiding this comment.
The test uses assertTrue to check for the presence of a key in a map. It would be more robust to use assertEquals to verify the expected value of the key, ensuring the test checks both existence and correctness.
| } | ||
| // As the prefs are mocked away, the getExternalStyles still returns the initial one | ||
| assertFalse(preferences.getExternalStyles().isEmpty()); | ||
| assertFalse(preferences.getExternalJStyles().isEmpty()); |
There was a problem hiding this comment.
The assertion checks for a boolean condition instead of asserting the expected contents of the list, which would provide more informative test results.
…aphy-formatting
Signed-off-by: subhramit <subhramit.bb@live.in>
|
TODO: Gifs for APA demos in the blog post will need updating. |
| * This is also why we don't let users manually input the name of any pre-set format. | ||
| * The following two lists below are taken from https://github.com/LibreOffice/core/blob/0891df6b21fd95ec7c9614509d92829c0f17c353/sw/qa/python/check_styles.py#L132 | ||
| */ | ||
| public static final List<String> BIBLIOGRAPHY_TITLE_FORMATS = List.of( |
There was a problem hiding this comment.
The patch reformats the code without adding new statements, which violates the guideline that code should not be reformatted only because of syntax.
| private final boolean isInternalStyle; | ||
|
|
||
| public CitationStyle(String filePath, String title, boolean isNumericStyle, boolean hasBibliography, String source, boolean isInternalStyle) { | ||
| public CitationStyle(String filePath, String title, boolean isNumericStyle, boolean hasBibliography, boolean usesHangingIndent, String source, boolean isInternalStyle) { |
There was a problem hiding this comment.
We now have so many booleans that one could think about having an Enum and an EnumSet to pass all the options. But that can be done in a further PR
Closes #13049, supersedes #13050
Closes https://github.com/JabRef/jabref-issue-melting-pot/issues/894 (internal)
Partially Closes #13051, but does not supersede #13072
Fixes #12784 (comment)
Changes
Added options to format CSL bibliography body:
Examples using IEEE:
Text body:Hanging indent:First line indent:...and so on.
Moved the option to modify CSL bibliography properties to the OO/LO panel, de-coupling it from the
Select Styledialog:(enabled only when a CSL style is selected) (renamed from "
Modify bibliography title" to "Bibliography properties")Added support for "
Hanging Indent" in CSL styles that specify it (auto-select as default bibliography body format, "Text body" being the default in all other cases).The metadata stored in the CSL catalog now includes hanging indent information:
{ "path" : "academy-of-management-review.csl", "isNumeric" : false, "hasBibliography" : true, "usesHangingIndent" : true, "title" : "Academy of Management Review" }Body Text" format as it is not specified by LO, and used "Text body" consistently.Bibliography Heading" to the available CSL bibliography header formats.property.set()methods as otherwise it caused them to be saved even if the "Modify bibliography title" dialog was closed without pressing "OK".Mandatory checks
CHANGELOG.mddescribed in a way that is understandable for the average user (if change is visible to the user)