Skip to content

fix:Libre office reference extension after adding spaces.#13592

Merged
subhramit merged 17 commits into
JabRef:mainfrom
tushar-2320:fix-for-issue-13559
Aug 7, 2025
Merged

fix:Libre office reference extension after adding spaces.#13592
subhramit merged 17 commits into
JabRef:mainfrom
tushar-2320:fix-for-issue-13559

Conversation

@tushar-2320

@tushar-2320 tushar-2320 commented Jul 27, 2025

Copy link
Copy Markdown
Contributor

Closes #13559

I have added Add space after citation in settings of open office panel.
screen recording of it is as follows.

Screen.Recording.2025-08-06.at.11.18.19.AM.mp4

so now by selecting checkbox we get space after citation.

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • [/] Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (if change is visible to the user)
  • 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.

@tushar-2320 tushar-2320 marked this pull request as draft July 27, 2025 05:01
@subhramit

Copy link
Copy Markdown
Member

Please provide an appropriate name and description to your PR, even if draft.

@tushar-2320 tushar-2320 changed the title intial commit. fix:Libre office reference extension after adding spaces. Jul 27, 2025
@subhramit

Copy link
Copy Markdown
Member

Hey, let me know if you need any help continuing this.

@tushar-2320

Copy link
Copy Markdown
Contributor Author

Hey I got preferences but i am not able to understand flow how do change the Boolean value from settings @subhramit

@subhramit

Copy link
Copy Markdown
Member

Hey I got preferences but i am not able to understand flow how do change the Boolean value from settings @subhramit

See how the first setting in the screenshot in the issue is set (automatically sync bibliography) for example. That's also a boolean, right?

@tushar-2320

Copy link
Copy Markdown
Contributor Author

hey @subhramit just check wether I am in right direction or not?

CheckMenuItem autoSync = new CheckMenuItem(Localization.lang("Automatically sync bibliography when inserting citations"));
autoSync.selectedProperty().set(openOfficePreferences.getSyncWhenCiting());

