diff --git a/src/global/getRowlen.js b/src/global/getRowlen.js index becd850..81760d2 100644 --- a/src/global/getRowlen.js +++ b/src/global/getRowlen.js @@ -19,7 +19,7 @@ function rowlenByRange(d, r1, r2, cfg) { let canvas = $("#luckysheetTableContent").get(0).getContext("2d"); canvas.textBaseline = 'top'; //textBaseline以top计算 - + for(let r = r1; r <= r2; r++){ if (cfg_clone["rowhidden"] != null && cfg_clone["rowhidden"][r] != null) { continue; @@ -50,7 +50,7 @@ function rowlenByRange(d, r1, r2, cfg) { }); let computeRowlen = 0; - + if(textInfo!=null){ computeRowlen = textInfo.textHeightAll+2; } @@ -63,7 +63,7 @@ function rowlenByRange(d, r1, r2, cfg) { } currentRowLen = currentRowLen/Store.zoomRatio; - + if(currentRowLen != Store.defaultrowlen){ cfg_clone["rowlen"][r] = currentRowLen; } @@ -79,7 +79,7 @@ function computeRowlenArr(rowHeight, cfg) { for (let i = 0; i < rowHeight; i++) { let rowlen = Store.defaultrowlen; - + if (cfg["rowlen"] != null && cfg["rowlen"][i] != null) { rowlen = cfg["rowlen"][i]; } @@ -92,7 +92,7 @@ function computeRowlenArr(rowHeight, cfg) { else { rh_height += rowlen + 1; } - + rowlenArr.push(rh_height);//行的临时长度分布 } @@ -147,7 +147,7 @@ function getMeasureText(value, ctx, fontset){ // cache.width = measureText.width; // } // else{ - // //measureText.actualBoundingBoxLeft + + // //measureText.actualBoundingBoxLeft + // cache.width = measureText.actualBoundingBoxRight; // } @@ -317,7 +317,7 @@ function getCellTextInfo(cell , ctx, option){ let splitArr = v.split("_x000D_"), preNewValue=null; for(let x=0;xcellHeight && textH_all_Column[colIndex]!=null){ // textW_all += textW; @@ -446,11 +446,11 @@ function getCellTextInfo(cell , ctx, option){ colIndex +=1; } } - + if(i== inlineStringArr.length-1){ textH_all_ColumnHeight.push(textH_all_cache); } - + if(textH_all_Column[colIndex]==null){ textH_all_Column[colIndex]= []; } @@ -471,36 +471,36 @@ function getCellTextInfo(cell , ctx, option){ if(shareCell.wrap===true){ item.wrap=true; } - + textH_all_Column[colIndex].push(item); console.log("normal",i,colIndex,shareCell, preShareCell, textH_all_Column); preShareCell = shareCell; - + } } - else{ - let measureText = getMeasureText(value, ctx); + else{ + let measureText = getMeasureText(value, ctx); let textHeight = measureText.actualBoundingBoxDescent + measureText.actualBoundingBoxAscent; value = value.toString(); - + let vArr = []; if(value.length > 1){ - vArr = value.split(""); + vArr = value.split(""); } else{ vArr.push(value); } let oneWordWidth = getMeasureText(vArr[0], ctx).width; - + for(let i = 0; i < vArr.length; i++){ let textW = oneWordWidth + space_width; let textH = textHeight + space_height; - + // textW_all += textW; textH_all_cache += textH; - - + + if(tb=="2"){ if(textH_all_cache>cellHeight && textH_all_Column[colIndex]!=null){ // textW_all += textW; @@ -510,15 +510,15 @@ function getCellTextInfo(cell , ctx, option){ colIndex +=1; } } - + if(i== vArr.length-1){ textH_all_ColumnHeight.push(textH_all_cache); } - + if(textH_all_Column[colIndex]==null){ textH_all_Column[colIndex]= []; } - + textH_all_Column[colIndex].push({ content:vArr[i], style:fontset, @@ -530,7 +530,7 @@ function getCellTextInfo(cell , ctx, option){ asc:measureText.actualBoundingBoxAscent, desc:measureText.actualBoundingBoxDescent }); - + } } @@ -555,7 +555,7 @@ function getCellTextInfo(cell , ctx, option){ // console.log("verticalWrap", textContent,cell, option); return textContent; } - + let cumColumnWidth = 0; for(let i = 0; i < textH_all_ColumnHeight.length; i++){ let columnHeight = textH_all_ColumnHeight[i]; @@ -565,7 +565,7 @@ function getCellTextInfo(cell , ctx, option){ let cumWordHeight = 0; for(let c=0;c1){ for(let s=0;scellHeight); @@ -721,7 +721,7 @@ function getCellTextInfo(cell , ctx, option){ // console.log("cut",anchor, i , str); if(spaceOrTwoByteIndex!=null && spaceOrTwoByteIndexcellWidth && text_all_split[splitIndex]!=null && tb=="2" && i!= inlineStringArr.length){ - + if(spaceOrTwoByteIndex!=null && spaceOrTwoByteIndexcellWidth && text_all_split[splitIndex]!=null && i!= value.length){ // console.log(spaceOrTwoByte, i, anchor); if(spaceOrTwoByte!=null && spaceOrTwoByte.index=0;c--){ let wordGroup = splitLists[c]; let left, top; @@ -1192,7 +1213,7 @@ function getCellTextInfo(cell , ctx, option){ if(horizonAlign == "0"){//center let sh = textH_all/Math.sin(rtPI); if(verticalAlign == "0"){//mid - + left = x + cellWidth/2 - (textW_all/2) + lastLineSpaceHeight*Math.cos(rtPI)/2; top = y + cellHeight/2 - textH_all/2 - lastLineSpaceHeight*Math.cos(rtPI)/2; } @@ -1233,17 +1254,17 @@ function getCellTextInfo(cell , ctx, option){ top = y + cellHeight - rw*Math.sin(rtPI) - lastLineSpaceHeight*Math.cos(rtPI); } } - + } - + wordGroup.left = left; wordGroup.top = top; // console.log(left, top, cumWordHeight, size.height); drawLineInfo(wordGroup, cancelLine, underLine,{ - width:wordGroup.width, - height:wordGroup.height, + width:wordGroup.width, + height:wordGroup.height, left:left-wordGroup.width, top:top, asc:size.asc, @@ -1271,7 +1292,7 @@ function getCellTextInfo(cell , ctx, option){ let size = split_all_size[i]; cumColumnWidth = 0; - + for(let c=0;c