Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.logic.openoffice.oocsltext

public Class BSTCitationOOAdapter

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.io.IOException, java.util.ArrayList, .Comparator, .LinkedHashMap, .LinkedHashSet, .List, .Map, .SequencedSet, .StringJoiner, java.util.regex.Matcher, .Pattern, org.jabref.logic.bst.BstVM, org.jabref.logic.openoffice.OpenOfficePreferences, org.jabref.logic.openoffice.bst.BSTFormatUtils, .BstEntryRenderer, .PandocLatexConverter, org.jabref.logic.openoffice.style.BstCitationFormat, .BstStyle, org.jabref.model.database.BibDatabase, .BibDatabaseContext, org.jabref.model.entry.AuthorList, .BibEntry, org.jabref.model.entry.field.StandardField, org.jabref.model.openoffice.ootext.OOFormat, .OOText, .OOTextIntoOO, org.jabref.model.openoffice.uno.CreationException, com.google.common.annotations.VisibleForTesting, com.sun.star.container.NoSuchElementException, com.sun.star.lang.WrappedTargetException, com.sun.star.text.XTextCursor, com.sun.star.text.XTextDocument, com.sun.star.uno.XComponentContext, org.jspecify.annotations.NullMarked

Inserts BST-styled citations and bibliography into a LibreOffice document.

In-text citation format is controlled by OpenOfficePreferences#getBstCitationFormat: numeric [n], author-year (Name, Year), or style-defined \bibitem[label]{key} markers. The bibliography is always rendered by the BST engine regardless of the citation format setting.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static record

Field Summary

Modifier and TypeField and Description
private static final Pattern
BIBITEM_PATTERN

Matches a rendered \\bibitem, capturing its optional display label and required key.

private final com.sun.star.uno.XComponentContext
private final com.sun.star.text.XTextDocument
private Map<String, String>
private final BSTReferenceMarkManager
private final OpenOfficePreferences
private final PandocLatexConverter

Constructor Summary

AccessConstructor and Description
public
BSTCitationOOAdapter(com.sun.star.text.XTextDocument document, com.sun.star.uno.XComponentContext componentContext, OpenOfficePreferences openOfficePreferences)

Method Summary

Modifier and TypeMethod and Description
pack-priv static String
private String
pack-priv static String
buildNumericCitationText(List<String> identifiers, Map<String, Integer> identifierToNumberMap)

private String
pack-priv static String
buildStyleDefinedCitationText(List<String> identifiers, Map<String, String> identifierToLabelMap)

pack-priv static BSTCitationOOAdapter.StyleOrderAndLabels
pack-priv static BSTCitationOOAdapter.StyleOrderAndLabels
computeStyleOrderAndLabels(String renderedBibliography, Map<String, String> keyToIdentifier)

private boolean
private void
pack-priv static String
private List<BibEntry>
public List<String>
pack-priv static String
getStyleDefinedLabelOrThrow(String identifier, Map<String, String> identifierToLabelMap)

public void
insertBibliography(com.sun.star.text.XTextCursor cursor, BstStyle style, List<BibEntry> entries, BibDatabaseContext ctx)

Inserts the bibliography by rendering each cited entry through BST → pandoc → OOText.

public void
insertCitation(com.sun.star.text.XTextCursor cursor, List<BibEntry> entries, BibDatabaseContext ctx)

Inserts an in-text citation mark.

private void
public boolean
isCitedEntry(BibEntry entry)

Returns true if the given entry has already been cited in the document.

pack-priv static boolean
pack-priv static String
public void
private void
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BIBITEM_PATTERNback to summary
private static final Pattern BIBITEM_PATTERN

Matches a rendered \\bibitem, capturing its optional display label and required key.

Examples:

  • \\bibitem{smith2020} → label absent, key smith2020
  • \\bibitem[SG20]{smith2020} → label SG20, key smith2020
componentContextback to summary
private final com.sun.star.uno.XComponentContext componentContext
documentback to summary
private final com.sun.star.text.XTextDocument document
identifierToLabelMapback to summary
private Map<String, String> identifierToLabelMap
markManagerback to summary
private final BSTReferenceMarkManager markManager
openOfficePreferencesback to summary
private final OpenOfficePreferences openOfficePreferences
pandocback to summary
private final PandocLatexConverter pandoc

Constructor Detail

BSTCitationOOAdapterback to summary
public BSTCitationOOAdapter(com.sun.star.text.XTextDocument document, com.sun.star.uno.XComponentContext componentContext, OpenOfficePreferences openOfficePreferences) throws com.sun.star.lang.WrappedTargetException, com.sun.star.container.NoSuchElementException

Method Detail