CheckMenuItem smartSpace = new CheckMenuItem(Localization.lang("Add smart space after citation"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The space we add before citations are called "smart" because they are aware of if a space already exists.
For the space after, we are just adding it if an option is manually enabled, so change this to 'add space after citations"

private final StringProperty cslBibliographyHeaderFormat;
private final StringProperty cslBibliographyBodyFormat;
private final ObservableList<String> externalCslStyles;
private final BooleanProperty smartSpaceAfter;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have to rename all these variables and methods due to above explanation.

public static final String OO_CSL_BIBLIOGRAPHY_HEADER_FORMAT = "cslBibliographyHeaderFormat";
public static final String OO_CSL_BIBLIOGRAPHY_BODY_FORMAT = "cslBibliographyBodyFormat";

public static final String OO_SMART_SPACE_AFTER = "ooSmartSpaceAfter";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename everywhere

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, i have left some initial comments. Your direction of playing around with preferences and properties is correct, but somehow the changes to CSLCitationooadapter seem to be lost. So you have to use this property in the functions there from preferences henceforth.

@tushar-panto

Copy link
Copy Markdown
Contributor

I tried to make changes around CSLCitationooadapter property just check it is this how its done @subhramit .?

@subhramit

subhramit commented Aug 4, 2025

Copy link
Copy Markdown
Member

I tried to make changes around CSLCitationooadapter property just check it is this how its done @subhramit .?

Unfortunately, that's not the right way. I get your thought process, but you had to use preferences, not the injector injection via constructor. See, for example, how the current style is obtained in the class from preferences. Since preferences are already imported and initialized in the class, why not use them?

PS - if this explanation is unclear, please do ask for more clarification. The reason I'm not giving you the solution right away is so that you learn something when navigating the codebase as well.
When following an example, try to understand what it is doing rather than just making an equivalent copy-paste.

@tushar-2320

Copy link
Copy Markdown
Contributor Author

now can you check @subhramit ?

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Few comments on correctness.
After you are done with these, add a changelog entry, move the PR away from draft, mark the mandatory checks, write a description and post a short screen recording of the changes.


private CitationStyle currentStyle;
private boolean styleChanged;
private boolean addSpaceAfter;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove


OOStyle initialStyle = openOfficePreferences.getCurrentStyle(); // may be a jstyle, can still be used for detecting subsequent style changes in context of CSL

this.addSpaceAfter = openOfficePreferences.getAddSpaceAfter();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove

}

markManager.insertReferenceIntoOO(entries, document, cursor, ooText, !preceedingSpaceExists, false);
markManager.insertReferenceIntoOO(entries, document, cursor, ooText, !preceedingSpaceExists, addSpaceAfter);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use this

Suggested change
markManager.insertReferenceIntoOO(entries, document, cursor, ooText, !preceedingSpaceExists, addSpaceAfter);
markManager.insertReferenceIntoOO(entries, document, cursor, ooText, !preceedingSpaceExists, openOfficePreferences.getAddSpaceAfter());

Reason: The setting may have changed after the instantiation of the adapter.

CheckMenuItem autoSync = new CheckMenuItem(Localization.lang("Automatically sync bibliography when inserting citations"));
autoSync.selectedProperty().set(openOfficePreferences.getSyncWhenCiting());

CheckMenuItem addSpaceAfter = new CheckMenuItem(Localization.lang("Add space after citation"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
CheckMenuItem addSpaceAfter = new CheckMenuItem(Localization.lang("Add space after citation"));
CheckMenuItem addSpaceAfter = new CheckMenuItem(Localization.lang("Add space after citation"));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, add the keys to the localization JabRef_en.properties file (see the failing check).


Automatically\ add\ "Cited\ on\ pages..."\ at\ the\ end\ of\ bibliographic\ entries=Automatically add "Cited on pages..." at the end of bibliographic entries
Automatically\ sync\ bibliography\ when\ inserting\ citations=Automatically sync bibliography when inserting citations
"Add\ space\ after\ citation"=Add space after citation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why the extra space above and here? You can click commit suggestion in https://github.com/JabRef/jabref/pull/13592/files#r2253606699 and below:

Suggested change
"Add\ space\ after\ citation"=Add space after citation
"Add\ space\ after\ citation"=Add space after citation


Automatically\ add\ "Cited\ on\ pages..."\ at\ the\ end\ of\ bibliographic\ entries=Automatically add "Cited on pages..." at the end of bibliographic entries
Automatically\ sync\ bibliography\ when\ inserting\ citations=Automatically sync bibliography when inserting citations
"Add\ space\ after\ citation"=Add space after citation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please look at 1. Other example entries. And/or 2. Failing checks by clicking on them to get hints as to which tests are failing. The bot comments already instruct on this.

In this case, you have to remove the quotes. There should be no quotes, unless they are a part of the string itself.

Suggested change
"Add\ space\ after\ citation"=Add space after citation
Add\ space\ after\ citation=Add space after citation

@tushar-2320

Copy link
Copy Markdown
Contributor Author

@subhramit can you check screen recording?

@subhramit

Copy link
Copy Markdown
Member

@subhramit can you check screen recording?

Yep, that's correct. I tried out myself, works properly.

Mow please add a changelog entry and mark the pr non-draft (ready for review).

@tushar-2320 tushar-2320 marked this pull request as ready for review August 6, 2025 08:43
Comment thread CHANGELOG.md Outdated
subhramit
subhramit previously approved these changes Aug 6, 2025

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I refined the changelog entry a bit, rest lgtm

@subhramit subhramit enabled auto-merge August 7, 2025 17:32
@trag-bot

trag-bot Bot commented Aug 7, 2025

Copy link
Copy Markdown

@trag-bot didn't find any issues in the code! ✅✨

@subhramit subhramit added this pull request to the merge queue Aug 7, 2025
Merged via the queue into JabRef:main with commit 197bc13 Aug 7, 2025
1 check passed
@github-actions github-actions Bot mentioned this pull request Aug 7, 2025
2 tasks
@tushar-2320

Copy link
Copy Markdown
Contributor Author

Thank you @subhramit for guiding me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LibreOffice Writer and JabRef

3 participants