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 = ...@@ -263,9 +263,9 @@ CControlComposition.prototype =
//backspace //backspace
else if(e.KeyCode==8) else if(e.KeyCode==8)
{ {
try{ try
{
if(this.Content[this.CurPos].Remove()) if(this.Content[this.CurPos].Remove(1))
{ {
//this.UpdatePosition(); //this.UpdatePosition();
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]); editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, editor.WordControl.m_oLogicDocument.Pages[0]);
...@@ -279,6 +279,16 @@ CControlComposition.prototype = ...@@ -279,6 +279,16 @@ CControlComposition.prototype =
return true; 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;
}, },
......
...@@ -53,7 +53,7 @@ CMathBase.prototype = ...@@ -53,7 +53,7 @@ CMathBase.prototype =
{ {
this.elements[i][j] = new CMathContent(); this.elements[i][j] = new CMathContent();
this.elements[i][j].relate(this); 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].setComposition(this.Composition);
this.elements[i][j].setRunPrp(this.RunPrp); this.elements[i][j].setRunPrp(this.RunPrp);
...@@ -82,7 +82,7 @@ CMathBase.prototype = ...@@ -82,7 +82,7 @@ CMathBase.prototype =
txtPrp.Merge(this.textPrp); txtPrp.Merge(this.textPrp);
txtPrp.FontSize *= this.reduct; //txtPrp.FontSize *= this.reduct;
return txtPrp; return txtPrp;
}, },
...@@ -124,7 +124,7 @@ CMathBase.prototype = ...@@ -124,7 +124,7 @@ CMathBase.prototype =
if(!this.elements[i][j].IsJustDraw()) if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].fillPlaceholders(); this.elements[i][j].fillPlaceholders();
}, },
setReduct: function(coeff) old_setReduct: function(coeff)
{ {
this.reduct = this.reduct*coeff; this.reduct = this.reduct*coeff;
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
...@@ -134,6 +134,14 @@ CMathBase.prototype = ...@@ -134,6 +134,14 @@ CMathBase.prototype =
this.elements[i][j].setReduct(coeff); this.elements[i][j].setReduct(coeff);
} }
}, },
setReduct: function(coeff)
{
this.reduct = this.reduct*coeff;
},
getReduct: function()
{
return this.reduct;
},
addMCToContent: function() addMCToContent: function()
{ {
if(arguments.length == this.nRow*this.nCol) if(arguments.length == this.nRow*this.nCol)
...@@ -149,7 +157,7 @@ CMathBase.prototype = ...@@ -149,7 +157,7 @@ CMathBase.prototype =
if(! this.elements[i][j].IsJustDraw() ) if(! this.elements[i][j].IsJustDraw() )
{ {
this.elements[i][j].setComposition(this.Composition); 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].setRunPrp(this.RunPrp);
} }
this.elements[i][j].bMObjs = true; this.elements[i][j].bMObjs = true;
...@@ -758,9 +766,9 @@ CMathBase.prototype = ...@@ -758,9 +766,9 @@ CMathBase.prototype =
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
this.elements[i][j].draw(); this.elements[i][j].draw();
}, },
remove: function() remove: function(order)
{ {
return this.Parent.remove(); return this.Parent.remove(order);
}, },
recalculateSize: function() recalculateSize: function()
{ {
......
function CBarFraction() function CBarFraction()
{ {
this.bHide = false; this.bHide = false;
this.bSimple = false;
CMathBase.call(this); CMathBase.call(this);
} }
extend(CBarFraction, CMathBase); extend(CBarFraction, CMathBase);
...@@ -51,10 +52,16 @@ CBarFraction.prototype.hideBar = function(flag) ...@@ -51,10 +52,16 @@ CBarFraction.prototype.hideBar = function(flag)
} }
CBarFraction.prototype.setSimple = function(flag) CBarFraction.prototype.setSimple = function(flag)
{ {
if(flag) this.bSimple = flag;
this.setReduct(DEGR_REDUCT); }
else CBarFraction.prototype.getTxtPrp = function()
this.setReduct(1); {
var txtPrp = CBarFraction.superclass.getTxtPrp.call(this);
if(this.bSimple)
txtPrp.FontSize *= DEGR_REDUCT; // делаем здес, чтобы учесть при пересчете расстояний
return txtPrp;
} }
////////// //////////
...@@ -163,6 +170,10 @@ CNumerator.prototype.getTxtPrp = function() ...@@ -163,6 +170,10 @@ CNumerator.prototype.getTxtPrp = function()
{ {
return this.Parent.getTxtPrp(); return this.Parent.getTxtPrp();
} }
CNumerator.prototype.getReduct = function()
{
return this.Parent.getReduct();
}
function CDenominator() function CDenominator()
{ {
...@@ -267,6 +278,10 @@ CDenominator.prototype.getTxtPrp = function() ...@@ -267,6 +278,10 @@ CDenominator.prototype.getTxtPrp = function()
{ {
return this.Parent.getTxtPrp(); return this.Parent.getTxtPrp();
} }
CDenominator.prototype.getReduct = function()
{
return this.Parent.getReduct();
}
////////// //////////
......
...@@ -20,6 +20,8 @@ function mathElem(_val) ...@@ -20,6 +20,8 @@ function mathElem(_val)
}; //mm }; //mm
} }
//TODO //TODO
//переделать/продумать DotIndef, т.к. при перетаскивании из одного места в другое флаг DotIndef может измениться для другого контента //переделать/продумать DotIndef, т.к. при перетаскивании из одного места в другое флаг DotIndef может измениться для другого контента
...@@ -2187,7 +2189,7 @@ CMathContent.prototype = ...@@ -2187,7 +2189,7 @@ CMathContent.prototype =
this.CurPos = 0; this.CurPos = 0;
} }
else if( this.selection.startPos != this.selection.endPos ) //т.к. после того как удалили тагет у нас эти 2 значения не равны, равенство их выставляется позднее, после добавления символа else if( this.selection.startPos != this.selection.endPos ) //т.к. после того как удалили тагет у нас эти 2 значения не равны, равенство их выставляется позднее, после добавления символа
this.remove(); this.remove(1);
}, },
setReduct: function(coeff) setReduct: function(coeff)
{ {
...@@ -2198,7 +2200,9 @@ CMathContent.prototype = ...@@ -2198,7 +2200,9 @@ CMathContent.prototype =
var txtPrp; var txtPrp;
if(!this.bRoot) if(!this.bRoot)
{
txtPrp = this.Parent.getTxtPrp(); txtPrp = this.Parent.getTxtPrp();
}
else else
{ {
txtPrp = new CMathTextPrp(); txtPrp = new CMathTextPrp();
...@@ -2206,10 +2210,20 @@ CMathContent.prototype = ...@@ -2206,10 +2210,20 @@ CMathContent.prototype =
} }
txtPrp.Merge(this.textPrp); txtPrp.Merge(this.textPrp);
txtPrp.FontSize *= this.reduct; // для итераторов
//txtPrp.FontSize *= this.reduct; // для итераторов
return txtPrp; return txtPrp;
}, },
getReduct: function()
{
var result = this.reduct;
if(!this.bRoot)
result *= this.Parent.getReduct(); // чтобы не перекрывать
return result;
},
relate: function(parent) relate: function(parent)
{ {
if(parent === -1) if(parent === -1)
...@@ -2854,7 +2868,7 @@ CMathContent.prototype = ...@@ -2854,7 +2868,7 @@ CMathContent.prototype =
return {x: X, y: Y}; return {x: X, y: Y};
}, },
remove: function() old_remove: function()
{ {
var state = var state =
{ {
...@@ -2923,7 +2937,7 @@ CMathContent.prototype = ...@@ -2923,7 +2937,7 @@ CMathContent.prototype =
end = tmp; end = tmp;
} }
} }
else else //backspace
{ {
start = this.CurPos; start = this.CurPos;
end = this.CurPos + 1; end = this.CurPos + 1;
...@@ -2966,10 +2980,147 @@ CMathContent.prototype = ...@@ -2966,10 +2980,147 @@ CMathContent.prototype =
CurrContent = SelectContent = this; CurrContent = SelectContent = this;
state.bBeginning = true; 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 }; 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() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
{ {
...@@ -3864,29 +4015,25 @@ CMathComposition.prototype = ...@@ -3864,29 +4015,25 @@ CMathComposition.prototype =
{ {
return this.Root.size; return this.Root.size;
}, },
Remove: function() Remove: function(order)
{ {
var result = false;
this.ClearSelect(); this.ClearSelect();
var removal = this.SelectContent.remove(); var result = this.SelectContent.remove(order);
this.CurrentContent = removal.CurrContent; this.CurrentContent = result.CurrContent;
this.SelectContent = removal.SelectContent; this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
if( removal.state.bRecPosition ) if( result.state.bDelete )
{ {
this.CurrentContent.RecalculateReverse(); this.CurrentContent.RecalculateReverse();
this.UpdatePosition(); this.UpdatePosition();
result = true;
} }
this.CheckTarget(); this.CheckTarget();
return result; return result.state.bDelete;
}, },
UpdatePosition: function() UpdatePosition: function()
{ {
......
...@@ -136,7 +136,10 @@ CMathText.prototype = ...@@ -136,7 +136,10 @@ CMathText.prototype =
{ {
var txtPrp = this.Parent.getTxtPrp(); var txtPrp = this.Parent.getTxtPrp();
txtPrp.Merge(this.textPrp); txtPrp.Merge(this.textPrp);
var reduct = this.Parent.getReduct(); // чтобы не перекрывать
txtPrp.FontSize *= reduct;
//txtPrp.FontSize *= this.Parent.getReduct(); // чтобы не перекрывать
//txtPrp.Italic = false; // всегда отправляем "false"!! //txtPrp.Italic = false; // всегда отправляем "false"!!
return txtPrp; 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