Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Format


  public String getHtmlStyle() {

    StringBuffer sb = new StringBuffer();
    if (_cell != null) {
      String txt = _cell.getText();
      Format format = _cell.getFormat();
      if (format == null)
        return "";

      String bgColor = format.getFillColor();
      if (AUTO_COLOR.equals(bgColor)) {
        bgColor = null;
      }
      if (bgColor != null) {
        sb.append("background-color:").append(bgColor).append(";");
View Full Code Here


  private boolean processBottomBorder(StringBuffer sb) {

    boolean hitBottom = false;

    if (_cell != null) {
      Format format = _cell.getFormat();
      if (format != null){
        BorderStyle bb = format.getBorderBottom();
        if (bb != null) {
          hitBottom = appendBorderStyle(sb, "bottom", bb);
        }
      }
    }
    Cell next = null;
    if (!hitBottom) {
      next = _sheet.getCell(_row + 1, _col);
      /*if(next == null){ // don't search into merge ranges
        //check is _row+1,_col in merge range
        MergedRect rect = _mmHelper.getMergeRange(_row+1, _col);
        if(rect !=null){
          next = _sheet.getCell(rect.getTop(),rect.getLeft());
        }
      }*/
      if (next != null) {
        Format format = next.getFormat();
        if (format != null){
          BorderStyle bb = format.getBorderTop();// get top border of
          if (bb != null) {
            // set next row top border as cell's bottom border;
            hitBottom = appendBorderStyle(sb, "bottom", bb);
          }
        }
      }
    }
   
    //border depends on next cell's background color
    if(!hitBottom && next !=null){
      Format format = next.getFormat();
      if (format != null){
        String bgColor = format.getFillColor();
        if (AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
        if (bgColor != null && !bgColor.toUpperCase().endsWith("FFFFFF")) {
          BorderStyle bb = new BorderStyleImpl(bgColor,BorderLineStyle.THIN);
          hitBottom = appendBorderStyle(sb, "bottom", bb);
        }
      }
    }
   
    //border depends on current cell's background color
    if(!hitBottom && _cell !=null){
      Format format = _cell.getFormat();
      if (format != null){
        String bgColor = format.getFillColor();
        if (AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
        if (bgColor != null && !bgColor.toUpperCase().endsWith("FFFFFF")) {
          BorderStyle bb = new BorderStyleImpl(bgColor,BorderLineStyle.THIN);
View Full Code Here

      rect = _mmHelper.getMergeRange(_row, _col);
      if(rect!=null){
        hitMerge = true;
        right = _sheet.getCell(_row,rect.getRight());
      }
      Format format = right.getFormat();
      if (format != null){
        BorderStyle bb = format.getBorderRight();
        if (bb != null) {
          hitRight = appendBorderStyle(sb, "right", bb);
        }
      }
    }

    Cell next = null;
    //if no border for target cell,then check is this cell in a merge range
    //if(true) then try to get next cell after this merge range
    //else get next cell of this cell
    if(!hitRight){
      int c = hitMerge?rect.getRight()+1:_col+1;
      next = _sheet.getCell(_row,c);
      //find the right cell of merge range.
      if(next!=null){
        Format format = next.getFormat();
        if (format != null){
          BorderStyle bb = format.getBorderLeft();//get left here
          if (bb != null) {
            hitRight = appendBorderStyle(sb, "right", bb);
          }
        }
      }
    }

    //border depends on next cell's background color
    if(!hitRight && next !=null){
      Format format = next.getFormat();
      if (format != null){
        String bgColor = format.getFillColor();
        if (AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
        if (bgColor != null && !bgColor.toUpperCase().endsWith("FFFFFF")) {
          BorderStyle bb = new BorderStyleImpl(bgColor,BorderLineStyle.THIN);
          hitRight = appendBorderStyle(sb, "right", bb);
        }
      }
    }
    //border depends on current cell's background color
    if(!hitRight && _cell !=null){
      Format format = _cell.getFormat();
      if (format != null){
        String bgColor = format.getFillColor();
        if (AUTO_COLOR.equals(bgColor)) {
          bgColor = null;
        }
        if (bgColor != null && !bgColor.toUpperCase().endsWith("FFFFFF")) {
          BorderStyle bb = new BorderStyleImpl(bgColor,BorderLineStyle.THIN);
View Full Code Here

  public String getInnerHtmlStyle() {
    StringBuffer sb = new StringBuffer();

    if (_cell != null) {

      Format format = _cell.getFormat();
      if (format == null)
        return "";

      String fontName = format.getFontType();
      if (fontName != null) {
        sb.append("font-family:").append(fontName).append(";");
      }

      TextHAlign textHAlign = _cell.getTextHAlign();
      if (textHAlign != null) {
        if (textHAlign.equals(TextHAlign.RIGHT)) {
          sb.append("text-align:").append("right").append(";");
        } else if (textHAlign.equals(TextHAlign.CENTER)) {
          sb.append("text-align:").append("center").append(";");
        }
      }

      boolean textWrap = format.isTextWrap();
      if (textWrap) {
        sb.append("white-space:").append("normal").append(";");
      }/*else{ sb.append("white-space:").append("nowrap").append(";"); }*/

      String textColor = _cell.getTextColor();
      if (AUTO_COLOR.equals(textColor)) {
        textColor = "#000000";
      }
      if (textColor != null) {
        sb.append("color:").append(textColor).append(";");
      }

      FontUnderline fontUnderline = format.getFontUnderline();
      boolean striketThrough = format.isFontStrikethrough();
      if (!striketThrough && fontUnderline != null) {
        if (fontUnderline.equals(FontUnderline.SINGLE) || fontUnderline.equals(FontUnderline.SINGLEA)) {
          sb.append("text-decoration:").append("underline;");
        } else if (fontUnderline.equals(FontUnderline.DOUBLE) || fontUnderline.equals(FontUnderline.DOUBLEA)) {

        }
      }

      if (striketThrough) {
        sb.append("text-decoration:").append("line-through;");
      }

      FontStyle fontStyle = format.getFontStyle();
      if (fontStyle != null) {
        if (fontStyle.equals(FontStyle.BOLDITALIC)) {
          sb.append("font-weight:").append("bold;");
          sb.append("font-style:").append("italic;");
        } else if (fontStyle.equals(FontStyle.ITALIC)) {
          sb.append("font-style:").append("italic;");
        } else if (fontStyle.equals(FontStyle.BOLD)) {
          sb.append("font-weight:").append("bold;");
        }
      }

      int fontSize = format.getFontSize();
      sb.append("font-size:").append(fontSize).append("pt;");

    }

    return sb.toString();
View Full Code Here

   
    Cell cell = sheet.getCell(row, col);
   
    if (cell != null) {

      Format format = cell.getFormat();
      boolean wrap = false;
     
      CellFormatHelper cfh = new CellFormatHelper(sheet,row,col,_mergeMatrix);
      String st = cfh.getHtmlStyle();
      String ist = cfh.getInnerHtmlStyle();
      if (st != null && !"".equals(st)){
        jcell.setData("st", st);// style of text cell.
      }
      if (ist != null && !"".equals(ist)){
        jcell.setData("ist", ist);// inner style of text cell
      }
      if (format!=null && format.isTextWrap()){
        wrap = format.isTextWrap();
        jcell.setData("wrap", true);//warp
      }
      if (cfh.hasRightBorder()){
        jcell.setData("rbo",true);//right border, when processing text overflow, must take care this.
      }
View Full Code Here

*/
public class Styles {
  private static final Log log = Log.lookup(Utils.class);
 
  private static Format cloneCellFormat(Cell cell){
    Format format = cell.getFormat();
    if(format==null){
      format = new FormatImpl();
    }else if((format instanceof FormatImpl)){
      try {
        format = (FormatImpl)((FormatImpl)format).clone();
      } catch (CloneNotSupportedException e) {
        log.warning(e);
      }
    }else{
      log.warning("not "+FormatImpl.class +":"+format.getClass());
    }
    return format;
  }
View Full Code Here

  }
 
  public static void setFontColor(Sheet sheet,int row,int col,String color){
    Cell cell = Utils.getCell(sheet,row,col);
    if(cell!=null){
      Format format = cloneCellFormat(cell);
      if(format instanceof FormatImpl){
        ((FormatImpl)format).setFontColor(color);
        cell.setFormat(format);
      }
    }
View Full Code Here

  }
 
  public static void setFillColor(Sheet sheet,int row,int col,String color){
    Cell cell = Utils.getCell(sheet,row,col);
    if(cell!=null){
      Format format = cloneCellFormat(cell);
      if(format instanceof FormatImpl){
        ((FormatImpl)format).setFillColor(color);
        cell.setFormat(format);
      }
    }
View Full Code Here

  }
 
  public static void setTextWrap(Sheet sheet,int row,int col,boolean wrap){
    Cell cell = Utils.getCell(sheet,row,col);
    if(cell!=null){
      Format format = cloneCellFormat(cell);
      if(format instanceof FormatImpl){
        ((FormatImpl)format).setTextWrap(wrap);
        cell.setFormat(format);
      }
    }
View Full Code Here

  }
 
  public static void setFontSize(Sheet sheet,int row,int col,int size){
    Cell cell = Utils.getCell(sheet,row,col);
    if(cell!=null){
      Format format = cloneCellFormat(cell);
      if(format instanceof FormatImpl){
        ((FormatImpl)format).setFontSize(size);
        cell.setFormat(format);
      }
    }
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.