Package org.zkoss.zss.ui.impl

Examples of org.zkoss.zss.ui.impl.MergeMatrixHelper


    }
   
   
    private StringBuffer appendMergeSClass(StringBuffer sb, int row, int col) {
      Sheet sheet = getSelectedSheet();
      MergeMatrixHelper mmhelper = getMergeMatrixHelper(sheet);
      //Cell cell = sheet.getCell(row,col);
      //if(cell!=null){
        boolean islefttop = mmhelper.isMergeRangeLeftTop(row, col);
        MergedRect block;
       
        if(islefttop){
          //System.out.println("1>>>>>"+row+","+col+">>zsmerge");
          block = mmhelper.getMergeRange(row, col);
          sb.append(" zsmerge").append(block.getId());
        }else if((block = mmhelper.getMergeRange(row, col)) != null){
          //System.out.println("2>>>>>"+row+","+col+">>zsmergee");
          sb.append(" zsmergee");
        }else{
          //System.out.println("3>>>>>"+row+","+col);
        }
View Full Code Here


    }
   
    public String getCellOuterAttrs(int row,int col){
      StringBuffer sb = new StringBuffer();
      Sheet sheet = getSelectedSheet();
      MergeMatrixHelper matrix = getMergeMatrixHelper(sheet);
      HeaderPositionHelper rowHelper = Spreadsheet.this.getRowPositionHelper(sheet);
      HeaderPositionHelper colHelper = Spreadsheet.this.getColumnPositionHelper(sheet);
      Cell cell = sheet.getCell(row,col);
     
     
      //class="zscell zscw${cstatus.index} zsrhi${rstatus.index} ${s:getCellSClass(self,rstatus.index,cstatus.index)}"
      sb.append("class=\"zscell");
      int zsh = -1;
      int zsw = -1;
      int[] meta = colHelper.getMeta(col);
      if(meta!=null){
        zsw = meta[2];
        sb.append(" zsw").append(zsw);
      }
      meta = rowHelper.getMeta(row);
      if(meta!=null){
        zsh = meta[2];
        sb.append(" zshi").append(zsh);
      }
      appendMergeSClass(sb,row,col);
      sb.append("\" ");
     
     
     
      CellFormatHelper cfh = new CellFormatHelper(sheet,row,col,getMergeMatrixHelper(sheet));
      HTMLs.appendAttribute(sb, "style", cfh.getHtmlStyle());
     
      HTMLs.appendAttribute(sb, "z.r",row);
      HTMLs.appendAttribute(sb, "z.c", col);
      if(zsw>=0){
        HTMLs.appendAttribute(sb, "z.zsw",zsw);
      }
      if(zsh>=0){
        HTMLs.appendAttribute(sb, "z.zsh",zsh);
      }
       
     
      if(cell!=null){
        Format format = cell.getFormat();
        if(format != null && format.isTextWrap()){
          HTMLs.appendAttribute(sb, "z.wrap", "t");
        }
       
        TextHAlign textHAlign = cell.getTextHAlign();
        if (textHAlign != null) {
          if (textHAlign.equals(TextHAlign.RIGHT)) {
            HTMLs.appendAttribute(sb, "z.hal", "r");
          } else if (textHAlign.equals(TextHAlign.CENTER)) {
            HTMLs.appendAttribute(sb, "z.hal", "c");
          }
        }
       
        if (cfh.hasRightBorder()){
          HTMLs.appendAttribute(sb, "z.rbo", "t");
        }
      }
     
      MergedRect block;
      if((block = matrix.getMergeRange(row, col)) != null){
        HTMLs.appendAttribute(sb, "z.merr",block.getRight());
        HTMLs.appendAttribute(sb, "z.merid",block.getId());
        HTMLs.appendAttribute(sb, "z.merl", block.getLeft());
      }
     
View Full Code Here

      bottom = top;
      updateCell(sheet,_loadedRect.getLeft(),top,_loadedRect.getRight(),bottom);
    }
   
    private void removeAffectedMergeRange(Sheet sheet,int type, int index) {
      MergeMatrixHelper mmhelper = this.getMergeMatrixHelper(sheet);
      List toremove = new ArrayList();
      if(type==0){//column
        mmhelper.deleteAffectedMergeRangeByColumn(index,toremove);
      }else if(type==1){
        mmhelper.deleteAffectedMergeRangeByRow(index,toremove);
      }else{
        return;
      }
      for(Iterator iter = toremove.iterator();iter.hasNext();){
        MergedRect block = (MergedRect)iter.next();
View Full Code Here

      deleteMergeCell(sheet,oleft,otop,oright,obottom);
      addMergeCell(sheet, left, top, right, bottom);
    }
   
    public void deleteMergeCell(Sheet sheet,int left,int top,int right,int bottom){
      MergeMatrixHelper mmhelper = this.getMergeMatrixHelper(sheet);
      List torem = new ArrayList();
      mmhelper.deleteMergeRange(left,top,right,bottom,torem);
      for(Iterator iter = torem.iterator();iter.hasNext();){
        MergedRect rect = (MergedRect)iter.next();
        log.debug("(R)remove merge:"+rect);
        updateMergeCell0(sheet,rect,"remove");
      }
View Full Code Here

     
      smartUpdateValues("merge_"+Utils.nextUpdateId(),new Object[]{"",Utils.getId(sheet),result.toString()});
    }
   
    public void addMergeCell(Sheet sheet,int left,int top,int right,int bottom){
      MergeMatrixHelper mmhelper = this.getMergeMatrixHelper(sheet);
     
      List toadd = new ArrayList();
      List torem = new ArrayList();
      mmhelper.addMergeRange(left,top,right,bottom,toadd,torem);
      for(Iterator iter = torem.iterator();iter.hasNext();){
        MergedRect rect = (MergedRect)iter.next();
        log.debug("(A)remove merge:"+rect);
        updateMergeCell0(sheet,rect,"remove");
      }
View Full Code Here

   
    int row_top = getRowBegin(ss).intValue();
    int row_bottom = getRowEnd(ss).intValue();
   
    Sheet sheet = ss.getSelectedSheet();
    MergeMatrixHelper mmhelper = ((SpreadsheetCtrl)ss.getExtraCtrl()).getMergeMatrixHelper(sheet);
    List blocks = mmhelper.getRangesByColumn(max);
    Iterator iter = blocks.iterator();
    while(iter.hasNext()){
      Rect rect = (Rect)iter.next();
      int top = rect.getTop();
      //int left = rect.getLeft();
View Full Code Here

    HTMLs.appendAttribute(sb, "z.csr", getSizeHelperStr(rowHelper));
   
    //generate merge range information
   
    MergeMatrixHelper mmhelper = getMergeMatrixHelper(sheet);
    Iterator iter = mmhelper.getRanges().iterator();
    StringBuffer merr = new StringBuffer();
    while(iter.hasNext()){
      MergedRect block = (MergedRect)iter.next();
      int left = block.getLeft();
      int top = block.getTop();
View Full Code Here

  }
 
 
  private MergeMatrixHelper getMergeMatrixHelper(Sheet sheet){
    if(sheet != getSelectedSheet()) throw new UiException("not current selected sheet ");
    MergeMatrixHelper mmhelper = (MergeMatrixHelper)getAttribute(MERGE_MATRIX_KEY);
    int fzr = getRowfreeze();
    int fzc = getColumnfreeze();
    if(mmhelper==null){
      mmhelper = new MergeMatrixHelper(sheet.getMergeRanges(),fzr,fzc);
      setAttribute(MERGE_MATRIX_KEY, mmhelper);
    }else{
      mmhelper.update(fzr, fzc);
    }
    return mmhelper;
  }
View Full Code Here

   
    Sheet sheet = getSelectedSheet();

    HeaderPositionHelper colHelper = this.getColumnPositionHelper(sheet);
    HeaderPositionHelper rowHelper = this.getRowPositionHelper(sheet);
    MergeMatrixHelper mmhelper = this.getMergeMatrixHelper(sheet);
   
   
    boolean hiderow = isHiderowhead();
    boolean hidecol = isHidecolumnhead();
   
    int th = hidecol?1:this.getTopheadheight();
    int lw = hiderow?1:this.getLeftheadwidth();
    int cp = this._cellpadding;//
    int rh = this.getRowheight();
    int cw = this.getColumnwidth();
    int lh = 20;// default line height;
   
    if(lh>rh){
      lh = rh;
    }
   
    String sheetid = getUuid();
    String name ="#"+sheetid;
   
    int cellwidth;//default
    int cellheight;//default
    Execution exe = Executions.getCurrent();
   
    boolean isGecko = exe.isGecko();
    boolean isIE = exe.isExplorer();
    //boolean isIE7 = exe.isExplorer7();
   
    if(isGecko){//firefox
      cellwidth = cw;
      cellheight = rh;
    }else {
      cellwidth = cw - 2*cp - 1;// 1 is border width
      cellheight = rh - 1;// 1 is border width
    }
   
    int celltextwidth =cw - 2*cp - 1;// 1 is border width
   
    StringBuffer sb = new StringBuffer();
   
    //zcss.setRule(name+" .zsdata",["padding-top","padding-left"],[th+"px",lw+"px"],true,sid);
    sb.append(name).append(" .zsdata{\n");
    sb.append("padding-top:").append(th).append("px;\n");
    sb.append("padding-left:").append(lw).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zsrow","height",rh+"px",true,sid);
    sb.append(name).append(" .zsrow{\n");
    sb.append("height:").append(rh).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zscell",["padding","height","width","line-height"],["0px "+cp+"px 0px "+cp+"px",cellheight+"px",cellwidth+"px",lh+"px"],true,sid);   
    sb.append(name).append(" .zscell{\n");
    sb.append("padding:").append("0px "+cp+"px 0px "+cp+"px;\n");
    sb.append("height:").append(cellheight).append("px;\n");
    sb.append("width:").append(cellwidth).append("px;\n");
    //sb.append("line-height:").append(lh).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zscelltxt",["width","height"],[celltextwidth+"px",cellheight+"px"],true,sid);
    sb.append(name).append(" .zscelltxt{\n");
    sb.append("width:").append(celltextwidth).append("px;\n");
    sb.append("height:").append(cellheight).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zstop",["left","height","line-height"],[lw+"px",(th-2)+"px",lh+"px"],true,sid);
   
    int toph = th-1;
    int topheadh = (isGecko)?toph:toph-1;
    int cornertoph = th-1;
    //int topblocktop = toph;
    int fzr = getRowfreeze();
    int fzc = getColumnfreeze();
   
    if(fzr>-1){
      toph = toph + rowHelper.getStartPixel(fzr+1);
    }
   
    sb.append(name).append(" .zstop{\n");
    sb.append("left:").append(lw).append("px;\n");
    sb.append("height:").append(fzr>-1?toph-1:toph).append("px;\n");
    //sb.append("line-height:").append(toph).append("px;\n");
    sb.append("}\n");
   
   
    sb.append(name).append(" .zstopi{\n");
    sb.append("height:").append(toph).append("px;\n");
    sb.append("}\n");
   
    sb.append(name).append(" .zstophead{\n");
    sb.append("height:").append(topheadh).append("px;\n");
    sb.append("}\n");
   
    sb.append(name).append(" .zscornertop{\n");
    sb.append("left:").append(lw).append("px;\n");
    sb.append("height:").append(cornertoph).append("px;\n");
    sb.append("}\n");
   
   
    //relative, so needn't set top position.
    /*sb.append(name).append(" .zstopblock{\n");
    sb.append("top:").append(topblocktop).append("px;\n");
    sb.append("}\n");*/
   
   
   
    //zcss.setRule(name+" .zstopcell",["padding","height","width","line-height"],["0px "+cp+"px 0px "+cp+"px",th+"px",cellwidth+"px",lh+"px"],true,sid);
    sb.append(name).append(" .zstopcell{\n");
    sb.append("padding:").append("0px "+cp+"px 0px "+cp+"px;\n");
    sb.append("height:").append(topheadh).append("px;\n");
    sb.append("width:").append(cellwidth).append("px;\n");
    sb.append("line-height:").append(topheadh).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zstopcelltxt","width", celltextwidth +"px",true,sid);
    sb.append(name).append(" .zstopcelltxt{\n");
    sb.append("width:").append(celltextwidth).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zsleft",["top","width"],[th+"px",(lw-2)+"px"],true,sid);
   
   
    int leftw = lw-1;
    int leftheadw = leftw;
    int leftblockleft = leftw;
   
    if(fzc>-1){
      leftw = leftw + colHelper.getStartPixel(fzc+1);
    }
   
    sb.append(name).append(" .zsleft{\n");
    sb.append("top:").append(th).append("px;\n");
    sb.append("width:").append(fzc>-1?leftw-1:leftw).append("px;\n");
    sb.append("}\n");
   
   
    sb.append(name).append(" .zslefti{\n");
    sb.append("width:").append(leftw).append("px;\n");
    sb.append("}\n");
   
   
    sb.append(name).append(" .zslefthead{\n");
    sb.append("width:").append(leftheadw).append("px;\n");
    sb.append("}\n");
   
    sb.append(name).append(" .zsleftblock{\n");
    sb.append("left:").append(leftblockleft).append("px;\n");
    sb.append("}\n");
   
    sb.append(name).append(" .zscornerleft{\n");
    sb.append("top:").append(th).append("px;\n");
    sb.append("width:").append(leftheadw).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zsleftcell",["height","line-height"],[(rh-1)+"px",(rh)+"px"],true,sid);//for middle the text, i use row leight instead of lh
    sb.append(name).append(" .zsleftcell{\n");
    sb.append("height:").append(rh-1).append("px;\n");
    sb.append("line-height:").append(rh-1).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zscorner",["width","height"],[(lw-2)+"px",(th-2)+"px"],true,sid);
   
   
    sb.append(name).append(" .zscorner{\n");
    sb.append("width:").append(fzc>-1?leftw:leftw+1).append("px;\n");
    sb.append("height:").append(fzr>-1?toph:toph+1).append("px;\n");
    sb.append("}\n");
   
    sb.append(name).append(" .zscorneri{\n");
    sb.append("width:").append(lw-2).append("px;\n");
    sb.append("height:").append(th-2).append("px;\n");
    sb.append("}\n");
   
    sb.append(name).append(" .zscornerblock{\n");
    sb.append("left:").append(lw).append("px;\n");
    sb.append("top:").append(th).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zshboun","height",th+"px",true,sid);
    sb.append(name).append(" .zshboun{\n");
    sb.append("height:").append(th).append("px;\n");
    sb.append("}\n");
   
   
   
    //zcss.setRule(name+" .zshboun","height",th+"px",true,sid);
    sb.append(name).append(" .zshboun{\n");
    sb.append("height:").append(th).append("px;\n");
    sb.append("}\n");
   
    //zcss.setRule(name+" .zshbouni","height",th+"px",true,sid);
    sb.append(name).append(" .zshbouni{\n");
    sb.append("height:").append(th).append("px;\n");
    sb.append("}\n");
   
   
    sb.append(name).append(" .zsfztop{\n");
    sb.append("border-bottom-style:").append(fzr>-1?"solid":"none").append(";");
    sb.append("}\n");
    sb.append(name).append(" .zsfzcorner{\n");
    sb.append("border-bottom-style:").append(fzr>-1?"solid":"none").append(";");
    sb.append("}\n");
   
    sb.append(name).append(" .zsfzleft{\n");
    sb.append("border-right-style:").append(fzc>-1?"solid":"none").append(";");
    sb.append("}\n");
    sb.append(name).append(" .zsfzcorner{\n");
    sb.append("border-right-style:").append(fzc>-1?"solid":"none").append(";");
    sb.append("}\n");
   
    //TODO transparent border mode
   
    boolean transparentBorder = false;
   
    if(transparentBorder){
      sb.append(name).append(" .zscell {");
      sb.append("border-right-color: transparent;");
      sb.append("border-bottom-color: transparent;");
      if(isIE){/**for IE6**/
        String color_to_transparent = "tomato";
        sb.append("_border-color:"+color_to_transparent+";");
        sb.append("_filter:chroma(color="+color_to_transparent+");");
      }
      sb.append("}\n");
    }
   
   
    int cs[][] = colHelper.getCostomizedSize();
    for(int i=0;i<cs.length;i++){
      int index = cs[i][0];
      int width = cs[i][1];
      int cid = cs[i][2];
     
      celltextwidth = width - 2*cp - 1;// 1 is border width
     
      //bug 1989680
      if(celltextwidth<0) celltextwidth = 0;
     
      if(!isGecko){
        cellwidth = celltextwidth;
      }else{
        cellwidth = width;
      }
     
      if(width<=0){
        sb.append(name).append(" .zsw").append(cid).append("{\n");
        sb.append("display:none;\n");
        sb.append("}\n");
       
      }else{
        sb.append(name).append(" .zsw").append(cid).append("{\n");
        sb.append("width:").append(cellwidth).append("px;\n");
        sb.append("}\n");
       
        sb.append(name).append(" .zswi").append(cid).append("{\n");
        sb.append("width:").append(celltextwidth).append("px;\n");
        sb.append("}\n");
      }
    }
   
   
    cs = rowHelper.getCostomizedSize();
    for(int i=0;i<cs.length;i++){
      int index = cs[i][0];
      int height = cs[i][1];
      int cid = cs[i][2];
      cellheight = height;
      if(!isGecko){
        cellheight = height - 1;// 1 is border width
      }
     
      if(height<=0){
       
        sb.append(name).append(" .zsh").append(cid).append("{\n");
        sb.append("display:none;");
        sb.append("}\n");
       
        sb.append(name).append(" .zslh").append(cid).append("{\n");
        sb.append("display:none;");
        sb.append("}\n");
       
       
      }else{
        sb.append(name).append(" .zsh").append(cid).append("{\n");
        sb.append("height:").append(height).append("px;");
        sb.append("}\n");
       
        sb.append(name).append(" .zshi").append(cid).append("{\n");
        sb.append("height:").append(cellheight).append("px;");
        sb.append("}\n");
       
        int h2 = (height<1)?0:height-1;
       
        sb.append(name).append(" .zslh").append(cid).append("{\n");
        sb.append("height:").append(h2).append("px;");
        sb.append("line-height:").append(h2).append("px;");
        sb.append("}\n");
       
      }
    }
    sb.append(".zs_header{}\n");//for indicating add new rule before this
   
    //merge size;
    List ranges = mmhelper.getRanges();
    Iterator iter = ranges.iterator();

    while(iter.hasNext()){
      MergedRect block = (MergedRect)iter.next();
      int left = block.getLeft();
View Full Code Here

      deleteMergeCell(sheet, oleft, otop, oright, obottom);
      addMergeCell(sheet, left, top, right, bottom);
    }

    public void deleteMergeCell(Worksheet sheet, int left, int top, int right, int bottom) {
      MergeMatrixHelper mmhelper = this.getMergeMatrixHelper(sheet);
      Set torem = new HashSet();
      mmhelper.deleteMergeRange(left, top, right, bottom, torem);
      for (Iterator iter = torem.iterator(); iter.hasNext();) {
        MergedRect rect = (MergedRect) iter.next();

        updateMergeCell0(sheet, rect, "remove");
      }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.ui.impl.MergeMatrixHelper

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.