Apache OpenOffice (AOO) Bugzilla – Issue 21398
StarBasic can't tell one end of a range from the other
Last modified: 2013-08-07 14:38:26 UTC
The functions getEnd() and getStart(), when applied to a text range, return a range from beginning and the end, as they should. The bug is that you don't know which you'll get. Sometimes getStart() returns the start of a range. Sometimes it returns the end. getEnd() will always return the opposite end to getStart(). The expected, and logical behaviour, is that getStart() should always return the end of the range nearest the start of the text, and getEnd() should return the end furthest from the start. This should obviously dependent on the way the text is read -- ie the start shouold be on th eleft i English and on the right in eg Hebrew. For the moment there is a workaround. You just need to compare the two ranges before using them, to determine which is actually the start and which th eend. As an immediate fix, I suggest changing the documentation in the API, to add to each method the following warning: " getStart() and getEnd() are guaranteed to return the beinning and end of a text range. Despite their names, it is not guaranteed that the range returned by betStart() will come before the range returned by getEnd(). If you want to use them as the start and end points of a range to be traversed, you need to check which one comes first. This can be done, in Basic, with code like this ... if not atext.compareRegionStarts(aRange.getStart(),aRange.getEnd()) then startcursor=atext.createTextCursorByRange(aRange.getStart()) stopcursor=atext.createTextCursorByRange(aRange.getEnd()) else startcursor=atext.createTextCursorByRange(aRange.getEnd()) stopcursor=atext.createTextCursorByRange(aRange.getStart()) end if ... "
Andrease, please have a look at this and target it appropriately.
That seems to be a (Writer?) API problem and has nothing to do with Basic.
The start or end position does not and should not depend on the writing direction. os->tl: Either the bookmark that is created for SwXTextRange objects should be in the right direction or the getStart/End methods should check the direction.
Set target to OOo 2.0
SW: changed Prio
SW: changed target
I know this is an old issue, but I'd like an update about it. Has it been effectively solved by the similar Issue 21335 (which is reported as fixed)? If not, at least *one* example where getStart and getEnd doesn't give respectively the leftmost and rightmost end of the selected range would be appreciated. On my end, these methods seem to do their jobs as expected, but I'd like to know if it's stabilized.
Long forgotten issue apparently, if it's still an issue. Anyways, will reluctantly continue to use andrewb's hack posted in his initial message, and other hacks when necessary.... assuming of course that compareRegionStarts itself has no unforseen bugs. It is unfortunate one cannot trust such simple methods.