Skip to content
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

Feature: Support Citation Style Language (CSL) Styles in LibreOffice/OpenOffice #1

Open
wants to merge 4 commits into
base: csl-lo-oo-integration
Choose a base branch
from

Conversation

cnwangjihe
Copy link

@cnwangjihe cnwangjihe commented Jun 30, 2022

Implement JabRef#8893.
Support Citation Style Language (CSL) Styles in the LO/OO integration.
Everything is now still working in progress.

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@cnwangjihe cnwangjihe added the enhancement New feature or request label Jun 30, 2022

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.jabref.logic.citationstyle.CitationStyle;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [reviewdog] <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck> reported by reviewdog 🐶
'org.jabref.logic.citationstyle.CitationStyle' should be separated from previous imports.

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import org.jabref.logic.citationstyle.CitationStyle;
import org.jabref.logic.openoffice.style.OOBibStyle;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [reviewdog] <com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck> reported by reviewdog 🐶
Unused import - org.jabref.logic.openoffice.style.OOBibStyle.

@@ -31,6 +33,8 @@
import com.airhacks.afterburner.views.ViewLoader;
import com.tobiasdiez.easybind.EasyBind;

import java.util.stream.Collectors;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [reviewdog] <com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck> reported by reviewdog 🐶
Wrong order for 'java.util.stream.Collectors' import.

@cnwangjihe
Copy link
Author

要支持CSL格式目前还有很多地方需要大改,首先是StyleSelectDialogView

preferences.setExternalStyles(externalStyles);
// TODO: Fit CSL into preferences style
preferences.setCurrentStyle(selectedItem.getValue().getStylePath());
preferencesService.setOpenOfficePreferences(preferences);

可以看到,他将JStyle的文件路径传递给了preferencesService,作为配置保存
然后在OpenOfficePanel中点击Cite后,会通过如下代码发送插入指令到OO/LO
ooBase.guiActionInsertEntry(entries,
database,
style,
citationType,
pageInfo,
syncOptions);
}

而此处的style是通过loader的getUsedStyle获取的
private boolean getOrUpdateTheStyle(String title) {
final boolean FAIL = true;
final boolean PASS = false;
if (style == null) {
style = loader.getUsedStyle();

getUsedStyle又是通过preferencesService获取到Style路径,抽取出loader中对应的OOBibStyle实例
public OOBibStyle getUsedStyle() {
String filename = openOfficePreferences.getCurrentStyle();
if (filename != null) {
for (OOBibStyle style : getStyles()) {
if (filename.equals(style.getPath())) {
return style;
}

然后这个OOBibStyle并不是一个接口,而是一个十分复杂的类,里面的所有操作、属性都与JStyle硬相关,甚至连构造函数就是通过传入JStyle Path来实例化,否则只能逐个设置所有属性(这些属性估计CSL也没有)
public OOBibStyle(String resourcePath, LayoutFormatterPreferences prefs) throws IOException {
this.prefs = Objects.requireNonNull(prefs);
Objects.requireNonNull(resourcePath);
setDefaultProperties();
initialize(OOBibStyle.class.getResourceAsStream(resourcePath));
fromResource = true;
path = resourcePath;
}

然后这个类和整个OpenOffice Panel的耦合也比较深
image
方法也巨多(不知道那些被外部使用了就是了,这就是不用接口的坏处/(ㄒoㄒ)/~~)
image
综上,感觉很难完工(

@hktk1643
Copy link

We have finished the UI design for additional CSL styles.
75F8B1EC7D396E52CD0AC4524C43F567
AE719336B30C338D3A65785C2AFDC37B
However, we found it difficult to do the functional part of the implementation because the original implementation was highly coupled with the JStyle format, and adding support for CSL would require extensive changes to the whole part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants