Commit 6d38edf8 authored by Ilya Kirillov's avatar Ilya Kirillov

Classes CMathContent/CMathBase/ParaField are now inherit from a new class...

Classes CMathContent/CMathBase/ParaField are now inherit from a new class CChangesBaseContentChange.
parent b0c742aa
...@@ -2899,6 +2899,10 @@ ...@@ -2899,6 +2899,10 @@
{ {
return this.Add; return this.Add;
}; };
CChangesBaseContentChange.prototype.GetItemsCount = function()
{
return this.Items.length;
};
CChangesBaseContentChange.prototype.WriteToBinary = function(Writer) CChangesBaseContentChange.prototype.WriteToBinary = function(Writer)
{ {
// Long : Количество элементов // Long : Количество элементов
......
...@@ -42,19 +42,13 @@ AscDFH.changesFactory[AscDFH.historyitem_Field_RemoveItem] = CChangesParaFieldRe ...@@ -42,19 +42,13 @@ AscDFH.changesFactory[AscDFH.historyitem_Field_RemoveItem] = CChangesParaFieldRe
/** /**
* @constructor * @constructor
* @extends {AscDFH.CChangesBase} * @extends {AscDFH.CChangesBaseContentChange}
*/ */
function CChangesParaFieldAddItem(Class, Pos, Items) function CChangesParaFieldAddItem(Class, Pos, Items)
{ {
CChangesParaFieldAddItem.superclass.constructor.call(this, Class); CChangesParaFieldAddItem.superclass.constructor.call(this, Class, Pos, Items, true);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
} }
AscCommon.extendClass(CChangesParaFieldAddItem, AscDFH.CChangesBase); AscCommon.extendClass(CChangesParaFieldAddItem, AscDFH.CChangesBaseContentChange);
CChangesParaFieldAddItem.prototype.Type = AscDFH.historyitem_Field_AddItem; CChangesParaFieldAddItem.prototype.Type = AscDFH.historyitem_Field_AddItem;
CChangesParaFieldAddItem.prototype.Undo = function() CChangesParaFieldAddItem.prototype.Undo = function()
{ {
...@@ -74,48 +68,13 @@ CChangesParaFieldAddItem.prototype.Redo = function() ...@@ -74,48 +68,13 @@ CChangesParaFieldAddItem.prototype.Redo = function()
oField.private_UpdateTrackRevisions(); oField.private_UpdateTrackRevisions();
oField.protected_UpdateSpellChecking(); oField.protected_UpdateSpellChecking();
}; };
CChangesParaFieldAddItem.prototype.WriteToBinary = function(Writer) CChangesParaFieldAddItem.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());
}
}; };
CChangesParaFieldAddItem.prototype.ReadFromBinary = function(Reader) CChangesParaFieldAddItem.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());
}
}; };
CChangesParaFieldAddItem.prototype.Load = function(Color) CChangesParaFieldAddItem.prototype.Load = function(Color)
{ {
...@@ -137,19 +96,13 @@ CChangesParaFieldAddItem.prototype.Load = function(Color) ...@@ -137,19 +96,13 @@ CChangesParaFieldAddItem.prototype.Load = function(Color)
}; };
/** /**
* @constructor * @constructor
* @extends {AscDFH.CChangesBase} * @extends {AscDFH.CChangesBaseContentChange}
*/ */
function CChangesParaFieldRemoveItem(Class, Pos, Items) function CChangesParaFieldRemoveItem(Class, Pos, Items)
{ {
CChangesParaFieldRemoveItem.superclass.constructor.call(this, Class); CChangesParaFieldRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
} }
AscCommon.extendClass(CChangesParaFieldRemoveItem, AscDFH.CChangesBase); AscCommon.extendClass(CChangesParaFieldRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesParaFieldRemoveItem.prototype.Type = AscDFH.historyitem_Field_RemoveItem; CChangesParaFieldRemoveItem.prototype.Type = AscDFH.historyitem_Field_RemoveItem;
CChangesParaFieldRemoveItem.prototype.Undo = function() CChangesParaFieldRemoveItem.prototype.Undo = function()
{ {
...@@ -169,67 +122,13 @@ CChangesParaFieldRemoveItem.prototype.Redo = function() ...@@ -169,67 +122,13 @@ CChangesParaFieldRemoveItem.prototype.Redo = function()
oField.private_UpdateTrackRevisions(); oField.private_UpdateTrackRevisions();
oField.protected_UpdateSpellChecking(); oField.protected_UpdateSpellChecking();
}; };
CChangesParaFieldRemoveItem.prototype.WriteToBinary = function(Writer) CChangesParaFieldRemoveItem.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);
}; };
CChangesParaFieldRemoveItem.prototype.ReadFromBinary = function(Reader) CChangesParaFieldRemoveItem.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());
}
}; };
CChangesParaFieldRemoveItem.prototype.Load = function(Color) CChangesParaFieldRemoveItem.prototype.Load = function(Color)
{ {
......
This diff is collapsed.
This diff is collapsed.
...@@ -183,6 +183,8 @@ function CMathBase(bInside) ...@@ -183,6 +183,8 @@ function CMathBase(bInside)
this.ReviewInfo.Update(); this.ReviewInfo.Update();
} }
this.m_oContentChanges = new AscCommon.CContentChanges(); // список изменений(добавление/удаление элементов)
return this; return this;
} }
AscCommon.extendClass(CMathBase, CParagraphContentWithParagraphLikeContent); AscCommon.extendClass(CMathBase, CParagraphContentWithParagraphLikeContent);
...@@ -2854,6 +2856,18 @@ CMathBase.prototype.Is_ContentUse = function(MathContent) ...@@ -2854,6 +2856,18 @@ CMathBase.prototype.Is_ContentUse = function(MathContent)
return false; return false;
}; };
CMathBase.prototype.Clear_ContentChanges = function()
{
this.m_oContentChanges.Clear();
};
CMathBase.prototype.Add_ContentChanges = function(Changes)
{
this.m_oContentChanges.Add(Changes);
};
CMathBase.prototype.Refresh_ContentChanges = function()
{
this.m_oContentChanges.Refresh();
};
function CMathBasePr() function CMathBasePr()
{ {
......
...@@ -1231,6 +1231,8 @@ function CMathContent() ...@@ -1231,6 +1231,8 @@ function CMathContent()
this.ParentElement = null; this.ParentElement = null;
this.size = new CMathSize(); this.size = new CMathSize();
this.m_oContentChanges = new AscCommon.CContentChanges(); // список изменений(добавление/удаление элементов)
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора) // Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
AscCommon.g_oTableId.Add( this, this.Id ); AscCommon.g_oTableId.Add( this, this.Id );
...@@ -5644,6 +5646,18 @@ CMathContent.prototype.private_CanAutoCorrectTextFunc = function( AutoCorrection ...@@ -5644,6 +5646,18 @@ CMathContent.prototype.private_CanAutoCorrectTextFunc = function( AutoCorrection
return Result; return Result;
}; };
CMathContent.prototype.Clear_ContentChanges = function()
{
this.m_oContentChanges.Clear();
};
CMathContent.prototype.Add_ContentChanges = function(Changes)
{
this.m_oContentChanges.Add(Changes);
};
CMathContent.prototype.Refresh_ContentChanges = function()
{
this.m_oContentChanges.Refresh();
};
function AutoCorrectionControl (AutoCorrectionEngine, ParaMath) function AutoCorrectionControl (AutoCorrectionEngine, ParaMath)
{ {
......
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