diff --git a/src/controllers/handler.js b/src/controllers/handler.js index e72c057..b770cd2 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -2356,17 +2356,24 @@ export default function luckysheetHandler() { width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left; - top = resizeXY[5] - resizeXY[7] + topchange; + height = Math.round(width * (resizeXY[3] / resizeXY[2])); + top = resizeXY[5] - resizeXY[7] + resizeXY[3] - height; if(top < minTop){ top = minTop; + height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width; } if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){ top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1; - } + height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top; - height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top; + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width; + } } else if(resize == 'lm'){//左中 left = resizeXY[4] - resizeXY[6] + leftchange; @@ -2397,16 +2404,22 @@ export default function luckysheetHandler() { width = resizeXY[4] - resizeXY[6] + resizeXY[2] - left; - top = resizeXY[5] - resizeXY[7]; + height = Math.round(width * (resizeXY[3] / resizeXY[2])); - height = resizeXY[3] + topchange; + top = resizeXY[5] - resizeXY[7]; if(height < 1){ height = 1; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width; } if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){ height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[4] - resizeXY[6] + resizeXY[2] - width; } } else if(resize == 'rt'){//右上 @@ -2422,17 +2435,22 @@ export default function luckysheetHandler() { width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left; } - top = resizeXY[5] - resizeXY[7] + topchange; + height = Math.round(width * (resizeXY[3] / resizeXY[2])); + top = resizeXY[5] - resizeXY[7] + resizeXY[3] - height; if(top < minTop){ top = minTop; + height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); } if(top > resizeXY[5] - resizeXY[7] + resizeXY[3] - 1){ top = resizeXY[5] - resizeXY[7] + resizeXY[3] - 1; - } + height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top; - height = resizeXY[5] - resizeXY[7] + resizeXY[3] - top; + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + } } else if(resize == 'rm'){//右中 left = resizeXY[4] - resizeXY[6]; @@ -2463,16 +2481,19 @@ export default function luckysheetHandler() { width = minLeft + Store.cellmainWidth - Store.cellMainSrollBarSize - left; } + height = Math.round(width * (resizeXY[3] / resizeXY[2])); top = resizeXY[5] - resizeXY[7]; - height = resizeXY[3] + topchange; - if(height < 1){ height = 1; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); } if(height > minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top){ height = minTop + Store.cellmainHeight - Store.cellMainSrollBarSize - top; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); } } else if(resize == 'mt'){//中上 @@ -2509,21 +2530,105 @@ export default function luckysheetHandler() { } } else{ - if (resize == "lm" || resize == "lt" || resize == "lb") { + if(resize == 'lt'){//左上 + left = x; + width = resizeXY[2] - leftchange; + + if (left > resizeXY[2] + resizeXY[4] - 1) { + left = resizeXY[2] + resizeXY[4] - 1; + width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1); + } + else if (left <= 0) { + left = 0; + width = resizeXY[2] + resizeXY[0]; + } + + height = Math.round(width * (resizeXY[3] / resizeXY[2])); + top = resizeXY[3] + resizeXY[1] - height; + + if (top > resizeXY[3] + resizeXY[5] - 1) { + top = resizeXY[3] + resizeXY[5] - 1; + height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1); + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[2] + resizeXY[0] - width; + } + else if (top <= 0) { + top = 0; + height = resizeXY[3] + resizeXY[1]; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[2] + resizeXY[0] - width; + } + } + else if(resize == 'lm'){//左中 + left = x; + width = resizeXY[2] - leftchange; + + if (left > resizeXY[2] + resizeXY[4] - 1) { + left = resizeXY[2] + resizeXY[4] - 1; + width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1); + } + else if (left <= 0) { + left = 0; + width = resizeXY[2] + resizeXY[0]; + } + } + else if(resize == 'lb'){//左下 left = x; width = resizeXY[2] - leftchange; if (left > resizeXY[2] + resizeXY[4] - 1) { left = resizeXY[2] + resizeXY[4] - 1; - width = resizeXY[2] - (resizeXY[2] + resizeXY[4] - 1 - resizeXY[0]); + width = resizeXY[2] + resizeXY[0] - (resizeXY[2] + resizeXY[4] - 1); } else if (left <= 0) { left = 0; width = resizeXY[2] + resizeXY[0]; } + + height = Math.round(width * (resizeXY[3] / resizeXY[2])); + + if (height < 1) { + height = 1; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[2] + resizeXY[0] - width; + } + else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) { + height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + left = resizeXY[2] + resizeXY[0] - width; + } } + else if(resize == 'rt'){//右上 + width = resizeXY[2] + leftchange; - if (resize == "rm" || resize == "rt" || resize == "rb") { + if (width < 1) { + width = 1; + } + else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) { + width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36; + } + + height = Math.round(width * (resizeXY[3] / resizeXY[2])); + top = resizeXY[3] + resizeXY[1] - height; + + if (top > resizeXY[3] + resizeXY[5] - 1) { + top = resizeXY[3] + resizeXY[5] - 1; + height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1); + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + } + else if (top <= 0) { + top = 0; + height = resizeXY[3] + resizeXY[1]; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + } + } + else if(resize == 'rm'){//右中 width = resizeXY[2] + leftchange; if (width < 1) { @@ -2533,22 +2638,43 @@ export default function luckysheetHandler() { width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36; } } + else if(resize == 'rb'){//右下 + width = resizeXY[2] + leftchange; + + if (width < 1) { + width = 1; + } + else if (width >= imageCtrl.currentWinW - resizeXY[4] - 22 - 36) { + width = imageCtrl.currentWinW - resizeXY[4] - 22 - 36; + } + + height = Math.round(width * (resizeXY[3] / resizeXY[2])); - if (resize == "mt" || resize == "lt" || resize == "rt") { + if (height < 1) { + height = 1; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + } + else if (height >= imageCtrl.currentWinH - resizeXY[5] - 42 - 6) { + height = imageCtrl.currentWinH - resizeXY[5] - 42 - 6; + + width = Math.round(height * (resizeXY[2] / resizeXY[3])); + } + } + else if(resize == 'mt'){//中上 top = y; height = resizeXY[3] - topchange; if (top > resizeXY[3] + resizeXY[5] - 1) { top = resizeXY[3] + resizeXY[5] - 1; - height = resizeXY[3] - (resizeXY[3] + resizeXY[5] - 1 - resizeXY[1]); + height = resizeXY[3] + resizeXY[1] - (resizeXY[3] + resizeXY[5] - 1); } else if (top <= 0) { top = 0; height = resizeXY[3] + resizeXY[1]; } } - - if (resize == "mb" || resize == "lb" || resize == "rb") { + else if(resize == 'mb'){//中下 height = resizeXY[3] + topchange; if (height < 1) { diff --git a/src/controllers/rowColumnOperation.js b/src/controllers/rowColumnOperation.js index b096e03..1c0be6d 100644 --- a/src/controllers/rowColumnOperation.js +++ b/src/controllers/rowColumnOperation.js @@ -1696,6 +1696,7 @@ export function rowColumnOperationInitial(){ let cfg = $.extend(true, {}, Store.config); let type; + let images = null; if(Store.luckysheetRightHeadClickIs == "row"){ if(!checkProtectionAuthorityNormal(Store.currentSheetIndex, "formatRows")){ @@ -1724,6 +1725,8 @@ export function rowColumnOperationInitial(){ for(let r = r1; r <= r2; r++){ cfg["rowlen"][r] = size; + + images = imageCtrl.moveChangeSize("row", r, size); } } } @@ -1754,6 +1757,8 @@ export function rowColumnOperationInitial(){ for(let c = c1; c <= c2; c++){ cfg["columnlen"][c] = size; + + images = imageCtrl.moveChangeSize("column", c, size); } } } @@ -1763,9 +1768,11 @@ export function rowColumnOperationInitial(){ Store.jfredo.push({ "type": "resize", "ctrlType": type, + "sheetIndex": Store.currentSheetIndex, "config": $.extend(true, {}, Store.config), "curconfig": $.extend(true, {}, cfg), - "sheetIndex": Store.currentSheetIndex + "images": $.extend(true, {}, imageCtrl.images), + "curImages": $.extend(true, {}, images) }); } @@ -1773,6 +1780,12 @@ export function rowColumnOperationInitial(){ Store.config = cfg; Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].config = Store.config; + //images + Store.luckysheetfile[getSheetIndex(Store.currentSheetIndex)].images = images; + server.saveParam("all", Store.currentSheetIndex, images, { "k": "images" }); + imageCtrl.images = images; + imageCtrl.allImagesShow(); + if(Store.luckysheetRightHeadClickIs == "row"){ server.saveParam("cg", Store.currentSheetIndex, cfg["rowlen"], { "k": "rowlen" }); jfrefreshgrid_rhcw(Store.flowdata.length, null); diff --git a/src/global/extend.js b/src/global/extend.js index 5af0a94..23b2eca 100644 --- a/src/global/extend.js +++ b/src/global/extend.js @@ -265,7 +265,9 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { } if(newFilterObj != null && newFilterObj.filter != null){ - cfg["rowhidden"] = {}; + if(cfg["rowhidden"] == null){ + cfg["rowhidden"] = {}; + } for(let k in newFilterObj.filter){ let f_rowhidden = newFilterObj.filter[k].rowhidden; @@ -275,9 +277,6 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { } } } - else{ - delete cfg["rowhidden"]; - } //条件格式配置变动 let CFarr = file.luckysheet_conditionformat_save; @@ -541,6 +540,32 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { cfg["rowlen"] = rowlen_new; } + //隐藏行配置变动 + if(cfg["rowhidden"] != null){ + let rowhidden_new = {}; + + for(let r in cfg["rowhidden"]){ + r = parseFloat(r); + + if(r < index){ + rowhidden_new[r] = cfg["rowhidden"][r]; + } + else if(r == index){ + if(direction == "lefttop"){ + rowhidden_new[(r + value)] = cfg["rowhidden"][r]; + } + else if(direction == "rightbottom"){ + rowhidden_new[r] = cfg["rowhidden"][r]; + } + } + else{ + rowhidden_new[(r + value)] = cfg["rowhidden"][r]; + } + } + + cfg["rowhidden"] = rowhidden_new; + } + //空行模板 let row = []; for(let c = 0; c < d[0].length; c++){ @@ -667,6 +692,32 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { cfg["columnlen"] = columnlen_new; } + //隐藏列配置变动 + if(cfg["colhidden"] != null){ + let colhidden_new = {}; + + for(let c in cfg["colhidden"]){ + c = parseFloat(c); + + if(c < index){ + colhidden_new[c] = cfg["colhidden"][c]; + } + else if(c == index){ + if(direction == "lefttop"){ + colhidden_new[(c + value)] = cfg["colhidden"][c]; + } + else if(direction == "rightbottom"){ + colhidden_new[c] = cfg["colhidden"][c]; + } + } + else{ + colhidden_new[(c + value)] = cfg["colhidden"][c]; + } + } + + cfg["colhidden"] = colhidden_new; + } + //空列模板 let col = []; for(let r = 0; r < d.length; r++){ @@ -1114,7 +1165,9 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) { } if(newFilterObj != null && newFilterObj.filter != null){ - cfg["rowhidden"] = {}; + if(cfg["rowhidden"] == null){ + cfg["rowhidden"] = {}; + } for(let k in newFilterObj.filter){ let f_rowhidden = newFilterObj.filter[k].rowhidden; @@ -1124,9 +1177,6 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) { } } } - else{ - delete cfg["rowhidden"]; - } //条件格式配置变动 let CFarr = file.luckysheet_conditionformat_save; @@ -1406,6 +1456,23 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) { cfg["rowlen"] = rowlen_new; + //隐藏行配置变动 + if(cfg["rowhidden"] == null){ + cfg["rowhidden"] = {}; + } + + let rowhidden_new = {}; + for(let r in cfg["rowhidden"]){ + if(r < st){ + rowhidden_new[r] = cfg["rowhidden"][r]; + } + else if(r > ed){ + rowhidden_new[r - slen] = cfg["rowhidden"][r]; + } + } + + cfg["rowhidden"] = rowhidden_new; + //边框配置变动 if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){ let borderInfo = []; @@ -1499,6 +1566,23 @@ function luckysheetdeletetable(type, st, ed, sheetIndex) { cfg["columnlen"] = columnlen_new; + //隐藏列配置变动 + if(cfg["colhidden"] == null){ + cfg["colhidden"] = {}; + } + + let colhidden_new = {}; + for(let c in cfg["colhidden"]){ + if(c < st){ + colhidden_new[c] = cfg["colhidden"][c]; + } + else if(c > ed){ + colhidden_new[c - slen] = cfg["colhidden"][c]; + } + } + + cfg["colhidden"] = colhidden_new; + //边框配置变动 if(cfg["borderInfo"] && cfg["borderInfo"].length > 0){ let borderInfo = []; @@ -1918,7 +2002,9 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, sheetIndex) { } if(newFilterObj != null && newFilterObj.filter != null){ - cfg["rowhidden"] = {}; + if(cfg["rowhidden"] == null){ + cfg["rowhidden"] = {}; + } for(let k in newFilterObj.filter){ let f_rowhidden = newFilterObj.filter[k].rowhidden; @@ -1928,9 +2014,6 @@ function luckysheetDeleteCell(type, str, edr, stc, edc, sheetIndex) { } } } - else{ - delete cfg["rowhidden"]; - } //条件格式配置变动 let CFarr = file.luckysheet_conditionformat_save;