Verified Owner
Top Description Inners Fields Constructors Methods
org.jabref.model.openoffice.rangesort

public Class RangeSortVisual

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, org.jabref.model.openoffice.uno.UnoScreenRefresh, com.sun.star.awt.Point, com.sun.star.text.XTextDocument, com.sun.star.text.XTextRange, com.sun.star.text.XTextViewCursor, org.slf4j.Logger, .LoggerFactory

Sort XTextRange values visually (top-down,left-to-right).

Requires functional XTextViewCursor.

Problem: for multicolumn layout and when viewing pages side-by-side in LO, the (top-down,left-to-right) order interpreted as-on-the-screen: an XTextRange at the top of the second column or second page is sorted before an XTextRange at the bottom of the first column of the first page.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
RangeSortVisual.ComparableMark<T>

A reference mark name paired with its visual position.

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 <T> int
private static com.sun.star.awt.Point
findPositionOfTextRange(com.sun.star.text.XTextRange
Location.
range
,
com.sun.star.text.XTextViewCursor
To get the position, we need az XTextViewCursor. It will be moved to the range.
cursor
)

Given a location, return its position: coordinates relative to the top left position of the first page of the document.

public static <T> List<RangeSortable<T>>

Returns:

The input, sorted by the elements XTextRange and getIndexInPosition.
visualSort
(List<RangeSortable<T>> inputs, com.sun.star.text.XTextDocument doc, FunctionalTextViewCursor fcursor)

Sort the input inputs visually.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER

Constructor Detail

RangeSortVisualback to summary
private RangeSortVisual()

Method Detail

compareTopToBottomLeftToRightback to summary
private static <T> int compareTopToBottomLeftToRight(RangeSortVisual.ComparableMark<T> a, RangeSortVisual.ComparableMark<T> b)
findPositionOfTextRangeback to summary
private static com.sun.star.awt.Point findPositionOfTextRange(com.sun.star.text.XTextRange range, com.sun.star.text.XTextViewCursor cursor)

Given a location, return its position: coordinates relative to the top left position of the first page of the document.

Note

for text layouts with two or more columns, this gives the wrong order: top-down/left-to-right does not match reading order.

Note

The "relative to the top left position of the first page" is meant "as it appears on the screen".

In particular: when viewing pages side-by-side, the top half of the right page is higher than the lower half of the left page. Again, top-down/left-to-right does not match reading order.

Parameters
range:com.sun.star.text.XTextRange

Location.

cursor:com.sun.star.text.XTextViewCursor

To get the position, we need az XTextViewCursor. It will be moved to the range.

visualSortback to summary
public static <T> List<RangeSortable<T>> visualSort(List<RangeSortable<T>> inputs, com.sun.star.text.XTextDocument doc, FunctionalTextViewCursor fcursor)

Sort the input inputs visually.

Requires a functional XTextViewCursor.

Returns:List<RangeSortable<T>>

The input, sorted by the elements XTextRange and getIndexInPosition.

org.jabref.model.openoffice.rangesort back to summary

private final Record RangeSortVisual.ComparableMark<T>

extends Record
Class Inheritance
Record Components
position:com.sun.star.awt.Point 
indexInPosition:int 
content:T 

A reference mark name paired with its visual position.

Comparison is based on (Y,X,indexInPosition): vertical compared first, horizontal second, indexInPosition third.

Used for sorting reference marks by their visual positions.

Field Summary

Modifier and TypeField and Description
private final T
content

Record Component accessed by content().

private final int
indexInPosition

Record Component accessed by indexInPosition().

private final com.sun.star.awt.Point
position

Record Component accessed by position().

Constructor Summary

AccessConstructor and Description
private
ComparableMark(com.sun.star.awt.Point position, int indexInPosition, T content)

Method Summary

Modifier and TypeMethod and Description
public T
content()

Record Component getter of content.

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 int
indexInPosition()

Record Component getter of indexInPosition.

public com.sun.star.awt.Point
position()

Record Component getter of position.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

contentback to summary
private final T content

Record Component accessed by content().

indexInPositionback to summary
private final int indexInPosition

Record Component accessed by indexInPosition().

positionback to summary
private final com.sun.star.awt.Point position

Record Component accessed by position().

Constructor Detail

ComparableMarkback to summary
private ComparableMark(com.sun.star.awt.Point position, int indexInPosition, T content)

Method Detail

contentback to summary
public T content()

Record Component getter of content.

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.

indexInPositionback to summary
public int indexInPosition()

Record Component getter of indexInPosition.

positionback to summary
public com.sun.star.awt.Point position()

Record Component getter of position.

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.