Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
fix(bug): bug
Browse files Browse the repository at this point in the history
bug
  • Loading branch information
wpxp123456 committed Aug 4, 2020
1 parent b656c27 commit fc8f61b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 84 deletions.
2 changes: 1 addition & 1 deletion src/controllers/constant.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 42 additions & 83 deletions src/controllers/rowColumnOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getObjType,
showrightclickmenu,
luckysheetContainerFocus,
luckysheetfontformat,
} from '../utils/util';
import { getSheetIndex, getRangetxt } from '../methods/get';
import {
Expand Down Expand Up @@ -1486,131 +1487,89 @@ export function rowColumnOperationInitial(){

function luckysheetcolsdbclick() {
Store.luckysheet_cols_change_size = false;

$("#luckysheet-change-size-line").hide();
$("#luckysheet-cols-change-size").css("opacity", 0);
$("#luckysheet-sheettable, #luckysheet-cols-h-c, .luckysheet-cols-h-cells, .luckysheet-cols-h-cells canvas").css("cursor", "default");

let mouse = mouseposition(event.pageX, event.pageY);
let scrollLeft = $("#luckysheet-cols-h-c").scrollLeft();
let x = mouse[0] + scrollLeft;
let winW = $(window).width();

let row_index = Store.visibledatarow.length - 1,
row = Store.visibledatarow[row_index],
row_pre = 0;
let col_location = colLocation(x),
col = col_location[1],
col_pre = col_location[0],
col_index = col_location[2];
Store.luckysheet_cols_change_size_start = [col_pre, col_index];
let dataflow = $("#luckysheetTableContent").get(0).getContext("2d");

let colIndex = colLocation(x)[2];
let d = editor.deepCopyFlowData(Store.flowdata);
let canvas = $("#luckysheetTableContent").get(0).getContext("2d");

let cfg = $.extend(true, {}, Store.config);
if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
}

let matchColumn = {};
for(let s = 0; s < Store.luckysheet_select_save.length; s++){
let c1 = Store.luckysheet_select_save[s].column[0],
c2 = Store.luckysheet_select_save[s].column[1];

if (col_index < c1 || col_index > c2) {
if(col_index in matchColumn){//此列已计算过
if (colIndex < c1 || colIndex > c2) {
if(colIndex in matchColumn){//此列已计算过
continue;
}

x = -Infinity;
let countret = 0;
let fontsize = 13;
for (let r = 0; r < Store.flowdata.length; r++) {
if (countret >= 15) {
break;
}
let currentColLen = Store.defaultcollen;

let value = getcellvalue(r, Store.luckysheet_cols_change_size_start[1], Store.flowdata);
let mask = getcellvalue(r, Store.luckysheet_cols_change_size_start[1], Store.flowdata, "m");

if(mask != null){
value = mask;
}

let cell = Store.flowdata[r][Store.luckysheet_cols_change_size_start[1]];
if(getObjType(cell) == "object" && ("fs" in cell)){
if(cell.fs > fontsize){
fontsize = cell.fs;
}
}

if (value == null || value.toString().length == 0) {
countret++;
for(let r = 0; r < d.length; r++){
let cell = d[r][colIndex];

if(cell == null || isRealNull(cell.v)){
continue;
}
let textMetrics = dataflow.measureText(value).width;
if (textMetrics > x) {
x = textMetrics;
}
}

let size = x + fontsize * 1.5;
if ((x + 3) < 30) {
size = 30;
}
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;

if (x >= winW - 100 + scrollLeft) {
size = winW - 100 + scrollLeft;
}
let value = getcellvalue(r, colIndex, d).toString(); //单元格文本
let textMetrics = canvas.measureText(value).width; //文本宽度

if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
}
}

cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size);
if(currentColLen != Store.defaultcollen){
cfg["columnlen"][colIndex] = currentColLen;
}

matchColumn[col_index] = 1;
matchColumn[colIndex] = 1;
}
else {
for (let c = c1; c <= c2; c++) {
if(c in matchColumn){//此列已计算过
continue;
}

x = -Infinity;
let countret = 0;
let fontsize = 13;
for (let r = 0; r < Store.flowdata.length; r++) {
if (countret >= 15) {
break;
}
let value = getcellvalue(r, c, Store.flowdata);

let cell = Store.flowdata[r][c];
if(getObjType(cell) == "object" && ("fs" in cell)){
if(cell.fs > fontsize){
fontsize = cell.fs;
}
}
let currentColLen = Store.defaultcollen;

if (isRealNull(value)) {
countret++;
for(let r = 0; r < d.length; r++){
let cell = d[r][c];

if(cell == null || isRealNull(cell.v)){
continue;
}

let textMetrics = dataflow.measureText(value).width;
if (textMetrics > x) {
x = textMetrics;
}
}
let fontset = luckysheetfontformat(cell);
canvas.font = fontset;

let size = x + fontsize*1.5;;
if ((x + 3) < 30) {
size = 30;
}
let value = getcellvalue(r, c, d).toString(); //单元格文本
let textMetrics = canvas.measureText(value).width; //文本宽度

if (x >= winW - 100 + scrollLeft) {
size = winW - 100 + scrollLeft;
if(textMetrics + 6 > currentColLen){
currentColLen = textMetrics + 6;
}
}

if (cfg["columnlen"] == null) {
cfg["columnlen"] = {};
if(currentColLen != Store.defaultcollen){
cfg["columnlen"][c] = currentColLen;
}
cfg["columnlen"][c] = Math.ceil(size);

matchColumn[c] = 1;
}
Expand Down

0 comments on commit fc8f61b

Please sign in to comment.