Browse Source

refactor(iniline): inline

master
wbfsa 5 years ago
parent
commit
2e40d1f14d
  1. 122
      src/global/getRowlen.js

122
src/global/getRowlen.js

@ -416,91 +416,113 @@ function getCellTextInfo(cell , ctx, option){
textContent.rotate = rt; textContent.rotate = rt;
rt = Math.abs(rt); rt = Math.abs(rt);
let anchor = 0; let anchor = 0, preHeight = 0, preWidth=0, preStr;
for(let i = 1; i <= value.length; i++){ for(let i = 1; i <= value.length; i++){
let str = value.substr(anchor, i); let str = value.substring(anchor, i);
let measureText = getMeasureText(str, ctx); let measureText = getMeasureText(str, ctx);
let textW = measureText.width; let textWidth = measureText.width;
let textH = measureText.actualBoundingBoxAscent+measureText.actualBoundingBoxDescent; let textHeight = measureText.actualBoundingBoxAscent+measureText.actualBoundingBoxDescent;
let width = textWidth * Math.cos(rt*Math.PI/180) + textHeight * Math.sin(rt*Math.PI/180);//consider text box wdith and line height
let height = textWidth * Math.sin(rt*Math.PI/180) + textHeight * Math.cos(rt*Math.PI/180);//consider text box wdith and line height
// textW_all += textW; // textW_all += textW;
if(text_all_split[splitIndex]==null){
text_all_split[splitIndex]= [];
}
if(rt!=0){ if(rt!=0){
text_all_cache += textH; if(height>cellHeight){
if(text_all_cache>cellHeight && text_all_split[splitIndex]!=null){ anchor = i-1;
text_all_splitLen.push(text_all_cache-textH);
text_all_cache = textH;
splitIndex +=1;
anchor = i; text_all_split[splitIndex].push({
content:preStr,
if(i== value.length){ style:fontset,
textH_all_ColumnHeight.push(textH_all_cache); width:preWidth,
} height:preHeight,
left:0,
top:0,
splitIndex:splitIndex,
});
if(textH_all_Column[colIndex]==null){ splitIndex +=1;
text_all_split[colIndex]= [];
} }
else if(i== value.length){
text_all_split[splitIndex].push({ text_all_split[splitIndex].push({
content:vArr[i], content:str,
style:fontset, style:fontset,
width:textW, width:width,
height:textH, height:height,
left:0, left:0,
top:0, top:0,
colIndex:colIndex, colIndex:splitIndex,
}); });
} }
} }
else{ else{
if(width>cellWidth){
} anchor = i-1;
if(i== vArr.length-1){ text_all_split[splitIndex].push({
textH_all_ColumnHeight.push(textH_all_cache); content:preStr,
} style:fontset,
width:preWidth,
height:preHeight,
left:0,
top:0,
splitIndex:splitIndex,
});
if(textH_all_Column[colIndex]==null){ splitIndex +=1;
text_all_split[colIndex]= [];
} }
else if(i== value.length){
text_all_split[splitIndex].push({ text_all_split[splitIndex].push({
content:vArr[i], content:str,
style:fontset, style:fontset,
width:textW, width:width,
height:textH, height:height,
left:0, left:0,
top:0, top:0,
colIndex:colIndex, colIndex:splitIndex,
}); });
} }
let textH_all_ColumWidth = [];
for(let i = 0; i < textH_all_ColumnHeight.length; i++){
let columnHeight = textH_all_ColumnHeight[i];
let col = textH_all_Column[i], colMaxW=0;
for(let c=0;c<col.length;c++){
let word = col[c];
colMaxW = Math.max(colMaxW, word.width);
} }
textH_all_ColumWidth.push(colMaxW);
textW_all += colMaxW; preWidth = width;
textH_all = Math.max(textH_all, columnHeight); preHeight = height;
preStr = str;
} }
// let textH_all_ColumWidth = [];
// for(let i = 0; i < text_all_split.length; i++){
// let splitLen = text_all_split[i];
// let col = splitLen[i], colMaxW=0;
// if(rt!=0){
// }
// for(let c=0;c<col.length;c++){
// let word = col[c];
// colMaxW = Math.max(colMaxW, word.width);
// }
// textH_all_ColumWidth.push(colMaxW);
// textW_all += colMaxW;
// textH_all = Math.max(textH_all, columnHeight);
// }
let cumColumnWidth = 0; let cumColumnWidth = 0;
for(let i = 0; i < textH_all_ColumnHeight.length; i++){ for(let i = 0; i < text_all_split.length; i++){
let columnHeight = textH_all_ColumnHeight[i]; let splitTexts = text_all_split[i];
let columnWidth = textH_all_ColumWidth[i];
let col = textH_all_Column[i];
let cumWordHeight = 0; let cumWordHeight = 0;
for(let c=0;c<col.length;c++){ for(let c=0;c<splitTexts.length;c++){
let word = col[c]; let wordGroup = splitTexts[c];
let left = space_width + cumColumnWidth; let left = space_width + cumColumnWidth;
if(horizonAlign == "0"){ if(horizonAlign == "0"){
@ -530,7 +552,7 @@ function getCellTextInfo(cell , ctx, option){
} }
textContent.type = "verticalWrap"; textContent.type = "plainWrap";
textContent.textWidthAll = textW_all; textContent.textWidthAll = textW_all;
textContent.textHeightAll = textH_all; textContent.textHeightAll = textH_all;
} }

Loading…
Cancel
Save