Top Fields Constructors Methods
org.jabref.logic.openoffice.frontend

public Class OOFrontend

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .List, .Map, .Objects, .Optional, java.util.stream.Collectors, org.jabref.logic.JabRefException, org.jabref.logic.l10n.Localization, org.jabref.logic.openoffice.backend.Backend52, org.jabref.model.openoffice.CitationEntry, org.jabref.model.openoffice.ootext.OOText, org.jabref.model.openoffice.rangesort.FunctionalTextViewCursor, .RangeOverlap, .RangeOverlapBetween, .RangeOverlapWithin, .RangeSort, .RangeSortEntry, .RangeSortVisual, .RangeSortable, org.jabref.model.openoffice.style.CitationGroup, .CitationGroupId, .CitationGroups, .CitationType, .OODataModel, org.jabref.model.openoffice.uno.CreationException, .NoDocumentException, .UnoCursor, .UnoTextRange, org.jabref.model.openoffice.util.OOListUtil, .OOVoidResult, com.sun.star.beans.IllegalTypeException, com.sun.star.beans.NotRemoveableException, com.sun.star.beans.PropertyVetoException, com.sun.star.lang.WrappedTargetException, com.sun.star.text.XTextCursor, com.sun.star.text.XTextDocument, com.sun.star.text.XTextRange

Field Summary

Modifier and TypeField and Description
public final Backend52
public final CitationGroups

Constructor Summary

AccessConstructor and Description
public
OOFrontend(com.sun.star.text.XTextDocument doc)

Method Summary

Modifier and TypeMethod and Description
public void
applyCitationEntries(com.sun.star.text.XTextDocument doc, List<CitationEntry> citationEntries)

public List<RangeForOverlapCheck<CitationGroupId>>
bibliographyRanges(com.sun.star.text.XTextDocument doc)

public OOVoidResult<JabRefException>
checkRangeOverlaps(com.sun.star.text.XTextDocument doc, List<RangeForOverlapCheck<CitationGroupId>> userRanges, boolean
Report range pairs that only share a boundary.
requireSeparation
,
int
Limit number of overlaps reported (0 for no limit)
reportAtMost
)

public OOVoidResult<JabRefException>
checkRangeOverlapsWithCursor(com.sun.star.text.XTextDocument doc, List<RangeForOverlapCheck<CitationGroupId>> userRanges, boolean requireSeparation)

Check for any overlap between userRanges and protected ranges.

public List<RangeForOverlapCheck<CitationGroupId>>

Returns:

A RangeForOverlapCheck for each citation group. result.size() == nRefMarks
citationRanges
(com.sun.star.text.XTextDocument doc)

public void
cleanFillCursorForCitationGroup(com.sun.star.text.XTextDocument doc, CitationGroup group)

Remove brackets added by getFillCursorForCitationGroup.

public CitationGroup
createCitationGroup(com.sun.star.text.XTextDocument doc, List<String>
In storage order
citationKeys
,
List<Optional<OOText>>
In storage order
pageInfos
,
CitationType citationType, com.sun.star.text.XTextCursor
Collapsed to its end.
position
,
boolean
If true, we insert a space after the mark, that carries on format of characters from the original position.
insertSpaceAfter
)

Create a citation group for the given citation keys, at the end of position.

private List<RangeSortable<CitationGroup>>
createVisualSortInput(com.sun.star.text.XTextDocument doc, boolean
If true, replace ranges in footnotes with the range of the corresponding footnote mark. This is used for numbering the citations.
mapFootnotesToFootnoteMarks
)

Creates a list of RangeSortable<CitationGroup> values for our CitationGroup values.

public List<RangeForOverlapCheck<CitationGroupId>>

Returns:

A range for each footnote mark where the footnote contains at least one citation group. Purpose: We do not want markers of footnotes containing reference marks to overlap with reference marks. Overwriting these footnote marks might kill our reference marks in the footnote.

Note

