1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 | 1×
1×
1×
1×
883×
883×
1×
984×
1×
496×
1×
90×
90×
87×
87×
87×
1×
1×
1×
87×
87×
87×
17×
87×
12×
12×
2×
10×
10×
10×
2×
10×
10×
5×
75×
75×
75×
53×
53×
53×
53×
75×
75×
75×
57×
57×
57×
57×
75×
5×
75×
1×
85×
85×
85×
85×
1×
883×
883×
883×
1×
883×
14×
14×
14×
1×
883×
883×
1×
126650×
1×
1×
| define(["require", "exports", "../../workbook/common/event", "../common/index", "../../workbook/index"], function (require, exports, event_1, index_1, index_2) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var NumberFormat = (function () {
function NumberFormat(parent) {
this.parent = parent;
this.addEventListener();
}
NumberFormat.prototype.refreshCellElement = function (args) {
this.parent.refreshNode(args.td, args);
};
NumberFormat.prototype.getTextSpace = function (args) {
args.width = index_1.getTextWidth(args.char, args.cell.style, this.parent.cellStyle);
};
NumberFormat.prototype.rowFillHandler = function (args) {
var cellElem = args.cellEle;
if (cellElem) {
var repeatCharSpan = void 0;
var endCol = args.colIdx;
if (args.cell.colSpan > 1) {
var mergeArgs = { range: [args.rowIdx, args.colIdx, args.rowIdx, args.colIdx] };
this.parent.notify(index_2.activeCellMergedRange, mergeArgs);
endCol = mergeArgs.range[3];
}
var cellWidth = index_1.getExcludedColumnWidth(this.parent.getActiveSheet(), args.rowIdx, args.colIdx, endCol);
var iconSetSpan = args.iconSetSpan || cellElem.querySelector('.e-iconsetspan');
if (iconSetSpan) {
cellWidth -= iconSetSpan.getBoundingClientRect().width;
}
if (args.updateFillSize) {
repeatCharSpan = cellElem.querySelector('.e-fill');
if (!repeatCharSpan || !repeatCharSpan.textContent) {
return;
}
args.repeatChar = repeatCharSpan.textContent[0];
var beforeSpan = cellElem.querySelector('.e-fill-before');
if (beforeSpan) {
cellWidth -= index_1.getTextWidth(beforeSpan.textContent, args.cell.style, this.parent.cellStyle);
}
var textSpan = cellElem.querySelector('.e-fill-sec');
if (textSpan) {
cellWidth -= index_1.getTextWidth(textSpan.textContent, args.cell.style, this.parent.cellStyle);
}
}
else {
var noteIndicator = cellElem.querySelector('.e-addNoteIndicator');
cellElem.innerText = '';
if (args.beforeFillText) {
var beforeSpan = this.parent.createElement('span', { className: 'e-fill-before', styles: "float: " + (this.parent.enableRtl ? 'right' : 'left') });
beforeSpan.innerText = args.beforeFillText;
cellElem.appendChild(beforeSpan);
cellWidth -= index_1.getTextWidth(args.beforeFillText, args.cell.style, this.parent.cellStyle);
}
repeatCharSpan = this.parent.createElement('span', { className: 'e-fill' });
cellElem.appendChild(repeatCharSpan);
if (args.afterFillText) {
var textSpan = this.parent.createElement('span', { className: 'e-fill-sec' });
textSpan.innerText = args.afterFillText;
cellElem.appendChild(textSpan);
cellWidth -= index_1.getTextWidth(args.afterFillText, args.cell.style, this.parent.cellStyle);
}
if (iconSetSpan) {
cellElem.insertBefore(iconSetSpan, cellElem.childNodes[0]);
}
if (noteIndicator) {
cellElem.appendChild(noteIndicator);
}
}
var repeatCharWidth = index_1.getTextWidth(args.repeatChar, args.cell.style, this.parent.cellStyle);
var repeatCount = parseInt((cellWidth / repeatCharWidth).toString(), 10);
args.formattedText = repeatCount > 0 ? args.repeatChar.repeat(repeatCount) : '';
repeatCharSpan.textContent = args.formattedText;
}
};
NumberFormat.prototype.addEventListener = function () {
this.parent.on(event_1.refreshCellElement, this.refreshCellElement, this);
this.parent.on(event_1.rowFillHandler, this.rowFillHandler, this);
this.parent.on(event_1.getTextSpace, this.getTextSpace, this);
};
NumberFormat.prototype.removeEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.off(event_1.refreshCellElement, this.refreshCellElement);
this.parent.off(event_1.rowFillHandler, this.rowFillHandler);
this.parent.off(event_1.getTextSpace, this.getTextSpace);
}
};
NumberFormat.prototype.destroy = function () {
this.removeEventListener();
this.parent = null;
};
NumberFormat.prototype.getModuleName = function () {
return 'numberFormat';
};
return NumberFormat;
}());
exports.NumberFormat = NumberFormat;
});
|