if (type == TokenType.OPERAND && subtype == TokenSubtype.RANGE) {
//prepare the original Reference
final Reference orgref = ctx != null ?
(Reference) ctx.getVariableResolver().resolveVariable("zkoss.ss.Ref") : null;
final SheetImpl sheet = orgref != null ?
(SheetImpl) orgref.getSheet() : null;
final Book book = sheet != null ?
sheet.getBook() : (ctx instanceof Book) ? (Book) ctx : null;
final String[] range = parseRange(value);
final String sheetnm1 = range[0];
final String sheetnm2 = range[1];
final String cell1 = range[2];
final String cell2 = range[3];
int[] lt = null;
int[] rb = null;
boolean var1 = false;
boolean var2 = false;
lt = parseCell(cell1);
var1 = (lt == null);
if (cell2 != null) {
rb = parseCell(cell2);
var2 = (lt == null);
} else { //cell2 == null
// cell1 is single col but cell2 is not available, should be a variable
if (!var1 && lt[1] == -1) {
var1 = true;
}
}
if (lt != null && rb != null) {
int l = lt[0];
int t = lt[1];
int absl = lt[2];
int abst = lt[3];
int r = rb[0];
int b = rb[1];
int absr = rb[2];
int absb = rb[3];
if (l > r) {
int tmp = l;
l = r;
r = tmp;
tmp = absl;
absl = absr;
absr = tmp;
lt[0] = l;
lt[2] = absl;
rb[0] = r;
rb[2] = absr;
}
if (t > b) {
int tmp = t;
t = b;
b = tmp;
tmp = abst;
abst = absb;
absb = tmp;
lt[1] = t;
lt[3] = abst;
rb[1] = b;
rb[3] = absb;
}
}
final SheetImpl psheet1 = (book != null && sheetnm1 != null) ?
(SheetImpl)book.lookupSheet(sheetnm1) : sheet;
final SheetImpl psheet2 = (book != null && sheetnm2 != null) ?
(SheetImpl)book.lookupSheet(sheetnm2) : sheet;
// final SheetImpl psheet1 = sheet1 != null ? sheet1 : sheet;
// final SheetImpl psheet2 = sheet2 != null ? sheet2 : sheet;
final boolean abssheet = book != null && (sheetnm1 != null || sheetnm2 != null);