Here we directly communicate to the document, not through the backend. This is because mapping ranges to footnote marks does not depend on how do we mark or structure those ranges.

footnoteMarkRanges
(com.sun.star.text.XTextDocument doc, List<RangeForOverlapCheck<CitationGroupId>> citationRanges)

public List<CitationEntry>

Returns:

A list with entries corresponding to citations in the text, in arbitrary order (same order as from getJabRefReferenceMarkNames).

Note

visual or alphabetic order could be more manageable for the user. We could provide these here, but switching between them needs change on GUI (adding a toggle or selector).

Note

CitationEntry implements Comparable, where compareTo() and equals() are based on refMarkName. The order used in the "Manage citations" dialog does not seem to use that.

The 1st is labeled "Citation" (show citation in bold, and some context around it).

The columns can be sorted by clicking on the column title. For the "Citation" column, the sorting is based on the content, (the context before the citation), not on the citation itself.

In the "Extra information ..." column some visual indication of the editable part could be helpful.

Wish: selecting an entry (or a button in the line) in the GUI could move the cursor in the document to the entry.

getCitationEntries
(com.sun.star.text.XTextDocument doc)

GUI: Get a list of CitationEntry objects corresponding to citations in the document.

public List<CitationGroup>
getCitationGroupsSortedWithinPartitions(com.sun.star.text.XTextDocument doc, boolean mapFootnotesToFootnoteMarks)

Return citation groups in visual order within (but not across) XText partitions.

public OODataModel
public com.sun.star.text.XTextCursor
getFillCursorForCitationGroup(com.sun.star.text.XTextDocument doc, CitationGroup group)

public Optional<com.sun.star.text.XTextRange>

Returns:

Optional.empty() if the reference mark is missing.
getMarkRange
(com.sun.star.text.XTextDocument doc, CitationGroup group)

ranges controlled by citation groups should not overlap with each other.

private List<CitationGroup>

Returns:

citation groups sorted by their visual positions. Limitation: for two column layout visual (top-down, left-right) order does not match the expected (textual) order.
getVisuallySortedCitationGroups
(com.sun.star.text.XTextDocument doc, boolean
If true, sort reference marks in footnotes as if they appeared at the corresponding footnote mark.
mapFootnotesToFootnoteMarks
,
FunctionalTextViewCursor fcursor)

public Optional<String>
healthReport(com.sun.star.text.XTextDocument doc)

public void
imposeGlobalOrder(com.sun.star.text.XTextDocument doc, FunctionalTextViewCursor fcursor)

pack-priv static String
private static Map<CitationGroupId, CitationGroup>
readCitationGroupsFromDocument(Backend52 backend, com.sun.star.text.XTextDocument doc, List<String> citationGroupNames)

public void
removeCitationGroup(CitationGroup group, com.sun.star.text.XTextDocument doc)

Remove group both from the document and notify citationGroups

public void
removeCitationGroups(List<CitationGroup> citationGroups, com.sun.star.text.XTextDocument doc)

public List<RangeForOverlapCheck<CitationGroupId>>
viewCursorRanges(com.sun.star.text.XTextDocument doc)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backendback to summary
public final Backend52 backend
citationGroupsback to summary
public final CitationGroups citationGroups

Constructor Detail

