Verified Owner
Top Fields Constructors Methods
org.jabref.logic.openoffice.backend

public Class NamedRangeReferenceMark

extends Object
implements NamedRange
Class Inheritance
All Implemented Interfaces
org.jabref.model.openoffice.backend.NamedRange
Imports
java.util.Optional, org.jabref.model.openoffice.DocumentAnnotation, org.jabref.model.openoffice.backend.NamedRange, org.jabref.model.openoffice.uno.CreationException, .NoDocumentException, .UnoCursor, .UnoDispatch, .UnoReferenceMark, com.sun.star.beans.UnknownPropertyException, com.sun.star.beans.XPropertySet, com.sun.star.lang.WrappedTargetException, com.sun.star.lang.XMultiServiceFactory, com.sun.star.text.XText, com.sun.star.text.XTextContent, com.sun.star.text.XTextCursor, com.sun.star.text.XTextDocument, com.sun.star.text.XTextRange, com.sun.star.uno.UnoRuntime, com.sun.star.uno.XComponentContext, org.slf4j.Logger, .LoggerFactory

Field Summary

Modifier and TypeField and Description
private static final Logger
private final String
rangeId

reference mark name

public static final String
public static final String
private static final boolean
private static final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static void
checkFillCursor(com.sun.star.text.XTextCursor cursor)

public void
cleanFillCursor(com.sun.star.text.XTextDocument doc)

Implements org.jabref.model.openoffice.backend.NamedRange.cleanFillCursor.

Remove brackets, but if the result would become empty, leave them; if the result would be a single characer, leave the left bracket.

pack-priv static NamedRangeReferenceMark
create(com.sun.star.text.XTextDocument doc, com.sun.star.uno.XComponentContext context, String refMarkName, com.sun.star.text.XTextCursor position, boolean insertSpaceBefore, boolean insertSpaceAfter, boolean withoutBrackets)

private static void
createReprInDocument(com.sun.star.text.XTextDocument doc, Optional<com.sun.star.uno.XComponentContext> context, String refMarkName, com.sun.star.text.XTextCursor position, boolean insertSpaceBefore, boolean insertSpaceAfter, boolean withoutBrackets)

private static Optional<com.sun.star.uno.XComponentContext>
findComponentContext(com.sun.star.text.XTextDocument doc)

public com.sun.star.text.XTextCursor
getFillCursor(com.sun.star.text.XTextDocument doc)

Implements org.jabref.model.openoffice.backend.NamedRange.getFillCursor.

See: getFillCursorForCitationGroup

pack-priv static Optional<NamedRangeReferenceMark>
getFromDocument(com.sun.star.text.XTextDocument doc, String refMarkName)

Returns: Optional.empty if there is no corresponding range.

pack-priv String
public Optional<com.sun.star.text.XTextRange>
getMarkRange(com.sun.star.text.XTextDocument doc)

Implements org.jabref.model.openoffice.backend.NamedRange.getMarkRange.

Returns: Optional.empty if the reference mark is missing.

public String
public Optional<com.sun.star.text.XTextCursor>

Returns:

Optional.empty() if reference mark is missing from the document, otherwise an XTextCursor for getMarkRange See: getRawCursorForCitationGroup
getRawCursor
(com.sun.star.text.XTextDocument doc)

Implements org.jabref.model.openoffice.backend.NamedRange.getRawCursor.

Cursor for the reference marks as is, not prepared for filling, but does not need cleanFillCursor either.

public void
removeFromDocument(com.sun.star.text.XTextDocument doc)

Implements org.jabref.model.openoffice.backend.NamedRange.removeFromDocument.

Remove it from the document.

public static com.sun.star.text.XTextCursor

Returns:

a new cursor, covering the just-inserted spaces.
safeInsertSpacesBetweenReferenceMarks
(com.sun.star.text.XTextRange
Where to insert (at position.getStart())
position
,
int
Number of spaces to insert.
numSpaces
)

Insert n spaces in a way that reference marks just before or just after the cursor are not affected.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGGERback to summary
private static final Logger LOGGER
rangeIdback to summary
private final String rangeId

reference mark name

