Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Range


  /*package*/ void collectChangedRanges(Sheet sheet, int rowoffset, int coloffset, Map changed) {
    if (getLtRefs() != null) {
      for (final Iterator itr = getLtRefs().iterator(); itr.hasNext();) {
        final Reference ref = (Reference) itr.next();
        if (!isScaned(ref, changed)) { //initially prepared ranges, create it
          final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
          final Range mod = new RangeSimple(sheet, null, ref.getLeft()+coloffset, ref.getTop()+rowoffset, ref.getRight(), ref.getBottom());
          putScaned(ref, new Range[] {org, mod}, changed);
        } else { //partially prepared ranges, update it
          final Range[] rngs = getScaned(ref, changed);
          final Range mod = rngs[1];
          rngs[1] = new RangeSimple(sheet, null, ref.getLeft()+coloffset, ref.getTop()+rowoffset, mod.getRight(), mod.getBottom());
        }
      }
    }
    if (getRbRefs() != null) {
      for (final Iterator itr = getRbRefs().iterator(); itr.hasNext();) {
        final Reference ref = (Reference) itr.next();
        if (!isScaned(ref, changed)) { //initially prepared ranges, create it
          final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
          final Range mod = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight()+coloffset, ref.getBottom()+rowoffset);
          putScaned(ref, new Range[] {org, mod}, changed);
        } else { //partially prepared ranges, update it
          final Range[] rngs = getScaned(ref, changed);
          final Range mod = rngs[1];
          rngs[1] = new RangeSimple(sheet, null, mod.getLeft(), mod.getTop(), ref.getRight()+coloffset, ref.getBottom()+rowoffset);
        }
      }
    }
  }
