Commit 1d100eda authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed bug #33362

parent d13e5285
......@@ -2534,6 +2534,17 @@ CContentChanges.prototype.Add = function(Changes)
{
this.m_aChanges.push( Changes );
};
CContentChanges.prototype.RemoveByHistoryItem = function(Item)
{
for (var nIndex = 0, nCount = this.m_aChanges.length; nIndex < nCount; ++nIndex)
{
if (this.m_aChanges[nIndex].m_pData === Item)
{
this.m_aChanges.splice(nIndex, 1);
return;
}
}
};
CContentChanges.prototype.Clear = function()
{
this.m_aChanges.length = 0;
......
......@@ -252,6 +252,7 @@ CHistory.prototype =
var Item = Point.Items[Index];
Item.Class.Undo(Item.Data);
Item.Class.Refresh_RecalcData(Item.Data);
this.private_UpdateContentChangesOnUndo(Item);
}
}
}
......@@ -265,6 +266,7 @@ CHistory.prototype =
var Item = Point.Items[Index];
Item.Class.Undo(Item.Data);
Item.Class.Refresh_RecalcData(Item.Data);
this.private_UpdateContentChangesOnUndo(Item);
}
}
......@@ -292,6 +294,7 @@ CHistory.prototype =
var Item = Point.Items[Index];
Item.Class.Redo( Item.Data );
Item.Class.Refresh_RecalcData( Item.Data );
this.private_UpdateContentChangesOnRedo(Item);
}
// Восстанавливаем состояние на следующую точку
......@@ -1056,6 +1059,65 @@ CHistory.prototype =
}
}
};
CHistory.prototype.private_UpdateContentChangesOnUndo = function(Item)
{
if (this.private_IsContentChange(Item.Class, Item.Data))
{
Item.Class.m_oContentChanges.RemoveByHistoryItem(Item);
}
};
CHistory.prototype.private_UpdateContentChangesOnRedo = function(Item)
{
if (this.private_IsContentChange(Item.Class, Item.Data))
{
var bAdd = this.private_IsAddContentChange(Item.Class, Item.Data);
var Count = this.private_GetItemsCountInContentChange(Item.Class, Item.Data);
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 );
}
};
CHistory.prototype.private_IsContentChange = function(Class, Data)
{
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 ) ) ||
( 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))
)
return true;
return false;
};
CHistory.prototype.private_IsAddContentChange = function(Class, Data)
{
return ( ( 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 ) ||
( bPresentation && Class instanceof CPresentation && (AscDFH.historyitem_Presentation_AddSlide === Data.Type )) ||
( bSlide && Class instanceof Slide && (AscDFH.historyitem_SlideAddToSpTree === Data.Type))
) ? true : false;
};
CHistory.prototype.private_GetItemsCountInContentChange = function(Class, Data)
{
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 ) )
return Data.Items.length;
return 1;
};
function CRC32()
{
......
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