Top Description Fields Constructors Methods
org.jabref.gui.openoffice

pack-priv Class OOBibBase

extends Object
Class Inheritance
Imports
java.nio.file.Path, java.util.ArrayList, .Arrays, .List, .Objects, .Optional, java.util.function.Supplier, java.util.stream.Collectors, org.jabref.gui.DialogService, org.jabref.logic.JabRefException, org.jabref.logic.l10n.Localization, org.jabref.logic.openoffice.NoDocumentFoundException, org.jabref.logic.openoffice.action.EditInsert, .EditMerge, .EditSeparate, .ExportCited, .ManageCitations, .Update, org.jabref.logic.openoffice.frontend.OOFrontend, .RangeForOverlapCheck, org.jabref.logic.openoffice.style.OOBibStyle, org.jabref.model.database.BibDatabase, org.jabref.model.entry.BibEntry, org.jabref.model.openoffice.CitationEntry, org.jabref.model.openoffice.rangesort.FunctionalTextViewCursor, org.jabref.model.openoffice.style.CitationGroupId, .CitationType, org.jabref.model.openoffice.uno.CreationException, .NoDocumentException, .UnoCrossRef, .UnoCursor, .UnoRedlines, .UnoStyle, .UnoUndo, org.jabref.model.openoffice.util.OOResult, .OOVoidResult, com.sun.star.beans.IllegalTypeException, com.sun.star.beans.NotRemoveableException, com.sun.star.beans.PropertyVetoException, com.sun.star.comp.helper.BootstrapException, com.sun.star.container.NoSuchElementException, com.sun.star.lang.DisposedException, com.sun.star.lang.WrappedTargetException, com.sun.star.text.XTextCursor, com.sun.star.text.XTextDocument, org.slf4j.Logger, .LoggerFactory

Class for manipulating the Bibliography of the currently started document in OpenOffice.

Field Summary

Modifier and TypeField and Description
private final boolean
private final OOBibBaseConnect
private final DialogService
private static final Logger
private final boolean

Constructor Summary

AccessConstructor and Description
public
OOBibBase(Path loPath, DialogService dialogService)

Method Summary

Modifier and TypeMethod and Description
private static OOVoidResult<OOError>
checkIfOpenOfficeIsRecordingChanges(com.sun.star.text.XTextDocument doc)

private static OOVoidResult<OOError>
checkRangeOverlaps(com.sun.star.text.XTextDocument doc, OOFrontend frontend)

private static OOVoidResult<OOError>
checkRangeOverlapsWithCursor(com.sun.star.text.XTextDocument doc, OOFrontend frontend)

private OOVoidResult<OOError>
checkStyleExistsInTheDocument(String familyName, String styleName, com.sun.star.text.XTextDocument doc, String labelInJstyleFile, String pathToStyleFile)

public OOVoidResult<OOError>
checkStylesExistInTheDocument(OOBibStyle style, com.sun.star.text.XTextDocument doc)

pack-priv OOVoidResult<OOError>
pack-priv OOVoidResult<OOError>
public Optional<BibDatabase>
exportCitedHelper(List<BibDatabase> databases, boolean
If there are some unresolved keys, shall we return an otherwise nonempty result, or Optional.empty()?
returnPartialResult
)

GUI action for "Export cited"

Does not refresh the bibliography.

public Optional<String>
getCurrentDocumentTitle()

The title of the current document, or Optional.empty()

pack-priv OOResult<OOFrontend, OOError>
getFrontend(com.sun.star.text.XTextDocument doc)

pack-priv OOResult<FunctionalTextViewCursor, OOError>
getFunctionalTextViewCursor(com.sun.star.text.XTextDocument doc, String errorTitle)

This may move the view cursor.

pack-priv OOResult<com.sun.star.text.XTextCursor, OOError>
getUserCursorForTextInsertion(com.sun.star.text.XTextDocument doc, String errorTitle)

Get the cursor positioned by the user for inserting text.

public OOResult<com.sun.star.text.XTextDocument, OOError>
getXTextDocument()

Either return an XTextDocument or return JabRefException.

public void
guiActionApplyCitationEntries(List<CitationEntry> citationEntries)

Apply editable parts of citationEntries to the document: store pageInfo.

