Examples of ChangeInfo


Examples of org.zkoss.zss.engine.impl.ChangeInfo

            && firstRow >= tRow && lastRow <= bRow) { //total cover
        changes.add(new MergeChange(new AreaRefImpl(firstRow, firstCol, lastRow, lastCol, refSheet), null));
        sheet.removeMergedRegion(j);
          }
    }
    return new ChangeInfo(null, null, changes);
  }
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

    if (across) {
      final Set<Ref> toEval = new HashSet<Ref>();
      final Set<Ref> affected = new HashSet<Ref>();
      final List<MergeChange> changes = new ArrayList<MergeChange>();
      for(int r = tRow; r <= bRow; ++r) {
        final ChangeInfo info = merge0(sheet, r, lCol, r, rCol);
        changes.addAll(info.getMergeChanges());
        toEval.addAll(info.getToEval());
        affected.addAll(info.getAffected());
      }
      return new ChangeInfo(toEval, affected, changes);
    } else {
      return merge0(sheet, tRow, lCol, bRow, rCol);
    }
  }
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

      final int tgtRow = target.getRowIndex();
      final int tgtCol = target.getColumnIndex();
      final int nRow = tRow - tgtRow;
      final int nCol = lCol - tgtCol;
      if (nRow != 0 || nCol != 0) { //if target not the left-top one, move to left-top
        final ChangeInfo info = BookHelper.moveRange(sheet, tgtRow, tgtCol, tgtRow, tgtCol, nRow, nCol);
        if (info != null) {
          changes.addAll(info.getMergeChanges());
          last.addAll(info.getToEval());
          all.addAll(info.getAffected());
        }
      }
      final CellStyle source = target.getCellStyle();
      style = source.getIndex() == 0 ? null : sheet.getWorkbook().createCellStyle();
      if (style != null) {
        style.cloneStyleFrom(source);
        style.setBorderLeft(CellStyle.BORDER_NONE);
        style.setBorderTop(CellStyle.BORDER_NONE);
        style.setBorderRight(CellStyle.BORDER_NONE);
        style.setBorderBottom(CellStyle.BORDER_NONE);
        target.setCellStyle(style); //set all cell in the merged range to CellStyle of the target minus border
      }
      //1st row (exclude 1st cell)
      for (int c = lCol + 1; c <= rCol; ++c) {
        final Cell cell = getOrCreateCell(sheet, tRow, c);
        cell.setCellStyle(style); //set all cell in the merged range to CellStyle of the target minus border
        final Set<Ref>[] refs = BookHelper.setCellValue(cell, (RichTextString) null);
        if (refs != null) {
          last.addAll(refs[0]);
          all.addAll(refs[1]);
        }
      }
      //2nd row and after
      for(int r = tRow+1; r <= bRow; ++r) {
        for(int c = lCol; c <= rCol; ++c) {
          final Cell cell = getOrCreateCell(sheet, r, c);
          cell.setCellStyle(style); //set all cell in the merged range to CellStyle of the target minus border
          final Set<Ref>[] refs = BookHelper.setCellValue(cell, (RichTextString) null);
          if (refs != null) {
            last.addAll(refs[0]);
            all.addAll(refs[1]);
          }
        }
      }
    }
   
    sheet.addMergedRegion(new CellRangeAddress(tRow, bRow, lCol, rCol));
    final Ref mergeArea = new AreaRefImpl(tRow, lCol, bRow, rCol, BookHelper.getRefSheet((Book)sheet.getWorkbook(), sheet));
    all.add(mergeArea);
    changes.add(new MergeChange(null, mergeArea));
   
    return new ChangeInfo(last, all, changes);
  }
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

    final int cellCount = bRow - tRow + 1;
    final Map<Integer, List<Cell>> newCols = new HashMap<Integer, List<Cell>>()
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    int j = 0;
    for(final Iterator<SortKey> it = sortKeys.iterator(); it.hasNext();++j) {
      final SortKey sortKey = it.next();
      final int oldColNum = sortKey.getIndex();
      final int newColNum = lCol + j;
      it.remove();
      if (oldColNum == newColNum) { //no move needed, skip it
        continue;
      }
      //remove cells from the old column of the Range
      final List<Cell> cells = new ArrayList<Cell>(cellCount);
      for(int k = tRow; k <= bRow; ++k) {
        final Cell cell = BookHelper.getCell(sheet, k, oldColNum);
        if (cell != null) {
          cells.add(cell);
          final Set<Ref>[] refs = BookHelper.removeCell(cell, false);
          toEval.addAll(refs[0]);
          affected.addAll(refs[1]);
        }
      }
      if (!cells.isEmpty()) {
        newCols.put(Integer.valueOf(newColNum), cells);
      }
    }
   
    //move cells
    for(Entry<Integer, List<Cell>> entry : newCols.entrySet()) {
      final int colNum = entry.getKey().intValue();
      final List<Cell> cells = entry.getValue();
      for(Cell cell : cells) {
        final int rowNum = cell.getRowIndex();
        final ChangeInfo changeInfo0 = BookHelper.copyCell(cell, sheet, rowNum, colNum, Range.PASTE_ALL, Range.PASTEOP_NONE, false);
        assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
      }
    }
    return changeInfo;
  }
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

    final int cellCount = rCol - lCol + 1;
    final Map<Integer, List<Cell>> newRows = new HashMap<Integer, List<Cell>>()
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    int j = 0;
    for(final Iterator<SortKey> it = sortKeys.iterator(); it.hasNext();++j) {
      final SortKey sortKey = it.next();
      final int oldRowNum = sortKey.getIndex();
      final Row row = sheet.getRow(oldRowNum);
      final int newRowNum = tRow + j;
      it.remove();
      if (oldRowNum == newRowNum) { //no move needed, skip it
        continue;
      }
      //remove cells from the old row of the Range
      final List<Cell> cells = new ArrayList<Cell>(cellCount);
      final int begCol = Math.max(lCol, row.getFirstCellNum());
      final int endCol = Math.min(rCol, row.getLastCellNum() - 1);
      for(int k = begCol; k <= endCol; ++k) {
        final Cell cell = row.getCell(k);
        if (cell != null) {
          cells.add(cell);
          final Set<Ref>[] refs = BookHelper.removeCell(cell, false);
          assignRefs(toEval, affected, refs);
        }
      }
      if (!cells.isEmpty()) {
        newRows.put(Integer.valueOf(newRowNum), cells);
      }
    }
   
    //move cells
    for(Entry<Integer, List<Cell>> entry : newRows.entrySet()) {
      final int rowNum = entry.getKey().intValue();
      final List<Cell> cells = entry.getValue();
      for(Cell cell : cells) {
        final int colNum = cell.getColumnIndex();
        final ChangeInfo changeInfo0 = BookHelper.copyCell(cell, sheet, rowNum, colNum, Range.PASTE_ALL, Range.PASTEOP_NONE, false);
        assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
      }
    }
    return changeInfo;
  }
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

      break;
    }
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    final int rowCount = srcRef.getRowCount();
    final int colCount = srcRef.getColumnCount();
    final int srctRow = srcRef.getTopRow();
    final int srcbRow = srcRef.getBottomRow();
    final int srclCol = srcRef.getLeftCol();
    final int srcrCol = srcRef.getRightCol();
   
    final int dstbRow = dstRef.getBottomRow();
    final StepChunk[] stepChunks = new StepChunk[colCount];
    //prepare StepChunks
    for(int c = srclCol, j = 0; c <= srcrCol; ++c) {
      final StepChunk stepChunk = getRowStepChunk(sheet, fillType, c, srctRow, srcbRow, true, colCount);
      stepChunks[j++] = stepChunk;
    }
    //handle special copy only case (two consecutive same type of row)
    handleSpecialCopyStep(stepChunks, rowCount, colCount);
    for(int c = srclCol, j = 0; c <= srcrCol; ++c) {
      final StepChunk stepChunk = stepChunks[j++];
      for(int srcIndex = 0, r = srcbRow + 1; r <= dstbRow; ++r, ++srcIndex) {
        final int index = srcIndex % rowCount;
        final int srcrow = srctRow + index;
        final Cell srcCell = BookHelper.getCell(sheet, srcrow, c);
        if (srcCell == null) {
          final Set<Ref>[] refs = BookHelper.removeCell(sheet, r, c);
          assignRefs(toEval, affected, refs);
        } else {
          final ChangeInfo changeInfo0 = BookHelper.copyCell(stepChunk.getStep(index).next(srcCell), srcCell, sheet, r, c, pasteType, BookHelper.PASTEOP_NONE, false);
          assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
        }
      }
    }
    final RefSheet refSheet = BookHelper.getRefSheet((Book)sheet.getWorkbook(), sheet);
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

      return null;
    }
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    final int rowCount = srcRef.getRowCount();
    final int colCount = srcRef.getColumnCount();
    final int srctRow = srcRef.getTopRow();
    final int srcbRow = srcRef.getBottomRow();
    final int srclCol = srcRef.getLeftCol();
    final int srcrCol = srcRef.getRightCol();
   
    final int dsttRow = dstRef.getTopRow();
    final StepChunk[] stepChunks = new StepChunk[colCount];
    for(int c = srclCol, j = 0; c <= srcrCol; ++c) {
      final StepChunk stepChunk = getRowStepChunk(sheet, fillType, c, srcbRow, srctRow, false, colCount);
      stepChunks[j++] = stepChunk;
    }
    //handle special copy only case (two consecutive same type of row)
    handleSpecialCopyStep(stepChunks, rowCount, colCount);
    for(int c = srclCol, j = 0; c <= srcrCol; ++c) {
      final StepChunk stepChunk = stepChunks[j++];
      for(int srcIndex = 0, r = srctRow - 1; r >= dsttRow; --r, ++srcIndex) {
        final int index = srcIndex % rowCount;
        final int srcrow = srcbRow - index;
        final Cell srcCell = BookHelper.getCell(sheet, srcrow, c);
        if (srcCell == null) {
          final Set<Ref>[] refs = BookHelper.removeCell(sheet, r, c);
          assignRefs(toEval, affected, refs);
        } else {
          final ChangeInfo changeInfo0 = BookHelper.copyCell(stepChunk.getStep(index).next(srcCell), srcCell, sheet, r, c, pasteType, BookHelper.PASTEOP_NONE, false);
          assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
        }
      }
    }
    final RefSheet refSheet = BookHelper.getRefSheet((Book)sheet.getWorkbook(), sheet);
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

      return null;
    }
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    final int rowCount = srcRef.getRowCount();
    final int colCount = srcRef.getColumnCount();
    final int srclCol = srcRef.getLeftCol();
    final int srcrCol = srcRef.getRightCol();
    final int srctRow = srcRef.getTopRow();
    final int srcbRow = srcRef.getBottomRow();
   
    final int dstrCol = dstRef.getRightCol();
    final StepChunk[] stepChunks = new StepChunk[rowCount];
    for(int r = srctRow, j = 0; r <= srcbRow; ++r) {
      final StepChunk stepChunk = getColStepChunk(sheet, fillType, r, srclCol, srcrCol, true, rowCount);
      stepChunks[j++] = stepChunk;
    }
    //handle special copy only case (two consecutive same type of row)
    handleSpecialCopyStep(stepChunks, colCount, rowCount);
    for(int r = srctRow, j = 0; r <= srcbRow; ++r) {
      final StepChunk stepChunk = stepChunks[j++];
      for(int srcIndex = 0, c = srcrCol + 1; c <= dstrCol; ++c, ++srcIndex) {
        final int index = srcIndex % colCount;
        final int srccol = srclCol + index;
        final Cell srcCell = BookHelper.getCell(sheet, r, srccol);
        if (srcCell == null) {
          final Set<Ref>[] refs = BookHelper.removeCell(sheet, r, c);
          assignRefs(toEval, affected, refs);
        } else {
          final ChangeInfo changeInfo0 = BookHelper.copyCell(stepChunk.getStep(index).next(srcCell), srcCell, sheet, r, c, pasteType, BookHelper.PASTEOP_NONE, false);
          assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
        }
      }
    }
    final RefSheet refSheet = BookHelper.getRefSheet((Book)sheet.getWorkbook(), sheet);
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

      return null;
    }
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    final int rowCount = srcRef.getRowCount();
    final int colCount = srcRef.getColumnCount();
    final int srclCol = srcRef.getLeftCol();
    final int srcrCol = srcRef.getRightCol();
    final int srctRow = srcRef.getTopRow();
    final int srcbRow = srcRef.getBottomRow();
   
    final int dstlCol = dstRef.getLeftCol();
    final StepChunk[] stepChunks = new StepChunk[rowCount];
    for(int r = srctRow, j = 0; r <= srcbRow; ++r) {
      final StepChunk stepChunk = getColStepChunk(sheet, fillType, r, srcrCol, srclCol, false, rowCount);
      stepChunks[j++] = stepChunk;
    }
    //handle special copy only case (two consecutive same type of row)
    handleSpecialCopyStep(stepChunks, colCount, rowCount);
    for(int r = srctRow, j = 0; r <= srcbRow; ++r) {
      final StepChunk stepChunk = stepChunks[j++];
      for(int srcIndex = 0, c = srclCol - 1; c >= dstlCol; --c, ++srcIndex) {
        final int index = srcIndex % colCount;
        final int srccol = srcrCol - index;
        final Cell srcCell = BookHelper.getCell(sheet, r, srccol);
        if (srcCell == null) {
          final Set<Ref>[] refs = BookHelper.removeCell(sheet, r, c);
          assignRefs(toEval, affected, refs);
        } else {
          final ChangeInfo changeInfo0 = BookHelper.copyCell(stepChunk.getStep(index).next(srcCell), srcCell, sheet, r, c, pasteType, BookHelper.PASTEOP_NONE, false);
          assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
        }
      }
    }
    final RefSheet refSheet = BookHelper.getRefSheet((Book)sheet.getWorkbook(), sheet);
