igniteui-angular-spreadsheet
Version:
Ignite UI Angular spreadsheet component for displaying and editing Microsoft Excel workbooks for modern web apps.
102 lines (101 loc) • 4.79 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { Base, Stream, typeCast, markType } from "igniteui-angular-core";
import { IZipFile_$type } from "igniteui-angular-excel";
import { List$1 } from "igniteui-angular-core";
import { IZipEntry_$type } from "igniteui-angular-excel";
import { MemoryStream } from "igniteui-angular-core";
import { DocCoreUtils } from "igniteui-angular-excel";
import { IOPath } from "igniteui-angular-core";
import { IGExcelSerializationProvider_SyncZipEntry } from "./IGExcelSerializationProvider_SyncZipEntry";
import { Encoding } from "igniteui-angular-core";
import { BinaryReader } from "igniteui-angular-core";
import { WorkItem } from "igniteui-angular-excel";
import { BinaryWriter } from "igniteui-angular-core";
import { b64toUint8Array } from "igniteui-angular-core";
import { stringReplace } from "igniteui-angular-core";
import * as Pako from "pako";
/**
* @hidden
*/
export let IGExcelSerializationProvider_SyncZipFile = /*@__PURE__*/ (() => {
class IGExcelSerializationProvider_SyncZipFile extends Base {
constructor() {
super();
this.a = null;
this.a = new List$1(IZipEntry_$type, 0);
}
get entries() {
return this.a;
}
createFile(fileName, directoryName, stream) {
arguments[2] = (typeof arguments[2] === 'string' ? b64toUint8Array(arguments[2]) : arguments[2]);
arguments[2] = (typeCast(Stream.$, arguments[2]) ? arguments[2] : new MemoryStream(2, arguments[2]));
return this._createFile$i.apply(this, arguments);
}
_createFile$i(a, b, c) {
let d = typeCast(MemoryStream.$, c);
if (d == null) {
let e = DocCoreUtils.c(c);
d = new MemoryStream(2, e);
}
return new IGExcelSerializationProvider_SyncZipEntry(stringReplace(IOPath.combine1(b, a), '\\', '/'), false, d);
}
load(stream) {
arguments[0] = (typeof arguments[0] === 'string' ? b64toUint8Array(arguments[0]) : arguments[0]);
arguments[0] = (typeCast(Stream.$, arguments[0]) ? arguments[0] : new MemoryStream(2, arguments[0]));
return this._load$i.apply(this, arguments);
}
_load$i(a) {
let b = Encoding.uTF8;
let c = new BinaryReader(1, a);
let d = c.readInt32();
for (let e = 0; e < d; e++) {
let f = c.readInt32();
let g = c.readBytes(f);
let h = b.getString(g);
let i = c.readInt32();
let j = c.readBytes(i);
let k = new MemoryStream(2, (Pako.inflate(j)));
let l = new IGExcelSerializationProvider_SyncZipEntry(h, false, k);
this.entries.add(l);
}
return WorkItem.h(IZipFile_$type, this);
}
save(stream) {
arguments[0] = (typeof arguments[0] === 'string' ? b64toUint8Array(arguments[0]) : arguments[0]);
arguments[0] = (typeCast(Stream.$, arguments[0]) ? arguments[0] : new MemoryStream(2, arguments[0]));
return this._save$i.apply(this, arguments);
}
_save$i(a) {
let b = Encoding.uTF8;
let c = new BinaryWriter(1, a);
c.q(this.entries.count);
for (let d = 0; d < this.a.count; d++) {
let e = this.a._inner[d];
if (!e.isDirectory) {
let f = e.name;
let g = e.b;
if (f.charAt(0) == '/') {
f = f.substr(1);
}
let h = b.getBytes1(f);
c.q(h.length);
c.h(h);
let i = g.toArray();
let j = (Pako.deflate(i));
c.q(j.length);
c.h(j);
}
}
c.g();
return null;
}
}
IGExcelSerializationProvider_SyncZipFile.$t = markType(IGExcelSerializationProvider_SyncZipFile, 'IGExcelSerializationProvider_SyncZipFile', Base.$, [IZipFile_$type]);
return IGExcelSerializationProvider_SyncZipFile;
})();