Commit 57ec2ea0 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

Реализовала выравниванивание с помощью амперсандов для EqqArray(отрисовка,...

Реализовала выравниванивание с помощью амперсандов для EqqArray(отрисовка, расчет размера и позиционирование Run для EqqArray) для случая, когда в контенте один Run

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57847 954022d7-b5bf-4e40-9824-e11837661b57
parent e7df7186
...@@ -25,6 +25,7 @@ function ParaMath() ...@@ -25,6 +25,7 @@ function ParaMath()
this.Root = new CMathContent(); this.Root = new CMathContent();
this.Root.bRoot = true; this.Root.bRoot = true;
this.NotDraw = false;
//this.Root.setComposition(this); //this.Root.setComposition(this);
this.X = 0; this.X = 0;
...@@ -544,14 +545,21 @@ ParaMath.prototype = ...@@ -544,14 +545,21 @@ ParaMath.prototype =
var ArgSize = new CMathArgSize(); var ArgSize = new CMathArgSize();
this.Root.Resize(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize, TextPr); this.Root.Resize(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize, TextPr);
this.NotDraw = RPI.bManyRuns;
//this.Root.Resize(null, this, g_oTextMeasurer, RPI/*recalculate properties info*/, TextPr); //this.Root.Resize(null, this, g_oTextMeasurer, RPI/*recalculate properties info*/, TextPr);
this.OldMathPara = this.MathPara; this.OldMathPara = this.MathPara;
var PosInfo = new CMathPosInfo();
var pos = new CMathPosition(); var pos = new CMathPosition();
pos.x = 0; pos.x = 0;
pos.y = 0; pos.y = 0;
this.Root.setPosition(pos);
this.Root.setPosition(pos, PosInfo);
this.Width = this.Root.size.width; this.Width = this.Root.size.width;
this.Height = this.Root.size.height; this.Height = this.Root.size.height;
...@@ -1225,8 +1233,12 @@ ParaMath.prototype = ...@@ -1225,8 +1233,12 @@ ParaMath.prototype =
// this.absPos.x ~> this.X // this.absPos.x ~> this.X
// this.absPos.y ~> this.Y // this.absPos.y ~> this.Y
if(this.NotDraw == false)
this.Root.draw( PDSE.X, PDSE.Y - this.Ascent, PDSE.Graphics); this.Root.draw( PDSE.X, PDSE.Y - this.Ascent, PDSE.Graphics);
PDSE.X += this.Width; PDSE.X += this.Width;
} }
/*PDSE.Graphics.p_color(255,0,0, 255); /*PDSE.Graphics.p_color(255,0,0, 255);
......
...@@ -52,12 +52,9 @@ function ParaRun(Paragraph, bMathRun) ...@@ -52,12 +52,9 @@ function ParaRun(Paragraph, bMathRun)
this.Type = para_Math_Run; this.Type = para_Math_Run;
this.MathPrp = new CMPrp(); this.MathPrp = new CMPrp();
this.Parent = null; this.Parent = null;
this.size = this.bEqqArray = false;
{ this.WidthsPoints = [];
ascent: 0, this.size = new CMathSize();
height: 0,
width: 0
};
} }
this.StartState = null; this.StartState = null;
...@@ -7562,19 +7559,89 @@ function CRunCollaborativeRange(PosS, PosE, Color) ...@@ -7562,19 +7559,89 @@ function CRunCollaborativeRange(PosS, PosE, Color)
this.PosE = PosE; this.PosE = PosE;
this.Color = Color; this.Color = Color;
} }
ParaRun.prototype.Math_SetPosition = function(pos, PosInfo)
{
var NewPos = new CMathPosition();
NewPos.x = pos.x;
NewPos.y = pos.y - this.size.ascent;
ParaRun.prototype.setPosition = function(_pos)
{
var pos = new CMathPosition();
pos.x = _pos.x; if(this.bEqqArray)
pos.y = _pos.y - this.size.ascent; {
var align = 0;
// нечетным точкам соответствуют четные индексы в массиве
var Pos = 0,
lng = this.Content.length,
Amp = 1;
var W = 0;
var WPointsLng = this.WidthsPoints.length;
var widthCurrPoint = 0;
for(var j = 0; j < WPointsLng; j += 2)
{
widthCurrPoint = 0;
if(j == WPointsLng - 1)
align = (PosInfo.Widths[j/2] - this.WidthsPoints[j])/2; // то есть последняя точка четная, выравнивание по центру
else
align = PosInfo.Points[j/2] - this.WidthsPoints[j];
NewPos.x += align;
while(Pos < lng && Amp < 3)
{
if(this.Content[Pos].Type == para_Math_Ampersand)
{
Amp++;
if(Amp < 3)
{
this.Content[Pos].setPosition(NewPos);
Pos++;
}
}
else
{
this.Content[Pos].setPosition(NewPos);
NewPos.x += this.Content[Pos].size.width;
widthCurrPoint += this.Content[Pos].size.width;
W += this.Content[Pos].size.width;
Pos++;
}
}
NewPos.x += PosInfo.Widths[j/2] - widthCurrPoint - align; // выравнивание справа
Amp = 0;
}
/*if(Pos < lng)
{
var Index = this.WidthsPoints.length/2;
align = (PosInfo.Widths[Index] - (this.size.width - W))/2;
NewPos.x += align;
while(Pos < lng)
{
{
this.Content[Pos].setPosition(NewPos);
NewPos.x += this.Content[Pos].size.width;
Pos++;
}
}
}*/
//
}
else
{
for(var i = 0; i < this.Content.length; i++) for(var i = 0; i < this.Content.length; i++)
{ {
this.Content[i].setPosition(pos); this.Content[i].setPosition(NewPos);
pos.x += this.Content[i].size.width; NewPos.x += this.Content[i].size.width;
}
} }
} }
ParaRun.prototype.Math_Draw = function(x, y, pGraphics) ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
...@@ -7612,7 +7679,6 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7612,7 +7679,6 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
// пересчет элементов контента в Run // пересчет элементов контента в Run
// Recalculate_MeasureContent // Recalculate_MeasureContent
// ParaText (ParagraphContent.js) // ParaText (ParagraphContent.js)
// для настройки TextPr // для настройки TextPr
// Measure // Measure
...@@ -7631,8 +7697,6 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7631,8 +7697,6 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
// обновляем позиции start и end для Range // обновляем позиции start и end для Range
this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos); this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos);
var width = 0,
ascent = 0, descent = 0;
var oWPrp = this.Get_CompiledPr(true); var oWPrp = this.Get_CompiledPr(true);
...@@ -7652,22 +7716,81 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7652,22 +7716,81 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
g_oTextMeasurer.SetFont(oWPrp); g_oTextMeasurer.SetFont(oWPrp);
this.WidthsPoints.length = 0;
for (var Pos = 0 ; Pos < this.Content.length; Pos++ ) this.bEqqArray = RPI.bEqqArray;
var Widths, PosW = 0;
if(RPI.bEqqArray)
{ {
this.Content[Pos].Resize(oMeasure, this); Widths = RPI.AmperWPoints.GetWidths();
this.Content[Pos].ApplyGaps();
var oSize = this.Content[Pos].size; Widths[0] = 0
width += oSize.width; this.WidthsPoints.length = 0;
this.WidthsPoints[0] = 0;
}
this.size.SetZero();
var widthCurr = 0,
ascent = 0, descent = 0;
for (var i = 0 ; i < this.Content.length; i++ )
{
this.Content[i].Resize(oMeasure, this, RPI);
var oSize = this.Content[i].size;
widthCurr = oSize.width + this.Content[i].GapLeft + this.Content[i].GapRight;
this.size.width += widthCurr;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
var oDescent = oSize.height - oSize.ascent; var oDescent = oSize.height - oSize.ascent;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
descent = descent < oDescent ? oDescent : descent; descent = descent < oDescent ? oDescent : descent;
/*if(this.Content[i].Type == para_Math_Ampersand && RPI.bEqqArray)
{
if(PosW == lng)
{
RPI.Widths[PosW] = W;
RPI.SingleAmpEnd = true;
}
else
{
RPI.Widths[PosW] = RPI.Widths[PosW] > W ? RPI.Widths[PosW] : W;
if(PosW == lng -1)
RPI.SingleAmpEnd = false;
} }
PosW++;
this.size = {width: width, height: ascent + descent, ascent: ascent}; W = 0;
}
else
W += width;*/
if(RPI.bEqqArray)
{
if(this.Content[i].Type == para_Math_Ampersand)
{
PosW++;
Widths[PosW] = 0;
this.WidthsPoints[PosW] = 0;
}
else
{
Widths[PosW] += widthCurr;
this.WidthsPoints[PosW] += widthCurr;
}
}
}
this.size.ascent = ascent;
this.size.height = ascent + descent;
} }
ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget) ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget)
{ {
...@@ -7770,10 +7893,10 @@ ParaRun.prototype.getPropsForWrite = function() ...@@ -7770,10 +7893,10 @@ ParaRun.prototype.getPropsForWrite = function()
} }
ParaRun.prototype.Math_SetGaps = function(GapsInfo) ParaRun.prototype.Math_SetGaps = function(GapsInfo)
{ {
//this.Parent = Parent; this.Parent = GapsInfo.Parent;
//this.Paragraph = Paragraph; this.Paragraph = GapsInfo.ParaMath.Paragraph;
var oWPrp = this.Get_CompiledPr(true); var oWPrp = this.Get_CompiledPr(true);
//this.Parent.ParaMath.ApplyArgSize(oWPrp, this.Parent.argSize); //this.Parent.ParaMath.ApplyArgSize(oWPrp, this.Parent.argSize);
/*if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам /*if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
...@@ -7825,6 +7948,14 @@ ParaRun.prototype.Math_ApplyGaps = function() ...@@ -7825,6 +7948,14 @@ ParaRun.prototype.Math_ApplyGaps = function()
this.size.width += this.Content[Pos].GapLeft + this.Content[Pos].GapRight; this.size.width += this.Content[Pos].GapLeft + this.Content[Pos].GapRight;
} }
} }
ParaRun.prototype.GetCompiled_ScrStyles = function()
{
return this.MathPrp.GetCompiled_ScrStyles();
}
ParaRun.prototype.IsEqqArray = function()
{
return this.Parent.IsEqqArray();
}
function CParaRunStartState(Run) function CParaRunStartState(Run)
......
...@@ -1067,7 +1067,7 @@ CAccent.prototype.old_init = function(properties) ...@@ -1067,7 +1067,7 @@ CAccent.prototype.old_init = function(properties)
this.elements[0][0].SetDot(true); this.elements[0][0].SetDot(true);
} }
CAccent.prototype.setPosition = function(pos) CAccent.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent; this.pos.y = pos.y - this.size.ascent;
...@@ -1092,7 +1092,7 @@ CAccent.prototype.setPosition = function(pos) ...@@ -1092,7 +1092,7 @@ CAccent.prototype.setPosition = function(pos)
PosBase.x = this.pos.x + this.GapLeft + alignCnt; PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + this.operator.size.height + this.gap; PosBase.y = this.pos.y + this.operator.size.height + this.gap;
this.elements[0][0].setPosition(PosBase); this.elements[0][0].setPosition(PosBase, PosInfo);
} }
CAccent.prototype.getPropsForWrite = function() CAccent.prototype.getPropsForWrite = function()
{ {
......
"use strict"; "use strict";
function CMathBase(bInside) function CMathBase(bInside)
{ {
//this.typeObj = MATH_COMP; //this.typeObj = MATH_COMP;
...@@ -212,6 +210,10 @@ CMathBase.prototype = ...@@ -212,6 +210,10 @@ CMathBase.prototype =
{ {
return false; return false;
}, },
IsEqqArray: function()
{
return false;
},
getWidthsHeights: function() getWidthsHeights: function()
{ {
var Widths = []; var Widths = [];
...@@ -302,7 +304,7 @@ CMathBase.prototype = ...@@ -302,7 +304,7 @@ CMathBase.prototype =
return PosAlign; return PosAlign;
}, },
setPosition: function(pos) setPosition: function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
...@@ -326,7 +328,7 @@ CMathBase.prototype = ...@@ -326,7 +328,7 @@ CMathBase.prototype =
var al = this.align(i, j); var al = this.align(i, j);
NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w; NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w;
NewPos.y = this.pos.y + al.y + this.dH*i + h; NewPos.y = this.pos.y + al.y + this.dH*i + h;
this.elements[i][j].setPosition(NewPos); this.elements[i][j].setPosition(NewPos, PosInfo);
w += Widths[j]; w += Widths[j];
} }
h += Heights[i]; h += Heights[i];
...@@ -362,8 +364,7 @@ CMathBase.prototype = ...@@ -362,8 +364,7 @@ CMathBase.prototype =
for(var i=0; i < this.nCol ; i++) for(var i=0; i < this.nCol ; i++)
width += Widths[i]; width += Widths[i];
width += this.dW*(this.nCol - 1); width += this.dW*(this.nCol - 1) + this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
var ascent = this.getAscent(oMeasure, height); var ascent = this.getAscent(oMeasure, height);
...@@ -374,7 +375,7 @@ CMathBase.prototype = ...@@ -374,7 +375,7 @@ CMathBase.prototype =
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
...@@ -767,8 +768,9 @@ CMathBase.prototype = ...@@ -767,8 +768,9 @@ CMathBase.prototype =
}, },
SetGaps: function(GapsInfo) SetGaps: function(GapsInfo)
{ {
//this.Parent = Parent; this.Parent = GapsInfo.Parent;
//this.ParaMath = ParaMath; this.ParaMath = GapsInfo.ParaMath;
GapsInfo.Left = GapsInfo.Current; GapsInfo.Left = GapsInfo.Current;
GapsInfo.leftRunPrp = GapsInfo.currRunPrp; GapsInfo.leftRunPrp = GapsInfo.currRunPrp;
...@@ -780,10 +782,10 @@ CMathBase.prototype = ...@@ -780,10 +782,10 @@ CMathBase.prototype =
GapsInfo.setGaps(); GapsInfo.setGaps();
}, },
ApplyGaps: function() /*ApplyGaps: function()
{ {
this.size.width += this.GapLeft + this.GapRight; this.size.width += this.GapLeft + this.GapRight;
}, },*/
Recalculate_Reset: function(StartRange, StartLine) Recalculate_Reset: function(StartRange, StartLine)
{ {
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
......
...@@ -91,7 +91,7 @@ CBorderBox.prototype.recalculateSize = function() ...@@ -91,7 +91,7 @@ CBorderBox.prototype.recalculateSize = function()
if(this.Pr.hideRight == false) if(this.Pr.hideRight == false)
width += this.gapBrd; width += this.gapBrd;
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {width : width, height: height, ascent: ascent}; this.size = {width : width, height: height, ascent: ascent};
} }
...@@ -255,7 +255,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -255,7 +255,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
} }
} }
CBorderBox.prototype.setPosition = function(pos) CBorderBox.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent; this.pos.y = pos.y - this.size.ascent;
...@@ -273,7 +273,7 @@ CBorderBox.prototype.setPosition = function(pos) ...@@ -273,7 +273,7 @@ CBorderBox.prototype.setPosition = function(pos)
else else
NewPos.y = this.pos.y; NewPos.y = this.pos.y;
this.elements[0][0].setPosition(NewPos); this.elements[0][0].setPosition(NewPos, PosInfo);
} }
CBorderBox.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd) CBorderBox.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
{ {
...@@ -458,7 +458,7 @@ CBox.prototype.fillContent = function() ...@@ -458,7 +458,7 @@ CBox.prototype.fillContent = function()
} }
CBox.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CBox.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
var ArgSizeBox = ArgSize.Copy(); var ArgSizeBox = ArgSize.Copy();
...@@ -632,7 +632,7 @@ CBar.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -632,7 +632,7 @@ CBar.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
CBar.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize); CBar.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize);
} }
......
...@@ -36,7 +36,7 @@ CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -36,7 +36,7 @@ CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
...@@ -49,7 +49,6 @@ CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -49,7 +49,6 @@ CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.recalculateSup(oMeasure); this.recalculateSup(oMeasure);
else if(this.Pr.type === DEGREE_SUBSCRIPT) else if(this.Pr.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure); this.recalculateSubScript(oMeasure);
} }
CDegree.prototype.old__recalculateSup = function(oMeasure) CDegree.prototype.old__recalculateSup = function(oMeasure)
{ {
...@@ -124,7 +123,6 @@ CDegree.prototype.old_recalculateSubScript = function(oMeasure) ...@@ -124,7 +123,6 @@ CDegree.prototype.old_recalculateSubScript = function(oMeasure)
this.upper = -(height - iter.height); this.upper = -(height - iter.height);
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CDegree.prototype.recalculateSup = function(oMeasure) CDegree.prototype.recalculateSup = function(oMeasure)
{ {
...@@ -173,7 +171,7 @@ CDegree.prototype.recalculateSup = function(oMeasure) ...@@ -173,7 +171,7 @@ CDegree.prototype.recalculateSup = function(oMeasure)
this.dW = 0.01*mgCtrPrp.FontSize; this.dW = 0.01*mgCtrPrp.FontSize;
var width = base.width + iter.width + this.dW; var width = base.width + iter.width + this.dW;
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
...@@ -186,6 +184,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure) ...@@ -186,6 +184,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var width = base.width + iter.width + this.dW; var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
var oBase = this.elements[0][0]; var oBase = this.elements[0][0];
var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText
...@@ -212,7 +211,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure) ...@@ -212,7 +211,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CDegree.prototype.setPosition = function(pos) CDegree.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
...@@ -231,8 +230,8 @@ CDegree.prototype.setPosition = function(pos) ...@@ -231,8 +230,8 @@ CDegree.prototype.setPosition = function(pos)
PosIter.x = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.dW; PosIter.x = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.dW;
PosIter.y = this.pos.y + this.upIter; PosIter.y = this.pos.y + this.upIter;
this.elements[0][0].setPosition(PosBase); this.elements[0][0].setPosition(PosBase, PosInfo);
this.elements[0][1].setPosition(PosIter); this.elements[0][1].setPosition(PosIter, PosInfo);
} }
CDegree.prototype.getIterator = function() CDegree.prototype.getIterator = function()
{ {
...@@ -534,7 +533,7 @@ CDegreeSubSup.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSi ...@@ -534,7 +533,7 @@ CDegreeSubSup.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSi
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
var ArgSzIters = ArgSize.Copy(); var ArgSzIters = ArgSize.Copy();
ArgSzIters.decrease(); ArgSzIters.decrease();
...@@ -865,6 +864,7 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -865,6 +864,7 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI)
iters.recalculateSize(oMeasure); iters.recalculateSize(oMeasure);
var width = iters.size.width + base.size.width + this.dW; var width = iters.size.width + base.size.width + this.dW;
width += this.GapLeft + this.GapRight;
var height = iters.size.height; var height = iters.size.height;
var ascent = base.size.ascent + this.gapBase; var ascent = base.size.ascent + this.gapBase;
...@@ -872,9 +872,9 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -872,9 +872,9 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI)
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CDegreeSubSup.prototype.setPosition = function(pos) CDegreeSubSup.prototype.setPosition = function(pos, PosInfo)
{ {
CDegreeSubSup.superclass.setPosition.call(this, pos); CDegreeSubSup.superclass.setPosition.call(this, pos, PosInfo);
} }
CDegreeSubSup.prototype.old_setPosition = function(pos) CDegreeSubSup.prototype.old_setPosition = function(pos)
{ {
......
...@@ -234,7 +234,10 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -234,7 +234,10 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
// компилируем CtrPrp после того, как выставим ArgSize // компилируем CtrPrp после того, как выставим ArgSize
// т.к. при компиляции CtrPrp для дроби важен this.Argsize (NO_BAR_FRACTION) // т.к. при компиляции CtrPrp для дроби важен this.Argsize (NO_BAR_FRACTION)
this.Set_CompiledCtrPrp(ParaMath);
// на Set_CompiledCtrPrp компилярются ctrPrp без учета ArgSize
// поэтому необязательно вызывать ее на Resize
//this.Set_CompiledCtrPrp(ParaMath);
var NewRPI = RPI.Copy(); var NewRPI = RPI.Copy();
NewRPI.bInsideFraction = true; NewRPI.bInsideFraction = true;
...@@ -262,7 +265,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure) ...@@ -262,7 +265,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
var height = num.height + den.height; var height = num.height + den.height;
var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
...@@ -277,7 +280,7 @@ CFraction.prototype.recalculateSkewed = function(oMeasure) ...@@ -277,7 +280,7 @@ CFraction.prototype.recalculateSkewed = function(oMeasure)
var height = this.elements[0][0].size.height + this.elements[0][1].size.height; var height = this.elements[0][0].size.height + this.elements[0][1].size.height;
var ascent = this.elements[0][0].size.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var ascent = this.elements[0][0].size.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
...@@ -314,11 +317,11 @@ CFraction.prototype.recalculateLinear = function() ...@@ -314,11 +317,11 @@ CFraction.prototype.recalculateLinear = function()
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width; var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent}; this.size = {height: height, width: width, ascent: ascent};
} }
CFraction.prototype.setPosition = function(pos) CFraction.prototype.setPosition = function(pos, PosInfo)
{ {
if(this.Pr.type == SKEWED_FRACTION) if(this.Pr.type == SKEWED_FRACTION)
{ {
...@@ -339,11 +342,11 @@ CFraction.prototype.setPosition = function(pos) ...@@ -339,11 +342,11 @@ CFraction.prototype.setPosition = function(pos)
PosDen.x = X + this.elements[0][0].size.width + this.dW; PosDen.x = X + this.elements[0][0].size.width + this.dW;
PosDen.y = Y + this.elements[0][0].size.height; PosDen.y = Y + this.elements[0][0].size.height;
this.elements[0][0].setPosition(PosNum); this.elements[0][0].setPosition(PosNum, PosInfo);
this.elements[0][1].setPosition(PosDen); this.elements[0][1].setPosition(PosDen, PosInfo);
} }
else else
CFraction.superclass.setPosition.call(this, pos); CFraction.superclass.setPosition.call(this, pos, PosInfo);
} }
CFraction.prototype.setProperties = function(props) CFraction.prototype.setProperties = function(props)
{ {
...@@ -499,9 +502,9 @@ CNumerator.prototype.recalculateSize = function() ...@@ -499,9 +502,9 @@ CNumerator.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent}; this.size = {width : width, height: height, ascent: ascent};
} }
CNumerator.prototype.setPosition = function(pos) CNumerator.prototype.setPosition = function(pos, PosInfo)
{ {
this.elements[0][0].setPosition(pos); this.elements[0][0].setPosition(pos, PosInfo);
} }
CNumerator.prototype.getElement = function() CNumerator.prototype.getElement = function()
{ {
...@@ -556,14 +559,14 @@ CDenominator.prototype.recalculateSize = function() ...@@ -556,14 +559,14 @@ CDenominator.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent}; this.size = {width : width, height: height, ascent: ascent};
} }
CDenominator.prototype.setPosition = function(pos) CDenominator.prototype.setPosition = function(pos, PosInfo)
{ {
var NewPos = new CMathPosition(); var NewPos = new CMathPosition();
NewPos.x = pos.x; NewPos.x = pos.x;
NewPos.y = pos.y + this.gap; NewPos.y = pos.y + this.gap;
this.elements[0][0].setPosition(NewPos); this.elements[0][0].setPosition(NewPos, PosInfo);
} }
CDenominator.prototype.getElement = function(txt) CDenominator.prototype.getElement = function(txt)
{ {
......
...@@ -26,7 +26,6 @@ CLimit.prototype.init = function(props) ...@@ -26,7 +26,6 @@ CLimit.prototype.init = function(props)
{ {
// посмотреть GetAllFonts // посмотреть GetAllFonts
this.setProperties(props); this.setProperties(props);
//this.fillContent();
} }
CLimit.prototype.getAscent = function() CLimit.prototype.getAscent = function()
{ {
...@@ -40,22 +39,10 @@ CLimit.prototype.getAscent = function() ...@@ -40,22 +39,10 @@ CLimit.prototype.getAscent = function()
} }
CLimit.prototype.getFName = function() CLimit.prototype.getFName = function()
{ {
/*var fName;
if(this.Pr.type == LIMIT_LOW)
fName = this.elements[0][0];
else if(this.Pr.type == LIMIT_UP)
fName = this.elements[1][0];*/
return this.FName; return this.FName;
} }
CLimit.prototype.getIterator = function() CLimit.prototype.getIterator = function()
{ {
/*var iterator;
if(this.Pr.type == LIMIT_LOW)
iterator = this.elements[1][0];
else if(this.Pr.type == LIMIT_UP)
iterator = this.elements[0][0];*/
return this.Iterator; return this.Iterator;
} }
CLimit.prototype.setDistance = function() CLimit.prototype.setDistance = function()
...@@ -69,51 +56,52 @@ CLimit.prototype.setProperties = function(props) ...@@ -69,51 +56,52 @@ CLimit.prototype.setProperties = function(props)
this.setCtrPrp(props.ctrPrp); this.setCtrPrp(props.ctrPrp);
} }
CLimit.prototype.fillContent = function() CLimit.prototype.fillMathComposition = function(props, contents /*array*/)
{ {
this.setDimension(2, 1); this.setProperties(props);
/*var oBase = new CMathContent();
var oIter = new CMathContent(); this.FName = contents[0];
//oIter.decreaseArgSize(); this.Iterator = contents[1];
if(this.Pr.type == LIMIT_LOW) this.RecalcInfo.bProps = true;
this.addMCToContent([oBase, oIter]);
else if(this.Pr.type == LIMIT_UP)
this.addMCToContent([oIter, oBase]);*/
} }
CLimit.prototype.fillMathComposition = function(props, contents /*array*/) CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.setProperties(props); this.Parent = Parent;
this.fillContent(); this.ParaMath = ParaMath;
if(this.Pr.type == LIMIT_LOW) //this.Set_CompiledCtrPrp(ParaMath);
if(this.RecalcInfo.bProps == true || RPI.bChangeInline == true)
{ {
// Base if(RPI.bInline == true)
this.elements[0][0] = contents[0]; {
this.setDimension(1, 1);
var props;
// Iterator if(this.Pr.type == LIMIT_LOW)
this.elements[1][0] = contents[1]; {
props =
{
type: DEGREE_SUBSCRIPT,
ctrPrp: this.CtrPrp
};
} }
else else
{ {
// Iterator props =
this.elements[0][0] = contents[1]; {
type: DEGREE_SUPERSCRIPT,
// Base ctrPrp: this.CtrPrp
this.elements[1][0] = contents[0]; };
} }
} this.elements[0][0] = new CDegree(null, true);
CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) this.elements[0][0].fillMathComposition(props, [this.FName, this.Iterator]);
{ }
this.Parent = Parent; else
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath);
if(this.RecalcInfo.bProps == true)
{ {
this.setDimension(2, 1); this.setDimension(2, 1);
...@@ -127,16 +115,26 @@ CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -127,16 +115,26 @@ CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.elements[0][0] = this.Iterator; this.elements[0][0] = this.Iterator;
this.elements[1][0] = this.FName; this.elements[1][0] = this.FName;
} }
}
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
if(RPI.bInline == true)
{
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
}
else
{
this.FName.Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.FName.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
var ArgSzIter = ArgSize.Copy(); var ArgSzIter = ArgSize.Copy();
ArgSzIter.decrease(); ArgSzIter.decrease();
this.Iterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzIter); this.Iterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzIter);
}
this.recalculateSize(oMeasure); this.recalculateSize(oMeasure);
} }
......
...@@ -41,6 +41,9 @@ function CRPI() ...@@ -41,6 +41,9 @@ function CRPI()
this.bInline = false; this.bInline = false;
this.bChangeInline = false; this.bChangeInline = false;
this.bNaryInline = false; /*для CDegreeSupSub внутри N-арного оператора, этот флаг необходим, чтобы итераторы максимально близко друг к другу расположить*/ this.bNaryInline = false; /*для CDegreeSupSub внутри N-арного оператора, этот флаг необходим, чтобы итераторы максимально близко друг к другу расположить*/
this.bEqqArray = false; /*для амперсанда*/
this.AmperWPoints = null;
this.bManyRuns = false;
} }
CRPI.prototype.Copy = function() CRPI.prototype.Copy = function()
{ {
...@@ -54,6 +57,36 @@ CRPI.prototype.Copy = function() ...@@ -54,6 +57,36 @@ CRPI.prototype.Copy = function()
return RPI; return RPI;
} }
function CMathPosInfo()
{
this.CurrPoint = 0;
this.Widths = [];
this.Points = [];
}
function CMathPosition()
{
this.x = 0;
this.y = 0;
}
function AmperWidths()
{
this.CurrRow = -1;
this.Widths = [];
}
AmperWidths.prototype.GetWidths = function()
{
return this.Widths[this.CurrRow];
}
AmperWidths.prototype.AddWRow = function()
{
this.CurrRow++;
this.Widths[this.CurrRow] = new Array();
}
function CGaps(oSign, oEqual, oZeroOper, oLett) function CGaps(oSign, oEqual, oZeroOper, oLett)
{ {
this.sign = oSign; this.sign = oSign;
...@@ -198,12 +231,12 @@ CMathArgSize.prototype = ...@@ -198,12 +231,12 @@ CMathArgSize.prototype =
// TODO // TODO
// проконтролировать GapLeft и GapRight для setPosition всех элементов // проконтролировать GapLeft и GapRight для setPosition всех элементов
function CMathGapsInfo(oMeasure, argSize) function CMathGapsInfo(oMeasure, Parent, argSize)
{ {
this.measure = oMeasure; this.measure = oMeasure;
//this.Parent = Parent; this.Parent = Parent;
//this.ParaMath = this.Parent.ParaMath; // для Para_Run this.ParaMath = this.Parent.ParaMath; // для Para_Run
this.argSize = argSize; // argSize выставляем один раз для всего контента this.argSize = argSize; // argSize выставляем один раз для всего контента
this.leftRunPrp = null; // Run_Prp левого элемента this.leftRunPrp = null; // Run_Prp левого элемента
...@@ -476,7 +509,7 @@ CMathGapsInfo.prototype = ...@@ -476,7 +509,7 @@ CMathGapsInfo.prototype =
if(leftCoeff > rightCoeff) if(leftCoeff > rightCoeff)
leftCoeff -= rightCoeff; leftCoeff -= rightCoeff;
} }
else else if(this.Left.Type == para_Math_Text)
{ {
leftCode = this.Left.getCodeChr(); leftCode = this.Left.getCodeChr();
leftCoeff = COEFF_GAPS.getCoeff(currCode, leftCode, -1); leftCoeff = COEFF_GAPS.getCoeff(currCode, leftCode, -1);
...@@ -487,7 +520,7 @@ CMathGapsInfo.prototype = ...@@ -487,7 +520,7 @@ CMathGapsInfo.prototype =
else else
this.Current.GapLeft = 0; this.Current.GapLeft = 0;
} }
else else if(this.Current.Type == para_Math_Composition)
{ {
leftCoeff = this.getGapsMComp(this.Current, -1); leftCoeff = this.getGapsMComp(this.Current, -1);
...@@ -507,7 +540,7 @@ CMathGapsInfo.prototype = ...@@ -507,7 +540,7 @@ CMathGapsInfo.prototype =
else else
leftCoeff -= rightCoeff/2; leftCoeff -= rightCoeff/2;
} }
else else if(this.Left.Type == para_Math_Text)
{ {
leftCode = this.Left.getCodeChr(); leftCode = this.Left.getCodeChr();
rightCoeff = COEFF_GAPS.getCoeff(leftCode, -1, 1); rightCoeff = COEFF_GAPS.getCoeff(leftCode, -1, 1);
...@@ -704,7 +737,6 @@ CMPrp.prototype = ...@@ -704,7 +737,6 @@ CMPrp.prototype =
function CMathContent() function CMathContent()
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
...@@ -744,13 +776,7 @@ function CMathContent() ...@@ -744,13 +776,7 @@ function CMathContent()
this.NearPosArray = []; this.NearPosArray = [];
this.size = this.size = new CMathSize();
{
width: 0,
height: 0,
ascent: 0
};
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора) // Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
...@@ -3804,10 +3830,8 @@ CMathContent.prototype = ...@@ -3804,10 +3830,8 @@ CMathContent.prototype =
this.content.push( placeholder );*/ this.content.push( placeholder );*/
}, },
////////////////////////////////////// //////////////////////////////////////
recalculateSize: function()
recalculateSize: function(oMeasure, RPI, ArgSize)
{ {
var width = 0 ; var width = 0 ;
var ascent = 0 ; var ascent = 0 ;
...@@ -3834,7 +3858,6 @@ CMathContent.prototype = ...@@ -3834,7 +3858,6 @@ CMathContent.prototype =
descent = descent < oDescent ? oDescent : descent; descent = descent < oDescent ? oDescent : descent;
} }
this.size = {width: width, height: ascent + descent, ascent: ascent}; this.size = {width: width, height: ascent + descent, ascent: ascent};
}, },
Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // пересчитываем всю формулу Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // пересчитываем всю формулу
...@@ -3845,49 +3868,80 @@ CMathContent.prototype = ...@@ -3845,49 +3868,80 @@ CMathContent.prototype =
this.Compiled_ArgSz.Merge(ArgSize); this.Compiled_ArgSz.Merge(ArgSize);
} }
var GapsInfo = new CMathGapsInfo(oMeasure, this.Compiled_ArgSz.value);
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
if(Parent !== null) if(Parent !== null)
{ {
this.bRoot = false; this.bRoot = false;
this.Parent = Parent; this.Parent = Parent;
} }
var GapsInfo = new CMathGapsInfo(oMeasure, this, this.Compiled_ArgSz.value);
if (!this.bRoot && this.content.length == 0) if (!this.bRoot && this.content.length == 0)
this.fillPlaceholders(); this.fillPlaceholders();
var lng = this.content.length; var lng = this.content.length;
this.size.SetZero();
var bManyRuns = RPI.bEqqArray == true && this.content.length > 1;
if(bManyRuns)
RPI.bManyRuns = true;
for(var pos = 0; pos < lng; pos++) for(var pos = 0; pos < lng; pos++)
{ {
if(this.content[pos].Type == para_Math_Composition) if(this.content[pos].Type == para_Math_Composition)
{ {
// мержим ctrPrp до того, как добавим Gaps !
//this.content[pos].Set_CompiledCtrPrp(ParaMath); // без ParaMath не смержим ctrPrp
// обнуляем Gaps, чтобы при расчете ширины они не участвовалиу // обнуляем Gaps, чтобы при расчете ширины они не участвовалиу
this.content[pos].GapLeft = 0; /*this.content[pos].GapLeft = 0;
this.content[pos].GapRight = 0; this.content[pos].GapRight = 0;*/
this.content[pos].Resize(oMeasure, this, ParaMath, RPI, this.Compiled_ArgSz);
this.content[pos].Set_CompiledCtrPrp(this.ParaMath);
this.content[pos].SetGaps(GapsInfo); this.content[pos].SetGaps(GapsInfo);
//this.content[pos].ApplyGaps();
} }
else if(this.content[pos].Type == para_Math_Run /*&& !this.content[pos].Is_Empty()*/) else if(this.content[pos].Type == para_Math_Run /*&& !this.content[pos].Is_Empty()*/)
{
this.content[pos].Math_Recalculate(oMeasure, this, ParaMath.Paragraph, RPI, this.Compiled_ArgSz);
this.content[pos].Math_SetGaps(GapsInfo); this.content[pos].Math_SetGaps(GapsInfo);
//this.content[pos].Math_ApplyGaps();
}
if(pos > 0)
this.recalculateSize_2(pos-1, oMeasure, Parent, ParaMath, RPI);
} }
if(GapsInfo.Current !== null) if(GapsInfo.Current !== null)
GapsInfo.Current.GapRight = 0; GapsInfo.Current.GapRight = 0;
if(lng > 0)
this.recalculateSize_2(lng-1, oMeasure, Parent, ParaMath, RPI);
},
recalculateSize_2: function(pos, oMeasure, Parent, ParaMath, RPI)
{
if(this.content[pos].Type == para_Math_Composition)
this.content[pos].Resize(oMeasure, this, ParaMath, RPI, this.Compiled_ArgSz);
else if(this.content[pos].Type == para_Math_Run)
this.content[pos].Math_Recalculate(oMeasure, this, ParaMath.Paragraph, RPI, this.Compiled_ArgSz);
this.WidthToElement[pos] = this.size.width;
var oSize = this.content[pos].size;
this.size.width += oSize.width;
var oDescent = oSize.height - oSize.ascent,
SizeDescent = this.size.height - this.size.ascent;
this.size.ascent = this.size.ascent > oSize.ascent ? this.size.ascent : oSize.ascent;
this.recalculateSize(oMeasure, RPI, this.Compiled_ArgSz); this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent;
},
IsEqqArray: function()
{
return this.Parent.IsEqqArray();
}, },
Get_CompiledArgSize: function() Get_CompiledArgSize: function()
{ {
...@@ -4009,23 +4063,27 @@ CMathContent.prototype = ...@@ -4009,23 +4063,27 @@ CMathContent.prototype =
{ {
return false; return false;
}, },
setPosition: function(pos) setPosition: function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
this.pos.y = pos.y; this.pos.y = pos.y;
var NewPos = new CMathPosition(); var x = pos.x,
y = pos.y + this.size.ascent; // y по baseline;
NewPos.x = pos.x;
NewPos.y = pos.y + this.size.ascent; // y по baseline;
for(var i=0; i < this.content.length; i++) for(var i=0; i < this.content.length; i++)
{ {
this.content[i].setPosition(NewPos); var NewPos = new CMathPosition();
NewPos.x += this.content[i].size.width; NewPos.x = x;
} NewPos.y = y;
if(this.content[i].Type == para_Math_Run)
this.content[i].Math_SetPosition(NewPos, PosInfo);
else
this.content[i].setPosition(NewPos, PosInfo);
x += this.content[i].size.width;
}
}, },
///// properties ///// ///// properties /////
SetDot: function(flag) SetDot: function(flag)
......
...@@ -21,10 +21,17 @@ var StartTextElement = 0x2B1A; // Cambria Math ...@@ -21,10 +21,17 @@ var StartTextElement = 0x2B1A; // Cambria Math
// смена хентов // смена хентов
// editor.SetFontRenderingMode(2); // editor.SetFontRenderingMode(2);
function CMathPosition() function CMathSize()
{ {
this.x = 0; this.width = 0;
this.y = 0; this.height = 0;
this.ascent = 0;
}
CMathSize.prototype.SetZero = function()
{
this.width = 0;
this.height = 0;
this.ascent = 0;
} }
function CMathText(bJDraw) function CMathText(bJDraw)
...@@ -33,8 +40,9 @@ function CMathText(bJDraw) ...@@ -33,8 +40,9 @@ function CMathText(bJDraw)
this.Type = para_Math_Text; this.Type = para_Math_Text;
this.bJDraw = bJDraw; this.bJDraw = bJDraw;
this.size = null; this.size = new CMathSize();
this.value = null; this.value = null;
this.Parent = null;
this.pos = new CMathPosition(); this.pos = new CMathPosition();
this.rasterOffsetX = 0; this.rasterOffsetX = 0;
...@@ -77,7 +85,7 @@ CMathText.prototype = ...@@ -77,7 +85,7 @@ CMathText.prototype =
{ {
var code = this.value; var code = this.value;
var Compiled_MPrp = this.bJDraw ? null : this.Parent.MathPrp.GetCompiled_ScrStyles(); var Compiled_MPrp = this.bJDraw ? null : this.Parent.GetCompiled_ScrStyles();
if(this.Type === para_Math_Placeholder || this.bJDraw || Compiled_MPrp.nor) if(this.Type === para_Math_Placeholder || this.bJDraw || Compiled_MPrp.nor)
return code; return code;
...@@ -464,7 +472,7 @@ CMathText.prototype = ...@@ -464,7 +472,7 @@ CMathText.prototype =
this.Type = para_Math_Placeholder; this.Type = para_Math_Placeholder;
this.value = StartTextElement; this.value = StartTextElement;
}, },
Resize: function(oMeasure, Run) Resize: function(oMeasure, Parent, RPI)
{ {
/* /*
var metricsTxt = g_oTextMeasurer.Measure2Code(letter); var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
...@@ -475,8 +483,8 @@ CMathText.prototype = ...@@ -475,8 +483,8 @@ CMathText.prototype =
this.GapLeft = 0; this.GapLeft = 0;
this.GapRight = 0; this.GapRight = 0;
if(!this.bJustDraw) if(!this.bJDraw)
this.Parent = Run; this.Parent = Parent;
else else
this.Parent = null; this.Parent = null;
...@@ -508,14 +516,19 @@ CMathText.prototype = ...@@ -508,14 +516,19 @@ CMathText.prototype =
this.WidthVisible = width; this.WidthVisible = width;
this.size = {width: width, widthG: width, height: height, ascent: ascent}; this.size.width = this.GapLeft + this.GapRight + width;
this.size.height = height;
this.size.ascent = ascent;
//this.size = {width: width, widthG: width, height: height, ascent: ascent};
}, },
ApplyGaps: function() /*ApplyGaps: function()
{ {
this.size.width += this.GapLeft + this.GapRight; this.size.SetZero();
this.size.width = this.GapLeft + this.GapRight;
this.WidthVisible = this.size.width; this.WidthVisible = this.size.width;
}, },*/
draw: function(x, y, pGraphics) draw: function(x, y, pGraphics)
{ {
var X = this.pos.x + x, var X = this.pos.x + x,
...@@ -677,12 +690,6 @@ CMathText.prototype = ...@@ -677,12 +690,6 @@ CMathText.prototype =
return NewLetter; return NewLetter;
}, },
// заглушка для текста (для n-арных операторов, когда выставляется текст вместо оператора)
setComposition: function() // заглушка
{},
setReferenceComposition: function() // заглушка
{},
Write_ToBinary : function(Writer) Write_ToBinary : function(Writer)
{ {
// Long : Type // Long : Type
...@@ -699,3 +706,85 @@ CMathText.prototype = ...@@ -699,3 +706,85 @@ CMathText.prototype =
} }
function CMathAmp()
{
this.bEqqArray = false;
this.Type = para_Math_Ampersand;
this.pos = new CMathPosition();
this.AmpText = new CMathText(false);
this.AmpText.add(0x26);
this.size = null;
this.Parent = null;
}
CMathAmp.prototype =
{
Resize: function(oMeasure, Parent, RPI)
{
this.Parent = Parent;
this.bEqqArray = RPI.bEqqArray;
this.AmpText.Resize(oMeasure, this, RPI);
if(this.bEqqArray)
{
this.size =
{
width: 0,
height: 0,
ascent: 0
};
}
else
{
this.size =
{
width: this.AmpText.size.width,
height: this.AmpText.size.height,
ascent: this.AmpText.size.ascent
};
}
},
setPosition: function(pos)
{
this.pos.x = pos.x;
this.pos.y = pos.y;
if(this.bEqqArray==false)
this.AmpText.setPosition(pos);
},
draw: function(x, y, pGraphics)
{
if(this.bEqqArray==false)
this.AmpText.draw(x, y, pGraphics);
else
{
var X = x + this.pos.x,
Y = y + this.pos.y,
Y2 = y + this.pos.y - this.AmpText.size.height;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, X, Y, Y2, 0.1);
}
},
IsPlaceholder: function()
{
return false;
},
/*ApplyGaps: function()
{
if(this.bEqqArray==false)
this.AmpText.ApplyGaps();
},*/
GetCompiled_ScrStyles: function()
{
return this.Parent.GetCompiled_ScrStyles();
},
IsAccent: function()
{
return this.Parent.IsAccent();
}
}
...@@ -93,7 +93,7 @@ CMathMatrix.prototype.setRuleGap = function(oSpace, rule, gap, minGap) ...@@ -93,7 +93,7 @@ CMathMatrix.prototype.setRuleGap = function(oSpace, rule, gap, minGap)
if(minGap == minGap - 0 && minGap == minGap^0) if(minGap == minGap - 0 && minGap == minGap^0)
oSpace.minGap = minGap; oSpace.minGap = minGap;
} }
CMathMatrix.prototype.recalculateSize = function(oMeasure) CMathMatrix.prototype.recalculateSize = function(oMeasure, RPI)
{ {
if(this.RecalcInfo.bProps) if(this.RecalcInfo.bProps)
{ {
...@@ -135,7 +135,7 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure) ...@@ -135,7 +135,7 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure)
var intervalRow = this.getRowSpace(txtPrp); var intervalRow = this.getRowSpace(txtPrp);
var divCenter = 0; var divCenter = 0;
var metrics = this.getMetrics(); var metrics = this.getMetrics(RPI);
var plH = 0.2743827160493827 * txtPrp.FontSize; var plH = 0.2743827160493827 * txtPrp.FontSize;
var minGp = this.spaceRow.minGap*txtPrp.FontSize*g_dKoef_pt_to_mm; var minGp = this.spaceRow.minGap*txtPrp.FontSize*g_dKoef_pt_to_mm;
...@@ -180,11 +180,11 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure) ...@@ -180,11 +180,11 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure)
ascent = this.getAscent(oMeasure, height); ascent = this.getAscent(oMeasure, height);
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CMathMatrix.prototype.setPosition = function(pos) CMathMatrix.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
...@@ -201,6 +201,7 @@ CMathMatrix.prototype.setPosition = function(pos) ...@@ -201,6 +201,7 @@ CMathMatrix.prototype.setPosition = function(pos)
var h = 0, w = 0; var h = 0, w = 0;
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
{ {
w = 0; w = 0;
...@@ -210,7 +211,7 @@ CMathMatrix.prototype.setPosition = function(pos) ...@@ -210,7 +211,7 @@ CMathMatrix.prototype.setPosition = function(pos)
NewPos.x = this.pos.x + this.GapLeft + al.x + w; NewPos.x = this.pos.x + this.GapLeft + al.x + w;
NewPos.y = this.pos.y + al.y + h; NewPos.y = this.pos.y + al.y + h;
this.elements[i][j].setPosition(NewPos); this.elements[i][j].setPosition(NewPos, PosInfo);
w += Widths[j] + this.gaps.column[j]; w += Widths[j] + this.gaps.column[j];
} }
h += Heights[i] + this.gaps.row[i]; h += Heights[i] + this.gaps.row[i];
...@@ -300,28 +301,25 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi ...@@ -300,28 +301,25 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi
return result; return result;
} }
CMathMatrix.prototype.getMetrics = function() CMathMatrix.prototype.getMetrics = function(RPI)
{ {
var Ascents = []; var Ascents = [];
var Descents = []; var Descents = [];
var Widths = []; var Widths = [];
for(tt = 0; tt < this.nRow; tt++ ) for(var i=0; i < this.nRow; i++)
{ {
Ascents[tt] = 0; Ascents[i] = 0;
Descents[tt] = 0; Descents[i] = 0;
}
for(var tt = 0; tt < this.nCol; tt++ )
Widths[tt] = 0;
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol ; j++) for(var j = 0; j < this.nCol ; j++)
{ {
var size = this.elements[i][j].size; var size = this.elements[i][j].size;
Widths[j] = ( Widths[j] > size.width ) ? Widths[j] : size.width; Widths[j] = i > 0 && ( Widths[j] > size.width ) ? Widths[j] : size.width;
Ascents[i] = (Ascents[i] > size.ascent ) ? Ascents[i] : size.ascent; Ascents[i] = (Ascents[i] > size.ascent ) ? Ascents[i] : size.ascent;
Descents[i] = (Descents[i] > size.height - size.ascent ) ? Descents[i] : size.height - size.ascent; Descents[i] = (Descents[i] > size.height - size.ascent ) ? Descents[i] : size.height - size.ascent;
} }
}
return {ascents: Ascents, descents: Descents, widths: Widths} return {ascents: Ascents, descents: Descents, widths: Widths}
} }
...@@ -680,6 +678,11 @@ function CEqArray(props) ...@@ -680,6 +678,11 @@ function CEqArray(props)
this.setDefaultSpace(); this.setDefaultSpace();
// for ampersand in Run
this.WidthsPoints = [];
this.Points = [];
//
//// special for "read" //// //// special for "read" ////
this.column = 0; this.column = 0;
//// ////
...@@ -699,6 +702,161 @@ CEqArray.prototype.init = function(props) ...@@ -699,6 +702,161 @@ CEqArray.prototype.init = function(props)
this.setProperties(props); this.setProperties(props);
this.fillContent(); this.fillContent();
} }
CEqArray.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
RPI.bEqqArray = true;
this.Parent = Parent;
this.ParaMath = ParaMath;
//this.Set_CompiledCtrPrp(ParaMath);
RPI.AmperWPoints = new AmperWidths();
for(var i = 0; i < this.nRow; i++)
{
RPI.AmperWPoints.AddWRow();
this.elements[i][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
}
this.recalculateSize(oMeasure, RPI);
RPI.AmperWPoints = null;
RPI.bEqqArray = false;
//CEqArray.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize);
}
CEqArray.prototype.getMetrics = function(RPI)
{
var AscentsMetrics = [];
var DescentsMetrics = [];
var WidthsMetrics = [];
// нумерация начинается с нуля, поэтому все четные точки идут с нечетными номерами в массиве
//var lngW = RPI.Widths.length; // this.nRow
var EndWidths = 0;
var even, // четная точка
odd, // нечетная точка
last;
var Pos = 0;
this.WidthsPoints.length = 0;
this.Points.length = 0;
WidthsMetrics[0] = 0;
while(EndWidths < this.nRow)
{
even = 0;
odd = 0;
last = 0;
for(var i = 0; i < this.nRow; i++)
{
var W = RPI.AmperWPoints.Widths[i],
len = RPI.AmperWPoints.Widths[i].length;
if(Pos < len && Pos + 1 < len)
{
even = even > W[Pos] ? even : W[Pos]; // before "odd"
odd = odd > W[Pos+1] ? odd : W[Pos+1]; // after "odd"
}
else if(Pos < len)
{
last = last > W[Pos] ? last: W[Pos];
}
if(Pos + 1 == len || Pos + 2 == len)
EndWidths++;
}
var w = even + odd > last ? even + odd : last;
this.WidthsPoints.push(w);
this.Points.push(even);
WidthsMetrics[0] += w;
Pos += 2;
}
if(true)
{
var str = "";
for(var i = 0; i < this.WidthsPoints.length; i++)
{
var num = this.WidthsPoints[i].toFixed(3);
str += num + " ";
}
console.log(str);
}
for(var i = 0; i < this.nRow; i++)
{
var size = this.elements[i][0].size;
AscentsMetrics[i] = size.ascent;
DescentsMetrics[i] = size.height - size.ascent;
}
/*for(var tt = 0; tt < this.nCol; tt++ )
Widths[tt] = 0;
for(var i=0; i < this.nRow; i++)
{
Ascents[i] = 0;
Descents[i] = 0;
for(var j = 0; j < this.nCol ; j++)
{
var size = this.elements[i][j].size;
Widths[j] = i > 0 && ( Widths[j] > size.width ) ? Widths[j] : size.width;
Ascents[i] = (Ascents[i] > size.ascent ) ? Ascents[i] : size.ascent;
Descents[i] = (Descents[i] > size.height - size.ascent ) ? Descents[i] : size.height - size.ascent;
}
}*/
return {ascents: AscentsMetrics, descents: DescentsMetrics, widths: WidthsMetrics};
}
CEqArray.prototype.setPosition = function(pos, PosInfo)
{
PosInfo.Widths = this.WidthsPoints;
PosInfo.Points = this.Points;
this.pos.x = pos.x;
if(this.bInside === true)
this.pos.y = pos.y;
else
this.pos.y = pos.y - this.size.ascent; ///!!!!
var maxWH = this.getWidthsHeights();
var Heights = maxWH.heights;
var NewPos = new CMathPosition();
var h = 0;
for(var i=0; i < this.nRow; i++)
{
NewPos.x = this.pos.x + this.GapLeft;
NewPos.y = this.pos.y + h;
this.elements[i][0].setPosition(NewPos, PosInfo);
h += Heights[i] + this.gaps.row[i];
}
PosInfo.Widths.length = 0;
PosInfo.Points.length = 0;
}
CEqArray.prototype.setProperties = function(props) CEqArray.prototype.setProperties = function(props)
{ {
if(props.maxDist !== "undefined" && props.maxDist !== null) if(props.maxDist !== "undefined" && props.maxDist !== null)
......
...@@ -63,7 +63,6 @@ CNary.prototype.fillContent = function(PropsInfo) ...@@ -63,7 +63,6 @@ CNary.prototype.fillContent = function(PropsInfo)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
//var arg = new CMathContent(),
var base; var base;
var Sign = PropsInfo.sign; var Sign = PropsInfo.sign;
...@@ -80,19 +79,12 @@ CNary.prototype.fillContent = function(PropsInfo) ...@@ -80,19 +79,12 @@ CNary.prototype.fillContent = function(PropsInfo)
base = new CNaryOvr(true); base = new CNaryOvr(true);
base.setBase(Sign); base.setBase(Sign);
base.setLowerIterator(this.LowerIterator); base.setLowerIterator(this.LowerIterator);
//base.setCtrPrp(ctrPrp);
//base.Set_CompiledCtrPrp(this.ParaMath);
} }
else if( !PropsInfo.supHide && PropsInfo.subHide ) else if( !PropsInfo.supHide && PropsInfo.subHide )
{ {
base = new CNaryUnd(true); base = new CNaryUnd(true);
base.setBase(Sign); base.setBase(Sign);
base.setUpperIterator(this.UpperIterator); base.setUpperIterator(this.UpperIterator);
//base.setCtrPrp(ctrPrp);
//base.Set_CompiledCtrPrp(this.ParaMath);
} }
else else
{ {
...@@ -100,9 +92,6 @@ CNary.prototype.fillContent = function(PropsInfo) ...@@ -100,9 +92,6 @@ CNary.prototype.fillContent = function(PropsInfo)
base.setBase(Sign); base.setBase(Sign);
base.setUpperIterator(this.UpperIterator); base.setUpperIterator(this.UpperIterator);
base.setLowerIterator(this.LowerIterator); base.setLowerIterator(this.LowerIterator);
//base.setCtrPrp(ctrPrp);
//base.Set_CompiledCtrPrp(this.ParaMath);
} }
} }
else else
...@@ -115,9 +104,6 @@ CNary.prototype.fillContent = function(PropsInfo) ...@@ -115,9 +104,6 @@ CNary.prototype.fillContent = function(PropsInfo)
base = new CDegree(prp, true); base = new CDegree(prp, true);
base.setBase(Sign); base.setBase(Sign);
base.setIterator(this.LowerIterator); base.setIterator(this.LowerIterator);
//base.setCtrPrp(ctrPrp);
//base.Set_CompiledCtrPrp(this.ParaMath);
} }
else if( !PropsInfo.supHide && PropsInfo.subHide ) else if( !PropsInfo.supHide && PropsInfo.subHide )
{ {
...@@ -125,9 +111,6 @@ CNary.prototype.fillContent = function(PropsInfo) ...@@ -125,9 +111,6 @@ CNary.prototype.fillContent = function(PropsInfo)
base = new CDegree(prp, true); base = new CDegree(prp, true);
base.setBase(Sign); base.setBase(Sign);
base.setIterator(this.UpperIterator); base.setIterator(this.UpperIterator);
//base.setCtrPrp(ctrPrp);
//base.Set_CompiledCtrPrp(this.ParaMath);
} }
else if(PropsInfo.supHide && PropsInfo.subHide) else if(PropsInfo.supHide && PropsInfo.subHide)
{ {
...@@ -140,8 +123,6 @@ CNary.prototype.fillContent = function(PropsInfo) ...@@ -140,8 +123,6 @@ CNary.prototype.fillContent = function(PropsInfo)
base.setBase(Sign); base.setBase(Sign);
base.setLowerIterator(this.LowerIterator); base.setLowerIterator(this.LowerIterator);
base.setUpperIterator(this.UpperIterator); base.setUpperIterator(this.UpperIterator);
base.setCtrPrp(ctrPrp);
//base.Set_CompiledCtrPrp(this.ParaMath);
} }
} }
...@@ -161,21 +142,6 @@ CNary.prototype.fillMathComposition = function(props, contents /*array*/) ...@@ -161,21 +142,6 @@ CNary.prototype.fillMathComposition = function(props, contents /*array*/)
this.UpperIterator = contents[1]; this.UpperIterator = contents[1];
this.LowerIterator = contents[2]; this.LowerIterator = contents[2];
//this.fillContent();
/*// Base
this.elements[0][1] = contents[0];
if(!this.Pr.subHide)
this.elements[0][0].changeUpperIterator(contents[1]);
// Lower iterator
if(!this.Pr.subHide)
this.elements[0][0].changeLowerIterator(contents[2]);*/
} }
CNary.prototype.old_fillMathComposition = function(props, contents /*array*/) CNary.prototype.old_fillMathComposition = function(props, contents /*array*/)
{ {
...@@ -200,7 +166,7 @@ CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -200,7 +166,7 @@ CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
if(this.RecalcInfo.bProps || RPI.bChangeInline == true) if(this.RecalcInfo.bProps || RPI.bChangeInline == true)
{ {
...@@ -252,36 +218,6 @@ CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -252,36 +218,6 @@ CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.Arg.Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.Arg.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
this.recalculateSize(oMeasure); this.recalculateSize(oMeasure);
/*if(PropsInfo.subHide == false)
{
var ArgSzSub = ArgSize.Copy();
ArgSzSub.decrease();
this.UpperIterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzSub);
}
if(PropsInfo.supHide == false)
{
var ArgSzSupScr = ArgSize.Copy();
ArgSzSub.decrease();
this.UpperIterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzSupScr);
}
if(PropsInfo.subHide == false || PropsInfo.supHide == false)
{
this.Base.Parent = this;
this.Base.ParaMath = ParaMath;
this.Base.recalculateSize(oMeasure);
}
this.Sign.Resize(oMeasure, this.Base, ParaMath);
this.recalculateSize(oMeasure);*/
//CNary.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI);
} }
CNary.prototype.getSign = function(chrCode, chrType) CNary.prototype.getSign = function(chrCode, chrType)
{ {
...@@ -294,16 +230,6 @@ CNary.prototype.getSign = function(chrCode, chrType) ...@@ -294,16 +230,6 @@ CNary.prototype.getSign = function(chrCode, chrType)
var bChr = chrCode !== null && chrCode == chrCode + 0; var bChr = chrCode !== null && chrCode == chrCode + 0;
/*var bChr = false;
var chrCode;*/
/*if(typeof(chr) === "string")
{
chrCode = chr.charCodeAt(0);
bChr = true;
}*/
if(chrCode == 0x222B || chrType == NARY_INTEGRAL) if(chrCode == 0x222B || chrType == NARY_INTEGRAL)
{ {
result.chrCode = 0x222B; result.chrCode = 0x222B;
...@@ -634,7 +560,7 @@ CNaryOvr.prototype.recalculateSize = function() ...@@ -634,7 +560,7 @@ CNaryOvr.prototype.recalculateSize = function()
var ascent = nOper.ascent; var ascent = nOper.ascent;
var width = nOper.width > iter.width ? nOper.width : iter.width; var width = nOper.width > iter.width ? nOper.width : iter.width;
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
var height = nOper.height + this.dH + iter.height; var height = nOper.height + this.dH + iter.height;
...@@ -719,12 +645,12 @@ CNaryUndOvr.prototype.recalculateSize = function() ...@@ -719,12 +645,12 @@ CNaryUndOvr.prototype.recalculateSize = function()
height += this.elements[i][0].size.height; height += this.elements[i][0].size.height;
} }
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
height += this.gapTop + this.gapBottom; height += this.gapTop + this.gapBottom;
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CNaryUndOvr.prototype.setPosition = function(pos) CNaryUndOvr.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent; this.pos.y = pos.y - this.size.ascent;
...@@ -746,9 +672,9 @@ CNaryUndOvr.prototype.setPosition = function(pos) ...@@ -746,9 +672,9 @@ CNaryUndOvr.prototype.setPosition = function(pos)
PosLowIter.x = pos.x + this.GapLeft + this.align(2,0).x; PosLowIter.x = pos.x + this.GapLeft + this.align(2,0).x;
PosLowIter.y = PosSign.y + this.elements[1][0].size.height + this.gapBottom; PosLowIter.y = PosSign.y + this.elements[1][0].size.height + this.gapBottom;
this.elements[0][0].setPosition(PosUpIter); this.elements[0][0].setPosition(PosUpIter, PosInfo);
this.elements[1][0].setPosition(PosSign); this.elements[1][0].setPosition(PosSign, PosInfo);
this.elements[2][0].setPosition(PosLowIter); this.elements[2][0].setPosition(PosLowIter, PosInfo);
} }
CNaryUndOvr.prototype.setBase = function(base) CNaryUndOvr.prototype.setBase = function(base)
{ {
......
...@@ -3468,7 +3468,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3468,7 +3468,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
if(this.RecalcInfo.bProps == true) if(this.RecalcInfo.bProps == true)
{ {
...@@ -3557,7 +3557,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3557,7 +3557,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
// Общая ширина // Общая ширина
var width = widthG + this.begOper.size.width + this.endOper.size.width + (this.nCol - 1)*this.sepOper.size.width; var width = widthG + this.begOper.size.width + this.endOper.size.width + (this.nCol - 1)*this.sepOper.size.width;
width += this.GapLeft + this.GapRight;
var maxDimOper; var maxDimOper;
if(this.begOper.size.height > this.endOper.size.height && this.begOper.size.height > this.sepOper.size.height) if(this.begOper.size.height > this.endOper.size.height && this.begOper.size.height > this.sepOper.size.height)
...@@ -3684,7 +3684,7 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве ...@@ -3684,7 +3684,7 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве
return align; return align;
} }
CDelimiter.prototype.setPosition = function(position) CDelimiter.prototype.setPosition = function(position, PosInfo)
{ {
this.pos.x = position.x; this.pos.x = position.x;
this.pos.y = position.y - this.size.ascent; this.pos.y = position.y - this.size.ascent;
...@@ -3707,7 +3707,7 @@ CDelimiter.prototype.setPosition = function(position) ...@@ -3707,7 +3707,7 @@ CDelimiter.prototype.setPosition = function(position)
PosContent.y = y + this.align_2(content); PosContent.y = y + this.align_2(content);
x += content.size.width; x += content.size.width;
content.setPosition(PosContent); // CMathContent content.setPosition(PosContent, PosInfo); // CMathContent
var Positions = []; var Positions = [];
...@@ -3726,7 +3726,7 @@ CDelimiter.prototype.setPosition = function(position) ...@@ -3726,7 +3726,7 @@ CDelimiter.prototype.setPosition = function(position)
NewPosContent.x = x; NewPosContent.x = x;
NewPosContent.y = y + this.align_2(content); NewPosContent.y = y + this.align_2(content);
content.setPosition(NewPosContent); content.setPosition(NewPosContent, PosInfo);
x += content.size.width; x += content.size.width;
} }
...@@ -3945,7 +3945,7 @@ CCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3945,7 +3945,7 @@ CCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.size = {height: height, width: width, ascent: ascent}; this.size = {height: height, width: width, ascent: ascent};
} }
CCharacter.prototype.setPosition = function(pos) CCharacter.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent; this.pos.y = pos.y - this.size.ascent;
...@@ -3968,14 +3968,14 @@ CCharacter.prototype.setPosition = function(pos) ...@@ -3968,14 +3968,14 @@ CCharacter.prototype.setPosition = function(pos)
PosBase.x = this.pos.x + this.GapLeft + alignCnt; PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + this.operator.size.height; PosBase.y = this.pos.y + this.operator.size.height;
this.elements[0][0].setPosition(PosBase); this.elements[0][0].setPosition(PosBase, PosInfo);
} }
else if(this.Pr.pos === LOCATION_BOT) else if(this.Pr.pos === LOCATION_BOT)
{ {
PosBase.x = this.pos.x + this.GapLeft + alignCnt; PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y; PosBase.y = this.pos.y;
this.elements[0][0].setPosition(PosBase); this.elements[0][0].setPosition(PosBase, PosInfo);
PosOper.x = this.pos.x + this.GapLeft + alignOp; PosOper.x = this.pos.x + this.GapLeft + alignOp;
PosOper.y = this.pos.y + this.elements[0][0].size.height; PosOper.y = this.pos.y + this.elements[0][0].size.height;
...@@ -4102,7 +4102,7 @@ CGroupCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, Arg ...@@ -4102,7 +4102,7 @@ CGroupCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, Arg
if(this.Pr.pos == this.Pr.vertJc) if(this.Pr.pos == this.Pr.vertJc)
ArgSz.decrease(); ArgSz.decrease();
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
CGroupCharacter.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSz); CGroupCharacter.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSz);
} }
......
...@@ -1037,7 +1037,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -1037,7 +1037,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
if(this.Pr.type == SQUARE_RADICAL) if(this.Pr.type == SQUARE_RADICAL)
this.RealBase.Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.RealBase.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
...@@ -1077,7 +1077,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -1077,7 +1077,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
ascent = gapBase + shTop + this.RealBase.size.ascent; ascent = gapBase + shTop + this.RealBase.size.ascent;
//ascent = height - (base.height - base.ascent); //ascent = height - (base.height - base.ascent);
//width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
...@@ -1097,8 +1097,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -1097,8 +1097,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0; var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0;
width = wDegree + sign.width + this.gapWidth; width = wDegree + sign.width + this.gapWidth;
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
var gapDegree; var gapDegree;
if( this.RealBase.size.height < plH ) if( this.RealBase.size.height < plH )
...@@ -1127,7 +1126,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -1127,7 +1126,7 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
} }
CRadical.prototype.setPosition = function(pos) CRadical.prototype.setPosition = function(pos, PosInfo)
{ {
this.pos.x = pos.x; this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent; this.pos.y = pos.y - this.size.ascent;
...@@ -1147,7 +1146,7 @@ CRadical.prototype.setPosition = function(pos) ...@@ -1147,7 +1146,7 @@ CRadical.prototype.setPosition = function(pos)
PosBase.y = this.pos.y + gapTop; PosBase.y = this.pos.y + gapTop;
this.signRadical.setPosition(PosRadical); this.signRadical.setPosition(PosRadical);
this.RealBase.setPosition(PosBase); this.RealBase.setPosition(PosBase, PosInfo);
} }
else if(this.Pr.type == DEGREE_RADICAL) else if(this.Pr.type == DEGREE_RADICAL)
{ {
...@@ -1162,7 +1161,7 @@ CRadical.prototype.setPosition = function(pos) ...@@ -1162,7 +1161,7 @@ CRadical.prototype.setPosition = function(pos)
PosDegree.x = this.pos.x + this.GapLeft + this.gapWidth; PosDegree.x = this.pos.x + this.GapLeft + this.gapWidth;
PosDegree.y = this.pos.y + this.gapDegree; PosDegree.y = this.pos.y + this.gapDegree;
this.Iterator.setPosition(PosDegree); this.Iterator.setPosition(PosDegree, PosInfo);
var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0; var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0;
...@@ -1174,7 +1173,7 @@ CRadical.prototype.setPosition = function(pos) ...@@ -1174,7 +1173,7 @@ CRadical.prototype.setPosition = function(pos)
PosBase.x = this.pos.x + this.size.width - this.RealBase.size.width - this.GapRight; 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; PosBase.y = this.pos.y + this.size.ascent - this.RealBase.size.ascent;
this.RealBase.setPosition(PosBase); this.RealBase.setPosition(PosBase, PosInfo);
} }
} }
CRadical.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd) CRadical.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
......
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