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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153 | 1×
1×
1×
1×
881×
881×
1×
259×
259×
259×
259×
30×
30×
30×
112×
107×
107×
106×
1×
105×
101×
101×
101×
101×
101×
1×
1×
1×
100×
101×
101×
101×
1×
101×
101×
1×
1×
101×
4×
1×
1×
112×
117×
112×
112×
112×
1×
111×
107×
107×
106×
106×
1×
106×
106×
106×
106×
1×
107×
107×
1×
1×
107×
4×
117×
259×
259×
94×
94×
94×
165×
93×
93×
1×
259×
259×
259×
259×
9127×
126280×
126280×
3×
3×
1×
881×
1×
881×
881×
1×
881×
13×
1×
126650×
1×
1×
| define(["require", "exports", "../common/index", "../../workbook/index", "../../workbook/index", "../../workbook/index"], function (require, exports, index_1, index_2, index_3, index_4) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Insert = (function () {
function Insert(parent) {
this.parent = parent;
this.addEventListener();
}
Insert.prototype.insert = function (actionArgs) {
var args = actionArgs.eventArgs;
this.parent.notify(index_2.beforeInsert, args);
var sheet = index_3.getSheet(this.parent, args.activeSheetIndex);
switch (args.modelType) {
case 'Sheet':
this.parent.notify(index_1.insertSheetTab, { startIdx: args.index, endIdx: args.index + (args.model.length - 1), preventUpdate: !args.isAction });
this.parent.renderModule.refreshSheet();
break;
case 'Row':
if (args.activeSheetIndex === this.parent.activeSheetIndex) {
var frozenRow = this.parent.frozenRowCount(sheet);
if (!this.parent.scrollSettings.enableVirtualization ||
args.index <= this.parent.viewport.bottomIndex) {
if (args.freezePane) {
this.parent.renderModule.refreshSheet(false, false, true);
}
else if (this.parent.scrollSettings.enableVirtualization) {
var frozenCol = this.parent.frozenColCount(sheet);
Eif (args.index >= this.parent.viewport.topIndex + frozenRow) {
var frozenIndexes = [];
var colIndex = void 0;
if (frozenCol) {
colIndex = index_3.getCellIndexes(sheet.topLeftCell)[1];
frozenIndexes.push(frozenRow);
frozenIndexes.push(this.parent.viewport.leftIndex + frozenCol);
}
else {
colIndex = this.parent.viewport.leftIndex;
}
var prevColIdx = this.parent.viewport.leftIndex;
this.parent.renderModule.refreshUI({
rowIndex: this.parent.viewport.topIndex, colIndex: colIndex, refresh: 'Row',
frozenIndexes: frozenIndexes, skipUpdateOnFirst: this.parent.viewport.topIndex +
frozenRow === index_4.skipHiddenIdx(sheet, frozenRow, true)
});
if (frozenCol) {
this.parent.viewport.leftIndex = prevColIdx;
}
}
var topIdx = index_3.getCellIndexes(sheet.paneTopLeftCell)[0];
if (args.index < topIdx) {
this.parent.notify(index_1.updateScrollValue, { scrollTop: index_2.getRowsHeight(sheet, frozenRow, topIdx - 1, true) });
this.parent.goTo(index_3.getCellAddress(args.index, index_4.skipHiddenIdx(sheet, frozenCol, true, 'columns')));
}
this.parent.selectRange(sheet.selectedRange);
}
else {
this.parent.renderModule.refreshSheet(false, false, true);
}
}
else Eif (this.parent.scrollSettings.isFinite && (this.parent.viewport.topIndex + frozenRow ===
index_4.skipHiddenIdx(sheet, 0, true) || this.parent.viewport.bottomIndex === index_4.skipHiddenIdx(sheet, sheet.rowCount - args.model.length - 1, false))) {
this.parent.renderModule.refreshSheet(false, false, true);
}
}
break;
case 'Column':
if (args.activeSheetIndex === this.parent.activeSheetIndex) {
var frozenCol = this.parent.frozenColCount(sheet);
Eif (!this.parent.scrollSettings.enableVirtualization || args.index <= this.parent.viewport.rightIndex) {
if (args.freezePane) {
this.parent.renderModule.refreshSheet(false, false, true);
}
else if (this.parent.scrollSettings.enableVirtualization) {
var frozenRow = this.parent.frozenRowCount(sheet);
if (args.index >= this.parent.viewport.leftIndex + frozenCol) {
var frozenIndexes = [];
if (frozenRow) {
frozenIndexes = [frozenRow + this.parent.viewport.topIndex, frozenCol];
}
var rowIndex = frozenRow ? index_3.getCellIndexes(sheet.topLeftCell)[0] : this.parent.viewport.topIndex;
var prevRowIdx = this.parent.viewport.topIndex;
this.parent.renderModule.refreshUI({ skipUpdateOnFirst: this.parent.viewport.leftIndex + frozenCol === index_4.skipHiddenIdx(sheet, frozenCol, true, 'columns'), rowIndex: rowIndex, colIndex: this.parent.viewport.leftIndex,
refresh: 'Column', frozenIndexes: frozenIndexes });
if (frozenRow) {
this.parent.viewport.topIndex = prevRowIdx;
}
}
var leftIdx = index_3.getCellIndexes(sheet.paneTopLeftCell)[1];
if (args.index < leftIdx) {
this.parent.notify(index_1.updateScrollValue, { scrollLeft: index_3.getColumnsWidth(sheet, 0, leftIdx - 1, true) });
this.parent.goTo(index_3.getCellAddress(index_4.skipHiddenIdx(sheet, frozenRow, true), args.index));
}
this.parent.selectRange(sheet.selectedRange);
}
else {
this.parent.renderModule.refreshSheet(false, false, true);
}
}
else if (this.parent.scrollSettings.isFinite && (this.parent.viewport.leftIndex + frozenCol ===
index_4.skipHiddenIdx(sheet, 0, true, 'columns') || this.parent.viewport.rightIndex === index_4.skipHiddenIdx(sheet, sheet.colCount - args.model.length - 1, false, 'columns'))) {
this.parent.renderModule.refreshSheet(false, false, true);
}
}
break;
}
this.refreshImgElement(args.model.length, this.parent.activeSheetIndex, args.modelType, args.index);
if (args.isAction) {
delete args.isAction;
this.parent.notify(index_1.completeAction, actionArgs);
index_1.focus(this.parent.element);
}
else if (!args.isUndoRedo) {
args.isMethod = true;
this.parent.notify(index_2.triggerDataChange, actionArgs);
}
};
Insert.prototype.refreshImgElement = function (count, sheetIdx, modelType, index) {
var sheet = this.parent.sheets[sheetIdx];
var cellObj;
var indexes = [0, 0, sheet.usedRange.rowIndex, sheet.usedRange.colIndex];
for (var i = 0; i <= indexes[2]; i++) {
for (var j = indexes[1]; j <= indexes[3]; j++) {
cellObj = index_3.getCell(i, j, sheet);
if (cellObj && cellObj.image && cellObj.image.length > 0) {
Eif ((modelType === 'Row' && i >= index) || (modelType === 'Column' && j >= index)) {
this.parent.notify(index_1.refreshImagePosition, {
rowIdx: i, colIdx: j, sheetIdx: sheetIdx, type: modelType, count: count, status: 'insert'
});
}
}
}
}
};
Insert.prototype.addEventListener = function () {
this.parent.on(index_2.insert, this.insert, this);
};
Insert.prototype.destroy = function () {
this.removeEventListener();
this.parent = null;
};
Insert.prototype.removeEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.off(index_2.insert, this.insert);
}
};
Insert.prototype.getModuleName = function () {
return 'insert';
};
return Insert;
}());
exports.Insert = Insert;
});
|