View Full Code Here

Examples of org.zkoss.zss.engine.impl.ChangeInfo

 
  private static ChangeInfo copyCell(Object cellValue, Cell srcCell, Cell dstCell, int pasteType, int pasteOp, boolean transpose) {
    final Set<Ref> toEval = new HashSet<Ref>();
    final Set<Ref> affected = new HashSet<Ref>();
    final List<MergeChange> mergeChanges = new ArrayList<MergeChange>();
    final ChangeInfo changeInfo = new ChangeInfo(toEval, affected, mergeChanges);
    //paste cell formats
    if ((pasteType & BookHelper.INNERPASTE_FORMATS) != 0) {
      dstCell.setCellStyle(prepareCellStyle(srcCell.getCellStyle(), dstCell, pasteType));
      //handle merge/unmerge cases
      final int dstrow = dstCell.getRowIndex();
      final int dstcol = dstCell.getColumnIndex();
      final Worksheet dstSheet = (Worksheet)dstCell.getSheet();
      final CellRangeAddress dstaddr = ((SheetCtrl)dstSheet).getMerged(dstrow, dstcol);
      if (dstaddr != null) { //shall un-merge the destination merge range
        final int dstrow2 = dstaddr.getLastRow();
        final int dstcol2 = dstaddr.getLastColumn();
        final ChangeInfo changeInfo0 = unMerge(dstSheet, dstrow, dstcol, dstrow2, dstcol2);
        assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
      }
      final int srcrow = srcCell.getRowIndex();
      final int srccol = srcCell.getColumnIndex();
      final CellRangeAddress srcaddr = ((SheetCtrl)srcCell.getSheet()).getMerged(srcrow, srccol);
      if (srcaddr != null) { //src is a merge range, shall merge dest cell
        final int srcrow2 = srcaddr.getLastRow();
        final int srccol2 = srcaddr.getLastColumn();
        final int tRow = dstrow;
        final int lCol = dstcol;
        final int bRow = tRow + srcrow2 - srcrow;
        final int rCol = lCol + srccol2 - srccol;
        final ChangeInfo changeInfo0 = merge(dstSheet, tRow, lCol, bRow, rCol, false);
        assignChangeInfo(toEval, affected, mergeChanges, changeInfo0);
      }
    }
   
    //paste comment
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.