|
|
|
@ -145,9 +145,13 @@ define([
|
|
|
|
|
return metadataMgr.getNetfluxId() + '-' + privateData.clientId;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var getWindow = function () {
|
|
|
|
|
return window.frames && window.frames[0];
|
|
|
|
|
};
|
|
|
|
|
var getEditor = function () {
|
|
|
|
|
if (!window.frames || !window.frames[0]) { return; }
|
|
|
|
|
return window.frames[0].editor || window.frames[0].editorCell;
|
|
|
|
|
var w = getWindow();
|
|
|
|
|
if (!w) { return; }
|
|
|
|
|
return w.editor || w.editorCell;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var setEditable = function (state, force) {
|
|
|
|
@ -1224,6 +1228,73 @@ define([
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
APP.testArr = [
|
|
|
|
|
['a','b',1,'d'],
|
|
|
|
|
['e',undefined,'g','h']
|
|
|
|
|
];
|
|
|
|
|
var makePatch = APP.makePatch = function (arr) {
|
|
|
|
|
var w = getWindow();
|
|
|
|
|
if (!w) { return; }
|
|
|
|
|
// Define OO classes
|
|
|
|
|
var AscCommonExcel = w.AscCommonExcel;
|
|
|
|
|
var CellValueData = AscCommonExcel.UndoRedoData_CellValueData;
|
|
|
|
|
var CCellValue = AscCommonExcel.CCellValue;
|
|
|
|
|
//var History = w.AscCommon.History;
|
|
|
|
|
var AscCH = w.AscCH;
|
|
|
|
|
var Asc = w.Asc;
|
|
|
|
|
var UndoRedoData_CellSimpleData = AscCommonExcel.UndoRedoData_CellSimpleData;
|
|
|
|
|
var editor = getEditor();
|
|
|
|
|
|
|
|
|
|
var Id = editor.GetSheet(0).worksheet.Id;
|
|
|
|
|
//History.Create_NewPoint();
|
|
|
|
|
var patches = [];
|
|
|
|
|
arr.forEach(function (arr2, i) {
|
|
|
|
|
arr2.forEach(function (v, j) {
|
|
|
|
|
var obj = {};
|
|
|
|
|
if (typeof(v) === "string") { obj.text = v; obj.type = 1; }
|
|
|
|
|
else if (typeof(v) === "number") { obj.number = v; obj.type = 0; }
|
|
|
|
|
else { return; }
|
|
|
|
|
var newValue = new CellValueData(undefined, new CCellValue(obj));
|
|
|
|
|
var nCol = j;
|
|
|
|
|
var nRow = i;
|
|
|
|
|
var patch = new AscCommonExcel.UndoRedoItemSerializable(AscCommonExcel.g_oUndoRedoCell, AscCH.historyitem_Cell_ChangeValue, Id,
|
|
|
|
|
new Asc.Range(nCol, nRow, nCol, nRow),
|
|
|
|
|
new UndoRedoData_CellSimpleData(nRow, nCol, undefined, newValue), undefined);
|
|
|
|
|
patches.push(patch);
|
|
|
|
|
/*
|
|
|
|
|
History.Add(AscCommonExcel.g_oUndoRedoCell, AscCH.historyitem_Cell_ChangeValue, Id,
|
|
|
|
|
new Asc.Range(nCol, nRow, nCol, nRow),
|
|
|
|
|
new UndoRedoData_CellSimpleData(nRow, nCol, undefined, newValue), undefined, true);
|
|
|
|
|
*/
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
var oMemory = new w.AscCommon.CMemory();
|
|
|
|
|
var aRes = [];
|
|
|
|
|
patches.forEach(function (item) {
|
|
|
|
|
editor.GetSheet(0).worksheet.workbook._SerializeHistoryBase64(oMemory, item, aRes);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Make the patch
|
|
|
|
|
var msg = {
|
|
|
|
|
type: "saveChanges",
|
|
|
|
|
changes: parseChanges(JSON.stringify(aRes)),
|
|
|
|
|
changesIndex: ooChannel.cpIndex || 0,
|
|
|
|
|
locks: getUserLock(getId(), true),
|
|
|
|
|
excelAdditionalInfo: null
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Send the patch
|
|
|
|
|
rtChannel.sendMsg(msg, null, function (err, hash) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return void console.error(err);
|
|
|
|
|
}
|
|
|
|
|
// Apply it on our side
|
|
|
|
|
ooChannel.send(msg);
|
|
|
|
|
ooChannel.lastHash = hash;
|
|
|
|
|
ooChannel.cpIndex++;
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var makeChannel = function () {
|
|
|
|
|
var msgEv = Util.mkEvent();
|
|
|
|
|