Commit 0f7bb692 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. Реализовала разбивку на строки delimiters

2. Поправила баг на Get_StartRangePos2, когда внутренний контент разбивался на несколько страниц было падение
3. Переделала setPosition для класса Operator

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61634 954022d7-b5bf-4e40-9824-e11837661b57
parent 387aadc5
......@@ -1751,7 +1751,7 @@ ParaMath.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchPos,
};
ParaMath.prototype.Get_StartRangePos2 = function(_CurLine, _CurRange, ContentPos, Depth)
{
return this.Root.Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth);
return this.Root.Get_StartRangePos2(_CurLine, _CurRange, ContentPos, Depth);
};
ParaMath.prototype.Get_StartPos = function(ContentPos, Depth)
......
......@@ -2168,9 +2168,11 @@ function CParagraphRecalculateStateWrap(Para)
Object : null // Объект, который вызвал пересчет
};
// for ParaMath
this.bMath_OneLine = false; // for ParaMath
this.bMathWordLarge = false; // for ParaMath
this.PosEndRun = new CParagraphContentPos();
this.ContentMetrics = new CMathMetrics();
}
CParagraphRecalculateStateWrap.prototype =
......
......@@ -2572,11 +2572,17 @@ ParaRun.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _Cur
{
case para_Sym:
case para_Text:
case para_PageNum:
{
UpdateLineMetricsText = true;
break;
}
case para_Math_Text:
case para_Math_Placeholder:
case para_Math_BreakOperator:
case para_PageNum:
{
PRS.ContentMetrics.UpdateMetrics(Item.size);
UpdateLineMetricsText = true;
break;
}
......@@ -8536,6 +8542,15 @@ ParaRun.prototype.Math_Get_EndRangePos = function(bEndLine, _CurLine, _CurRange,
return Result;
};
ParaRun.prototype.Math_Is_End = function(_CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
return EndPos == this.Content.length;
};
ParaRun.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
{
// данная функция используется только для мат объектов, которые на строки не разбиваются
......
......@@ -30,7 +30,10 @@ function CMathBase(bInside)
this.NumBreakContent = -1;
this.elements = [];
this.LinesWidths = [];
//this.LinesWidths = [];
//this.LineMetrics = [];
this.LineMetrics = new CMathLineMetrics();
this.dW = 0; //column gap, gap width
this.dH = 0; //row gap, gap height
......@@ -44,6 +47,9 @@ function CMathBase(bInside)
this.GapLeft = 0;
this.GapRight = 0;
this.BrGapLeft = 0;
this.BrGapRight = 0;
this.RecalcInfo =
{
bCtrPrp: true,
......@@ -98,6 +104,9 @@ CMathBase.prototype.NeedBreakContent = function(Number)
{
this.bCanBreak = true;
this.NumBreakContent = Number;
this.BrGapLeft = this.GapLeft;
this.BrGapRight = this.GapRight;
};
///////// RunPrp, CtrPrp
CMathBase.prototype.setCtrPrp = function(txtPrp) // выставляем ctrPrp на чтение
......@@ -336,7 +345,7 @@ CMathBase.prototype.setPosition = function(pos, Line, Range)
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
pos.x += this.GapLeft;
pos.x += this.BrGapLeft;
this.Content[StartPos].setPosition(pos, Line, Range);
......@@ -349,7 +358,7 @@ CMathBase.prototype.setPosition = function(pos, Line, Range)
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
pos.x += this.GapRight;
pos.x += this.BrGapRight;
}
};
......@@ -420,7 +429,7 @@ CMathBase.prototype.Draw_Elements = function(PDSE)
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PDSE.X += this.GapLeft;
PDSE.X += this.BrGapLeft;
this.Content[StartPos].Draw_Elements(PDSE);
......@@ -434,7 +443,7 @@ CMathBase.prototype.Draw_Elements = function(PDSE)
if(LinesCount - 1 == CurLine)
{
PDSE.X += this.GapRight;
PDSE.X += this.BrGapRight;
}
}
};
......@@ -1085,7 +1094,7 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PRSA.X += this.GapLeft;
PRSA.X += this.BrGapLeft;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
......@@ -1116,7 +1125,7 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang
if(LinesCount - 1 == CurLine)
{
PRSA.X += this.GapRight;
PRSA.X += this.BrGapRight;
}
}
};
......@@ -1131,7 +1140,8 @@ CMathBase.prototype.Get_Width = function(_CurLine)
else
{
var CurLine = _CurLine - this.StartLine;
Width = this.LinesWidths[CurLine];
Width = this.LineMetrics.GetWidth(CurLine);
//Width = this.LinesWidths[CurLine];
}
return Width;
......@@ -1537,7 +1547,7 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
{
SelectionDraw.FindStart = false;
SelectionDraw.W += this.LinesWidths[CurLine];
SelectionDraw.W += this.LineMetrics.GetWidth(CurLine);
}
else
......@@ -1545,9 +1555,9 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
if(CurLine == 0)
{
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.GapLeft;
SelectionDraw.StartX += this.BrGapLeft;
else if(SelectionUse == true)
SelectionDraw.W += this.GapLeft;
SelectionDraw.W += this.BrGapLeft;
}
this.Content[StartPos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
......@@ -1567,7 +1577,7 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
}
if(SelectionDraw.FindStart == true && LinesCount - 1 == CurLine)
SelectionDraw.StartX += this.GapRight;
SelectionDraw.StartX += this.BrGapRight;
}
}
};
......@@ -1782,8 +1792,6 @@ CMathBase.prototype.GetFirstElement = function()
};
CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var WordLen = PRS.WordLen; // запоминаем, чтобы внутр мат объекты не увеличили WordLen
var bOneLine = PRS.bMath_OneLine;
......@@ -1831,6 +1839,9 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
}
else
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
this.setDistance();
var Numb = this.NumBreakContent;
......@@ -1841,7 +1852,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if(CurLine == 0 && CurRange == 0)
{
PRS.WordLen += this.GapLeft;
PRS.WordLen += this.BrGapLeft;
}
//var PosEndRun = PRS.PosEndRun.Copy();
......@@ -1894,7 +1905,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if(PRS.NewRange == false)
{
PRS.WordLen += this.GapRight;
PRS.WordLen += this.BrGapRight;
}
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
......@@ -1928,11 +1939,8 @@ CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _C
{
if(this.bOneLine)
{
if ( PRS.LineAscent < this.size.ascent )
PRS.LineAscent = this.size.ascent;
if ( PRS.LineDescent < this.size.height - this.size.ascent )
PRS.LineDescent = this.size.height - this.size.ascent;
this.UpdateMetrics(PRS, this.size);
this.LineMetrics.UpdateMetrics(0, this.size);
}
else
{
......@@ -1942,6 +1950,7 @@ CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _C
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
......@@ -1949,18 +1958,25 @@ CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _C
if(CurPos == this.NumBreakContent)
{
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.LineMetrics.UpdateMetrics(CurLine, PRS.ContentMetrics);
}
else
{
if ( PRS.LineAscent < Item.size.ascent )
PRS.LineAscent = Item.size.ascent;
if ( PRS.LineDescent < Item.size.height - Item.size.ascent )
PRS.LineDescent = Item.size.height - Item.size.ascent;
this.UpdateMetrics(PRS, Item.size);
this.LineMetrics.UpdateMetrics(CurLine, Item.size);
}
}
}
};
CMathBase.prototype.UpdateMetrics = function(PRS, Size)
{
if(PRS.LineAscent < Size.ascent)
PRS.LineAscent = Size.ascent;
if(PRS.LineDescent < Size.height - Size.ascent)
PRS.LineDescent = Size.height - Size.ascent;
PRS.ContentMetrics.UpdateMetrics(Size);
};
CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
......@@ -1979,7 +1995,7 @@ CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange
var RangeW = PRSC.Range.W;
if(CurLine == 0 && CurRange == 0)
PRSC.Range.W += this.GapLeft;
PRSC.Range.W += this.BrGapLeft;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
......@@ -2001,10 +2017,11 @@ CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange
if(LinesCount - 1 == CurLine)
{
PRSC.Range.W += this.GapRight;
PRSC.Range.W += this.BrGapRight;
}
this.LinesWidths[CurLine] = PRSC.Range.W - RangeW;
//this.LinesWidths[CurLine] = PRSC.Range.W - RangeW;
this.LineMetrics.SetWidth(CurLine, PRSC.Range.W - RangeW);
}
};
CMathBase.prototype.Is_EmptyRange = function()
......@@ -2083,3 +2100,70 @@ CMathBasePr.prototype.Set_FromObject = function(Obj){};
CMathBasePr.prototype.Copy = function(){return new CMathBasePr();};
CMathBasePr.prototype.Write_ToBinary = function(Writer){};
CMathBasePr.prototype.Read_FromBinary = function(Reader){};
function CMathLineMetrics()
{
this.Metrics = [];
}
CMathLineMetrics.prototype.Reset = function()
{
this.Metrics.length = 0;
};
CMathLineMetrics.prototype.CheckLineMetric = function(Line)
{
if(this.Metrics.length <= Line)
{
this.Metrics[Line] = new CMathMetrics();
}
};
CMathLineMetrics.prototype.UpdateMetrics = function(Line, Metric)
{
this.CheckLineMetric(Line);
this.Metrics[Line].UpdateMetrics(Metric);
};
CMathLineMetrics.prototype.UpdateWidth = function(Line, Width)
{
this.CheckLineMetric(Line);
this.Metrics[Line].UpdateWidth(Width);
};
CMathLineMetrics.prototype.SetWidth = function(Line, Width)
{
this.CheckLineMetric(Line);
this.Metrics[Line].SetWidth(Width);
};
CMathLineMetrics.prototype.GetWidth = function(Line)
{
return this.Metrics[Line].width;
};
CMathLineMetrics.prototype.GetAscent = function(Line)
{
return this.Metrics[Line].ascent;
};
CMathLineMetrics.prototype.GetHeight = function(Line)
{
return this.Metrics[Line].height;
};
function CMathMetrics()
{
this.ascent = 0;
this.height = 0;
this.width = 0;
}
CMathMetrics.prototype.UpdateMetrics = function(Metric)
{
if(this.ascent < Metric.ascent)
this.ascent = Metric.ascent;
if(this.height < Metric.height)
this.height = Metric.height;
};
CMathMetrics.prototype.UpdateWidth = function(Width)
{
this.width += Width;
};
CMathMetrics.prototype.SetWidth = function(Width)
{
this.width = Width;
};
......@@ -678,6 +678,8 @@ function CMathContent()
this.InfoPoints = new CInfoPoints();
///////////////
this.LineMetrics = new CMathLineMetrics();
this.plhHide = false;
this.bRoot = false;
this.bOneLine = false;
......@@ -4135,6 +4137,35 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
};
CMathContent.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
{
this.LineMetrics.Reset();
}
var ParentContentMetric = PRS.ContentMetrics;
PRS.ContentMetrics = new CMathMetrics();
for(var Pos = StartPos; Pos <= EndPos; Pos++)
{
var Item = this.Content[Pos];
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
this.LineMetrics.UpdateMetrics(CurLine, PRS.ContentMetrics);
ParentContentMetric.UpdateMetrics(PRS.ContentMetrics);
PRS.ContentMetrics = ParentContentMetric;
};
CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchPos, Depth)
{
var CurLine = _CurLine - this.StartLine;
......@@ -4173,7 +4204,6 @@ CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchP
if ( true === Result )
SearchPos.Pos.Update(StartPos, Depth );
}
return Result;
......@@ -4220,6 +4250,24 @@ CMathContent.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos
return Result;
};
CMathContent.prototype.Math_Is_End = function(_CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var Len = this.Content.length;
var result = false;
if(EndPos == Len - 1)
{
result = this.Content[Len - 1].Math_Is_End(_CurLine, _CurRange);
}
return result;
};
CMathContent.prototype.IsFirstLine = function(Line)
{
var CurLine = Line - this.StartLine;
......
......@@ -32,7 +32,7 @@ CGlyphOperator.prototype.init = function(props)
this.turn = props.turn;
this.bStretch = (props.bStretch == true || props.bStretch == false) ? props.bStretch : true;
}
};
CGlyphOperator.prototype.fixSize = function(stretch)
{
var sizeGlyph = this.calcSize(stretch);
......@@ -67,7 +67,7 @@ CGlyphOperator.prototype.fixSize = function(stretch)
}
this.size = {width: width, height: height, ascent: ascent};
}
};
CGlyphOperator.prototype.draw_other = function() // с выравниванием к краю (относительно аргумента)
{
var coord = this.calcCoord(this.stretch);
......@@ -196,7 +196,7 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание
MathControl.pGraph.df();
MathControl.pGraph.SetIntegerGrid(intGrid);
}
};
CGlyphOperator.prototype.getCoordinateGlyph = function()
{
var coord = this.calcCoord(this.stretch);
......@@ -377,7 +377,7 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
}
return {XX: XX, YY: YY, Width: glW, Height: glH};
}
};
CGlyphOperator.prototype.draw = function(pGraphics, XX, YY, PDSE)
{
this.Parent.Make_ShdColor(PDSE);
......@@ -392,21 +392,21 @@ CGlyphOperator.prototype.draw = function(pGraphics, XX, YY, PDSE)
pGraphics.df();
pGraphics.SetIntegerGrid(intGrid);
}
};
CGlyphOperator.prototype.drawOnlyLines = function(x, y, pGraphics, PDSE)
{
this.Parent.Make_ShdColor(PDSE);
this.draw(x, y, pGraphics);
}
};
CGlyphOperator.prototype.getCtrPrp = function()
{
return this.Parent.Get_TxtPrControlLetter();
}
};
CGlyphOperator.prototype.PreRecalc = function(Parent)
{
this.Parent = Parent;
}
};
function COperatorBracket()
......@@ -451,7 +451,7 @@ COperatorBracket.prototype.calcSize = function( stretch )
}
return {width: widthBr, height: heightBr};
}
};
COperatorBracket.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -879,7 +879,7 @@ COperatorBracket.prototype.calcCoord = function(stretch)
H = YY[26]; // высота глифа
return {XX: XX, YY: YY, W: W, H: H};
}
};
COperatorBracket.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -940,7 +940,7 @@ COperatorBracket.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._c(XX[98], YY[98], XX[99], YY[99], XX[100], YY[100] );
pGraphics._c(XX[100], YY[100], XX[101], YY[101], XX[102], YY[102]);
pGraphics._c(XX[102], YY[102], XX[103], YY[103], XX[0], YY[0]);
}
};
function COperatorParenthesis()
......@@ -977,7 +977,7 @@ COperatorParenthesis.prototype.calcSize = function(stretch)
return {height: heightBr, width : widthBr};
}
};
COperatorParenthesis.prototype.calcCoord = function(stretch)
{
//cкобка перевернутая на 90 градусов
......@@ -1069,7 +1069,7 @@ COperatorParenthesis.prototype.calcCoord = function(stretch)
H = YY[4];
return {XX: XX, YY: YY, W: W, H: H };
}
};
COperatorParenthesis.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]); //mm
......@@ -1085,7 +1085,7 @@ COperatorParenthesis.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17]);
pGraphics._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19]);
pGraphics._l(XX[20], YY[20]);
}
};
// TODO
// установить минимальный размер стрелок
......@@ -1109,7 +1109,7 @@ COperatorAngleBracket.prototype.calcSize = function(stretch)
heightBr = 4.828645833333333*betta;
return {width : widthBr, height: heightBr};
}
};
COperatorAngleBracket.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1188,7 +1188,7 @@ COperatorAngleBracket.prototype.calcCoord = function(stretch)
H = YY[1];
return {XX: XX, YY: YY, W: W, H: H};
}
};
COperatorAngleBracket.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1199,7 +1199,7 @@ COperatorAngleBracket.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[5], YY[5]);
pGraphics._l(XX[6], YY[6]);
pGraphics._l(XX[7], YY[7]);
}
};
function CSquareBracket()
{
......@@ -1248,7 +1248,7 @@ CSquareBracket.prototype.calcCoord = function(stretch)
H = YY[1];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1260,7 +1260,7 @@ CSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[6], YY[6]);
pGraphics._l(XX[7], YY[7]);
pGraphics._l(XX[8], YY[8]);
}
};
CSquareBracket.prototype.calcSize = function()
{
var betta = this.getCtrPrp().FontSize/36;
......@@ -1270,7 +1270,7 @@ CSquareBracket.prototype.calcSize = function()
var width = 12.347222222222221*betta;
return {width: width, height: height};
}
};
function CHalfSquareBracket()
{
......@@ -1318,7 +1318,7 @@ CHalfSquareBracket.prototype.calcCoord = function(stretch)
H = YY[4];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CHalfSquareBracket.prototype.calcSize = function()
{
var betta = this.getCtrPrp().FontSize/36;
......@@ -1327,7 +1327,7 @@ CHalfSquareBracket.prototype.calcSize = function()
var width = 11.99444444444*betta;
return {width: width, height: height};
}
};
CHalfSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1337,7 +1337,7 @@ CHalfSquareBracket.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[4], YY[4]);
pGraphics._l(XX[5], YY[5]);
pGraphics._l(XX[6], YY[6]);
}
};
function COperatorLine()
......@@ -1353,7 +1353,7 @@ COperatorLine.prototype.calcSize = function()
var width = 11.99444444444*betta;
return {width: width, height: height};
}
};
COperatorLine.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1393,7 +1393,7 @@ COperatorLine.prototype.calcCoord = function(stretch)
return {XX: XX, YY: YY, W: W, H: H};
}
};
COperatorLine.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1401,7 +1401,7 @@ COperatorLine.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[2], YY[2]);
pGraphics._l(XX[3], YY[3]);
pGraphics._l(XX[4], YY[4]);
}
};
function CWhiteSquareBracket()
{
......@@ -1416,7 +1416,7 @@ CWhiteSquareBracket.prototype.calcSize = function()
var width = 11.99444444444*betta;
return {width: width, height: height};
}
};
CWhiteSquareBracket.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1479,7 +1479,7 @@ CWhiteSquareBracket.prototype.calcCoord = function(stretch)
H = YY[3];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CWhiteSquareBracket.prototype.drawPath = function(pGraphics, XX, YY, PDSE)
{
......@@ -1502,7 +1502,7 @@ CWhiteSquareBracket.prototype.drawPath = function(pGraphics, XX, YY, PDSE)
pGraphics._l(XX[11], YY[11]);
pGraphics._l(XX[12], YY[12]);
pGraphics._l(XX[13], YY[13]);
}
};
function COperatorDoubleLine()
{
......@@ -1517,7 +1517,7 @@ COperatorDoubleLine.prototype.calcSize = function()
width = 11.99444444444*betta;
return {width: width, height: height};
}
};
COperatorDoubleLine.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1562,7 +1562,7 @@ COperatorDoubleLine.prototype.calcCoord = function(stretch)
H = YY[7];
return {XX: XX, YY: YY, W: W, H: H};
}
};
COperatorDoubleLine.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1578,7 +1578,7 @@ COperatorDoubleLine.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[7], YY[7]);
pGraphics._l(XX[8], YY[8]);
pGraphics._l(XX[9], YY[9]);
}
};
function CSingleArrow()
......@@ -1593,7 +1593,7 @@ CSingleArrow.prototype.calcSize = function()
var width = 10.641210937499999*betta;
return {width: width, height: height};
}
};
CSingleArrow.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1637,7 +1637,7 @@ CSingleArrow.prototype.calcCoord = function(stretch)
H = YY[6];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CSingleArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1651,7 +1651,7 @@ CSingleArrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[8], YY[8]);
pGraphics._l(XX[9], YY[9]);
pGraphics._l(XX[10], YY[10]);
}
};
function CLeftRightArrow()
{
......@@ -1666,7 +1666,7 @@ CLeftRightArrow.prototype.calcSize = function()
var width = 11.695410156249999*betta;
return {width: width, height: height};
}
};
CLeftRightArrow.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1715,7 +1715,7 @@ CLeftRightArrow.prototype.calcCoord = function(stretch)
H = YY[1];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CLeftRightArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1736,7 +1736,7 @@ CLeftRightArrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[15], YY[15]);
pGraphics._l(XX[16], YY[16]);
}
};
function CDoubleArrow()
{
......@@ -1751,7 +1751,7 @@ CDoubleArrow.prototype.calcSize = function()
var width = 10.994677734375*betta;
return {width: width, height: height};
}
};
CDoubleArrow.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1807,7 +1807,7 @@ CDoubleArrow.prototype.calcCoord = function(stretch)
H = YY[2];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CDoubleArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1831,7 +1831,7 @@ CDoubleArrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._s();
pGraphics._m(XX[16], YY[16]);
pGraphics._l(XX[17], YY[17]);
}
};
function CLR_DoubleArrow()
......@@ -1847,7 +1847,7 @@ CLR_DoubleArrow.prototype.calcSize = function()
var width = 13.146484375*betta;
return {width: width, height: height};
}
};
CLR_DoubleArrow.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -1906,7 +1906,7 @@ CLR_DoubleArrow.prototype.calcCoord = function(stretch)
H = YY[11];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CLR_DoubleArrow.prototype.drawPath = function(pGraphics, XX, YY, PDSE)
{
pGraphics._m(XX[0], YY[0]);
......@@ -1940,7 +1940,7 @@ CLR_DoubleArrow.prototype.drawPath = function(pGraphics, XX, YY, PDSE)
pGraphics._l(XX[21], YY[21]);
pGraphics._l(XX[22], YY[22]);
pGraphics._l(XX[23], YY[23]);
}
};
function CCombiningArrow()
......@@ -1956,7 +1956,7 @@ CCombiningArrow.prototype.calcSize = function()
var width = 4.938*betta;
return {width: width, height: height};
}
};
CCombiningArrow.prototype.calcCoord = function(stretch)
{
// px mm
......@@ -1997,7 +1997,7 @@ CCombiningArrow.prototype.calcCoord = function(stretch)
H = YY[8];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CCombiningArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -2011,7 +2011,7 @@ CCombiningArrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[8], YY[8]);
pGraphics._l(XX[9], YY[9]);
pGraphics._l(XX[10], YY[10]);
}
};
function CCombiningHalfArrow()
{
......@@ -2028,7 +2028,7 @@ CCombiningHalfArrow.prototype.calcSize = function()
var width = 4.938*betta;
return {width: width, height: height};
}
};
CCombiningHalfArrow.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -2039,7 +2039,7 @@ CCombiningHalfArrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[5], YY[5]);
pGraphics._l(XX[6], YY[6]);
pGraphics._l(XX[7], YY[7]);
}
};
CCombiningHalfArrow.prototype.calcCoord = function(stretch)
{
// px mm
......@@ -2077,7 +2077,7 @@ CCombiningHalfArrow.prototype.calcCoord = function(stretch)
H = YY[5];
return {XX: XX, YY: YY, W: W, H: H};
}
};
function CCombining_LR_Arrow()
{
......@@ -2092,7 +2092,7 @@ CCombining_LR_Arrow.prototype.calcSize = function()
var width = 4.938*betta;
return {width: width, height: height};
}
};
CCombining_LR_Arrow.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -2113,7 +2113,7 @@ CCombining_LR_Arrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[15], YY[15]);
pGraphics._l(XX[16], YY[16]);
}
};
CCombining_LR_Arrow.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -2161,7 +2161,7 @@ CCombining_LR_Arrow.prototype.calcCoord = function(stretch)
return {XX: XX, YY: YY, W: W, H: H};
}
};
function COperator(type)
......@@ -2176,7 +2176,8 @@ function COperator(type)
this.defaultType = null;
this.grow = true;
this.Positions = [];
this.pos = new CMathPosition();
this.coordGlyph = null;
this.size = new CMathSize();
......@@ -2895,7 +2896,7 @@ COperator.prototype.mergeProperties = function(properties, defaultProps) // pr
this.operator = operator;
this.code = codeChr;
this.typeOper = typeOper;
}
};
COperator.prototype.getProps = function(props, defaultProps)
{
var location = props.loc,
......@@ -2928,46 +2929,64 @@ COperator.prototype.getProps = function(props, defaultProps)
location = defaultProps.loc;
return {loc: location, type: type, code: code};
}
};
COperator.prototype.draw = function(x, y, pGraphics, PDSE)
{
var XX = this.pos.x + x,
YY = this.pos.y + y;
if(this.typeOper === OPERATOR_TEXT)
{
// выставляем font, если нужно отрисовать текст
//pGraphics.b_color1(0,0,0,255);
this.Make_ShdColor(PDSE);
var ctrPrp = this.Get_TxtPrControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false
};
pGraphics.SetFont(Font);
////////////////////////////////////////////////
this.operator.Draw(x, y, pGraphics, PDSE);
this.drawText(XX, YY, pGraphics, PDSE);
}
else if(this.IsLineGlyph())
{
this.drawLines(XX, YY, pGraphics, PDSE);
}
else
{
if(this.IsLineGlyph())
this.drawLines(x, y, pGraphics, PDSE);
else if(this.type === OPER_SEPARATOR)
this.drawSeparator(x, y, pGraphics, PDSE);
else
this.drawOperator(x, y, pGraphics, PDSE);
this.drawOperator(XX, YY, pGraphics, PDSE);
}
}
};
COperator.prototype.setPosition = function(_pos)
{
this.pos.x = _pos.x;
this.pos.y = _pos.y;
if(this.typeOper === OPERATOR_TEXT)
{
var pos = new CMathPosition();
pos.x = 0;
pos.y = 0;
this.operator.setPosition(pos);
}
};
COperator.prototype.Make_ShdColor = function(PDSE)
{
return this.Parent.Make_ShdColor(PDSE, this.Parent.Get_CompiledCtrPrp());
}
};
COperator.prototype.drawText = function(absX, absY, pGraphics, PDSE)
{
this.Make_ShdColor(PDSE);
var ctrPrp = this.Get_TxtPrControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false
};
pGraphics.SetFont(Font);
////////////////////////////////////////////////
this.operator.Draw(absX, absY, pGraphics, PDSE);
};
COperator.prototype.drawOperator = function(absX, absY, pGraphics, PDSE)
{
if(this.typeOper !== OPERATOR_EMPTY)
......@@ -2977,52 +2996,26 @@ COperator.prototype.drawOperator = function(absX, absY, pGraphics, PDSE)
var X = [],
Y = [];
var PosOper = this.Positions[0];
for(var j = 0; j < lng; j++)
{
X.push(PosOper.x + absX + this.coordGlyph.XX[j]);
Y.push(PosOper.y + absY + this.coordGlyph.YY[j]);
X.push(absX + this.coordGlyph.XX[j]);
Y.push(absY + this.coordGlyph.YY[j]);
}
this.operator.draw(pGraphics, X, Y, PDSE);
}
}
COperator.prototype.drawSeparator = function(absX, absY, pGraphics, PDSE)
{
if(this.typeOper !== OPERATOR_EMPTY)
{
var lng = this.coordGlyph.XX.length;
for(var i = 0; i < this.Positions.length; i++)
{
var X = [],
Y = [];
var PosOper = this.Positions[i];
for(var j = 0; j < lng; j++)
{
X.push(PosOper.x + absX + this.coordGlyph.XX[j]);
Y.push(PosOper.y + absY + this.coordGlyph.YY[j]);
}
this.operator.draw(pGraphics, X, Y, PDSE);
}
}
}
};
COperator.prototype.drawLines = function(absX, absY, pGraphics, PDSE)
{
if(this.typeOper !== OPERATOR_EMPTY)
{
var PosOper = this.Positions[0];
this.operator.drawOnlyLines(PosOper.x + absX, PosOper.y + absY, pGraphics, PDSE);
this.operator.drawOnlyLines(absX, absY, pGraphics, PDSE);
}
}
};
COperator.prototype.IsLineGlyph = function()
{
return this.typeOper == ACCENT_LINE || this.typeOper == ACCENT_DOUBLE_LINE;
}
};
COperator.prototype.fixSize = function(oMeasure, stretch)
{
if(this.typeOper !== OPERATOR_EMPTY)
......@@ -3115,60 +3108,11 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
this.size.height = height;
this.size.ascent = ascent;
}
}
COperator.prototype.setPosition = function(Positions)
{
// для оператора, это будет просто позиция
// для сепаратора - массив позиций
if(this.type == OPER_SEPARATOR)
this.Positions = Positions;
else
{
this.Positions.length = 0;
this.Positions[0] = Positions;
}
if(this.typeOper == OPERATOR_TEXT)
{
var NewPos = new CMathPosition();
NewPos.x = this.Positions[0].x;
NewPos.y = this.Positions[0].y;
this.operator.setPosition(NewPos);
}
}
COperator.prototype._setPosition = function(Positions)
{
// для оператора, это будет просто позиция
// для сепаратора - массив позиций
if(this.type == OPER_SEPARATOR)
this.Positions = Positions;
else
{
this.Positions.length = 0;
this.Positions[0] = Positions;
}
if(this.typeOper == OPERATOR_TEXT)
{
var NewPos = new CMathPosition();
NewPos.x = this.Positions[0].x;
if(this.type == OPER_ACCENT)
NewPos.y = this.Positions[0].y + this.operator.size.height;
else
NewPos.y = this.Positions[0].y;
this.operator.setPosition(NewPos);
}
}
};
COperator.prototype.IsJustDraw = function()
{
return true;
}
};
COperator.prototype.Resize = function(oMeasure)
{
if(this.typeOper !== OPERATOR_EMPTY)
......@@ -3180,18 +3124,18 @@ COperator.prototype.Resize = function(oMeasure)
else
this.fixSize(oMeasure, this.size.height);
}
}
};
COperator.prototype.PreRecalc = function(Parent, ParaMath)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.typeOper !== OPERATOR_EMPTY)
this.operator.PreRecalc(this); // в данном случае mathText нужен только один параметр
}
};
COperator.prototype.Get_TxtPrControlLetter = function()
{
return this.Parent.Get_TxtPrControlLetter();
}
};
COperator.prototype.getChr = function()
{
var chr = null; //если operator не определен, то this.code = null
......@@ -3202,7 +3146,7 @@ COperator.prototype.getChr = function()
chr = "";
return chr;
}
};
COperator.prototype.IsArrow = function()
{
//return this.operator.IsArrow();
......@@ -3212,7 +3156,7 @@ COperator.prototype.IsArrow = function()
bAccentArrow = his.typeOper == ACCENT_ARROW_LEFT || this.typeOper == ACCENT_ARROW_RIGHT || this.typeOper == ACCENT_ARROW_LR || this.typeOper == ACCENT_HALF_ARROW_LEFT || this.typeOper == ACCENT_HALF_ARROW_RIGHT;
return bArrow || bDoubleArrow;
}
};
function CMathDelimiterPr()
{
......@@ -3389,6 +3333,8 @@ function CDelimiter(props)
this.Id = g_oIdCounter.Get_NewId();
this.MaxMetrics = new CMathSize();
this.begOper = new COperator (OPER_DELIMITER);
this.endOper = new COperator (OPER_DELIMITER);
this.sepOper = new COperator (OPER_SEPARATOR);
......@@ -3413,7 +3359,7 @@ CDelimiter.prototype.init = function(props)
this.Fill_LogicalContent(this.getColumnsCount());
this.fillContent();
}
};
CDelimiter.prototype.getColumnsCount = function()
{
return this.Pr.column;
......@@ -3426,7 +3372,7 @@ CDelimiter.prototype.fillContent = function()
for (var nIndex = 0; nIndex < nColumnsCount; nIndex++)
this.elements[0][nIndex] = this.Content[nIndex];
}
};
CDelimiter.prototype.ApplyProperties = function(RPI)
{
if(this.RecalcInfo.bProps == true)
......@@ -3480,7 +3426,7 @@ CDelimiter.prototype.ApplyProperties = function(RPI)
this.RecalcInfo.bProps = false;
}
}
};
CDelimiter.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
......@@ -3490,7 +3436,158 @@ CDelimiter.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsIn
this.sepOper.PreRecalc(this, ParaMath);
CDelimiter.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
}
};
CDelimiter.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
this.bOneLine = PRS.bMath_OneLine == true || this.Content.length > 1; // this.Content.length > 1 - несколько контентов, разделлные сепараторами
if(this.bOneLine == false)
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
this.protected_AddRange(CurLine, CurRange);
this.NumBreakContent = 0;
var Content = this.Content[0];
if(CurLine == 0 && CurRange == 0)
{
PRS.bMath_OneLine = true;
Content.Recalculate_Range(PRS, ParaPr, Depth + 1);
this.UpdateMetricsDelimiters(g_oTextMeasurer, Content.size.height, Content.size.ascent);
Content.Recalculate_Reset(PRS.Range, PRS.Line);
PRS.WordLen += this.BrGapLeft;
}
PRS.bMath_OneLine = false;
PRS.Update_CurPos(0, Depth);
Content.Recalculate_Range(PRS, ParaPr, Depth + 1);
if(PRS.NewRange == false)
{
PRS.WordLen += this.BrGapRight;
}
this.protected_FillRange(CurLine, CurRange, 0, 0);
PRS.bMath_OneLine = false;
}
else
{
PRS.bMath_OneLine = true;
this.NumBreakContent = -1;
CDelimiter.superclass.Recalculate_Range.call(this, PRS, ParaPr, Depth);
}
this.BrGapLeft = this.GapLeft + this.begOper.size.width;
this.BrGapRight = this.GapRight + this.endOper.size.width;
};
CDelimiter.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
if(CurLine == 0 && CurRange == 0)
{
if(PRS.LineAscent < this.begOper.size.ascent)
PRS.LineAscent = this.begOper.size.ascent;
if ( PRS.LineDescent < this.begOper.size.height - this.begOper.size.ascent )
PRS.LineDescent = this.begOper.size.height - this.begOper.size.ascent;
}
var bEnd = this.Content[0].Math_Is_End(_CurLine, _CurRange);
if(bEnd)
{
if(PRS.LineAscent < this.endOper.size.ascent)
PRS.LineAscent = this.endOper.size.ascent;
if ( PRS.LineDescent < this.endOper.size.height - this.endOper.size.ascent )
PRS.LineDescent = this.endOper.size.height - this.endOper.size.ascent;
}
CDelimiter.superclass.Recalculate_LineMetrics.call(this, PRS, ParaPr, _CurLine, _CurRange);
};
CDelimiter.prototype.UpdateMetricsDelimiters = function(oMeasure, height, ascent)
{
var descent = height - ascent;
var mgCtrPrp = this.Get_TxtPrControlLetter();
var ShCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var maxAD = ascent - ShCenter > descent + ShCenter ? ascent - ShCenter: descent + ShCenter;
var plH = this.ParaMath.GetPlh(oMeasure, mgCtrPrp);
this.TextInContent = ascent < 1.01*plH && descent < 0.4*plH; // для текста операторы в случае центрирования не увеличиваем
var bCentered = this.Pr.shp == DELIMITER_SHAPE_CENTERED,
b2Max = bCentered && (2*maxAD - height > 0.001);
var heightStretch = b2Max && !this.TextInContent ? 2*maxAD : height;
this.begOper.fixSize(oMeasure, heightStretch);
this.endOper.fixSize(oMeasure, heightStretch);
this.sepOper.fixSize(oMeasure, heightStretch);
var HeigthMaxOper = Math.max(this.begOper.size.height, this.endOper.size.height, this.sepOper.size.height);
var AscentMaxOper = HeigthMaxOper/2 + ShCenter;
g_oTextMeasurer.SetFont(mgCtrPrp);
var Height = g_oTextMeasurer.GetHeight();
if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
{
var deltaHeight = height - HeigthMaxOper;
if(deltaHeight < 0)
deltaHeight = -deltaHeight;
/*var deltaMaxAD = maxAD - HeigthMaxOper/2;
if(deltaMaxAD < 0)
deltaMaxAD = -deltaMaxAD;
var deltaMinAD = (height - maxAD) - HeigthMaxOper/2;*/
var bEqualOper = deltaHeight < 0.001,
bLText = height < Height;
var DimHeight, DimAscent;
if(bEqualOper)
{
DimHeight = 2*maxAD;
DimAscent = maxAD + ShCenter;
}
else if(bLText)
{
DimAscent = ascent > AscentMaxOper ? ascent : AscentMaxOper;
DimHeight = HeigthMaxOper;
}
else // для случаев когда скобку можно расстянуть не по всей высоте (угловые скобки, аскент >> дескента)
{
DimHeight = HeigthMaxOper/2 + maxAD;
DimAscent = ascent > AscentMaxOper? ascent : AscentMaxOper;
}
}
else
{
if(height < Height)
{
DimAscent = ascent > AscentMaxOper ? ascent : AscentMaxOper;
DimHeight = HeigthMaxOper;
}
else
{
DimAscent = ascent;
DimHeight = height;
}
}
this.MaxMetrics.ascent = DimAscent;
this.MaxMetrics.height = DimHeight;
};
CDelimiter.prototype.Resize = function(oMeasure, RPI)
{
// размеры аргумента
......@@ -3611,15 +3708,13 @@ CDelimiter.prototype.Resize = function(oMeasure, RPI)
this.size.width = width;
this.size.height = height;
this.size.ascent = ascent;
}
};
CDelimiter.prototype.recalculateSize = function(oMeasure)
{
// размеры аргумента
var heightG = 0, widthG = 0,
var widthG = 0,
ascentG = 0, descentG = 0;
// Аргумент
for(var j = 0; j < this.nCol; j++)
{
var content = this.elements[0][j].size;
......@@ -3628,106 +3723,17 @@ CDelimiter.prototype.recalculateSize = function(oMeasure)
descentG = content.height - content.ascent > descentG ? content.height - content.ascent: descentG;
}
heightG = ascentG + descentG;
var mgCtrPrp = this.Get_TxtPrControlLetter();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var maxAD = ascentG - shCenter > descentG + shCenter ? ascentG - shCenter: descentG + shCenter;
var plH = this.ParaMath.GetPlh(oMeasure, mgCtrPrp);
//var plH = 10.8 * mgCtrPrp.FontSize/36;
//var bTextContent = ascentG < plH || descentG < plH ; // для текста операторы в случае центрирования не увеличиваем
var bTextContent = ascentG < 1.01*plH && (heightG - ascentG) < 0.4*plH; // для текста операторы в случае центрирования не увеличиваем
var bCentered = this.Pr.shp == DELIMITER_SHAPE_CENTERED,
b2Max = bCentered && (2*maxAD - heightG > 0.001);
this.TextInContent = bTextContent;
var heightStretch = b2Max && !bTextContent ? 2*maxAD : ascentG + descentG;
this.begOper.fixSize(oMeasure, heightStretch);
this.endOper.fixSize(oMeasure, heightStretch);
this.sepOper.fixSize(oMeasure, heightStretch);
this.UpdateMetricsDelimiters(oMeasure, ascentG + descentG, ascentG);
// Общая ширина
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;
if(this.begOper.size.height > this.endOper.size.height && this.begOper.size.height > this.sepOper.size.height)
maxDimOper = this.begOper.size;
else if(this.endOper.size.height > this.sepOper.size.height)
maxDimOper = this.endOper.size;
else
maxDimOper = this.sepOper.size;
// Общие высота и ascent
var height, ascent, descent;
if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
{
var deltaHeight = heightG - maxDimOper.height;
if(deltaHeight < 0)
deltaHeight = -deltaHeight;
var deltaMaxAD = maxAD - maxDimOper.height/ 2;
if(deltaMaxAD < 0)
deltaMaxAD = -deltaMaxAD;
var deltaMinAD = (heightG - maxAD) - maxDimOper.height/2;
var bLHeight = deltaHeight < 0.001,
bLMaxAD = deltaMaxAD > 0.001,
bLMinAD = deltaMinAD > 0.001,
bLText = deltaMinAD < - 0.001;
this.size.ascent = this.MaxMetrics.ascent;
this.size.height = this.MaxMetrics.height;
var bEqualOper = bLHeight,
bMiddleOper = bLMaxAD && !bLMinAD,
bLittleOper = bLMinAD,
bText = bLText;
if(bEqualOper)
{
height = 2*maxAD;
ascent = maxAD + shCenter;
}
else if(bText)
{
//ascent = maxDimOper.ascent;
ascent = ascentG > maxDimOper.ascent ? ascentG : maxDimOper.ascent;
height = maxDimOper.height;
}
else if(bMiddleOper)
{
height = maxDimOper.height/2 + maxAD;
ascent = ascentG > maxDimOper.ascent? ascentG : maxDimOper.ascent;
}
else
{
ascent = ascentG;
height = ascentG + descentG;
}
}
else
{
g_oTextMeasurer.SetFont(mgCtrPrp);
var Height = g_oTextMeasurer.GetHeight();
if(heightG < Height)
{
ascent = ascentG > maxDimOper.ascent ? ascentG : maxDimOper.ascent;
height = maxDimOper.height;
}
else
{
ascent = ascentG;
height = ascentG + descentG;
}
}
this.size = {width: width, height: height, ascent: ascent};
this.size.width = width;
};
CDelimiter.prototype.alignOperator = function(operator) // в качестве аргумента передаем высоту оператора
{
......@@ -3742,7 +3748,7 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве
{
if(this.Pr.shp == DELIMITER_SHAPE_CENTERED)
{
align = this.size.ascent > dimOper.ascent ? this.size.ascent - dimOper.ascent : 0;
align = this.MaxMetrics.ascent > dimOper.ascent ? this.MaxMetrics.ascent - dimOper.ascent : 0;
}
else if(this.Pr.shp === DELIMITER_SHAPE_MATH)
......@@ -3750,89 +3756,147 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве
var shCenter = dimOper.ascent - dimOper.height/2; // так получаем shCenter, иначе соотношение м/ду ascent и descent будет неверное
var k = 2*(this.size.ascent - shCenter)/this.size.height ;
var k = 2*(this.MaxMetrics.ascent - shCenter)/this.size.height ;
// k/(k + 1)
// 0.2/(0.2 + 1) = 1/6
k = k > 1/4 ? k : 1/4;
align = this.size.ascent - shCenter - k*(dimOper.ascent - shCenter);
align = this.MaxMetrics.ascent - shCenter - k*(dimOper.ascent - shCenter);
}
}
return align;
}
CDelimiter.prototype.setPosition = function(position, Line, Range)
};
CDelimiter.prototype.setPosition = function(pos, Line, Range)
{
this.pos.x = position.x;
this.pos.y = position.y - this.size.ascent;
if(this.bOneLine == false)
{
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
var x = this.pos.x + this.GapLeft,
y = this.pos.y;
var LinesCount = this.protected_GetLinesCount();
var PosOper = new CMathPosition();
var PosBegOper = new CMathPosition();
PosBegOper.x = x;
PosBegOper.y = y + this.alignOperator(this.begOper);
if(CurLine == 0 && CurRange == 0)
{
PosOper.x = pos.x;
PosOper.y = pos.y - this.begOper.size.ascent;
this.UpdatePosOperBeg(pos);
}
this.begOper.setPosition(PosBegOper);
x += this.begOper.size.width;
this.Content[0].setPosition(pos, Line, Range);
var content = this.elements[0][0];
if(LinesCount - 1 == CurLine)
{
PosOper.x = pos.x;
PosOper.y = pos.y - this.endOper.size.ascent;
var PosContent = new CMathPosition();
PosContent.x = x;
PosContent.y = y + this.align_2(content) + content.size.ascent;
x += content.size.width;
this.UpdatePosOperEnd(pos);
}
content.setPosition(PosContent, Line, Range); // CMathContent
}
else
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
var Positions = [];
var CurrPos = new CMathPosition();
CurrPos.x = pos.x;
CurrPos.y = pos.y;
this.UpdatePosOperBeg(CurrPos);
this.Content[0].setPosition(CurrPos, Line, Range); // CMathContent
for(var j = 1 ; j < this.nCol; j++)
{
var PosSep = new CMathPosition();
PosSep.x = x;
PosSep.y = y + this.alignOperator(this.sepOper);
PosSep.x = CurrPos.x;
PosSep.y = CurrPos.y + this.alignOperator(this.sepOper) - this.sepOper.size.ascent;
Positions.push(PosSep);
x += this.sepOper.size.width;
this.sepOper.setPosition(PosSep);
for(var j = 1 ; j < this.nCol; j++)
{
CurrPos.x += this.sepOper.size.width;
content = this.elements[0][j];
this.Content[j].setPosition(CurrPos, Line, Range);
pos.x += this.Content[j].size.width;
}
var NewPosContent = new CMathPosition();
NewPosContent.x = x;
NewPosContent.y = y + this.align_2(content) + content.size.ascent;
this.UpdatePosOperEnd(CurrPos);
content.setPosition(NewPosContent, Line, Range);
x += content.size.width;
pos.x = CurrPos.x;
}
};
CDelimiter.prototype.Draw_Elements = function(PDSE)
{
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
this.sepOper.setPosition(Positions);
if(this.bOneLine == false)
{
var CurLine = PDSE.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range );
var PosEndOper = new CMathPosition();
PosEndOper.x = x;
PosEndOper.y = y + this.alignOperator(this.endOper);
if(CurLine == 0 && CurRange == 0)
{
this.begOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
PDSE.X += this.BrGapLeft;
}
this.endOper.setPosition(PosEndOper);
this.Content[0].Draw_Elements(PDSE);
position.x += this.size.width;
}
CDelimiter.prototype.Draw_Elements = function(PDSE)
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
{
this.endOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
PDSE.X += this.BrGapRight;
}
}
else
{
this.begOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
PDSE.X += this.BrGapLeft;
this.Content[0].Draw_Elements(PDSE);
var X = PosLine.x;
for(var j = 1; j < this.nCol; j++)
{
this.sepOper.draw(X, PosLine.y, PDSE.Graphics, PDSE);
PDSE.X += this.sepOper.size.width;
this.Content[j].Draw_Elements(PDSE);
X += this.sepOper.size.width + this.Content[j].size.width;
}
this.endOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
PDSE.X += this.BrGapRight;
}
};
CDelimiter.prototype.UpdatePosOperBeg = function(pos)
{
var X = PDSE.X;
var PosBegOper = new CMathPosition();
PosBegOper.x = pos.x + this.GapLeft;
PosBegOper.y = pos.y + this.alignOperator(this.begOper) - this.begOper.size.ascent;
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
this.begOper.setPosition(PosBegOper);
this.begOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
this.sepOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
this.endOper.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
pos.x += this.BrGapLeft; // BrGapLeft = GapLeft + size of beginning Operator
};
CDelimiter.prototype.UpdatePosOperEnd = function(pos)
{
var PosEndOper = new CMathPosition();
PosEndOper.x = pos.x;
PosEndOper.y = pos.y + this.alignOperator(this.endOper) - this.endOper.size.ascent;
for(var j = 0; j < this.nCol; j++)
this.elements[0][j].Draw_Elements(PDSE);
this.endOper.setPosition(PosEndOper);
PDSE.X = X + this.size.width;
}
pos.x += this.BrGapRight; // BrGapRight = GapRight + size of ending Operator
};
CDelimiter.prototype.align_2 = function(element)
{
var align = 0;
......@@ -3841,16 +3905,15 @@ CDelimiter.prototype.align_2 = function(element)
else
align = (this.size.height - element.size.height)/2;
return align;
}
};
CDelimiter.prototype.getBase = function(numb)
{
if(numb !== numb - 0)
numb = 0;
return this.elements[0][numb];
}
};
CDelimiter.prototype.getElementMathContent = function(Index)
{
return this.Content[Index];
......@@ -3905,7 +3968,7 @@ Asc.extendClass(CCharacter, CMathBase);
CCharacter.prototype.setCharacter = function(props, defaultProps)
{
this.operator.mergeProperties(props, defaultProps);
}
};
CCharacter.prototype.recalculateSize = function(oMeasure)
{
var Base = this.Content[0];
......@@ -3919,7 +3982,7 @@ CCharacter.prototype.recalculateSize = function(oMeasure)
width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent};
}
};
CCharacter.prototype.setPosition = function(pos, Line, Range)
{
this.pos.x = pos.x;
......@@ -3961,7 +4024,7 @@ CCharacter.prototype.setPosition = function(pos, Line, Range)
}
pos.x += this.size.width;
}
};
CCharacter.prototype.Draw_Elements = function(PDSE)
{
var X = PDSE.X;
......@@ -3986,11 +4049,11 @@ CCharacter.prototype.Draw_Elements = function(PDSE)
this.operator.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
PDSE.X = X + this.size.width;
}
};
CCharacter.prototype.getBase = function()
{
return this.elements[0][0];
}
};
function CMathGroupChrPr()
{
......@@ -3999,7 +4062,6 @@ function CMathGroupChrPr()
this.vertJc = VJUST_TOP;
this.pos = LOCATION_BOT;
}
CMathGroupChrPr.prototype.Set_FromObject = function(Obj)
{
this.chr = Obj.chr;
......@@ -4098,17 +4160,15 @@ function CGroupCharacter(props)
g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CGroupCharacter, CCharacter);
CGroupCharacter.prototype.ClassType = historyitem_type_groupChr;
CGroupCharacter.prototype.kind = MATH_GROUP_CHARACTER;
CGroupCharacter.prototype.init = function(props)
{
this.Fill_LogicalContent(1);
this.setProperties(props);
this.fillContent();
}
};
CGroupCharacter.prototype.ApplyProperties = function(RPI)
{
if(this.RecalcInfo.bProps == true)
......@@ -4145,7 +4205,7 @@ CGroupCharacter.prototype.ApplyProperties = function(RPI)
this.elements[0][0] = this.getBase();
}
}
};
CGroupCharacter.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
......@@ -4158,16 +4218,16 @@ CGroupCharacter.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, G
ArgSz.decrease();
CGroupCharacter.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSz, RPI, GapsInfo);
}
};
CGroupCharacter.prototype.getBase = function()
{
return this.Content[0];
}
};
CGroupCharacter.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.elements[0][0] = this.getBase();
}
};
CGroupCharacter.prototype.getAscent = function(oMeasure)
{
var ascent;
......@@ -4190,7 +4250,7 @@ CGroupCharacter.prototype.getAscent = function(oMeasure)
return ascent;
}
};
CGroupCharacter.prototype.Document_UpdateInterfaceState = function(MathProps)
{
MathProps.Type = c_oAscMathInterfaceType.GroupChar;
......
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