From 760378b369b9bf71da0182ea3b413a0accb23c38 Mon Sep 17 00:00:00 2001 From: liuyang Date: Wed, 14 Oct 2020 11:14:51 +0800 Subject: [PATCH] fix(lineheight change to 0.5): similar to excel --- src/controllers/inlineString.js | 14 +++++++------- src/controllers/select.js | 34 ++++++++++++++++++++++++++------- src/controllers/sheetmanage.js | 2 +- src/global/getRowlen.js | 4 ++-- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/controllers/inlineString.js b/src/controllers/inlineString.js index 8884ab600..48013e570 100644 --- a/src/controllers/inlineString.js +++ b/src/controllers/inlineString.js @@ -372,20 +372,20 @@ export function convertCssToStyleList(cssText){ return {}; } let cssTextArray = cssText.split(";"); + + + const _locale = locale(); + const locale_fontarray = _locale.fontarray; + const locale_fontjson = _locale.fontjson; let styleList = { - "ff":"Arial", //font family + "ff":locale_fontarray[0], //font family "fc":"#000000",//font color - "fs":12,//font size + "fs":10,//font size "cl":0,//strike "un":0,//underline "bl":0,//blod "it":0,//italic }; - - const _locale = locale(); - const locale_fontarray = _locale.fontarray; - const locale_fontjson = _locale.fontjson; - cssTextArray.forEach(s => { s = s.toLowerCase(); let key = textTrim(s.substr(0, s.indexOf(':'))); diff --git a/src/controllers/select.js b/src/controllers/select.js index e726e2151..416baa733 100644 --- a/src/controllers/select.js +++ b/src/controllers/select.js @@ -24,7 +24,7 @@ function seletedHighlistByindex(id, r1, r2, c1, c2) { } //Set selection highlight -function selectHightlightShow() { +function selectHightlightShow(isRestore=false) { $("#luckysheet-cell-selected-boxs").show(); $("#luckysheet-cell-selected-boxs #luckysheet-cell-selected").siblings(".luckysheet-cell-selected").remove(); @@ -80,10 +80,19 @@ function selectHightlightShow() { Store.luckysheet_select_save[i]["top"] = row_pre_f; Store.luckysheet_select_save[i]["height"] = row_f - row_pre_f - 1; - Store.luckysheet_select_save[i]["left_move"] = col_pre; - Store.luckysheet_select_save[i]["width_move"] = col - col_pre - 1; - Store.luckysheet_select_save[i]["top_move"] = row_pre; - Store.luckysheet_select_save[i]["height_move"] = row - row_pre - 1; + if(isRestore){ + Store.luckysheet_select_save[i]["left_move"] = col_pre_f; + Store.luckysheet_select_save[i]["width_move"] = col_f - col_pre_f - 1; + Store.luckysheet_select_save[i]["top_move"] = row_pre_f; + Store.luckysheet_select_save[i]["height_move"] = row_f - row_pre_f - 1; + } + else{ + + Store.luckysheet_select_save[i]["left_move"] = col_pre; + Store.luckysheet_select_save[i]["width_move"] = col - col_pre - 1; + Store.luckysheet_select_save[i]["top_move"] = row_pre; + Store.luckysheet_select_save[i]["height_move"] = row - row_pre - 1; + } if(i == 0){ if(Store.luckysheet_select_save.length == 1){ @@ -170,7 +179,7 @@ function selectHightlightShow() { } //行列标题栏 - selectTitlesShow(Store.luckysheet_select_save); + selectTitlesShow(Store.luckysheet_select_save,isRestore); //左上角范围显示 selectHelpboxFill(); @@ -185,13 +194,24 @@ function selectHightlightShow() { } //选区标题栏 -function selectTitlesShow(rangeArr) { +function selectTitlesShow(rangeArr,isRestore=false) { let s = $.extend(true, [], rangeArr); let rowTitleMap = {}, columnTitleMap = {}; for(let i = 0; i < s.length; i++){ let r1 = s[i]["row"][0], r2 = s[i]["row"][1], c1 = s[i]["column"][0], c2 = s[i]["column"][1]; + if(isRestore){ + let margeset = menuButton.mergeborer(Store.flowdata, r1, c1); + if(!!margeset){ + r1 = margeset.row[2]; + r2 = margeset.row[3]; + + c1 = margeset.column[2]; + c2 = margeset.column[3]; + } + } + //行、列标题栏 rowTitleMap = selectTitlesMap(rowTitleMap, r1, r2); columnTitleMap = selectTitlesMap(columnTitleMap, c1, c2); diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js index 29af1a2f6..6b3e5482b 100644 --- a/src/controllers/sheetmanage.js +++ b/src/controllers/sheetmanage.js @@ -917,7 +917,7 @@ const sheetmanage = { let file = Store.luckysheetfile[index]; //选区 - selectHightlightShow(); + selectHightlightShow(true); //复制选区虚线框 selectionCopyShow(); diff --git a/src/global/getRowlen.js b/src/global/getRowlen.js index ca738825d..b7e1e76f1 100644 --- a/src/global/getRowlen.js +++ b/src/global/getRowlen.js @@ -982,7 +982,7 @@ function getCellTextInfo(cell , ctx, option){ maxWordCount++; } - lineHeight = sHeight/1.5; + lineHeight = sHeight/2; oneLinemaxWordCount = Math.max(oneLinemaxWordCount, maxWordCount); if(rt!=0){//rotate sHeight+=lineHeight; @@ -1334,7 +1334,7 @@ function getCellTextInfo(cell , ctx, option){ textContent.textHeightAll = textHeightAll; } else{ - textContent.textHeightAll = textHeightAll+textHeight/1.5-measureText.actualBoundingBoxDescent-space_height; + textContent.textHeightAll = textHeightAll+textHeight/2-measureText.actualBoundingBoxDescent-space_height; } textContent.textWidthAll = textWidthAll;