REFERENCE_MARK_LEFT_BRACKETback to summary
public static final String REFERENCE_MARK_LEFT_BRACKET
REFERENCE_MARK_RIGHT_BRACKETback to summary
public static final String REFERENCE_MARK_RIGHT_BRACKET
REFERENCE_MARK_USE_INVISIBLE_BRACKETSback to summary
private static final boolean REFERENCE_MARK_USE_INVISIBLE_BRACKETS
ZERO_WIDTH_SPACEback to summary
private static final String ZERO_WIDTH_SPACE

Constructor Detail

NamedRangeReferenceMarkback to summary
private NamedRangeReferenceMark(String rangeId)

Method Detail

checkFillCursorback to summary
public static void checkFillCursor(com.sun.star.text.XTextCursor cursor)
cleanFillCursorback to summary
public void cleanFillCursor(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Implements org.jabref.model.openoffice.backend.NamedRange.cleanFillCursor.

Remove brackets, but if the result would become empty, leave them; if the result would be a single characer, leave the left bracket.

See: cleanFillCursorForCitationGroup

Annotations
@Override
createback to summary
pack-priv static NamedRangeReferenceMark create(com.sun.star.text.XTextDocument doc, com.sun.star.uno.XComponentContext context, String refMarkName, com.sun.star.text.XTextCursor position, boolean insertSpaceBefore, boolean insertSpaceAfter, boolean withoutBrackets) throws CreationException
createReprInDocumentback to summary
private static void createReprInDocument(com.sun.star.text.XTextDocument doc, Optional<com.sun.star.uno.XComponentContext> context, String refMarkName, com.sun.star.text.XTextCursor position, boolean insertSpaceBefore, boolean insertSpaceAfter, boolean withoutBrackets) throws CreationException
findComponentContextback to summary
private static Optional<com.sun.star.uno.XComponentContext> findComponentContext(com.sun.star.text.XTextDocument doc)
getFillCursorback to summary
public com.sun.star.text.XTextCursor getFillCursor(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException, CreationException

Implements org.jabref.model.openoffice.backend.NamedRange.getFillCursor.

See: getFillCursorForCitationGroup

Annotations
@Override
getFromDocumentback to summary
pack-priv static Optional<NamedRangeReferenceMark> getFromDocument(com.sun.star.text.XTextDocument doc, String refMarkName) throws NoDocumentException, com.sun.star.lang.WrappedTargetException
Returns:Optional<NamedRangeReferenceMark>

Optional.empty if there is no corresponding range.

getIdback to summary
pack-priv String getId()
getMarkRangeback to summary
public Optional<com.sun.star.text.XTextRange> getMarkRange(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Implements org.jabref.model.openoffice.backend.NamedRange.getMarkRange.

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

Optional.empty if the reference mark is missing. See: UnoReferenceMark.getAnchor

Annotations
@Override
getRangeNameback to summary
public String getRangeName()

Implements org.jabref.model.openoffice.backend.NamedRange.getRangeName.

Annotations
@Override
getRawCursorback to summary
public Optional<com.sun.star.text.XTextCursor> getRawCursor(com.sun.star.text.XTextDocument doc) throws NoDocumentException, com.sun.star.lang.WrappedTargetException

Implements org.jabref.model.openoffice.backend.NamedRange.getRawCursor.

Cursor for the reference marks as is, not prepared for filling, but does not need cleanFillCursor either.

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

Optional.empty() if reference mark is missing from the document, otherwise an XTextCursor for getMarkRange See: getRawCursorForCitationGroup

Annotations
@Override
removeFromDocumentback to summary
public void removeFromDocument(com.sun.star.text.XTextDocument doc) throws com.sun.star.lang.WrappedTargetException, NoDocumentException

Implements org.jabref.model.openoffice.backend.NamedRange.removeFromDocument.

Remove it from the document.

See: removeCitationGroups

Annotations
@Override
safeInsertSpacesBetweenReferenceMarksback to summary
public static com.sun.star.text.XTextCursor safeInsertSpacesBetweenReferenceMarks(com.sun.star.text.XTextRange position, int numSpaces)

Insert n spaces in a way that reference marks just before or just after the cursor are not affected.

This is based on the observation, that starting two new paragraphs separates us from reference marks on either side.

The pattern used is: safeInsertSpaces(n): para, para, left, space(n), right-delete, left(n), left-delete

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

Where to insert (at position.getStart())

numSpaces:int

Number of spaces to insert.

Returns:com.sun.star.text.XTextCursor

a new cursor, covering the just-inserted spaces.