OOFrontendback to summary
public OOFrontend(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Method Detail

applyCitationEntriesback to summary
public void applyCitationEntries(com.sun.star.text.XTextDocument doc, List<CitationEntry> citationEntries) throws com.sun.star.beans.PropertyVetoException, com.sun.star.beans.IllegalTypeException, IllegalArgumentException, com.sun.star.lang.WrappedTargetException
bibliographyRangesback to summary
public List<RangeForOverlapCheck<CitationGroupId>> bibliographyRanges(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException
checkRangeOverlapsback to summary
public OOVoidResult<JabRefException> checkRangeOverlaps(com.sun.star.text.XTextDocument doc, List<RangeForOverlapCheck<CitationGroupId>> userRanges, boolean requireSeparation, int reportAtMost) throws NoDocumentException, com.sun.star.lang.WrappedTargetException
Parameters
requireSeparation:boolean

Report range pairs that only share a boundary.

reportAtMost:int

Limit number of overlaps reported (0 for no limit)

checkRangeOverlapsWithCursorback to summary
public OOVoidResult<JabRefException> checkRangeOverlapsWithCursor(com.sun.star.text.XTextDocument doc, List<RangeForOverlapCheck<CitationGroupId>> userRanges, boolean requireSeparation) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Check for any overlap between userRanges and protected ranges.

Assume userRanges is small (usually 1 elements for checking the cursor)

Returns on first problem found.

citationRangesback to summary
public List<RangeForOverlapCheck<CitationGroupId>> citationRanges(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException
Returns:List<RangeForOverlapCheck<CitationGroupId>>

A RangeForOverlapCheck for each citation group. result.size() == nRefMarks

cleanFillCursorForCitationGroupback to summary
public void cleanFillCursorForCitationGroup(com.sun.star.text.XTextDocument doc, CitationGroup group) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Remove brackets added by getFillCursorForCitationGroup.

createCitationGroupback to summary
public CitationGroup createCitationGroup(com.sun.star.text.XTextDocument doc, List<String> citationKeys, List<Optional<OOText>> pageInfos, CitationType citationType, com.sun.star.text.XTextCursor position, boolean insertSpaceAfter) throws CreationException, NoDocumentException, com.sun.star.lang.WrappedTargetException, com.sun.star.beans.NotRemoveableException, com.sun.star.beans.PropertyVetoException, com.sun.star.beans.IllegalTypeException

Create a citation group for the given citation keys, at the end of position.

On return position is collapsed, and is after the inserted space, or at the end of the reference mark.

Parameters
citationKeys:List<String>

In storage order

pageInfos:List<Optional<OOText>>

In storage order

position:com.sun.star.text.XTextCursor

Collapsed to its end.

insertSpaceAfter:boolean

If true, we insert a space after the mark, that carries on format of characters from the original position.

createVisualSortInputback to summary
private List<RangeSortable<CitationGroup>> createVisualSortInput(com.sun.star.text.XTextDocument doc, boolean mapFootnotesToFootnoteMarks) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Creates a list of RangeSortable<CitationGroup> values for our CitationGroup values. Originally designed to be passed to visualSort.

The elements of the returned list are actually of type RangeSortEntry<CitationGroup>.

The result is sorted within XTextRange.getText() partitions of the citation groups according to their XTextRange (before mapping to footnote marks).

In the result, RangeSortable.getIndexInPosition() contains unique indexes within the original partition (not after mapFootnotesToFootnoteMarks).

Parameters
mapFootnotesToFootnoteMarks:boolean

If true, replace ranges in footnotes with the range of the corresponding footnote mark. This is used for numbering the citations.

footnoteMarkRangesback to summary
public List<RangeForOverlapCheck<CitationGroupId>> footnoteMarkRanges(com.sun.star.text.XTextDocument doc, List<RangeForOverlapCheck<CitationGroupId>> citationRanges)
Returns:List<RangeForOverlapCheck<CitationGroupId>>

A range for each footnote mark where the footnote contains at least one citation group. Purpose: We do not want markers of footnotes containing reference marks to overlap with reference marks. Overwriting these footnote marks might kill our reference marks in the footnote.

Note

Here we directly communicate to the document, not through the backend. This is because mapping ranges to footnote marks does not depend on how do we mark or structure those ranges.

getCitationEntriesback to summary
public List<CitationEntry> getCitationEntries(com.sun.star.text.XTextDocument doc) throws com.sun.star.lang.WrappedTargetException, NoDocumentException

GUI: Get a list of CitationEntry objects corresponding to citations in the document.

Called from: ManageCitationsDialogViewModel constructor.

Returns:List<CitationEntry>

A list with entries corresponding to citations in the text, in arbitrary order (same order as from getJabRefReferenceMarkNames).

Note

visual or alphabetic order could be more manageable for the user. We could provide these here, but switching between them needs change on GUI (adding a toggle or selector).

Note

CitationEntry implements Comparable, where compareTo() and equals() are based on refMarkName. The order used in the "Manage citations" dialog does not seem to use that.

The 1st is labeled "Citation" (show citation in bold, and some context around it).

The columns can be sorted by clicking on the column title. For the "Citation" column, the sorting is based on the content, (the context before the citation), not on the citation itself.

In the "Extra information ..." column some visual indication of the editable part could be helpful.

Wish: selecting an entry (or a button in the line) in the GUI could move the cursor in the document to the entry.

getCitationGroupsSortedWithinPartitionsback to summary
public List<CitationGroup> getCitationGroupsSortedWithinPartitions(com.sun.star.text.XTextDocument doc, boolean mapFootnotesToFootnoteMarks) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Return citation groups in visual order within (but not across) XText partitions.

This is (1) sufficient for combineCiteMarkers which looks for consecutive XTextRanges within each XText, (2) not confused by multicolumn layout or multipage display.

getDataModelback to summary
public OODataModel getDataModel()
getFillCursorForCitationGroupback to summary
public com.sun.star.text.XTextCursor getFillCursorForCitationGroup(com.sun.star.text.XTextDocument doc, CitationGroup group) throws NoDocumentException, com.sun.star.lang.WrappedTargetException, CreationException
getMarkRangeback to summary
public Optional<com.sun.star.text.XTextRange> getMarkRange(com.sun.star.text.XTextDocument doc, CitationGroup group) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

ranges controlled by citation groups should not overlap with each other.

Returns:Optional<com.sun.star.text.XTextRange>

Optional.empty() if the reference mark is missing.

getVisuallySortedCitationGroupsback to summary
private List<CitationGroup> getVisuallySortedCitationGroups(com.sun.star.text.XTextDocument doc, boolean mapFootnotesToFootnoteMarks, FunctionalTextViewCursor fcursor) throws com.sun.star.lang.WrappedTargetException, NoDocumentException
Parameters
mapFootnotesToFootnoteMarks:boolean

If true, sort reference marks in footnotes as if they appeared at the corresponding footnote mark.

Returns:List<CitationGroup>

citation groups sorted by their visual positions. Limitation: for two column layout visual (top-down, left-right) order does not match the expected (textual) order.

healthReportback to summary
public Optional<String> healthReport(com.sun.star.text.XTextDocument doc) throws NoDocumentException
imposeGlobalOrderback to summary
public void imposeGlobalOrder(com.sun.star.text.XTextDocument doc, FunctionalTextViewCursor fcursor) throws com.sun.star.lang.WrappedTargetException, NoDocumentException
rangeOverlapsToMessageback to summary
pack-priv static String rangeOverlapsToMessage(List<RangeOverlap<RangeForOverlapCheck<CitationGroupId>>> overlaps)
readCitationGroupsFromDocumentback to summary
private static Map<CitationGroupId, CitationGroup> readCitationGroupsFromDocument(Backend52 backend, com.sun.star.text.XTextDocument doc, List<String> citationGroupNames) throws com.sun.star.lang.WrappedTargetException, NoDocumentException
removeCitationGroupback to summary
public void removeCitationGroup(CitationGroup group, com.sun.star.text.XTextDocument doc) throws com.sun.star.lang.WrappedTargetException, NoDocumentException, com.sun.star.beans.NotRemoveableException

Remove group both from the document and notify citationGroups

removeCitationGroupsback to summary
public void removeCitationGroups(List<CitationGroup> citationGroups, com.sun.star.text.XTextDocument doc) throws com.sun.star.lang.WrappedTargetException, NoDocumentException, com.sun.star.beans.NotRemoveableException
viewCursorRangesback to summary
public List<RangeForOverlapCheck<CitationGroupId>> viewCursorRanges(com.sun.star.text.XTextDocument doc)