Commit b0c742aa authored by Ilya Kirillov's avatar Ilya Kirillov

Added a new base class CChangesBaseContentChange. Content changes for classes ...

Added a new base class CChangesBaseContentChange. Content changes for classes  Document/DocumentContent/Hyperlink/Paragraph/Run/Table/TableRow now inherit from this class.
parent a600cb36
......@@ -59,6 +59,8 @@ CCollaborativeChanges.prototype.Set_FromUndoRedo = function(Class, Data, Binary)
};
CCollaborativeChanges.prototype.Apply_Data = function()
{
var CollaborativeEditing = AscCommon.CollaborativeEditing;
var Reader = this.private_LoadData(this.m_pData);
var ClassId = Reader.GetString2();
var Class = AscCommon.g_oTableId.Get_ById(ClassId);
......@@ -77,18 +79,24 @@ CCollaborativeChanges.prototype.Apply_Data = function()
var oChange = new fChangesClass(Class);
oChange.ReadFromBinary(Reader);
oChange.Load(this.m_oColor);
CollaborativeEditing.private_AddOverallChange(oChange);
return true;
}
// Сюда мы попадаем, когда у данного изменения нет класса и он все еще работает по старой схеме через объект
else
{
CollaborativeEditing.private_AddOverallChange(this.m_pData);
// Сюда мы попадаем, когда у данного изменения нет класса и он все еще работает по старой схеме через объект
Reader.Seek2(nReaderPos);
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Старая схема
Reader.Seek2(nReaderPos);
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// Старая схема
if (!Class.Load_Changes)
return false;
if (!Class.Load_Changes)
return false;
return Class.Load_Changes(Reader, null, this.m_oColor);
return Class.Load_Changes(Reader, null, this.m_oColor);
}
};
CCollaborativeChanges.prototype.private_LoadData = function(szSrc)
{
......@@ -726,6 +734,9 @@ CCollaborativeEditingBase.prototype.InitMemory = function() {
{
this.m_aChanges = [];
};
CCollaborativeEditingBase.prototype.private_AddOverallChange = function(oChange)
{
};
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -2870,7 +2870,105 @@
if (this.Class && this.Class.Refresh_RecalcData)
this.Class.Refresh_RecalcData(this);
};
CChangesBase.prototype.IsContentChange = function()
{
return false;
};
window['AscDFH'].CChangesBase = CChangesBase;
/**
* Базовый класс для изменений, которые меняют содержимое родительского класса.*
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesBaseContentChange(Class, Pos, Items, isAdd)
{
CChangesBaseContentChange.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
this.Add = isAdd;
}
AscCommon.extendClass(CChangesBaseContentChange, CChangesBase);
CChangesBaseContentChange.prototype.IsContentChange = function()
{
return true;
};
CChangesBaseContentChange.prototype.IsAdd = function()
{
return this.Add;
};
CChangesBaseContentChange.prototype.WriteToBinary = function(Writer)
{
// Long : Количество элементов
// Array of
// {
// Long : позиции элементов
// Variable : Item
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
var nStartPos = Writer.GetCurPosition();
Writer.Skip(4);
var nRealCount = nCount;
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
{
if (false === this.PosArray[nIndex])
{
nRealCount--;
}
else
{
Writer.WriteLong(this.PosArray[nIndex]);
this.private_WriteItem(Writer, this.Items[nIndex]);
}
}
else
{
Writer.WriteLong(this.Pos);
this.private_WriteItem(Writer, this.Items[nIndex]);
}
}
var nEndPos = Writer.GetCurPosition();
Writer.Seek(nStartPos);
Writer.WriteLong(nRealCount);
Writer.Seek(nEndPos);
};
CChangesBaseContentChange.prototype.ReadFromBinary = function(Reader)
{
// Long : Количество элементов
// Array of
// {
// Long : позиции элементов
// Variable : Item
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = this.private_ReadItem(Reader);
}
};
CChangesBaseContentChange.prototype.private_WriteItem = function(Writer, Item)
{
};
CChangesBaseContentChange.prototype.private_ReadItem = function(Reader)
{
return null;
};
window['AscDFH'].CChangesBaseContentChange = CChangesBaseContentChange;
/**
* Базовый класс для изменения свойств.
* @constructor
......
......@@ -95,7 +95,12 @@ CWordCollaborativeEditing.prototype.Send_Changes = function(IsUserSave, Addition
var Item = Point.Items[Index];
var oChanges = new AscCommon.CCollaborativeChanges();
oChanges.Set_FromUndoRedo(Item.Class, Item.Data, Item.Binary);
aChanges2.push(oChanges);
if (Item.Data.IsChangesClass && Item.Data.IsChangesClass())
aChanges2.push(Item.Data);
else
aChanges2.push(oChanges.m_pDatay);
aChanges.push(oChanges.m_pData);
}
}
......@@ -591,9 +596,12 @@ CWordCollaborativeEditing.prototype.Update_ForeignCursorLabelPosition = function
//----------------------------------------------------------------------------------------------------------------------
CWordCollaborativeEditing.prototype.private_ClearChanges = function()
{
this.m_aAllChanges = this.m_aAllChanges.concat(this.m_aChanges);
this.m_aChanges = [];
};
CWordCollaborativeEditing.prototype.private_AddOverallChange = function(oChange)
{
this.m_aAllChanges.push(oChange);
};
CWordCollaborativeEditing.prototype.private_OnSendOwnChanges = function(arrChanges, nDeleteIndex)
{
this.m_aOwnChangesIndexes.push({
......@@ -625,10 +633,19 @@ CWordCollaborativeEditing.prototype.Undo = function()
{
var oChange = this.m_aAllChanges[nPosition + nIndex];
if (this.private_IsChangeContentChange(oChange))
if (oChange && oChange.IsChangesClass && oChange.IsChangesClass())
{
var bAdd = this.private_IsChangeAddToContent(oChange);
console.log(bAdd);
if (oChange.IsContentChange())
{
var bAdd = oChange.IsAdd();
console.log(bAdd);
}
}
else
{
console.log("Old change:");
console.log(oChange);
}
}
......@@ -640,46 +657,6 @@ CWordCollaborativeEditing.prototype.CanUndo = function()
return this.m_aOwnChangesIndexes.length <= 0 ? false : true;
};
CWordCollaborativeEditing.prototype.private_IsChangeContentChange = function(Data)
{
if (AscDFH.historyitem_Document_AddItem === Data.Type
|| AscDFH.historyitem_Document_RemoveItem === Data.Type
|| AscDFH.historyitem_DocumentContent_AddItem === Data.Type
|| AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type
|| AscDFH.historyitem_Table_AddRow === Data.Type
|| AscDFH.historyitem_Table_RemoveRow === Data.Type
|| AscDFH.historyitem_TableRow_AddCell === Data.Type
|| AscDFH.historyitem_TableRow_RemoveCell === Data.Type
|| AscDFH.historyitem_Paragraph_AddItem === Data.Type
|| AscDFH.historyitem_Paragraph_RemoveItem === Data.Type
|| AscDFH.historyitem_Hyperlink_AddItem === Data.Type
|| AscDFH.historyitem_Hyperlink_RemoveItem === Data.Type
|| AscDFH.historyitem_ParaRun_AddItem === Data.Type
|| AscDFH.historyitem_ParaRun_RemoveItem === Data.Type
|| AscDFH.historyitem_Presentation_AddSlide === Data.Type
|| AscDFH.historyitem_Presentation_RemoveSlide === Data.Type
|| AscDFH.historyitem_SlideAddToSpTree === Data.Type
|| AscDFH.historyitem_SlideRemoveFromSpTree === Data.Type)
return true;
return false;
};
CWordCollaborativeEditing.prototype.private_IsChangeAddToContent = function(Data)
{
if (AscDFH.historyitem_Document_AddItem === Data.Type
|| AscDFH.historyitem_DocumentContent_AddItem === Data.Type
|| AscDFH.historyitem_Table_AddRow === Data.Type
|| AscDFH.historyitem_TableRow_AddCell === Data.Type
|| AscDFH.historyitem_Paragraph_AddItem === Data.Type
|| AscDFH.historyitem_Hyperlink_AddItem === Data.Type
|| AscDFH.historyitem_ParaRun_AddItem === Data.Type
|| AscDFH.historyitem_Presentation_AddSlide === Data.Type
|| AscDFH.historyitem_SlideAddToSpTree === Data.Type)
return true;
return false;
};
//--------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].CWordCollaborativeEditing = CWordCollaborativeEditing;
......
......@@ -46,28 +46,23 @@ AscDFH.changesFactory[AscDFH.historyitem_Document_MathSettings] = CChangesD
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesDocumentAddItem(Class, Pos, Item)
{
CChangesDocumentAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Item;
this.UseArray = false;
this.PosArray = [];
CChangesDocumentAddItem.superclass.constructor.call(this, Class, Pos, [Item], true);
}
AscCommon.extendClass(CChangesDocumentAddItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesDocumentAddItem, AscDFH.CChangesBaseContentChange);
CChangesDocumentAddItem.prototype.Type = AscDFH.historyitem_Document_AddItem;
CChangesDocumentAddItem.prototype.Undo = function()
{
var Pos = this.Pos;
var oDocument = this.Class;
var Elements = oDocument.Content.splice(this.Pos, 1);
var Elements = oDocument.Content.splice(Pos, 1);
oDocument.private_RecalculateNumbering(Elements);
oDocument.SectionsInfo.Update_OnRemove(this.Pos, 1);
oDocument.SectionsInfo.Update_OnRemove(Pos, 1);
var Pos = this.Pos;
if (Pos > 0)
{
if (Pos <= oDocument.Content.length - 1)
......@@ -87,13 +82,17 @@ CChangesDocumentAddItem.prototype.Undo = function()
};
CChangesDocumentAddItem.prototype.Redo = function()
{
var oDocument = this.Class;
oDocument.Content.splice(this.Pos, 0, this.Item);
oDocument.private_RecalculateNumbering([this.Item]);
oDocument.SectionsInfo.Update_OnAdd(this.Pos, [this.Item]);
if (this.Items.length <= 0)
return;
var Element = this.Item;
var Element = this.Items[0];
var Pos = this.Pos;
var oDocument = this.Class;
oDocument.Content.splice(Pos, 0, Element);
oDocument.private_RecalculateNumbering([Element]);
oDocument.SectionsInfo.Update_OnAdd(Pos, [Element]);
if (Pos > 0)
{
oDocument.Content[Pos - 1].Next = Element;
......@@ -116,33 +115,23 @@ CChangesDocumentAddItem.prototype.Redo = function()
Element.Parent = oDocument;
};
CChangesDocumentAddItem.prototype.WriteToBinary = function(Writer)
CChangesDocumentAddItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Pos
// String : Id элемента
if (true === this.UseArray)
Writer.WriteLong(this.PosArray[0]);
else
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Item.Get_Id());
Writer.WriteString2(Item.Get_Id());
};
CChangesDocumentAddItem.prototype.ReadFromBinary = function(Reader)
CChangesDocumentAddItem.prototype.private_ReadItem = function(Reader)
{
// Long : Pos
// String : Id элемента
this.UseArray = false;
this.Pos = Reader.GetLong();
this.PosArray = [this.Pos];
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesDocumentAddItem.prototype.Load = function(Color)
{
if (this.Items.length <= 0 || this.PosArray.length <= 0)
return;
var oDocument = this.Class;
var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.Pos);
var Element = this.Item;
var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.PosArray[0]);
var Element = this.Items[0];
Pos = Math.min(Pos, oDocument.Content.length);
......@@ -180,19 +169,13 @@ CChangesDocumentAddItem.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesDocumentRemoveItem(Class, Pos, Items)
{
CChangesDocumentRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesDocumentRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
}
AscCommon.extendClass(CChangesDocumentRemoveItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesDocumentRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesDocumentRemoveItem.prototype.Type = AscDFH.historyitem_Document_RemoveItem;
CChangesDocumentRemoveItem.prototype.Undo = function()
{
......@@ -249,67 +232,13 @@ CChangesDocumentRemoveItem.prototype.Redo = function()
oDocument.Content[Pos].Prev = null;
}
};
CChangesDocumentRemoveItem.prototype.WriteToBinary = function(Writer)
CChangesDocumentRemoveItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемого элемента
// }
var bArray = this.UseArray;
var Count = this.Items.length;
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var RealCount = Count;
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
{
if (false === this.PosArray[Index])
{
RealCount--;
}
else
{
Writer.WriteLong(this.PosArray[Index]);
Writer.WriteString2(this.Items[Index]);
}
}
else
{
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Items[Index]);
}
}
var EndPos = Writer.GetCurPosition();
Writer.Seek(StartPos);
Writer.WriteLong(RealCount);
Writer.Seek(EndPos);
Writer.WriteString2(Item.Get_Id());
};
CChangesDocumentRemoveItem.prototype.ReadFromBinary = function(Reader)
CChangesDocumentRemoveItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемого элемента
// }
this.UseArray = true;
this.PosArray = [];
this.Items = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesDocumentRemoveItem.prototype.Load = function(Color)
{
......
......@@ -42,27 +42,22 @@ AscDFH.changesFactory[AscDFH.historyitem_DocumentContent_RemoveItem] = CChangesD
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesDocumentContentAddItem(Class, Pos, Item)
{
CChangesDocumentContentAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Item;
this.UseArray = false;
this.PosArray = [];
CChangesDocumentContentAddItem.superclass.constructor.call(this, Class, Pos, [Item], true);
}
AscCommon.extendClass(CChangesDocumentContentAddItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesDocumentContentAddItem, AscDFH.CChangesBaseContentChange);
CChangesDocumentContentAddItem.prototype.Type = AscDFH.historyitem_DocumentContent_AddItem;
CChangesDocumentContentAddItem.prototype.Undo = function()
{
var Pos = this.Pos;
var oDocument = this.Class;
var Elements = oDocument.Content.splice(this.Pos, 1);
var Elements = oDocument.Content.splice(Pos, 1);
oDocument.private_RecalculateNumbering(Elements);
var Pos = this.Pos;
if (Pos > 0)
{
if (Pos <= oDocument.Content.length - 1)
......@@ -82,12 +77,16 @@ CChangesDocumentContentAddItem.prototype.Undo = function()
};
CChangesDocumentContentAddItem.prototype.Redo = function()
{
var oDocument = this.Class;
oDocument.Content.splice(this.Pos, 0, this.Item);
oDocument.private_RecalculateNumbering([this.Item]);
if (this.Items.length <= 0)
return;
var Element = this.Item;
var Element = this.Items[0];
var Pos = this.Pos;
var oDocument = this.Class;
oDocument.Content.splice(Pos, 0, Element);
oDocument.private_RecalculateNumbering([Element]);
if (Pos > 0)
{
oDocument.Content[Pos - 1].Next = Element;
......@@ -110,33 +109,23 @@ CChangesDocumentContentAddItem.prototype.Redo = function()
Element.Parent = oDocument;
};
CChangesDocumentContentAddItem.prototype.WriteToBinary = function(Writer)
CChangesDocumentContentAddItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Pos
// String : Id элемента
if (true === this.UseArray)
Writer.WriteLong(this.PosArray[0]);
else
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Item.Get_Id());
Writer.WriteString2(Item.Get_Id());
};
CChangesDocumentContentAddItem.prototype.ReadFromBinary = function(Reader)
CChangesDocumentContentAddItem.prototype.private_ReadItem = function(Reader)
{
// Long : Pos
// String : Id элемента
this.UseArray = false;
this.Pos = Reader.GetLong();
this.PosArray = [this.Pos];
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesDocumentContentAddItem.prototype.Load = function(Color)
{
if (this.PosArray.length <= 0 || this.Items.length <= 0)
return;
var oDocument = this.Class;
var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.Pos);
var Element = this.Item;
var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.PosArray[0]);
var Element = this.Items[0];
Pos = Math.min(Pos, oDocument.Content.length);
......@@ -173,19 +162,13 @@ CChangesDocumentContentAddItem.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesDocumentContentRemoveItem(Class, Pos, Items)
{
CChangesDocumentContentRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesDocumentContentRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
}
AscCommon.extendClass(CChangesDocumentContentRemoveItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesDocumentContentRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesDocumentContentRemoveItem.prototype.Type = AscDFH.historyitem_DocumentContent_RemoveItem;
CChangesDocumentContentRemoveItem.prototype.Undo = function()
{
......@@ -245,67 +228,13 @@ CChangesDocumentContentRemoveItem.prototype.Redo = function()
oDocument.Content[Pos].Prev = null;
}
};
CChangesDocumentContentRemoveItem.prototype.WriteToBinary = function(Writer)
CChangesDocumentContentRemoveItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемого элемента
// }
var bArray = this.UseArray;
var Count = this.Items.length;
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var RealCount = Count;
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
{
if (false === this.PosArray[Index])
{
RealCount--;
}
else
{
Writer.WriteLong(this.PosArray[Index]);
Writer.WriteString2(this.Items[Index]);
}
}
else
{
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Items[Index]);
}
}
var EndPos = Writer.GetCurPosition();
Writer.Seek(StartPos);
Writer.WriteLong(RealCount);
Writer.Seek(EndPos);
Writer.WriteString2(Item.Get_Id());
};
CChangesDocumentContentRemoveItem.prototype.ReadFromBinary = function(Reader)
CChangesDocumentContentRemoveItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемого элемента
// }
this.UseArray = true;
this.PosArray = [];
this.Items = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesDocumentContentRemoveItem.prototype.Load = function(Color)
{
......
......@@ -72,19 +72,13 @@ CChangesHyperlinkToolTip.prototype.private_SetValue = function(Value)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesHyperlinkAddItem(Class, Pos, Items)
{
CChangesHyperlinkAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesHyperlinkAddItem.superclass.constructor.call(this, Class, Pos, Items, true);
}
AscCommon.extendClass(CChangesHyperlinkAddItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesHyperlinkAddItem, AscDFH.CChangesBaseContentChange);
CChangesHyperlinkAddItem.prototype.Type = AscDFH.historyitem_Hyperlink_AddItem;
CChangesHyperlinkAddItem.prototype.Undo = function()
{
......@@ -103,48 +97,13 @@ CChangesHyperlinkAddItem.prototype.Redo = function()
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
CChangesHyperlinkAddItem.prototype.WriteToBinary = function(Writer)
CChangesHyperlinkAddItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id элемента
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
Writer.WriteLong(nCount);
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
Writer.WriteLong(this.PosArray[nIndex]);
else
Writer.WriteLong(this.Pos + nIndex);
Writer.WriteString2(this.Items[nIndex].Get_Id());
}
Writer.WriteString2(Item.Get_Id());
};
CChangesHyperlinkAddItem.prototype.ReadFromBinary = function(Reader)
CChangesHyperlinkAddItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id Элемента
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesHyperlinkAddItem.prototype.Load = function(Color)
{
......@@ -166,19 +125,13 @@ CChangesHyperlinkAddItem.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesHyperlinkRemoveItem(Class, Pos, Items)
{
CChangesHyperlinkRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesHyperlinkRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
}
AscCommon.extendClass(CChangesHyperlinkRemoveItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesHyperlinkRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesHyperlinkRemoveItem.prototype.Type = AscDFH.historyitem_Hyperlink_RemoveItem;
CChangesHyperlinkRemoveItem.prototype.Undo = function()
{
......@@ -197,67 +150,13 @@ CChangesHyperlinkRemoveItem.prototype.Redo = function()
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
CChangesHyperlinkRemoveItem.prototype.WriteToBinary = function(Writer)
CChangesHyperlinkRemoveItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемых элементов
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
var nStartPos = Writer.GetCurPosition();
Writer.Skip(4);
var nRealCount = nCount;
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
{
if (false === this.PosArray[nIndex])
{
nRealCount--;
}
else
{
Writer.WriteLong(this.PosArray[nIndex]);
Writer.WriteString2(this.Items[nIndex]);
}
}
else
{
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Items[nIndex]);
}
}
var nEndPos = Writer.GetCurPosition();
Writer.Seek(nStartPos);
Writer.WriteLong(nRealCount);
Writer.Seek(nEndPos);
Writer.WriteString2(Item.Get_Id());
};
CChangesHyperlinkRemoveItem.prototype.ReadFromBinary = function(Reader)
CChangesHyperlinkRemoveItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемых элементов
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesHyperlinkRemoveItem.prototype.Load = function(Color)
{
......
......@@ -90,19 +90,13 @@ function private_ParagraphChangesOnSetValue(oParagraph)
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesParagraphAddItem(Class, Pos, Items)
{
CChangesParagraphAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesParagraphAddItem.superclass.constructor.call(this, Class, Pos, Items, true);
}
AscCommon.extendClass(CChangesParagraphAddItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesParagraphAddItem, AscDFH.CChangesBaseContentChange);
CChangesParagraphAddItem.prototype.Type = AscDFH.historyitem_Paragraph_AddItem;
CChangesParagraphAddItem.prototype.Undo = function()
{
......@@ -121,48 +115,13 @@ CChangesParagraphAddItem.prototype.Redo = function()
oParagraph.private_UpdateTrackRevisions();
private_ParagraphChangesOnSetValue(this.Class);
};
CChangesParagraphAddItem.prototype.WriteToBinary = function(Writer)
CChangesParagraphAddItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id элемента
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
Writer.WriteLong(nCount);
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
Writer.WriteLong(this.PosArray[nIndex]);
else
Writer.WriteLong(this.Pos + nIndex);
Writer.WriteString2(this.Items[nIndex].Get_Id());
}
Writer.WriteString2(Item.Get_Id());
};
CChangesParagraphAddItem.prototype.ReadFromBinary = function(Reader)
CChangesParagraphAddItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id Элемента
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesParagraphAddItem.prototype.Load = function(Color)
{
......@@ -206,19 +165,13 @@ CChangesParagraphAddItem.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesParagraphRemoveItem(Class, Pos, Items)
{
CChangesParagraphRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesParagraphRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
}
AscCommon.extendClass(CChangesParagraphRemoveItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesParagraphRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesParagraphRemoveItem.prototype.Type = AscDFH.historyitem_Paragraph_RemoveItem;
CChangesParagraphRemoveItem.prototype.Undo = function()
{
......@@ -237,67 +190,13 @@ CChangesParagraphRemoveItem.prototype.Redo = function()
oParagraph.private_UpdateTrackRevisions();
private_ParagraphChangesOnSetValue(this.Class);
};
CChangesParagraphRemoveItem.prototype.WriteToBinary = function(Writer)
CChangesParagraphRemoveItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемых элементов
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
var nStartPos = Writer.GetCurPosition();
Writer.Skip(4);
var nRealCount = nCount;
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
{
if (false === this.PosArray[nIndex])
{
nRealCount--;
}
else
{
Writer.WriteLong(this.PosArray[nIndex]);
Writer.WriteString2(this.Items[nIndex]);
}
}
else
{
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Items[nIndex]);
}
}
var nEndPos = Writer.GetCurPosition();
Writer.Seek(nStartPos);
Writer.WriteLong(nRealCount);
Writer.Seek(nEndPos);
Writer.WriteString2(Item.Get_Id());
};
CChangesParagraphRemoveItem.prototype.ReadFromBinary = function(Reader)
CChangesParagraphRemoveItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемых элементов
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesParagraphRemoveItem.prototype.Load = function(Color)
{
......
......@@ -1034,7 +1034,7 @@ ParaRun.prototype.private_UpdateCompositeInputPositionsOnRemove = function(Pos,
// Добавляем элемент в позицию с сохранием в историю
ParaRun.prototype.Add_ToContent = function(Pos, Item, UpdatePosition)
{
History.Add(new CChangesRunAddItem(this, Pos, [Item], Pos, true));
History.Add(new CChangesRunAddItem(this, Pos, [Item], true));
this.Content.splice( Pos, 0, Item );
if (true === UpdatePosition)
......@@ -1090,7 +1090,7 @@ ParaRun.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition)
{
// Получим массив удаляемых элементов
var DeletedItems = this.Content.slice( Pos, Pos + Count );
History.Add(new CChangesRunRemoveItem(this, Pos, DeletedItems, Pos + Count - 1));
History.Add(new CChangesRunRemoveItem(this, Pos, DeletedItems));
this.Content.splice( Pos, Count );
......@@ -1154,7 +1154,7 @@ ParaRun.prototype.Concat_ToContent = function(NewItems)
var StartPos = this.Content.length;
this.Content = this.Content.concat( NewItems );
History.Add(new CChangesRunAddItem(this, StartPos, NewItems, this.Content.length - 1, false));
History.Add(new CChangesRunAddItem(this, StartPos, NewItems, false));
this.private_UpdateTrackRevisionOnChangeContent(true);
......
......@@ -84,27 +84,21 @@ AscDFH.changesFactory[AscDFH.historyitem_ParaRun_MathForcedBreak] = CChangesRu
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesRunAddItem(Class, Pos, Items, EndPos, Color)
function CChangesRunAddItem(Class, Pos, Items, Color)
{
CChangesRunAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.EndPos = EndPos;
CChangesRunAddItem.superclass.constructor.call(this, Class, Pos, Items, true);
this.Color = true === Color ? true : false;
this.UseArray = false;
this.PosArray = [];
this.Color = true === Color ? true : false;
}
AscCommon.extendClass(CChangesRunAddItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesRunAddItem, AscDFH.CChangesBaseContentChange);
CChangesRunAddItem.prototype.Type = AscDFH.historyitem_ParaRun_AddItem;
CChangesRunAddItem.prototype.Undo = function()
{
var oRun = this.Class;
oRun.Content.splice(this.Pos, this.EndPos - this.Pos + 1);
oRun.Content.splice(this.Pos, this.Items.length);
oRun.RecalcInfo.Measure = true;
oRun.protected_UpdateSpellChecking();
......@@ -123,57 +117,13 @@ CChangesRunAddItem.prototype.Redo = function()
oRun.protected_UpdateSpellChecking();
oRun.private_UpdateTrackRevisionOnChangeContent(false);
};
CChangesRunAddItem.prototype.WriteToBinary = function(Writer)
CChangesRunAddItem.prototype.private_WriteItem = function(Writer, Item)
{
// Bool : Подсвечивать ли данные изменения
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Элемент
// }
var bArray = this.UseArray;
var Count = this.Items.length;
if (false === this.Color)
Writer.WriteBool(false);
else
Writer.WriteBool(true);
Writer.WriteLong(Count);
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
Writer.WriteLong(this.PosArray[Index]);
else
Writer.WriteLong(this.Pos + Index);
this.Items[Index].Write_ToBinary(Writer);
}
Item.Write_ToBinary(Writer);
};
CChangesRunAddItem.prototype.ReadFromBinary = function(Reader)
CChangesRunAddItem.prototype.private_ReadItem = function(Reader)
{
// Bool : Подсвечивать ли данные изменения
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id Элемента
// }
this.UseArray = true;
this.PosArray = [];
this.Items = [];
this.Color = Reader.GetBool();
var Count = Reader.GetLong();
for (var Index = 0; Index < Count; Index++)
{
this.PosArray[Index] = Reader.GetLong();
this.Items[Index] = ParagraphContent_Read_FromBinary(Reader);
}
return ParagraphContent_Read_FromBinary(Reader);
};
CChangesRunAddItem.prototype.Load = function(Color)
{
......@@ -204,20 +154,13 @@ CChangesRunAddItem.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesRunRemoveItem(Class, Pos, Items, EndPos)
function CChangesRunRemoveItem(Class, Pos, Items)
{
CChangesRunRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.EndPos = EndPos;
this.UseArray = false;
this.PosArray = [];
CChangesRunRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
}
AscCommon.extendClass(CChangesRunRemoveItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesRunRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesRunRemoveItem.prototype.Type = AscDFH.historyitem_ParaRun_RemoveItem;
CChangesRunRemoveItem.prototype.Undo = function()
{
......@@ -235,74 +178,19 @@ CChangesRunRemoveItem.prototype.Undo = function()
CChangesRunRemoveItem.prototype.Redo = function()
{
var oRun = this.Class;
oRun.Content.splice(this.Pos, this.EndPos - this.Pos + 1);
oRun.Content.splice(this.Pos, this.Items.length);
oRun.RecalcInfo.Measure = true;
oRun.protected_UpdateSpellChecking();
oRun.private_UpdateTrackRevisionOnChangeContent(false);
};
CChangesRunRemoveItem.prototype.WriteToBinary = function(Writer)
CChangesRunRemoveItem.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Элемент
// }
var bArray = this.UseArray;
var Count = this.Items.length;
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var RealCount = Count;
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
{
if (false === this.PosArray[Index])
{
RealCount--;
}
else
{
Writer.WriteLong(this.PosArray[Index]);
this.Items[Index].Write_ToBinary(Writer);
}
}
else
{
Writer.WriteLong(this.Pos);
this.Items[Index].Write_ToBinary(Writer);
}
}
var EndPos = Writer.GetCurPosition();
Writer.Seek(StartPos);
Writer.WriteLong(RealCount);
Writer.Seek(EndPos);
Item.Write_ToBinary(Writer);
};
CChangesRunRemoveItem.prototype.ReadFromBinary = function(Reader)
CChangesRunRemoveItem.prototype.private_ReadItem = function(Reader)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Элемент
// }
this.UseArray = true;
this.PosArray = [];
this.Items = [];
var Count = Reader.GetLong();
for (var Index = 0; Index < Count; Index++)
{
this.PosArray[Index] = Reader.GetLong();
this.Items[Index] = ParagraphContent_Read_FromBinary(Reader);
}
return ParagraphContent_Read_FromBinary(Reader);
};
CChangesRunRemoveItem.prototype.Load = function()
{
......
......@@ -455,19 +455,13 @@ CChangesTableInline.prototype.private_SetValue = function(Value)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesTableAddRow(Class, Pos, Row)
{
CChangesTableAddRow.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Row;
this.UseArray = false;
this.PosArray = [];
CChangesTableAddRow.superclass.constructor.call(this, Class, Pos, [Row], true);
}
AscCommon.extendClass(CChangesTableAddRow, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesTableAddRow, AscDFH.CChangesBaseContentChange);
CChangesTableAddRow.prototype.Type = AscDFH.historyitem_Table_AddRow;
CChangesTableAddRow.prototype.Undo = function()
{
......@@ -482,44 +476,35 @@ CChangesTableAddRow.prototype.Undo = function()
};
CChangesTableAddRow.prototype.Redo = function()
{
if (this.Items.length <= 0)
return;
var oTable = this.Class;
oTable.Content.splice(this.Pos, 0, this.Item);
oTable.Content.splice(this.Pos, 0, this.Items[0]);
oTable.TableRowsBottom.splice(this.Pos, 0, {});
oTable.RowsInfo.splice(this.Pos, 0, {});
oTable.Internal_ReIndexing(this.Pos);
oTable.Recalc_CompiledPr2();
};
CChangesTableAddRow.prototype.WriteToBinary = function(Writer)
CChangesTableAddRow.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Позиция
// String : Id элемента
if (true === this.UseArray)
Writer.WriteLong(this.PosArray[0]);
else
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Item.Get_Id());
Writer.WriteString2(Item.Get_Id());
};
CChangesTableAddRow.prototype.ReadFromBinary = function(Reader)
CChangesTableAddRow.prototype.private_ReadItem = function(Reader)
{
// Long : Позиция
// String : Id элемента
this.UseArray = false;
this.PosArray = [];
this.Pos = Reader.GetLong();
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesTableAddRow.prototype.Load = function(Color)
{
if (this.PosArray.length <= 0 || this.Items.length <= 0)
return;
var oTable = this.Class;
var Pos = oTable.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.Pos);
var Element = this.Item;
var Pos = oTable.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.PosArray[0]);
var Element = this.Items[0];
if (null != Element)
{
......@@ -532,28 +517,22 @@ CChangesTableAddRow.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesTableRemoveRow(Class, Pos, Row)
{
CChangesTableRemoveRow.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Row;
this.UseArray = false;
this.PosArray = [];
CChangesTableRemoveRow.superclass.constructor.call(this, Class, Pos, [Row], false);
}
AscCommon.extendClass(CChangesTableRemoveRow, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesTableRemoveRow, AscDFH.CChangesBaseContentChange);
CChangesTableRemoveRow.prototype.Type = AscDFH.historyitem_Table_RemoveRow;
CChangesTableRemoveRow.prototype.Undo = function()
{
if (!this.Item)
if (this.Items.length <= 0)
return;
var oTable = this.Class;
oTable.Content.splice(this.Pos, 0, this.Item);
oTable.Content.splice(this.Pos, 0, this.Items[0]);
oTable.TableRowsBottom.splice(this.Pos, 0, {});
oTable.RowsInfo.splice(this.Pos, 0, {});
......@@ -562,7 +541,7 @@ CChangesTableRemoveRow.prototype.Undo = function()
};
CChangesTableRemoveRow.prototype.Redo = function()
{
if (!this.Item)
if (this.Items.length <= 0)
return;
var oTable = this.Class;
......@@ -574,52 +553,22 @@ CChangesTableRemoveRow.prototype.Redo = function()
oTable.Internal_ReIndexing(this.Pos);
oTable.Recalc_CompiledPr2();
};
CChangesTableRemoveRow.prototype.WriteToBinary = function(Writer)
CChangesTableRemoveRow.prototype.private_WriteItem = function(Writer, Item)
{
// Bool : Is already deleted?
// false ->
// Long : позиция
// String : Id удаляемой строки
if (this.UseArray && false === this.PosArray[0])
{
Writer.WriteBool(true);
}
else
{
Writer.WriteBool(false);
Writer.WriteLong(this.UseArray ? this.PosArray[0] : this.Pos);
Writer.WriteString2(this.Item.Get_Id());
}
Writer.WriteString2(Item.Get_Id());
};
CChangesTableRemoveRow.prototype.ReadFromBinary = function(Reader)
CChangesTableRemoveRow.prototype.private_ReadItem = function(Reader)
{
// Bool : Is already deleted?
// false ->
// Long : позиция
// String : Id удаляемой строки
if (false === Reader.GetBool())
{
this.UseArray = false;
this.Pos = Reader.GetLong();
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
else
{
this.Item = undefined;
this.Pos = -1;
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesTableRemoveRow.prototype.Load = function(Color)
{
if (!this.Item)
if (this.PosArray.length <= 0 || this.Items.length <= 0)
return;
var oTable = this.Class;
var Pos = oTable.m_oContentChanges.Check(AscCommon.contentchanges_Remove, this.Pos);
var Pos = oTable.m_oContentChanges.Check(AscCommon.contentchanges_Remove, this.PosArray[0]);
if (false === Pos)
return;
......
......@@ -348,22 +348,19 @@ CChangesTableRowHeight.prototype.private_SetValue = function(Value)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesTableRowAddCell(Class, Pos, Cell)
{
CChangesTableRowAddCell.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Cell;
this.UseArray = false;
this.PosArray = [];
CChangesTableRowAddCell.superclass.constructor.call(this, Class, Pos, [Cell], true);
}
AscCommon.extendClass(CChangesTableRowAddCell, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesTableRowAddCell, AscDFH.CChangesBaseContentChange);
CChangesTableRowAddCell.prototype.Type = AscDFH.historyitem_TableRow_AddCell;
CChangesTableRowAddCell.prototype.Undo = function()
{
if (this.Items.length <= 0)
return;
var oRow = this.Class;
oRow.Content.splice(this.Pos, 1);
oRow.CellsInfo.splice(this.Pos, 1);
......@@ -371,40 +368,31 @@ CChangesTableRowAddCell.prototype.Undo = function()
};
CChangesTableRowAddCell.prototype.Redo = function()
{
if (this.Items.length <= 0)
return;
var oRow = this.Class;
oRow.Content.splice(this.Pos, 0, this.Item);
oRow.Content.splice(this.Pos, 0, this.Items[0]);
oRow.CellsInfo.splice(this.Pos, 0, {});
oRow.Internal_ReIndexing(this.Pos);
};
CChangesTableRowAddCell.prototype.WriteToBinary = function(Writer)
CChangesTableRowAddCell.prototype.private_WriteItem = function(Writer, Item)
{
// Long : Позиция
// String : Id элемента
if (true === this.UseArray)
Writer.WriteLong(this.PosArray[0]);
else
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Item.Get_Id());
Writer.WriteString2(Item.Get_Id());
};
CChangesTableRowAddCell.prototype.ReadFromBinary = function(Reader)
CChangesTableRowAddCell.prototype.private_ReadItem = function(Reader)
{
// Long : Позиция
// String : Id элемента
this.UseArray = false;
this.PosArray = [];
this.Pos = Reader.GetLong();
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesTableRowAddCell.prototype.Load = function(Color)
{
if (this.Items.length <= 0 || this.PosArray <= 0)
return;
var oRow = this.Class;
var Pos = oRow.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.Pos);
var Element = this.Item;
var Pos = oRow.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.PosArray[0]);
var Element = this.Items[0];
if (null != Element)
{
......@@ -416,33 +404,27 @@ CChangesTableRowAddCell.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesTableRowRemoveCell(Class, Pos, Row)
function CChangesTableRowRemoveCell(Class, Pos, Cell)
{
CChangesTableRowRemoveCell.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Row;
this.UseArray = false;
this.PosArray = [];
CChangesTableRowRemoveCell.superclass.constructor.call(this, Class, Pos, [Cell], false);
}
AscCommon.extendClass(CChangesTableRowRemoveCell, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesTableRowRemoveCell, AscDFH.CChangesBaseContentChange);
CChangesTableRowRemoveCell.prototype.Type = AscDFH.historyitem_TableRow_RemoveCell;
CChangesTableRowRemoveCell.prototype.Undo = function()
{
if (!this.Item)
if (this.Items.length <= 0)
return;
var oRow = this.Class;
oRow.Content.splice(this.Pos, 0, this.Item);
oRow.Content.splice(this.Pos, 0, this.Items[0]);
oRow.CellsInfo.splice(this.Pos, 0, {});
oRow.Internal_ReIndexing(this.Pos);
};
CChangesTableRowRemoveCell.prototype.Redo = function()
{
if (!this.Item)
if (this.Items.length <= 0)
return;
var oRow = this.Class;
......@@ -450,52 +432,22 @@ CChangesTableRowRemoveCell.prototype.Redo = function()
oRow.CellsInfo.splice(this.Pos, 1);
oRow.Internal_ReIndexing(this.Pos);
};
CChangesTableRowRemoveCell.prototype.WriteToBinary = function(Writer)
CChangesTableRowRemoveCell.prototype.private_WriteItem = function(Writer, Item)
{
// Bool : Is already deleted?
// false ->
// Long : позиция
// String : Id удаляемой строки
if (this.UseArray && false === this.PosArray[0])
{
Writer.WriteBool(true);
}
else
{
Writer.WriteBool(false);
Writer.WriteLong(this.UseArray ? this.PosArray[0] : this.Pos);
Writer.WriteString2(this.Item.Get_Id());
}
Writer.WriteString2(Item.Get_Id());
};
CChangesTableRowRemoveCell.prototype.ReadFromBinary = function(Reader)
CChangesTableRowRemoveCell.prototype.private_ReadItem = function(Reader)
{
// Bool : Is already deleted?
// false ->
// Long : позиция
// String : Id удаляемой строки
if (false === Reader.GetBool())
{
this.UseArray = false;
this.Pos = Reader.GetLong();
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
else
{
this.Item = undefined;
this.Pos = -1;
}
return AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesTableRowRemoveCell.prototype.Load = function(Color)
{
if (!this.Item)
if (this.Items.length <= 0 || this.PosArray.length <= 0)
return;
var oRow = this.Class;
var Pos = oRow.m_oContentChanges.Check(AscCommon.contentchanges_Remove, this.Pos);
var Pos = oRow.m_oContentChanges.Check(AscCommon.contentchanges_Remove, this.PosArray[0]);
if (false === Pos)
return;
......
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