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)
{ {
......
...@@ -413,7 +413,7 @@ CHistory.prototype = ...@@ -413,7 +413,7 @@ CHistory.prototype =
// Заглушка на случай, если у нас во время создания одной точки в истории, после нескольких изменений идет // Заглушка на случай, если у нас во время создания одной точки в истории, после нескольких изменений идет
// пересчет, потом снова добавляются изменения и снова запускается пересчет и т.д. // пересчет, потом снова добавляются изменения и снова запускается пересчет и т.д.
if ( this.RecIndex >= this.Index ) if (this.RecIndex >= this.Index)
this.RecIndex = this.Index - 1; this.RecIndex = this.Index - 1;
var Binary_Pos = this.BinaryWriter.GetCurPosition(); var Binary_Pos = this.BinaryWriter.GetCurPosition();
...@@ -447,54 +447,62 @@ CHistory.prototype = ...@@ -447,54 +447,62 @@ CHistory.prototype =
NeedRecalc : !this.MinorChanges NeedRecalc : !this.MinorChanges
}; };
this.Points[this.Index].Items.push( Item ); this.Points[this.Index].Items.push(Item);
if (!this.CollaborativeEditing) if (!this.CollaborativeEditing)
return; 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 bPresentation = !(typeof CPresentation === "undefined");
var bSlide = !(typeof Slide === "undefined"); var bSlide = !(typeof Slide === "undefined");
if ( ( Class instanceof CDocument && ( AscDFH.historyitem_Document_AddItem === Data.Type || AscDFH.historyitem_Document_RemoveItem === Data.Type ) ) || if (( Class instanceof AscFormat.CDrawingDocContent && ( AscDFH.historyitem_DocumentContent_AddItem === Data.Type || AscDFH.historyitem_DocumentContent_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 ) ) ||
( bPresentation && Class instanceof CPresentation && (AscDFH.historyitem_Presentation_AddSlide === Data.Type || AscDFH.historyitem_Presentation_RemoveSlide === 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)) ( 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 ) || var bAdd = ( ( Class instanceof AscFormat.CDrawingDocContent && AscDFH.historyitem_DocumentContent_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 ) ||
( bPresentation && Class instanceof CPresentation && (AscDFH.historyitem_Presentation_AddSlide === Data.Type )) || ( bPresentation && Class instanceof CPresentation && (AscDFH.historyitem_Presentation_AddSlide === Data.Type )) ||
( bSlide && Class instanceof Slide && (AscDFH.historyitem_SlideAddToSpTree === Data.Type)) ( bSlide && Class instanceof Slide && (AscDFH.historyitem_SlideAddToSpTree === Data.Type))
) ? true : false; ) ? true : false;
var Count = 1; var Count = 1;
if ( ( Class instanceof Paragraph ) || ( Class instanceof ParaHyperlink) || ( Class instanceof ParaRun ) || if (Class instanceof AscFormat.CDrawingDocContent && AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type)
( Class instanceof CDocument && AscDFH.historyitem_Document_RemoveItem === Data.Type ) ||
( ((Class instanceof CDocumentContent || Class instanceof AscFormat.CDrawingDocContent)) && AscDFH.historyitem_DocumentContent_RemoveItem === Data.Type ) )
Count = Data.Items.length; Count = Data.Items.length;
var ContentChanges = new AscCommon.CContentChangesElement( ( bAdd == true ? AscCommon.contentchanges_Add : AscCommon.contentchanges_Remove ), Data.Pos, Count, Item ); var ContentChanges = new AscCommon.CContentChangesElement(( bAdd == true ? AscCommon.contentchanges_Add : AscCommon.contentchanges_Remove ), Data.Pos, Count, Item);
Class.Add_ContentChanges( ContentChanges ); Class.Add_ContentChanges(ContentChanges);
this.CollaborativeEditing.Add_NewDC( Class ); this.CollaborativeEditing.Add_NewDC(Class);
if (true === bAdd) if (true === bAdd)
this.CollaborativeEditing.Update_DocumentPositionsOnAdd(Class, Data.Pos); this.CollaborativeEditing.Update_DocumentPositionsOnAdd(Class, Data.Pos);
else else
this.CollaborativeEditing.Update_DocumentPositionsOnRemove(Class, Data.Pos, Count); 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_SetOffY === Data.Type ||
AscDFH.historyitem_Xfrm_SetExtX === Data.Type || AscDFH.historyitem_Xfrm_SetExtX === Data.Type ||
AscDFH.historyitem_Xfrm_SetExtY === Data.Type || AscDFH.historyitem_Xfrm_SetExtY === Data.Type ||
...@@ -507,7 +515,7 @@ CHistory.prototype = ...@@ -507,7 +515,7 @@ CHistory.prototype =
AscDFH.historyitem_Xfrm_SetOffX === Data.Type || AscDFH.historyitem_Xfrm_SetOffX === Data.Type ||
AscDFH.historyitem_Xfrm_SetExtX === Data.Type || AscDFH.historyitem_Xfrm_SetExtX === Data.Type ||
AscDFH.historyitem_Xfrm_SetChOffX === 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) ...@@ -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()
{ {
......
...@@ -1232,6 +1232,8 @@ function CMathContent() ...@@ -1232,6 +1232,8 @@ function CMathContent()
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