Commit e2092407 authored by Anna.Pavlova's avatar Anna.Pavlova

Разбивка на строки формул (инлайн и неинлайн). Выравнивание для формул не учитывается

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@60869 954022d7-b5bf-4e40-9824-e11837661b57
parent 78b806be
......@@ -8,6 +8,7 @@ var g_dMathArgSizeKoeff_1 = 0.76;
var g_dMathArgSizeKoeff_2 = 0.76 * 0.855;
var g_oMathSettings = {};
function MathMenu (type)
{
this.Type = para_Math;
......@@ -20,6 +21,7 @@ MathMenu.prototype =
return this.Type;
}
}
function ParaMath()
{
ParaMath.superclass.constructor.call(this);
......@@ -36,6 +38,9 @@ function ParaMath()
this.X = 0;
this.Y = 0;
this.LinesPositions = [];
this.ParaMathRPI = new CMathRecalculateInfo();
/*this.bInline = false;
......@@ -65,9 +70,7 @@ function ParaMath()
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
Asc.extendClass(ParaMath, CParagraphContentWithContentBase);
ParaMath.prototype.Get_Type = function()
{
return this.Type;
......@@ -203,7 +206,7 @@ ParaMath.prototype.Add = function(Item)
else if (para_Space === Type)
{
NewElement = new CMathText(false);
NewElement.addTxt(" ");
NewElement.add(32);
Run.Add(NewElement, true);
}
else if (para_Math === Type)
......@@ -396,7 +399,7 @@ ParaMath.prototype.GetSelectContent = function()
return this.Root.GetSelectContent();
};
ParaMath.prototype.Get_CurrentParaPos = function()
ParaMath.prototype.old_Get_CurrentParaPos = function()
{
var nLinesCount = this.protected_GetLinesCount();
for (var nLineIndex = 0; nLineIndex < nLinesCount; nLineIndex++)
......@@ -413,6 +416,11 @@ ParaMath.prototype.Get_CurrentParaPos = function()
return new CParaPos(this.StartRange, this.StartLine, 0, 0);
};
ParaMath.prototype.Get_CurrentParaPos = function()
{
return this.Root.Get_CurrentParaPos();
};
ParaMath.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll)
{
// TODO: ParaMath.Apply_TextPr
......@@ -463,6 +471,7 @@ ParaMath.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll)
}
}
};
ParaMath.prototype.Clear_TextPr = function()
{
......@@ -581,6 +590,45 @@ ParaMath.prototype.Add_ToContent = function(Pos, Item, UpdatePosition)
// Функции пересчета
//-----------------------------------------------------------------------------------
ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
if ( this.Paragraph !== PRS.Paragraph )
{
this.Paragraph = PRS.Paragraph;
this.protected_UpdateSpellChecking();
}
var Para = PRS.Paragraph;
var ParaLine = PRS.Line;
var ParaRange = PRS.Range;
// информация о пересчете
var RPI = new CRPI();
RPI.MergeMathInfo(this.ParaMathRPI);
//PRS.RPI = RPI;
var ArgSize = new CMathArgSize();
if ( ( 0 === ParaLine && 0 === ParaRange ) )
{
this.Root.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange только для Root (в CParagraphContentWithContentBase), для внутренних элементов обновится на Recalculate_Range
}
if(RPI.NeedResize)
{
this.Root.Set_Paragraph(Para);
this.Root.Set_ParaMath(this, null);
this.Root.PreRecalc(null, this, ArgSize, RPI);
}
PRS.bMath_OneLine = false;
this.Root.Recalculate_Range(PRS, ParaPr, Depth);
this.ParaMathRPI.ClearRecalculate();
}
ParaMath.prototype.old_Recalculate_Range = function(PRS, ParaPr, Depth)
{
// TODO: Пока у нас контент здесь состоит из 1 элемента (всего элемента Math). Поэтому у нас в данном
// контенте есть 2 позиции 0 и 1, т.е. до или после Math.
......@@ -598,10 +646,6 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
var ParaLine = PRS.Line;
var ParaRange = PRS.Range;
/*var RPI = new CRPI();
RPI.bInline = this.bInline;
RPI.bChangeInline = this.bChangeInline;
RPI.NeedResize = this.NeedResize;*/
var RPI = new CRPI();
RPI.MergeMathInfo(this.ParaMathRPI);
......@@ -612,6 +656,8 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if(PRS.NewRange == false)
this.Root.Recalculate_Reset(PRS.Range, PRS.Line);
if(RPI.NeedResize)
{
this.Root.Set_Paragraph(Para);
......@@ -747,17 +793,20 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
};
ParaMath.prototype.Recalculate_Set_RangeEndPos = function(PRS, PRP, Depth)
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var CurPos = PRP.Get(Depth);
//var CurLine = PRS.Line - this.StartLine;
//var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
//var CurPos = PRP.Get(Depth);
this.protected_FillRangeEndPos(CurLine, CurRange, CurPos);
//this.protected_FillRangeEndPos(CurLine, CurRange, CurPos);
this.Root.Recalculate_Set_RangeEndPos(PRS, PRP, Depth);
};
ParaMath.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
this.Root.Recalculate_Range_Width(PRSC, _CurLine, _CurRange);
};
ParaMath.prototype.old_Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -842,7 +891,7 @@ ParaMath.prototype.Prepare_RecalculateObject = function()
this.protected_ClearLines();
};
ParaMath.prototype.Is_EmptyRange = function(_CurLine, _CurRange)
ParaMath.prototype.old_Is_EmptyRange = function(_CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -855,7 +904,12 @@ ParaMath.prototype.Is_EmptyRange = function(_CurLine, _CurRange)
return true;
};
ParaMath.prototype.Is_EmptyRange = function(_CurLine, _CurRange)
{
// TO DO
// доделать
return this.Root.Is_EmptyRange(_CurLine, _CurRange);
};
ParaMath.prototype.Check_Range_OnlyMath = function(Checker, CurRange, CurLine)
{
if (null !== Checker.Math)
......@@ -907,7 +961,7 @@ ParaMath.prototype.Get_ParaPosByContentPos = function(ContentPos, Depth)
return new CParaPos((LinesCount === 1 ? this.protected_GetRangesCount(0) - 1 + this.StartRange : this.protected_GetRangesCount(0) - 1), LinesCount - 1 + this.StartLine, 0, 0);
};
ParaMath.prototype.Recalculate_CurPos = function(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
ParaMath.prototype.old_Recalculate_CurPos = function(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -923,10 +977,14 @@ ParaMath.prototype.Recalculate_CurPos = function(_X, Y, CurrentRun, _CurRange, _
result = this.Root.Recalculate_CurPos(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
}
return result;
};
ParaMath.prototype.Recalculate_CurPos = function(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
{
return this.Root.Recalculate_CurPos(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
};
ParaMath.prototype.Refresh_RecalcData = function(Data)
{
this.Paragraph.Refresh_RecalcData2(0);
......@@ -1321,7 +1379,7 @@ ParaMath.prototype.Draw_HighLights = function(PDSH)
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var X = PDSH.X;
var X = PDSH.X;
var Y0 = PDSH.Y0;
var Y1 = PDSH.Y1;
......@@ -1360,34 +1418,48 @@ ParaMath.prototype.Draw_HighLights = function(PDSH)
};
ParaMath.prototype.Draw_Elements = function(PDSE)
{
var CurLine = PDSE.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range );
/*PDSE.Graphics.p_color(255,0,0, 255);
PDSE.Graphics.drawHorLine(0, PDSE.Y - this.Ascent, PDSE.X - 30, PDSE.X + this.Width + 30 , 1);*/
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var CurLine = PDSE.Line - this.Root.StartLine;
var Pos = new CMathPosition();
Pos.x = PDSE.X;
Pos.y = PDSE.Y;
this.LinesPositions[CurLine] = Pos;
var pos = new CMathPosition();
this.Root.setPosition(pos, 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.old_Draw_Elements = function(PDSE)
{
/*PDSE.Graphics.p_color(255,0,0, 255);
PDSE.Graphics.drawHorLine(0, PDSE.Y - this.Ascent, PDSE.X - 30, PDSE.X + this.Width + 30 , 1);*/
if ( EndPos >= 1 )
{
//this.Math.Draw( PDSE.X, PDSE.Y, PDSE.Graphics );
// CMathComposition => this.Root.draw(this.absPos.x, this.absPos.y , pGraphics);
// this.absPos.x ~> this.X
// this.absPos.y ~> this.Y
PDSE.X_Line = PDSE.X;
PDSE.Y -= this.Ascent;
var pos = new CMathPosition();
this.Root.setPosition(pos, PDSE);
this.Root.draw( PDSE.X, PDSE.Y, PDSE.Graphics, PDSE);
this.Root.Draw_Elements(PDSE);
PDSE.Y += this.Ascent;
PDSE.X += this.Width;
}
PDSE.X = PDSE.X_Line;
/*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];
};
ParaMath.prototype.Draw_Lines = function(PDSL)
{
var CurLine = PDSL.Line - this.StartLine;
......@@ -1441,7 +1513,6 @@ ParaMath.prototype.Draw_Lines = function(PDSL)
aUnderline.Add( UnderlineY, UnderlineY, X, X + this.Width, LineW, CurColor.r, CurColor.g, CurColor.b );
this.Root.Draw_Lines(PDSL);
PDSL.X = this.X + this.Width;
......@@ -1489,7 +1560,7 @@ ParaMath.prototype.Cursor_MoveToEndPos = function(SelectFromEnd)
this.Root.Cursor_MoveToEndPos(SelectFromEnd);
};
ParaMath.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd, Flag) // получить логическую позицию по XY
ParaMath.prototype.old_Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd, Flag) // получить логическую позицию по XY
{
var Result = false;
......@@ -1522,6 +1593,15 @@ ParaMath.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
return Result;
};
ParaMath.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd, Flag) // получить логическую позицию по XY
{
var Result = this.Root.Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
if(SearchPos.InText)
SearchPos.DiffX = 0.001; // чтобы всегда встать в формулу, если попали в текст
return Result;
};
ParaMath.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos) // получить текущую логическую позицию
{
......@@ -1671,7 +1751,7 @@ ParaMath.prototype.Select_All = function(Direction)
this.Root.Select_All();
};
ParaMath.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
ParaMath.prototype.old_Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -1694,7 +1774,10 @@ ParaMath.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selection
}
}
};
ParaMath.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
this.Root.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
};
ParaMath.prototype.Selection_IsEmpty = function(CheckEnd)
{
// TODO: ParaMath.Selection_IsEmpty
......@@ -1857,7 +1940,7 @@ ParaMath.prototype.Handle_AddNewLine = function()
CurrContent.SplitContent(SecondContent, ContentPos, 0);
CurrContent.CopyTo(FirstContent, false);
// остаим пустой Run в Content, чтобы не упала ф-ия Remove_FromContent
// вставим пустой Run в Content, чтобы не упала ф-ия Remove_FromContent
// первый элемент всегда Run
var Run = CurrContent.getElem(0);
Run.Remove_FromContent(0, Run.Content.length, true);
......@@ -1942,8 +2025,8 @@ ParaMath.prototype.Get_Bounds = function()
return {X : this.X, Y : this.Y, W : this.Width, H : this.Height, Page : 0};
else
{
var LinesCount = this.protected_GetLinesCount();
var CurLine = this.StartLine + LinesCount - 1;
var LinesCount = this.Root.protected_GetLinesCount();
var CurLine = this.Root.StartLine + LinesCount - 1;
var CurPage = this.Paragraph.Get_PageByLine(CurLine);
......@@ -2818,6 +2901,7 @@ function MatGetKoeffArgSize(FontSize, ArgSize)
return FontKoef;
}
function CMathRecalculateInfo()
{
this.NeedResize = true;
......@@ -2831,4 +2915,4 @@ CMathRecalculateInfo.prototype.ClearRecalculate = function()
this.NeedResize = false;
this.bRecalcCtrPrp = false;
this.bChangeInline = false;
};
\ No newline at end of file
};
......@@ -52,6 +52,9 @@ var para_Math_Composition = 0x0033; // Математический о
var para_Math_Text = 0x0034; // Текст в формуле
var para_Math_Ampersand = 0x0035; // &
var para_Field = 0x0036; // Поле
var para_Math_BreakOperator = 0x0037; // break operator в формуле
var para_Math_Content = 0x0038; // math content
var break_Line = 0x01;
......
......@@ -40,12 +40,14 @@ function ParaRun(Paragraph, bMathRun)
{
this.Type = para_Math_Run;
// запомним позицию для Recalculate_CurPos, когда Run пустой
this.pos = new CMathPosition();
this.ParaMath = null;
this.Parent = null;
this.ArgSize = 0;
this.bEqqArray = false;
this.size = new CMathSize();
this.MathPrp = new CMPrp();
this.bEqArray = false;
}
this.StartState = null;
......@@ -57,7 +59,7 @@ function ParaRun(Paragraph, bMathRun)
}
}
Asc.extendClass(ParaRun, CParagraphContentWithContentBase)
Asc.extendClass(ParaRun, CParagraphContentWithContentBase);
ParaRun.prototype.Get_Type = function()
{
......@@ -622,6 +624,25 @@ ParaRun.prototype.Get_CurrentParaPos = function()
}
// Значит курсор стоит в самом конце, поэтому посылаем последний отрезок
if(this.Type == para_Math_Run && LinesCount > 1)
{
var Line = LinesCount - 1,
Range = this.protected_GetRangesCount(LinesCount - 1) - 1;
StartPos = this.protected_GetRangeStartPos(Line, Range);
EndPos = this.protected_GetRangeEndPos(Line, Range);
// учтем, что в одной строке в формуле может быть только один Range
while(StartPos == EndPos && Line >= 0) // == this.Content.length, т.к. последний Range
{
Line--;
StartPos = this.protected_GetRangeStartPos(Line, Range);
EndPos = this.protected_GetRangeEndPos(Line, Range);
}
return new CParaPos((this.protected_GetRangesCount(Line) - 1), Line + this.StartLine, 0, 0 );
}
return new CParaPos((LinesCount <= 1 ? this.protected_GetRangesCount(0) - 1 + this.StartRange : this.protected_GetRangesCount(LinesCount - 1) - 1), LinesCount - 1 + this.StartLine, 0, 0 );
};
......@@ -661,34 +682,71 @@ ParaRun.prototype.Recalculate_CurPos = function(X, Y, CurrentRun, _CurRange, _Cu
var Pos = StartPos;
var _EndPos = ( true === CurrentRun ? Math.min( EndPos, this.State.ContentPos ) : EndPos );
for ( ; Pos < _EndPos; Pos++ )
if(this.Type == para_Math_Run)
{
var Item = this.Content[Pos];
var ItemType = Item.Type;
var Lng = this.Content.length;
switch( ItemType )
Pos = _EndPos;
var loc;
var MATH_X = X;
var MATH_Y = Y;
if(Lng == 0)
{
case para_Text:
case para_Space:
case para_Sym:
case para_PageNum:
case para_Tab:
case para_End:
case para_NewLine:
case para_Math_Text:
case para_Math_Placeholder:
case para_Math_Ampersand:
{
X += Item.Get_WidthVisible();
break;
}
case para_Drawing:
X += this.pos.x;
Y += this.pos.y;
}
else if(Pos < EndPos)
{
loc = this.Content[Pos].GetLocationOfLetter();
X += loc.x;
Y += loc.y;
}
else
{
var Letter = this.Content[Pos - 1];
loc = Letter.GetLocationOfLetter();
X += loc.x + Letter.Get_WidthVisible();
Y += loc.y;
}
}
else
{
for ( ; Pos < _EndPos; Pos++ )
{
var Item = this.Content[Pos];
var ItemType = Item.Type;
switch( ItemType )
{
if ( drawing_Inline != Item.DrawingType )
case para_Text:
case para_Space:
case para_Sym:
case para_PageNum:
case para_Tab:
case para_End:
case para_NewLine:
case para_Math_Text:
case para_Math_BreakOperator:
case para_Math_Placeholder:
case para_Math_Ampersand:
{
X += Item.Get_WidthVisible();
break;
}
case para_Drawing:
{
if ( drawing_Inline != Item.DrawingType )
break;
X += Item.Get_WidthVisible();
break;
X += Item.Get_WidthVisible();
break;
}
}
}
}
......@@ -795,13 +853,22 @@ ParaRun.prototype.Recalculate_CurPos = function(X, Y, CurrentRun, _CurRange, _Cu
Para.DrawingDocument.UpdateTarget( X, __Y0, Page_Abs );
}
if (para_Math_Run === this.Type && null !== this.Parent && true !== this.Parent.bRoot)
if (para_Math_Run === this.Type && null !== this.Parent && true !== this.Parent.bRoot && this.Parent.bMath_OneLine)
{
var oBounds = this.Parent.Get_Bounds();
var __Y0 = TargetY, __Y1 = TargetY + Height;
var ___Y0 = oBounds.Y - 0.2 * oBounds.H;
var ___Y1 = oBounds.Y + 1.4 * oBounds.H;
//var ___Y0 = oBounds.Y - 0.2 * oBounds.H;
//var ___Y1 = oBounds.Y + 1.4 * oBounds.H;
// пока так
// TO DO : переделать
var YY = this.Parent.pos.y - this.Parent.size.ascent,
XX = this.Parent.pos.x;
var ___Y0 = MATH_Y + YY - 0.2 * oBounds.H;
var ___Y1 = MATH_Y + YY + 1.4 * oBounds.H;
__Y0 = Math.max( __Y0, ___Y0 );
__Y1 = Math.min( __Y1, ___Y1 );
......@@ -1436,6 +1503,16 @@ ParaRun.prototype.Recalculate_MeasureContent = function()
var ContentLength = this.Content.length;
var InfoMathText;
if(para_Math_Run == this.Type)
{
var ArgSize = this.Parent.Compiled_ArgSz.value,
bNormalText = this.IsNormalText(),
bEqArray = this.Parent.IsEqArray();
InfoMathText = new CMathInfoTextPr_2(Pr, ArgSize, bNormalText, bEqArray);
}
for ( var Pos = 0; Pos < ContentLength; Pos++ )
{
var Item = this.Content[Pos];
......@@ -1460,7 +1537,8 @@ ParaRun.prototype.Recalculate_MeasureContent = function()
continue;
}
Item.Measure( g_oTextMeasurer, Pr );
Item.Measure( g_oTextMeasurer, Pr, InfoMathText );
if (para_Drawing === Item.Type)
{
......@@ -1512,10 +1590,8 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
}
// Сначала измеряем элементы (можно вызывать каждый раз, внутри разруливается, чтобы измерялось 1 раз)
this.Recalculate_MeasureContent();
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
......@@ -1571,6 +1647,11 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
var Pos = RangeStartPos;
var bInline = false;
if(this.Type == para_Math_Run)
bInline = this.ParaMath.Is_Inline();
var UpdateLineMetricsText = false;
var ContentLen = this.Content.length;
......@@ -1599,6 +1680,8 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
case para_Sym:
case para_Text:
case para_Math_Text:
case para_Math_Placeholder:
{
// Отмечаем, что началось слово
StartWord = true;
......@@ -1607,6 +1690,7 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
// При проверке, убирается ли слово, мы должны учитывать ширину предшествующих пробелов.
var LetterLen = Item.Width / TEXTWIDTH_DIVIDER;//var LetterLen = Item.Get_Width();
if (true !== Word)
{
// Слово только началось. Делаем следующее:
......@@ -1624,7 +1708,7 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
}
}
if (true !== NewRange)
if (true !== NewRange || (this.Type == para_Math_Run && bInline == true))
{
// Отмечаем начало нового слова
PRS.Set_LineBreakPos(Pos);
......@@ -1636,11 +1720,13 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
if (X + SpaceLen + WordLen + LetterLen > XEnd)
{
if (true === FirstItemOnLine)
{
// Слово оказалось единственным элементом в промежутке, и, все равно,
// не умещается целиком. Делаем следующее:
//
// 0) Для Формулы слово не разбиваем, перенос не делаем, пишем в одну строку (слово выйдет за границу как в Ворде)
// 1) Если у нас строка без вырезов, тогда ставим перенос строки на
// текущей позиции.
// 2) Если у нас строка с вырезом, и данный вырез не последний, тогда
......@@ -1648,7 +1734,11 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
// 3) Если у нас строка с вырезом и вырез последний, тогда ставим перенос
// строки в начале слова.
if (false === Para.Internal_Check_Ranges(ParaLine, ParaRange))
if(this.Type == para_Math_Run)
{
//
}
else if (false === Para.Internal_Check_Ranges(ParaLine, ParaRange))
{
// Слово не убирается в отрезке. Переносим слово в следующий отрезок
MoveToLBP = true;
......@@ -1715,6 +1805,81 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
// перенос делаем при добавлении любого непробельного символа
SpaceLen += Item.Width / TEXTWIDTH_DIVIDER;//SpaceLen += Item.Get_Width();
break;
}
case para_Math_BreakOperator:
{
var bCurrWord = Word;
if (true === Word)
{
// Добавляем длину пробелов до слова + длина самого слова. Не надо проверять
// убирается ли слово, мы это проверяем при добавленнии букв.
X += SpaceLen + WordLen;
Word = false;
EmptyLine = false;
SpaceLen = 0;
WordLen = 0;
}
// На пробеле не делаем перенос. Перенос строки или внутристрочный
// перенос делаем при добавлении любого непробельного символа
SpaceLen += Item.Width / TEXTWIDTH_DIVIDER;//SpaceLen += Item.Get_Width();
/*if(bInline == false && bCurrWord == true)
{
PRS.Set_LineBreakPos(Pos);
WordLen = SpaceLen;
SpaceLen = 0;
Word = true;
}*/
if(bInline == false)
{
if(bCurrWord == true)
{
PRS.Set_LineBreakPos(Pos);
WordLen = SpaceLen;
SpaceLen = 0;
Word = true;
FirstItemOnLine = false;
}
}
else
{
if(X + SpaceLen > XEnd && FirstItemOnLine == false) // Слово не убирается в отрезке. Переносим слово в следующий отрезок
{
MoveToLBP = true;
NewRange = true;
UpdateLineMetricsText = true;
if(bCurrWord == false)
{
PRS.Set_LineBreakPos(Pos);
SpaceLen = Item.Width / TEXTWIDTH_DIVIDER;
}
}
// исключительно для первого элемента в формуле
if(PRS.Line == 0 && PRS.Range == 0 && bCurrWord == true && FirstItemOnLine == true)
{
PRS.Set_LineBreakPos(Pos);
WordLen = SpaceLen;
SpaceLen = 0;
Word = true;
}
if(!(bCurrWord == false && FirstItemOnLine == true))
FirstItemOnLine = false;
}
break;
}
case para_Drawing:
......@@ -2123,6 +2288,8 @@ ParaRun.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
case para_Sym:
case para_Text:
case para_Math_Text:
case para_Math_Placeholder:
{
PRSC.Letters++;
......@@ -2151,6 +2318,7 @@ ParaRun.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
break;
}
case para_Math_BreakOperator:
case para_Space:
{
if ( true === PRSC.Word )
......@@ -3236,6 +3404,7 @@ ParaRun.prototype.Draw_HighLights = function(PDSH)
case para_Tab:
case para_Text:
case para_Math_Text:
case para_Math_BreakOperator:
case para_Math_Ampersand:
case para_Sym:
{
......@@ -3332,17 +3501,10 @@ ParaRun.prototype.Draw_Elements = function(PDSE)
var InfoMathText ;
if(this.Type == para_Math_Run)
{
Y += this.size.ascent;
//var ArgSize = this.Parent.Compiled_ArgSz.value,
// bNormalText = this.IsNormalText();
var ArgSize = this.Parent.Compiled_ArgSz.value,
bNormalText = this.IsNormalText();
InfoMathText = new CMathInfoTextPr_2(CurTextPr, ArgSize, bNormalText);
//NewMathTextPr = GetMathModifiedFont(MathFont_ForMathText, CurTextPr, this);
//pGraphics.SetTextPr( NewMathTextPr, Theme );
InfoMathText = new CMathInfoTextPr_2(CurTextPr, ArgSize, bNormalText, this.bEqArray);
}
if ( undefined !== CurTextPr.Shd && shd_Nil !== CurTextPr.Shd.Value )
......@@ -3511,10 +3673,12 @@ ParaRun.prototype.Draw_Elements = function(PDSE)
}
case para_Math_Ampersand:
case para_Math_Text:
case para_Math_BreakOperator:
case para_Math_Placeholder:
{
Item.draw(X, Y, pGraphics, InfoMathText);
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
Item.Draw(PosLine.x, PosLine.y, pGraphics, InfoMathText);
X += Item.Get_WidthVisible();
break;
}
}
......@@ -3679,6 +3843,7 @@ ParaRun.prototype.Draw_Lines = function(PDSL)
break;
}
case para_Math_Text:
case para_Math_BreakOperator:
case para_Math_Ampersand:
{
if ( true === CurTextPr.DStrikeout )
......@@ -3820,7 +3985,9 @@ ParaRun.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var CurPos = StartPos;
var bNotUpdate = SearchPos.InText && this.Type === para_Math_Run;
var InMathText = this.Type == para_Math_Run ? SearchPos.InText == true : false;
for (; CurPos < EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
......@@ -3833,9 +4000,18 @@ ParaRun.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
TempDx = Item.Get_WidthVisible();
}
if(this.Type == para_Math_Run)
{
var PosLine = this.ParaMath.GetLinePosition(_CurLine);
var loc = this.Content[CurPos].GetLocationOfLetter()
SearchPos.CurX = PosLine.x + loc.x; // позиция формулы в строке + смещение буквы в контенте
}
// Проверяем, попали ли мы в данный элемент
var Diff = SearchPos.X - SearchPos.CurX;
if ((Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)) && !bNotUpdate)
if ((Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)) && InMathText == false)
{
SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth );
......@@ -3852,7 +4028,7 @@ ParaRun.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
// Заглушка для знака параграфа и конца строки
Diff = SearchPos.X - SearchPos.CurX;
if ((Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)) && !bNotUpdate)
if ((Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)) && InMathText == false)
{
if ( para_End === ItemType )
{
......@@ -3883,8 +4059,16 @@ ParaRun.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
if (this.Type == para_Math_Run) // не только для пустых Run, но и для проверки на конец Run (т.к. Diff не обновляется)
{
var Diff = SearchPos.X - SearchPos.CurX;
if ((Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)) && !bNotUpdate)
//для пустых Run искомая позиция - позиция самого Run
var bEmpty = this.Is_Empty();
var PosLine = this.ParaMath.GetLinePosition(_CurLine);
if(bEmpty)
SearchPos.CurX = PosLine.x + this.pos.x;
Diff = SearchPos.X - SearchPos.CurX;
if(SearchPos.InText == false && (bEmpty || StartPos !== EndPos) && (Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)))
{
SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth );
......@@ -4468,7 +4652,7 @@ ParaRun.prototype.Select_All = function(Direction)
}
};
ParaRun.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw, PointsInfo)
ParaRun.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -4489,7 +4673,7 @@ ParaRun.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionD
var FindStart = SelectionDraw.FindStart;
for ( var CurPos = StartPos; CurPos < EndPos; CurPos++ )
for(var CurPos = StartPos; CurPos < EndPos; CurPos++)
{
var Item = this.Content[CurPos];
var ItemType = Item.Type;
......@@ -7823,20 +8007,29 @@ function CRunCollaborativeRange(PosS, PosE, Color)
this.PosE = PosE;
this.Color = Color;
}
ParaRun.prototype.Math_SetPosition = function(pos)
ParaRun.prototype.Math_SetPosition = function(pos, PDSE)
{
var w = 0;
for(var i = 0; i < this.Content.length; i++)
var CurLine = PDSE.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
// запомним позицию для Recalculate_CurPos, когда Run пустой
this.pos.x = pos.x;
this.pos.y = pos.y;
for(var i = StartPos; i < EndPos; i++)
{
var NewPos = new CMathPosition();
//var NewPos = new CMathPosition();
NewPos.x = pos.x + w;
NewPos.y = pos.y - this.size.ascent;
//NewPos.x = pos.x + w;
//NewPos.y = pos.y - this.size.ascent;
this.Content[i].setPosition(NewPos);
w += this.Content[i].size.width;
this.Content[i].setPosition(pos);
pos.x += this.Content[i].size.width;
}
}
};
ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
{
var X = x;
......@@ -7863,12 +8056,9 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
for(var i=0; i < this.Content.length;i++)
this.Content[i].draw(X, Y, pGraphics);
}
ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints)
};
ParaRun.prototype.old_Math_Recalculate = function(oMeasure, RPI, WidthPoints)
{
// пересчет элементов контента в Run
// Recalculate_MeasureContent
// ParaText (ParagraphContent.js)
// для настройки TextPr
// Measure
......@@ -7899,13 +8089,11 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints)
var InfoMathText = new CMathInfoTextPr_2(oWPrp, ArgSize, bNormalText);
this.bEqqArray = RPI.bEqqArray;
this.bEqArray = RPI.bEqArray;
this.size.SetZero();
var widthCurr = 0,
ascent = 0, descent = 0;
var ascent = 0, descent = 0;
var Lng = this.Content.length;
......@@ -7915,18 +8103,17 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints)
var oSize = this.Content[i].size;
widthCurr = oSize.width;
this.size.width += widthCurr;
this.size.width += oSize.width;
var oDescent = oSize.height - oSize.ascent;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
descent = descent < oDescent ? oDescent : descent;
if(RPI.bEqqArray)
if(RPI.bEqArray)
{
if(this.Content[i].Type !== para_Math_Ampersand)
WidthPoints.UpdatePoint(widthCurr);
WidthPoints.UpdatePoint(oSize.width);
else
WidthPoints.AddNewAlignRange();
}
......@@ -7951,7 +8138,171 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints)
if (RPI.PRS.LineTextDescent < this.TextDescent)
RPI.PRS.LineTextDescent = this.TextDescent;
}
};
ParaRun.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
{
// данная функция используется только для мат объектов, которые на строки не разбиваются
// ParaText (ParagraphContent.js)
// для настройки TextPr
// Measure
// FontClassification.js
// Get_FontClass
var Lng = this.Content.length;
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
// обновляем позиции start и end для Range
//this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos);
var RangeStartPos = this.protected_AddRange(CurLine, CurRange);
var RangeEndPos = Lng;
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
var WidthPoints = this.Parent.Get_WidthPoints();
this.bEqArray = this.Parent.IsEqArray();
var ascent = 0, descent = 0, width = 0;
this.Recalculate_MeasureContent();
for(var i = 0 ; i < Lng; i++)
{
var size = this.Content[i].size,
Type = this.Content[i].Type;
width += size.width;
if(ascent < size.ascent)
ascent = size.ascent;
if (descent < size.height - size.ascent)
descent = size.height - size.ascent;
if(this.bEqArray)
{
if(Type !== para_Math_Ampersand)
WidthPoints.UpdatePoint(size.width);
else
WidthPoints.AddNewAlignRange();
}
}
this.size.width = width;
this.size.ascent = ascent;
this.size.height = ascent + descent;
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
// данная функция используется только для мат объектов, которые на строки не разбиваются
// поэтому далее можно убрать
// Запрашиваем текущие метрики шрифта, под TextAscent мы будем понимать ascent + linegap(которые записаны в шрифте)
/*this.TextHeight = g_oTextMeasurer.GetHeight();
this.TextDescent = Math.abs( g_oTextMeasurer.GetDescender() );
this.TextAscent = this.TextHeight - this.TextDescent;
this.TextAscent2 = g_oTextMeasurer.GetAscender();
// Пересчитаем метрику строки относительно размера данного текста
if (PRS.LineTextAscent < this.TextAscent)
PRS.LineTextAscent = this.TextAscent;
if (PRS.LineTextAscent2 < this.TextAscent2)
PRS.LineTextAscent2 = this.TextAscent2;
if (PRS.LineTextDescent < this.TextDescent)
PRS.LineTextDescent = this.TextDescent;*/
};
/*ParaRun.prototype.Recalculate_WidthPoints_EqArray = function(WidthPoints)
{
this.bEqArray = true;
this.Recalculate_MeasureContent(WidthPoints);
};*/
ParaRun.prototype.new_Math_Recalculate = function(oMeasure, WidthPoints)
{
// ParaText (ParagraphContent.js)
// для настройки TextPr
// Measure
// FontClassification.js
// Get_FontClass
var RangeStartPos = 0;
var RangeEndPos = this.Content.length;
// обновляем позиции start и end для Range
//this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos);
this.protected_AddRange(0, 0);
this.protected_FillRange(0, 0, RangeStartPos, RangeEndPos);
var oWPrp = this.Get_CompiledPr(false);
var Theme = this.Paragraph.Get_Theme();
var ArgSize = this.Parent.Compiled_ArgSz.value,
bNormalText = this.IsNormalText();
// argSize
g_oTextMeasurer.SetTextPr(oWPrp,Theme);
var InfoMathText = new CMathInfoTextPr_2(oWPrp, ArgSize, bNormalText);
//this.bEqArray = RPI.bEqArray;
this.size.SetZero();
var ascent = 0, descent = 0;
var Lng = this.Content.length;
for (var i = 0 ; i < Lng; i++)
{
this.Content[i].Measure(oMeasure, oWPrp, InfoMathText);
var oSize = this.Content[i].size;
this.size.width += oSize.width;
var oDescent = oSize.height - oSize.ascent;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
descent = descent < oDescent ? oDescent : descent;
if(this.Parent.IsEqArray())
{
if(this.Content[i].Type !== para_Math_Ampersand)
WidthPoints.UpdatePoint(oSize.width);
else
WidthPoints.AddNewAlignRange();
}
this.size.ascent = ascent;
this.size.height = ascent + descent;
// Запрашиваем текущие метрики шрифта, под TextAscent мы будем понимать ascent + linegap(которые записаны в шрифте)
/*this.TextHeight = g_oTextMeasurer.GetHeight();
this.TextDescent = Math.abs( g_oTextMeasurer.GetDescender() );
this.TextAscent = this.TextHeight - this.TextDescent;
this.TextAscent2 = g_oTextMeasurer.GetAscender();*/
}
// Пересчитаем метрику строки относительно размера данного текста
/*if (RPI.PRS.LineTextAscent < this.TextAscent)
RPI.PRS.LineTextAscent = this.TextAscent;
if (RPI.PRS.LineTextAscent2 < this.TextAscent2)
RPI.PRS.LineTextAscent2 = this.TextAscent2;
if (RPI.PRS.LineTextDescent < this.TextDescent)
RPI.PRS.LineTextDescent = this.TextDescent;*/
};
ParaRun.prototype.Math_Apply_Style = function(Value)
{
if(Value !== this.MathPrp.sty)
......@@ -7963,26 +8314,26 @@ ParaRun.prototype.Math_Apply_Style = function(Value)
this.Recalc_CompiledPr(true);
}
}
};
ParaRun.prototype.IsNormalText = function()
{
var comp_MPrp = this.MathPrp.GetCompiled_ScrStyles();
return comp_MPrp.nor === true;
}
};
ParaRun.prototype.IsMathematicalText = function()
{
var MathText = !this.IsNormalText();
var bMFont = this.Get_CompiledPr(false).FontFamily.Name == "Cambria Math";
return MathText && bMFont;
}
};
ParaRun.prototype.getPropsForWrite = function()
{
var wRPrp = this.Pr.Copy(),
mathRPrp = this.MathPrp.getPropsForWrite();
return {wRPrp: wRPrp, mathRPrp: mathRPrp};
}
};
ParaRun.prototype.Math_PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
......@@ -7990,6 +8341,9 @@ ParaRun.prototype.Math_PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gaps
var FontSize = this.Get_CompiledPr(false).FontSize;
if(RPI.bChangeInline)
this.RecalcInfo.Measure = true; // нужно сделать пересчет элементов, например для дроби, т.к. ArgSize у внутренних контентов будет другой => размер
for (var Pos = 0 ; Pos < this.Content.length; Pos++ )
{
if( !this.Content[Pos].IsAlignPoint() )
......@@ -7997,18 +8351,18 @@ ParaRun.prototype.Math_PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gaps
this.Content[Pos].PreRecalc(this);
}
}
};
ParaRun.prototype.IsPlaceholder = function()
{
return this.Content.length == 1 && this.Content[0].IsPlaceholder();
}
};
ParaRun.prototype.fillPlaceholders = function()
{
var placeholder = new CMathText(false);
placeholder.fillPlaceholders();
this.Add_ToContent(0, placeholder, false);
}
};
ParaRun.prototype.Math_Correct_Content = function()
{
for(var i = 0; i < this.Content.length; i++)
......@@ -8016,7 +8370,50 @@ ParaRun.prototype.Math_Correct_Content = function()
if(this.Content[i].Type == para_Math_Placeholder)
this.Remove_FromContent(i, 1, true);
}
}
};
ParaRun.prototype.Get_ParaContentPosByXY_2 = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
{
var Result = false;
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);
var CurPos = StartPos;
var Dx = 0;
for (; CurPos < EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
var CurX = Item.pos.x;
Dx = Item.Get_WidthVisible();
// Проверяем, попали ли мы в данный элемент
var Diff = SearchPos.X - CurX;
if ((Math.abs( Diff ) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)))
{
SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
if (Diff >= - 0.001 && Diff <= Dx + 0.001)
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}
}
}
if ((Math.abs(Diff - Dx) < SearchPos.DiffX + 0.001 && (SearchPos.CenterMode || SearchPos.X > SearchPos.CurX)) )
{
SearchPos.Pos.Update( EndPos, Depth );
Result = true;
}
};
ParaRun.prototype.Set_MathPr = function(MPrp)
{
var OldValue = this.MathPrp;
......@@ -8025,36 +8422,33 @@ ParaRun.prototype.Set_MathPr = function(MPrp)
History.Add( this, { Type : historyitem_ParaRun_MathPrp, New : MPrp, Old : OldValue } );
this.Recalc_CompiledPr(true);
}
};
ParaRun.prototype.Set_MathTextPr2 = function(TextPr, MathPr)
{
this.Set_Pr(TextPr.Copy());
this.Set_MathPr(MathPr.Copy());
}
};
ParaRun.prototype.IsAccent = function()
{
return this.Parent.IsAccent();
}
};
ParaRun.prototype.GetCompiled_ScrStyles = function()
{
return this.MathPrp.GetCompiled_ScrStyles();
}
ParaRun.prototype.IsEqqArray = function()
};
ParaRun.prototype.IsEqArray = function()
{
return this.Parent.IsEqqArray();
}
ParaRun.prototype.Math_GetInfoLetter = function(Info)
return this.Parent.IsEqArray();
};
ParaRun.prototype.Math_Is_InclineLetter = function()
{
var result = false;
if(this.Content.length == 1)
{
var Compiled_MPrp = this.MathPrp.GetCompiled_ScrStyles();
Info.sty = Compiled_MPrp.sty;
Info.scr = Compiled_MPrp.scr;
this.Content[0].getInfoLetter(Info);
}
else
Info.Result = false;
}
result = this.Content[0].Is_InclineLetter();
return result;
};
ParaRun.prototype.GetMathTextPrForMenu = function()
{
var TextPr = new CTextPr();
......@@ -8071,10 +8465,10 @@ ParaRun.prototype.GetMathTextPrForMenu = function()
TextPr.Bold = BI.Bold;
return TextPr;
}
};
ParaRun.prototype.ApplyPoints = function(PointsInfo)
{
if(this.bEqqArray)
if(this.Parent.IsEqArray())
{
this.size.width = 0;
......@@ -8089,7 +8483,14 @@ ParaRun.prototype.ApplyPoints = function(PointsInfo)
this.size.width += this.Content[Pos].size.width;
}
}
}
};
ParaRun.prototype.Update_LineBreakPos = function(PRS, bAfterRun)
{
if(bAfterRun)
{
PRS.Set_LineBreakPos(this.Content.length);
}
};
ParaRun.prototype.Get_TextForAutoCorrect = function(AutoCorrectEngine, RunPos)
{
var ActionElement = AutoCorrectEngine.Get_ActionElement();
......@@ -8097,7 +8498,7 @@ ParaRun.prototype.Get_TextForAutoCorrect = function(AutoCorrectEngine, RunPos)
for (var nPos = 0; nPos < nCount; nPos++)
{
var Item = this.Content[nPos];
if (para_Math_Text === Item.Type)
if (para_Math_Text === Item.Type || para_Math_BreakOperator === Item.Type)
{
AutoCorrectEngine.Add_Text(String.fromCharCode(Item.value), this, nPos, RunPos);
}
......@@ -8141,8 +8542,6 @@ ParaRun.prototype.Get_RangesByPos = function(Pos)
return Ranges;
};
function CParaRunStartState(Run)
{
this.Paragraph = Run.Paragraph;
......@@ -8152,4 +8551,4 @@ function CParaRunStartState(Run)
{
this.Content.push(Run.Content[i]);
}
}
}
\ No newline at end of file
......@@ -467,31 +467,32 @@ CAccent.prototype.IsAccent = function()
{
return true;
};
CAccent.prototype.setPosition = function(pos, PosInfo)
CAccent.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
var width = this.size.width - this.GapLeft - this.GapRight;
var oBase = this.Content[0];
var alignOp = (width - this.operator.size.width)/2,
alignCnt = (width- this.elements[0][0].size.width)/2;
alignCnt = (width - oBase.size.width)/2;
var PosOper = new CMathPosition();
PosOper.x = this.pos.x + this.GapLeft + alignOp;
PosOper.y = this.pos.y;
//PosOper.y = this.pos.y + this.size.ascent - this.shiftX;
this.operator.setPosition(PosOper);
var PosBase = new CMathPosition();
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 + oBase.size.ascent;
oBase.setPosition(PosBase, PDSE);
this.elements[0][0].setPosition(PosBase, PosInfo);
pos.x += this.size.width;
};
CAccent.prototype.ApplyProperties = function(RPI)
{
......@@ -533,6 +534,30 @@ CAccent.prototype.Resize = function(oMeasure, RPI)
this.size = {height: height, width: width, ascent: ascent};
};
CAccent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var bMath_OneLine = PRS.bMath_OneLine;
var WordLen = PRS.WordLen; // запоминаем, чтобы внутр мат объекты не увеличили WordLen
PRS.bMath_OneLine = true;
var oBase = this.getBase();
oBase.Recalculate_Reset(PRS.Range, PRS.Line ); // обновим StartLine и StartRange
oBase.Recalculate_Range(PRS, ParaPr, Depth);
this.operator.fixSize(g_oTextMeasurer, oBase.size.width);
this.size.width = oBase.size.width + this.GapLeft + this.GapRight; // (!)
this.size.height = oBase.size.height + this.operator.size.height;
this.size.ascent = this.operator.size.height + oBase.size.ascent;
PRS.bMath_OneLine = bMath_OneLine;
this.Update_WordLen(PRS, WordLen);
};
CAccent.prototype.draw = function(x, y, pGraphics, PDSE)
{
var base = this.elements[0][0];
......@@ -567,6 +592,30 @@ CAccent.prototype.draw = function(x, y, pGraphics, PDSE)
this.operator.draw(x, y, pGraphics, PDSE);
};
CAccent.prototype.Draw_Elements = function(PDSE)
{
var oBase = this.Content[0];
oBase.Draw_Elements(PDSE);
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
var x = PosLine.x,
y = PosLine.y;
//var x = PDSE.X,
// y = PDSE.Y;
if(oBase.Is_InclineLetter())
{
if(this.Pr.chr != 0x305 && this.Pr.chr >= 0x300 && this.Pr.chr <= 0x315 || this.Pr.chr == 0x20DB)
{
var ascent = this.elements[0][0].size.ascent;
x += ascent*0.1;
}
}
this.operator.draw(x, y, PDSE.Graphics, PDSE);
};
CAccent.prototype.GetLastElement = function()
{
return this.Content[0].GetLastElement();
......
......@@ -22,6 +22,7 @@ function CMathBase(bInside)
this.nCol = 0;
this.bInside = bInside === true ? true: false;
this.bMath_OneLine = true;
this.elements = [];
......@@ -185,7 +186,7 @@ CMathBase.prototype =
{
return false;
},
IsEqqArray: function()
IsEqArray: function()
{
return false;
},
......@@ -279,7 +280,45 @@ CMathBase.prototype =
return PosAlign;
},
setPosition: function(pos, PosInfo)
setPosition: function(pos, PDSE)
{
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 Widths = maxWH.widths;
var Heights = maxWH.heights;
var h = 0, w = 0;
for(var i=0; i < this.nRow; i++)
{
w = 0;
for(var j = 0; j < this.nCol; j++)
{
var NewPos = new CMathPosition();
var al = this.align(i, j);
NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w;
NewPos.y = this.pos.y + al.y + this.dH*i + h;
if(this.elements[i][j].Type == para_Math_Content) // прибавим ascent только для контентов, для вложенных мат объектов не добавляем !
NewPos.y += this.elements[i][j].size.ascent;
this.elements[i][j].setPosition(NewPos, PDSE);
w += Widths[j];
}
h += Heights[i];
}
pos.x += this.size.width;
},
old_setPosition: function(pos)
{
this.pos.x = pos.x;
......@@ -303,7 +342,7 @@ CMathBase.prototype =
var al = this.align(i, j);
NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w;
NewPos.y = this.pos.y + al.y + this.dH*i + h;
this.elements[i][j].setPosition(NewPos, PosInfo);
this.elements[i][j].setPosition(NewPos);
w += Widths[j];
}
h += Heights[i];
......@@ -334,6 +373,37 @@ CMathBase.prototype =
this.elements[i][j].draw(x, y, pGraphics, PDSE);
}
},
Draw_Elements: function(PDSE)
{
var X = PDSE.X;
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp()); // для Just-Draw элементов
for(var i=0; i < this.nRow; i++)
{
for(var j = 0; j < this.nCol; j++)
{
if(this.elements[i][j].IsJustDraw()) // для Just-Draw элементов надо выставить Font
{
var ctrPrp = this.Get_TxtPrControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
PDSE.Graphics.SetFont(Font);
}
this.elements[i][j].Draw_Elements(PDSE);
}
}
PDSE.X = X + this.size.width;
},
remove: function(order)
{
return this.Parent.remove(order);
......@@ -1132,7 +1202,7 @@ CMathBase.prototype.Recalculate_CurPos = function(_X, Y, CurrentRun, _CurRange,
{
return this.Content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
};
CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
CMathBase.prototype.old_Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
{
var nCount = this.Content.length;
if (nCount <= 0)
......@@ -1198,6 +1268,96 @@ CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine
return bResult;
};
CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
{
var bResult = false;
var nCount = this.Content.length;
if (nCount <= 0)
return false;
if(this.bMath_OneLine)
{
var aBounds = [];
for (var nIndex = 0; nIndex < nCount; nIndex++)
{
var oBounds = this.Content[nIndex].Get_Bounds();
if (oBounds.W > 0.001 && oBounds.H > 0.001)
aBounds.push(oBounds);
else
aBounds.push(null);
}
var X = SearchPos.X;
var Y = SearchPos.Y;
var dDiff = null;
var nCurIndex = 0;
var nFindIndex = 0;
var PosLine = this.ParaMath.GetLinePosition(_CurLine);
while (nCurIndex < nCount)
{
var oBounds = aBounds[nCurIndex];
if (null !== oBounds)
{
var _X = PosLine.x + oBounds.X,
_Y = PosLine.y + oBounds.Y;
if (_X <= X && X <= _X + oBounds.W && _Y <= Y && Y <= _Y + oBounds.H)
{
nFindIndex = nCurIndex;
break;
}
else
{
var dCurDiffX = X - (_X + oBounds.W / 2);
var dCurDiffY = Y - (_Y + oBounds.H / 2);
var dCurDiff = dCurDiffX * dCurDiffX + dCurDiffY * dCurDiffY;
if (null === dDiff || dDiff > dCurDiff)
{
dDiff = dCurDiff;
nFindIndex = nCurIndex;
}
}
}
nCurIndex++;
}
if (null === aBounds[nFindIndex])
return false;
SearchPos.CurX = aBounds[nFindIndex].X;
SearchPos.CurY = aBounds[nFindIndex].Y;
bResult = this.Content[nFindIndex].Get_ParaContentPosByXY(SearchPos, Depth + 1, _CurLine, _CurRange, StepEnd);
if(true === bResult)
{
SearchPos.Pos.Update2(nFindIndex, Depth);
}
}
else
{
for (var nIndex = 0; nIndex < nCount; nIndex++)
{
if ( false === SearchPos.InText )
SearchPos.InTextPos.Update2( nIndex, Depth );
if(true == this.Content[nIndex].Get_ParaContentPosByXY(SearchPos, Depth + 1, _CurLine, _CurRange, StepEnd))
{
SearchPos.Pos.Update2( nIndex, Depth );
bResult = true;
}
}
}
return bResult;
};
CMathBase.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos)
{
var nPos = (true !== bSelection ? this.CurPos : (false !== bStart ? this.Selection.StartPos : this.Selection.EndPos));
......@@ -1226,6 +1386,23 @@ CMathBase.prototype.Set_ParaContentPos = function(ContentPos, Depth)
this.Content[this.CurPos].Set_ParaContentPos(ContentPos, Depth + 1);
}
};
CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
var SelectionUse = this.Selection.Use;
if(SelectionStartPos !== SelectionEndPos)
{
SelectionDraw.FindStart = false;
SelectionDraw.DrawSelection = true;
SelectionDraw.W += this.size.width;
}
else
this.Content[SelectionStartPos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
};
CMathBase.prototype.Selection_IsEmpty = function()
{
if (true !== this.Selection.Use)
......@@ -1414,7 +1591,7 @@ CMathBase.prototype.raw_AddToContent = function(Pos, Items, bUpdatePosition)
this.fillContent();
this.private_SetNeedResize();
}
};
CMathBase.prototype.raw_RemoveFromContent = function(Pos, Count)
{
this.Content.splice(Pos, Count);
......@@ -1435,7 +1612,96 @@ CMathBase.prototype.GetFirstElement = function()
{
return this;
};
CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
//var ParaRange = PRS.Range;
//var ParaLine = PRS.Line;
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var bMath_OneLine = PRS.bMath_OneLine;
var WordLen = PRS.WordLen; // запоминаем, чтобы внутр мат объекты не увеличили WordLen
this.bMath_OneLine = true;
PRS.bMath_OneLine = true;
for(var i=0; i < this.nRow; i++)
{
for(var j = 0; j < this.nCol; j++)
{
var Item = this.elements[i][j];
if(Item.IsJustDraw()) // для Just-Draw элементов надо выставить Font
{
var ctrPrp = this.Get_TxtPrControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
g_oTextMeasurer.SetFont(Font);
Item.Measure(g_oTextMeasurer);
}
else
{
// когда мат объект будет разбиваться на строки
// var CurLine = PRS.Line - this.StartLine;
// var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
//if ( Item.Type == para_Math_Content && ( 0 === CurLine && 0 === CurRange ) ) // CMathContent для первой строки нужно обновить Lines
if(Item.Type == para_Math_Content)
{
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange
}
Item.Recalculate_Range(PRS, ParaPr, Depth);
}
}
}
this.recalculateSize(g_oTextMeasurer);
PRS.bMath_OneLine = bMath_OneLine;
this.Update_WordLen(PRS, WordLen);
};
CMathBase.prototype.Update_WordLen = function(PRS, WordLen)
{
if(this.bInside == false)
{
if(true !== PRS.Word)
{
PRS.WordLen = this.size.width;
}
else
{
PRS.WordLen = WordLen + this.size.width;
}
}
};
CMathBase.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
{
this.Recalculate_Range(PRS, ParaPr, Depth);
};
CMathBase.prototype.Recalculate_Reset = function()
{
//TODO
// будет реализовано, когда мат объекты будут разбиваться на строки
};
CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
PRSC.Range.W += this.size.width;
};
CMathBase.prototype.Get_CurrentParaPos = CMathContent.prototype.Get_CurrentParaPos;
CMathBase.prototype.private_UpdatePosOnAdd = CMathContent.prototype.private_UpdatePosOnAdd;
CMathBase.prototype.private_UpdatePosOnRemove = CMathContent.prototype.private_UpdateOnRemove;
CMathBase.prototype.private_CorrectSelectionPos = CMathContent.prototype.private_CorrectSelectionPos;
......
......@@ -201,17 +201,22 @@ CBorderBox.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent};
}
CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
CBorderBox.prototype.Draw_Elements = function(PDSE)
{
this.elements[0][0].draw(x, y, pGraphics, PDSE);
this.Content[0].Draw_Elements(PDSE);
var penW = this.Get_TxtPrControlLetter().FontSize*0.02;
var Width = this.size.width - this.GapLeft - this.GapRight,
Height = this.size.height;
var X = this.pos.x + x + this.GapLeft,
Y = this.pos.y + y;
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
var X = this.pos.x + PosLine.x + this.GapLeft,
Y = this.pos.y + PosLine.y;
/*var X = this.pos.x + PDSE.X + this.GapLeft,
Y = this.pos.y + PDSE.Y;*/
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
......@@ -222,7 +227,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
x2 = X + Width,
y1 = Y;
pGraphics.drawHorLine(0, y1, x1, x2, penW);
PDSE.Graphics.drawHorLine(0, y1, x1, x2, penW);
}
if(!this.Pr.hideBot)
......@@ -231,7 +236,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
x2 = X + Width,
y1 = Y + Height;
pGraphics.drawHorLine(2, y1, x1, x2, penW);
PDSE.Graphics.drawHorLine(2, y1, x1, x2, penW);
}
if(!this.Pr.hideLeft)
......@@ -240,7 +245,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
y1 = Y,
y2 = Y + Height;
pGraphics.drawVerLine(0, x1, y1, y2, penW);
PDSE.Graphics.drawVerLine(0, x1, y1, y2, penW);
}
if(!this.Pr.hideRight)
......@@ -249,7 +254,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
y1 = Y,
y2 = Y + Height;
pGraphics.drawVerLine(2, x1, y1, y2, penW);
PDSE.Graphics.drawVerLine(2, x1, y1, y2, penW);
}
if(this.Pr.strikeTLBR) // left diagonal
......@@ -259,12 +264,12 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
var x1 = X, y1 = Y,
x2 = X + Width, y2 = Y + Height;
pGraphics.p_width(180);
PDSE.Graphics.p_width(180);
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics.ds();
PDSE.Graphics._s();
PDSE.Graphics._m(x1, y1);
PDSE.Graphics._l(x2, y2);
PDSE.Graphics.ds();
}
else
{
......@@ -278,17 +283,17 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
x6 = X, y6 = Y + pW,
x7 = X, y7 = Y;
pGraphics.p_width(1000);
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics._l(x3, y3);
pGraphics._l(x4, y4);
pGraphics._l(x5, y5);
pGraphics._l(x6, y6);
pGraphics._l(x7, y7);
pGraphics.df();
PDSE.Graphics.p_width(1000);
PDSE.Graphics._s();
PDSE.Graphics._m(x1, y1);
PDSE.Graphics._l(x2, y2);
PDSE.Graphics._l(x3, y3);
PDSE.Graphics._l(x4, y4);
PDSE.Graphics._l(x5, y5);
PDSE.Graphics._l(x6, y6);
PDSE.Graphics._l(x7, y7);
PDSE.Graphics.df();
}
}
......@@ -300,12 +305,12 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
var x1 = X + Width, y1 = Y,
x2 = X, y2 = Y + Height;
pGraphics.p_width(180);
PDSE.Graphics.p_width(180);
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics.ds();
PDSE.Graphics._s();
PDSE.Graphics._m(x1, y1);
PDSE.Graphics._l(x2, y2);
PDSE.Graphics.ds();
}
else
{
......@@ -320,17 +325,17 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
x7 = X + Width, y7 = Y;
pGraphics.p_width(1000);
PDSE.Graphics.p_width(1000);
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics._l(x3, y3);
pGraphics._l(x4, y4);
pGraphics._l(x5, y5);
pGraphics._l(x6, y6);
pGraphics._l(x7, y7);
pGraphics.df();
PDSE.Graphics._s();
PDSE.Graphics._m(x1, y1);
PDSE.Graphics._l(x2, y2);
PDSE.Graphics._l(x3, y3);
PDSE.Graphics._l(x4, y4);
PDSE.Graphics._l(x5, y5);
PDSE.Graphics._l(x6, y6);
PDSE.Graphics._l(x7, y7);
PDSE.Graphics.df();
}
}
......@@ -341,7 +346,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
x2 = X + Width,
y1 = Y + Height/2 - penW/2;
pGraphics.drawHorLine(0, y1, x1, x2, penW);
PDSE.Graphics.drawHorLine(0, y1, x1, x2, penW);
}
if(this.Pr.strikeV)
......@@ -350,17 +355,19 @@ CBorderBox.prototype.draw = function(x, y, pGraphics, PDSE)
y1 = Y,
y2 = Y + Height;
pGraphics.drawVerLine(0, x1, y1, y2, penW);
PDSE.Graphics.drawVerLine(0, x1, y1, y2, penW);
}
}
CBorderBox.prototype.setPosition = function(pos, PosInfo)
CBorderBox.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
var NewPos = new CMathPosition();
var Base = this.Content[0];
if(this.Pr.hideLeft == false)
NewPos.x = this.pos.x + this.GapLeft + this.gapBrd;
else
......@@ -368,11 +375,13 @@ CBorderBox.prototype.setPosition = function(pos, PosInfo)
if(this.Pr.hideTop == false)
NewPos.y = this.pos.y + this.gapBrd;
NewPos.y = this.pos.y + this.gapBrd + Base.size.ascent;
else
NewPos.y = this.pos.y;
NewPos.y = this.pos.y + Base.size.ascent;
Base.setPosition(NewPos, PDSE); // base
this.elements[0][0].setPosition(NewPos, PosInfo);
pos.x += this.size.width;
}
function CMathBoxPr()
......
......@@ -105,6 +105,13 @@ CDegreeBase.prototype.Resize = function(oMeasure, RPI)
else if(this.Pr.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure);
};
CDegreeBase.prototype.recalculateSize = function(oMeasure)
{
if(this.Pr.type === DEGREE_SUPERSCRIPT)
this.recalculateSup(oMeasure);
else if(this.Pr.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure);
};
CDegreeBase.prototype.recalculateSup = function(oMeasure)
{
var base = this.elements[0][0].size,
......@@ -264,7 +271,37 @@ CDegreeBase.prototype.recalculateSubScript = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent};
};
CDegreeBase.prototype.setPosition = function(pos, PosInfo)
CDegreeBase.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
if(this.bInside === true)
this.pos.y = pos.y;
else
this.pos.y = pos.y - this.size.ascent;
var oBase = this.elements[0][0],
oIter = this.elements[0][1];
var PosBase = new CMathPosition();
PosBase.x = this.pos.x + this.GapLeft;
PosBase.y = this.pos.y + this.upBase;
if(oBase.Type == para_Math_Content)
PosBase.y += oBase.size.ascent;
var PosIter = new CMathPosition();
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, PDSE);
oIter.setPosition(PosIter, PDSE);
pos.x += this.size.width;
};
CDegreeBase.prototype.old_setPosition = function(pos, PosInfo)
{
this.pos.x = pos.x;
......@@ -285,6 +322,7 @@ CDegreeBase.prototype.setPosition = function(pos, PosInfo)
this.elements[0][0].setPosition(PosBase, PosInfo);
this.elements[0][1].setPosition(PosIter, PosInfo);
};
CDegreeBase.prototype.getIterator = function()
{
......
......@@ -69,7 +69,16 @@ CFraction.prototype.draw = function(x, y, pGraphics, PDSE)
else if(this.Pr.type == LINEAR_FRACTION)
this.drawLinearFraction(x, y, pGraphics, PDSE);
}
CFraction.prototype.drawBarFraction = function(x, y, pGraphics, PDSE)
CFraction.prototype.Draw_Elements = function(PDSE)
{
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
this.drawBarFraction(PDSE);
else if(this.Pr.type == SKEWED_FRACTION)
this.drawSkewedFraction(PDSE);
else if(this.Pr.type == LINEAR_FRACTION)
this.drawLinearFraction(PDSE);
}
CFraction.prototype.drawBarFraction = function(PDSE)
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
......@@ -79,21 +88,23 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics, PDSE)
var width = this.size.width - this.GapLeft - this.GapRight;
var x1 = this.pos.x + x + this.GapLeft,
x2 = x1 + width,
y1 = this.pos.y + y + numHeight- penW;
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
var x1 = this.pos.x + PosLine.x + this.GapLeft,
x2 = this.pos.x + PosLine.x + this.GapLeft + width,
y1 = this.pos.y + PosLine.y + numHeight- penW;
if( !this.bHideBar )
{
pGraphics.SetFont(mgCtrPrp);
PDSE.Graphics.SetFont(mgCtrPrp);
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
pGraphics.drawHorLine(0, y1, x1, x2, penW);
PDSE.Graphics.drawHorLine(0, y1, x1, x2, penW);
}
CFraction.superclass.draw.call(this, x, y, pGraphics, PDSE);
CFraction.superclass.Draw_Elements.call(this, PDSE);
}
CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics, PDSE)
CFraction.prototype.drawSkewedFraction = function(PDSE)
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
......@@ -110,8 +121,10 @@ CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics, PDSE)
var tg1 = -2.22,
tg2 = -3.7;
var X = this.pos.x + x + this.GapLeft,
Y = this.pos.y + y;
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
var X = this.pos.x + PosLine.x + this.GapLeft,
Y = this.pos.y + PosLine.y;
var heightSlash = this.size.height*2/3;
......@@ -175,24 +188,26 @@ CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics, PDSE)
}
pGraphics.SetFont(mgCtrPrp);
PDSE.Graphics.SetFont(mgCtrPrp);
pGraphics.p_width(penW*1000);
PDSE.Graphics.p_width(penW*1000);
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
pGraphics._s();
pGraphics._m(xx1, yy1);
pGraphics._l(xx2, yy2);
pGraphics.ds();
PDSE.Graphics._s();
PDSE.Graphics._m(xx1, yy1);
PDSE.Graphics._l(xx2, yy2);
PDSE.Graphics.ds();
CFraction.superclass.draw.call(this, x, y, pGraphics, PDSE);
CFraction.superclass.Draw_Elements.call(this, PDSE);
}
CFraction.prototype.drawLinearFraction = function(x, y, pGraphics, PDSE)
CFraction.prototype.drawLinearFraction = function(PDSE)
{
var shift = 0.1*this.dW;
var X = this.pos.x + x + this.GapLeft,
Y = this.pos.y + y;
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
var X = this.pos.x + PosLine.x + this.GapLeft,
Y = this.pos.y + PosLine.y;
var x1 = X + this.elements[0][0].size.width + this.dW - shift,
y1 = Y,
......@@ -202,17 +217,17 @@ CFraction.prototype.drawLinearFraction = function(x, y, pGraphics, PDSE)
var mgCtrPrp = this.Get_TxtPrControlLetter();
var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
pGraphics.SetFont(mgCtrPrp);
pGraphics.p_width(penW*1000);
PDSE.Graphics.SetFont(mgCtrPrp);
PDSE.Graphics.p_width(penW*1000);
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
pGraphics._s();
pGraphics._m(x1, y1);
pGraphics._l(x2, y2);
pGraphics.ds();
PDSE.Graphics._s();
PDSE.Graphics._m(x1, y1);
PDSE.Graphics._l(x2, y2);
PDSE.Graphics.ds();
CFraction.superclass.draw.call(this, x, y, pGraphics, PDSE);
CFraction.superclass.Draw_Elements.call(this, PDSE);
}
CFraction.prototype.getNumerator = function()
{
......@@ -359,10 +374,13 @@ CFraction.prototype.recalculateLinear = function()
this.size = {height: height, width: width, ascent: ascent};
}
CFraction.prototype.setPosition = function(pos, PosInfo)
CFraction.prototype.setPosition = function(pos, PDSE)
{
if(this.Pr.type == SKEWED_FRACTION)
{
var Numerator = this.Content[0],
Denominator = this.Content[1];
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -372,19 +390,20 @@ CFraction.prototype.setPosition = function(pos, PosInfo)
var PosNum = new CMathPosition();
PosNum.x = X;
PosNum.y = Y;
PosNum.y = Y + Numerator.size.ascent;
var PosDen = new CMathPosition();
PosDen.x = X + this.elements[0][0].size.width + this.dW;
PosDen.y = Y + this.elements[0][0].size.height;
PosDen.x = X + Numerator.size.width + this.dW;
PosDen.y = Y + Numerator.size.height + Denominator.size.ascent;
this.elements[0][0].setPosition(PosNum, PosInfo);
this.elements[0][1].setPosition(PosDen, PosInfo);
Numerator.setPosition(PosNum, PDSE);
Denominator.setPosition(PosDen, PDSE);
pos.x += this.size.width;
}
else
CFraction.superclass.setPosition.call(this, pos, PosInfo);
CFraction.superclass.setPosition.call(this, pos, PDSE);
}
CFraction.prototype.fillContent = function()
{
......@@ -496,10 +515,6 @@ CNumerator.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent};
}
CNumerator.prototype.setPosition = function(pos, PosInfo)
{
this.elements[0][0].setPosition(pos, PosInfo);
}
function CDenominator(MathContent)
{
......@@ -519,7 +534,7 @@ CDenominator.prototype.recalculateSize = function()
var gapDen, minGap;
if(this.Parent.kind == MATH_LIMIT || this.Parent.kind == MATH_GROUP_CHARACTER)
if(this.Parent.kind == MATH_PRIMARY_LIMIT || this.Parent.kind == MATH_GROUP_CHARACTER)
{
gapDen = Height/2.6;
minGap = Height/10;
......@@ -540,13 +555,10 @@ CDenominator.prototype.recalculateSize = function()
this.size = {width : width, height: height, ascent: ascent};
}
CDenominator.prototype.setPosition = function(pos, PosInfo)
CDenominator.prototype.setPosition = function(pos, PDSE)
{
var NewPos = new CMathPosition();
NewPos.x = pos.x;
NewPos.y = pos.y + this.gap;
pos.y += this.gap;
this.elements[0][0].setPosition(NewPos, PosInfo);
CDenominator.superclass.setPosition.call(this, pos, PDSE);
}
//////////
......@@ -41,6 +41,7 @@ function CLimitPrimary(bInside, Type, FName, Iterator)
this.init(FName, Iterator);
}
Asc.extendClass(CLimitPrimary, CMathBase);
CLimitPrimary.prototype.kind = MATH_PRIMARY_LIMIT;
CLimitPrimary.prototype.init = function(FName, Iterator)
{
this.setDimension(2, 1);
......@@ -84,16 +85,20 @@ CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gap
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI);
};
CLimitPrimary.prototype.Resize = function(oMeasure, RPI)
{
this.FName.Resize(oMeasure, RPI);
this.Iterator.Resize(oMeasure, RPI);
this.recalculateSize(oMeasure);
};
CLimitPrimary.prototype.recalculateSize = function(oMeasure)
{
if(this.Type == LIMIT_LOW)
this.dH = 0;
else
this.dH = 0.06*this.Get_TxtPrControlLetter().FontSize;
this.FName.Resize(oMeasure, RPI);
this.Iterator.Resize(oMeasure, RPI);
var SizeFName = this.FName.size,
SizeIter = this.Iterator.size;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,6 +10,8 @@
//api 2212: asc_docs_api.prototype.sync_TextPrFontFamilyCallBack
// возвращает название шрифта
// Таблица соответствия кодов ASCII (десятичные, соответствующие восьмеричные, шестнадцатиричные, двоичные, ASCII коды )
// http://www.dpva.info/Guide/GuideMathematics/GuideMathematicsNumericalSystems/TableCodeEquivalent/
var DIV_CENT = 0.1386;
......@@ -24,7 +26,7 @@ function CMathSize()
CMathSize.prototype.SetZero = function()
{
this.width = 0;
this.height = 0;
this.descent = 0;
this.ascent = 0;
}
......@@ -47,8 +49,12 @@ function CMathText(bJDraw)
bSpecialOperator: false
};
this.ParaMath = null;
this.Flags = 0;
this.Parent = null;
this.size = new CMathSize();
this.Width = 0; // для Recalculate_Range
this.pos = new CMathPosition();
this.rasterOffsetX = 0;
......@@ -76,6 +82,9 @@ CMathText.prototype =
add: function(code)
{
this.value = code;
if( this.Is_BreakOperator(code) )
this.Type = para_Math_BreakOperator;
},
addTxt: function(txt)
{
......@@ -544,7 +553,7 @@ CMathText.prototype =
this.Type = para_Math_Placeholder;
this.value = StartTextElement;
},
Resize: function(oMeasure, RPI, InfoTextPr)
Measure: function(oMeasure, TextPr, InfoMathText)
{
/*
var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
......@@ -566,12 +575,12 @@ CMathText.prototype =
{
var ascent, width, height, descent;
this.FontSlot = InfoTextPr.GetFontSlot(this.value); // возвращает fontslot_ASCII || fontslot_EastAsia || fontslot_CS || fontslot_HAnsi
this.FontSlot = InfoMathText.GetFontSlot(this.value); // возвращает fontslot_ASCII || fontslot_EastAsia || fontslot_CS || fontslot_HAnsi
var letter = this.getCode();
// в не математическом тексте i и j не подменяются на i и j без точек
var bAccentIJ = !InfoTextPr.bNormalText && this.Parent.IsAccent() && (this.value == 0x69 || this.value == 0x6A);
var bAccentIJ = !InfoMathText.bNormalText && this.Parent.IsAccent() && (this.value == 0x69 || this.value == 0x6A);
this.RecalcInfo.StyleCode = letter;
this.RecalcInfo.bAccentIJ = bAccentIJ;
......@@ -579,21 +588,14 @@ CMathText.prototype =
if(bAccentIJ || this.RecalcInfo.bApostrophe)
oMeasure.SetStringGid(true);
if( InfoTextPr.NeedUpdateFont(this.value, this.FontSlot, this.IsPlaceholder()) )
if( InfoMathText.NeedUpdateFont(this.value, this.FontSlot, this.IsPlaceholder()) )
{
g_oTextMeasurer.SetFont(InfoTextPr.Font);
g_oTextMeasurer.SetFont(InfoMathText.Font);
//g_oTextMeasurer.SetTextPr(InfoTextPr.CurrentTextPr, InfoTextPr.Theme);
}
else if(InfoTextPr.CurrType == MathTextInfo_NormalText)
else if(InfoMathText.CurrType == MathTextInfo_NormalText)
{
/*this.FontKoef = InfoTextPr.FontKoef;
if (1 !== this.FontKoef )
{
var FontSize = this.FontSlot == fontslot_CS ? InfoTextPr.TextPr.FontSizeCS : InfoTextPr.TextPr.FontSize;
this.FontKoef = (((FontSize * this.FontKoef * 2 + 0.5) | 0) / 2) / FontSize;
}*/
var FontKoef = InfoTextPr.GetFontKoef(this.FontSlot);
var FontKoef = InfoMathText.GetFontKoef(this.FontSlot);
g_oTextMeasurer.SetFontSlot(this.FontSlot, FontKoef);
}
......@@ -634,9 +636,12 @@ CMathText.prototype =
this.size.height = height;
this.size.ascent = ascent;
this.Width = (this.size.width * TEXTWIDTH_DIVIDER) | 0;
},
PreRecalc: function(Parent, ParaMath, ArgSize, RPI)
{
this.ParaMath = ParaMath;
if(!this.bJDraw)
this.Parent = Parent;
else
......@@ -646,12 +651,16 @@ CMathText.prototype =
{
return this.size.width;
},
draw: function(x, y, pGraphics, InfoTextPr)
Draw_Elements: function(PDSE)
{
var X = this.pos.x + x,
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
this.Draw(PosLine.x, PosLine.y, PDSE.Graphics);
},
Draw: function(x, y, pGraphics, InfoTextPr)
{
var X = this.pos.x + x + this.GapLeft,
Y = this.pos.y + y;
/*var tx = 0;
var ty = 0;
......@@ -708,7 +717,7 @@ CMathText.prototype =
{
if (!this.bJDraw) // for text
{
this.pos.x = pos.x + this.GapLeft;
this.pos.x = pos.x;
this.pos.y = pos.y;
}
else // for symbol only drawing
......@@ -723,19 +732,33 @@ CMathText.prototype =
}
},
getInfoLetter: function(Info)
GetLocationOfLetter: function()
{
var pos = new CMathPosition();
pos.x = this.pos.x;
pos.y = this.pos.y;
return pos;
},
Is_InclineLetter: function()
{
var code = this.value;
var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b) || code == 0x131 || code == 0x237;
Info.Latin = bCapitale || bSmall;
var bCapGreek = (code > 0x0390 && code < 0x03AA),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
Info.Greek = bCapGreek || bSmallGreek;
var bAlphabet = bCapitale || bSmall || bCapGreek || bSmallGreek;
var MPrp = this.Parent.GetCompiled_ScrStyles();
var bRomanSerif = (MPrp.sty == STY_BI || MPrp.sty == STY_ITALIC) && (MPrp.scr == TXT_ROMAN || MPrp.scr == TXT_SANS_SERIF),
bScript = MPrp.scr == TXT_SCRIPT;
return bAlphabet && (bRomanSerif || bScript);
},
setCoeffTransform: function(sx, shx, shy, sy)
{
......@@ -799,6 +822,15 @@ CMathText.prototype =
{
return true;
},
Is_BreakOperator: function(val)
{
var bSimpleOper = val == 0x2D || val == 0x2B || val == 0x3D || val == 0x2A || val == 0x2F || val == 0x5C || val == 0x3C || val == 0x3E || val == 0xB1 || val == 0x2213,
bArrows = (val >= 0x2190 && val <= 0x21B3) || val == 0x21B6 || val == 0x21B7 || (val >= 0x21BA && val <= 0x21E9) || (val >= 0x21F4 && val <= 0x21FF),
bOtherSymbols = (val >= 0x2234 && val <= 0x2237) || val == 0x2239 || (val >= 0x223B && val <= 0x228B) || (val >= 0x228F && val <= 0x2292) || (val >= 0x22A2 && val <= 0x22B9),
bFishes = (val >= 0x22C8 && val <= 0x22CD) || val == 0x22D0 ||val == 0x22D1 || (val >= 0x22D5 && val <= 0x22EE) || (val >= 0x22F0 && val <= 0x22FF) || (val >= 0x27F0 && val <= 0x297F ) || ( val >= 0x29CE && val <= 0x29D5);
return bSimpleOper || bArrows || bOtherSymbols || bFishes;
},
// For ParaRun
Is_Punctuation: function()
{
......@@ -824,6 +856,10 @@ CMathText.prototype =
return bSpecialOperator || bSpecialArrow || bSpecialSymbols || bOtherArrows;
},
Can_AddNumbering: function()
{
return false;
},
////
Copy: function()
{
......@@ -853,7 +889,7 @@ CMathText.prototype =
function CMathAmp()
{
this.bEqqArray = false;
this.bEqArray = false;
this.Type = para_Math_Ampersand;
this.GapLeft = 0;
......@@ -866,16 +902,18 @@ function CMathAmp()
this.size = null;
this.Parent = null;
this.Width = 0;
}
CMathAmp.prototype =
{
Resize: function(oMeasure, RPI, InfoTextPr)
Measure: function(oMeasure, TextPr, InfoMathText)
{
this.bEqqArray = RPI.bEqqArray;
this.bEqArray = InfoMathText.bEqArray;
this.AmpText.Resize(oMeasure, RPI, InfoTextPr);
this.AmpText.Measure(oMeasure, TextPr, InfoMathText);
if(this.bEqqArray)
if(this.bEqArray)
{
this.size =
{
......@@ -883,6 +921,8 @@ CMathAmp.prototype =
height: 0,
ascent: 0
};
this.Width = 0;
}
else
{
......@@ -892,6 +932,8 @@ CMathAmp.prototype =
height: this.AmpText.size.height,
ascent: this.AmpText.size.ascent
};
this.Width = this.AmpText.Width;
}
},
......@@ -904,14 +946,14 @@ CMathAmp.prototype =
getCodeChr: function()
{
var code = null;
if(!this.bEqqArray)
if(!this.bEqArray)
code = this.AmpText.getCodeChr();
return code;
},
IsText: function()
{
return !this.bEqqArray;
return !this.bEqArray;
},
Get_WidthVisible: function()
{
......@@ -922,13 +964,13 @@ CMathAmp.prototype =
this.pos.x = pos.x;
this.pos.y = pos.y;
if(this.bEqqArray==false)
if(this.bEqArray==false)
this.AmpText.setPosition(pos);
},
draw: function(x, y, pGraphics, InfoTextPr)
Draw: function(x, y, pGraphics, InfoTextPr)
{
if(this.bEqqArray==false)
this.AmpText.draw(x + this.GapLeft, y, pGraphics, InfoTextPr);
if(this.bEqArray==false)
this.AmpText.Draw(x + this.GapLeft, y, pGraphics, InfoTextPr);
else if(editor.ShowParaMarks) // показать метки выравнивания, если включена отметка о знаках параграфа
{
var X = x + this.pos.x + this.size.width,
......@@ -938,6 +980,15 @@ CMathAmp.prototype =
pGraphics.drawVerLine(0, X, Y, Y2, 0.1);
}
},
GetLocationOfLetter: function()
{
var pos = new CMathPosition();
pos.x = this.pos.x;
pos.y = this.pos.y;
return pos;
},
IsPlaceholder: function()
{
return false;
......@@ -952,11 +1003,15 @@ CMathAmp.prototype =
},
IsAlignPoint: function()
{
return this.bEqqArray;
return this.bEqArray;
},
Copy : function()
{
return new CMathAmp();
},
Can_AddNumbering: function()
{
return false;
},
Write_ToBinary : function(Writer)
{
......@@ -1129,7 +1184,7 @@ var MathTextInfo_MathText = 1;
var MathTextInfo_SpecialOperator = 2;
var MathTextInfo_NormalText = 3;
function CMathInfoTextPr_2(TextPr, ArgSize, bNormalText)
function CMathInfoTextPr_2(TextPr, ArgSize, bNormalText, bEqArray)
{
this.CurrType = -1; // в первый раз Font всегда выставляем
this.TextPr = TextPr;
......@@ -1143,6 +1198,7 @@ function CMathInfoTextPr_2(TextPr, ArgSize, bNormalText)
};
this.bNormalText = bNormalText;
this.bEqArray = bEqArray;
this.RFontsCompare = [];
......@@ -1208,4 +1264,4 @@ CMathInfoTextPr_2.prototype.IsSpecilalOperator = function(val)
// отдельно Cambria Math 0x27
return bSpecialOperator || bSpecialArrow || bSpecialSymbols || bOtherArrows;
}
\ No newline at end of file
};
\ No newline at end of file
......@@ -18,6 +18,7 @@ var MATH_BAR = 14;
var MATH_PHANTOM = 15;
var MATH_RUN = 16;
var MATH_PRIMARY_LIMIT = 17;
var BAR_FRACTION = 0;
var SKEWED_FRACTION = 1;
......
......@@ -462,7 +462,7 @@ CMathMatrix.prototype.init = function(props)
this.fillContent();
}
CMathMatrix.prototype.setPosition = function(pos, PosInfo)
CMathMatrix.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
......@@ -479,22 +479,23 @@ CMathMatrix.prototype.setPosition = function(pos, PosInfo)
var h = 0, w = 0;
for(var i=0; i < this.nRow; i++)
{
w = 0;
for(var j = 0; j < this.nCol; j++)
{
var Item = this.elements[i][j];
var al = this.align(i, j);
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 + Item.size.ascent;
this.elements[i][j].setPosition(NewPos, PosInfo);
Item.setPosition(NewPos, PDSE);
w += Widths[j] + this.gaps.column[j];
}
h += Heights[i] + this.gaps.row[i];
}
pos.x += this.size.width;
}
CMathMatrix.prototype.getMetrics = function(RPI)
{
......@@ -722,14 +723,23 @@ CEqArray.prototype.fillContent = function()
for (var nIndex = 0; nIndex < nRowsCount; nIndex++)
this.elements[nIndex][0] = this.Content[nIndex];
};
/*CEqArray.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
PRS.bMath_OneLine = true;
for (var Pos = 0, Count = this.Content.length; Pos < Count; Pos++)
this.Content[Pos].Recalculate_Range(PRS, ParaPr, Depth);
this.recalculateSize(g_oTextMeasurer);
};*/
CEqArray.prototype.Resize = function(oMeasure, RPI)
{
// на случай, чтобы не затереть массив
//var CurrAmperWPoints = RPI.AmperWPoints,
// CurrEqqArray = RPI.bEqqArray;
// CurrEqArray = RPI.bEqArray;
var NewRPI = RPI.Copy();
NewRPI.bEqqArray = true;
NewRPI.bEqArray = true;
for(var i = 0; i < this.nRow; i++)
this.elements[i][0].Resize(oMeasure, NewRPI);
......@@ -772,7 +782,7 @@ CEqArray.prototype.getMetrics = function()
for(var i = 0; i < this.nRow; i++)
{
var WidthsRow = this.elements[i][0].getWidthsPoints(),
var WidthsRow = this.elements[i][0].Get_WidthPoints().Widths,
len = WidthsRow.length;
if(Pos < len)
......@@ -784,7 +794,7 @@ CEqArray.prototype.getMetrics = function()
maxDim = WidthsRow[Pos].even < WidthsRow[Pos].odd ? WidthsRow[Pos].odd : WidthsRow[Pos].even;
maxDimWidth = WidthsRow[Pos].even + WidthsRow[Pos].odd;
}
even = even > WidthsRow[Pos].even ? even : WidthsRow[Pos].even; // before "odd"
even = even > WidthsRow[Pos].even ? even : WidthsRow[Pos].even; // before "odd"
odd = odd > WidthsRow[Pos].odd ? odd : WidthsRow[Pos].odd; // after "odd"
}
else
......@@ -848,11 +858,8 @@ CEqArray.prototype.getMetrics = function()
return {ascents: AscentsMetrics, descents: DescentsMetrics, widths: WidthsMetrics};
}
CEqArray.prototype.setPosition = function(pos)
CEqArray.prototype.setPosition = function(pos, PDSE)
{
//PosInfo.Widths = this.WidthsPoints;
//PosInfo.Points = this.Points;
this.pos.x = pos.x;
if(this.bInside === true)
......@@ -869,19 +876,16 @@ CEqArray.prototype.setPosition = function(pos)
for(var i=0; i < this.nRow; i++)
{
var Item = this.elements[i][0];
NewPos.x = this.pos.x + this.GapLeft;
NewPos.y = this.pos.y + h;
//PosInfo.CurrPoint = 0;
this.elements[i][0].setPosition(NewPos);
NewPos.y = this.pos.y + h + Item.size.ascent;
Item.setPosition(NewPos, PDSE);
h += Heights[i] + this.gaps.row[i];
}
//PosInfo.Widths.length = 0;
//PosInfo.Points.length = 0;
pos.x += this.size.width;
}
CEqArray.prototype.getElement = function(num)
{
......@@ -896,4 +900,8 @@ CEqArray.prototype.Document_UpdateInterfaceState = function(MathProps)
MathProps.Type = c_oAscMathInterfaceType.EqArray;
MathProps.Pr = null;
};
CEqArray.prototype.IsEqArray = function()
{
return true;
};
......@@ -625,31 +625,35 @@ CNaryUndOvr.prototype.recalculateSize = function()
this.size = {width: width, height: height, ascent: ascent};
}
CNaryUndOvr.prototype.setPosition = function(pos, PosInfo)
CNaryUndOvr.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
this.pos.y = pos.y;
var UpIter = this.elements[0][0],
Sign = this.elements[1][0],
LowIter = this.elements[2][0];
var PosUpIter = new CMathPosition();
PosUpIter.x = pos.x + this.GapLeft + this.align(0,0).x;
PosUpIter.y = pos.y;
PosUpIter.y = pos.y + UpIter.size.ascent;
var PosSign = new CMathPosition();
PosSign.x = pos.x + this.GapLeft + this.align(1,0).x;
PosSign.y = pos.y + this.elements[0][0].size.height + this.gapTop;
PosSign.y = pos.y + UpIter.size.height + this.gapTop;
var PosLowIter = new CMathPosition();
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 + Sign.size.height + this.gapBottom + LowIter.size.ascent;
this.elements[0][0].setPosition(PosUpIter, PosInfo);
this.elements[1][0].setPosition(PosSign, PosInfo);
this.elements[2][0].setPosition(PosLowIter, PosInfo);
UpIter.setPosition(PosUpIter, PDSE);
Sign.setPosition(PosSign, PDSE);
LowIter.setPosition(PosLowIter, PDSE);
}
CNaryUndOvr.prototype.setBase = function(base)
{
......@@ -680,16 +684,18 @@ function CNaryOperator(flip)
this.bFlip = (flip == -1);
this.sizeGlyph = null;
}
CNaryOperator.prototype.draw = function(x, y, pGraphics, PDSE)
CNaryOperator.prototype.Draw_Elements = function(PDSE)
{
this.Parent.Make_ShdColor(PDSE, this.Parent.Get_CompiledCtrPrp());
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
if(this.Type == para_Math_Text)
this.drawTextElem(x, y, pGraphics);
this.drawTextElem(PosLine.x, PosLine.y, PDSE.Graphics);
else
this.drawGlyph(x, y, pGraphics);
this.drawGlyph(PosLine.x, PosLine.y, PDSE.Graphics);
}
CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics)
CNaryOperator.prototype.drawGlyph = function(x, y, pGraphics)
{
var coord = this.getCoord();
......@@ -778,7 +784,7 @@ CNaryOperator.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
this.Parent = Parent;
this.ParaMath = ParaMath;
}
CNaryOperator.prototype.Resize = function(oMeasure, RPI)
CNaryOperator.prototype.Measure = function(oMeasure, RPI)
{
this.recalculateSize(); //обычный пересчет, oMeasure не нужен
}
......
......@@ -2957,7 +2957,7 @@ COperator.prototype.draw = function(x, y, pGraphics, PDSE)
////////////////////////////////////////////////
this.operator.draw(x, y, pGraphics, PDSE);
this.operator.Draw(x, y, pGraphics, PDSE);
}
else
{
......@@ -3055,7 +3055,7 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
// Width
if(this.typeOper == OPERATOR_TEXT) // отдельный случай для текста в качестве оператора
{
this.operator.Resize(oMeasure, this);
this.operator.Measure(oMeasure, ctrPrp);
width = this.operator.size.width;
}
else
......@@ -3083,13 +3083,13 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
var letterOperator = new CMathText(true);
letterOperator.add(this.code);
letterOperator.Resize(oMeasure, null);
letterOperator.Measure(oMeasure, ctrPrp);
if(this.type === OPER_ACCENT)
{
var letterX = new CMathText(true);
letterX.add(0x78);
letterX.Resize(oMeasure, null);
letterX.Measure(oMeasure, ctrPrp);
height = letterOperator.size.ascent - letterX.size.ascent;
}
......@@ -3613,9 +3613,127 @@ CDelimiter.prototype.Resize = function(oMeasure, RPI)
}
}
this.size = {width: width, height: height, ascent: ascent};
this.size.width = width;
this.size.height = height;
this.size.ascent = ascent;
}
CDelimiter.prototype.recalculateSize = function(oMeasure)
{
// размеры аргумента
var heightG = 0, widthG = 0,
ascentG = 0, descentG = 0;
// Аргумент
for(var j = 0; j < this.nCol; j++)
{
var content = this.elements[0][j].size;
widthG += content.width;
ascentG = content.ascent > ascentG ? content.ascent : ascentG;
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);
// Общая ширина
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;
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};
};
CDelimiter.prototype.alignOperator = function(operator) // в качестве аргумента передаем высоту оператора
{
var align = 0;
......@@ -3649,7 +3767,7 @@ CDelimiter.prototype.alignOperator = function(operator) // в качестве
return align;
}
CDelimiter.prototype.setPosition = function(position, PosInfo)
CDelimiter.prototype.setPosition = function(position, PDSE)
{
this.pos.x = position.x;
this.pos.y = position.y - this.size.ascent;
......@@ -3669,10 +3787,10 @@ CDelimiter.prototype.setPosition = function(position, PosInfo)
var PosContent = new CMathPosition();
PosContent.x = x;
PosContent.y = y + this.align_2(content);
PosContent.y = y + this.align_2(content) + content.size.ascent;
x += content.size.width;
content.setPosition(PosContent, PosInfo); // CMathContent
content.setPosition(PosContent, PDSE); // CMathContent
var Positions = [];
......@@ -3689,9 +3807,9 @@ CDelimiter.prototype.setPosition = function(position, PosInfo)
var NewPosContent = new CMathPosition();
NewPosContent.x = x;
NewPosContent.y = y + this.align_2(content);
NewPosContent.y = y + this.align_2(content) + content.size.ascent;
content.setPosition(NewPosContent, PosInfo);
content.setPosition(NewPosContent, PDSE);
x += content.size.width;
}
......@@ -3703,30 +3821,18 @@ CDelimiter.prototype.setPosition = function(position, PosInfo)
this.endOper.setPosition(PosEndOper);
/*this.pos.x = position.x;
this.pos.y = position.y - this.size.ascent;
var x = this.pos.x + this.GapLeft,
y = this.pos.y;
var content = this.elements[0][0];
var PosContent = new CMathPosition();
PosContent.x = x;
PosContent.y = y + this.align(content);
x += content.size.width;
content.setPosition(PosContent); // CMathContent*/
position.x += this.size.width;
}
CDelimiter.prototype.draw = function(x, y, pGraphics, PDSE)
CDelimiter.prototype.Draw_Elements = function(PDSE)
{
this.begOper.draw(x, y, pGraphics, PDSE);
this.sepOper.draw(x, y, pGraphics, PDSE);
this.endOper.draw(x, y, pGraphics, PDSE);
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
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);
for(var j = 0; j < this.nCol; j++)
this.elements[0][j].draw(x, y,pGraphics, PDSE);
this.elements[0][j].Draw_Elements(PDSE);
}
CDelimiter.prototype.align_2 = function(element)
{
......@@ -3801,22 +3907,21 @@ CCharacter.prototype.setCharacter = function(props, defaultProps)
{
this.operator.mergeProperties(props, defaultProps);
}
CCharacter.prototype.Resize = function(oMeasure, RPI)
CCharacter.prototype.recalculateSize = function(oMeasure)
{
var base = this.elements[0][0];
base.Resize(oMeasure, RPI);
var Base = this.Content[0];
this.operator.fixSize(oMeasure, base.size.width);
this.operator.fixSize(oMeasure, Base.size.width);
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
height = base.size.height + this.operator.size.height,
var width = Base.size.width > this.operator.size.width ? Base.size.width : this.operator.size.width,
height = Base.size.height + this.operator.size.height,
ascent = this.getAscent(oMeasure);
width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent};
}
CCharacter.prototype.setPosition = function(pos, PosInfo)
CCharacter.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -3829,6 +3934,8 @@ CCharacter.prototype.setPosition = function(pos, PosInfo)
var PosOper = new CMathPosition(),
PosBase = new CMathPosition();
var Base = this.Content[0];
if(this.Pr.pos === LOCATION_TOP)
{
PosOper.x = this.pos.x + this.GapLeft + alignOp;
......@@ -3837,26 +3944,28 @@ CCharacter.prototype.setPosition = function(pos, PosInfo)
this.operator.setPosition(PosOper);
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 + Base.size.ascent;
this.elements[0][0].setPosition(PosBase, PosInfo);
Base.setPosition(PosBase, PDSE);
}
else if(this.Pr.pos === LOCATION_BOT)
{
PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y;
PosBase.y = this.pos.y + Base.size.ascent;
this.elements[0][0].setPosition(PosBase, PosInfo);
Base.setPosition(PosBase, PDSE);
PosOper.x = this.pos.x + this.GapLeft + alignOp;
PosOper.y = this.pos.y + this.elements[0][0].size.height;
PosOper.y = this.pos.y + Base.size.height;
this.operator.setPosition(PosOper);
}
pos.x += this.size.width;
}
CCharacter.prototype.draw = function(x, y, pGraphics, PDSE)
CCharacter.prototype.Draw_Elements = function(PDSE)
{
this.elements[0][0].draw(x, y, pGraphics, PDSE);
this.Content[0].Draw_Elements(PDSE);
var ctrPrp = this.Get_TxtPrControlLetter();
......@@ -3869,11 +3978,11 @@ CCharacter.prototype.draw = function(x, y, pGraphics, PDSE)
};
pGraphics.SetFont(Font);
PDSE.Graphics.SetFont(Font);
//this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
this.operator.draw(x, y, pGraphics, PDSE);
this.operator.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
}
CCharacter.prototype.getBase = function()
......
......@@ -497,17 +497,8 @@ CRadical.prototype.ApplyProperties = function(RPI)
this.RecalcInfo.bProps = false;
}
}
CRadical.prototype.Resize = function(oMeasure, RPI)
CRadical.prototype.recalculateSize = function(oMeasure)
{
if(this.Pr.type == SQUARE_RADICAL)
this.RealBase.Resize(oMeasure, RPI);
else
{
this.Iterator.Resize(oMeasure, RPI);
this.RealBase.Resize(oMeasure, RPI);
}
var shTop,
height, width, ascent;
......@@ -516,7 +507,7 @@ CRadical.prototype.Resize = function(oMeasure, RPI)
var txtPrp = this.Get_CompiledCtrPrp();
var sign = this.signRadical.size,
gSign = this.signRadical.gapSign,
// в случае смещения baseline контента тоже смещается, и по высоте артгумент может выйти чуть за пределы (т.о. значок интеграла будет расположен чуть выше, чем следовало бы, и размер аргумента выйде за границы)
// в случае смещения baseline контента тоже смещается, и по высоте артгумент может выйти чуть за пределы (т.о. значок интеграла будет расположен чуть выше, чем следовало бы, и размер аргумента выйде за границы)
gArg = this.signRadical.gapArg > 2*g_dKoef_pt_to_mm ? this.signRadical.gapArg : 2*g_dKoef_pt_to_mm; // делаем смещение, т.к. для fontSize 11, 14 и меньше высота плейсхолдера не совпадает
// с высотой отрисовки плейсхолдера и происходит наложение черты значка радикала и плейсхолдера
......@@ -530,10 +521,9 @@ CRadical.prototype.Resize = function(oMeasure, RPI)
ascent = gapBase + shTop + this.RealBase.size.ascent;
height = sign.height > ascent - this.RealBase.size.ascent + this.RealBase.size.height ? sign.height : ascent - this.RealBase.size.ascent + this.RealBase.size.height ;
height = sign.height > ascent - this.RealBase.size.ascent + this.RealBase.size.height ? sign.height : ascent - this.RealBase.size.ascent + this.RealBase.size.height;
width = sign.width;
//ascent = height - (base.height - base.ascent);
width += this.GapLeft + this.GapRight;
......@@ -585,7 +575,19 @@ CRadical.prototype.Resize = function(oMeasure, RPI)
this.size = {width: width, height: height, ascent: ascent};
}
}
CRadical.prototype.setPosition = function(pos, PosInfo)
CRadical.prototype.Resize = function(oMeasure, RPI)
{
if(this.Pr.type == SQUARE_RADICAL)
this.RealBase.Resize(oMeasure, RPI);
else
{
this.Iterator.Resize(oMeasure, RPI);
this.RealBase.Resize(oMeasure, RPI);
}
this.recalculateSize(oMeasure);
}
CRadical.prototype.setPosition = function(pos, PDSE)
{
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
......@@ -602,10 +604,10 @@ CRadical.prototype.setPosition = function(pos, PosInfo)
PosRadical.y = this.pos.y;
PosBase.x = this.pos.x + gapLeft;
PosBase.y = this.pos.y + gapTop;
PosBase.y = this.pos.y + gapTop + this.RealBase.size.ascent;
this.signRadical.setPosition(PosRadical);
this.RealBase.setPosition(PosBase, PosInfo);
this.RealBase.setPosition(PosBase, PDSE);
}
else if(this.Pr.type == DEGREE_RADICAL)
{
......@@ -614,9 +616,9 @@ CRadical.prototype.setPosition = function(pos, PosInfo)
var PosDegree = new CMathPosition();
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.size.ascent;
this.Iterator.setPosition(PosDegree, PosInfo);
this.Iterator.setPosition(PosDegree, PDSE);
var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0;
......@@ -626,15 +628,19 @@ CRadical.prototype.setPosition = function(pos, PosInfo)
this.signRadical.setPosition(PosRadical);
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.setPosition(PosBase, PosInfo);
this.RealBase.setPosition(PosBase, PDSE);
}
pos.x += this.size.width;
}
CRadical.prototype.draw = function(x, y, pGraphics, PDSE)
CRadical.prototype.Draw_Elements = function(PDSE)
{
this.signRadical.draw(x, y, pGraphics, PDSE);
CRadical.superclass.draw.call(this, x, y, pGraphics, PDSE);
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
this.signRadical.draw(PosLine.x, PosLine.y, PDSE.Graphics, PDSE);
CRadical.superclass.Draw_Elements.call(this, PDSE);
}
CRadical.prototype.getBase = function()
{
......
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