Commit 1894d064 authored by Ilya Kirillov's avatar Ilya Kirillov

Improved performance of a paste function.

parent d7fb3e2b
......@@ -467,12 +467,11 @@ CHistory.prototype =
}
},
Internal_RecalcData_Clear : function()
{
// NumPr здесь не обнуляем
var NumPr = this.RecalculateData.NumPr;
this.RecalculateData =
{
Internal_RecalcData_Clear : function()
{
// NumPr здесь не обнуляем
var NumPr = this.RecalculateData.NumPr;
this.RecalculateData = {
Inline : {
Pos : -1,
PageNum : 0
......@@ -485,11 +484,14 @@ CHistory.prototype =
ThemeInfo : null
},
Tables : [],
NumPr : NumPr,
NotesEnd : false,
NotesEndPage : 0,
Update : true
Tables : [],
NumPr : NumPr,
NotesEnd : false,
NotesEndPage : 0,
Update : true,
ChangedStyles : {},
ChangedNums : {},
AllParagraphs : null
};
},
......@@ -596,6 +598,33 @@ CHistory.prototype =
}
},
AddChangedStyleToRecalculateData : function(sId, oStyle)
{
if (!this.RecalculateData.ChangedStyles)
this.RecalculateData.ChangedStyles = {};
if (this.RecalculateData.ChangedStyles[sId] === oStyle)
return false;
this.RecalculateData.ChangedStyles[sId] = oStyle;
return true;
},
AddChangedNumberingToRecalculateData : function(NumId, Lvl, oNum)
{
if (!this.RecalculateData.ChangedNums)
this.RecalculateData.ChangedNums = {};
if (!this.RecalculateData.ChangedNums[NumId])
this.RecalculateData.ChangedNums[NumId] = {};
if (this.RecalculateData.ChangedNums[NumId][Lvl] === oNum)
return false;
this.RecalculateData.ChangedNums[NumId][Lvl] = oNum;
return true;
},
Add_RecalcNumPr : function(NumPr)
{
if (undefined !== NumPr && null !== NumPr && undefined !== NumPr.NumId)
......@@ -1119,6 +1148,52 @@ CHistory.prototype.private_GetItemsCountInContentChange = function(Class, Data)
return 1;
};
CHistory.prototype.GetAllParagraphsForRecalcData = function(Props)
{
if (!this.RecalculateData.AllParagraphs)
{
if (this.Document)
this.RecalculateData.AllParagraphs = this.Document.Get_AllParagraphs({All : true});
else
this.RecalculateData.AllParagraphs = [];
}
var arrParagraphs = [];
if (!Props || true === Props.All)
{
return this.RecalculateData.AllParagraphs;
}
else if (true === Props.Style)
{
var arrStylesId = Props.StylesId;
for (var nParaIndex = 0, nParasCount = this.RecalculateData.AllParagraphs.length; nParaIndex < nParasCount; ++nParaIndex)
{
var oPara = this.RecalculateData.AllParagraphs[nParaIndex];
for (var nStyleIndex = 0, nStylesCount = arrStylesId.length; nStyleIndex < nStylesCount; ++nStyleIndex)
{
if (oPara.Pr.PStyle === arrStylesId[nStyleIndex])
{
arrParagraphs.push(oPara);
break;
}
}
}
}
else if (true === Props.Numbering)
{
for (var nParaIndex = 0, nParasCount = this.RecalculateData.AllParagraphs.length; nParaIndex < nParasCount; ++nParaIndex)
{
var oPara = this.RecalculateData.AllParagraphs[nParaIndex];
var NumPr = Props.NumPr;
var _NumPr = oPara.Numbering_Get();
if (undefined != _NumPr && _NumPr.NumId === NumPr.NumId && (_NumPr.Lvl === NumPr.Lvl || undefined === NumPr.Lvl))
arrParagraphs.push(oPara);
}
}
return arrParagraphs;
};
function CRC32()
{
......
......@@ -1605,12 +1605,18 @@ CAbstractNum.prototype =
Refresh_RecalcData : function(Data)
{
var oHistory = History;
if (!oHistory)
return;
if (!oHistory.AddChangedNumberingToRecalculateData(this.Get_Id(), Data.Index, this))
return;
var NumPr = new CNumPr();
NumPr.NumId = this.Id;
NumPr.Lvl = Data.Index;
var LogicDocument = editor.WordControl.m_oLogicDocument;
var AllParagraphs = LogicDocument.Get_AllParagraphsByNumbering( NumPr );
var AllParagraphs = oHistory.GetAllParagraphsForRecalcData({Numbering : true, NumPr : NumPr});
var Count = AllParagraphs.length;
for ( var Index = 0; Index < Count; Index++ )
......
......@@ -2826,33 +2826,39 @@ CStyle.prototype =
}
},
Refresh_RecalcData2 : function()
{
// TODO: Надо сделать механизм, чтобы данное действие не вызывалось много раз подряд, а только 1.
var LogicDocument = editor.WordControl.m_oLogicDocument;
var Styles = LogicDocument.Get_Styles();
Refresh_RecalcData2 : function()
{
var oHistory = History;
if (!oHistory)
return;
var AllParagraphs = [];
if (!oHistory.AddChangedStyleToRecalculateData(this.Get_Id(), this))
return;
if (this.Id != Styles.Default.Paragraph)
{
var AllStylesId = Styles.private_GetAllBasedStylesId(this.Id);
AllParagraphs = LogicDocument.Get_AllParagraphsByStyle(AllStylesId);
LogicDocument.Add_ChangedStyle(AllStylesId);
}
else
{
AllParagraphs = LogicDocument.Get_AllParagraphs({All : true});
LogicDocument.Add_ChangedStyle([this.Id]);
}
var LogicDocument = editor.WordControl.m_oLogicDocument;
var Styles = LogicDocument.Get_Styles();
var Count = AllParagraphs.length;
for ( var Index = 0; Index < Count; Index++ )
{
var Para = AllParagraphs[Index];
Para.Refresh_RecalcData( { Type : AscDFH.historyitem_Paragraph_PStyle } );
}
},
var AllParagraphs = [];
if (this.Id != Styles.Default.Paragraph)
{
var AllStylesId = Styles.private_GetAllBasedStylesId(this.Id);
AllParagraphs = oHistory.GetAllParagraphsForRecalcData({Style : true, StylesId : AllStylesId});
LogicDocument.Add_ChangedStyle(AllStylesId);
}
else
{
AllParagraphs = oHistory.GetAllParagraphsForRecalcData({All : true});
LogicDocument.Add_ChangedStyle([this.Id]);
}
var Count = AllParagraphs.length;
for (var Index = 0; Index < Count; Index++)
{
var Para = AllParagraphs[Index];
Para.Refresh_RecalcData({Type : AscDFH.historyitem_Paragraph_PStyle});
}
},
//-----------------------------------------------------------------------------------
// Функции для совместного редактирования
//-----------------------------------------------------------------------------------
......
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