wpxp123456 5 years ago
parent
commit
3933c8a1f3
  1. 12
      src/controllers/handler.js
  2. 231
      src/controllers/menuButton.js
  3. 65
      src/controllers/rowColumnOperation.js
  4. 10
      src/controllers/server.js
  5. 7
      src/controllers/updateCell.js
  6. 2
      src/global/draw.js
  7. 7
      src/global/formula.js
  8. 40
      src/global/getRowlen.js
  9. 240
      src/global/getdata.js

12
src/controllers/handler.js

@ -3146,6 +3146,12 @@ export default function luckysheetHandler() {
cfg["rowlen"] = {};
}
if (cfg["customHeight"] == null) {
cfg["customHeight"] = {};
}
cfg["customHeight"][Store.luckysheet_rows_change_size_start[1]] = 1;
cfg["rowlen"][Store.luckysheet_rows_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
let images = imageCtrl.moveChangeSize("row", Store.luckysheet_rows_change_size_start[1], size);
@ -3222,6 +3228,12 @@ export default function luckysheetHandler() {
cfg["columnlen"] = {};
}
if (cfg["customWidth"] == null) {
cfg["customWidth"] = {};
}
cfg["customWidth"][Store.luckysheet_cols_change_size_start[1]] = 1;
cfg["columnlen"][Store.luckysheet_cols_change_size_start[1]] = Math.ceil(size/Store.zoomRatio);
let images = imageCtrl.moveChangeSize("column", Store.luckysheet_cols_change_size_start[1], size);

231
src/controllers/menuButton.js

@ -26,6 +26,7 @@ import { rowLocationByIndex, colLocationByIndex } from '../global/location';
import { isdatatypemulti } from '../global/datecontroll';
import { rowlenByRange, getCellTextSplitArr } from '../global/getRowlen';
import { setcellvalue } from '../global/setdata';
import { getFontStyleByCell, checkstatusByCell} from '../global/getdata';
import { countfunc } from '../global/count';
import { getSheetIndex, getRangetxt, getluckysheetfile } from '../methods/get';
import { setluckysheetfile } from '../methods/set';
@ -3312,165 +3313,9 @@ const menuButton = {
}
}
},
checkstatusByCell:function(cell, a){
let foucsStatus =cell;
let tf = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1};
if(a in tf){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "fc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
if(foucsStatus.indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a == "bg"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
else if(foucsStatus.toString().indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a.substr(0, 2) == "bs"){
if(foucsStatus == null){
foucsStatus = "none";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "none";
}
}
}
else if(a.substr(0, 2) == "bc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
}
}
else if(a == "ht"){
if(foucsStatus == null){
foucsStatus = "1";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "1";
}
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "1";
}
}
else if(a == "vt"){
if(foucsStatus == null){
foucsStatus = "2";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "2";
}
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "2";
}
}
else if(a == "ct"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
else if(a == "fs"){
if(foucsStatus == null){
foucsStatus = "10";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "10";
}
}
}
else if(a == "tb"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "tr"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "rt"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
return foucsStatus;
},
checkstatus: function(d, r, c, a){
let foucsStatus = d[r][c];
return this.checkstatusByCell(foucsStatus, a);
return checkstatusByCell(foucsStatus, a);
},
setLineDash: function(canvasborder, type, hv, m_st, m_ed, line_st, line_ed){
let borderType = {
@ -4232,6 +4077,10 @@ const menuButton = {
const locale_fontarray = locale().fontarray;
let cell = d[r][c];
let ct = cell.ct, isInline=false;
if(ct!=null && ct.t=="inlineStr" && ct.s!=null && ct.s.length>0){
isInline = true;
}
for(let key in cell){
let value = _this.checkstatus(d, r, c , key);
@ -4260,37 +4109,39 @@ const menuButton = {
}
}
if(key == "bl" && value != "0"){
style += "font-weight: bold;";
}
if(key == "it" && value != "0"){
style += "font-style:italic;";
}
if(key == "ff" && value != "0"){
let f = value;
if(!isNaN(parseInt(value))){
f = locale_fontarray[parseInt(value)];
}
style += "font-family: " + f + ";";
}
if(key == "fs" && value != "10"){
style += "font-size: "+ value + "pt;";
}
if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
if(checksCF != null && checksCF["textColor"] != null){
style += "color: " + checksCF["textColor"] + ";";
}
else if(checksAF != null){
style += "color: " + checksAF[0] + ";";
}
else{
style += "color: " + value + ";";
}
}
// if(!isInline){
// if(key == "bl" && value != "0"){
// style += "font-weight: bold;";
// }
// if(key == "it" && value != "0"){
// style += "font-style:italic;";
// }
// if(key == "ff" && value != "0"){
// let f = value;
// if(!isNaN(parseInt(value))){
// f = locale_fontarray[parseInt(value)];
// }
// style += "font-family: " + f + ";";
// }
// if(key == "fs" && value != "10"){
// style += "font-size: "+ value + "pt;";
// }
// if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
// if(checksCF != null && checksCF["textColor"] != null){
// style += "color: " + checksCF["textColor"] + ";";
// }
// else if(checksAF != null){
// style += "color: " + checksAF[0] + ";";
// }
// else{
// style += "color: " + value + ";";
// }
// }
// }
if(key == "ht" && value != "1"){
if(value == "0"){
@ -4311,6 +4162,10 @@ const menuButton = {
}
}
if(!isInline){
style += getFontStyleByCell(cell,checksAF,checksCF);
}
return style;
}
}

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;

10
src/controllers/server.js

@ -714,13 +714,15 @@ const server = {
multipleRangeShow: function(id, name, r, c) {
let _this = this;
let r2 = Store.luckysheet_select_save[0].row[1],
c2 = Store.luckysheet_select_save[0].column[1];
let r1 = r2 = r;
let c1 = c2 = c;
let row = visibledatarow[r2],
row_pre = r1 - 1 == -1 ? 0 : visibledatarow[r1 - 1],
col = visibledatacolumn[c2],
col_pre = c1 - 1 == -1 ? 0 : visibledatacolumn[c1 - 1];
let row = Store.visibledatarow[r2],
row_pre = r1 - 1 == -1 ? 0 : Store.visibledatarow[r1 - 1],
col = Store.visibledatacolumn[c2],
col_pre = c1 - 1 == -1 ? 0 : Store.visibledatacolumn[c1 - 1];
let margeset = menuButton.mergeborer(Store.flowdata, r1, c1);
if(!!margeset){

7
src/controllers/updateCell.js

@ -6,7 +6,7 @@ import alternateformat from './alternateformat';
import dataVerificationCtrl from './dataVerificationCtrl';
import { chatatABC } from '../utils/util';
import { isEditMode } from '../global/validate';
import { getcellvalue } from '../global/getdata';
import { getcellvalue,getInlineStringStyle } from '../global/getdata';
import { valueShowEs } from '../global/format';
import formula from '../global/formula';
import { luckysheetRangeLast } from '../global/cursorPos';
@ -135,7 +135,10 @@ export function luckysheetupdateCell(row_index1, col_index1, d, cover, isnotfocu
if (!cover) {
if(cell.f!=null){
if(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0){
value = getInlineStringStyle(row_index, col_index, d);
}
else if(cell.f!=null){
value = getcellvalue(row_index, col_index, d, "f");
}
else{

2
src/global/draw.js

@ -1897,7 +1897,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;

7
src/global/formula.js

@ -10,7 +10,7 @@ import { seletedHighlistByindex, luckysheet_count_show } from '../controllers/se
import { isRealNum, isRealNull, valueIsError, isEditMode } from './validate';
import { isdatetime, isdatatype } from './datecontroll';
import { getCellTextSplitArr } from '../global/getRowlen';
import { getcellvalue,getcellFormula } from './getdata';
import { getcellvalue,getcellFormula,getInlineStringNoStyle } from './getdata';
import { setcellvalue } from './setdata';
import { genarate, valueShowEs } from './format';
import editor from './editor';
@ -325,7 +325,10 @@ const luckysheetformula = {
if (d[r] != null && d[r][c] != null) {
let cell = d[r][c];
if(cell.f != null){
if(cell.ct!=null && cell.ct.t=="inlineStr" && cell.ct.s!=null && cell.ct.s.length>0){
value = getInlineStringNoStyle(r, c);
}
else if(cell.f != null){
value = getcellvalue(r, c, d, "f");
}
else{

40
src/global/getRowlen.js

@ -1,6 +1,6 @@
import { luckysheetfontformat } from '../utils/util';
import menuButton from '../controllers/menuButton';
import { getcellvalue } from './getdata';
import { getcellvalue,checkstatusByCell } from './getdata';
import { colLocationByIndex } from './location';
import { hasChinaword, isRealNull } from './validate';
import Store from '../store';
@ -12,6 +12,10 @@ function rowlenByRange(d, r1, r2, cfg) {
cfg_clone["rowlen"] = {};
}
if(cfg_clone["customHeight"] == null){
cfg_clone["customHeight"] = {};
}
let canvas = $("#luckysheetTableContent").get(0).getContext("2d");
canvas.textBaseline = 'top'; //textBaseline以top计算
@ -25,6 +29,10 @@ function rowlenByRange(d, r1, r2, cfg) {
// currentRowLen = cfg_clone["rowlen"][r];
// }
if(cfg_clone["customHeight"][r]==1){
continue;
}
delete cfg_clone["rowlen"][r];
for(let c = 0; c < d[r].length; c++){
@ -269,13 +277,13 @@ function getCellTextInfo(cell , ctx, option){
}
//水平对齐
let horizonAlign = menuButton.checkstatusByCell(cell, "ht");
let horizonAlign = checkstatusByCell(cell, "ht");
//垂直对齐
let verticalAlign = menuButton.checkstatusByCell(cell, "vt");
let verticalAlign = checkstatusByCell(cell, "vt");
let tb = menuButton.checkstatusByCell(cell ,"tb");//wrap overflow
let tr = menuButton.checkstatusByCell(cell ,"tr");//rotate
let rt = menuButton.checkstatusByCell(cell ,"rt");//rotate angle
let tb = checkstatusByCell(cell ,"tb");//wrap overflow
let tr = checkstatusByCell(cell ,"tr");//rotate
let rt = checkstatusByCell(cell ,"rt");//rotate angle
let isRotateUp = 1, isRotateDown=0;
@ -380,8 +388,8 @@ function getCellTextInfo(cell , ctx, option){
fontset = luckysheetfontformat(cell);
ctx.font = fontset;
cancelLine = menuButton.checkstatusByCell(cell ,"cl");//cancelLine
underLine = menuButton.checkstatusByCell(cell ,"un");//underLine
cancelLine = checkstatusByCell(cell ,"cl");//cancelLine
underLine = checkstatusByCell(cell ,"un");//underLine
if(cell instanceof Object){
value = cell.m;
@ -423,11 +431,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 +455,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 +488,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 +606,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);

240
src/global/getdata.js

@ -5,6 +5,7 @@ import formula from './formula';
import editor from './editor';
import { dynamicArrayCompute } from './dynamicArray';
import sheetmanage from '../controllers/sheetmanage';
import locale from '../locale/locale';
import Store from '../store';
//Get selection range value
@ -276,4 +277,243 @@ export function getRealCellValue(r, c){
}
return value;
}
export function getInlineStringNoStyle(r, c){
let ct = getcellvalue(r, c, null, "ct");
if(ct!=null && ct.t=="inlineStr" && ct.s!=null && ct.s.length>0){
let strings = ct.s, value="";
for(let i=0;i<strings.length;i++){
let strObj = strings[i];
if(strObj.v!=null){
value += strObj.v;
}
}
return value;
}
return "";
}
export function getInlineStringStyle(r, c, data){
let ct = getcellvalue(r, c, data, "ct");
if (data == null) {
data = Store.flowdata;
}
let cell = data[r][c];
if(ct!=null && ct.t=="inlineStr" && ct.s!=null && ct.s.length>0){
let strings = ct.s, value="";
for(let i=0;i<strings.length;i++){
let strObj = strings[i];
if(strObj.v!=null){
let style = getFontStyleByCell(strObj);
value += "<span style='"+ style +"'>" + strObj.v + "</span>";
}
}
return value;
}
return "";
}
export function getFontStyleByCell(cell,checksAF,checksCF){
if(cell==null){
return;
}
let style = "";
const _locale = locale();
const locale_fontarray = _locale.fontarray;
for(let key in cell){
let value = checkstatusByCell(cell, key);
if(key == "bl" && value != "0"){
style += "font-weight: bold;";
}
if(key == "it" && value != "0"){
style += "font-style:italic;";
}
if(key == "ff" && value != "0"){
let f = value;
if(!isNaN(parseInt(value))){
f = locale_fontarray[parseInt(value)];
}
style += "font-family: " + f + ";";
}
if(key == "fs" && value != "10"){
style += "font-size: "+ value + "pt;";
}
if((key == "fc" && value != "#000000") || checksAF != null || (checksCF != null && checksCF["textColor"] != null)){
if(checksCF != null && checksCF["textColor"] != null){
style += "color: " + checksCF["textColor"] + ";";
}
else if(checksAF != null){
style += "color: " + checksAF[0] + ";";
}
else{
style += "color: " + value + ";";
}
}
}
return style;
}
export function checkstatusByCell(cell, a){
let foucsStatus =cell;
let tf = {"bl":1, "it":1 , "ff":1, "cl":1, "un":1};
if(a in tf){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "fc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
if(foucsStatus.indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a == "bg"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
else if(foucsStatus.toString().indexOf("rgba") > -1){
foucsStatus = rgbTohex(foucsStatus);
}
}
}
else if(a.substr(0, 2) == "bs"){
if(foucsStatus == null){
foucsStatus = "none";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "none";
}
}
}
else if(a.substr(0, 2) == "bc"){
if(foucsStatus == null){
foucsStatus = "#000000";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "#000000";
}
}
}
else if(a == "ht"){
if(foucsStatus == null){
foucsStatus = "1";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "1";
}
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "1";
}
}
else if(a == "vt"){
if(foucsStatus == null){
foucsStatus = "2";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "2";
}
}
if(["0", "1", "2"].indexOf(foucsStatus.toString()) == -1){
foucsStatus = "2";
}
}
else if(a == "ct"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
else if(a == "fs"){
if(foucsStatus == null){
foucsStatus = "10";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "10";
}
}
}
else if(a == "tb"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "tr"){
if(foucsStatus == null){
foucsStatus = "0";
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = "0";
}
}
}
else if(a == "rt"){
if(foucsStatus == null){
foucsStatus = null;
}
else{
foucsStatus = foucsStatus[a];
if(foucsStatus == null){
foucsStatus = null;
}
}
}
return foucsStatus;
}
Loading…
Cancel
Save