hi, i am using the java api to manipulate a document, i need to know if a XTextCursor object is at the end of the line, i saw the documentation in open office and i found this method: isAtEndOfLine(), but this is writen in C i guess,
is there any equivalent in java api for this?
I don’t use Java. However …
A TextCursor doesn’t know about lines. The function isAtEndOfLine is supplied by the XLineCursor interface. The only object I know offering this interface is the ViewCursor.
The following Basic code using it for the purpose surely isn’t exactly pretty, and will also not be very efficient but…
Function tryIsTextCursorAtEndOfLine(pDoc, pTextCursor, ByRef pErr) As Boolean
REM This is a construct I often use to get a similar functionality
REM as is provided by programming laguages as (e.g.) "Try ... Except ...End"
tryIsTextCursorAtEndOfLine = False
pErr = True
On Local Error Goto fail
cCtrl = pDoc.CurrentController
lText = pTextCursor.Text
vC = cCtrl.ViewCursor
oldSel = pDoc.CurrentSelection
cCtrl.select(pTextCursor)
tryIsTextCursorAtEndOfLine = vC.isAtEndOfLine()
pDoc.CurrentController.select(oldSel)
pErr = False
fail:
End Function
Since your Java must have its way to access all the API elements used, the implementation of an equivalent function should be simple.