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

public Class EditMerge

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, .Objects, .Optional, java.util.stream.Collectors, org.jabref.logic.JabRefException, org.jabref.logic.openoffice.frontend.OOFrontend, .UpdateCitationMarkers, org.jabref.logic.openoffice.style.JStyle, org.jabref.model.openoffice.ootext.OOText, org.jabref.model.openoffice.style.Citation, .CitationGroup, .CitationType, org.jabref.model.openoffice.uno.CreationException, .NoDocumentException, .UnoScreenRefresh, .UnoTextRange, org.jabref.model.openoffice.util.OOListUtil, .OOResult, 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, com.sun.star.uno.XComponentContext, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
private static class

Field Summary

Modifier and TypeField and Description
private static final Logger

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
addToCurrentGroup(EditMerge.ScanState state, CitationGroup group, com.sun.star.text.XTextRange currentRange)

Add group to state.currentGroup Set state.cursorBetween to start at currentRange.getEnd() Expand state.currentGroupCursor to also cover currentRange Set state.prev to group, state.prevRange to currentRange

private static boolean

Returns:

false if cannot add, true if can. If returned true, then state.cursorBetween and state.currentGroupCursor are expanded to end at the start of currentRange.
checkAddToGroup
(EditMerge.ScanState state, CitationGroup
The CitationGroup to test
group
,
com.sun.star.text.XTextRange
The XTextRange corresponding to group.
currentRange
)

Decide if group could be added to state.currentGroup

private static boolean

Returns:

false if cannot expand, true if can.
checkCouldExpand
(EditMerge.ScanState
The CitationGroup to test.
state
,
com.sun.star.text.XTextRange
The XTextRange corresponding to group.
currentRange
,
String
The failure message for the LOGGER.
loggerMessage
)

Helper method for checkAddToGroup.

public static OOResult<Boolean, JabRefException>
mergeCitationGroups(com.sun.star.text.XTextDocument doc, com.sun.star.uno.XComponentContext context, OOFrontend frontend, JStyle style)

Returns: true if modified document

private static List<EditMerge.JoinableGroupData>
scan(com.sun.star.text.XTextDocument doc, OOFrontend frontend)

Scan the document for joinable groups.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

EditMergeback to summary
private EditMerge()

Method Detail

addToCurrentGroupback to summary
private static void addToCurrentGroup(EditMerge.ScanState state, CitationGroup group, com.sun.star.text.XTextRange currentRange)

Add group to state.currentGroup Set state.cursorBetween to start at currentRange.getEnd() Expand state.currentGroupCursor to also cover currentRange Set state.prev to group, state.prevRange to currentRange

checkAddToGroupback to summary
private static boolean checkAddToGroup(EditMerge.ScanState state, CitationGroup group, com.sun.star.text.XTextRange currentRange)

Decide if group could be added to state.currentGroup

Parameters
group:CitationGroup

The CitationGroup to test

currentRange:com.sun.star.text.XTextRange

The XTextRange corresponding to group.

Returns:boolean

false if cannot add, true if can. If returned true, then state.cursorBetween and state.currentGroupCursor are expanded to end at the start of currentRange.

checkCouldExpandback to summary
private static boolean checkCouldExpand(EditMerge.ScanState state, com.sun.star.text.XTextRange currentRange, String loggerMessage)

Helper method for checkAddToGroup. Tries to expand state.currentGroupCursor and state.cursorBetween by going right to reach rangeStart.

Parameters
state:EditMerge.ScanState

The CitationGroup to test.

currentRange:com.sun.star.text.XTextRange

The XTextRange corresponding to group.

loggerMessage:String

The failure message for the LOGGER.

Returns:boolean

false if cannot expand, true if can.

mergeCitationGroupsback to summary
public static OOResult<Boolean, JabRefException> mergeCitationGroups(com.sun.star.text.XTextDocument doc, com.sun.star.uno.XComponentContext context, OOFrontend frontend, JStyle style)
Returns:OOResult<Boolean, JabRefException>

true if modified document

scanback to summary
private static List<EditMerge.JoinableGroupData> scan(com.sun.star.text.XTextDocument doc, OOFrontend frontend) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Scan the document for joinable groups. Return those found.

org.jabref.logic.openoffice.action back to summary

private final Record EditMerge.JoinableGroupData

extends Record
Class Inheritance
Record Components
group:List<CitationGroup>
A list of consecutive citation groups only separated by spaces.
groupCursor:com.sun.star.text.XTextCursor
A cursor covering the XTextRange of each entry in group (and the spaces between them)

Field Summary

Modifier and TypeField and Description
private final List<CitationGroup>
group

Record Component accessed by group().

A list of consecutive citation groups only separated by spaces.
private final com.sun.star.text.XTextCursor
groupCursor

Record Component accessed by groupCursor().

A cursor covering the XTextRange of each entry in group (and the spaces between them)

Constructor Summary

AccessConstructor and Description
private
JoinableGroupData(List<CitationGroup> group, com.sun.star.text.XTextCursor groupCursor)

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 List<CitationGroup>
group()

Record Component getter of group.

Record Component A list of consecutive citation groups only separated by spaces.

public com.sun.star.text.XTextCursor
groupCursor()

Record Component getter of groupCursor.

Record Component A cursor covering the XTextRange of each entry in group (and the spaces between them)

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

groupback to summary
private final List<CitationGroup> group

Record Component accessed by group().

A list of consecutive citation groups only separated by spaces.

groupCursorback to summary
private final com.sun.star.text.XTextCursor groupCursor

Record Component accessed by groupCursor().

A cursor covering the XTextRange of each entry in group (and the spaces between them)

Constructor Detail

JoinableGroupDataback to summary
private JoinableGroupData(List<CitationGroup> group, com.sun.star.text.XTextCursor groupCursor)

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).
groupback to summary
public List<CitationGroup> group()

Record Component getter of group.

Record Component
A list of consecutive citation groups only separated by spaces.
groupCursorback to summary
public com.sun.star.text.XTextCursor groupCursor()

Record Component getter of groupCursor.

Record Component
A cursor covering the XTextRange of each entry in group (and the spaces between them)
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.

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.

org.jabref.logic.openoffice.action back to summary

private Class EditMerge.ScanState

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv List<CitationGroup>
pack-priv com.sun.star.text.XTextCursor
pack-priv com.sun.star.text.XTextCursor
pack-priv CitationGroup
pack-priv com.sun.star.text.XTextRange

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentGroupback to summary
pack-priv List<CitationGroup> currentGroup
currentGroupCursorback to summary
pack-priv com.sun.star.text.XTextCursor currentGroupCursor
cursorBetweenback to summary
pack-priv com.sun.star.text.XTextCursor cursorBetween
prevback to summary
pack-priv CitationGroup prev
prevRangeback to summary
pack-priv com.sun.star.text.XTextRange prevRange

Constructor Detail

ScanStateback to summary
pack-priv ScanState()

Method Detail

resetback to summary
pack-priv void reset()