Download it now!
Bug 86131 - XTextField.getAnchor().getText() returns XTextRange objects with the start position being the same as the end position
Summary: XTextField.getAnchor().getText() returns XTextRange objects with the start po...
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: sdk (show other bugs)
(earliest affected) rc
Hardware: Other All
: medium normal
Assignee: Miklos Vajna
Whiteboard: target:4.4.0
Depends on:
Reported: 2014-11-10 23:00 UTC by XQ
Modified: 2014-11-20 08:33 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:

testcase written in java that reproduces the annotation start==end bug (2.20 KB, text/plain)
2014-11-10 23:00 UTC, XQ

Note You need to log in before you can comment on or make changes to this bug.
Description XQ 2014-11-10 23:00:43 UTC
Created attachment 109250 [details]
testcase written in java that reproduces the annotation start==end bug

When I get all annotations from an ODT document using UNO api, I iterate through
them(they are of type XTextField which I suppose is the actual object sitting
at the right side of the page, the actual annotations) and call .getAnchor().getText() on them in order to get the start and end position of
the selected text (the text that is part of the document, to which the annotation refers to) they're associated with. 

For every such annotation, it seems that the start position(I call .getStart() to get it) is the same as the end position(I call .getEnd() to get that).
And the value of this, is actually the right value for .getEnd().

So .getStart() returns the wrong value.

I've read every possible part of the documentation(of both libreoffice
and openoffice) related to this, I've read the examples 
in the SDK, I've downloaded all the libreoffice/openoffice
mailing lists related to this, I've checked for 
similar problems, I've downloaded all libreoffice/openoffice extensions, unpacked them and indexed them and searched through them to 
see how other people get the start and end positions of annotations.

I wasn't able to find a way to get the correct position for the document text
referenced by the annotation.

I am attaching a testcase written in Java to this bug report.
Also, below I tried to collect all the versions of Libreoffice 
on my system.

user@xw:/usr/share/java$ ls | grep uno | xargs stat | grep File:
  File: ‘java_uno.jar’
  File: ‘unoil-4.3.3.jar’
  File: ‘unoil.jar’ -> ‘unoil-4.3.3.jar’
  File: ‘unoloader.jar’

user@xw:/usr/share/java$ aptitude show libreoffice | grep Version
Version: 1:4.3.3~rc2~git20141011-1

user@xw:/usr/share/java$ libreoffice --version
LibreOffice 430m0(Build:1)
Comment 1 Miklos Vajna 2014-11-17 18:50:27 UTC
Annotated text ranges is my stuff, CC'ing myself.
Comment 2 Commit Notification 2014-11-18 08:06:12 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

fdo#86131 SwXTextField::getAnchor: handle postit field with annotation mark

It will be available in 4.4.0.

The patch should be included in the daily builds available at in the next 24-48 hours. More
information about daily builds can be found at:
Affected users are encouraged to test the fix and report feedback.
Comment 3 Miklos Vajna 2014-11-20 08:33:40 UTC
libreoffice-4-3 review: