Package org.zkoss.zss.engine

Examples of org.zkoss.zss.engine.Reference


  }
 
  //validate the specified range which must cover all existing ref2d
  private void validateCorner(int left, int top, int right, int bottom, Collection refs) {
    for (final Iterator it = refs.iterator(); it.hasNext();) {
      final Reference ref = (Reference) it.next();
      if (left > ref.getLeft() || right < ref.getRight()
          || top > ref.getTop() || bottom < ref.getBottom()) {
        throw new ModelException("Cannot change part of a merged cell");
      }
    }
  }
View Full Code Here


 
  public List getMergeRanges() {
    final List refs = _matrixMerge.getAllRefs();
    final List list = new ArrayList(refs.size());
    for (final Iterator it = refs.iterator(); it.hasNext();) {
      final Reference ref = (Reference) it.next();
      list.add(new int[] {ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom()});
    }
    return list;
  }
View Full Code Here

  //Internal Use Only. Called when formula in a cell is to be removed.
  public void remove(XelContext ctx)
  throws XelException {
    if (_type == TokenType.OPERAND && _subtype == TokenSubtype.VAR) { //refer to a variable
      final VariableResolver resolver = ctx.getVariableResolver();
      final Reference ref =
        (Reference) resolver.resolveVariable("zkoss.ss.Ref");
      final BookImpl book = (BookImpl) ref.getSheet().getBook();
      book.removeVariable((String)_value, ref);
    }
   
    //scan thru kid tokens
    if (_operands != null) {
View Full Code Here

    if (cell == null) { //no such cell
      return SSError.REF.toString();
    }
    final StringBuffer sb = new StringBuffer(32);
    final VariableResolver resolver = ctx.getVariableResolver();
    final Reference ref = (Reference) resolver.resolveVariable("zkoss.ss.Ref");
    final Sheet orgsheet = ref.getSheet();
    final Book orgbook = orgsheet.getBook();
   
    final Sheet sheet = cell.getSheet();
    final Book book = sheet.getBook();
    if (book != orgbook) {
View Full Code Here

    if (rng == null) { //no such cell
      return SSError.REF.toString();
    }
    final StringBuffer sb = new StringBuffer(32);
    final VariableResolver resolver = ctx.getVariableResolver();
    final Reference ref = (Reference) resolver.resolveVariable("zkoss.ss.Ref");
    final Sheet orgsheet = ref.getSheet();
    final Book orgbook = orgsheet.getBook();
   
    final Sheet sheet = rng.getSheet();
    final Sheet sheetTo = rng.getSheetTo();
    final Book book = sheet.getBook();
View Full Code Here

    formula.remove(ctx);
  }
 
  private Reference connectRefs(List ranges, XelContext ctx) {
    //connect DAG ref nodes
    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;
View Full Code Here

    return matrix.getRef(sheetFrom, sheetTo, left, top, right, bottom);
  }
  public Reference removeRef(Sheet sheetFrom, Sheet sheetTo, int left, int top, int right, int bottom) {
    final Matrix matrix = sheetTo == null ?
        ((SheetImpl)sheetFrom).getMatrix() : ((BookImpl)sheetFrom.getBook()).getMatrix();
    final Reference ref = matrix.removeRef(sheetFrom, sheetTo, left, top, right, bottom);
    return ref;
  }
View Full Code Here

      ref.update();
    }
    if (ref.getDimension() == 1) {
      final Collection refs = getIntersectRefs(ref.getSheet(), ref.getTop(), ref.getLeft());
      for(final Iterator itr = refs.iterator(); itr.hasNext();) {
        final Reference xref = (Reference) itr.next();
        if (ref != xref) { //skip self
          evalDependent(xref, set, false); //recursive
        }
      }
    }
    for(final Iterator it = ref.getDependents().iterator(); it.hasNext();) {
      final Reference xref = (Reference) it.next();
      evalDependent(xref, set, false); //recursive
    }
  }
View Full Code Here

    }
  }

  //Trigger abacus to update dependent cells and FormulaListener.
  private void update() {
    final Reference ref = getRef();
    getAbacus().evalRef(ref != null ? ref : new RefCell(this));
  }
View Full Code Here

  private XelContext newXelContext() {
    final Book book = getSheet().getBook();
   
    //VariableResolver
    final SSMapResolver resolver = new SSMapResolver(((XelContext)book).getVariableResolver());
    final Reference ref = addRef(); //add it back whenever there is new formula
    ((Ref2d)ref).setUpdatable(true); //and of course a cell is an updatable reference
    ((Ref2d)ref).setLonglive(true); //cannot be cascade removed (ref to cell)
    resolver.set("zkoss.ss.Ref", ref);
   
    return new SimpleXelContext(resolver, ((XelContext)book).getFunctionMapper());
View Full Code Here

TOP

Related Classes of org.zkoss.zss.engine.Reference

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.