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 | 1×
1×
1×
1×
886×
886×
1×
46×
46×
46×
46×
46×
46×
46×
46×
83×
74×
1×
12×
12×
12×
12×
12×
12×
12×
12×
12×
1×
885×
885×
1×
886×
886×
886×
1×
885×
12×
12×
12×
1×
26×
26×
26×
26×
26×
2×
4×
26×
675×
6174×
26×
25×
1×
126650×
1×
1×
| define(["require", "exports", "../base/index", "../common/index", "../common/index", "../common/index", "@syncfusion/ej2-base"], function (require, exports, index_1, index_2, index_3, index_4, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var WorkbookProtectSheet = (function () {
function WorkbookProtectSheet(workbook) {
this.parent = workbook;
this.addEventListener();
}
WorkbookProtectSheet.prototype.protectsheetHandler = function (args) {
var sheetIndex = ej2_base_1.isNullOrUndefined(args.sheetIndex) ? this.parent.activeSheetIndex : args.sheetIndex;
var sheet = index_1.getSheet(this.parent, sheetIndex);
this.parent.setSheetPropertyOnMute(sheet, 'isProtected', true);
this.parent.setSheetPropertyOnMute(sheet, 'protectSettings', {
selectCells: args.protectSettings.selectCells, formatCells: args.protectSettings.formatCells,
formatColumns: args.protectSettings.formatColumns, formatRows: args.protectSettings.formatRows,
insertLink: args.protectSettings.insertLink, selectUnLockedCells: args.protectSettings.selectUnLockedCells
});
this.parent.notify(index_2.protectSheetWorkBook, { sheetIndex: sheetIndex, triggerEvent: args.triggerEvent });
this.parent.notify(index_2.updateToggle, { props: 'Protect' });
sheet.password = args.password ? args.password : '';
sheet.columns.forEach(function (column) {
if (column && ej2_base_1.isUndefined(column.isLocked)) {
column.isLocked = true;
}
});
};
WorkbookProtectSheet.prototype.unprotectsheetHandler = function (args) {
var sheet = this.parent.getActiveSheet();
Eif (!ej2_base_1.isNullOrUndefined(args.sheet)) {
sheet = this.parent.sheets[args.sheet];
}
Iif (sheet.isImportProtected) {
sheet.isImportProtected = false;
}
sheet.protectSettings.formatCells = sheet.protectSettings.formatColumns = false;
sheet.protectSettings.formatRows = sheet.protectSettings.selectCells = false;
this.parent.setSheetPropertyOnMute(sheet, 'isProtected', false);
this.parent.notify(index_2.protectSheetWorkBook, sheet.protectSettings);
this.parent.notify(index_2.updateToggle, { props: 'Protect' });
};
WorkbookProtectSheet.prototype.destroy = function () {
this.removeEventListener();
this.parent = null;
};
WorkbookProtectSheet.prototype.addEventListener = function () {
this.parent.on(index_2.protectsheetHandler, this.protectsheetHandler, this);
this.parent.on(index_3.unprotectsheetHandler, this.unprotectsheetHandler, this);
this.parent.on(index_2.setLockCells, this.lockCells, this);
};
WorkbookProtectSheet.prototype.removeEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.off(index_2.protectsheetHandler, this.protectsheetHandler);
this.parent.off(index_2.setLockCells, this.lockCells);
this.parent.off(index_2.protectsheetHandler, this.unprotectsheetHandler);
}
};
WorkbookProtectSheet.prototype.lockCells = function (args) {
var addressInfo = this.parent.getAddressInfo(args.range);
var indexes = index_4.getSwapRange(addressInfo.indices);
var sheet = index_1.getSheet(this.parent, addressInfo.sheetIndex);
var isLocked = args.isLocked ? args.isLocked : false;
if (indexes[0] === 0 && indexes[2] === sheet.rowCount - 1) {
for (var i = indexes[1]; i <= indexes[3]; i++) {
index_1.setColumn(sheet, i, { isLocked: args.isLocked });
}
}
for (var i = indexes[0]; i <= indexes[2]; i++) {
for (var j = indexes[1]; j <= indexes[3]; j++) {
index_1.setCell(i, j, sheet, { isLocked: isLocked }, true);
}
}
if (args.triggerEvent) {
this.parent.notify('actionComplete', { action: 'lockCells', eventArgs: args });
}
};
WorkbookProtectSheet.prototype.getModuleName = function () {
return 'workbookProtectSheet';
};
return WorkbookProtectSheet;
}());
exports.WorkbookProtectSheet = WorkbookProtectSheet;
});
|