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

1. Поправила gaps для delimiters

2. Убрала LinesPositions, LinesWidths из ParaMath
3. Реализовала Bounds для контенов и мат объектов
4. Реализоавала рамку и подсветку дл многострочных формул
5. Поправила баг для delimiters : неправильно операторы выравнивались в случае текстовых элементов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61744 954022d7-b5bf-4e40-9824-e11837661b57
parent eab59fee
......@@ -217,8 +217,7 @@ function ParaMath()
this.Y = 0;
this.FirstPage = -1;
this.LinesWidths = []; // в тч для отрисовки рамки
this.LinesPositions = [];
//this.Bounds = [];
this.CurPageInfo =
{
......@@ -449,12 +448,22 @@ ParaMath.prototype.Get_AlignToLine = function(_CurLine, _CurRange, Page, _X, _XL
_XLimit -= MathSettings.Get_RightMargin(this.State);
var Jc = this.Get_Align();
var FirstWidth = CurrentPage == 0 ? this.LinesWidths[0] : 0; // если страница не первая, то ширину первой строки формулы не учитываем
var WidthFirstLine = 0;
var LineCount = this.Root.protected_GetLinesCount();
if(LineCount > 0)
WidthFirstLine = this.Root.GetWidth(_CurLine);
/*if(this.Bounds.length > 0)
WidthFirstLine = this.Bounds[0].W;*/
var FirstWidth = CurrentPage == 0 ? WidthFirstLine : 0; // если страница не первая, то ширину первой строки формулы не учитываем
var W = 0;
var MaxW = this.CurPageInfo.MaxLineW;
var LineCount = this.Root.protected_GetLinesCount();
if(LineCount == 1) // чтобы не сравнивать с wrapIndent, когда формула занимает одну строку
W = FirstWidth;
......@@ -856,7 +865,6 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.FirstPage = Page;
this.CurPageInfo.Page = -1;
this.LinesWidths.length = 0;
}
// пока будем каждый раз обновлять информацию (т.к. когда не inline формула становиться inline может получиться так, что пересчет для первой строки не придет)
......@@ -887,7 +895,6 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
PRS.X += MathSettings.Get_LeftMargin(this.State);
PRS.XEnd -= MathSettings.Get_RightMargin(this.State);
if(bFirstLine == false)
PRS.X += MathSettings.Get_WrapIndent(this.State);
......@@ -943,12 +950,7 @@ ParaMath.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
PRSC.Range.W += PRSC.SpaceLen - SpaceLen;
PRSC.Range.SpaceLen = SpaceLen;
var W = PRSC.Range.W;
PRSC.Words++;
var CurLine = _CurLine - this.Root.StartLine;
this.LinesWidths[CurLine] = W;
};
ParaMath.prototype.UpdateWidthLine = function(PRS, Width)
{
......@@ -970,42 +972,12 @@ ParaMath.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange
var CurLine = _CurLine - this.Root.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.Root.StartRange : _CurRange );
var Pos = new CMathPosition();
Pos.x = PRSA.X;
Pos.y = PRSA.Y;
this.LinesPositions[CurLine] = Pos;
// до пересчета Bounds для текущей строки ранее должны быть вызваны Recalculate_Range_Width (для ширины), Recalculate_LineMetrics(для высоты и аскента)
var pos = new CMathPosition();
this.Root.setPosition(pos, _CurLine, _CurRange);
this.Root.setPosition(pos, PRSA, _CurLine, _CurRange, _CurPage);
this.Root.Recalculate_Range_Spaces(PRSA, _CurLine, _CurRange, _CurPage);
/*
// Позиция в документе для формулы
//this.Math.absPos = {x: PRSA.X, y: PRSA.Y - this.Root.size.ascent};
this.X = PRSA.X;
this.Y = PRSA.Y - this.Root.size.ascent;
*/
/*var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if (EndPos >= 1)
{
if ( 0 !== PRSA.LettersSkip )
{
this.WidthVisible = this.Width;
PRSA.LettersSkip--;
}
else
this.WidthVisible = this.Width + PRSA.JustifyWord;
PRSA.X += this.WidthVisible;
PRSA.LastW = this.WidthVisible;
}*/
};
ParaMath.prototype.Recalculate_PageEndInfo = function(PRSI, _CurLine, _CurRange)
{
......@@ -1530,14 +1502,22 @@ ParaMath.prototype.Draw_Elements = function(PDSE)
this.Root.Draw_Elements(PDSE);
/*PDSE.Graphics.p_color(255,0,0, 255);
PDSE.Graphics.drawHorLine(0, PDSE.Y - this.Ascent + this.Height, PDSE.X - 30, PDSE.X + this.Width + 30 , 1);*/
};
ParaMath.prototype.GetLinePosition = function(Line)
{
var CurLine = Line - this.Root.StartLine;
return this.LinesPositions[CurLine];
/*var CurLine = Line - this.Root.StartLine;
var Bounds = this.Root.Get_Bounds();
Bounds.Get_LineBound(CurLine);
var Pos = new CMathPosition();
Pos.x = this.Bounds[CurLine].X;
Pos.y = this.Bounds[CurLine].Y + RootLineMetrics.ascent;*/
return this.Root.GetPos(Line);
};
ParaMath.prototype.Draw_Lines = function(PDSL)
{
......@@ -1793,29 +1773,6 @@ ParaMath.prototype.Select_All = function(Direction)
this.Root.Select_All();
};
ParaMath.prototype.old_Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if (EndPos >= 1)
{
if (true === this.bSelectionUse)
{
var oSelectedContent = this.GetSelectContent();
oSelectedContent.Content.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
else
{
if ( true === SelectionDraw.FindStart )
{
SelectionDraw.StartX += this.Width;
}
}
}
};
ParaMath.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
this.Root.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
......@@ -1919,10 +1876,11 @@ ParaMath.prototype.Get_ContentSelection = function()
if (oContent.bRoot)
return null;
var X = oContent.pos.x + this.X;
var Y = oContent.pos.y + this.Y;
var Bounds = oContent.Get_Bounds();
var LinesCount = oContent.protected_GetLinesCount();
return {X : X, Y : Y, W : oContent.size.width, H : oContent.size.height};
return Bounds[LinesCount - 1];
};
ParaMath.prototype.Recalc_RunsCompiledPr = function()
......@@ -2064,18 +2022,19 @@ ParaMath.prototype.Make_AutoCorrect = function()
ParaMath.prototype.Get_Bounds = function()
{
if (undefined === this.Paragraph || null === this.Paragraph)
return {X : this.X, Y : this.Y, W : this.Width, H : this.Height, Page : 0};
return {X : 0, Y : 0, W : 0, H : 0, Page : 0};
else
{
var LinesCount = this.Root.protected_GetLinesCount();
var CurLine = this.Root.StartLine + LinesCount - 1;
//var LinesCount = this.Root.protected_GetLinesCount();
/*if(LinesCount < this.Bounds.length)
this.Bounds.splice(LinesCount, this.Bounds.length - LinesCount);
var CurPage = this.Paragraph.Get_PageByLine(CurLine);
return this.Bounds[LinesCount - 1];*/
var Y = this.Paragraph.Pages[CurPage].Y + this.Paragraph.Lines[CurLine].Top;
var H = this.Paragraph.Lines[CurLine].Bottom - this.Paragraph.Lines[CurLine].Top;
var LinesCount = this.Root.protected_GetLinesCount();
return {X : this.X, Y : Y, W : this.Width, H : H, Page : this.Paragraph.Get_StartPage_Absolute() + CurPage};
return this.Root.Get_Bounds()[LinesCount - 1];
}
};
......
......@@ -2172,7 +2172,7 @@ function CParagraphRecalculateStateWrap(Para)
this.bMath_OneLine = false; // for ParaMath
this.bMathWordLarge = false; // for ParaMath
this.PosEndRun = new CParagraphContentPos();
this.ContentMetrics = new CMathMetrics();
this.ContentMetrics = new CMathBoundsMeasures();
}
CParagraphRecalculateStateWrap.prototype =
......
......@@ -8356,7 +8356,7 @@ function CRunCollaborativeRange(PosS, PosE, Color)
this.PosE = PosE;
this.Color = Color;
}
ParaRun.prototype.Math_SetPosition = function(pos, Line, Range)
ParaRun.prototype.Math_SetPosition = function(pos, PRSA, Line, Range, Page)
{
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
......
......@@ -37,7 +37,7 @@ CAccentCircumflex.prototype.calcSize = function(stretch)
width *= augm;
return {width: width, height: height};
}
};
CAccentCircumflex.prototype.calcCoord = function(stretch)
{
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
......@@ -102,7 +102,7 @@ CAccentCircumflex.prototype.calcCoord = function(stretch)
W = XX[3];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CAccentCircumflex.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -117,7 +117,7 @@ CAccentCircumflex.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[9], YY[9]);
pGraphics._l(XX[10], YY[10]);
pGraphics._l(XX[11], YY[11]);
}
};
function CAccentLine()
{
......@@ -134,7 +134,7 @@ CAccentLine.prototype.calcSize = function(stretch)
width = stretch > width ? stretch : width;
return {width: width, height: height};
}
};
CAccentLine.prototype.draw = function(x, y, pGraphics)
{
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
......@@ -145,7 +145,7 @@ CAccentLine.prototype.draw = function(x, y, pGraphics)
//pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y, x1, x2, penW);
}
};
function CAccentDoubleLine()
......@@ -174,7 +174,7 @@ CAccentDoubleLine.prototype.calcSize = function(stretch)
this.diff = DoubleLine.size.ascent - Line.size.ascent;
return {width: width, height: height};
}
};
CAccentDoubleLine.prototype.draw = function(x, y, pGraphics)
{
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
......@@ -194,7 +194,7 @@ CAccentDoubleLine.prototype.draw = function(x, y, pGraphics)
pGraphics.drawHorLine(0, y1, x1, x2, penW);
pGraphics.drawHorLine(0, y2, x1, x2, penW);
}
};
function CAccentTilde()
......@@ -219,7 +219,7 @@ CAccentTilde.prototype.calcSize = function(stretch)
width *= augm;
return {width: width, height: height};
}
};
CAccentTilde.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -276,7 +276,7 @@ CAccentTilde.prototype.calcCoord = function(stretch)
return {XX: XX, YY: YY, W: W, H: H};
}
};
CAccentTilde.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -294,7 +294,7 @@ CAccentTilde.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._c(XX[21], YY[21], XX[22], YY[22], XX[23], YY[23] );
pGraphics._c(XX[23], YY[23], XX[24], YY[24], XX[25], YY[25] );
pGraphics._l(XX[26], YY[26]);
}
};
function CAccentBreve()
......@@ -310,7 +310,7 @@ CAccentBreve.prototype.calcSize = function(stretch)
var height = 2.469444444444445*betta;
return {width: width, height: height};
}
};
CAccentBreve.prototype.calcCoord = function(stretch)
{
var X = [],
......@@ -358,7 +358,7 @@ CAccentBreve.prototype.calcCoord = function(stretch)
W = XX[0];
return {XX: XX, YY: YY, W: W, H: H};
}
};
CAccentBreve.prototype.drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
......@@ -374,7 +374,7 @@ CAccentBreve.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19] );
pGraphics._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21] );
pGraphics._l(XX[22], YY[22]);
}
};
function CMathAccentPr()
{
......@@ -453,7 +453,7 @@ CAccent.prototype.init = function(props)
this.setProperties(props);
this.fillContent();
}
};
CAccent.prototype.getBase = function()
{
return this.Content[0];
......@@ -467,7 +467,7 @@ CAccent.prototype.IsAccent = function()
{
return true;
};
CAccent.prototype.setPosition = function(pos, Line, Range)
CAccent.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -490,7 +490,7 @@ CAccent.prototype.setPosition = function(pos, Line, Range)
PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + this.operator.size.height + oBase.size.ascent;
oBase.setPosition(PosBase, Line, Range);
oBase.setPosition(PosBase, PRSA, Line, Range, Page);
pos.x += this.size.width;
};
......@@ -532,7 +532,9 @@ CAccent.prototype.Resize = function(oMeasure, RPI)
width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent};
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CAccent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
......
This diff is collapsed.
......@@ -11,14 +11,14 @@ CMathBreak.prototype.Set_FromObject = function(Obj)
if(Obj.AlnAt >= 1 && Obj.AlnAt <= 255)
this.AlnAt = Obj.AlnAt;
}
}
};
CMathBreak.prototype.Copy = function()
{
var NewMBreak = new CMathBreak();
NewMBreak.AlnAt = this.AlnAt;
return NewMBreak;
}
};
CMathBreak.prototype.Write_ToBinary = function(Writer)
{
if(this.AlnAt !== undefined)
......@@ -30,7 +30,7 @@ CMathBreak.prototype.Write_ToBinary = function(Writer)
{
Writer.WriteBool(true);
}
}
};
CMathBreak.prototype.Read_FromBinary = function(Reader)
{
if(Reader.GetBool() == false)
......@@ -41,7 +41,7 @@ CMathBreak.prototype.Read_FromBinary = function(Reader)
{
this.AlnAt = undefined;
}
}
};
function CMathBorderBoxPr()
{
......@@ -164,7 +164,7 @@ CBorderBox.prototype.init = function(props)
this.setProperties(props);
this.fillContent();
}
};
CBorderBox.prototype.getBase = function()
{
return this.Content[0];
......@@ -173,7 +173,7 @@ CBorderBox.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.elements[0][0] = this.getBase();
}
};
CBorderBox.prototype.recalculateSize = function()
{
var base = this.elements[0][0].size;
......@@ -199,8 +199,10 @@ CBorderBox.prototype.recalculateSize = function()
width += this.GapLeft + this.GapRight;
this.size = {width : width, height: height, ascent: ascent};
}
this.size.width = width;
this.size.height = height;
this.size.ascent = ascent;
};
CBorderBox.prototype.Draw_Elements = function(PDSE)
{
var _X = PDSE.X;
......@@ -358,8 +360,8 @@ CBorderBox.prototype.Draw_Elements = function(PDSE)
PDSE.X = _X + this.size.width;
}
CBorderBox.prototype.setPosition = function(pos, Line, Range)
};
CBorderBox.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -379,10 +381,10 @@ CBorderBox.prototype.setPosition = function(pos, Line, Range)
else
NewPos.y = this.pos.y + Base.size.ascent;
Base.setPosition(NewPos, Line, Range); // base
Base.setPosition(NewPos, PRSA, Line, Range, Page); // base
pos.x += this.size.width;
}
};
function CMathBoxPr()
{
......@@ -581,7 +583,7 @@ CBar.prototype.init = function(props)
this.setProperties(props);
this.fillContent();
}
};
CBar.prototype.getBase = function()
{
return this.Content[0];
......@@ -590,7 +592,7 @@ CBar.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.elements[0][0] = this.getBase();
}
};
CBar.prototype.ApplyProperties = function(RPI)
{
if(this.RecalcInfo.bProps == true)
......@@ -602,14 +604,14 @@ CBar.prototype.ApplyProperties = function(RPI)
this.setCharacter(prp, defaultProps);
this.RecalcInfo.bProps = false;
}
}
};
CBar.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
this.operator.PreRecalc(this, ParaMath);
CBar.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
}
};
CBar.prototype.getAscent = function()
{
var ascent;
......@@ -620,7 +622,7 @@ CBar.prototype.getAscent = function()
ascent = this.elements[0][0].size.ascent;
return ascent;
}
};
function CMathPhantomPr()
{
......@@ -726,13 +728,13 @@ CPhantom.prototype.init = function(props)
this.setProperties(props);
this.fillContent();
}
};
CPhantom.prototype.getBase = function()
{
return this.Content[0];
}
};
CPhantom.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.elements[0][0] = this.getBase();
}
\ No newline at end of file
};
\ No newline at end of file
......@@ -97,6 +97,29 @@ CDegreeBase.prototype.Resize = function(oMeasure, RPI)
else if(this.Pr.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure);
};
/*CDegreeBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
if(PRS.bMath_OneLine == false)
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var RangeStartPos = this.protected_AddRange(CurLine, CurRange);
var RangeEndPos = 0;
this.baseContent.Recalculate_Range(PRS, ParaPr, Depth + 1);
if(PRS.NewRange == false)
{
RangeEndPos = 1;
this.iterContent.Recalculate_Range(PRS, ParaPr, Depth + 1);
}
}
else
{
CDegreeBase.superclass.Recalculate_Range.call(this, PRS, ParaPr, Depth);
}
};*/
CDegreeBase.prototype.recalculateSize = function(oMeasure)
{
if(this.Pr.type === DEGREE_SUPERSCRIPT)
......@@ -104,6 +127,86 @@ CDegreeBase.prototype.recalculateSize = function(oMeasure)
else if(this.Pr.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure);
};
CDegreeBase.prototype.new_recalculateSup = function(oMeasure, PRS)
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
var iterSize = this.iterContent.size;
var base = this.baseContent.size,
iter = this.iterContent.size;
this.upBase = 0;
this.upIter = 0;
var HeightLine = AscentLine + DescentLine;
// для итератора степени выравниваем по последнему текстовому элементу (в случае если размер шрифта для основания один и то же)
// исключая случай, когда итератор в N-арном операторе
var BaseJustDraw = this.baseContent.IsJustDraw();
var lastElem = this.baseContent.GetLastElement();
var BaseRun = lastElem.Type == para_Math_Run && mgCtrPrp.FontSize == lastElem.Get_CompiledPr(false).FontSize;
var bTextElement = BaseJustDraw && (BaseRun || (lastElem.Type !== para_Math_Run && lastElem.IsJustDraw()));
var UpBaseline = 0.5*TextAscent;
if(bTextElement)
{
var minR = 0.3*TextAscent;
var last = lastElem.size,
upBaseLast = 0,
upBaseIter = 0;
if(base.ascent > UpBaseline + iter.ascent && iter.height + minR < base.ascent) // размер шрифта итератора << размера шрифта основания => iter << base; дробь + текст
{
this.upIter = base.ascent - (UpBaseline + iter.ascent);
}
else if(UpBaseline - (iter.height - iter.ascent) > minR)
{
this.upBase = UpBaseline + iter.ascent - base.ascent;
}
else
{
this.upBase = iter.height + minR - base.ascent;
}
}
else
{
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
if(iter.height - iter.ascent + shCenter > base.ascent) // для дробей и т.п.
{
this.upBase = iter.height - (base.ascent - shCenter);
}
else if(iter.ascent > shCenter)
{
this.upBase = iter.ascent - shCenter;
}
else
{
this.upIter = shCenter - iter.ascent;
}
}
if( this.bNaryInline)
this.dW = 0.17*PlH;
else
this.dW = 0.056*PlH;
if(PRS.bMath_OneLine == true)
{
this.size.height = this.upBase + base.height;
this.size.ascent = this.upBase + base.ascent;
this.size.width = base.width + iter.width + this.dW;
this.size.width += this.GapLeft + this.GapRight;
}
};
CDegreeBase.prototype.recalculateSup = function(oMeasure)
{
var base = this.baseContent.size,
......@@ -182,7 +285,9 @@ CDegreeBase.prototype.recalculateSup = function(oMeasure)
var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CDegreeBase.prototype.recalculateSubScript = function(oMeasure)
{
......@@ -260,9 +365,11 @@ CDegreeBase.prototype.recalculateSubScript = function(oMeasure)
var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CDegreeBase.prototype.setPosition = function(pos, Line, Range)
CDegreeBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
......@@ -287,8 +394,8 @@ CDegreeBase.prototype.setPosition = function(pos, Line, Range)
PosIter.x = this.pos.x + this.GapLeft + oBase.size.width + this.dW;
PosIter.y = this.pos.y + this.upIter + oIter.size.ascent;
oBase.setPosition(PosBase, Line, Range);
oIter.setPosition(PosIter, Line, Range);
oBase.setPosition(PosBase, PRSA, Line, Range, Page);
oIter.setPosition(PosIter, PRSA, Line, Range, Page);
pos.x += this.size.width;
};
......@@ -632,7 +739,9 @@ CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI)
width = this.iters.size.width + base.width + this.dW;
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
}
CDegreeSubSupBase.prototype.getBase = function()
......
......@@ -55,11 +55,11 @@ CFraction.prototype.init = function(props)
this.setProperties(props);
this.fillContent();
}
};
CFraction.prototype.getType = function()
{
return this.Pr.type;
}
};
CFraction.prototype.draw = function(x, y, pGraphics, PDSE)
{
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
......@@ -68,7 +68,7 @@ CFraction.prototype.draw = function(x, y, pGraphics, PDSE)
this.drawSkewedFraction(x, y, pGraphics, PDSE);
else if(this.Pr.type == LINEAR_FRACTION)
this.drawLinearFraction(x, y, pGraphics, PDSE);
}
};
CFraction.prototype.Draw_Elements = function(PDSE)
{
var X = PDSE.X;
......@@ -81,7 +81,7 @@ CFraction.prototype.Draw_Elements = function(PDSE)
this.drawLinearFraction(PDSE);
PDSE.X = X + this.size.width;
}
};
CFraction.prototype.drawBarFraction = function(PDSE)
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
......@@ -107,7 +107,7 @@ CFraction.prototype.drawBarFraction = function(PDSE)
}
CFraction.superclass.Draw_Elements.call(this, PDSE);
}
};
CFraction.prototype.drawSkewedFraction = function(PDSE)
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
......@@ -203,7 +203,7 @@ CFraction.prototype.drawSkewedFraction = function(PDSE)
PDSE.Graphics.ds();
CFraction.superclass.Draw_Elements.call(this, PDSE);
}
};
CFraction.prototype.drawLinearFraction = function(PDSE)
{
var shift = 0.1*this.dW;
......@@ -232,7 +232,7 @@ CFraction.prototype.drawLinearFraction = function(PDSE)
PDSE.Graphics.ds();
CFraction.superclass.Draw_Elements.call(this, PDSE);
}
};
CFraction.prototype.getNumerator = function()
{
var numerator;
......@@ -243,7 +243,7 @@ CFraction.prototype.getNumerator = function()
numerator = this.elements[0][0];
return numerator;
}
};
CFraction.prototype.getDenominator = function()
{
var denominator;
......@@ -254,7 +254,7 @@ CFraction.prototype.getDenominator = function()
denominator = this.elements[0][1];
return denominator;
}
};
CFraction.prototype.getNumeratorMathContent = function()
{
return this.Content[0];
......@@ -302,7 +302,7 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
}
};
CFraction.prototype.recalculateSize = function(oMeasure)
{
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
......@@ -311,7 +311,7 @@ CFraction.prototype.recalculateSize = function(oMeasure)
this.recalculateSkewed(oMeasure);
else if(this.Pr.type == LINEAR_FRACTION)
this.recalculateLinear(oMeasure);
}
};
CFraction.prototype.recalculateBarFraction = function(oMeasure)
{
var num = this.elements[0][0].size,
......@@ -325,8 +325,10 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CFraction.prototype.recalculateSkewed = function(oMeasure)
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
......@@ -339,8 +341,10 @@ CFraction.prototype.recalculateSkewed = function(oMeasure)
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CFraction.prototype.recalculateLinear = function()
{
var AscentFirst = this.elements[0][0].size.ascent,
......@@ -376,9 +380,11 @@ CFraction.prototype.recalculateLinear = function()
width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent};
}
CFraction.prototype.setPosition = function(pos, Line, Range)
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CFraction.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
if(this.Pr.type == SKEWED_FRACTION)
{
......@@ -401,14 +407,14 @@ CFraction.prototype.setPosition = function(pos, Line, Range)
PosDen.x = X + Numerator.size.width + this.dW;
PosDen.y = Y + Numerator.size.height + Denominator.size.ascent;
Numerator.setPosition(PosNum, Line, Range);
Denominator.setPosition(PosDen, Line, Range);
Numerator.setPosition(PosNum, PRSA, Line, Range, Page);
Denominator.setPosition(PosDen, PRSA, Line, Range, Page);
pos.x += this.size.width;
}
else
CFraction.superclass.setPosition.call(this, pos, Line, Range);
}
CFraction.superclass.setPosition.call(this, pos, PRSA, Line, Range, Page);
};
CFraction.prototype.fillContent = function()
{
this.Numerator = new CNumerator(this.Content[0]);
......@@ -436,7 +442,7 @@ CFraction.prototype.fillContent = function()
this.elements[0][0] = this.Numerator.getElement();
this.elements[0][1] = this.Denominator.getElement();
}
}
};
CFraction.prototype.Document_UpdateInterfaceState = function(MathProps)
{
MathProps.Type = c_oAscMathInterfaceType.Fraction;
......@@ -454,11 +460,11 @@ CFractionBase.prototype.init = function(MathContent)
{
this.setDimension(1, 1);
this.elements[0][0] = MathContent;
}
};
CFractionBase.prototype.getElement = function()
{
return this.elements[0][0];
}
};
CFractionBase.prototype.setElement = function(Element)
{
this.elements[0][0] = Element;
......@@ -466,7 +472,7 @@ CFractionBase.prototype.setElement = function(Element)
CFractionBase.prototype.getPropsForWrite = function()
{
return {};
}
};
CFractionBase.prototype.Get_Id = function()
{
return this.elements[0][0].Get_Id();
......@@ -517,8 +523,10 @@ CNumerator.prototype.recalculateSize = function()
var height = arg.height + this.gap;
var ascent = arg.ascent;
this.size = {width : width, height: height, ascent: ascent};
}
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
function CDenominator(MathContent)
{
......@@ -557,12 +565,14 @@ CDenominator.prototype.recalculateSize = function()
var height = arg.height + this.gap;
var ascent = arg.ascent + this.gap;
this.size = {width : width, height: height, ascent: ascent};
}
CDenominator.prototype.setPosition = function(pos, Line, Range)
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CDenominator.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
pos.y += this.gap;
CDenominator.superclass.setPosition.call(this, pos, Line, Range);
}
CDenominator.superclass.setPosition.call(this, pos, PRSA, Line, Range, Page);
};
//////////
......@@ -114,7 +114,9 @@ CLimitPrimary.prototype.recalculateSize = function(oMeasure)
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
function CLimit(props)
......
This diff is collapsed.
......@@ -19,6 +19,7 @@ var StartTextElement = 0x2B1A; // Cambria Math
function CMathSize()
{
this.Type = MATH_SIZE;
this.width = 0;
this.height = 0;
this.ascent = 0;
......@@ -885,7 +886,7 @@ CMathText.prototype =
this.value = Reader.GetLong();
}
}
};
function CMathAmp()
{
......@@ -1023,7 +1024,7 @@ CMathAmp.prototype =
{
}
}
};
var MathFont_ForMathText = 1;
var MathFont_ForSpecialOperator = 2;
......
......@@ -208,3 +208,6 @@ var ALIGN_EMPTY = 3;
var MATH_LEFT_MARGIN = 0;
var MATH_RIGHT_MARGIN = 1;
var MATH_WRAP_INDENT = 2;
var MATH_SIZE = 0;
var MATH_BOUNDS_MEASURES = 1;
\ No newline at end of file
......@@ -314,8 +314,10 @@ CMatrixBase.prototype.recalculateSize = function(oMeasure, RPI)
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CMatrixBase.prototype.baseJustification = function(type)
{
this.Pr.baseJc = type;
......@@ -342,7 +344,7 @@ CMatrixBase.prototype.setDefaultSpace = function()
row: [],
column: []
};
}
};
CMatrixBase.prototype.setRuleGap = function(oSpace, rule, gap, minGap)
{
var bInt = rule == rule - 0 && rule == rule^0,
......@@ -461,8 +463,8 @@ CMathMatrix.prototype.init = function(props)
this.Fill_LogicalContent(nRowsCount * nColsCount);
this.fillContent();
}
CMathMatrix.prototype.setPosition = function(pos, Line, Range)
};
CMathMatrix.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
......@@ -489,14 +491,14 @@ CMathMatrix.prototype.setPosition = function(pos, Line, Range)
NewPos.x = this.pos.x + this.GapLeft + al.x + w;
NewPos.y = this.pos.y + al.y + h + Item.size.ascent;
Item.setPosition(NewPos, Line, Range);
Item.setPosition(NewPos, PRSA, Line, Range, Page);
w += Widths[j] + this.gaps.column[j];
}
h += Heights[i] + this.gaps.row[i];
}
pos.x += this.size.width;
}
};
CMathMatrix.prototype.getMetrics = function(RPI)
{
var Ascents = [];
......@@ -692,7 +694,7 @@ CEqArray.prototype.init = function(props)
this.setProperties(props);
this.fillContent();
}
};
CEqArray.prototype.addRow = function()
{
var NewContent = new CMathContent();
......@@ -704,7 +706,7 @@ CEqArray.prototype.addRow = function()
this.setPr(NewPr);
return NewContent;
}
};
CEqArray.prototype.setPr = function(NewPr)
{
History.Add(this, new CChangesMathEqArrayPr(NewPr, this.Pr));
......@@ -714,7 +716,7 @@ CEqArray.prototype.raw_SetPr = function(NewPr)
{
this.Pr = NewPr;
this.private_SetNeedResize();
}
};
CEqArray.prototype.fillContent = function()
{
var nRowsCount = this.Content.length;
......@@ -745,7 +747,7 @@ CEqArray.prototype.Resize = function(oMeasure, RPI)
this.elements[i][0].Resize(oMeasure, NewRPI);
this.recalculateSize(oMeasure);
}
};
CEqArray.prototype.getMetrics = function()
{
var AscentsMetrics = [];
......@@ -839,8 +841,8 @@ CEqArray.prototype.getMetrics = function()
}
return {ascents: AscentsMetrics, descents: DescentsMetrics, widths: WidthsMetrics};
}
CEqArray.prototype.setPosition = function(pos, Line, Range)
};
CEqArray.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
......@@ -862,17 +864,17 @@ CEqArray.prototype.setPosition = function(pos, Line, Range)
NewPos.x = this.pos.x + this.GapLeft;
NewPos.y = this.pos.y + h + Item.size.ascent;
Item.setPosition(NewPos, Line, Range);
Item.setPosition(NewPos, PRSA, Line, Range, Page);
h += Heights[i] + this.gaps.row[i];
}
pos.x += this.size.width;
}
};
CEqArray.prototype.getElement = function(num)
{
return this.elements[num][0];
}
};
CEqArray.prototype.getElementMathContent = function(Index)
{
return this.Content[Index];
......
This diff is collapsed.
......@@ -2939,7 +2939,7 @@ COperator.prototype.draw = function(x, y, pGraphics, PDSE)
if(this.typeOper === OPERATOR_TEXT)
{
this.drawText(XX, YY, pGraphics, PDSE);
this.drawText(x, y, pGraphics, PDSE);
}
else if(this.IsLineGlyph())
{
......@@ -2957,11 +2957,6 @@ COperator.prototype.setPosition = function(_pos)
if(this.typeOper === OPERATOR_TEXT)
{
/*var pos = new CMathPosition();
pos.x = 0;
pos.y = 0;*/
this.operator.setPosition(_pos);
}
};
......@@ -3490,6 +3485,13 @@ CDelimiter.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.BrGapLeft = this.GapLeft + this.begOper.size.width;
this.BrGapRight = this.GapRight + this.endOper.size.width;
};
CDelimiter.prototype.Is_EmptyGaps = function()
{
var Height = g_oTextMeasurer.GetHeight();
var result = this.GeneralMetrics.size.height < Height;
return result;
};
CDelimiter.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
......@@ -3652,7 +3654,7 @@ CDelimiter.prototype.GetAscentOperator = function(operator) // в качеств
return Ascent;
};
CDelimiter.prototype.setPosition = function(pos, Line, Range)
CDelimiter.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
......@@ -3670,7 +3672,7 @@ CDelimiter.prototype.setPosition = function(pos, Line, Range)
this.UpdatePosOperBeg(pos, Line);
}
this.Content[0].setPosition(pos, Line, Range);
this.Content[0].setPosition(pos, PRSA, Line, Range, Page);
if(LinesCount - 1 == CurLine)
{
......@@ -3691,7 +3693,7 @@ CDelimiter.prototype.setPosition = function(pos, Line, Range)
this.UpdatePosOperBeg(CurrPos, Line);
this.Content[0].setPosition(CurrPos, Line, Range); // CMathContent
this.Content[0].setPosition(CurrPos, PRSA, Line, Range, Page); // CMathContent
var PosSep = new CMathPosition();
PosSep.x = CurrPos.x;
......@@ -3704,7 +3706,7 @@ CDelimiter.prototype.setPosition = function(pos, Line, Range)
{
CurrPos.x += this.sepOper.size.width;
this.Content[j].setPosition(CurrPos, Line, Range);
this.Content[j].setPosition(CurrPos, PRSA, Line, Range, Page);
pos.x += this.Content[j].size.width;
}
......@@ -3857,9 +3859,11 @@ CCharacter.prototype.recalculateSize = function(oMeasure)
width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent};
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CCharacter.prototype.setPosition = function(pos, Line, Range)
CCharacter.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -3884,14 +3888,14 @@ CCharacter.prototype.setPosition = function(pos, Line, Range)
PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + this.operator.size.height + Base.size.ascent;
Base.setPosition(PosBase, Line, Range);
Base.setPosition(PosBase, PRSA, Line, Range, Page);
}
else if(this.Pr.pos === LOCATION_BOT)
{
PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + Base.size.ascent;
Base.setPosition(PosBase, Line, Range);
Base.setPosition(PosBase, PRSA, Line, Range, Page);
PosOper.x = this.pos.x + this.GapLeft + alignOp;
PosOper.y = this.pos.y + Base.size.height;
......
......@@ -5,7 +5,7 @@ function CSignRadical()
this.Parent = null;
this.pos = null;
this.size = null;
this.size = new CMathSize();
this.gapArg = 0;
this.gapSign = 0; /// расстояние до значка радикала
......@@ -112,7 +112,7 @@ CSignRadical.prototype.new_draw = function(x, y, pGraphics)
pGraphics._l(x5 + penW/3*sin, y4 - penW/5);
pGraphics.ds();
}
};
CSignRadical.prototype.draw = function(x, y, pGraphics, PDSE)
{
var txtPrp = this.Parent.Get_CompiledCtrPrp();
......@@ -210,7 +210,7 @@ CSignRadical.prototype.draw = function(x, y, pGraphics, PDSE)
pGraphics.ds();
}
};
CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg)
{
var txtPrp = this.Parent.Get_CompiledCtrPrp();
......@@ -322,16 +322,17 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg)
height += this.gapSign;
//////////////////////////////
this.size = {height: height, width: width};
}
this.size.height = height;
this.size.width = width;
};
CSignRadical.prototype.setPosition = function(pos)
{
this.pos = pos;
}
};
CSignRadical.prototype.relate = function(parent)
{
this.Parent = parent;
}
};
function CMathRadicalPr()
{
......@@ -419,7 +420,7 @@ CRadical.prototype.init = function(props)
this.Fill_LogicalContent(2);
this.fillContent();
}
};
CRadical.prototype.fillContent = function()
{
this.Iterator = this.getDegree();
......@@ -447,7 +448,7 @@ CRadical.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
}
};
CRadical.prototype.ApplyProperties = function(RPI)
{
if(this.RecalcInfo.bProps)
......@@ -496,7 +497,7 @@ CRadical.prototype.ApplyProperties = function(RPI)
this.RecalcInfo.bProps = false;
}
}
};
CRadical.prototype.recalculateSize = function(oMeasure)
{
var shTop,
......@@ -527,8 +528,6 @@ CRadical.prototype.recalculateSize = function(oMeasure)
//ascent = height - (base.height - base.ascent);
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
else if(this.Pr.type == DEGREE_RADICAL)
{
......@@ -571,10 +570,12 @@ CRadical.prototype.recalculateSize = function(oMeasure)
}
this.gapDegree = height - h1 + gapHeight;
this.size = {width: width, height: height, ascent: ascent};
}
}
this.size.height = height;
this.size.width = width;
this.size.ascent = ascent;
};
CRadical.prototype.Resize = function(oMeasure, RPI)
{
if(this.Pr.type == SQUARE_RADICAL)
......@@ -586,8 +587,8 @@ CRadical.prototype.Resize = function(oMeasure, RPI)
}
this.recalculateSize(oMeasure);
}
CRadical.prototype.setPosition = function(pos, Line, Range)
};
CRadical.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -607,7 +608,7 @@ CRadical.prototype.setPosition = function(pos, Line, Range)
PosBase.y = this.pos.y + gapTop + this.RealBase.size.ascent;
this.signRadical.setPosition(PosRadical);
this.RealBase.setPosition(PosBase, Line, Range);
this.RealBase.setPosition(PosBase, PRSA, Line, Range, Page);
}
else if(this.Pr.type == DEGREE_RADICAL)
{
......@@ -618,7 +619,7 @@ CRadical.prototype.setPosition = function(pos, Line, Range)
PosDegree.x = this.pos.x + this.GapLeft + this.gapWidth;
PosDegree.y = this.pos.y + this.gapDegree + this.Iterator.size.ascent;
this.Iterator.setPosition(PosDegree, Line, Range);
this.Iterator.setPosition(PosDegree, PRSA, Line, Range, Page);
var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0;
......@@ -630,11 +631,11 @@ CRadical.prototype.setPosition = function(pos, Line, Range)
PosBase.x = this.pos.x + this.size.width - this.RealBase.size.width - this.GapRight;
PosBase.y = this.pos.y + this.size.ascent;
this.RealBase.setPosition(PosBase, Line, Range);
this.RealBase.setPosition(PosBase, PRSA, Line, Range, Page);
}
pos.x += this.size.width;
}
};
CRadical.prototype.Draw_Elements = function(PDSE)
{
var X = PDSE.X;
......@@ -645,15 +646,15 @@ CRadical.prototype.Draw_Elements = function(PDSE)
CRadical.superclass.Draw_Elements.call(this, PDSE);
PDSE.X = X + this.size.width;
}
};
CRadical.prototype.getBase = function()
{
return this.Content[1];
}
};
CRadical.prototype.getDegree = function()
{
return this.Content[0];
}
};
CRadical.prototype.Document_UpdateInterfaceState = function(MathProps)
{
MathProps.Type = c_oAscMathInterfaceType.Radical;
......
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