Browse Source

refactor(inline string): develop

master
liuyang 5 years ago
parent
commit
74d6ec8507
  1. 65
      src/controllers/rowColumnOperation.js
  2. 2
      src/global/draw.js
  3. 16
      src/global/getRowlen.js

65
src/controllers/rowColumnOperation.js

@ -32,7 +32,7 @@ import { getcellvalue } from '../global/getdata';
import tooltip from '../global/tooltip';
import editor from '../global/editor';
import locale from '../locale/locale';
import {getMeasureText} from '../global/getRowlen';
import {getMeasureText,getCellTextInfo} from '../global/getRowlen';
import { luckysheet_searcharray } from '../controllers/sheetSearch';
import Store from '../store';
@ -1711,24 +1711,39 @@ function luckysheetcolsdbclick() {
for(let r = dataset_row_st; r <= dataset_row_ed; r++){
let cell = d[r][colIndex];
if(cell == null || isRealNull(cell.v)){
if(cell == null || (isRealNull(cell.v) && !(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0)) ){
continue;
}
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;
// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;
let value = getcellvalue(r, colIndex, d, "m").toString(); //单元格文本
let textMetrics = getMeasureText(value, canvas).width; //文本宽度
// let value = getcellvalue(r, colIndex, d, "m").toString(); //单元格文本
// let textMetrics = getMeasureText(value, canvas).width; //文本宽度
let cellWidth = colLocationByIndex(colIndex)[1] - colLocationByIndex(colIndex)[0] - 2;
let textInfo = getCellTextInfo(cell, canvas,{
r:r,
c:colIndex,
cellWidth:cellWidth
});
let computeRowlen = 0;
// console.log("rowlen", textInfo);
if(textInfo!=null){
computeRowlen = textInfo.textWidthAll;
}
if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
if(computeRowlen + 6 > currentColLen){
currentColLen = computeRowlen + 6;
}
}
if(currentColLen != Store.defaultcollen){
cfg["columnlen"][colIndex] = currentColLen;
if(cfg["customWidth"]){
delete cfg["customWidth"][colIndex];
}
}
matchColumn[colIndex] = 1;
@ -1744,24 +1759,44 @@ function luckysheetcolsdbclick() {
for(let r = dataset_row_st; r <= dataset_row_ed; r++){
let cell = d[r][c];
if(cell == null || isRealNull(cell.v)){
if(cell == null || (isRealNull(cell.v) && !(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0)) ){
continue;
}
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;
// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;
// let value = getcellvalue(r, c, d, "m").toString(); //单元格文本
// let textMetrics = getMeasureText(value, canvas).width; //文本宽度
let value = getcellvalue(r, c, d, "m").toString(); //单元格文本
let textMetrics = getMeasureText(value, canvas).width; //文本宽度
// if(textMetrics + 6 > currentColLen){
// currentColLen = textMetrics + 6;
// }
if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
let cellWidth = colLocationByIndex(c)[1] - colLocationByIndex(c)[0] - 2;
let textInfo = getCellTextInfo(cell, canvas,{
r:r,
c:c,
cellWidth:cellWidth
});
let computeRowlen = 0;
// console.log("rowlen", textInfo);
if(textInfo!=null){
computeRowlen = textInfo.textWidthAll;
}
if(computeRowlen + 6 > currentColLen){
currentColLen = computeRowlen + 6;
}
}
if(currentColLen != Store.defaultcollen){
cfg["columnlen"][c] = currentColLen;
if(cfg["customWidth"]){
delete cfg["customWidth"][c];
}
}
matchColumn[c] = 1;

2
src/global/draw.js

@ -1801,7 +1801,7 @@ function getCellOverflowMap(canvas, col_st, col_ed, row_st, row_end){
continue
}
if(cell != null && !isRealNull(cell.v) && cell.mc == null && cell.tb == '1'){
if(cell != null && (!isRealNull(cell.v) || (cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0) ) && cell.mc == null && cell.tb == '1'){
// let fontset = luckysheetfontformat(cell);
// canvas.font = fontset;

16
src/global/getRowlen.js

@ -423,11 +423,13 @@ function getCellTextInfo(cell , ctx, option){
showValue = "";
if(!(preShareCell==null || preShareCell.wrap==true || (i==inlineStringArr.length-1))){
console.log("wrap",i,shareCell, preShareCell);
if( preShareCell!=null && preShareCell.wrap!==true && (i<inlineStringArr.length-1)){
// console.log("wrap",i,colIndex,preShareCell.wrap);
textH_all_ColumnHeight.push(textH_all_cache);
textH_all_cache = 0;
colIndex +=1;
preShareCell = shareCell;
continue;
}
}
@ -445,7 +447,7 @@ function getCellTextInfo(cell , ctx, option){
if(textH_all_cache>cellHeight && textH_all_Column[colIndex]!=null){
// textW_all += textW;
// textH_all = Math.max(textH_all,textH_all_cache);
console.log(">",i,shareCell, preShareCell);
// console.log(">",i,colIndex);
textH_all_ColumnHeight.push(textH_all_cache-textH);
textH_all_cache = textH;
colIndex +=1;
@ -478,7 +480,7 @@ function getCellTextInfo(cell , ctx, option){
}
textH_all_Column[colIndex].push(item);
console.log("normal",i,colIndex,shareCell, preShareCell, textH_all_Column);
preShareCell = shareCell;
}
@ -596,9 +598,9 @@ function getCellTextInfo(cell , ctx, option){
width:columnWidth,
height:word.height,
left:left,
top:top+word.height/2,
asc:word.asc,
desc:word.desc
top:top+word.height-space_height,
asc:word.height,
desc:0
});
textContent.values.push(word);

Loading…
Cancel
Save