View Full Code Here


              } else { //total removed
                removeLtRef(ref);
                ref.getRbIndex().removeRbRef(ref);
              }
            } else { //initially scaned, create ranges
              final Range org = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              if (ref.getBottom() >= bottom) { //partially removed
                final RowIndex dstri =  _rowIndex.getMatrix().getRowIndex(bottom);
                final CellIndex dstci = dstri.getCellIndex(_col);
                dstci.addLtRef(ref); //ref's left, top, right, bottom is associated with dstci
                final Range mod = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
                putScaned(ref, new Range[] {org, mod}, changed);
              } else { //total removed
                removeLtRef(ref);
                ref.getRbIndex().removeRbRef(ref);
                putScaned(ref, new Range[] {org, null}, changed);
              }
            }
          }
        }
      } else {
        for (int j = sz - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _ltRefs.get(j);
          if (right == -1 || (ref.getLeft() >= left && ref.getRight() <= right)) { //in range
            if (ref.getBottom() >= bottom) { //partially removed
              final RowIndex dstri =  _rowIndex.getMatrix().getRowIndex(bottom);
              final CellIndex dstci = dstri.getCellIndex(_col);
              dstci.addLtRef(ref); //ref's left, top, right, bottom is associated with dstci
            } else { //total removed
              removeLtRef(ref);
              ref.getRbIndex().removeRbRef(ref);
            }
          }
        }
      }
    }
    if (_rbRefs != null) {
      top = top - 1;
      final int sz = _rbRefs.size();
      if (matrix.isUiRelated()) {
        for (int j = sz - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (right == -1 || (ref.getLeft() >= left && ref.getRight() <= right)) { //in range
            if (isScaned(ref, changed)) { //ever scaned, ranges might half baked
              if (ref.getTop() <= top) { //partially removed
                final RowIndex dstri =  _rowIndex.getMatrix().getRowIndex(top);
                if (dstri.isEmpty()) {
                  ++indexdiff;
                }
                final CellIndex dstci = dstri.getCellIndex(_col);
                dstci.addRbRef(ref); //ref's left, top, right, bottom is associated with dstci
                final Range[] rngs = getScaned(ref, changed);
                rngs[1] = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              } else { //total removed
                removeRbRef(ref);
                ref.getLtIndex().removeLtRef(ref);
              }
            } else { //initially scaned, create ranges
              final Range org = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              if (ref.getTop() <= top) { //partially removed
                final RowIndex dstri =  _rowIndex.getMatrix().getRowIndex(top);
                if (dstri.isEmpty()) {
                  ++indexdiff;
                }
                final CellIndex dstci = dstri.getCellIndex(_col);
                dstci.addRbRef(ref); //ref's left, top, right, bottom is associated with dstci
                final Range mod = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
                putScaned(ref, new Range[] {org, mod}, changed);
              } else { //total removed
                removeRbRef(ref);
                ref.getLtIndex().removeLtRef(ref);
                putScaned(ref, new Range[] {org, null}, changed);
View Full Code Here

              } else { //total remove
                removeLtRef(ref);
                ref.getRbIndex().removeRbRef(ref);
              }
            } else { //initial scaned, create ranges
              final Range org = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              if (ref.getRight() >= right) { //partial remove
                final CellIndex dstci = _rowIndex.getMatrix().getCellIndex(row, right);
                dstci.addLtRef(ref); //ref's left, top, right, bottom is associated with dstci
                final Range mod = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
                putScaned(ref, new Range[] {org, mod}, changed);
              } else { //total remove
                removeLtRef(ref);
                ref.getRbIndex().removeRbRef(ref);
                putScaned(ref, new Range[] {org, null}, changed);
              }
            }
          }
        }
      } else {
        for (int j = sz - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _ltRefs.get(j);
          if (top == -1 || (ref.getTop() >= top && ref.getBottom() <= bottom)) { //in range
            if (ref.getRight() >= right) { //partial remove
              final CellIndex dstci = _rowIndex.getMatrix().getCellIndex(row, right);
              dstci.addLtRef(ref); //ref's left, top, right, bottom is associated with dstci
            } else { //total remove
              removeLtRef(ref);
              ref.getRbIndex().removeRbRef(ref);
            }
          }
        }
      }
    }
    int indexdiff = 0;
    if (_rbRefs != null) {
      left = left - 1;
      final int sz = _rbRefs.size();
      if (matrix.isUiRelated()) {
        for (int j = sz - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (top == -1 || (ref.getTop() >= top && ref.getBottom() <= bottom)) { //in range
            if (isScaned(ref, changed)) { //ever scaned, ranges might half baked
              if (ref.getLeft() <= left) { //partial remove
                final CellIndex dstci = _rowIndex.getMatrix().getCellIndex(row, left);
                if (dstci.isEmpty()) {
                  ++indexdiff;
                }
                dstci.addRbRef(ref);
                final Range[] rngs = getScaned(ref, changed);
                rngs[1] = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              } else { //total remove
                removeRbRef(ref);
                ref.getLtIndex().removeLtRef(ref);
              }
            } else { //initial scaned, create ranges
              final Range org = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              if (ref.getLeft() <= left) { //partial remove
                final CellIndex dstci = _rowIndex.getMatrix().getCellIndex(row, left);
                if (dstci.isEmpty()) {
                  ++indexdiff;
                }
                dstci.addRbRef(ref);
                final Range mod = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
                putScaned(ref, new Range[] {org, mod}, changed);
              } else { //total remove
                removeRbRef(ref);
                ref.getLtIndex().removeLtRef(ref);
                putScaned(ref, new Range[] {org, null}, changed);
View Full Code Here

            if (isScaned(ref, changed)) {
              //detach reference from the CellIndex
              ref.getRbIndex().removeRbRef(ref);
              removeLtRef(ref);
            } else { //initial scaned, create ranges
              final Range org = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              //detach reference from the CellIndex
              ref.getRbIndex().removeRbRef(ref);
              removeLtRef(ref);
              putScaned(ref, new Range[] {org, null}, changed);
            }
          }
        }
      } else {
        for (int j = sz - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _ltRefs.get(j);
          if (top == -1 || (ref.getTop() >= top && ref.getBottom() <= bottom)) { //complete in range
            //detach reference from the CellIndex
            ref.getRbIndex().removeRbRef(ref);
            removeLtRef(ref);
          }
        }
      }
    }
    if (_rbRefs != null) {
      final int sz = _rbRefs.size();
      if (matrix.isUiRelated()) {
        for (int j = sz - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (top == -1 || (ref.getTop() >= top && ref.getBottom() <= bottom)) { //complete in range
            if (isScaned(ref, changed)) {
              //detach reference from the CellIndex
              ref.getLtIndex().removeRbRef(ref);
              removeRbRef(ref);
            } else {
              final Range org = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              //detach reference from the CellIndex
              ref.getLtIndex().removeRbRef(ref);
              removeRbRef(ref);
              putScaned(ref, new Range[] {org, null}, changed);
            }
View Full Code Here

            if (isScaned(ref, changed)) { //ever scaned, ranges might half baked
              dstci.addLtRef(ref); //left, top, right, bottom associate with dstci
              final Range[] rngs = getScaned(ref, changed);
              rngs[1] = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
            } else {
              final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              dstci.addLtRef(ref); //left, top, right, bottom associate with dstci
              final Range mod = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              putScaned(ref, new Range[] {org, mod}, changed);
            }
          }
        }
      } else {
        for(int j = _ltRefs.size() - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _ltRefs.get(j);
          if (ref.getBottom() >= dstri.getRow() //not overly moved and in range
          && (left == -1 || (ref.getLeft() >= left && ref.getRight() <= right))) {
            dstci.addLtRef(ref); //left, top, right, bottom associate with dstci
          }
        }
      }
    }
    if (_rbRefs != null) {
      if (matrix.isUiRelated()) {
        for(int j = _rbRefs.size() - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (ref.getTop() <= dstri.getRow() //not overly moved and in range
          && (left == -1 || (ref.getLeft() >= left && ref.getRight() <= right))) {
            if (isScaned(ref, changed)) {
              dstci.addRbRef(ref);
              final Range[] rngs = getScaned(ref, changed);
              rngs[1] = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
            } else {
              final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              dstci.addRbRef(ref);
              final Range mod = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              putScaned(ref, new Range[] {org, mod}, changed);
            }
          }
        }
      } else {
View Full Code Here

            if (isScaned(ref, changed)) { //ever scaned, ranges might partially baked
              dstci.addLtRef(ref);
              final Range[] rngs = getScaned(ref, changed);
              rngs[1] = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
            } else {
              final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              dstci.addLtRef(ref);
              final Range mod = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              putScaned(ref, new Range[] {org, mod}, changed);
            }
          }
        }
      } else {
        for(int j = _ltRefs.size() - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _ltRefs.get(j);
          if (ref.getRight() >= dstci.getColumn() //not overly moved and in range
          && (top == -1 || (ref.getTop() >= top && ref.getBottom() <= bottom))) {
            dstci.addLtRef(ref);
          }
        }
      }
    }
    if (_rbRefs != null) {
      if (matrix.isUiRelated()) {
        for(int j = _rbRefs.size() - 1; j >= 0; --j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (ref.getLeft() <= dstci.getColumn() //not overly moved and in range
          && (top == -1 || (ref.getTop() >= top && ref.getBottom() <= bottom))) {
            if (isScaned(ref, changed)) { //ever scaned, ranges might half baked
              dstci.addRbRef(ref);
              final Range[] rngs = getScaned(ref, changed);
              rngs[1] = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
            } else {
              final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              dstci.addRbRef(ref);
              final Range mod = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              putScaned(ref, new Range[] {org, mod}, changed);
            }
          }
        }
      } else {
View Full Code Here

              // and it disturbs the row iteration that call this method.
              ltRefs.add(ref);
              final Range[] rngs = getScaned(ref, changed);
              rngs[1] = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
            } else { //initial scaned, create ranges
              final Range org = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              dstci.addRbRef(ref);
              // store in ltRefs and prepared to be processed later
              // cannot process here since it can cause a whole RowIndex removed
              // and it disturbs the row iteration that call this method.
              ltRefs.add(ref);
              final Range mod = new RangeSimple(sheet, null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              putScaned(ref, new Range[] {org, mod}, changed);
            }
          }
        }
      } else {
View Full Code Here

    for (Iterator it = _listeners.iterator(); it.hasNext();)
      ((SSDataListener)it.next()).onChange(event);
  }
 
  public void fireSSDataEvent(Reference ref, int type, int direction) {
    final Range rng = new RangeRef(ref, true, true, true, true, true);
    fireSSDataEvent(new SSDataEvent(rng, type, direction));
  }
