diff options
author | Felipe Heidrich | 2012-02-28 17:13:10 +0000 |
---|---|---|
committer | Felipe Heidrich | 2012-02-28 17:13:10 +0000 |
commit | d3c0efa94b11c766b17f4670a7e8438e97a87bdc (patch) | |
tree | 934dbfd44acfd7e804abbc76052472b414289d67 | |
parent | db8003c8f90beb76b88b1209aa0ad9e6c8d8c3d2 (diff) | |
download | eclipse.platform.swt-d3c0efa94b11c766b17f4670a7e8438e97a87bdc.tar.gz eclipse.platform.swt-d3c0efa94b11c766b17f4670a7e8438e97a87bdc.tar.xz eclipse.platform.swt-d3c0efa94b11c766b17f4670a7e8438e97a87bdc.zip |
Bug 372760 - segments offset should be more flexible
3 files changed, 9 insertions, 28 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java index b688cb6368..06b714b7c6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BidiSegmentEvent.java @@ -26,12 +26,11 @@ import org.eclipse.swt.events.*; * a segment relative to the start of the line. They must follow * the following rules: * <ul> - * <li>first element must be 0 * <li>elements must be in ascending order and must not have duplicates * <li>elements must not exceed the line length * </ul> - * In addition, the last element may be set to the end of the line - * but this is not required. + * In addition, the first element may be set to zero and the last element may + * be set to the end of the line but this is not required. * * The segments field may be left null if the entire line should * be reordered as is. diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java index edb5b6a6b1..75de2c0edb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java @@ -4776,30 +4776,13 @@ StyledTextEvent getBidiSegments(int lineOffset, String line) { if (event == null || event.segments == null || event.segments.length == 0) return null; int lineLength = line.length(); int[] segments = event.segments; - int segmentCount = segments.length; - if (event.segmentsChars == null) { - // test segment index consistency - if (segments[0] != 0) { + if (segments[0] > lineLength) { + SWT.error(SWT.ERROR_INVALID_ARGUMENT); + } + for (int i = 1; i < segments.length; i++) { + if (segments[i] <= segments[i - 1] || segments[i] > lineLength) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } - for (int i = 1; i < segmentCount; i++) { - if (segments[i] <= segments[i - 1] || segments[i] > lineLength) { - SWT.error(SWT.ERROR_INVALID_ARGUMENT); - } - } - // ensure that last segment index is line end offset - if (segments[segmentCount - 1] != lineLength) { - segments = new int[segmentCount + 1]; - System.arraycopy(event.segments, 0, segments, 0, segmentCount); - segments[segmentCount] = lineLength; - } - event.segments = segments; - } else { - for (int i = 1; i < segmentCount; i++) { - if (event.segments[i] < event.segments[i - 1] || event.segments[i] > lineLength) { - SWT.error(SWT.ERROR_INVALID_ARGUMENT); - } - } } return event; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java index 99d1b0f312..336cebf359 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SegmentEvent.java @@ -22,12 +22,11 @@ import org.eclipse.swt.widgets.Event; * The elements in the segments field specify the start offset of a segment
* relative to the start of the text. They must follow the following rules:
* <ul>
- * <li>first element must be 0
* <li>elements must be in ascending order and must not have duplicates
* <li>elements must not exceed the text length
* </ul>
- * In addition, the last element may be set to the end of the text but this is
- * not required.
+ * In addition, the first element may be set to zero and the last element may
+ * be set to the end of the line but this is not required.
*
* The segments field may be left null if the entire text content doesn't
* require segmentation.
|