Commit 98b046ab authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. Переделала поиск позиции -> findDisposition(SearchPos, Depth)

2. Поправила баг на Get_ParaContentPosByXY (при поиске позиции в findDisposition, когда выходили за пределы формулы, позиция не определялась)
3. Поправила баг на SetRunEmpty : неправильной была позиция, в которую добавлялись Run и поправила удаление 
ненужных Run из контента
4. Поправила Get_CompiledTextPr, менялась ссылка CompiledPr у ParaRun (из-за этого возникали проблемы с Recalculate_CurPos)
5. Поправила баг для вложенных степеней (неправильно ArgSize рассчитывался)
6. SetArgSize для ArgSize в CMathContent при открытии
7. Поправила позицию для accent

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57490 954022d7-b5bf-4e40-9824-e11837661b57
parent 51369298
......@@ -1309,11 +1309,12 @@ ParaMath.prototype =
var X = SearchPos.X,
Y = SearchPos.Y;
//console.log("Get_ParaContentPosByXY: X " + SearchPos.X + " Y " + SearchPos.Y);
SearchPos.X -= this.X;
SearchPos.Y -= this.Y;
this.Root.Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
SearchPos.X = X;
......
......@@ -1062,8 +1062,6 @@ CAccent.prototype.old_init = function(properties)
//this.setOperator(accent);
this.elements[0][0].SetDot(true);
/// вызов этой функции обязательно в конце
//this.WriteContentsToHistory();
}
CAccent.prototype.setPosition = function(pos)
{
......@@ -1079,7 +1077,7 @@ CAccent.prototype.setPosition = function(pos)
PosOper.x = this.pos.x + this.GapLeft + alignOp;
PosOper.y = this.pos.y + this.shiftX_2;
PosOper.y = this.pos.y + this.shiftX_2 ;
//PosOper.y = this.pos.y + this.size.ascent - this.shiftX;
......@@ -1136,9 +1134,8 @@ CAccent.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
letterX.Resize(oMeasure, null);
this.gap = this.operator.size.ascentSign - letterX.size.ascent;
this.shiftX_2 = this.operator.size.ascentSign;
//this.shiftX = base.size.ascent - letterX.size.ascent;
//this.shiftX_2 = this.operator.size.ascentSign;
this.shiftX_2 = 0;
}
......@@ -1173,48 +1170,30 @@ CAccent.prototype.draw = function(x, y, pGraphics)
this.operator.draw(x, y, pGraphics);
}
CAccent.prototype.findDisposition = function(pos)
CAccent.prototype.findDisposition = function(SearchPos, Depth)
{
var curs_X = 0,
curs_Y = 0;
var X, Y;
var inside_flag = -1;
var base = this.elements[0][0],
align = (this.size.width - this.elements[0][0].size.width)/2;
align = (this.size.width - this.GapLeft - this.GapRight - base.size.width)/2;
if(pos.x < align)
{
X = 0;
inside_flag = 0;
}
else if(pos.x > align + base.size.width)
{
X = base.size.width;
inside_flag = 1;
}
if(SearchPos.X < align)
SearchPos.X = 0;
else if(SearchPos.X > align + base.size.width)
SearchPos.X = base.size.width;
else
X = pos.x - align;
SearchPos.X -= align;
var accentGap = this.size.height - base.size.height;
if(pos.y < accentGap)
if(SearchPos.Y < accentGap)
{
Y = 0;
inside_flag = 2;
SearchPos.Y = 0;
}
else
Y = pos.y - accentGap;
/*if(pos.y > 0)
console.log("Pos.y " + pos.y + "accent gap" + accentGap);*/
SearchPos.Y -= accentGap;
var mouseCoord = {x: X, y: Y},
posCurs = {x: curs_X, y: curs_Y};
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth + 1);
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CAccent.prototype.setProperties = function(props)
{
......
This diff is collapsed.
......@@ -275,7 +275,7 @@ CBorderBox.prototype.setPosition = function(pos)
this.elements[0][0].setPosition(NewPos);
}
CBorderBox.prototype.findDisposition = function(mCoord)
CBorderBox.prototype.old_findDisposition = function(mCoord)
{
var X = null,
Y = null,
......@@ -327,6 +327,60 @@ CBorderBox.prototype.findDisposition = function(mCoord)
return {pos: posCurs, mCoord: coord, inside_flag: inside_flag};
}
CBorderBox.prototype.findDisposition = function(SearchPos, Depth)
{
/*var X = null,
Y = null,
inside_flag = -1;*/ // остаемя в пределах данного элемента( за границы элемента не вышли )
var alignX = 0, alignY = 0;
if(this.Pr.hideLeft == false)
alignX = this.gapBrd;
if(this.Pr.hideTop == false)
alignY = this.gapBrd;
var base = this.elements[0][0].size;
if(SearchPos.X < alignX)
{
SearchPos.X = 0;
//inside_flag = 0;
}
else if(SearchPos.X > alignX + base.width)
{
SearchPos.X = base.width;
//inside_flag = 1;
}
else
{
SearchPos.X -= alignX;
}
if(SearchPos.Y < alignY)
{
SearchPos.Y = 0;
//inside_flag = 2;
}
else if(SearchPos.Y > alignY + base.height)
{
SearchPos.Y = base.height;
//inside_flag = 2;
}
else
{
SearchPos.Y -= alignY;
}
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
/*var coord = {x: X, y: Y},
posCurs = {x: 0, y: 0};*/
//return {pos: posCurs, mCoord: coord, inside_flag: inside_flag};
}
CBorderBox.prototype.getBase = function()
{
return this.elements[0][0];
......@@ -489,21 +543,15 @@ CBox.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.setContent();
/*if(this.Pr.opEmu)
{
this.elements[0][0].decreaseArgSize();
}*/
}
CBox.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
var CurrArgSize = new CMathArgSize();
CurrArgSize.Merge(ArgSize);
var ArgSizeBox = ArgSize.Copy();
if(this.Pr.opEmu)
CurrArgSize.decrease();
ArgSizeBox.decrease();
CBox.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, CurrArgSize);
CBox.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSizeBox);
}
CBox.prototype.setProperties = function(props)
{
......
......@@ -49,7 +49,7 @@ CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
var ArgSzDegr = new CMathArgSize();
var ArgSzDegr = ArgSize.Copy();
ArgSzDegr.decrease();
this.elements[0][1].Resize(oMeasure, this, ParaMath, RPI, ArgSzDegr);
......@@ -265,74 +265,6 @@ CDegree.prototype.old_findDisposition = function(mCoord)
var inside_flag = -1;
var shBase = 0,
shIter = 0;
if(this.upper > 0)
shBase = this.upper;
else
shIter = - this.upper;
if( mCoord.x < this.elements[0][0].size.width)
{
if( this.elements[0][0].IsJustDraw() )
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - shIter;
inside_flag = 0;
}
else
{
X = 0; Y = 0; // встаем в первый элемент
coordX = mCoord.x;
coordY = mCoord.y - shBase;
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ))
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - shIter;
inside_flag = 0;
}
else if(mCoord.x > this.size.width)
{
X = 0; Y = 1; // встаем во второй элемент
coordX = this.size.width;
coordY = mCoord.y - shIter;
inside_flag = 1;
}
else
{
X = 0; Y = 1; // встаем во второй элемент
coordX = mCoord.x - (this.elements[0][0].size.width + this.dW);
coordY = mCoord.y - shIter;
}
if(coordY < 0)
{
coordY = 0;
inside_flag = 2;
}
else if(coordY > this.elements[X][Y].size.height)
{
coordY = this.elements[X][Y].size.height;
inside_flag = 2;
}
var mCoord = {x: coordX, y: coordY};
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
CDegree.prototype.findDisposition = function(mCoord)
{
var coordX, coordY;
var X, Y;
var inside_flag = -1;
if( mCoord.x < this.elements[0][0].size.width)
{
if( this.elements[0][0].IsJustDraw() )
......@@ -386,64 +318,59 @@ CDegree.prototype.findDisposition = function(mCoord)
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
CDegree.prototype.old_findDisposition = function(mCoord)
CDegree.prototype.findDisposition = function(SearchPos, Depth)
{
var coordX, coordY;
var X, Y;
var base = this.elements[0][0];
var inside_flag = -1;
var Curr_Pos_X = 0,
Curr_Pos_Y = SearchPos.Pos.Get(Depth+1);
if( mCoord.x < this.elements[0][0].size.width)
if( SearchPos.X < base.size.width)
{
if( this.elements[0][0].IsJustDraw() )
if( base.IsJustDraw() )
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 0;
Curr_Pos_Y = 1; // позиция итератора
SearchPos.X = 0;
}
else
{
X = 0; Y = 0; // встаем в первый элемент
coordX = mCoord.x;
coordY = mCoord.y - ( this.size.center - this.elements[0][0].size.center);
Curr_Pos_Y = 0; // позиция основания
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ))
else if(SearchPos.X < (base.size.width + this.dW ))
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 0;
Curr_Pos_Y = 1; // позиция итератора
SearchPos.X = 0;
}
else if(mCoord.x > this.size.width)
else if(SearchPos.X > this.size.width)
{
X = 0; Y = 1; // встаем во второй элемент
coordX = this.size.width;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 1;
Curr_Pos_Y = 1;
SearchPos.X = this.size.width;
}
else
{
X = 0; Y = 1; // встаем во второй элемент
coordX = mCoord.x - (this.elements[0][0].size.width + this.dW);
coordY = mCoord.y - this.shiftDegree;
Curr_Pos_Y = 1;
SearchPos.X -= base.size.width + this.dW;
}
if(coordY < 0)
{
coordY = 0;
inside_flag = 2;
}
else if(coordY > this.elements[X][Y].size.height)
{
coordY = this.elements[X][Y].size.height;
inside_flag = 2;
}
var alignY = 0;
if(Curr_Pos_Y == 0)
alignY = this.upBase;
else
alignY = this.upIter;
var mCoord = {x: coordX, y: coordY};
if(SearchPos.Y < alignY)
SearchPos.Y = 0;
else if(SearchPos.Y > alignY + this.elements[Curr_Pos_X][Curr_Pos_Y].size.height)
SearchPos.Y = this.elements[Curr_Pos_X][Curr_Pos_Y].size.height;
else
SearchPos.Y -= alignY;
SearchPos.Pos.Update(Curr_Pos_X, Depth);
SearchPos.Pos.Update(Curr_Pos_Y, Depth+1);
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
CDegree.prototype.getIterator = function()
{
......@@ -745,8 +672,7 @@ CDegreeSubSup.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSi
this.Parent = Parent;
this.ParaMath = ParaMath;
var ArgSzIters = new CMathArgSize();
ArgSzIters.Merge(ArgSize);
var ArgSzIters = ArgSize.Copy();
ArgSzIters.decrease();
if(this.Pr.type == DEGREE_SubSup)
......
......@@ -354,7 +354,7 @@ CFraction.prototype.setPosition = function(pos)
else
CFraction.superclass.setPosition.call(this, pos);
}
CFraction.prototype.findDisposition = function( mCoord )
CFraction.prototype.old_findDisposition = function(mCoord)
{
var disposition;
......@@ -421,6 +421,63 @@ CFraction.prototype.findDisposition = function( mCoord )
return disposition;
}
CFraction.prototype.findDisposition = function(SearchPos, Depth)
{
if(this.Pr.type == SKEWED_FRACTION)
{
var Numerator = this.elements[0][0].size,
Denominator = this.elements[0][1].size;
//posCurs.x = 0;
SearchPos.Pos.Update(0, Depth);
if( SearchPos.X < (Numerator.width + this.gapSlash/2))
{
if(Numerator.width < SearchPos.X)
{
SearchPos.X = Numerator.width;
}
if(Numerator.height < SearchPos.Y)
{
SearchPos.Y = Numerator.height;
}
SearchPos.Pos.Update(0, Depth+1);
//posCurs.y = 0;
}
else
{
if(SearchPos.X < this.size.width - Denominator.width)
{
SearchPos.X = 0;
}
else if(SearchPos.X > this.size.width)
{
SearchPos.X = Denominator.width;
}
else
SearchPos.X -= Numerator.width - this.gapSlash;
if( SearchPos.Y < this.size.height - Denominator.height)
{
SearchPos.Y = 0;
}
else if(SearchPos.Y > this.size.height)
{
SearchPos.Y = Denominator.height;
}
else
SearchPos.Y -= Numerator.height;
SearchPos.Pos.Update(1, Depth+1);
//posCurs.y = 1;
}
}
else
CFraction.superclass.findDisposition.call(this, SearchPos, Depth);
}
CFraction.prototype.setProperties = function(props)
{
var bBar = props.type === BAR_FRACTION || props.type === NO_BAR_FRACTION,
......@@ -575,17 +632,17 @@ CNumerator.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent};
}
CNumerator.prototype.findDisposition = function(mCoord)
CNumerator.prototype.findDisposition = function(SearchPos, Depth)
{
var arg = this.elements[0][0].size;
var posCurs = {x: 0, y: 0};
var inside_flag = -1;
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
if(mCoord.y > arg.height)
mCoord.y = arg.height;
return {pos: posCurs, mCoord: mCoord, inside_flag: inside_flag};
if(SearchPos.Y > arg.height)
SearchPos.Y = arg.height;
}
CNumerator.prototype.setPosition = function(pos)
{
......@@ -644,25 +701,25 @@ CDenominator.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent};
}
CDenominator.prototype.findDisposition = function(mCoord)
CDenominator.prototype.findDisposition = function(SearchPos, Depth)
{
var arg = this.elements[0][0].size;
var posCurs = {x: 0, y: 0};
var inside_flag = -1;
if(mCoord.y < this.gap)
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
if(SearchPos.Y < this.gap)
{
mCoord.y = 0;
SearchPos.Y = 0;
}
else if (mCoord.y > arg.height + this.gap)
else if (SearchPos.Y > arg.height + this.gap)
{
mCoord.y = arg.height;
SearchPos.Y = arg.height;
}
else
mCoord.y -= this.gap;
SearchPos.Y -= this.gap;
return {pos: posCurs, mCoord: mCoord, inside_flag: inside_flag};
}
CDenominator.prototype.setPosition = function(pos)
{
......
......@@ -4014,27 +4014,28 @@ CMathContent.prototype =
return result;
},
findPosition: function(X, Y)
findDisposition: function(SearchPos, Depth)
{
var W = 0, width = 0;
var W = 0;
var pos = 0;
for(var i = 0; i < this.content.length && X > W; i++)
for(var i = 0; i < this.content.length && SearchPos.X > W; i++)
{
W += this.content[i].size.width;
width = this.content[i].size.width;
pos = i;
}
if( this.content[pos].Type === para_Math_Composition )
{
if(X < W - width + this.content[pos].GapLeft)
if(SearchPos.X < W - this.content[pos].size.width + this.content[pos].GapLeft)
pos--;
else if(X >= W - this.content[pos].GapRight)
else if(SearchPos.X >= W - this.content[pos].GapRight)
pos++;
}
return pos;
SearchPos.Pos.Update(pos, Depth);
SearchPos.X -= this.WidthToElement[pos];
//return pos;
},
setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
{
......@@ -4207,6 +4208,10 @@ CMathContent.prototype =
{
return this.Parent.GetParent();
},
SetArgSize: function(val)
{
this.ArgSize.SetValue(val);
},
///////// Перемещение ////////////
......@@ -4452,21 +4457,22 @@ CMathContent.prototype =
}
this.content = NewContent;
},
SetRunEmptyToContent: function(bAll)
{
var len = this.content.length;
var current = null, left = null;
var emptyRun, ctrPrp, mathPrp, txtPrp;
var current = null;
var emptyRun, ctrPrp, mathPrp;
for(var i = 0; i < len; i++)
var currPos = 0;
while(currPos < len)
{
current = this.content[i];
current = this.content[currPos];
var bLeftRun = left !== null ? left.Type == para_Math_Run : false,
bRightRun = i < len - 1 ? this.content[i + 1].Type === para_Math_Run : false;
var bLeftRun = currPos > 0 ? this.content[currPos-1].Type == para_Math_Run : false,
bRightRun = currPos < len - 1 ? this.content[currPos + 1].Type === para_Math_Run : false;
var bCurrComp = current.Type == para_Math_Composition,
bCurrEmptyRun = current.Type == para_Math_Run && current.Is_Empty();
......@@ -4474,7 +4480,7 @@ CMathContent.prototype =
var bDeleteEmptyRun = bCurrEmptyRun && (bLeftRun || bRightRun);
if(bCurrComp && bAll == true)
this.content[i].SetRunEmptyToContent(bAll);
this.content[currPos].SetRunEmptyToContent(bAll);
if(bCurrComp && !bLeftRun) // добавление пустого Run перед мат объектом
{
......@@ -4491,22 +4497,20 @@ CMathContent.prototype =
ctrPrp.Italic = undefined;
emptyRun.Set_Pr(ctrPrp);
left = current;
this.Internal_Content_Add(i, emptyRun);
this.Internal_Content_Add(currPos, emptyRun);
currPos += 2;
}
else if(bDeleteEmptyRun)
{
this.Remove_FromContent(i, 1);
this.Remove_FromContent(currPos, 1);
}
else
{
left = current;
}
currPos++;
len = this.content.length;
}
len = this.content.length;
if(len > 0 && this.content[len - 1].Type == para_Math_Composition)
{
......@@ -4544,23 +4548,25 @@ CMathContent.prototype =
{
if(this.content.length > 0) // случай , если у нас контент не заполнен, не предусмотрен
{
var pos = this.findPosition(SearchPos.X, SearchPos.Y);
this.findDisposition(SearchPos, Depth);
var pos = SearchPos.Pos.Get(Depth);
//var pos = this.findPosition(SearchPos.X, SearchPos.Y);
SearchPos.Pos.Update( pos, Depth );
Depth++;
//SearchPos.Pos.Update( pos, Depth );
//Depth++;
SearchPos.X -= this.WidthToElement[pos];
//SearchPos.X -= this.WidthToElement[pos];
if(this.content[pos].Type == para_Math_Composition)
{
SearchPos.Y -= this.size.ascent - this.content[pos].size.ascent;
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth+1, _CurLine, _CurRange, StepEnd);
}
else if(this.content[pos].Type == para_Math_Run) // проверка на gaps в findDisposition
{
SearchPos.X += this.pos.x + this.ParaMath.X + this.WidthToElement[pos];
SearchPos.CurX += this.pos.x + this.WidthToElement[pos];
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth+1, _CurLine, _CurRange, StepEnd);
}
}
},
......@@ -4721,9 +4727,8 @@ CMathContent.prototype =
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var CurTextPr;
var CurTextPr = this.content[CurPos].Get_CompiledPr(true);
CurTextPr = this.content[CurPos].Get_CompiledPr(false);
if ( null !== CurTextPr )
TextPr = TextPr.Compare( CurTextPr );
}
......@@ -4880,8 +4885,8 @@ CMathContent.prototype =
},
Remove_FromContent : function(Pos, Count)
{
var DeletedItems = this.content.slice( Pos, Pos + Count );
History.Add( this, { Type : historyitem_Math_RemoveItem, Pos : Pos, EndPos : Pos + Count - 1, Items : DeletedItems } );
var DeletedItems = this.content.splice(Pos, Count);
History.Add( this, { Type : historyitem_Math_RemoveItem, Pos : Pos, EndPos : Pos + Count, Items : DeletedItems } );
if(this.CurPos > Pos)
{
......
......@@ -214,82 +214,70 @@ CMathMatrix.prototype.setPosition = function(pos)
}
}
CMathMatrix.prototype.findDisposition = function( coord )
CMathMatrix.prototype.findDisposition = function(SearchPos, Depth)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: this.nRow - 1, y: this.nCol - 1};
var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths;
var Heights = maxWH.heights;
var Curr_Pos_X = this.nRow - 1, Curr_Pos_Y = this.nCol - 1;
for(var i = 0, w = 0; i < this.nCol; i++)
{
w += Widths[i] + this.gaps.column[i + 1]/2;
if(coord.x < w)
if(SearchPos.X < w)
{
posCurs.y = i;
Curr_Pos_Y = i;
break;
}
w += this.gaps.column[i + 1]/2;
}
SearchPos.Pos.Update(Curr_Pos_Y, Depth+1);
for(var j = 0, h = 0; j < this.nRow; j++)
{
h += Heights[j] + this.gaps.row[j + 1]/2;
if(coord.y < h)
if(SearchPos.Y < h)
{
posCurs.x = j;
Curr_Pos_X = j;
break;
}
h += this.gaps.row[j + 1]/2;
}
SearchPos.Pos.Update(Curr_Pos_X, Depth);
////////////////////////////////
var sumWidth = 0;
var sumHeight = 0;
for(var t = 0; t < posCurs.y; t++)
for(var t = 0; t < Curr_Pos_Y; t++)
sumWidth += Widths[t] + this.gaps.column[t + 1];
for(t = 0; t < posCurs.x; t++)
for(t = 0; t < Curr_Pos_X; t++)
sumHeight += Heights[t] + this.gaps.row[t + 1];
// флаг для случая, когда выходим за границы элемента и есть выравнивание относительно других элементов
var inside_flag = -1;
if( posCurs.x != null && posCurs.y != null)
if( Curr_Pos_X != null && Curr_Pos_Y != null)
{
var size = this.elements[posCurs.x][posCurs.y].size;
var align = this.align(posCurs.x, posCurs.y);
if(coord.x < ( sumWidth + align.x ))
{
mouseCoord.x = 0;
inside_flag = 0;
}
else if( coord.x > (sumWidth + align.x + size.width ))
{
mouseCoord.x = size.width;
inside_flag = 1;
}
var size = this.elements[Curr_Pos_X][Curr_Pos_Y].size;
var align = this.align(Curr_Pos_X, Curr_Pos_Y);
if(SearchPos.X < ( sumWidth + align.x ))
SearchPos.X = 0;
else if( SearchPos.X > (sumWidth + align.x + size.width ))
SearchPos.X = size.width;
else
mouseCoord.x = coord.x - ( sumWidth + align.x );
SearchPos.X -= ( sumWidth + align.x );
if(coord.y < (sumHeight + align.y))
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if( coord.y > ( sumHeight + align.y + size.height ) )
{
mouseCoord.y = size.height;
inside_flag = 2;
}
if(SearchPos.Y < (sumHeight + align.y))
SearchPos.Y = 0;
else if( SearchPos.Y > ( sumHeight + align.y + size.height ) )
SearchPos.Y = size.height;
else
mouseCoord.y = coord.y - ( sumHeight + align.y );
SearchPos.Y -= ( sumHeight + align.y );
}
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CMathMatrix.prototype.getMetrics = function()
{
......
......@@ -751,54 +751,48 @@ CNaryUndOvr.prototype.setPosition = function(pos)
this.elements[1][0].setPosition(PosSign);
this.elements[2][0].setPosition(PosLowIter);
}
CNaryUndOvr.prototype.findDisposition = function(mCoord)
CNaryUndOvr.prototype.findDisposition = function(SearchPos, Depth)
{
var X = null, Y = null;
var iter, pos_x, pos_y = 0;
var inside_flag = -1;
if(mCoord.y < this.size.height/2)
var Curr_Pos_X, Curr_Pos_Y;
if(SearchPos.Y < this.size.height/2)
{
iter = this.elements[0][0].size;
if( mCoord.y > iter.height )
{
Y = iter.height;
inside_flag = 2;
}
else
Y = mCoord.y;
if( SearchPos.Y > iter.height )
SearchPos.Y = iter.height;
pos_x = 0;
SearchPos.Pos.Update(0, Depth);
Curr_Pos_X = 0;
}
else
{
iter = this.elements[2][0].size;
if( mCoord.y < iter.height )
{
Y = 0;
inside_flag = 2;
}
if( SearchPos.Y < iter.height )
SearchPos.Y = 0;
else
Y = mCoord.y - (this.size.height - iter.height);
SearchPos.Y -= (this.size.height - iter.height);
pos_x = 2;
SearchPos.Pos.Update(2, Depth);
Curr_Pos_X = 2;
}
var align = this.align(pos_x, 0);
if(mCoord.x < align.x )
SearchPos.Pos.Update(0, Depth+1);
var align = this.align(Curr_Pos_X, 0);
if(SearchPos.X < align.x )
{
X = 0;
inside_flag = 0;
SearchPos.X = 0;
}
else if(mCoord.x > align.x + iter.width)
else if(SearchPos.X > align.x + iter.width)
{
X = iter.width;
inside_flag = 1;
SearchPos.X = iter.width;
}
else
X = mCoord.x - align.x;
SearchPos.X -= align.x;
return {pos: {x: pos_x, y: pos_y}, mCoord: {x: X, y: Y}, inside_flag: inside_flag};
}
CNaryUndOvr.prototype.setBase = function(base)
{
......
......@@ -3752,66 +3752,60 @@ CDelimiter.prototype.setPosition = function(position)
content.setPosition(PosContent); // CMathContent*/
}
CDelimiter.prototype.findDisposition = function(pos)
CDelimiter.prototype.findDisposition = function(SearchPos, Depth)
{
var curs_X = 0,
curs_Y = 0;
var X, Y;
var begWidth = this.begOper.size.width,
sepWidth = this.sepOper.size.width,
endWidth = this.endOper.size.width;
var inside_flag = -1;
SearchPos.Pos.Update(0, Depth);
if(pos.x < this.begOper.size.width)
var Curr_Pos_Y;
if(SearchPos.X < begWidth)
{
curs_Y = 0;
X = 0;
inside_flag = 0;
Curr_Pos_Y = 0;
SearchPos.X = 0;
}
else if(pos.x > this.size.width - this.endOper.size.width)
else if(SearchPos.X > this.size.width - endWidth)
{
curs_Y = this.nCol - 1;
X = this.elements[0][this.nCol - 1].size.width;
inside_flag = 1;
Curr_Pos_Y = 0;
SearchPos.X = this.elements[0][this.nCol - 1].size.width;
}
else
{
var xx = this.begOper.size.width;
var ww = begWidth;
Curr_Pos_Y = this.nCol - 1;
for(var j = 0; j < this.nCol; j++)
{
if(xx + this.elements[0][j].size.width + this.sepOper.size.width/2 > pos.x)
if(ww + this.elements[0][j].size.width + this.sepOper.size.width/2 > SearchPos.X)
{
curs_Y = j;
if( pos.x < xx + this.elements[0][j].size.width)
X = pos.x - xx;
Curr_Pos_Y = j;
if( SearchPos.X < ww + this.elements[0][j].size.width)
SearchPos.X -= ww;
else
X = xx + this.elements[0][j].size.width;
SearchPos.X = ww + this.elements[0][j].size.width;
break;
}
xx += this.elements[0][j].size.width + this.sepOper.size.width;
ww += this.elements[0][j].size.width + sepWidth;
}
}
var align = this.align( this.elements[0][curs_Y]);
SearchPos.Pos.Update(Curr_Pos_Y, Depth+1);
if(align > pos.y)
{
Y = 0;
inside_flag = 2;
}
else if(this.elements[0][curs_Y].size.height + align < pos.y)
{
Y = this.elements[0][curs_Y].size.height;
inside_flag = 2;
}
else
Y = pos.y - align;
var mouseCoord = {x: X, y: Y},
posCurs = {x: curs_X, y: curs_Y};
var align = this.align(this.elements[0][Curr_Pos_Y]);
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
if(align > SearchPos.Y)
SearchPos.Y = 0;
else if(this.elements[0][Curr_Pos_Y].size.height + align < SearchPos.Y)
SearchPos.Y = this.elements[0][Curr_Pos_Y].size.height;
else
SearchPos.Y -= align;
}
CDelimiter.prototype.draw = function(x, y, pGraphics)
......@@ -4043,55 +4037,34 @@ CCharacter.prototype.draw = function(x, y, pGraphics)
this.operator.draw(x, y, pGraphics);
}
CCharacter.prototype.findDisposition = function(pos)
CCharacter.prototype.findDisposition = function(SearchPos, Depth)
{
var curs_X = 0,
curs_Y = 0;
var X, Y;
var inside_flag = -1;
var base = this.elements[0][0],
align = this.align(base);
var content = this.elements[0][0],
align = this.align(content);
if(pos.x < align)
{
X = 0;
inside_flag = 0;
}
else if(pos.x > align + content.size.width)
{
X = content.size.width;
inside_flag = 1;
}
if(SearchPos.X < align)
SearchPos.X = 0;
else if(SearchPos.X > align + base.size.width)
SearchPos.X = base.size.width;
else
X = pos.x - align;
SearchPos.X -= align;
if(this.Pr.pos === LOCATION_TOP)
{
if(pos.y < this.operator.size.height)
{
Y = 0;
inside_flag = 2;
}
if(SearchPos.Y < this.operator.size.height)
SearchPos.Y = 0;
else
Y = pos.y - this.operator.size.height;
SearchPos.Y -= this.operator.size.height;
}
else if(this.Pr.pos === LOCATION_BOT)
{
if(pos.y > content.size.height)
{
Y = content.size.height;
inside_flag = 2;
}
else
Y = pos.y;
if(SearchPos.Y > base.size.height)
SearchPos.Y = base.size.height;
}
var mouseCoord = {x: X, y: Y},
posCurs = {x: curs_X, y: curs_Y};
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
CCharacter.prototype.getBase = function()
{
......
......@@ -1047,7 +1047,8 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
var ArgSzIter = new CMathArgSize();
ArgSzIter.SetValue(-2);
ArgSzIter.Merge(ArgSize);
//ArgSzIter.Merge(ArgSize);
this.Iterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzIter);
this.RealBase.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
......@@ -1175,124 +1176,92 @@ CRadical.prototype.setPosition = function(pos)
PosBase.x = this.pos.x + this.size.width - this.RealBase.size.width - this.GapRight;
PosBase.y = this.pos.y + this.size.ascent - this.RealBase.size.ascent;
this.RealBase.setPosition(PosBase);
}
}
CRadical.prototype.findDisposition = function(mCoord)
CRadical.prototype.findDisposition = function(SearchPos, Depth)
{
var disposition;
var inside_flag = -1;
//var disposition;
//var inside_flag = -1;
var base, degree;
if(this.Pr.type == SQUARE_RADICAL)
{
var sizeBase = this.elements[0][0].size;
var X, Y;
base = this.elements[0][0].size;
//var X, Y;
var gapLeft = this.size.width - this.elements[0][0].size.width;
var gapTop = this.size.ascent - this.elements[0][0].size.ascent;
var gapLeft = this.size.width - base.width;
var gapTop = this.size.ascent - base.ascent;
if(mCoord.x < gapLeft)
{
X = 0;
inside_flag = 0;
}
else if(mCoord.x > gapLeft + sizeBase.width)
{
X = sizeBase.width;
inside_flag = 1;
}
if(SearchPos.X < gapLeft)
SearchPos.X = 0;
else if(SearchPos.X > gapLeft + base.width)
SearchPos.X = base.width;
else
X = mCoord.x - gapLeft;
SearchPos.X -= gapLeft;
if(mCoord.y < gapTop)
{
Y = 0;
inside_flag = 2;
}
else if(mCoord.y > gapTop + sizeBase.height)
{
Y = sizeBase.height;
inside_flag = 2;
}
if(SearchPos.Y < gapTop)
SearchPos.Y = 0;
else if(SearchPos.Y > gapTop + base.height)
SearchPos.Y = base.height;
else
Y = mCoord.y - gapTop;
SearchPos.Y -= gapTop;
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
disposition = {pos: {x:0, y:0}, mCoord: {x: X, y: Y}, inside_flag: inside_flag};
}
else if(this.Pr.type == DEGREE_RADICAL)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: 0, y: null};
//var mouseCoord = {x: null, y: null},
// posCurs = {x: 0, y: null};
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
degree = this.elements[0][0].size;
base = this.elements[0][1].size;
SearchPos.Pos.Update(0, Depth);
if(mCoord.x < this.size.width - base.width)
if(SearchPos.X < this.size.width - base.width)
{
posCurs.y = 0;
//posCurs.y = 0;
SearchPos.Pos.Update(0, Depth+1);
if(mCoord.x > degr.width)
{
mouseCoord.x = degr.width;
inside_flag = 1;
}
else if(mCoord.x < this.gapWidth)
{
mouseCoord.x = 0;
inside_flag = 0;
}
if(SearchPos.X > degree.width)
SearchPos.X = degree.width;
else if(SearchPos.X < this.gapWidth)
SearchPos.X = 0;
else
{
mouseCoord.x = mCoord.x - this.gapWidth;
}
mouseCoord.x = mCoord.x;
SearchPos.X -= this.gapWidth;
if(mCoord.y < this.gapDegree)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > degr.height + this.gapDegree)
{
mouseCoord.y = degr.height;
inside_flag = 2;
}
if(SearchPos.Y < this.gapDegree)
SearchPos.Y = 0;
else if(SearchPos.Y > degree.height + this.gapDegree)
SearchPos.Y = degree.height;
else
{
mouseCoord.y = mCoord.y - this.gapDegree;
}
SearchPos.Y -= this.gapDegree;
}
else
{
posCurs.y = 1;
//posCurs.y = 1;
SearchPos.Pos.Update(1, Depth+1);
mouseCoord.x = mCoord.x - (this.size.width - base.width);
SearchPos.X -= (this.size.width - base.width);
var topBase = this.size.ascent - base.ascent;
if(mCoord.y < topBase)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > base.height + topBase)
{
mouseCoord.y = base.height;
inside_flag = 2;
}
if(SearchPos.Y < topBase)
SearchPos.Y = 0;
else if(SearchPos.Y > base.height + topBase)
SearchPos.Y = base.height;
else
mouseCoord.y = mCoord.y - topBase;
SearchPos.Y -= topBase;
}
disposition = {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
//disposition = {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
//console.log("x : " + disposition.pos.x + ", y : " + disposition.pos.y);
return disposition;
//return disposition;
}
CRadical.prototype.draw = function(x, y, pGraphics)
{
......
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