public Optional<List<CitationEntry>>
public void
guiActionInsertEntry(List<BibEntry>
The entries to cite.
entries
,
BibDatabase
The database the entries belong to (all of them). Used when creating the citation mark.

Consistency: for each entry in entries: looking it up in syncOptions.get().databases (if present) should yield database.

database
,
OOBibStyle
The bibliography style we are using.
style
,
CitationType
Indicates whether it is an in-text citation, a citation in parenthesis or an invisible citation.
citationType
,
String
A single page-info for these entries. Attributed to the last entry.
pageInfo
,
Optional<Update.SyncOptions>
Indicates whether in-text citations should be refreshed in the document. Optional.empty() indicates no refresh. Otherwise provides options for refreshing the reference list.
syncOptions
)

Creates a citation group from entries at the cursor.

public void
guiActionMergeCitationGroups(List<BibDatabase> databases, OOBibStyle style)

GUI action "Merge citations"

public void
guiActionSelectDocument(boolean autoSelectForSingle)

public void
guiActionSeparateCitations(List<BibDatabase> databases, OOBibStyle style)

GUI action "Separate citations".

public void
guiActionUpdateDocument(List<BibDatabase>
Must have at least one.
databases
,
OOBibStyle
Style.
style
)

GUI action, refreshes citation markers and bibliography.

public boolean
isConnectedToDocument()

A simple test for document availability.

public boolean

Returns:

true if we are connected to a document
isDocumentConnectionMissing
()

pack-priv OOVoidResult<OOError>
pack-priv void
pack-priv void
showDialog(String errorTitle, OOError err)

pack-priv OOVoidResult<OOError>
pack-priv boolean
pack-priv boolean
pack-priv boolean
testDialog(String errorTitle, List<OOVoidResult<OOError>> results)

pack-priv final boolean
testDialog(String errorTitle, OOVoidResult<OOError>... results)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

alwaysAddCitedOnPagesback to summary
private final boolean alwaysAddCitedOnPages
connectionback to summary
private final OOBibBaseConnect connection
dialogServiceback to summary
private final DialogService dialogService
LOGGERback to summary
private static final Logger LOGGER
refreshBibliographyDuringSyncWhenCitingback to summary
private final boolean refreshBibliographyDuringSyncWhenCiting

Constructor Detail

OOBibBaseback to summary
public OOBibBase(Path loPath, DialogService dialogService) throws com.sun.star.comp.helper.BootstrapException, CreationException

Method Detail

checkIfOpenOfficeIsRecordingChangesback to summary
private static OOVoidResult<OOError> checkIfOpenOfficeIsRecordingChanges(com.sun.star.text.XTextDocument doc)
checkRangeOverlapsback to summary
private static OOVoidResult<OOError> checkRangeOverlaps(com.sun.star.text.XTextDocument doc, OOFrontend frontend)
checkRangeOverlapsWithCursorback to summary
private static OOVoidResult<OOError> checkRangeOverlapsWithCursor(com.sun.star.text.XTextDocument doc, OOFrontend frontend)
checkStyleExistsInTheDocumentback to summary
private OOVoidResult<OOError> checkStyleExistsInTheDocument(String familyName, String styleName, com.sun.star.text.XTextDocument doc, String labelInJstyleFile, String pathToStyleFile) throws com.sun.star.lang.WrappedTargetException
checkStylesExistInTheDocumentback to summary
public OOVoidResult<OOError> checkStylesExistInTheDocument(OOBibStyle style, com.sun.star.text.XTextDocument doc)
collectResultsback to summary
pack-priv OOVoidResult<OOError> collectResults(String errorTitle, List<OOVoidResult<OOError>> results)
databaseIsRequiredback to summary
pack-priv OOVoidResult<OOError> databaseIsRequired(List<BibDatabase> databases, Supplier<OOError> fun)
exportCitedHelperback to summary
public Optional<BibDatabase> exportCitedHelper(List<BibDatabase> databases, boolean returnPartialResult)

GUI action for "Export cited"

Does not refresh the bibliography.

Parameters
returnPartialResult:boolean

If there are some unresolved keys, shall we return an otherwise nonempty result, or Optional.empty()?

getCurrentDocumentTitleback to summary
public Optional<String> getCurrentDocumentTitle()

The title of the current document, or Optional.empty()

getFrontendback to summary
pack-priv OOResult<OOFrontend, OOError> getFrontend(com.sun.star.text.XTextDocument doc)
getFunctionalTextViewCursorback to summary
pack-priv OOResult<FunctionalTextViewCursor, OOError> getFunctionalTextViewCursor(com.sun.star.text.XTextDocument doc, String errorTitle)

