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