Commit cf84d35b authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Исправлены баги в Undo/Redo и совместном редактировании после отрабатывания enter внутри формулы.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59370 954022d7-b5bf-4e40-9824-e11837661b57
parent 6ba09169
......@@ -1693,11 +1693,15 @@ ParaMath.prototype.Handle_AddNewLine = function()
var ContentPos = new CParagraphContentPos();
var CurrContent = this.GetSelectContent().Content;
if (true === CurrContent.bRoot)
return false;
CurrContent.Get_ParaContentPos(this.bSelectionUse, true, ContentPos);
var NeedRecalculate = false;
if(CurrContent.Parent.kind == MATH_EQ_ARRAY)
if(MATH_EQ_ARRAY === CurrContent.ParentElement.kind)
{
var NewContent = CurrContent.Parent.addRow();
CurrContent.SplitContent(NewContent, ContentPos, 0);
......@@ -1706,14 +1710,14 @@ ParaMath.prototype.Handle_AddNewLine = function()
NeedRecalculate = true;
}
else if(CurrContent.bRoot == false && CurrContent.Parent.kind !== MATH_MATRIX)
else if(MATH_MATRIX !== CurrContent.ParentElement.kind)
{
var ctrPrp = CurrContent.Parent.CtrPrp.Copy();
var props = {row: 2, ctrPrp: ctrPrp};
var EqArray = new CEqArray(props);
var FirstContent = EqArray.getElement(0),
SecondContent = EqArray.getElement(1);
var FirstContent = EqArray.getElementMathContent(0);
var SecondContent = EqArray.getElementMathContent(1);
CurrContent.SplitContent(SecondContent, ContentPos, 0);
CurrContent.CopyTo(FirstContent, false);
......@@ -1740,10 +1744,10 @@ ParaMath.prototype.Handle_AddNewLine = function()
NeedRecalculate = true;
}
this.SetNeedResize();
if (true === NeedRecalculate)
this.SetNeedResize();
return NeedRecalculate;
};
/**
......@@ -1947,36 +1951,42 @@ function CChangesMathAddItems(Pos, Items)
CChangesMathAddItems.prototype.Type = historyitem_Math_AddItems_ToMathBase;
CChangesMathAddItems.prototype.Undo = function(Class)
{
Class.raw_RemoveFromContent(this.Pos, this.Items.length);
};
CChangesMathAddItems.prototype.Redo = function(Class)
{
Class.raw_Internal_Content_Add(this.Pos, this.Items, false);
Class.raw_AddToContent(this.Pos, this.Items, false);
};
CChangesMathAddItems.prototype.Save_Changes = function(Writer)
{
// Long : Count
// Long : Pos
// Array of String : Id
var Count = this.Items.length;
Writer.WriteLong(Count);
Writer.WriteLong(this.Pos);
for(var Index = 0; Index < Count; Index++)
{
Writer.WriteLong(this.Pos + Index);
Writer.WriteString2(this.Items[Index].Get_Id());
}
};
CChangesMathAddItems.prototype.Load_Changes = function(Reader, Class)
{
var Count = Reader.GetLong();
this.Pos = Reader.GetLong();
// Long : Count
// Long : Pos
// Array of String : Id
if(this.Items == undefined)
this.Items = [];
var Count = Reader.GetLong();
this.Pos = Reader.GetLong();
this.Items = [];
for(var Index = 0; Index < Count; Index++)
{
var Element = g_oTableId.Get_ById( Reader.GetString2() );
var Element = g_oTableId.Get_ById(Reader.GetString2());
if ( null != Element )
if (null !== Element)
this.Items.push(Element);
}
......
......@@ -12140,12 +12140,15 @@ Paragraph.prototype.private_CorrectCurPosRangeLine = function()
var RangeIndex = Ranges[Index].Range;
var LineIndex = Ranges[Index].Line;
var Range = this.Lines[LineIndex].Ranges[RangeIndex];
if (Range.W > 0)
if (undefined !== this.Lines[LineIndex] && undefined !== this.Lines[LineIndex].Ranges[RangeIndex])
{
this.CurPos.Line = LineIndex;
this.CurPos.Range = RangeIndex;
break;
var Range = this.Lines[LineIndex].Ranges[RangeIndex];
if (Range.W > 0)
{
this.CurPos.Line = LineIndex;
this.CurPos.Range = RangeIndex;
break;
}
}
}
};
......
......@@ -1041,23 +1041,33 @@ CMathBase.prototype.Draw_HighLights = function(PDSH, bAll)
PDSH.X = this.pos.x + this.ParaMath.X + this.size.width;
};
CMathBase.prototype.Internal_Content_Add = function(Pos, Items, bUpdatePosition)
CMathBase.prototype.protected_AddToContent = function(Pos, Items, bUpdatePosition)
{
History.Add(this, new CChangesMathAddItems(Pos, Items));
//History.Add( this, { Type : historyitem_Math_AddItems_ToMathBase, Pos : Pos, EndPos : Pos, Items : Items } );
this.raw_Internal_Content_Add(Pos, Items, bUpdatePosition);
this.raw_AddToContent(Pos, Items, bUpdatePosition);
this.private_UpdatePosOnAdd(Pos, bUpdatePosition);
};
CMathBase.prototype.raw_Internal_Content_Add = function(Pos, Items, bUpdatePosition)
CMathBase.prototype.raw_AddToContent = function(Pos, Items, bUpdatePosition)
{
for(var Index = 0; Index < Items.length; Index++)
this.Content.splice(Pos + Index, 0, Items[Index]);
for(var Index = 0, Count = Items.length; Index < Count; Index++)
{
var Item = Items[Index];
this.Content.splice(Pos + Index, 0, Item);
Item.ParentElement = this;
}
this.Update_Pos_After_AddItems(Pos, bUpdatePosition);
this.fillContent();
this.private_SetNeedResize();
}
CMathBase.prototype.Update_Pos_After_AddItems = CMathContent.prototype.Update_Pos_After_AddItems;
CMathBase.prototype.raw_RemoveFromContent = function(Pos, Count)
{
this.Content.splice(Pos, Count);
this.fillContent();
this.private_SetNeedResize();
};
CMathBase.prototype.private_UpdatePosOnAdd = CMathContent.prototype.private_UpdatePosOnAdd;
CMathBase.prototype.private_UpdatePosOnRemove = CMathContent.prototype.private_UpdateOnRemove;
CMathBase.prototype.private_CorrectSelectionPos = CMathContent.prototype.private_CorrectSelectionPos;
CMathBase.prototype.private_SetNeedResize = CMathContent.prototype.private_SetNeedResize;
......
......@@ -1564,9 +1564,10 @@ CMathContent.prototype =
History.Add( this, { Type : historyitem_Math_AddItem, Pos : Pos, EndPos : Pos, Items : [ Item ] } );
this.Content.splice( Pos, 0, Item );
this.Update_Pos_After_AddItems(Pos, bUpdatePosition);
this.private_UpdatePosOnAdd(Pos, bUpdatePosition);
},
Update_Pos_After_AddItems: function(Pos, bUpdatePosition)
private_UpdatePosOnAdd: function(Pos, bUpdatePosition)
{
if(bUpdatePosition !== false)
{
......@@ -1631,13 +1632,12 @@ CMathContent.prototype =
{
var Pos = ContentPos.Get(Depth);
if(this.Content[Pos].Type == para_Math_Run)
if(para_Math_Run === this.Content[Pos].Type)
{
var NewRun = this.Content[Pos].Split(ContentPos, Depth+1);
NewContent.Add_ToContent(0, NewRun);
var len = this.Content.length;
if(Pos < len - 1)
{
NewContent.Concat_ToContent( this.Content.slice(Pos + 1) );
......@@ -1645,8 +1645,7 @@ CMathContent.prototype =
}
}
this.ParaMath.SetNeedResize();
this.private_SetNeedResize();
},
Add_ToContent : function(Pos, Item)
{
......@@ -1672,7 +1671,11 @@ CMathContent.prototype =
this.CurPos = Pos;
this.private_CorrectCurPos();
this.private_UpdatePosOnRemove(Pos, Count);
},
private_UpdatePosOnRemove : function(Pos, Count)
{
// Обновим начало и конец селекта
if (true === this.Selection.Use)
{
......
......@@ -687,20 +687,10 @@ CEqArray.prototype.addRow = function()
{
this.bDecreaseRow = true;
var NewContent = new CMathContent();
this.Internal_Content_Add(this.CurPos + 1, [NewContent], true);
this.protected_AddToContent(this.CurPos + 1, [NewContent], true);
return NewContent;
}
/*CEqArray.prototype.addRow = function()
{
this.Content.splice( this.CurPos + 1, 0, new CMathContent() );
this.Content[this.CurPos + 1].ParentElement = this;
//this.Pr.DecreaseCountRow();
//this.bDecreaseRow = true;
return this.Content[this.CurPos + 1];
}*/
CEqArray.prototype.fillContent = function()
{
var nRowsCount = this.Content.length;
......
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