This may move the view cursor.

getUserCursorForTextInsertionback to summary
pack-priv OOResult<com.sun.star.text.XTextCursor, OOError> getUserCursorForTextInsertion(com.sun.star.text.XTextDocument doc, String errorTitle)

Get the cursor positioned by the user for inserting text.

getXTextDocumentback to summary
public OOResult<com.sun.star.text.XTextDocument, OOError> getXTextDocument()

Either return an XTextDocument or return JabRefException.

guiActionApplyCitationEntriesback to summary
public void guiActionApplyCitationEntries(List<CitationEntry> citationEntries)

Apply editable parts of citationEntries to the document: store pageInfo.

Does not change presentation.

Note

we use no undo context here, because only DocumentConnection.setUserDefinedStringPropertyValue() is called, and Undo in LO will not undo that.

GUI: "Manage citations" dialog "OK" button. Called from: ManageCitationsDialogViewModel.storeSettings

Currently the only editable part is pageInfo.

Since the only call to applyCitationEntries() only changes pageInfo w.r.t those returned by getCitationEntries(), we can do with the following restrictions:

  • Missing pageInfo means no action.
  • Missing CitationEntry means no action (no attempt to remove citation from the text).
guiActionGetCitationEntriesback to summary
public Optional<List<CitationEntry>> guiActionGetCitationEntries()
guiActionInsertEntryback to summary
public void guiActionInsertEntry(List<BibEntry> entries, BibDatabase database, OOBibStyle style, CitationType citationType, String pageInfo, Optional<Update.SyncOptions> syncOptions)

Creates a citation group from entries at the cursor.

Uses LO undo context "Insert citation".

Note

Undo does not remove or reestablish custom properties.

Parameters
entries:List<BibEntry>

The entries to cite.

database:BibDatabase

The database the entries belong to (all of them). Used when creating the citation mark.

Consistency: for each entry in entries: looking it up in syncOptions.get().databases (if present) should yield database.

style:OOBibStyle

The bibliography style we are using.

citationType:CitationType

Indicates whether it is an in-text citation, a citation in parenthesis or an invisible citation.

pageInfo:String

A single page-info for these entries. Attributed to the last entry.

syncOptions:Optional<Update.SyncOptions>

Indicates whether in-text citations should be refreshed in the document. Optional.empty() indicates no refresh. Otherwise provides options for refreshing the reference list.

guiActionMergeCitationGroupsback to summary
public void guiActionMergeCitationGroups(List<BibDatabase> databases, OOBibStyle style)

GUI action "Merge citations"

guiActionSelectDocumentback to summary
public void guiActionSelectDocument(boolean autoSelectForSingle)
guiActionSeparateCitationsback to summary
public void guiActionSeparateCitations(List<BibDatabase> databases, OOBibStyle style)

GUI action "Separate citations".

Do the opposite of MergeCitationGroups. Combined markers are split, with a space inserted between.

guiActionUpdateDocumentback to summary
public void guiActionUpdateDocument(List<BibDatabase> databases, OOBibStyle style)

GUI action, refreshes citation markers and bibliography.

Parameters
databases:List<BibDatabase>

Must have at least one.

style:OOBibStyle

Style.

isConnectedToDocumentback to summary
public boolean isConnectedToDocument()

A simple test for document availability.

See also `isDocumentConnectionMissing` for a test actually attempting to use the connection.

isDocumentConnectionMissingback to summary
public boolean isDocumentConnectionMissing()
Returns:boolean

true if we are connected to a document

selectedBibEntryIsRequiredback to summary
pack-priv OOVoidResult<OOError> selectedBibEntryIsRequired(List<BibEntry> entries, Supplier<OOError> fun)
showDialogback to summary
pack-priv void showDialog(OOError err)
showDialogback to summary
pack-priv void showDialog(String errorTitle, OOError err)
styleIsRequiredback to summary
pack-priv OOVoidResult<OOError> styleIsRequired(OOBibStyle style)
testDialogback to summary
pack-priv boolean testDialog(OOVoidResult<OOError> res)
testDialogback to summary
pack-priv boolean testDialog(String errorTitle, OOVoidResult<OOError> res)
testDialogback to summary
pack-priv boolean testDialog(String errorTitle, List<OOVoidResult<OOError>> results)
testDialogback to summary
pack-priv final boolean testDialog(String errorTitle, OOVoidResult<OOError>... results)
Annotations
@SafeVarargs