buildAuthorYearCitationback to summary
pack-priv static String buildAuthorYearCitation(List<BibEntry> entries, BibDatabaseContext ctx)
Annotations
@VisibleForTesting
buildNumericCitationback to summary
private String buildNumericCitation(List<BibEntry> entries)
buildNumericCitationTextback to summary
pack-priv static String buildNumericCitationText(List<String> identifiers, Map<String, Integer> identifierToNumberMap)
Annotations
@VisibleForTesting
buildStyleDefinedCitationback to summary
private String buildStyleDefinedCitation(List<BibEntry> entries, BibDatabaseContext ctx) throws MissingStyleDefinedCitationLabelException
buildStyleDefinedCitationTextback to summary
pack-priv static String buildStyleDefinedCitationText(List<String> identifiers, Map<String, String> identifierToLabelMap) throws MissingStyleDefinedCitationLabelException
Annotations
@VisibleForTesting
computeStyleOrderAndLabelsback to summary
pack-priv static BSTCitationOOAdapter.StyleOrderAndLabels computeStyleOrderAndLabels(BstVM bstVM, List<BibEntry> entries, BibDatabase database)
Annotations
@VisibleForTesting
computeStyleOrderAndLabelsback to summary
pack-priv static BSTCitationOOAdapter.StyleOrderAndLabels computeStyleOrderAndLabels(String renderedBibliography, Map<String, String> keyToIdentifier)
Annotations
@VisibleForTesting
currentStyleUsesStyleDefinedNumericOrderback to summary
private boolean currentStyleUsesStyleDefinedNumericOrder()
ensureStyleDefinedLabelsback to summary
private void ensureStyleDefinedLabels(List<BibEntry> entries, BibDatabase database)
extractFirstAuthorLastNameback to summary
pack-priv static String extractFirstAuthorLastName(BibEntry entry)
Annotations
@VisibleForTesting
getCitedEntriesIncludingback to summary
private List<BibEntry> getCitedEntriesIncluding(List<BibEntry> entries, BibDatabase database)
getCitedIdentifiersback to summary
public List<String> getCitedIdentifiers() throws com.sun.star.lang.WrappedTargetException, com.sun.star.container.NoSuchElementException
getStyleDefinedLabelOrThrowback to summary
pack-priv static String getStyleDefinedLabelOrThrow(String identifier, Map<String, String> identifierToLabelMap) throws MissingStyleDefinedCitationLabelException
Annotations
@VisibleForTesting
insertBibliographyback to summary
public void insertBibliography(com.sun.star.text.XTextCursor cursor, BstStyle style, List<BibEntry> entries, BibDatabaseContext ctx) throws IOException, InterruptedException, com.sun.star.uno.Exception, CreationException, MissingStyleDefinedCitationLabelException

Inserts the bibliography by rendering each cited entry through BST → pandoc → OOText. Entries are sorted by first-appearance (citation-number) order or BST style order.

insertCitationback to summary
public void insertCitation(com.sun.star.text.XTextCursor cursor, List<BibEntry> entries, BibDatabaseContext ctx) throws CreationException, com.sun.star.uno.Exception, MissingStyleDefinedCitationLabelException

Inserts an in-text citation mark. Format depends on OpenOfficePreferences#getBstCitationFormat:

invalidateStyleDefinedLabelsback to summary
private void invalidateStyleDefinedLabels()
isCitedEntryback to summary
public boolean isCitedEntry(BibEntry entry)

Returns true if the given entry has already been cited in the document.

isSupportedStyleDefinedLabelback to summary
pack-priv static boolean isSupportedStyleDefinedLabel(String label)
Annotations
@VisibleForTesting
keyOrIdback to summary
pack-priv static String keyOrId(BibEntry entry)
Annotations
@VisibleForTesting
refreshCitationStateback to summary
public void refreshCitationState() throws com.sun.star.lang.WrappedTargetException, com.sun.star.container.NoSuchElementException
updateNumericCitationTextsback to summary
private void updateNumericCitationTexts(BibDatabase database) throws CreationException, com.sun.star.uno.Exception
updateStyleDefinedCitationTextsback to summary
private void updateStyleDefinedCitationTexts(BibDatabase database) throws CreationException, com.sun.star.uno.Exception, MissingStyleDefinedCitationLabelException
org.jabref.logic.openoffice.oocsltext back to summary

pack-priv final Record BSTCitationOOAdapter.StyleOrderAndLabels

extends Record
Class Inheritance
Annotations
@VisibleForTesting
Record Components
identifierToNumberMap:Map<String, Integer> 
identifierToLabelMap:Map<String, String> 

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
identifierToLabelMap

Record Component accessed by identifierToLabelMap().

private final Map<String, Integer>
identifierToNumberMap

Record Component accessed by identifierToNumberMap().

Constructor Summary

AccessConstructor and Description
pack-priv
StyleOrderAndLabels(Map<String, Integer> identifierToNumberMap, Map<String, String> identifierToLabelMap)

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Map<String, String>
identifierToLabelMap()

Record Component getter of identifierToLabelMap.

public Map<String, Integer>
identifierToNumberMap()

Record Component getter of identifierToNumberMap.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

identifierToLabelMapback to summary
private final Map<String, String> identifierToLabelMap

Record Component accessed by identifierToLabelMap().

identifierToNumberMapback to summary
private final Map<String, Integer> identifierToNumberMap

Record Component accessed by identifierToNumberMap().

Constructor Detail

StyleOrderAndLabelsback to summary
pack-priv StyleOrderAndLabels(Map<String, Integer> identifierToNumberMap, Map<String, String> identifierToLabelMap)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

identifierToLabelMapback to summary
public Map<String, String> identifierToLabelMap()

Record Component getter of identifierToLabelMap.

identifierToNumberMapback to summary
public Map<String, Integer> identifierToNumberMap()

Record Component getter of identifierToNumberMap.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.