Commit 8ce221b0 authored by Anna.Pavlova's avatar Anna.Pavlova

delete (изменила remove)

поправила reduction (при изменении размера не учитывались настройки на уровень выше)
изменила расчет reduction для simple fraction

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48639 954022d7-b5bf-4e40-9824-e11837661b57
parent 1e61f4d2
......@@ -263,9 +263,9 @@ CControlComposition.prototype =
//backspace
else if(e.KeyCode==8)
{
try{
if(this.Content[this.CurPos].Remove())
try
{
if(this.Content[this.CurPos].Remove(1))
{
//this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
......@@ -279,8 +279,18 @@ CControlComposition.prototype =
return true;
}
//delete
else if ( e.KeyCode == 46)
{
if(this.Content[this.CurPos].Remove(-1))
{
//this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
}
}
return false;
return false;
},
OnKeyPress: function(e)
{
......
......@@ -53,7 +53,7 @@ CMathBase.prototype =
{
this.elements[i][j] = new CMathContent();
this.elements[i][j].relate(this);
this.elements[i][j].setReduct(this.reduct);
//this.elements[i][j].setReduct(this.reduct);
this.elements[i][j].setComposition(this.Composition);
this.elements[i][j].setRunPrp(this.RunPrp);
......@@ -82,7 +82,7 @@ CMathBase.prototype =
txtPrp.Merge(this.textPrp);
txtPrp.FontSize *= this.reduct;
//txtPrp.FontSize *= this.reduct;
return txtPrp;
},
......@@ -124,7 +124,7 @@ CMathBase.prototype =
if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].fillPlaceholders();
},
setReduct: function(coeff)
old_setReduct: function(coeff)
{
this.reduct = this.reduct*coeff;
for(var i=0; i < this.nRow; i++)
......@@ -134,6 +134,14 @@ CMathBase.prototype =
this.elements[i][j].setReduct(coeff);
}
},
setReduct: function(coeff)
{
this.reduct = this.reduct*coeff;
},
getReduct: function()
{
return this.reduct;
},
addMCToContent: function()
{
if(arguments.length == this.nRow*this.nCol)
......@@ -149,7 +157,7 @@ CMathBase.prototype =
if(! this.elements[i][j].IsJustDraw() )
{
this.elements[i][j].setComposition(this.Composition);
this.elements[i][j].setReduct(this.reduct);
//this.elements[i][j].setReduct(this.reduct);
this.elements[i][j].setRunPrp(this.RunPrp);
}
this.elements[i][j].bMObjs = true;
......@@ -758,9 +766,9 @@ CMathBase.prototype =
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].draw();
},
remove: function()
remove: function(order)
{
return this.Parent.remove();
return this.Parent.remove(order);
},
recalculateSize: function()
{
......
function CBarFraction()
{
this.bHide = false;
this.bSimple = false;
CMathBase.call(this);
}
extend(CBarFraction, CMathBase);
......@@ -51,10 +52,16 @@ CBarFraction.prototype.hideBar = function(flag)
}
CBarFraction.prototype.setSimple = function(flag)
{
if(flag)
this.setReduct(DEGR_REDUCT);
else
this.setReduct(1);
this.bSimple = flag;
}
CBarFraction.prototype.getTxtPrp = function()
{
var txtPrp = CBarFraction.superclass.getTxtPrp.call(this);
if(this.bSimple)
txtPrp.FontSize *= DEGR_REDUCT; // делаем здес, чтобы учесть при пересчете расстояний
return txtPrp;
}
//////////
......@@ -163,6 +170,10 @@ CNumerator.prototype.getTxtPrp = function()
{
return this.Parent.getTxtPrp();
}
CNumerator.prototype.getReduct = function()
{
return this.Parent.getReduct();
}
function CDenominator()
{
......@@ -267,6 +278,10 @@ CDenominator.prototype.getTxtPrp = function()
{
return this.Parent.getTxtPrp();
}
CDenominator.prototype.getReduct = function()
{
return this.Parent.getReduct();
}
//////////
......
......@@ -20,6 +20,8 @@ function mathElem(_val)
}; //mm
}
//TODO
//переделать/продумать DotIndef, т.к. при перетаскивании из одного места в другое флаг DotIndef может измениться для другого контента
......@@ -2187,7 +2189,7 @@ CMathContent.prototype =
this.CurPos = 0;
}
else if( this.selection.startPos != this.selection.endPos ) //т.к. после того как удалили тагет у нас эти 2 значения не равны, равенство их выставляется позднее, после добавления символа
this.remove();
this.remove(1);
},
setReduct: function(coeff)
{
......@@ -2198,7 +2200,9 @@ CMathContent.prototype =
var txtPrp;
if(!this.bRoot)
{
txtPrp = this.Parent.getTxtPrp();
}
else
{
txtPrp = new CMathTextPrp();
......@@ -2206,10 +2210,20 @@ CMathContent.prototype =
}
txtPrp.Merge(this.textPrp);
txtPrp.FontSize *= this.reduct; // для итераторов
//txtPrp.FontSize *= this.reduct; // для итераторов
return txtPrp;
},
getReduct: function()
{
var result = this.reduct;
if(!this.bRoot)
result *= this.Parent.getReduct(); // чтобы не перекрывать
return result;
},
relate: function(parent)
{
if(parent === -1)
......@@ -2854,7 +2868,7 @@ CMathContent.prototype =
return {x: X, y: Y};
},
remove: function()
old_remove: function()
{
var state =
{
......@@ -2862,7 +2876,7 @@ CMathContent.prototype =
bBeginning: false /*в начале контента или нет*/
//bTargetAfterRemove: false /*нужно ли селектить target, этот флаг выставляется в CMathBase*/
};
var CurrContent = SelectContent = null;
var CurrContent = SelectContent = null;
if( this.IsTarget() )
{
......@@ -2923,7 +2937,7 @@ CMathContent.prototype =
end = tmp;
}
}
else
else //backspace
{
start = this.CurPos;
end = this.CurPos + 1;
......@@ -2949,7 +2963,7 @@ CMathContent.prototype =
/*if(this.content.length == 1 && ! this.bRoot )//только CEmpty
{
this.add(StartTextElement);
this.add(StartTextElement);
}*/
//this.recalculate();
......@@ -2966,10 +2980,147 @@ CMathContent.prototype =
CurrContent = SelectContent = this;
state.bBeginning = true;
}
}
return {CurrContent : CurrContent, SelectContent: SelectContent, state: state };
},
remove: function(order)
{
var state =
{
bDelete: false, /* нужно ли пересчитывать позицию или нет, работает при backspace */
bBeging: false, /* в начале контента или нет */
bEnd: false /* в конце */
};
var CurrContent = SelectContent = null;
if( this.IsTarget() )
{
if ( !this.bRoot )
{
var result = this.Parent.remove(-2);
SelectContent = result.SelectContent;
CurrContent = this;
}
else
{
//в основном контенте и элемент target
//переделать : вставлять объект типа placeholder
this.content.length = 0;
state.bDelete = true;
SelectContent = this;
CurrContent = this;
}
}
else
{
var bFirst = order == 1 && this.CurPos == 0,
bLast = order == -1 && this.CurPos == this.content.length - 1;
if(bFirst)
state.bBeging = true;
else if(bLast)
state.bEnd = true;
if(bFirst || bLast)
{
if( ! this.bRoot )
{
var result = this.Parent.remove(-2);
SelectContent = result.SelectContent;
CurrContent = this;
}
else
{
CurrContent = SelectContent = this;
}
}
else if(order == 1 || order == -1)
{
state.bDelete = this.remove_internal(order);
SelectContent = this;
CurrContent = this;
}
else if(order == -2)
{
this.setStart_Selection(this.CurPos + 1);
this.setEnd_Selection(this.CurPos - 1);
this.selection.active = false;
SelectContent = this;
CurrContent = null; // т.к. пришли из другого контента
}
}
return {CurrContent : CurrContent, SelectContent: SelectContent, state: state };
},
remove_internal: function(order)
{
var bDelete = false;
var bSelect = this.selection.startPos !== this.selection.endPos;
var bMEDirect = order == 1 && this.content[this.CurPos].value.empty,
bMEReverse = order == -1 && this.content[this.CurPos + 1].value.SUBCONTENT;
if(!bSelect && bMEDirect)
{
this.setStart_Selection(this.CurPos);
this.setEnd_Selection( this.CurPos-2 );
this.selection.active = false;
}
else if(!bSelect && bMEReverse)
{
this.setStart_Selection(this.CurPos);
this.setEnd_Selection( this.CurPos + 2 );
this.selection.active = false;
}
else
{
var start, end;
if(bSelect)
{
start = this.selection.startPos;
end = this.selection.endPos;
if(start > end)
{
tmp = start;
start = end;
end = tmp;
}
}
else if(order == 1)
{
start = this.CurPos;
end = this.CurPos + 1;
}
else if(order == -1)
{
start = this.CurPos + 1;
end = this.CurPos + 2;
}
var tmp = new Array();
for(var i = 0; i< start; i++)
tmp.push(this.content[i]);
for (var j = end; j < this.content.length; j++)
tmp.push(this.content[j]);
this.content.length = 0;
this.content = tmp;
this.CurPos = start - 1;
this.setStart_Selection(this.CurPos);
this.selection.active = false;
bDelete = true;
}
return bDelete;
},
setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
{
......@@ -3864,29 +4015,25 @@ CMathComposition.prototype =
{
return this.Root.size;
},
Remove: function()
Remove: function(order)
{
var result = false;
this.ClearSelect();
var removal = this.SelectContent.remove();
this.CurrentContent = removal.CurrContent;
this.SelectContent = removal.SelectContent;
var result = this.SelectContent.remove(order);
this.CurrentContent = result.CurrContent;
this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
if( removal.state.bRecPosition )
if( result.state.bDelete )
{
this.CurrentContent.RecalculateReverse();
this.UpdatePosition();
result = true;
}
this.CheckTarget();
return result;
return result.state.bDelete;
},
UpdatePosition: function()
{
......
......@@ -136,7 +136,10 @@ CMathText.prototype =
{
var txtPrp = this.Parent.getTxtPrp();
txtPrp.Merge(this.textPrp);
var reduct = this.Parent.getReduct(); // чтобы не перекрывать
txtPrp.FontSize *= reduct;
//txtPrp.FontSize *= this.Parent.getReduct(); // чтобы не перекрывать
//txtPrp.Italic = false; // всегда отправляем "false"!!
return txtPrp;
......
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