-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
CSL4LibreOffice - G [Custom CSL Styles, build-time loading] #12951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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>
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>
(PR state when ticket-check-action does not work as expected) |
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>
@@ -300,8 +300,8 @@ private JStyleSelectViewModel getJStyleOrDefault(String stylePath) { | |||
|
|||
public void addJStyleFile() { | |||
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() | |||
.addExtensionFilter(Localization.lang("Style file"), StandardFileType.JSTYLE) | |||
.withDefaultExtension(Localization.lang("Style file"), StandardFileType.JSTYLE) | |||
.addExtensionFilter(Localization.lang("JStyle file"), StandardFileType.JSTYLE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe %0 file? I'm sure we have it somewhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to localization.
I found:
this.description = Localization.lang("%0 file", fileType.getName()); |
So do you mean:
.addExtensionFilter(Localization.lang("%0 file", StandardFileType.JSTYLE.getName()), StandardFileType.JSTYLE)
.withDefaultExtension(Localization.lang("%0 file", StandardFileType.JSTYLE.getName()), StandardFileType.JSTYLE)
That causes %0 to be "LibreOffice layout style". I can change that to "JStyle" and use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit 45c7d51
Signed-off-by: subhramit <subhramit.bb@live.in>
Signed-off-by: subhramit <subhramit.bb@live.in>
if (matchingLayout.isEmpty()) { | ||
matchingLayout = availableCslLayouts.stream() | ||
.filter(layout -> layout.getDisplayName().equals(citationStyle.getTitle())) | ||
.findFirst(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code uses an else branch to handle the case where matchingLayout is empty. It should return early if matchingLayout is present, following the fail-fast principle.
path.map(Path::toAbsolutePath).map(Path::toString).ifPresent(stylePath -> { | ||
Optional<CitationStyle> newStyleOptional = cslStyleLoader.addStyleIfValid(stylePath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not handle the case where path is empty before proceeding with the mapping operation. It should return early if path is not present.
path.map(Path::toAbsolutePath).map(Path::toString).ifPresent(stylePath -> { | ||
if (jStyleLoader.addStyleIfValid(stylePath)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code does not handle the case where path is empty before proceeding with the mapping operation. It should return early if path is not present.
@trag-bot didn't find any issues in the code! ✅✨ |
Custom CSL Styles & build-time loading
Follow-up to #12472
A. Functionality
The list of available CSL styles is now determined at build-time.
Common metadata (
path
,title
,isNumericStyle
) from internal.csl
files is pre-fetched and stored in a JSON file (citation-style-catalog.json
) viaCitationStyleCatalogGenerator
. This reduces delays in population of the styles list (and cuts off some parsing overhead) for both the OO/LO integration as well as the preview viewer.Form:
Revamped Select Style dialog UI - now both the CSL and JStyle tabs uniformly use
TableView
.Support for external CSL styles:
B. Code quality
CitationStyle
now only handles modelling of a CSL style.CitationStyleCatalogGenerator
along withCSLStyleLoader
takes care of loading/removal of styles.CSLStyleUtils
handles creation of CSL style instances and parsing.StyleSelectDialogView
, the handling of different components is now much more neatly compartmentalized for both CSL styles and JStyles.StyleSelectDialogViewModel
has also been refactored for better manageability).OOBibStyle
toJStyle
.JStyle
class.Closes #12337
Mandatory checks
CHANGELOG.md
described in a way that is understandable for the average user (if change is visible to the user)