Package org.zkoss.zss.engine.impl

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


    /*sort(Sheet sheet, int tRow, int lCol, int bRow, int rCol,
        Ref key1, boolean desc1, Ref key2, int type, boolean desc2, Ref key3, boolean desc3, int header, int orderCustom,
        boolean matchCase, boolean sortByRows, int sortMethod, int dataOption1, int dataOption2, int dataOption3) */

    //Sort A15:L17
    ChangeInfo info = BookHelper.sort(sheet1, 14, 0, 16, 11, ((RangeImpl)Utils.getRange(sheet1, 14, 0)).getRefs().iterator().next(), false,
        null, 0, false, null, false, BookHelper.SORT_HEADER_NO, 0, false, true, 0,
        BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT);
    Set<Ref> last = info.getToEval();
    Set<Ref> all = info.getAffected();
    _evaluator.notifySetFormula(cellM17);

    assertEquals(1, row15.getCell(0).getNumericCellValue(), 0.0000000000000001); //A15: 1
    assertEquals(2, row15.getCell(1).getNumericCellValue(), 0.0000000000000001); //B15: 2
    assertEquals(3, row15.getCell(2).getNumericCellValue(), 0.0000000000000001); //C15: 3
View Full Code Here


    assertEquals(12, valueC13.getNumberValue(), 0.0000000000000001);
    assertEquals(Cell.CELL_TYPE_NUMERIC, valueC13.getCellType());
    testToFormulaString(cellC13, "B12");
   
    //Sort A1:C12
    ChangeInfo info = BookHelper.sort(sheet1, 0, 0, 11, 2, ((RangeImpl)Utils.getRange(sheet1, 0, 0)).getRefs().iterator().next(), false,
        null, 0, false, null, false, BookHelper.SORT_HEADER_NO, 0, false, false, 0,
        BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT);
    Set<Ref> last = info.getToEval();
    Set<Ref> all = info.getAffected();
    _evaluator.notifySetFormula(cellC13);

    assertEquals(1, row1.getCell(0).getNumericCellValue(), 0.0000000000000001); //A1: 1
    assertEquals(2, row2.getCell(0).getNumericCellValue(), 0.0000000000000001)//A2: 2
    assertEquals(3, row3.getCell(0).getNumericCellValue(), 0.0000000000000001); //A3: 3
View Full Code Here

    /*sort(Sheet sheet, int tRow, int lCol, int bRow, int rCol,
        Ref key1, boolean desc1, Ref key2, int type, boolean desc2, Ref key3, boolean desc3, int header, int orderCustom,
        boolean matchCase, boolean sortByRows, int sortMethod, int dataOption1, int dataOption2, int dataOption3) */

    //Sort A15:L17
    ChangeInfo info = BookHelper.sort(sheet1, 14, 0, 16, 11, ((RangeImpl)Utils.getRange(sheet1, 14, 0)).getRefs().iterator().next(), false,
        null, 0, false, null, false, BookHelper.SORT_HEADER_NO, 0, false, true, 0,
        BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT, BookHelper.SORT_NORMAL_DEFAULT);
    Set<Ref> last = info.getToEval();
    Set<Ref> all = info.getAffected();
    _evaluator.notifySetFormula(cellM17);

    assertEquals(1, row15.getCell(0).getNumericCellValue(), 0.0000000000000001); //A15: 1
    assertEquals(2, row15.getCell(1).getNumericCellValue(), 0.0000000000000001); //B15: 2
    assertEquals(3, row15.getCell(2).getNumericCellValue(), 0.0000000000000001); //C15: 3
View Full Code Here

    int nbRow = Math.min(maxrow, bRow + nRow);
    int nrCol = Math.min(maxcol, rCol + nCol);
    if (ntRow <= nbRow && nlCol <= nrCol)
    all.add(new AreaRefImpl(ntRow, nlCol, nbRow, nrCol, refSheet));
   
    return new ChangeInfo(last, all, changeMerges);
  }
View Full Code Here

    int nbRow = Math.min(maxrow, bRow + nRow);
    int nrCol = Math.min(maxcol, rCol + nCol);
    if (ntRow <= nbRow && nlCol <= nrCol)
    all.add(new AreaRefImpl(ntRow, nlCol, nbRow, nrCol, refSheet));
   
    return new ChangeInfo(last, all, changeMerges);
  }
View Full Code Here

            && 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

    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

      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

    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

    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

TOP

Related Classes of org.zkoss.zss.engine.impl.ChangeInfo

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.