define(["require", "exports", "../common/index", "../base/index", "../common/event", "@syncfusion/ej2-base"], function (require, exports, index_1, index_2, event_1, ej2_base_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var WorkbookImage = (function () {
function WorkbookImage(parent) {
this.parent = parent;
this.addEventListener();
}
WorkbookImage.prototype.setImage = function (args) {
var lastIndex = args.range ? args.range.lastIndexOf('!') : -1;
var imgRange = args.range ? (lastIndex > -1) ? args.range.substring(lastIndex + 1) : args.range
: this.parent.getActiveSheet().selectedRange;
var sheetIdx = (args.range && lastIndex > -1) ?
index_2.getSheetIndex(this.parent, args.range.substring(0, lastIndex)) : this.parent.activeSheetIndex;
var indexes = index_1.getRangeIndexes(imgRange);
var sheet = ej2_base_1.isUndefined(sheetIdx) ? this.parent.getActiveSheet() : index_2.getSheet(this.parent, sheetIdx);
var cell = index_2.getCell(indexes[0], indexes[1], sheet);
var oldImgData;
var imgData = args.options;
if (cell && cell.image) {
oldImgData = cell.image;
for (var i = 0; i < imgData.length; i++) {
oldImgData.push(imgData[i]);
}
}
index_2.setCell(indexes[0], indexes[1], sheet, { image: (cell && cell.image) ? oldImgData : imgData }, true);
};
WorkbookImage.prototype.addEventListener = function () {
this.parent.on(event_1.setImage, this.setImage, this);
};
WorkbookImage.prototype.removeEventListener = function () {
if (!this.parent.isDestroyed) {
this.parent.off(event_1.setImage, this.setImage);
}
};
WorkbookImage.prototype.destroy = function () {
this.removeEventListener();
this.parent = null;
};
WorkbookImage.prototype.getModuleName = function () {
return 'workbookImage';
};
return WorkbookImage;
}());
exports.WorkbookImage = WorkbookImage;
});
|