View Full Code Here

        throw x;
      }
    }
   
    public void onChange0(SSDataEvent event) {
      Range rng = event.getRange();//rng might be null in MERGE_DELETE
      Range orng = event.getOriginalRange();
      Sheet sheet = rng!=null?rng.getSheet():orng.getSheet();
      if(!getSelectedSheet().equals(sheet)) return;
     
      int type  = event.getType();
      int dir = event.getDirection();
     
      int left,top,right,bottom;
      int oleft,otop,oright,obottom;
     
      if(rng!=null){
        left = rng.getLeft();
        top = rng.getTop();
        right = rng.getRight();
        bottom = rng.getBottom();
      }else{
        left = top = right = bottom = -1;
      }
     
      if(orng!=null){
        oleft = orng.getLeft();
        otop = orng.getTop();
        oright = orng.getRight();
        obottom = orng.getBottom();
      }else{
        oleft = otop = oright = obottom = -1;
      }
     
      if(type != SSDataEvent.MERGE_DELETE){
View Full Code Here

    final Cell old = ci == null ? null : ci.getCellIfExists();
    if (old != null) {
      //remove the merge range if a merged cell
      final RangeMerge rm = ((CellImpl)old).getRangeMerge();
      if (rm != null) {
        final Range rng = new RangeSimple(this, null, rm.getLeft(), rm.getTop(), rm.getRight(), rm.getBottom());
        rm.getRef().remove();
        _book.fireSSDataEvent(new SSDataEvent(null, rng, SSDataEvent.MERGE_DELETE, SSDataEvent.MOVE_NO));
      }
      if (ci.setCell(null)) { //CellIndex should be removed, too
        _matrix.detachCellIndex(row, col);
View Full Code Here

TOP

Related Classes of org.zkoss.zss.model.Range

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.