Commit 2615d720 authored by Sergey.Tsarkov's avatar Sergey.Tsarkov Committed by Alexander.Trofimov

удаление в формуле

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58629 954022d7-b5bf-4e40-9824-e11837661b57
parent aafe75c5
...@@ -246,8 +246,6 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -246,8 +246,6 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
} }
else if (oElem.Type == para_Math_Run && oElem.IsPlaceholder() && bOnAddText == true) else if (oElem.Type == para_Math_Run && oElem.IsPlaceholder() && bOnAddText == true)
{ {
History.Create_NewPoint();
var Items = []; var Items = [];
Items.push(oContent.Content.content[0]); Items.push(oContent.Content.content[0]);
oContent.Content.content.splice( 0, 1 ); oContent.Content.content.splice( 0, 1 );
...@@ -276,17 +274,16 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -276,17 +274,16 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
} }
else //слева ран else //слева ран
{ {
History.Create_NewPoint(); if(prevElem.Content.length == 0 && !bOnAddText)
{
this.RemoveEmptyRun(prevElem);
this.Remove( Direction, bOnAddText );
return;
}
prevElem.Remove(Direction, bOnAddText); prevElem.Remove(Direction, bOnAddText);
if(prevElem.Content.length == 0 && !bOnAddText) //тк pararun пустой, удаляем его if(prevElem.Content.length == 0 && !bOnAddText) //тк pararun пустой, удаляем его
{ this.RemoveEmptyRun(prevElem);
var Items = [];
Items.push(prevElem.Parent.content[0]);
prevElem.Parent.content.splice( 0, 1 );
History.Add(prevElem.Parent, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: 0});
prevElem.Parent.CurPos--;
}
return; return;
} }
} }
...@@ -322,7 +319,6 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -322,7 +319,6 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
} }
else //справа ран else //справа ран
{ {
History.Create_NewPoint();
nextElem.State.ContentPos = 0; nextElem.State.ContentPos = 0;
nextElem.Remove(Direction, bOnAddText); nextElem.Remove(Direction, bOnAddText);
if(nextElem.Content.length == 0 && !bOnAddText) //тк pararun пустой, удаляем его if(nextElem.Content.length == 0 && !bOnAddText) //тк pararun пустой, удаляем его
...@@ -337,17 +333,18 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -337,17 +333,18 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
} }
} }
History.Create_NewPoint();
oElem.Remove(Direction, bOnAddText); oElem.Remove(Direction, bOnAddText);
if(oElem.Content.length == 0 && !bOnAddText) //тк pararun пустой, удаляем его
if (oElem.Content.length == 0 && oContent.Start == oContent.Content.content.length - 1 &&
oContent.Start >0 && oContent.Content.content[oContent.Start-1].Type == para_Math_Composition) //тк это крайний правый пустой ран и слева композиция, он остается.
return;
else if( oElem.Content.length == 0 && !bOnAddText) //тк pararun пустой, удаляем его
{ {
var Items = []; var Items = [];
Items.push(oElem.Parent.content[oContent.Start]); Items.push(oElem.Parent.content[oContent.Start]);
oElem.Parent.content.splice( oContent.Start, 1 ); oElem.Parent.content.splice( oContent.Start, 1 );
History.Add(oElem.Parent, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: oContent.Start}); History.Add(oElem.Parent, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: oContent.Start});
oContent.Content.CurPos--; this.PosTransitLeft(oContent.Content);
if (oContent.Content.CurPos < 0)
oContent.Content.CurPos = 0;
oContent.Content.SetRunEmptyToContent(true); oContent.Content.SetRunEmptyToContent(true);
} }
} }
...@@ -357,8 +354,8 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -357,8 +354,8 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
}, },
ParaMath.prototype.RemoveElem = function(oContent, Direction, bOnAdd) ParaMath.prototype.RemoveElem = function(oContent, Direction, bOnAdd)
{ {
var oMath = oContent.Content; var oMath = oContent.Content;
var oMathContent = oMath.content; var oMathContent = oMath.content;
...@@ -392,18 +389,25 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -392,18 +389,25 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
var oElem = oMathContent[start]; var oElem = oMathContent[start];
if ( para_Math_Run == oElem.Type && oElem.Selection.Use) if ( para_Math_Run == oElem.Type && oElem.Selection.Use)
{
if (oElem.Selection.EndPos - oElem.Selection.StartPos != oElem.Content.length)
{ {
oElem.Remove(Direction,false); oElem.Remove(Direction,false);
start++; start++;
if (!bRightSelect) if (!bRightSelect)
oMath.CurPos++; oMath.CurPos++;
} }
else
nStartContent--;
}
else else
{ {
Items.push(oElem); Items.push(oElem);
History.Add(oMath, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: start}); History.Add(oMath, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: start});
} }
if ( start != end)
{
Items = []; Items = [];
for (var i=nStartContent+1; i<nEndContent; i++) for (var i=nStartContent+1; i<nEndContent; i++)
{ {
...@@ -416,17 +420,23 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -416,17 +420,23 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
Items = []; Items = [];
var oElem = oMathContent[end]; var oElem = oMathContent[end];
if ( para_Math_Run == oElem.Type && oElem.Selection.Use) if ( para_Math_Run == oElem.Type && oElem.Selection.Use)
{
if (oElem.Selection.EndPos - oElem.Selection.StartPos != oElem.Content.length)
{ {
oElem.Remove(Direction,false); oElem.Remove(Direction,false);
end--; end--;
if (bRightSelect) if (bRightSelect)
oMath.CurPos--; this.PosTransitLeft(oMath);
}
else
nEndContent++;
} }
else else
{ {
Items.push(oElem); Items.push(oElem);
History.Add(oMath, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: end}); History.Add(oMath, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: end});
} }
}
var len = end - start + 1; var len = end - start + 1;
oMathContent.splice( start, len ); oMathContent.splice( start, len );
...@@ -444,12 +454,35 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText) ...@@ -444,12 +454,35 @@ ParaMath.prototype.Remove = function(Direction, bOnAddText)
PosEnd = Pos + 1; PosEnd = Pos + 1;
History.Add(oContent.Content, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd}); History.Add(oContent.Content, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd});
oContent.Content.SetRunEmptyToContent(true);
if (oMath.CurPos < 0) if (oMath.CurPos < 0)
oMath.CurPos = 0; oMath.CurPos = 0;
this.Selection_Remove(); this.Selection_Remove();
return; return;
}; };
ParaMath.prototype.RemoveEmptyRun = function(oElem)
{
var Items = [];
Items.push(oElem.Parent.content[oElem.Parent.CurPos]);
oElem.Parent.content.splice( oElem.Parent.CurPos, 1 );
History.Add(oElem.Parent, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: oElem.Parent.CurPos});
this.PosTransitLeft(oElem.Parent)
}
ParaMath.prototype.PosTransitLeft = function(oElem)
{
var oPreElem;
if (oElem.CurPos > 0)
{
oElem.CurPos--;
oPreElem = oElem.content[oElem.CurPos];
if (oPreElem.Type == para_Math_Run)
oPreElem.State.ContentPos = oPreElem.Content.length;
}
}
ParaMath.prototype.GetSelectContent = function() ParaMath.prototype.GetSelectContent = function()
{ {
......
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