Package org.zkoss.zss.model.impl

Examples of org.zkoss.zss.model.impl.RangeRef


    sb.append("[");
    if(args!=null){
      for(int i=0;i<args.length;i++){
        if(i>0) sb.append(", ");
        if(args[i] instanceof RangeRef){
          RangeRef ref = (RangeRef)args[i];
          for(Iterator iter = ref.getCells().iterator();iter.hasNext();){
            Cell cell = (Cell)iter.next();
            sb.append(cell.getText());
            if(iter.hasNext()) sb.append(", ");
          }
        }else if(args[i]!=null){
View Full Code Here


    final Reference orgref = ctx != null ?
        (Reference) ctx.getVariableResolver().resolveVariable("zkoss.ss.Ref") : null;
    for(final Iterator it = ranges.iterator(); it.hasNext(); ) {
      final Range xrng = (Range) it.next();
      if (xrng instanceof RangeRef) {
        final RangeRef rng = (RangeRef) xrng;
        orgref.addPrecedent(rng.getRef());
      }
    }
    final Sheet orgSheet = orgref.getSheet();
    if (orgSheet != null) {
      for(final Iterator it = ranges.iterator(); it.hasNext(); ) {
        final Range xrng = (Range) it.next();
        if (xrng instanceof RangeRef) {
          final RangeRef rng = (RangeRef) xrng;
          if (rng.getSheetTo() == null && rng.getSheet() != orgSheet) {
            rng.setSheetAbsolute(true);
          }
        }
      }
    }
    return orgref;
View Full Code Here

            final boolean absleft = lt[2] != 0;
            final boolean abstop = lt[3] != 0;
            final boolean absright = absleft;
            final boolean absbottom = abstop;
            final Range rng = psheet1 == null ? RangeRefError.RANGE_REF_ERROR :
              new RangeRef(psheet1, null, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
            ranges.add(rng);
/*            if (orgref != null) {
              final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
              orgref.addPrecedent(precedent);
            }
*/            token1.setValue(rng);
            operand.addOperand(token1);
          }
         
          if (var2) {
            //lookup NameRange
            final Range rng = book.lookupNameRange(cell2);
            if (rng != null) {
              ranges.add(rng);
              operand.addOperand(new Token(rng, TokenType.OPERAND, TokenSubtype.RANGE));
            } else {
              operand.addOperand(new Token(cell2, TokenType.OPERAND, TokenSubtype.VAR));
              if (!((BookImpl)book).addVariable(cell2, orgref)) {
                throw new XelException("Illegal variable name: "+cell2);
              }
            }
          } else {
            final Token token2 =
              new Token(cell2, TokenType.OPERAND, TokenSubtype.CELL);
            //TODO: matain ref DAG graph
            //TODO: How do we handle variable range2d?
//            final SheetImpl psheet = sheet2 != null ? sheet2 : sheet;
//            final Abacus pabacus = psheet.getBook().getAbacus();
            final int left = rb[0];
            final int top = rb[1];
            final int right = left;
            final int bottom = top;
            final boolean absleft = rb[2] != 0;
            final boolean abstop = rb[3] != 0;
            final boolean absright = absleft;
            final boolean absbottom = abstop;
            final Range rng =
              new RangeRef(psheet2, null, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
            ranges.add(rng);
/*            if (orgref != null) {
              final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
              orgref.addPrecedent(precedent);
            }
*/            token2.setValue(rng);
            operand.addOperand(token2);
          }
        } else { //a const cell or a const range
          if (sheetnm1 == null || (sheetnm2 == null || sheetnm1.equals(sheetnm2))) { //single sheet
            if (cell1.equals(cell2)) { //a cell reference
              if (lt[0] == -1 || lt[1] == -1) { //single row || single column
//                final SheetImpl psheet = sheet1 != null ? sheet1 : sheet;
//                final Abacus pabacus = psheet.getBook().getAbacus();
                final int left = lt[0];
                final int top = lt[1];
                final int right = rb[0];
                final int bottom = rb[1];
                final boolean absleft = lt[2] != 0;
                final boolean abstop = lt[3] != 0;
                final boolean absright = rb[2] != 0;
                final boolean absbottom = rb[3] != 0;
                final Range rng = psheet1 == null ? RangeRefError.RANGE_REF_ERROR :
                  new RangeRef(psheet1, null, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
                ranges.add(rng);
/*                if (orgref != null) {
                  final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
                  orgref.addPrecedent(precedent);
                }
*/                operand.setValue(rng);
              } else { //degrad to single cell
                operand.setSubtype(TokenSubtype.CELL);
                //TODO: maintain DAG reference
//                final SheetImpl psheet = sheet1 != null ? sheet1 : sheet;
//                final Abacus pabacus = psheet.getBook().getAbacus();
                final int left = lt[0];
                final int top = lt[1];
                final int right = left;
                final int bottom = top;
                final boolean absleft = lt[2] != 0;
                final boolean abstop = lt[3] != 0;
                final boolean absright = absleft;
                final boolean absbottom = abstop;
                final Range rng = psheet1 == null ? RangeRefError.RANGE_REF_ERROR :
                  new RangeRef(psheet1, null, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
                ranges.add(rng);
/*                if (orgref != null) {
                  final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
                  orgref.addPrecedent(precedent);
                }
*/                operand.setValue(rng);
              }
            } else { //a range reference
              //TODO: maintain DAG reference
//              final SheetImpl psheet = sheet1 != null ? sheet1 : sheet;
//              final Abacus pabacus = psheet.getBook().getAbacus();
              final int left = lt[0];
              final int top = lt[1];
              final int right = rb[0];
              final int bottom = rb[1];
              final boolean absleft = lt[2] != 0;
              final boolean abstop = lt[3] != 0;
              final boolean absright = rb[2] != 0;
              final boolean absbottom = rb[3] != 0;
              final Range rng = psheet1 == null ? RangeRefError.RANGE_REF_ERROR :
                new RangeRef(psheet1, null, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
              ranges.add(rng);
/*              if (orgref != null) {
                final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
                orgref.addPrecedent((Reference)precedent);
              }
*/              operand.setValue(rng);
            }
          } else { //range 3d
            //TODO: maintain DAG reference
            //TODO: for each sheet between two sheet name
            final int left = lt[0];
            final int top = lt[1];
            final int right = rb[0];
            final int bottom = rb[1];
            final boolean absleft = lt[2] != 0;
            final boolean abstop = lt[3] != 0;
            final boolean absright = rb[2] != 0;
            final boolean absbottom = rb[3] != 0;
            final Range rng = (psheet1 == null || psheet2 == null) ? RangeRefError.RANGE_REF_ERROR :
              new RangeRef(psheet1, psheet2, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
            ranges.add(rng);
/*            if (orgref != null) {
              final Book pbook = sheet1.getBook();
              final int from = pbook.indexOfSheet(sheet1);
              final int to = pbook.indexOfSheet(sheet2);
              final Abacus pabacus = pbook.getAbacus();
              final List sheets = book.getSheets();
              for (int j=from; j <= to; ++j) {
                final SheetImpl psheet = (SheetImpl) sheets.get(j);
                final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
                orgref.addPrecedent((Reference)precedent);
              }
            }
*/            operand.setValue(rng);
          }
        }
      } else if (var1) { //single variable
        //lookup NameRange
        final Range rng = book.lookupNameRange(cell1);
        if (rng != null) {
          ranges.add(rng);
          operand.setValue(rng);
        } else {
          operand.setSubtype(TokenSubtype.VAR);
          if (!((BookImpl)book).addVariable(cell1, orgref)) {
            throw new XelException("Illegal variable name: "+cell1);
          }
        }
      } else {//single cell
        operand.setSubtype(TokenSubtype.CELL);
        //TODO: maintain DAG reference
//        final SheetImpl psheet = sheet1 != null ? sheet1 : sheet;
//        final Abacus pabacus = psheet.getBook().getAbacus();
        final int left = lt[0];
        final int top = lt[1];
        final int right = left;
        final int bottom = top;
        final boolean absleft = lt[2] != 0;
        final boolean abstop = lt[3] != 0;
        final boolean absright = absleft;
        final boolean absbottom = abstop;
        final Range rng = psheet1 == null ? RangeRefError.RANGE_REF_ERROR :
          new RangeRef(psheet1, null, left, top, right, bottom, absleft, abstop, absright, absbottom, abssheet);
        ranges.add(rng);
/*        if (orgref != null) {
          final Reference precedent = pabacus.addRef(new SimpleRef(psheet, rng, orgrow, orgcol));
          orgref.addPrecedent((Reference)precedent);
        }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.model.impl.RangeRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.