Package org.zkoss.zss.engine.xel

Examples of org.zkoss.zss.engine.xel.Ref2d


   * @return The managed Reference at the same range if already exists;
   * otherwise, the passed in Reference is returned. 
   */
  public Reference addRef(Sheet sheetFrom, Sheet sheetTo, int left, int top, int right, int bottom) {
    Reference ref = sheetTo == null ?
      (Reference) new Ref2d(sheetFrom) : (Reference) new Ref3d(sheetFrom, sheetTo);
    final CellIndex ltci = getCellIndex(top, left);
    final CellIndex rbci = getCellIndex(bottom, right);
    if (!ltci.isEmpty() && !rbci.isEmpty()) {
      final Reference xref  = ltci.getLtRef(right, bottom);
      if (xref != null && xref.getSheet() == sheetFrom && xref.getSheetTo() == sheetTo) {
View Full Code Here


    rbci.addRbRef(ref);
    return ref;
  }
 
  public Reference removeRef(Sheet sheetFrom, Sheet sheetTo, int left, int top, int right, int bottom) {
    final Ref2d ref = (Ref2d) getRef(sheetFrom, sheetTo, left, top, right, bottom);
    if (ref != null) {
      ref.remove(false);
    }
    return ref;
  }
View Full Code Here

      }
    }
    //cannot adjust left-top simulataneously in above loop
    //RowIndex can be removed or added unexpectedly, no proper way to adjust the j index above 
    for (final Iterator it = ltRefs.iterator(); it.hasNext(); ) {
      final Ref2d ref = (Ref2d) it.next();
      final CellIndex srcci = ref.getLtIndex();
      final RowIndex srcri = srcci.getRowIndex();
      final int col = srcci.getColumn();
      final int row = srcri.getRow();
      final CellIndex ci = getCellIndex(row+rowoffset, col+coloffset);
      ci.addLtRef(ref);
View Full Code Here

    final Matrix matrix = _rowIndex.getMatrix();
    if (_ltRefs != null) {
      final int sz = _ltRefs.size();
      if (matrix.isUiRelated()) {
        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
            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);
            }
          }
        }
      } else {
        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
            //detach reference from the CellIndex
            ref.getLtIndex().removeRbRef(ref);
            removeRbRef(ref);
          }
        }
      }
    }
View Full Code Here

    final Matrix matrix = _rowIndex.getMatrix();
    final Sheet sheet = matrix.getSheet();
    if (_ltRefs != null) {
      if (matrix.isUiRelated()) {
        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))) {
            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 {
        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))) {
            dstci.addRbRef(ref);
          }
        }
      }
    }
View Full Code Here

    final Sheet sheet = matrix.getSheet();
    moveCell(dstci);
    if (_ltRefs != null) {
      if (matrix.isUiRelated()) {
        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))) {
            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 {
        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))) { 
            dstci.addRbRef(ref);
          }
        }
      }
    }
View Full Code Here

    if (_ltRefs != null) {
      bottom = bottom + 1;
      final int sz = _ltRefs.size();
      if (matrix.isUiRelated()) {
        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 (isScaned(ref, changed)) { //ever scaned, the ranges might half baked
              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[] rngs = getScaned(ref, changed);
                rngs[1] = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              } 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);
              }
            }
          }
        }
      } else {
        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 (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
            } else { //total removed
              removeRbRef(ref);
              ref.getLtIndex().removeLtRef(ref);
            }
          }
        }
      }
    }
View Full Code Here

    if (_ltRefs != null) {
      right = right + 1;
      final int sz = _ltRefs.size();
      if (matrix.isUiRelated()) {
        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 (isScaned(ref, changed)) { //ever scaned, ranges might half baked
              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[] rngs = getScaned(ref, changed);
                rngs[1] = new RangeSimple(ref.getSheet(), null, ref.getLeft(), ref.getTop(), ref.getRight(), ref.getBottom());
              } 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);
              }
            }
          }
        }
      } else {
        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 (ref.getLeft() <= left) { //partial remove
              final CellIndex dstci = _rowIndex.getMatrix().getCellIndex(row, left);
              if (dstci.isEmpty()) {
                ++indexdiff;
              }
              dstci.addRbRef(ref);
            } else { //total remove
              removeRbRef(ref);
              ref.getLtIndex().removeLtRef(ref);
            }
          }
        }
      }
    }
View Full Code Here

    final CellIndex dstci = dstri.getCellIndex(getColumn()+coloffset);
    if (_rbRefs != null) {
      final int sz = _rbRefs.size();
      if (matrix.isUiRelated()) {
        for(int j = 0; j < sz; ++j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (ref.getLeft() >= left && ref.getRight() <= right
          && ref.getTop() >= top && ref.getBottom() <= bottom) {
            if (isScaned(ref, changed)) { //ever scaned, ranges might half baked
              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[] 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 {
        for(int j = 0; j < sz; ++j) {
          final Ref2d ref = (Ref2d) _rbRefs.get(j);
          if (ref.getLeft() >= left && ref.getRight() <= right
          && ref.getTop() >= top && ref.getBottom() <= bottom) {
            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);
View Full Code Here

  }
 
  /*package*/ Collection getRowOverlapRefs(int left, int right, Collection lst) {
    if (_ltRefs != null) {
      for(final Iterator it = _ltRefs.iterator(); it.hasNext();) {
        final Ref2d ref = (Ref2d) it.next();
        final int refr = ref.getRight();
        if (right == -1 || refr <= right) {
          lst.add(ref);
        }
      }
    }
    if (_rbRefs != null) {
      for(final Iterator it = _rbRefs.iterator(); it.hasNext();) {
        final Ref2d ref = (Ref2d) it.next();
        final int refl = ref.getLeft();
        if (left == -1 || refl >= left) {
          lst.add(ref);
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.engine.xel.Ref2d

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.