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 @@
{
return this.Add;
};
CChangesBaseContentChange.prototype.GetItemsCount = function()
{
return this.Items.length;
};
CChangesBaseContentChange.prototype.WriteToBinary = function(Writer)
{
// Long : Количество элементов
......
......@@ -42,19 +42,13 @@ AscDFH.changesFactory[AscDFH.historyitem_Field_RemoveItem] = CChangesParaFieldRe
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesParaFieldAddItem(Class, Pos, Items)
{
CChangesParaFieldAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesParaFieldAddItem.superclass.constructor.call(this, Class, Pos, Items, true);
}
AscCommon.extendClass(CChangesParaFieldAddItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesParaFieldAddItem, AscDFH.CChangesBaseContentChange);
CChangesParaFieldAddItem.prototype.Type = AscDFH.historyitem_Field_AddItem;
CChangesParaFieldAddItem.prototype.Undo = function()
{
......@@ -74,48 +68,13 @@ CChangesParaFieldAddItem.prototype.Redo = function()
oField.private_UpdateTrackRevisions();
oField.protected_UpdateSpellChecking();
};
CChangesParaFieldAddItem.prototype.WriteToBinary = function(Writer)
CChangesParaFieldAddItem.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());
};
CChangesParaFieldAddItem.prototype.ReadFromBinary = function(Reader)
CChangesParaFieldAddItem.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());
};
CChangesParaFieldAddItem.prototype.Load = function(Color)
{
......@@ -137,19 +96,13 @@ CChangesParaFieldAddItem.prototype.Load = function(Color)
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseContentChange}
*/
function CChangesParaFieldRemoveItem(Class, Pos, Items)
{
CChangesParaFieldRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
CChangesParaFieldRemoveItem.superclass.constructor.call(this, Class, Pos, Items, false);
}
AscCommon.extendClass(CChangesParaFieldRemoveItem, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesParaFieldRemoveItem, AscDFH.CChangesBaseContentChange);
CChangesParaFieldRemoveItem.prototype.Type = AscDFH.historyitem_Field_RemoveItem;
CChangesParaFieldRemoveItem.prototype.Undo = function()
{
......@@ -169,67 +122,13 @@ CChangesParaFieldRemoveItem.prototype.Redo = function()
oField.private_UpdateTrackRevisions();
oField.protected_UpdateSpellChecking();
};
CChangesParaFieldRemoveItem.prototype.WriteToBinary = function(Writer)
CChangesParaFieldRemoveItem.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());
};
CChangesParaFieldRemoveItem.prototype.ReadFromBinary = function(Reader)
CChangesParaFieldRemoveItem.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());
};
CChangesParaFieldRemoveItem.prototype.Load = function(Color)
{
......
......@@ -413,7 +413,7 @@ CHistory.prototype =
// Заглушка на случай, если у нас во время создания одной точки в истории, после нескольких изменений идет
// пересчет, потом снова добавляются изменения и снова запускается пересчет и т.д.
if ( this.RecIndex >= this.Index )
if (this.RecIndex >= this.Index)
this.RecIndex = this.Index - 1;
var Binary_Pos = this.BinaryWriter.GetCurPosition();
......@@ -447,54 +447,62 @@ CHistory.prototype =
NeedRecalc : !this.MinorChanges
};
this.Points[this.Index].Items.push( Item );
this.Points[this.Index].Items.push(Item);
if (!this.CollaborativeEditing)
return;
if (_Class && _Class.IsChangesClass && _Class.IsChangesClass())
{
if (_Class.IsContentChange())
{
var bAdd = _Class.IsAdd();
var Count = _Class.GetItemsCount();
var ContentChanges = new AscCommon.CContentChangesElement(bAdd == true ? AscCommon.contentchanges_Add : AscCommon.contentchanges_Remove, Data.Pos, Count, Item);
Class.Add_ContentChanges(ContentChanges);
this.CollaborativeEditing.Add_NewDC(Class);
if (true === bAdd)
this.CollaborativeEditing.Update_DocumentPositionsOnAdd(Class, Data.Pos);
else
this.CollaborativeEditing.Update_DocumentPositionsOnRemove(Class, Data.Pos, Count);
}
}
else
{
var bPresentation = !(typeof CPresentation === "undefined");
var bSlide = !(typeof Slide === "undefined");
if ( ( Class instanceof CDocument && ( AscDFH.historyitem_Document_AddItem === Data.Type || AscDFH.historyitem_Document_RemoveItem === Data.Type ) ) ||
(((Class instanceof CDocumentContent || Class instanceof AscFormat.CDrawingDocContent)) && ( AscDFH.historyitem_DocumentContent_AddItem === Data.Type || AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type ) ) ||
( Class instanceof CTable && ( AscDFH.historyitem_Table_AddRow === Data.Type || AscDFH.historyitem_Table_RemoveRow === Data.Type ) ) ||
( Class instanceof CTableRow && ( AscDFH.historyitem_TableRow_AddCell === Data.Type || AscDFH.historyitem_TableRow_RemoveCell === Data.Type ) ) ||
( Class instanceof Paragraph && ( AscDFH.historyitem_Paragraph_AddItem === Data.Type || AscDFH.historyitem_Paragraph_RemoveItem === Data.Type ) ) ||
( Class instanceof ParaHyperlink && ( AscDFH.historyitem_Hyperlink_AddItem === Data.Type || AscDFH.historyitem_Hyperlink_RemoveItem === Data.Type ) ) ||
( Class instanceof ParaRun && ( AscDFH.historyitem_ParaRun_AddItem === Data.Type || AscDFH.historyitem_ParaRun_RemoveItem === Data.Type ) ) ||
if (( Class instanceof AscFormat.CDrawingDocContent && ( AscDFH.historyitem_DocumentContent_AddItem === Data.Type || AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type ) ) ||
( bPresentation && Class instanceof CPresentation && (AscDFH.historyitem_Presentation_AddSlide === Data.Type || AscDFH.historyitem_Presentation_RemoveSlide === Data.Type)) ||
( bSlide && Class instanceof Slide && (AscDFH.historyitem_SlideAddToSpTree === Data.Type || AscDFH.historyitem_SlideRemoveFromSpTree === Data.Type))
)
{
var bAdd = ( ( Class instanceof CDocument && AscDFH.historyitem_Document_AddItem === Data.Type ) ||
( ((Class instanceof CDocumentContent || Class instanceof AscFormat.CDrawingDocContent)) && AscDFH.historyitem_DocumentContent_AddItem === Data.Type ) ||
( Class instanceof CTable && AscDFH.historyitem_Table_AddRow === Data.Type ) ||
( Class instanceof CTableRow && AscDFH.historyitem_TableRow_AddCell === Data.Type ) ||
( Class instanceof Paragraph && AscDFH.historyitem_Paragraph_AddItem === Data.Type ) ||
( Class instanceof ParaHyperlink && AscDFH.historyitem_Hyperlink_AddItem === Data.Type ) ||
( Class instanceof ParaRun && AscDFH.historyitem_ParaRun_AddItem === Data.Type ) ||
var bAdd = ( ( Class instanceof AscFormat.CDrawingDocContent && AscDFH.historyitem_DocumentContent_AddItem === Data.Type ) ||
( bPresentation && Class instanceof CPresentation && (AscDFH.historyitem_Presentation_AddSlide === Data.Type )) ||
( bSlide && Class instanceof Slide && (AscDFH.historyitem_SlideAddToSpTree === Data.Type))
) ? true : false;
var Count = 1;
if ( ( Class instanceof Paragraph ) || ( Class instanceof ParaHyperlink) || ( Class instanceof ParaRun ) ||
( Class instanceof CDocument && AscDFH.historyitem_Document_RemoveItem === Data.Type ) ||
( ((Class instanceof CDocumentContent || Class instanceof AscFormat.CDrawingDocContent)) && AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type ) )
if (Class instanceof AscFormat.CDrawingDocContent && AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type)
Count = Data.Items.length;
var ContentChanges = new AscCommon.CContentChangesElement( ( bAdd == true ? AscCommon.contentchanges_Add : AscCommon.contentchanges_Remove ), Data.Pos, Count, Item );
Class.Add_ContentChanges( ContentChanges );
this.CollaborativeEditing.Add_NewDC( Class );
var ContentChanges = new AscCommon.CContentChangesElement(( bAdd == true ? AscCommon.contentchanges_Add : AscCommon.contentchanges_Remove ), Data.Pos, Count, Item);
Class.Add_ContentChanges(ContentChanges);
this.CollaborativeEditing.Add_NewDC(Class);
if (true === bAdd)
this.CollaborativeEditing.Update_DocumentPositionsOnAdd(Class, Data.Pos);
else
this.CollaborativeEditing.Update_DocumentPositionsOnRemove(Class, Data.Pos, Count);
}
if(this.CollaborativeEditing.AddPosExtChanges && Class instanceof AscFormat.CXfrm)
}
if (this.CollaborativeEditing.AddPosExtChanges && Class instanceof AscFormat.CXfrm)
{
if(AscDFH.historyitem_Xfrm_SetOffX === Data.Type ||
if (AscDFH.historyitem_Xfrm_SetOffX === Data.Type ||
AscDFH.historyitem_Xfrm_SetOffY === Data.Type ||
AscDFH.historyitem_Xfrm_SetExtX === Data.Type ||
AscDFH.historyitem_Xfrm_SetExtY === Data.Type ||
......@@ -507,7 +515,7 @@ CHistory.prototype =
AscDFH.historyitem_Xfrm_SetOffX === Data.Type ||
AscDFH.historyitem_Xfrm_SetExtX === Data.Type ||
AscDFH.historyitem_Xfrm_SetChOffX === Data.Type ||
AscDFH.historyitem_Xfrm_SetChExtX === Data.Type );
AscDFH.historyitem_Xfrm_SetChExtX === Data.Type);
}
}
},
......
This diff is collapsed.
......@@ -183,6 +183,8 @@ function CMathBase(bInside)
this.ReviewInfo.Update();
}
this.m_oContentChanges = new AscCommon.CContentChanges(); // список изменений(добавление/удаление элементов)
return this;
}
AscCommon.extendClass(CMathBase, CParagraphContentWithParagraphLikeContent);
......@@ -2854,6 +2856,18 @@ CMathBase.prototype.Is_ContentUse = function(MathContent)
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()
{
......
......@@ -1232,6 +1232,8 @@ function CMathContent()
this.size = new CMathSize();
this.m_oContentChanges = new AscCommon.CContentChanges(); // список изменений(добавление/удаление элементов)
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
AscCommon.g_oTableId.Add( this, this.Id );
}
......@@ -5644,6 +5646,18 @@ CMathContent.prototype.private_CanAutoCorrectTextFunc = function( AutoCorrection
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)
{
......
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