From 40550d6e59c44e0f47e23f8b5fac4c5e79a5c122 Mon Sep 17 00:00:00 2001 From: liuyang <qwbfsa@gmail.com> Date: Tue, 8 Sep 2020 15:34:04 +0800 Subject: [PATCH] fix(render): render --- src/global/draw.js | 4 ++-- src/global/getRowlen.js | 43 ++++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/global/draw.js b/src/global/draw.js index dba093af8..3dc866e45 100644 --- a/src/global/draw.js +++ b/src/global/draw.js @@ -1178,7 +1178,7 @@ let nullCellRender = function(r, c, start_r, start_c, end_r, end_c,luckysheetTab } -let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05,isMerge){ +let cellRender1 = function(r, c, start_r, start_c, end_r, end_c, value, luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05,isMerge){ let cell = Store.flowdata[r][c]; let cellWidth = end_c - start_c - 2; @@ -1600,7 +1600,7 @@ let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckyshee } //非空白单元格渲染 -let cellRender1 = function(r, c, start_r, start_c, end_r, end_c, value, luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05,isMerge){ +let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, luckysheetTableContent,af_compute, cf_compute,offsetLeft,offsetTop,dynamicArray_compute,cellOverflowMap, dataset_col_st, dataset_col_ed,scrollHeight,scrollWidth,bodrder05,isMerge){ let cell = Store.flowdata[r][c]; let cellWidth = end_c - start_c - 2; diff --git a/src/global/getRowlen.js b/src/global/getRowlen.js index e2753f510..8e54887d9 100644 --- a/src/global/getRowlen.js +++ b/src/global/getRowlen.js @@ -433,7 +433,7 @@ function getCellTextInfo(cell , ctx, option){ text_all_split[splitIndex]= []; } - if(rt!=0){ + if(rt!=0){//rotate if(height>cellHeight){ anchor = i-1; @@ -462,7 +462,7 @@ function getCellTextInfo(cell , ctx, option){ }); } } - else{ + else{//plain if(width>cellWidth){ anchor = i-1; @@ -499,22 +499,27 @@ function getCellTextInfo(cell , ctx, option){ } - // 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 split_all_size = []; + for(let i = 0; i <= splitIndex; i++){ + let splitLists = text_all_split[i]; + let sWidth = 0, sHeight=0; + for(let s=0;s<splitLists.length;s++){ + let sp = splitLists[i]; + if(rt!=0){//rotate + sWidth += sp.width; + sHeight += sp.height; + } + else{//plain + sWidth += sp.width; + sHeight = Math.max(sHeight, sp.height); + } + } + + split_all_size.push({ + width:sWidth, + height:sHeight + }); + } let cumColumnWidth = 0; for(let i = 0; i < text_all_split.length; i++){ @@ -524,6 +529,8 @@ function getCellTextInfo(cell , ctx, option){ for(let c=0;c<splitTexts.length;c++){ let wordGroup = splitTexts[c]; + + let left = space_width + cumColumnWidth; if(horizonAlign == "0"){ left = cellWidth / 2 + cumColumnWidth - textW_all/2 + space_width*textH_all_ColumnHeight.length;