public int[] getSelectedRange() {
IHTMLGraphicalViewer viewer = (IHTMLGraphicalViewer) this.getViewer();
if (viewer == null || !viewer.isInRangeMode()) {
return null;
}
DesignRange range = viewer.getRangeSelection();
if (range == null || !range.isValid()) {
return null;
}
if (!RangeUtil.intersect(range, this)) {
return null;
}
// ok, we intersect with the range.
range = RangeUtil.normalize(range);
EditPart startContainer = range.getStartPosition().getContainerPart();
EditPart endContainer = range.getEndPosition().getContainerPart();
int[] ret = new int[2];
if (startContainer != this) {
ret[0] = 0;
} else {
ret[0] = range.getStartPosition().getOffset();
}
if (endContainer != this) {
ret[1] = this.getTextData().length();
} else {
{
ret[1] = range.getEndPosition().getOffset();
}
}
return ret;
}