Commit 83764c43 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

UNDO

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48948 954022d7-b5bf-4e40-9824-e11837661b57
parent 7811b90d
...@@ -896,6 +896,23 @@ CMathBase.prototype = ...@@ -896,6 +896,23 @@ CMathBase.prototype =
{ {
return this.elements[x][y]; return this.elements[x][y];
}, },
getStackPositions: function(stack)
{
stack.push({X: this.CurPos_X, Y: this.CurPos_Y});
this.Parent.getStackPositions(stack);
},
getContent: function(stack, bCurrent)
{
var pos = stack.pop();
if(bCurrent)
{
this.CurPos_X = pos.X;
this.CurPos_Y = pos.Y;
}
var content = this.elements[pos.X][pos.Y].getContent(stack, bCurrent);
return content;
},
old_setTxtPrp: function(txtPrp) old_setTxtPrp: function(txtPrp)
{ {
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
...@@ -903,7 +920,7 @@ CMathBase.prototype = ...@@ -903,7 +920,7 @@ CMathBase.prototype =
if(!this.elements[i][j].IsJustDraw()) if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].setTxtPrp(txtPrp); this.elements[i][j].setTxtPrp(txtPrp);
}, },
getRealPosition: function(type) old_getRealPosition: function(type)
{ {
var pos = this.elements[this.CurPos_X][this.CurPos_Y].getRealPosition(type); var pos = this.elements[this.CurPos_X][this.CurPos_Y].getRealPosition(type);
......
...@@ -9139,7 +9139,7 @@ CDocument.prototype = ...@@ -9139,7 +9139,7 @@ CDocument.prototype =
this.History.Redo(); this.History.Redo();
this.Recalculate( false, false, this.History.RecalculateData ); this.Recalculate( false, false, this.History.RecalculateData );
this.Document_UpdateSelectionState(); //this.Document_UpdateSelectionState();
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
}, },
......
...@@ -2,6 +2,7 @@ var historyitem_Math_AddItem = 1; // Добавляем эл ...@@ -2,6 +2,7 @@ var historyitem_Math_AddItem = 1; // Добавляем эл
var historyitem_Math_RemoveItem = 2; // Удаляем элемент var historyitem_Math_RemoveItem = 2; // Удаляем элемент
var TEST = true; var TEST = true;
var TEST_2 = false;
var StartTextElement = 0x2B1A; // Cambria Math var StartTextElement = 0x2B1A; // Cambria Math
...@@ -2726,13 +2727,13 @@ CMathContent.prototype = ...@@ -2726,13 +2727,13 @@ CMathContent.prototype =
afterDisplacement: function(coord) //аналог mouseDown для goToUpperLevel и goToLowerLever afterDisplacement: function(coord) //аналог mouseDown для goToUpperLevel и goToLowerLever
{ {
var content = null; var content = null;
//var msCoord = this.coordWOGaps(coord); var msCoord = this.coordWOGaps(coord);
this.CurPos = this.findPosition( coord ); this.CurPos = this.findPosition( msCoord );
if( this.content[this.CurPos].value.SUBCONTENT ) if( this.content[this.CurPos].value.SUBCONTENT )
{ {
var _coord = this.getCoordElem(this.CurPos, coord); var _coord = this.getCoordElem(this.CurPos, msCoord);
content = this.content[this.CurPos].value.afterDisplacement(_coord); content = this.content[this.CurPos].value.afterDisplacement(_coord);
} }
else else
...@@ -3467,6 +3468,13 @@ CMathContent.prototype = ...@@ -3467,6 +3468,13 @@ CMathContent.prototype =
{ {
var Pos = Data.Pos; var Pos = Data.Pos;
if( this.IsTarget() ) //удаляем тагет
{
var empty = this.content[0]; //CEmpty
this.content.length = 0;
this.content.push( empty );
}
var Content_start = this.content.slice(0, Pos); var Content_start = this.content.slice(0, Pos);
var Content_end = this.content.slice(Pos); var Content_end = this.content.slice(Pos);
...@@ -3475,9 +3483,46 @@ CMathContent.prototype = ...@@ -3475,9 +3483,46 @@ CMathContent.prototype =
} }
} }
}, },
Redo: function() Redo: function(Data)
{ {
/*var type = Data.Type;
switch(type)
{
case historyitem_Math_AddItem:
{
var Pos = Data.Pos;
if( this.IsTarget() ) //удаляем тагет
{
var empty = this.content[0]; //CEmpty
this.content.length = 0;
this.content.push( empty );
}
var Content_start = this.content.slice(0, Pos);
var Content_end = this.content.slice(Pos);
this.content = Content_start.concat(Data.Items, Content_end);
break;
}
case historyitem_Math_RemoveItem:
{
var Pos = Data.Pos,
PosEnd = Data.PosEnd;
var Content_start = this.content.slice(0, Pos);
var Content_end = this.content.slice(PosEnd);
this.content = Content_start.concat(Content_end);
this.CurPos = Pos - 1;
this.setPlaceholderAfterRemove(); // выставляем placeholder после удаления всех остальных элементов
break;
}
}*/
}, },
Save_Changes: function(Data, Writer) Save_Changes: function(Data, Writer)
{ {
...@@ -3503,98 +3548,66 @@ CMathContent.prototype = ...@@ -3503,98 +3548,66 @@ CMathContent.prototype =
{ {
return false; return false;
}, },
getRealPosition: function(type) getStackPositions: function(stack)
{ {
var X = 0, stack.push( {X: this.CurPos} );
Y = 0;
var txtW = this.TxtPrp.FontSize*g_dKoef_pt_to_mm*0.01; if(!this.bRoot)
var pos; this.Parent.getStackPositions( stack );
var bSelect = this.selection.startPos !== this.selection.endPos && !this.IsTarget();
if(type == 2 && bSelect )
pos = this.selection.startPos < this.selection.endPos ? this.selection.startPos - 1 : this.selection.endPos - 1;
else
pos = this.CurPos;
if( this.content[pos].value.SUBCONTENT ) },
{ getContent: function(stack, bCurrent)
{
var content = null;
var pos = stack.pop();
var intPos = this.content[pos].value.getRealPosition(type); if(bCurrent)
X = this.content[pos - 1].widthToEl + intPos.X; this.CurPos = pos.X;
Y += intPos.Y;
}
else if(pos == this.content.length - 1)
{
X = this.content[pos].widthToEl - txtW; if(stack.length > 0 && this.content[pos.X].value.SUBCONTENT)
} content = this.content[pos.X].value.getContent(stack, bCurrent);
else if(pos == 0)
{
X = this.content[pos].widthToEl + txtW;
}
else else
{ content = this;
X = this.content[pos].widthToEl;
} return content;
return {X: X, Y: Y};
}, },
old_getRealPosition_2: function() old_getRealPosition: function(type)
{ {
var pos = {X: null, Y : null}; var X = 0,
Y = 0;
var txtW = this.TxtPrp.FontSize*g_dKoef_pt_to_mm*0.01; var txtW = this.TxtPrp.FontSize*g_dKoef_pt_to_mm*0.01;
var pos;
if(this.selection.start == this.selection.end && this.content[this.CurPos].value.SUBCONTENT) var bSelect = this.selection.startPos !== this.selection.endPos && !this.IsTarget();
{
pos = this.content[this.CurPos].value.getRealPosition_2();
}
else if(this.selection.start !== this.selection.end)
{
pos.X = this.content[ this.selection.start ].widthToEl - txtW;
pos.Y = 0;
}
else if(this.CurPos == this.content.length - 1)
{
X = this.content[this.CurPos].widthToEl - txtW; if(type == 2 && bSelect )
}
else if(this.CurPos == 0)
{ {
X = this.content[this.CurPos].widthToEl + txtW; pos = this.selection.startPos < this.selection.endPos ? this.selection.startPos : this.selection.endPos;
X = this.content[pos - 1].widthToEl;
} }
else else
{ {
X = this.content[this.CurPos].widthToEl; pos = this.CurPos;
}
return pos;
},
old_CheckTarget: function()
{
var bSelect = this.selectUse(),
bTarget = this.IsTarget();
if(bTarget) if( this.content[pos].value.SUBCONTENT )
{
if( !this.plhHide )
{ {
this.tgtSelect(); var intPos = this.content[pos].value.getRealPosition(type);
this.HideCursor(); X = this.content[pos - 1].widthToEl + intPos.X;
Y += intPos.Y;
}
else if(this.content[pos].value.empty)
{
X = this.content[pos].widthToEl + txtW;
} }
else else
{ {
this.CurPos = 0; X = this.content[pos].widthToEl;
this.ShowCursor();
} }
} }
else if(bSelect)
this.HideCursor();
else
this.ShowCursor();
this.update_Cursor(); return {X: X, Y: Y};
} }
} }
//todo //todo
...@@ -3749,6 +3762,9 @@ CMathComposition.prototype = ...@@ -3749,6 +3762,9 @@ CMathComposition.prototype =
}, },
Remove: function(order) Remove: function(order)
{ {
if(TEST_2)
var temp = 0;
if(TEST) if(TEST)
{ {
History.Create_NewPoint(); History.Create_NewPoint();
...@@ -3764,19 +3780,20 @@ CMathComposition.prototype = ...@@ -3764,19 +3780,20 @@ CMathComposition.prototype =
if( result.state.bDelete ) if( result.state.bDelete )
{ {
this.CurrentContent.RecalculateReverse();
this.UpdatePosition();
if(TEST) if(TEST)
{ {
var Pos = this.CurrentContent.CurPos + 1; var Pos = this.CurrentContent.CurPos + 1;
History.Add(this.CurrentContent, {Type: historyitem_Math_RemoveItem, Items: result.items, Pos: Pos}); History.Add(this.CurrentContent, {Type: historyitem_Math_RemoveItem, Items: result.items, Pos: Pos});
} }
this.CurrentContent.RecalculateReverse();
this.UpdatePosition();
} }
this.CheckTarget(); this.CheckTarget();
TEST_2 = !TEST_2;
return result.state.bDelete; return result.state.bDelete;
}, },
UpdatePosition: function() UpdatePosition: function()
...@@ -3859,21 +3876,22 @@ CMathComposition.prototype = ...@@ -3859,21 +3876,22 @@ CMathComposition.prototype =
Get_SelectionState : function() Get_SelectionState : function()
{ {
var State = new Object(); var State = new Object();
var RealPos = this.GetRealPosition(1);
var stackCurrent = new Array();
this.CurrentContent.getStackPositions( stackCurrent );
State.Current = State.Current =
{ {
CurPos: this.CurrentContent.CurPos, stack: stackCurrent
RealX: RealPos.X,
RealY: RealPos.Y
}; };
var RealPos_2 = this.GetRealPosition(2); var stackSelect = new Array();
this.SelectContent.getStackPositions( stackSelect );
State.Select = State.Select =
{ {
StartSelect: this.SelectContent.selection.startPos - 1, StartSelect: this.SelectContent.selection.startPos - 1,
EndSelect: this.SelectContent.selection.endPos - 1, EndSelect: this.SelectContent.selection.endPos - 1,
RealX: RealPos_2.X, stack: stackSelect
RealY: RealPos_2.Y
}; };
return State; return State;
...@@ -3882,8 +3900,8 @@ CMathComposition.prototype = ...@@ -3882,8 +3900,8 @@ CMathComposition.prototype =
{ {
var pos = this.Root.getRealPosition(type); var pos = this.Root.getRealPosition(type);
pos.x += this.Root.g_mContext.top; pos.X += this.Root.g_mContext.top;
pos.y += this.Root.g_mContext.left; pos.Y += this.Root.g_mContext.left;
return pos; return pos;
}, },
...@@ -3893,12 +3911,8 @@ CMathComposition.prototype = ...@@ -3893,12 +3911,8 @@ CMathComposition.prototype =
this.RecalculateReverse(); this.RecalculateReverse();
this.UpdatePosition(); this.UpdatePosition();
var selPos = {x: State.Select.RealX, y: State.Select.RealY}; this.SelectContent = this.Root.getContent( State.Select.stack, false );
this.SelectContent = this.Root.afterDisplacement(selPos); this.CurrentContent = this.Root.getContent( State.Current.stack, true );
var currPos = {x: State.Current.RealX, y: State.Current.RealY};
this.CurrentContent = this.Root.afterDisplacement(currPos);
if(this.SelectContent.IsTarget()) if(this.SelectContent.IsTarget())
this.CheckTarget(); this.CheckTarget();
......
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