Browse Source

style(inline string): programing

master
wbfsa 5 years ago
parent
commit
592c1638c7
  1. 137
      src/global/getRowlen.js
  2. 40
      src/index.html

137
src/global/getRowlen.js

@ -294,6 +294,8 @@ function getCellTextInfo(cell , ctx, option){
isRotateDown = 1;
}
ctx.textAlign="start";
let textContent = {};
textContent.values = [];
@ -667,8 +669,8 @@ function getCellTextInfo(cell , ctx, option){
return textContent;
}
if(rt!=0 && isRotateUp=="1"){
ctx.textAlign="end";
for(let i = 0; i < splitLen; i++){
let splitLists = text_all_split[i];
if(splitLists==null){
@ -678,26 +680,26 @@ function getCellTextInfo(cell , ctx, option){
cumColumnWidth = 0;
for(let c=0;c<splitLists.length;c++){
for(let c=splitLists.length-1;c>=0;c--){
let wordGroup = splitLists[c];
let left, top;
if(rt!=0){//rotate
let x, y = cumWordHeight+size.asc;
if(isRotateUp=="1"){
// x = (cumWordHeight)/Math.tan(rtPI) + cumColumnWidth;
if(verticalAlign=="2"){
x = (cumWordHeight+size.height)/Math.tan(rtPI) + cumColumnWidth;
}
else if(verticalAlign=="0"){
x = (cumWordHeight+size.height/2)/Math.tan(rtPI) + cumColumnWidth;
}
else{
x = (cumWordHeight)/Math.tan(rtPI) + cumColumnWidth;
}
// if(verticalAlign=="2"){
// x = (cumWordHeight)/Math.tan(rtPI) - cumColumnWidth + textW_all_inner;
// }
// else if(verticalAlign=="0"){
// x = (cumWordHeight)/Math.tan(rtPI) - cumColumnWidth + textW_all_inner;
// }
// else{
// x = (cumWordHeight)/Math.tan(rtPI) - cumColumnWidth + textW_all_inner;
// }
if(horizonAlign == "0"){//center
let sh = textH_all/Math.sin(rtPI);
x = (cumWordHeight+size.height)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
x = (cumWordHeight)/Math.tan(rt*Math.PI/180) - cumColumnWidth + textW_all_inner;
if(verticalAlign == "0"){//mid
left = x + cellWidth/2 - (textW_all/2);
@ -713,25 +715,26 @@ function getCellTextInfo(cell , ctx, option){
}
}
else if(horizonAlign == "1"){//left
x = (cumWordHeight)/Math.tan(rtPI) - cumColumnWidth + textW_all_inner;
if(verticalAlign == "0"){//mid
left = x - rh*Math.sin(rtPI)/2;
top = y + cellHeight/2 + rh*Math.cos(rtPI)/2;
left = x - rh*Math.sin(rtPI)/2 + lastLineSpaceHeight*Math.cos(rtPI)/2;
top = y + cellHeight/2 + rh*Math.cos(rtPI)/2 - lastLineSpaceHeight*Math.sin(rtPI)/2;
}
else if(verticalAlign == "1"){//top
left = x - rh*Math.sin(rtPI);
top = y + rh*Math.cos(rtPI);
}
else if(verticalAlign == "2"){//bottom
left = x;
top = y + cellHeight;
left = x + lastLineSpaceHeight*Math.cos(rtPI);
top = y + cellHeight - lastLineSpaceHeight*Math.sin(rtPI);
}
}
else if(horizonAlign == "2"){//right
x = (cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
x = (cumWordHeight)/Math.tan(rtPI) - cumColumnWidth + textW_all_inner;
if(verticalAlign == "0"){//mid
// left = x + cellWidth - ( textH_all/Math.tan(rtPI) + (rh/2)*Math.sin(rtPI));
// top = y + cellHeight/2 - (textH_all - (rh/2)*Math.cos(rtPI));
left = x + cellWidth - rw/2 - (textW_all/2+(textH_all/2)/Math.tan(rtPI));
left = x + cellWidth - rw/2 - (textW_all_inner/2+(textH_all/2)/Math.tan(rtPI));
top = y + cellHeight/2 - textH_all/2;
}
else if(verticalAlign == "1"){//top fixOneLineLeft
@ -740,11 +743,102 @@ function getCellTextInfo(cell , ctx, option){
}
else if(verticalAlign == "2"){//bottom
left = x + cellWidth - rw*Math.cos(rtPI) + lastLineSpaceHeight*Math.cos(rtPI);
top = y + cellHeight - rw*Math.sin(rtPI) + lastLineSpaceHeight*Math.sin(rtPI);
top = y + cellHeight - rw*Math.sin(rtPI) - lastLineSpaceHeight*Math.sin(rtPI);
}
}
}
}
wordGroup.left = left;
wordGroup.top = top;
textContent.values.push(wordGroup);
}
cumWordHeight += size.height;
}
}
else{
for(let i = 0; i < splitLen; i++){
let splitLists = text_all_split[i];
if(splitLists==null){
continue;
}
let size = split_all_size[i];
cumColumnWidth = 0;
for(let c=0;c<splitLists.length;c++){
let wordGroup = splitLists[c];
let left, top;
if(rt!=0){//rotate
let x, y = cumWordHeight+size.asc;
// if(isRotateUp=="1"){
// // x = (cumWordHeight)/Math.tan(rtPI) + cumColumnWidth;
// if(verticalAlign=="2"){
// x = (cumWordHeight+size.height)/Math.tan(rtPI) + cumColumnWidth;
// }
// else if(verticalAlign=="0"){
// x = (cumWordHeight+size.height/2)/Math.tan(rtPI) + cumColumnWidth;
// }
// else{
// x = (cumWordHeight)/Math.tan(rtPI) + cumColumnWidth;
// }
// if(horizonAlign == "0"){//center
// let sh = textH_all/Math.sin(rtPI);
// x = (cumWordHeight+size.height)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// if(verticalAlign == "0"){//mid
// left = x + cellWidth/2 - (textW_all/2);
// top = y + cellHeight/2 - textH_all/2;
// }
// else if(verticalAlign == "1"){//top
// left = x + cellWidth/2 - textW_all/2- lastLineSpaceHeight*Math.cos(rtPI)/2;
// top = y - (textH_all/2 - rh/2) + lastLineSpaceHeight*Math.sin(rtPI)/2;
// }
// else if(verticalAlign == "2"){//bottom
// left = x + cellWidth/2 - (textW_all/2);
// top = y + cellHeight - rh/2-textH_all/2;
// }
// }
// else if(horizonAlign == "1"){//left
// if(verticalAlign == "0"){//mid
// left = x - rh*Math.sin(rtPI)/2;
// top = y + cellHeight/2 + rh*Math.cos(rtPI)/2;
// }
// else if(verticalAlign == "1"){//top
// left = x - rh*Math.sin(rtPI);
// top = y + rh*Math.cos(rtPI);
// }
// else if(verticalAlign == "2"){//bottom
// left = x;
// top = y + cellHeight;
// }
// }
// else if(horizonAlign == "2"){//right
// x = (cumWordHeight)/Math.tan(rt*Math.PI/180) + cumColumnWidth;
// if(verticalAlign == "0"){//mid
// // left = x + cellWidth - ( textH_all/Math.tan(rtPI) + (rh/2)*Math.sin(rtPI));
// // top = y + cellHeight/2 - (textH_all - (rh/2)*Math.cos(rtPI));
// left = x + cellWidth - rw/2 - (textW_all/2+(textH_all/2)/Math.tan(rtPI));
// top = y + cellHeight/2 - textH_all/2;
// }
// else if(verticalAlign == "1"){//top fixOneLineLeft
// left = x + cellWidth - textW_all + lastLine.height*Math.cos(rtPI)/2;
// top = y - textH_all + lastLine.height*Math.sin(rtPI)/2;
// }
// else if(verticalAlign == "2"){//bottom
// left = x + cellWidth - rw*Math.cos(rtPI) + lastLineSpaceHeight*Math.cos(rtPI);
// top = y + cellHeight - rw*Math.sin(rtPI) - lastLineSpaceHeight*Math.sin(rtPI);
// }
// }
// }
// else{
x = (textH_all-cumWordHeight)/Math.tan(rtPI) + cumColumnWidth;
if(horizonAlign == "0"){//center
@ -795,7 +889,7 @@ function getCellTextInfo(cell , ctx, option){
top = y + cellHeight - rw*Math.sin(rtPI);
}
}
}
// }
// let x, y = cumWordHeight; //+ wordGroup.textHeight / Math.sin(rt*Math.PI/180)*isRotateDown;
// if(isRotateUp=="1"){
@ -892,6 +986,7 @@ function getCellTextInfo(cell , ctx, option){
}
}
textContent.type = "plainWrap";

40
src/index.html

@ -30,6 +30,46 @@
import sheetSparkline from './demoData/sheetSparkline.js'
import sheetChart from './demoData/sheetChart.js'
$(function () {
// [sheetCell,sheetFormula,sheetConditionFormat,sheetSparkline,sheetTable,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart]
// [{"name":"Sheet1","config":{"columnlen":{"0":241},"rowlen":{"0":81}},"index":"1","status":"1","order":"0","luckysheet_select_save":[{"row":[0,0],"column":[4,4],"sheetIndex":1}],"zoomRatio":1,"showGridLines":"1","defaultColWidth":72,"defaultRowHeight":18,"celldata":[
// {"r":0,"c":0,
// "v":{
// "ct":{
// "fa":"General",
// "t":"inlineStr",
// "sharedStrings":[
// {
// "ff":"等线", //font family
// "fc":"#fff000",//font color
// "fs":12,//font size
// "cl":1,//strike
// "un":0,//underline
// "bl":0,//blod
// "it":1,//italic
// v:"我在\r\n"
// },
// {
// "ff":"等线", //font family
// "fc":"#ff0000",//font color
// "fs":14,//font size
// "cl":"1",//strike
// "un":"0",//underline
// "bl":"1",//blod
// "it":"0",//italic
// v:"马路边"
// },
// ]
// },
// "fs":11,
// "ff":"等线",
// "vt":0,
// "tb":2,
// "v":"",
// "qp":1,
// }
// },
// {"r":17,"c":2,"v":{"v":"Luckysheet","ct":{"fa":"General","t":"g"},"bg":null,"bl":0,"it":0,"ff":0,"fs":"11","fc":"rgb(51, 51, 51)","ht":1,"vt":1,"m":"Luckysheet"}}
// ],"calcChain":[]}]
luckysheet.create({
container: 'luckysheet',

Loading…
Cancel
Save