|
|
@ -654,6 +654,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
|
|
|
|
//非空白单元格渲染
|
|
|
|
let cellRender = function(r, c, start_r, start_c, end_r, end_c, value, canvasType){ |
|
|
|
|
|
|
|
let cell = Store.flowdata[r][c]; |
|
|
|
let cellWidth = end_c - start_c - 2; |
|
|
|
let cellHeight = end_r - start_r - 2; |
|
|
@ -664,7 +665,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
luckysheetTableContent.textBaseline = 'top'; |
|
|
|
|
|
|
|
//文本计算 宽度和高度
|
|
|
|
let cellValueSize = getCellValueSize(cell, value, luckysheetTableContent, cellWidth, cellHeight, space_width, space_height); |
|
|
|
// let cellValueSize = getCellValueSize(cell, value, luckysheetTableContent, cellWidth, cellHeight, space_width, space_height);
|
|
|
|
|
|
|
|
//水平对齐
|
|
|
|
let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c, "ht"); |
|
|
@ -675,7 +676,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
let measureText = luckysheetTableContent.measureText(value); |
|
|
|
let textMetrics = measureText.width; |
|
|
|
let oneLineTextHeight = measureText.actualBoundingBoxDescent - measureText.actualBoundingBoxAscent; |
|
|
|
|
|
|
|
|
|
|
|
//交替颜色
|
|
|
|
let checksAF = alternateformat.checksAF(r, c, af_compute); |
|
|
|
//条件格式
|
|
|
@ -695,7 +696,6 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
(end_c - start_c + 2) * Store.devicePixelRatio, |
|
|
|
(end_r - start_r) * Store.devicePixelRatio |
|
|
|
) |
|
|
|
|
|
|
|
//若单元格有批注(单元格右上角红色小三角标示)
|
|
|
|
if(cell.ps != null){ |
|
|
|
let ps_w = 5, ps_h = 5; //红色小三角宽高
|
|
|
@ -721,7 +721,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
//溢出单元格
|
|
|
|
let cellOverflow_bd_r_render = true; //溢出单元格右边框是否需要绘制
|
|
|
|
let cellOverflow_colInObj = cellOverflow_colIn(cellOverflowMap, r, c, dataset_col_st, dataset_col_ed); |
|
|
|
|
|
|
|
|
|
|
|
if(cell.tb == '1' && cellOverflow_colInObj.colIn){ |
|
|
|
//此单元格 为 溢出单元格渲染范围最后一列,绘制溢出单元格内容
|
|
|
|
if(cellOverflow_colInObj.colLast){ |
|
|
@ -1303,12 +1303,14 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
Store.devicePixelRatio * (end_r + offsetTop - 2) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineWidth = Store.devicePixelRatio; |
|
|
|
|
|
|
|
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//下边框
|
|
|
|
if(!Store.luckysheetcurrentisPivotTable){ |
|
|
|
luckysheetTableContent.beginPath(); |
|
|
@ -1321,7 +1323,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineWidth = Store.devicePixelRatio; |
|
|
|
|
|
|
|
luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle; |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
} |
|
|
@ -1655,7 +1657,7 @@ function luckysheetDrawMain(scrollWidth, scrollHeight, drawWidth, drawHeight, of |
|
|
|
|
|
|
|
if (r == 6 && c == 3) { |
|
|
|
luckysheetTableContent.fillText( |
|
|
|
"数据透视表", |
|
|
|
"Pivot Table", |
|
|
|
Store.devicePixelRatio * (start_c + 4 + offsetLeft), |
|
|
|
Store.devicePixelRatio *(start_r + (end_r - start_r) / 2 - 1 + offsetTop) |
|
|
|
); |
|
|
@ -2089,784 +2091,10 @@ function getCellValueSize(cell, value, canvas, cellWidth, cellHeight, space_widt |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function luckysheetDrawMain_back(scrollWidth, scrollHeight, drawWidth, drawHeight, offsetLeft, offsetTop, columnOffsetCell, rowOffsetCell, mycanvas) { |
|
|
|
if (scrollWidth == null) { |
|
|
|
scrollWidth = $("#luckysheet-cell-main").scrollLeft(); |
|
|
|
} |
|
|
|
if (scrollHeight == null) { |
|
|
|
scrollHeight = $("#luckysheet-cell-main").scrollTop(); |
|
|
|
} |
|
|
|
|
|
|
|
if (drawWidth == null) { |
|
|
|
drawWidth = Store.luckysheetTableContentHW[0]; |
|
|
|
} |
|
|
|
if (drawHeight == null) { |
|
|
|
drawHeight = Store.luckysheetTableContentHW[1]; |
|
|
|
} |
|
|
|
|
|
|
|
if (offsetLeft == null) { |
|
|
|
offsetLeft = Store.rowHeaderWidth; |
|
|
|
} |
|
|
|
if (offsetTop == null) { |
|
|
|
offsetTop = Store.columeHeaderHeight; |
|
|
|
} |
|
|
|
|
|
|
|
if (columnOffsetCell == null) { |
|
|
|
columnOffsetCell = 0; |
|
|
|
} |
|
|
|
if (rowOffsetCell == null) { |
|
|
|
rowOffsetCell = 0; |
|
|
|
} |
|
|
|
|
|
|
|
let luckysheetTableContent = null; |
|
|
|
if(mycanvas == null){ |
|
|
|
luckysheetTableContent = $("#luckysheetTableContent").get(0).getContext("2d"); |
|
|
|
} |
|
|
|
else { |
|
|
|
if(getObjType(mycanvas) == "object"){ |
|
|
|
try{ |
|
|
|
luckysheetTableContent = mycanvas.get(0).getContext("2d"); |
|
|
|
} |
|
|
|
catch(err){ |
|
|
|
luckysheetTableContent = mycanvas; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
luckysheetTableContent = $("#" + mycanvas).get(0).getContext("2d"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
luckysheetTableContent.clearRect( |
|
|
|
offsetLeft * Store.devicePixelRatio, |
|
|
|
offsetTop * Store.devicePixelRatio, |
|
|
|
drawWidth * Store.devicePixelRatio, |
|
|
|
drawHeight * Store.devicePixelRatio |
|
|
|
); |
|
|
|
|
|
|
|
//离屏canvas
|
|
|
|
let offlinecanvas = $("#luckysheetTableContentF").get(0).getContext("2d"); |
|
|
|
offlinecanvas.fillStyle = "#ffffff"; |
|
|
|
offlinecanvas.fillRect( |
|
|
|
0, |
|
|
|
0, |
|
|
|
Store.luckysheetTableContentHW[0] * Store.devicePixelRatio, |
|
|
|
Store.luckysheetTableContentHW[1] * Store.devicePixelRatio |
|
|
|
); |
|
|
|
|
|
|
|
offlinecanvas.font = luckysheetdefaultFont(); |
|
|
|
offlinecanvas.textBaseline = "top"; |
|
|
|
offlinecanvas.fillStyle = luckysheetdefaultstyle.fillStyle; |
|
|
|
|
|
|
|
let dataset_row_st, dataset_row_ed, dataset_col_st, dataset_col_ed; |
|
|
|
|
|
|
|
dataset_row_st = luckysheet_searcharray(Store.visibledatarow, scrollHeight); |
|
|
|
dataset_row_ed = luckysheet_searcharray(Store.visibledatarow, scrollHeight + drawHeight); |
|
|
|
|
|
|
|
if (dataset_row_st == -1) { |
|
|
|
dataset_row_st = 0; |
|
|
|
} |
|
|
|
|
|
|
|
dataset_row_st += rowOffsetCell; |
|
|
|
|
|
|
|
if (dataset_row_ed == -1) { |
|
|
|
dataset_row_ed = Store.visibledatarow.length - 1; |
|
|
|
} |
|
|
|
|
|
|
|
dataset_row_ed += rowOffsetCell; |
|
|
|
|
|
|
|
if (dataset_row_ed >= Store.visibledatarow.length) { |
|
|
|
dataset_row_ed = Store.visibledatarow.length - 1; |
|
|
|
} |
|
|
|
|
|
|
|
dataset_col_st = luckysheet_searcharray(Store.visibledatacolumn, scrollWidth); |
|
|
|
dataset_col_ed = luckysheet_searcharray(Store.visibledatacolumn, scrollWidth + drawWidth); |
|
|
|
|
|
|
|
if (dataset_col_st == -1) { |
|
|
|
dataset_col_st = 0; |
|
|
|
} |
|
|
|
|
|
|
|
dataset_col_st += columnOffsetCell; |
|
|
|
|
|
|
|
if (dataset_col_ed == -1) { |
|
|
|
dataset_col_ed = Store.visibledatacolumn.length - 1; |
|
|
|
} |
|
|
|
|
|
|
|
dataset_col_ed += columnOffsetCell; |
|
|
|
|
|
|
|
if (dataset_col_ed >= Store.visibledatacolumn.length) { |
|
|
|
dataset_col_ed = Store.visibledatacolumn.length - 1; |
|
|
|
} |
|
|
|
|
|
|
|
let fill_row_st, fill_row_ed, fill_col_st, fill_col_ed; |
|
|
|
if(dataset_row_st==0){ |
|
|
|
fill_row_st = 0; |
|
|
|
} |
|
|
|
else{ |
|
|
|
fill_row_st = Store.visibledatarow[dataset_row_st-1]; |
|
|
|
} |
|
|
|
|
|
|
|
fill_row_ed = Store.visibledatarow[dataset_row_ed]; |
|
|
|
|
|
|
|
if(dataset_col_st==0){ |
|
|
|
fill_col_st = 0; |
|
|
|
} |
|
|
|
else{ |
|
|
|
fill_col_st = Store.visibledatacolumn[dataset_col_st-1]; |
|
|
|
} |
|
|
|
|
|
|
|
fill_col_ed = Store.visibledatacolumn[dataset_col_ed]; |
|
|
|
|
|
|
|
luckysheetTableContent.fillStyle="#ffffff"; |
|
|
|
luckysheetTableContent.fillRect( |
|
|
|
(offsetLeft - 1) * Store.devicePixelRatio, |
|
|
|
(offsetTop - 1) * Store.devicePixelRatio, |
|
|
|
(fill_col_ed - fill_col_st) * Store.devicePixelRatio, |
|
|
|
(fill_row_ed - fill_row_st) * Store.devicePixelRatio |
|
|
|
); |
|
|
|
|
|
|
|
let end_r, start_r, end_c, start_c; |
|
|
|
|
|
|
|
let cellupdate = []; |
|
|
|
let mergeCache = {}; |
|
|
|
for (let r = dataset_row_st; r <= dataset_row_ed; r++) { |
|
|
|
if (r == 0) { |
|
|
|
start_r = -scrollHeight - 1; |
|
|
|
} |
|
|
|
else { |
|
|
|
start_r = Store.visibledatarow[r - 1] - scrollHeight - 1; |
|
|
|
} |
|
|
|
end_r = Store.visibledatarow[r] - scrollHeight; |
|
|
|
|
|
|
|
for (let c = dataset_col_st; c <= dataset_col_ed; c++) { |
|
|
|
if (c == 0) { |
|
|
|
start_c = -scrollWidth; |
|
|
|
} |
|
|
|
else { |
|
|
|
start_c = Store.visibledatacolumn[c - 1] - scrollWidth; |
|
|
|
} |
|
|
|
end_c = Store.visibledatacolumn[c] - scrollWidth; |
|
|
|
|
|
|
|
// if(c==dataset_col_ed){
|
|
|
|
// if (!Store.luckysheetcurrentisPivotTable && end_r <= drawHeight && start_r >= -1) {
|
|
|
|
// //行
|
|
|
|
// luckysheetTableContent.beginPath();
|
|
|
|
// luckysheetTableContent.moveTo(
|
|
|
|
// Store.devicePixelRatio * (offsetLeft - 1),
|
|
|
|
// Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5)
|
|
|
|
// );
|
|
|
|
// luckysheetTableContent.lineTo(
|
|
|
|
// Store.devicePixelRatio * (end_c + offsetLeft-2),
|
|
|
|
// Store.devicePixelRatio * (end_r + offsetTop - 2 + 0.5)
|
|
|
|
// );
|
|
|
|
// luckysheetTableContent.lineWidth = Store.devicePixelRatio;
|
|
|
|
// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
|
|
|
|
// luckysheetTableContent.closePath();
|
|
|
|
// luckysheetTableContent.stroke();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (r == dataset_row_st) {
|
|
|
|
// if (!Store.luckysheetcurrentisPivotTable && end_c <= drawWidth + 18 && start_c >= -1) {
|
|
|
|
// //列
|
|
|
|
// luckysheetTableContent.beginPath();
|
|
|
|
// luckysheetTableContent.moveTo(
|
|
|
|
// Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
|
|
|
|
// Store.devicePixelRatio * (offsetTop - 1)
|
|
|
|
// );
|
|
|
|
// luckysheetTableContent.lineTo(
|
|
|
|
// Store.devicePixelRatio * (end_c + offsetLeft - 2 + 0.5),
|
|
|
|
// Store.devicePixelRatio * (fill_row_ed - fill_row_st + offsetTop-2)
|
|
|
|
// );
|
|
|
|
// luckysheetTableContent.lineWidth = Store.devicePixelRatio;
|
|
|
|
// luckysheetTableContent.strokeStyle = luckysheetdefaultstyle.strokeStyle;
|
|
|
|
// luckysheetTableContent.closePath();
|
|
|
|
// luckysheetTableContent.stroke();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
if (!!Store.luckysheetcurrentisPivotTable && pivotTable.drawPivotTable) { |
|
|
|
if ((c == 0 || c == 5) && r <= 11) { |
|
|
|
luckysheetTableContent.beginPath(); |
|
|
|
luckysheetTableContent.moveTo( |
|
|
|
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (start_r + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineTo( |
|
|
|
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineWidth = Store.devicePixelRatio; |
|
|
|
luckysheetTableContent.strokeStyle = "#000000"; |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
} |
|
|
|
|
|
|
|
if ((r == 2 || r == 11) && c <= 5) { |
|
|
|
luckysheetTableContent.beginPath(); |
|
|
|
luckysheetTableContent.moveTo( |
|
|
|
Store.devicePixelRatio * (start_c - 1 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineTo( |
|
|
|
Store.devicePixelRatio * (end_c + offsetLeft-2), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineWidth = Store.devicePixelRatio; |
|
|
|
luckysheetTableContent.strokeStyle = "#000000"; |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
} |
|
|
|
|
|
|
|
if (r == 6 && c == 3) { |
|
|
|
luckysheetTableContent.fillText( |
|
|
|
"数据透视表", |
|
|
|
Store.devicePixelRatio * (start_c + 4 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (start_r + (end_r - start_r) / 2 - 1 + offsetTop) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!!Store.luckysheetcurrentisPivotTable) { |
|
|
|
if (c < pivotTable.pivotTableBoundary[1] && r < pivotTable.pivotTableBoundary[0]) { |
|
|
|
luckysheetTableContent.beginPath(); |
|
|
|
luckysheetTableContent.moveTo( |
|
|
|
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (start_r + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineTo( |
|
|
|
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineWidth = Store.devicePixelRatio; |
|
|
|
luckysheetTableContent.strokeStyle = "#000000"; |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
|
|
|
|
luckysheetTableContent.beginPath(); |
|
|
|
luckysheetTableContent.moveTo( |
|
|
|
Store.devicePixelRatio * (start_c - 1 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop) |
|
|
|
); |
|
|
|
luckysheetTableContent.lineTo( |
|
|
|
Store.devicePixelRatio * (end_c + offsetLeft - 2), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop)); |
|
|
|
luckysheetTableContent.lineWidth = Store.devicePixelRatio; |
|
|
|
luckysheetTableContent.strokeStyle = "#000000"; |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (Store.config["rowhidden"] != null && Store.config["rowhidden"][r] != null) { |
|
|
|
|
|
|
|
} |
|
|
|
else { |
|
|
|
if (Store.flowdata[r] != null && Store.flowdata[r][c] != null && start_r >= -1 && start_c >= -1 ) { |
|
|
|
let value = Store.flowdata[r][c]; |
|
|
|
|
|
|
|
let firstcolumlen = Store.defaultcollen; |
|
|
|
if (Store.config["columlen"] != null && Store.config["columlen"][c] != null) { |
|
|
|
firstcolumlen = Store.config["columlen"][c]; |
|
|
|
} |
|
|
|
|
|
|
|
if(getObjType(value) == "object" && ("mc" in value)){ |
|
|
|
if("rs" in value["mc"]){ |
|
|
|
let key = "r"+ r + "c" + c; |
|
|
|
mergeCache[key] = cellupdate.length; |
|
|
|
} |
|
|
|
else{ |
|
|
|
let key = "r"+ value["mc"].r + "c" + value["mc"].c; |
|
|
|
let margeMain = cellupdate[mergeCache[key]]; |
|
|
|
|
|
|
|
if(margeMain==null){ |
|
|
|
mergeCache[key] = cellupdate.length; |
|
|
|
cellupdate.push({ |
|
|
|
"r": r, |
|
|
|
"c": c, |
|
|
|
"start_c": start_c, |
|
|
|
"start_r": start_r, |
|
|
|
"end_r": end_r, |
|
|
|
"end_c": end_c, |
|
|
|
"firstcolumlen": firstcolumlen, |
|
|
|
"startlist": [] |
|
|
|
}); |
|
|
|
} |
|
|
|
else{ |
|
|
|
if(margeMain.c==c){ |
|
|
|
margeMain.end_r += (end_r-start_r-1); |
|
|
|
margeMain.startlist.push(start_r); |
|
|
|
} |
|
|
|
|
|
|
|
if(margeMain.r==r){ |
|
|
|
margeMain.end_c += (end_c-start_c); |
|
|
|
margeMain.firstcolumlen += firstcolumlen; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let margeMaindata = Store.flowdata[margeMain.r][margeMain.c]; |
|
|
|
if((margeMain.c + margeMaindata.mc.cs-1)==c && (margeMain.r + margeMaindata.mc.rs-1)==r){ |
|
|
|
//margeMain.end_r -= 10;
|
|
|
|
//margeMain.end_c -= 1;
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
cellupdate.push({ |
|
|
|
"r": r, |
|
|
|
"c": c, |
|
|
|
"start_c": start_c, |
|
|
|
"start_r": start_r, |
|
|
|
"end_r": end_r, |
|
|
|
"end_c": end_c, |
|
|
|
"firstcolumlen": firstcolumlen, |
|
|
|
"startlist": [] |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for(let cud = 0; cud < cellupdate.length; cud++){ |
|
|
|
let item = cellupdate[cud]; |
|
|
|
let r= item.r, |
|
|
|
c = item.c, |
|
|
|
start_c = item.start_c, |
|
|
|
start_r = item.start_r, |
|
|
|
end_c = item.end_c, |
|
|
|
end_r = item.end_r; |
|
|
|
let firstcolumlen = item.firstcolumlen; |
|
|
|
|
|
|
|
let cell = Store.flowdata[r][c]; |
|
|
|
let value = null, er = r, ec = c, end_ec = end_c; |
|
|
|
if((typeof cell == "object") && "mc" in cell){ |
|
|
|
let margeMaindata = cell["mc"]; |
|
|
|
value = getcellvalue(margeMaindata.r, margeMaindata.c, null,"m"); |
|
|
|
if(value == null){ |
|
|
|
value = getcellvalue(margeMaindata.r, margeMaindata.c); |
|
|
|
} |
|
|
|
|
|
|
|
r = margeMaindata.r; |
|
|
|
c = margeMaindata.c; |
|
|
|
|
|
|
|
er += margeMaindata.rs; |
|
|
|
ec += margeMaindata.rc; |
|
|
|
|
|
|
|
if (c == 0) { |
|
|
|
start_c = -scrollWidth; |
|
|
|
} |
|
|
|
else { |
|
|
|
start_c = Store.visibledatacolumn[c - 1] - scrollWidth; |
|
|
|
} |
|
|
|
|
|
|
|
if (r == 0) { |
|
|
|
start_r = -scrollHeight - 1; |
|
|
|
} |
|
|
|
else { |
|
|
|
start_r = Store.visibledatarow[r - 1] - scrollHeight - 1; |
|
|
|
} |
|
|
|
|
|
|
|
end_ec = Store.visibledatacolumn[ec] - scrollWidth; |
|
|
|
} |
|
|
|
else{ |
|
|
|
value = getcellvalue(r, c, null,"m"); |
|
|
|
if(value == null){ |
|
|
|
value = getcellvalue(r, c); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let borderfix = menuButton.borderfix(Store.flowdata, r, c); |
|
|
|
offlinecanvas.fillStyle= menuButton.checkstatus(Store.flowdata, r, c , "bg"); |
|
|
|
|
|
|
|
let cellsize = [ |
|
|
|
Store.devicePixelRatio * (start_c + offsetLeft + borderfix[0]), |
|
|
|
Store.devicePixelRatio * (start_r + offsetTop + 0.5 + borderfix[1]), |
|
|
|
Store.devicePixelRatio * (end_c - start_c - 3 + borderfix[2]), |
|
|
|
Store.devicePixelRatio * (end_r - start_r-3 - 0.5 + borderfix[3]) |
|
|
|
]; |
|
|
|
offlinecanvas.fillRect(cellsize[0], cellsize[1], cellsize[2], cellsize[3]); |
|
|
|
|
|
|
|
offlinecanvas.fillStyle= menuButton.checkstatus(Store.flowdata, r, c , "fc"); |
|
|
|
|
|
|
|
let fontset = luckysheetfontformat(Store.flowdata[r][c]); |
|
|
|
offlinecanvas.font = fontset; |
|
|
|
|
|
|
|
let textMetrics = offlinecanvas.measureText(value).width; |
|
|
|
let oneLineTextHeight = menuButton.getTextSize("田", fontset)[1]; |
|
|
|
|
|
|
|
offlinecanvas.fillStyle= menuButton.checkstatus(Store.flowdata, r, c , "fc"); |
|
|
|
|
|
|
|
let horizonAlign = menuButton.checkstatus(Store.flowdata, r, c , "ht"); |
|
|
|
let horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; |
|
|
|
if(horizonAlign == "0"){ |
|
|
|
horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textMetrics)/2; |
|
|
|
} |
|
|
|
else if(horizonAlign=="2"){ |
|
|
|
horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textMetrics); |
|
|
|
} |
|
|
|
|
|
|
|
let verticalAlign = menuButton.checkstatus(Store.flowdata, r, c , "vt"); |
|
|
|
let verticalFixed = browser.luckysheetrefreshfixed(); |
|
|
|
let verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight; |
|
|
|
if(verticalAlign == "0"){ |
|
|
|
verticalAlignPos = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight/2; |
|
|
|
} |
|
|
|
else if(verticalAlign == "1"){ |
|
|
|
verticalAlignPos = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
|
|
|
|
//自动换行、旋转、删除线功能
|
|
|
|
if(Store.flowdata[r][c].tb == "2" && textMetrics > (end_c - start_c)){ |
|
|
|
let strValue = value.toString(); |
|
|
|
let cellWidth = end_c-start_c-8; |
|
|
|
let strArr = []; |
|
|
|
|
|
|
|
for(let strI = 1; strI <= strValue.length; strI++){ |
|
|
|
let strV = strValue.substring(strArr.join("").length,strI); |
|
|
|
let strtextMetrics = offlinecanvas.measureText(strV).width; |
|
|
|
if(strtextMetrics > cellWidth){ |
|
|
|
strArr.push(strValue.substring(strArr.join("").length,strI - 1)); |
|
|
|
strI = strI - 2; |
|
|
|
} |
|
|
|
else if(strtextMetrics <= cellWidth && strI == strValue.length){ |
|
|
|
strArr.push(strV); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for(let iFill = 0; iFill < strArr.length; iFill++){ |
|
|
|
//水平对齐计算
|
|
|
|
let strWidth = offlinecanvas.measureText(strArr[iFill]).width; |
|
|
|
if(horizonAlign == "0"){ |
|
|
|
horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (strWidth)/2; |
|
|
|
} |
|
|
|
else if(horizonAlign == "2"){ |
|
|
|
horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (strWidth); |
|
|
|
} |
|
|
|
else{ |
|
|
|
horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
|
|
|
|
//垂直对齐计算
|
|
|
|
if(verticalAlign == "0"){ |
|
|
|
verticalAlignPos = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight * strArr.length / 2; |
|
|
|
} |
|
|
|
else if(verticalAlign == "1"){ |
|
|
|
verticalAlignPos = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
else{ |
|
|
|
verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight * strArr.length; |
|
|
|
} |
|
|
|
|
|
|
|
offlinecanvas.fillText(strArr[iFill], horizonAlignPos, (verticalAlignPos + iFill * Store.oneLineTextHeight)); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(!!Store.flowdata[r][c].tr && Store.flowdata[r][c].tr != "0"){ |
|
|
|
//单元格旋转属性
|
|
|
|
let tr = Store.flowdata[r][c].tr; |
|
|
|
|
|
|
|
if(tr == "1" || tr == "2"){ |
|
|
|
//旋转重新计算水平、垂直方向坐标
|
|
|
|
let textW = 0.707 * (textMetrics + oneLineTextHeight); |
|
|
|
let textH = 0.707 * (textMetrics + oneLineTextHeight); |
|
|
|
|
|
|
|
let hAP = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; |
|
|
|
if(horizonAlign=="0"){ |
|
|
|
hAP = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textW)/2; |
|
|
|
} |
|
|
|
else if(horizonAlign=="2"){ |
|
|
|
hAP = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textW); |
|
|
|
} |
|
|
|
|
|
|
|
let vAP = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - textH; |
|
|
|
if(verticalAlign=="0"){ |
|
|
|
vAP = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - textH/2; |
|
|
|
} |
|
|
|
else if(verticalAlign=="1"){ |
|
|
|
vAP = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
|
|
|
|
//向下倾斜(45 旋转)
|
|
|
|
if(tr == "1"){ |
|
|
|
offlinecanvas.save(); |
|
|
|
offlinecanvas.translate(hAP, vAP); |
|
|
|
offlinecanvas.rotate(45 * Math.PI / 180); |
|
|
|
offlinecanvas.translate(-hAP, -vAP); |
|
|
|
offlinecanvas.fillText( |
|
|
|
value == null ? "" : value, |
|
|
|
hAP + (0.707 * 0.707 * oneLineTextHeight), |
|
|
|
vAP - (0.707 * 0.707 * oneLineTextHeight) |
|
|
|
); |
|
|
|
offlinecanvas.restore(); |
|
|
|
|
|
|
|
//是否有删除线
|
|
|
|
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); |
|
|
|
if(cl == "1" && !!value){ |
|
|
|
offlinecanvas.beginPath(); |
|
|
|
offlinecanvas.moveTo(hAP + oneLineTextHeight/2, vAP + oneLineTextHeight/2); |
|
|
|
offlinecanvas.lineTo(hAP + textW - oneLineTextHeight/2, vAP + textH - oneLineTextHeight/2); |
|
|
|
offlinecanvas.closePath(); |
|
|
|
offlinecanvas.stroke(); |
|
|
|
} |
|
|
|
} |
|
|
|
//向上倾斜(-45 旋转)
|
|
|
|
if(tr == "2"){ |
|
|
|
offlinecanvas.save(); |
|
|
|
offlinecanvas.translate(hAP + textW, vAP); |
|
|
|
offlinecanvas.rotate(-45 * Math.PI / 180); |
|
|
|
offlinecanvas.translate(-(hAP + textW), -vAP); |
|
|
|
offlinecanvas.fillText( |
|
|
|
value == null ? "" : value, |
|
|
|
hAP - (0.707 * 0.707 * oneLineTextHeight), |
|
|
|
vAP - (0.707 * 0.707 * oneLineTextHeight) |
|
|
|
); |
|
|
|
offlinecanvas.restore(); |
|
|
|
|
|
|
|
//是否有删除线
|
|
|
|
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); |
|
|
|
if(cl == "1" && !!value){ |
|
|
|
offlinecanvas.beginPath(); |
|
|
|
offlinecanvas.moveTo(hAP + oneLineTextHeight/2, vAP + textH - oneLineTextHeight/2); |
|
|
|
offlinecanvas.lineTo(hAP + textW - oneLineTextHeight/2, vAP + oneLineTextHeight/2); |
|
|
|
offlinecanvas.closePath(); |
|
|
|
offlinecanvas.stroke(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(tr == "3"){ |
|
|
|
if(!!value){ |
|
|
|
value = value.toString(); |
|
|
|
|
|
|
|
let vArr; |
|
|
|
if(value.length > 1){ |
|
|
|
vArr = value.split(""); |
|
|
|
} |
|
|
|
else{ |
|
|
|
vArr = []; |
|
|
|
vArr.push(value); |
|
|
|
} |
|
|
|
|
|
|
|
let textW = offlinecanvas.measureText(vArr[0]).width; |
|
|
|
let textH = vArr.length * oneLineTextHeight; |
|
|
|
|
|
|
|
for(let i = 0; i < vArr.length; i++){ |
|
|
|
let vWidth = offlinecanvas.measureText(vArr[i]).width; |
|
|
|
|
|
|
|
//水平对齐计算
|
|
|
|
if(horizonAlign == "0"){ |
|
|
|
horizonAlignPos = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (vWidth)/2; |
|
|
|
} |
|
|
|
else if(horizonAlign == "2"){ |
|
|
|
horizonAlignPos = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (vWidth); |
|
|
|
} |
|
|
|
else{ |
|
|
|
horizonAlignPos = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
|
|
|
|
//垂直对齐计算
|
|
|
|
if(verticalAlign == "0"){ |
|
|
|
verticalAlignPos = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight*vArr.length/2; |
|
|
|
} |
|
|
|
else if(verticalAlign == "1"){ |
|
|
|
verticalAlignPos = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
else{ |
|
|
|
verticalAlignPos = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - oneLineTextHeight*vArr.length; |
|
|
|
} |
|
|
|
|
|
|
|
offlinecanvas.fillText(vArr[i], horizonAlignPos, (verticalAlignPos + i * oneLineTextHeight)); |
|
|
|
} |
|
|
|
|
|
|
|
//是否有删除线
|
|
|
|
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); |
|
|
|
if(cl == "1" && !!value){ |
|
|
|
offlinecanvas.beginPath(); |
|
|
|
offlinecanvas.moveTo(horizonAlignPos + textW/2, verticalAlignPos); |
|
|
|
offlinecanvas.lineTo(horizonAlignPos + textW/2, verticalAlignPos + textH); |
|
|
|
offlinecanvas.closePath(); |
|
|
|
offlinecanvas.stroke(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(tr == "4" || tr == "5"){ |
|
|
|
//旋转重新计算水平、垂直方向坐标
|
|
|
|
let textW = oneLineTextHeight; |
|
|
|
let textH = textMetrics; |
|
|
|
|
|
|
|
let hAP = (start_c + 4 + offsetLeft) * Store.devicePixelRatio; |
|
|
|
if(horizonAlign=="0"){ |
|
|
|
hAP = (start_c + (end_c - start_c) / 2 + offsetLeft) * Store.devicePixelRatio - (textW)/2; |
|
|
|
} |
|
|
|
else if(horizonAlign=="2"){ |
|
|
|
hAP = (end_c + offsetLeft - 8) * Store.devicePixelRatio - (textW); |
|
|
|
} |
|
|
|
|
|
|
|
let vAP = (end_r + offsetTop - 2 + verticalFixed) * Store.devicePixelRatio - textH; |
|
|
|
if(verticalAlign=="0"){ |
|
|
|
vAP = (start_r + (end_r - start_r) / 2 + offsetTop + verticalFixed) * Store.devicePixelRatio - textH/2; |
|
|
|
} |
|
|
|
else if(verticalAlign=="1"){ |
|
|
|
vAP = (start_r + offsetTop + verticalFixed) * Store.devicePixelRatio; |
|
|
|
} |
|
|
|
|
|
|
|
//向下90(90 旋转)
|
|
|
|
if(tr == "4"){ |
|
|
|
offlinecanvas.save(); |
|
|
|
offlinecanvas.translate(hAP, vAP); |
|
|
|
offlinecanvas.rotate(90 * Math.PI / 180); |
|
|
|
offlinecanvas.translate(-hAP, -vAP); |
|
|
|
offlinecanvas.fillText(value == null ? "" : value, hAP, vAP - textW); |
|
|
|
offlinecanvas.restore(); |
|
|
|
|
|
|
|
//是否有删除线
|
|
|
|
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); |
|
|
|
if(cl == "1" && !!value){ |
|
|
|
offlinecanvas.beginPath(); |
|
|
|
offlinecanvas.moveTo(hAP + textW/2, vAP); |
|
|
|
offlinecanvas.lineTo(hAP + textW/2, vAP + textH); |
|
|
|
offlinecanvas.closePath(); |
|
|
|
offlinecanvas.stroke(); |
|
|
|
} |
|
|
|
} |
|
|
|
//向上90(-90 旋转)
|
|
|
|
if(tr == "5"){ |
|
|
|
offlinecanvas.save(); |
|
|
|
offlinecanvas.translate(hAP + textH, vAP); |
|
|
|
offlinecanvas.rotate(-90 * Math.PI / 180); |
|
|
|
offlinecanvas.translate(-(hAP + textH), -vAP); |
|
|
|
offlinecanvas.fillText(value == null ? "" : value, hAP, vAP - textH); |
|
|
|
offlinecanvas.restore(); |
|
|
|
|
|
|
|
//是否有删除线
|
|
|
|
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); |
|
|
|
if(cl == "1" && !!value){ |
|
|
|
offlinecanvas.beginPath(); |
|
|
|
offlinecanvas.moveTo(hAP + textW/2, vAP); |
|
|
|
offlinecanvas.lineTo(hAP + textW/2, vAP + textH); |
|
|
|
offlinecanvas.closePath(); |
|
|
|
offlinecanvas.stroke(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
//是否有删除线
|
|
|
|
let cl = menuButton.checkstatus(Store.flowdata, r, c , "cl"); |
|
|
|
if(cl == "1" && !!value){ |
|
|
|
luckysheetTableContent.strokeStyle = "#000000"; |
|
|
|
|
|
|
|
offlinecanvas.beginPath(); |
|
|
|
offlinecanvas.moveTo(horizonAlignPos, verticalAlignPos + oneLineTextHeight/2); |
|
|
|
offlinecanvas.lineTo(horizonAlignPos + textMetrics, verticalAlignPos + oneLineTextHeight/2); |
|
|
|
offlinecanvas.closePath(); |
|
|
|
offlinecanvas.stroke(); |
|
|
|
|
|
|
|
offlinecanvas.textBaseline = "middle"; |
|
|
|
offlinecanvas.fillText(value==null?"":value, horizonAlignPos, verticalAlignPos + oneLineTextHeight/2); |
|
|
|
} |
|
|
|
else{ |
|
|
|
offlinecanvas.textBaseline = "top"; |
|
|
|
offlinecanvas.fillText(value==null?"":value, horizonAlignPos, verticalAlignPos); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
offlinecanvas.font = luckysheetdefaultFont(); |
|
|
|
|
|
|
|
luckysheetTableContent.drawImage($("#luckysheetTableContentF").get(0), cellsize[0], cellsize[1], cellsize[2], cellsize[3], cellsize[0], cellsize[1], cellsize[2], cellsize[3]); |
|
|
|
|
|
|
|
let bs = menuButton.checkstatus(Store.flowdata, r, c , "bs"); |
|
|
|
let bc = menuButton.checkstatus(Store.flowdata, r, c , "bc"); |
|
|
|
let bs_t = menuButton.checkstatus(Store.flowdata, r, c , "bs_t"); |
|
|
|
let bc_t = menuButton.checkstatus(Store.flowdata, r, c , "bc_t"); |
|
|
|
let bs_b = menuButton.checkstatus(Store.flowdata, r, c , "bs_b"); |
|
|
|
let bc_b = menuButton.checkstatus(Store.flowdata, r, c , "bc_b"); |
|
|
|
let bs_l = menuButton.checkstatus(Store.flowdata, r, c , "bs_l"); |
|
|
|
let bc_l = menuButton.checkstatus(Store.flowdata, r, c , "bc_l"); |
|
|
|
let bs_r = menuButton.checkstatus(Store.flowdata, r, c , "bs_r"); |
|
|
|
let bc_r = menuButton.checkstatus(Store.flowdata, r, c , "bc_r"); |
|
|
|
|
|
|
|
//左边框
|
|
|
|
if(bs_l!="none" || bs!="none"){ |
|
|
|
let linetype = bs_l=="none" ?bs:bs_l; |
|
|
|
|
|
|
|
menuButton.setLineDash( |
|
|
|
luckysheetTableContent, |
|
|
|
linetype, |
|
|
|
"v", |
|
|
|
Store.devicePixelRatio * (start_c - 2+ 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (start_r + offsetTop), |
|
|
|
Store.devicePixelRatio * (start_c - 2+ 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + offsetTop) |
|
|
|
); |
|
|
|
|
|
|
|
luckysheetTableContent.strokeStyle = bs_l == "none" ? bc : bc_l; |
|
|
|
|
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
} |
|
|
|
|
|
|
|
// //右边框
|
|
|
|
if(bs_r!="none" || bs!="none"){ |
|
|
|
let linetype = bs_r=="none" ?bs:bs_r; |
|
|
|
|
|
|
|
menuButton.setLineDash( |
|
|
|
luckysheetTableContent, |
|
|
|
linetype, |
|
|
|
"v", |
|
|
|
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (start_r + offsetTop), |
|
|
|
Store.devicePixelRatio * (end_c - 2 + 0.5 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + offsetTop) |
|
|
|
); |
|
|
|
|
|
|
|
luckysheetTableContent.strokeStyle = bs_r == "none" ? bc : bc_r; |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
} |
|
|
|
|
|
|
|
//下边框
|
|
|
|
if(bs_b!="none" || bs!="none"){ |
|
|
|
let linetype = bs_b=="none" ?bs:bs_b; |
|
|
|
|
|
|
|
menuButton.setLineDash( |
|
|
|
luckysheetTableContent, |
|
|
|
linetype, |
|
|
|
"h", |
|
|
|
Store.devicePixelRatio * (start_c - 2 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop), |
|
|
|
Store.devicePixelRatio * (end_c + offsetLeft-2), |
|
|
|
Store.devicePixelRatio * (end_r - 2 + 0.5 + offsetTop) |
|
|
|
); |
|
|
|
|
|
|
|
luckysheetTableContent.strokeStyle = bs_b == "none" ? bc : bc_b; |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
} |
|
|
|
|
|
|
|
//上边框
|
|
|
|
if(bs_t!="none" || bs!="none"){ |
|
|
|
let linetype = bs_t=="none" ?bs:bs_t; |
|
|
|
|
|
|
|
menuButton.setLineDash( |
|
|
|
luckysheetTableContent, |
|
|
|
linetype, |
|
|
|
"h", |
|
|
|
Store.devicePixelRatio * (start_c - 2 + offsetLeft), |
|
|
|
Store.devicePixelRatio * (start_r - 1 + 0.5 + offsetTop), |
|
|
|
Store.devicePixelRatio * (end_c + offsetLeft-2), |
|
|
|
Store.devicePixelRatio * (start_r - 1 + 0.5 + offsetTop) |
|
|
|
); |
|
|
|
|
|
|
|
luckysheetTableContent.strokeStyle = bs_t == "none" ? bc : bc_t; |
|
|
|
luckysheetTableContent.stroke(); |
|
|
|
luckysheetTableContent.closePath(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export { |
|
|
|
luckysheetDrawgrid, |
|
|
|
luckysheetDrawgridRowTitle, |
|
|
|
luckysheetDrawgridColumnTitle, |
|
|
|
luckysheetDrawMain, |
|
|
|
luckysheetDrawMain_back, |
|
|
|
} |