Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Format


    final int cellcol = thecell.getColumn();
    if (cellrow != top || cellcol != left) {
      //preserve the left-top format
      final CellIndex ltci = _matrix.getCellIndexIfExists(top, left);
      final Cell ltcell = ltci != null ? ltci.getCell() : null;
      final Format ltfmt = ltcell != null ? ltcell.getFormat() : null;
 
      //move the cell to left-top
      final int coloff = left - cellcol;
      final int rowoff = top - cellrow;
      _matrix.moveRange(_matrix, cellcol, cellrow, cellcol, cellrow, rowoff, coloff);
     
      //recover the moved border if any
      final Cell x = _matrix.getCellIndex(cellrow, cellcol).getCell();
      if (cellcol == left) { //left border
        getFormatOrCreate(x).setBorderLeft(fmt.getBorderLeft());
      }
      if (cellrow == top) { //top border
        getFormatOrCreate(x).setBorderTop(fmt.getBorderTop());
      }
      if (cellcol == right) { //right border
        getFormatOrCreate(x).setBorderRight(fmt.getBorderRight());
      }
      if (cellrow == bottom) { //bottom border
        getFormatOrCreate(x).setBorderBottom(fmt.getBorderBottom());
      }
     
      //assign ltfmt border to fmt
      if (ltfmt != null) {
        fmt.setBorderLeft(ltfmt.getBorderLeft());
        fmt.setBorderTop(ltfmt.getBorderTop());
        fmt.setBorderRight(ltfmt.getBorderRight());
        fmt.setBorderBottom(ltfmt.getBorderBottom());
      } else {
        fmt.setBorderLeft(null);
        fmt.setBorderTop(null);
        fmt.setBorderRight(null);
        fmt.setBorderBottom(null);
View Full Code Here


    if (left > 0) { //left == 0, no need to copy format
      final List lst = _matrix.getCells(left-1, top, left-1, bottom, new LinkedList());
      for (final Iterator it = lst.iterator(); it.hasNext();) {
        final Cell cell = (Cell) it.next();
        final int row = cell.getRow();
        final Format format = cell.getFormat();
        if (format != null) {
          for(int k = left; k <= right; ++k) {
            copyCellFormat(cell, row, k);
          }
          final Range xrng = new RangeSimple(this, null, left, row, right, row);
View Full Code Here

    if (top > 0) { //top == 0, no need to copy format
      final List lst = _matrix.getCells(left, top-1, right, top-1, new LinkedList());
      for (final Iterator it = lst.iterator(); it.hasNext();) {
        final Cell cell = (Cell) it.next();
        final int col = cell.getColumn();
        final Format format = cell.getFormat();
        if (format != null) {
          for(int r = top; r <= bottom; ++r) {
            copyCellFormat(cell, r, col);
          }
          final Range xrng = new RangeSimple(this, null, col, top, col, bottom);
View Full Code Here

    int[][] cells = new int[][]{{1,1},{2,1},{3,1},{4,1},{5,1},{6,1}};
    String[] colors = new String[]{"#CC0000","#CC9900","#008000","#006699","#3333FF","#FF00FF",};
   
   
    Cell cell;
    Format format;
    String color;
    for(int i=0;i<cells.length;i++){
      cell = sheet1.getCell(cells[i][0],cells[i][1]);
      assertNotNull(cell);
      format = cell.getFormat();
      assertNotNull(format);
      color = format.getFillColor();
      assertNotNull(color);
      assertEquals(colors[i],color.toUpperCase());
    }
   
  }
View Full Code Here

    }
    return _value;
  }
 
  public String getText() {
    final Format format = getFormat();
    Object result = getResult();
    if (result instanceof Range) {
      final Range rng = (Range) result;
      final Cell[][][] rngcella = rng.getCellsArray();
      final int colsz = rng.getColumnSize();
      final int rowsz = rng.getRowSize();
      if (colsz == 1 && rowsz == 1) { //single cell range
        final Cell rngcell = rngcella[0][0][0];
        if (rngcell == null) {
          result = Objects.ZERO_DOUBLE;
        } else {
          result = rngcell.getResult();
        }
      } else if (colsz > 1 && rowsz > 1) {
        result = SSError.VALUE;
      } else if (colsz == 1) {
        final int row = getRow();
        final int rngtop = rng.getTop();
        final int rngbottom = rng.getBottom();
        if (row >= rngtop && row <= rngbottom) {
          final int rowidx = row - rngtop;
          final Cell rngcell = rngcella[0][rowidx][0];
          if (rngcell == null) {
            result = Objects.ZERO_DOUBLE;
          } else {
            result = rngcell.getResult();
          }
        } else {
          result = SSError.VALUE;
        }
      } else { //rowsz == 1
        final int col = getColumn();
        final int rngleft = rng.getLeft();
        final int rngright = rng.getRight();
        if (col >= rngleft && col <= rngright) {
          final int colidx = col - rngleft;
          final Cell rngcell = rngcella[0][0][colidx];
          if (rngcell == null) {
            result = Objects.ZERO_DOUBLE;
          } else {
            result = rngcell.getResult();
          }
        } else {
          result = SSError.VALUE;
        }
      }
      if (result == null) {
        result = Objects.ZERO_DOUBLE;
      }
    }
    if (result == null && (_value instanceof Formula)) {
      result = new Double(0);
    }
    return format != null ?
      format.getText(result) : FormatImpl.DEFAULT_FORMAT.getText(result)
  }
View Full Code Here

    return format != null ?
      format.getText(result) : FormatImpl.DEFAULT_FORMAT.getText(result)
  }
 
  public String getTextColor() {
    final Format format = getFormat();
    final Object result = getResult();
    return format == null ?
      FormatImpl.DEFAULT_FORMAT.getTextColor(result) : format.getTextColor(result);
  }
View Full Code Here

    return format == null ?
      FormatImpl.DEFAULT_FORMAT.getTextColor(result) : format.getTextColor(result);
  }
 
  public TextHAlign getTextHAlign() {
    final Format format = getFormat();
    final Object result = getResult();
    return format == null ?
      FormatImpl.DEFAULT_FORMAT.getTextHAlign(result) : format.getTextHAlign(result);
  }
View Full Code Here

TOP

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

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.