Commit b4196484 authored by Boris Kocherov's avatar Boris Kocherov

gadget: use binary format for save/open document

parent c5b52c29
......@@ -3295,9 +3295,6 @@ var editor;
var oBinaryFileWriter = new AscCommonExcel.BinaryFileWriter(this.wbModel);
oBinaryFileWriter.Write(undefined, true);
var _header = oBinaryFileWriter.WriteFileHeader(oBinaryFileWriter.Memory.GetCurPosition(), Asc.c_nVersionNoBase64);
window["native"]["Save_End"](_header, oBinaryFileWriter.Memory.GetCurPosition());
return oBinaryFileWriter.Memory.ImData.data;
};
......
......@@ -276,50 +276,28 @@ AscCommon.downloadUrlAsBlob = function (url) {
AscCommon.baseEditorsApi.prototype.jio_open = function () {
var t = this,
g = Common.Gateway;
return g.jio_getAttachment('/', 'body.txt')
.push(undefined, function (error) {
if (error["status_code"] === 404) {
return g.props.value;
}
throw error;
})
.push(function (doc) {
if (!doc) {
switch (g.props.documentType) {
case "presentation":
doc = t.getEmpty();
break;
case "spreadsheet":
doc = "XLSY;v2;2286;BAKAAgAAA+cHAAAEAwgAAADqCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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A4AAABQAGUAcgBjAGUAbgB0AAUEAAAAEwAAABgAAAAAAwAAAAEBAAELAAAAAgYAAAAABAAAAADjAAAAAN4AAAABGwAAAAAGDAAAAFMAaABlAGUAdAAxAAEEAQAAAAIBAgIkAAAAAx8AAAABAQACBAEEAAADBAEAAAAEBAAAAAAFBXnalahdiStABAQAAABBADEAFhEAAAAXDAAAAAQBAAAAAQYBAAAAAQsKAAAAAQWamZmZmZkpQA48AAAAAAVxPQrXowA0QAEFKFyPwvUIOkACBXE9CtejADRAAwUoXI/C9Qg6QAQFcT0K16MANEAFBXE9CtejADRADwYAAAAAAQEBAQkQBgAAAAABAQEBAAkAAAAAGAYAAAACAQAAAAAAAAAA";
break;
case "text":
doc = window.g_sEmpty_bin;
break;
}
}
t._OfflineAppDocumentEndLoad('', doc);
})
.push(undefined, function (error) {
console.log(error);
});
g = Common.Gateway,
doc = g.props.value;
if (!doc) {
switch (g.props.documentType) {
case "presentation":
doc = t.getEmpty();
break;
case "spreadsheet":
doc = "XLSY;v2;2286;BAKAAgAAA+cHAAAEAwgAAADqCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AABArAAAAAAQAAAAFAAAAAQEAAAAABA4AAABQAGUAcgBjAGUAbgB0AAUEAAAAEwAAABgAAAAAAwAAAAEBAAELAAAAAgYAAAAABAAAAADjAAAAAN4AAAABGwAAAAAGDAAAAFMAaABlAGUAdAAxAAEEAQAAAAIBAgIkAAAAAx8AAAABAQACBAEEAAADBAEAAAAEBAAAAAAFBXnalahdiStABAQAAABBADEAFhEAAAAXDAAAAAQBAAAAAQYBAAAAAQsKAAAAAQWamZmZmZkpQA48AAAAAAVxPQrXowA0QAEFKFyPwvUIOkACBXE9CtejADRAAwUoXI/C9Qg6QAQFcT0K16MANEAFBXE9CtejADRADwYAAAAAAQEBAQkQBgAAAAABAQEBAAkAAAAAGAYAAAACAQAAAAAAAAAA";
break;
case "text":
doc = window.g_sEmpty_bin;
break;
}
}
t._OfflineAppDocumentEndLoad('', doc);
};
AscCommon.baseEditorsApi.prototype.jio_save = function () {
var t = this,
g = Common.Gateway,
result = {},
data = t.asc_nativeGetFile();
if (g.props.save_defer) {
// if we are run from getContent
result[g.props.key] = data;
g.props.save_defer.resolve(result);
g.props.save_defer = null;
} else {
// TODO: rewrite to put_attachment
return g.jio_putAttachment('/', 'body.txt', data)
.push(undefined, function (error) {
console.log(error);
});
}
// data = t.asc_nativeGetFile(); // base64 file
data = new Blob([t.asc_nativeGetFileData()]); // binary file
return g.jio_save(data);
};
\ No newline at end of file
......@@ -58,6 +58,7 @@ Common.Gateway = {
* @return {Object}
*/
Common.Gateway.jio_getAttachment = function (doc_id, attach_id) {};
Common.Gateway.jio_save = function () {};
function jq(){}
......
......@@ -6704,9 +6704,6 @@ background-repeat: no-repeat;\
this.WordControl.m_oLogicDocument.CalculateComments();
writer.WriteDocument3(this.WordControl.m_oLogicDocument);
var _header = "PPTY;v10;" + writer.pos + ";";
window["native"]["Save_End"](_header, writer.pos);
return writer.ImData.data;
};
......
......@@ -7985,9 +7985,6 @@ background-repeat: no-repeat;\
oBinaryFileWriter.Write(true);
var _header = AscCommon.c_oSerFormat.Signature + ";v" + Asc.c_nVersionNoBase64 + ";" + _memory.GetCurPosition() + ";";
window["native"]["Save_End"](_header, _memory.GetCurPosition());
return _memory.ImData.data;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment