Commit db71e0e2 authored by konovalovsergey's avatar konovalovsergey

fix bug 33134

parent 577f1638
...@@ -158,7 +158,7 @@ UndoRedoItemSerializable.prototype = { ...@@ -158,7 +158,7 @@ UndoRedoItemSerializable.prototype = {
if(oData.Write_ToBinary2) if(oData.Write_ToBinary2)
oBinaryCommonWriter.WriteItemWithLength(function(){oData.Write_ToBinary2(oBinaryWriter)}); oBinaryCommonWriter.WriteItemWithLength(function(){oData.Write_ToBinary2(oBinaryWriter)});
else else
oBinaryCommonWriter.WriteItemWithLength(function(){oThis.SerializeDataInner(oBinaryWriter, oData, false, nSheetId, collaborativeEditing);}); oBinaryCommonWriter.WriteItemWithLength(function(){oThis.SerializeDataInnerObject(oBinaryWriter, oData, nSheetId, collaborativeEditing);});
} }
else else
{ {
...@@ -166,92 +166,84 @@ UndoRedoItemSerializable.prototype = { ...@@ -166,92 +166,84 @@ UndoRedoItemSerializable.prototype = {
oBinaryWriter.WriteLong(0); oBinaryWriter.WriteLong(0);
} }
}, },
SerializeDataInner : function(oBinaryWriter, oData, bIsArray, nSheetId, collaborativeEditing) SerializeDataInnerObject: function(oBinaryWriter, oData, nSheetId, collaborativeEditing) {
{ var oProperties = oData.getProperties();
for (var i in oProperties) {
var nItemType = oProperties[i];
var oItem = oData.getProperty(nItemType);
this.SerializeDataInner(oBinaryWriter, nItemType, oItem, nSheetId, collaborativeEditing);
}
},
SerializeDataInnerArray: function(oBinaryWriter, oData, nSheetId, collaborativeEditing) {
for (var i = 0; i < oData.length; ++i) {
this.SerializeDataInner(oBinaryWriter, 0, oData[i], nSheetId, collaborativeEditing);
}
},
SerializeDataInner: function(oBinaryWriter, nItemType, oItem, nSheetId, collaborativeEditing) {
var oThis = this; var oThis = this;
var oProperties; var sTypeOf;
if(bIsArray) if(null == oItem)
oProperties = oData; sTypeOf = "null";
else if(oItem instanceof Array)
sTypeOf = "array";
else else
oProperties = oData.getProperties(); sTypeOf = typeof(oItem);
for(var i in oProperties) switch(sTypeOf)
{ {
var oItem; case "object":
var nItemType; oBinaryWriter.WriteByte(nItemType);
if(bIsArray) oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Object);
{ this.SerializeDataObject(oBinaryWriter, oItem, nSheetId, collaborativeEditing);
nItemType = i - 0; break;
oItem = oProperties[i]; case "array":
} oBinaryWriter.WriteByte(nItemType);
else oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Array);
{ var oBinaryCommonWriter = new AscCommon.BinaryCommonWriter(oBinaryWriter);
nItemType = oProperties[i]; oBinaryCommonWriter.WriteItemWithLength(function(){oThis.SerializeDataInnerArray(oBinaryWriter, oItem, nSheetId, collaborativeEditing);});
oItem = oData.getProperty(nItemType); break;
} case "number":
var sTypeOf; oBinaryWriter.WriteByte(nItemType);
if(null == oItem) var nFlorItem = Math.floor(oItem);
sTypeOf = "null"; if(nFlorItem == oItem)
else if(oItem instanceof Array) {
sTypeOf = "array"; if(oItem >= 0 && oItem <= 255)
else
sTypeOf = typeof(oItem);
switch(sTypeOf)
{
case "object":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Object);
this.SerializeDataObject(oBinaryWriter, oItem, nSheetId, collaborativeEditing);
break;
case "array":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Array);
var oBinaryCommonWriter = new AscCommon.BinaryCommonWriter(oBinaryWriter);
oBinaryCommonWriter.WriteItemWithLength(function(){oThis.SerializeDataInner(oBinaryWriter, oItem, true, nSheetId, collaborativeEditing);});
break;
case "number":
oBinaryWriter.WriteByte(nItemType);
var nFlorItem = Math.floor(oItem);
if(nFlorItem == oItem)
{ {
if(oItem >= 0 && oItem <= 255) oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Byte);
{ oBinaryWriter.WriteByte(oItem);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Byte); }
oBinaryWriter.WriteByte(oItem); else if(oItem <= 0xffffffff)
} {
else if(oItem <= 0xffffffff) oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Long);
{ oBinaryWriter.WriteLong(oItem);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Long);
oBinaryWriter.WriteLong(oItem);
}
else
{
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Double);
oBinaryWriter.WriteDouble2(oItem);
}
} }
else else
{ {
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Double); oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Double);
oBinaryWriter.WriteDouble2(oItem); oBinaryWriter.WriteDouble2(oItem);
} }
}
else
{
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Double);
oBinaryWriter.WriteDouble2(oItem);
}
break;
case "boolean":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Bool);
oBinaryWriter.WriteBool(oItem);
break;
case "string":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.String);
oBinaryWriter.WriteString2(oItem);
break;
case "null":
case "undefined":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Null);
default:
break; break;
case "boolean":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Bool);
oBinaryWriter.WriteBool(oItem);
break;
case "string":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.String);
oBinaryWriter.WriteString2(oItem);
break;
case "null":
case "undefined":
oBinaryWriter.WriteByte(nItemType);
oBinaryWriter.WriteByte(c_oUndoRedoSerializeType.Null);
default:
break;
}
} }
}, },
...@@ -363,7 +355,7 @@ UndoRedoItemSerializable.prototype = { ...@@ -363,7 +355,7 @@ UndoRedoItemSerializable.prototype = {
if(false == nUnknownType) if(false == nUnknownType)
{ {
if(bIsArray) if(bIsArray)
oDataObject[nMemeberType] = oNewValue; oDataObject.push(oNewValue);
else else
oDataObject.setProperty(nMemeberType, oNewValue); oDataObject.setProperty(nMemeberType, oNewValue);
} }
......
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