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

1. Реализовала функцию для мержа текстовых настроек для управляющих элементов...

1. Реализовала функцию для мержа текстовых настроек для управляющих элементов объектов (текстовые свойства для управляющих элементов зависят от тестовых настроек первого Run)
2. На Resize сначала компилируем ArgSize каждого контента, TxtPrp для управляющих элементов и CtrPrp, вычисляем Gaps, затем делаем Recalculate
3. Поправила баг : при запросе Get_CompiledTextPr менялись скомпилированные настройки у пустого рана (из-за этого было падение при смене размера шрифта из меню)
4. Поправила свойство Delimiters при чтении файла
5. При добавлении сложных объектов (n-арных объектов, дробей и др) в итераторы N-арных операторов, итераторы степеней
6. Поправила баг : когда ctrPrp у степени больше TxtPrp итераторов, итераторы разъезжались у DegreeSupSub (беру смерженные ctrPrp для плейсхолдеров)
7. На Split матрицы копирую св-во Jc


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58950 954022d7-b5bf-4e40-9824-e11837661b57
parent 635d70c9
...@@ -58,7 +58,7 @@ function ParaMath() ...@@ -58,7 +58,7 @@ function ParaMath()
this.DefaultTextPr = new CTextPr(); this.DefaultTextPr = new CTextPr();
this.DefaultTextPr.Italic = true; this.DefaultTextPr.FontSize = 11;
this.DefaultTextPr.FontFamily = {Name : "Cambria Math", Index : -1 }; this.DefaultTextPr.FontFamily = {Name : "Cambria Math", Index : -1 };
this.DefaultTextPr.RFonts.Set_All("Cambria Math", -1); this.DefaultTextPr.RFonts.Set_All("Cambria Math", -1);
...@@ -150,13 +150,13 @@ ParaMath.prototype.Get_CompiledTextPr = function(Copy) ...@@ -150,13 +150,13 @@ ParaMath.prototype.Get_CompiledTextPr = function(Copy)
{ {
// TODO: ParaMath.Get_CompiledTextPr // TODO: ParaMath.Get_CompiledTextPr
var TextPr = new CTextPr(); //var TextPr = new CTextPr();
var oContent = this.GetSelectContent(); var oContent = this.GetSelectContent();
var mTextPr = oContent.Content.Get_CompiledTextPr(Copy); var mTextPr = oContent.Content.Get_CompiledTextPr(Copy);
TextPr.Merge( mTextPr ); //TextPr.Merge( mTextPr );
return TextPr; return mTextPr;
}; };
ParaMath.prototype.Add = function(Item) ParaMath.prototype.Add = function(Item)
...@@ -379,11 +379,23 @@ ParaMath.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll) ...@@ -379,11 +379,23 @@ ParaMath.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll)
else else
{ {
var content = this.GetSelectContent().Content; var content = this.GetSelectContent().Content;
var FontSize = TextPr.FontSize;
if(TextPr.FontSize !== undefined && content.IsNormalTextInRuns() == false)
{
var NewTextPr = new CTextPr();
NewTextPr.FontSize = FontSize;
this.Root.Apply_TextPr(NewTextPr, IncFontSize, true);
TextPr.FontSize = undefined;
}
content.Apply_TextPr(TextPr, IncFontSize, ApplyToAll); content.Apply_TextPr(TextPr, IncFontSize, ApplyToAll);
}
TextPr.FontSize = FontSize;
}
}; };
ParaMath.prototype.Clear_TextPr = function() ParaMath.prototype.Clear_TextPr = function()
{ {
...@@ -522,7 +534,8 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -522,7 +534,8 @@ ParaMath.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if(RPI.NeedResize) if(RPI.NeedResize)
{ {
this.Root.Resize(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize); this.Root.PreRecalc(null, this, ArgSize, RPI);
this.Root.Resize(g_oTextMeasurer, RPI/*recalculate properties info*/);
// когда формула будеат разбиваться на строки, Position придется перерасчитывать // когда формула будеат разбиваться на строки, Position придется перерасчитывать
var pos = new CMathPosition(); var pos = new CMathPosition();
pos.x = 0; pos.x = 0;
...@@ -900,7 +913,11 @@ ParaMath.prototype.SetInline = function(value) ...@@ -900,7 +913,11 @@ ParaMath.prototype.SetInline = function(value)
ParaMath.prototype.SetNeedResize = function() ParaMath.prototype.SetNeedResize = function()
{ {
this.NeedResize = true; this.NeedResize = true;
} };
ParaMath.prototype.NeedCompiledCtrPr = function()
{
this.Root.NeedCompiledCtrPr();
};
ParaMath.prototype.MathToImageConverter= function() ParaMath.prototype.MathToImageConverter= function()
{ {
window.IsShapeToImageConverter = true; window.IsShapeToImageConverter = true;
...@@ -1497,6 +1514,7 @@ ParaMath.prototype.Split = function (ContentPos, Depth) ...@@ -1497,6 +1514,7 @@ ParaMath.prototype.Split = function (ContentPos, Depth)
if(this.Root.content[Pos].Type == para_Math_Run) if(this.Root.content[Pos].Type == para_Math_Run)
{ {
NewParaMath = new ParaMath(); NewParaMath = new ParaMath();
NewParaMath.Jc = this.Jc;
var NewRun = this.Root.content[Pos].Split(ContentPos, Depth+1); var NewRun = this.Root.content[Pos].Split(ContentPos, Depth+1);
NewParaMath.Root.Add_ToContent(0, NewRun); NewParaMath.Root.Add_ToContent(0, NewRun);
......
...@@ -7793,7 +7793,7 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics) ...@@ -7793,7 +7793,7 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
for(var i=0; i < this.Content.length;i++) for(var i=0; i < this.Content.length;i++)
this.Content[i].draw(X, Y, pGraphics); this.Content[i].draw(X, Y, pGraphics);
} }
ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ArgSize, WidthPoints) ParaRun.prototype.Math_Recalculate = function(oMeasure, RPI, WidthPoints)
{ {
// пересчет элементов контента в Run // пересчет элементов контента в Run
// Recalculate_MeasureContent // Recalculate_MeasureContent
...@@ -7809,8 +7809,8 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7809,8 +7809,8 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
var RangeEndPos = this.Content.length; var RangeEndPos = this.Content.length;
this.Paragraph = Paragraph; //this.Paragraph = Paragraph;
this.Parent = Parent; //this.Parent = Parent;
// обновляем позиции start и end для Range // обновляем позиции start и end для Range
//this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos); //this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos);
...@@ -7857,7 +7857,7 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI, ...@@ -7857,7 +7857,7 @@ ParaRun.prototype.Math_Recalculate = function(oMeasure, Parent, Paragraph, RPI,
for (var i = 0 ; i < Lng; i++) for (var i = 0 ; i < Lng; i++)
{ {
this.Content[i].Resize(oMeasure, this, RPI); this.Content[i].Resize(oMeasure, RPI);
var oSize = this.Content[i].size; var oSize = this.Content[i].size;
...@@ -7951,6 +7951,21 @@ ParaRun.prototype.Math_SetGaps = function(GapsInfo) ...@@ -7951,6 +7951,21 @@ ParaRun.prototype.Math_SetGaps = function(GapsInfo)
} }
} }
} }
ParaRun.prototype.Math_PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
this.Paragraph = ParaMath.Paragraph;
var FontSize = this.Get_CompiledPr(false).FontSize;
for (var Pos = 0 ; Pos < this.Content.length; Pos++ )
{
if( !this.Content[Pos].IsAlignPoint() )
GapsInfo.setGaps(this.Content[Pos], FontSize);
this.Content[Pos].PreRecalc(this);
}
}
ParaRun.prototype.IsPlaceholder = function() ParaRun.prototype.IsPlaceholder = function()
{ {
return this.Content.length == 1 && this.Content[0].IsPlaceholder(); return this.Content.length == 1 && this.Content[0].IsPlaceholder();
...@@ -8004,6 +8019,10 @@ ParaRun.prototype.Math_GetInfoLetter = function(Info) ...@@ -8004,6 +8019,10 @@ ParaRun.prototype.Math_GetInfoLetter = function(Info)
else else
Info.Result = false; Info.Result = false;
} }
ParaRun.IsNormalText = function()
{
return this.MathPrp.nor === true;
}
function CParaRunStartState(Run) function CParaRunStartState(Run)
{ {
......
...@@ -22,7 +22,7 @@ function CAccentCircumflex() ...@@ -22,7 +22,7 @@ function CAccentCircumflex()
Asc.extendClass(CAccentCircumflex, CGlyphOperator); Asc.extendClass(CAccentCircumflex, CGlyphOperator);
CAccentCircumflex.prototype.calcSize = function(stretch) CAccentCircumflex.prototype.calcSize = function(stretch)
{ {
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36; var alpha = this.Parent.GetTPrpToControlLetter().FontSize/36;
var width = 3.88*alpha; var width = 3.88*alpha;
var height = 3.175*alpha; var height = 3.175*alpha;
...@@ -40,7 +40,7 @@ CAccentCircumflex.prototype.calcSize = function(stretch) ...@@ -40,7 +40,7 @@ CAccentCircumflex.prototype.calcSize = function(stretch)
} }
CAccentCircumflex.prototype.calcCoord = function(stretch) CAccentCircumflex.prototype.calcCoord = function(stretch)
{ {
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize; var fontSize = this.Parent.GetTPrpToControlLetter().FontSize;
//var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W; //var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
//penW *= 96/25.4; //penW *= 96/25.4;
...@@ -126,7 +126,7 @@ function CAccentLine() ...@@ -126,7 +126,7 @@ function CAccentLine()
Asc.extendClass(CAccentLine, CGlyphOperator); Asc.extendClass(CAccentLine, CGlyphOperator);
CAccentLine.prototype.calcSize = function(stretch) CAccentLine.prototype.calcSize = function(stretch)
{ {
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36; var alpha = this.Parent.GetTPrpToControlLetter().FontSize/36;
var height = 1.68*alpha; var height = 1.68*alpha;
var width = 4.938*alpha; var width = 4.938*alpha;
...@@ -135,37 +135,9 @@ CAccentLine.prototype.calcSize = function(stretch) ...@@ -135,37 +135,9 @@ CAccentLine.prototype.calcSize = function(stretch)
return {width: width, height: height}; return {width: width, height: height};
} }
CAccentLine.prototype.old_calcCoord = function(stretch)
{
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var X = [],
Y = [];
//stretch *= 0.9;
X[0] = 0; Y[0] = 0;
X[1] = stretch; Y[1] = 0;
X[2] = stretch; Y[2] = 0.011*fontSize;
X[3] = 0; Y[3] = Y[2];
X[4] = 0; Y[4] = 0;
var W = X[2],
H = Y[2];
return {XX: X, YY: Y, W: W, H: H};
}
CAccentLine.prototype.old_drawPath = function(pGraphics, XX, YY)
{
pGraphics._m(XX[0], YY[0]);
pGraphics._l(XX[1], YY[1]);
pGraphics._l(XX[2], YY[2]);
pGraphics._l(XX[3], YY[3]);
pGraphics._l(XX[4], YY[4]);
}
CAccentLine.prototype.draw = function(x, y, pGraphics) CAccentLine.prototype.draw = function(x, y, pGraphics)
{ {
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize; var fontSize = this.Parent.GetTPrpToControlLetter().FontSize;
var penW = fontSize*0.067 * 25.4/96; var penW = fontSize*0.067 * 25.4/96;
var x1 = x + 25.4/96, var x1 = x + 25.4/96,
...@@ -184,7 +156,7 @@ function CAccentDoubleLine() ...@@ -184,7 +156,7 @@ function CAccentDoubleLine()
Asc.extendClass(CAccentDoubleLine, CGlyphOperator); Asc.extendClass(CAccentDoubleLine, CGlyphOperator);
CAccentDoubleLine.prototype.calcSize = function(stretch) CAccentDoubleLine.prototype.calcSize = function(stretch)
{ {
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36; var alpha = this.Parent.GetTPrpToControlLetter().FontSize/36;
var height = 2.843*alpha; var height = 2.843*alpha;
var width = 4.938*alpha; var width = 4.938*alpha;
...@@ -205,7 +177,7 @@ CAccentDoubleLine.prototype.calcSize = function(stretch) ...@@ -205,7 +177,7 @@ CAccentDoubleLine.prototype.calcSize = function(stretch)
} }
CAccentDoubleLine.prototype.old_calcCoord = function(stretch) CAccentDoubleLine.prototype.old_calcCoord = function(stretch)
{ {
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize; var fontSize = this.Parent.GetTPrpToControlLetter().FontSize;
var X = [], var X = [],
Y = []; Y = [];
...@@ -246,7 +218,7 @@ CAccentDoubleLine.prototype.old_drawPath = function(pGraphics, XX, YY) ...@@ -246,7 +218,7 @@ CAccentDoubleLine.prototype.old_drawPath = function(pGraphics, XX, YY)
} }
CAccentDoubleLine.prototype.draw = function(x, y, pGraphics) CAccentDoubleLine.prototype.draw = function(x, y, pGraphics)
{ {
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize; var fontSize = this.Parent.GetTPrpToControlLetter().FontSize;
var diff = this.diff; var diff = this.diff;
...@@ -273,7 +245,7 @@ function CAccentTilde() ...@@ -273,7 +245,7 @@ function CAccentTilde()
Asc.extendClass(CAccentTilde, CGlyphOperator); Asc.extendClass(CAccentTilde, CGlyphOperator);
CAccentTilde.prototype.calcSize = function(stretch) CAccentTilde.prototype.calcSize = function(stretch)
{ {
var betta = this.Parent.Get_CompiledCtrPrp().FontSize/36; var betta = this.Parent.GetTPrpToControlLetter().FontSize/36;
var width = 9.047509765625*betta; // реальная на отрисовке width 7.495282031249999 var width = 9.047509765625*betta; // реальная на отрисовке width 7.495282031249999
var height = 2.469444444444444*betta; var height = 2.469444444444444*betta;
...@@ -326,7 +298,7 @@ CAccentTilde.prototype.calcCoord = function(stretch) ...@@ -326,7 +298,7 @@ CAccentTilde.prototype.calcCoord = function(stretch)
var XX = [], var XX = [],
YY = []; YY = [];
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize; var fontSize = this.Parent.GetTPrpToControlLetter().FontSize;
var textScale = fontSize/1000, // 1000 pt var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96 alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
...@@ -373,7 +345,7 @@ function CAccentBreve() ...@@ -373,7 +345,7 @@ function CAccentBreve()
Asc.extendClass(CAccentBreve, CGlyphOperator); Asc.extendClass(CAccentBreve, CGlyphOperator);
CAccentBreve.prototype.calcSize = function(stretch) CAccentBreve.prototype.calcSize = function(stretch)
{ {
var betta = this.Parent.Get_CompiledCtrPrp().FontSize/36; var betta = this.Parent.GetTPrpToControlLetter().FontSize/36;
var width = 4.2333333333333325*betta; var width = 4.2333333333333325*betta;
var height = 2.469444444444445*betta; var height = 2.469444444444445*betta;
...@@ -413,7 +385,7 @@ CAccentBreve.prototype.calcCoord = function(stretch) ...@@ -413,7 +385,7 @@ CAccentBreve.prototype.calcCoord = function(stretch)
var XX = [], var XX = [],
YY = []; YY = [];
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize; var fontSize = this.Parent.GetTPrpToControlLetter().FontSize;
var textScale = fontSize/1000, // 1000 pt var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96 alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
...@@ -567,13 +539,8 @@ CAccent.prototype.setPosition = function(pos, PosInfo) ...@@ -567,13 +539,8 @@ CAccent.prototype.setPosition = function(pos, PosInfo)
this.elements[0][0].setPosition(PosBase, PosInfo); this.elements[0][0].setPosition(PosBase, PosInfo);
} }
CAccent.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CAccent.prototype.ApplyProperties = function(RPI)
{ {
this.Parent = Parent;
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(ParaMath);
if(this.RecalcInfo.bProps == true) if(this.RecalcInfo.bProps == true)
{ {
var prp = var prp =
...@@ -583,25 +550,26 @@ CAccent.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -583,25 +550,26 @@ CAccent.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
loc: LOCATION_TOP loc: LOCATION_TOP
}; };
var defaultPrp = var defaultPrp = {type: ACCENT_CIRCUMFLEX };
{
type: ACCENT_CIRCUMFLEX
};
this.operator.mergeProperties(prp, defaultPrp); this.operator.mergeProperties(prp, defaultPrp);
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
}
CAccent.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
this.operator.PreRecalc(this, ParaMath);
this.operator.relate(this); CAccent.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
}
var base = this.elements[0][0]; CAccent.prototype.Resize = function(oMeasure, RPI)
base.Resize(oMeasure, this, ParaMath, RPI, ArgSize); {
var base = this.getBase();
var ctrPrp = this.Get_CompiledCtrPrp(); base.Resize(oMeasure, RPI);
oMeasure.SetFont(ctrPrp);
this.operator.fixSize(ParaMath, oMeasure, base.size.width); this.operator.fixSize(oMeasure, base.size.width);
var width = base.size.width, // (!) var width = base.size.width, // (!)
height = base.size.height + this.operator.size.height, height = base.size.height + this.operator.size.height,
......
...@@ -13,6 +13,7 @@ function CMathBase(bInside) ...@@ -13,6 +13,7 @@ function CMathBase(bInside)
this.CtrPrp = new CTextPr(); this.CtrPrp = new CTextPr();
this.CompiledCtrPrp = new CTextPr(); this.CompiledCtrPrp = new CTextPr();
this.TextPrControlLetter = new CTextPr();
this.ArgSize = new CMathArgSize(); this.ArgSize = new CMathArgSize();
...@@ -97,7 +98,6 @@ CMathBase.prototype = ...@@ -97,7 +98,6 @@ CMathBase.prototype =
if(txtPrp !== null && typeof(txtPrp) !== "undefined") if(txtPrp !== null && typeof(txtPrp) !== "undefined")
{ {
this.CtrPrp.Merge(txtPrp); this.CtrPrp.Merge(txtPrp);
this.CtrPrp.FontFamily = {Name : "Cambria Math", Index : -1 };
} }
}, },
Get_CtrPrp: function() Get_CtrPrp: function()
...@@ -110,6 +110,16 @@ CMathBase.prototype = ...@@ -110,6 +110,16 @@ CMathBase.prototype =
return CtrPrp; return CtrPrp;
}, },
NeedCompiledCtrPr: function()
{
this.RecalcInfo.bCtrPrp = true;
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].NeedCompiledCtrPr();
},
/*Set_CompiledCtrPrp: function(ParaMath) /*Set_CompiledCtrPrp: function(ParaMath)
{ {
var defaultRPrp = ParaMath.GetFirstRPrp(); var defaultRPrp = ParaMath.GetFirstRPrp();
...@@ -125,7 +135,7 @@ CMathBase.prototype = ...@@ -125,7 +135,7 @@ CMathBase.prototype =
},*/ },*/
Get_CompiledCtrPrp: function() Get_CompiledCtrPrp: function()
{ {
this.Set_CompiledCtrPrp(this.ParaMath); this.Set_CompiledCtrPrp(this.Parent, this.ParaMath);
var CompiledCtrPrp; var CompiledCtrPrp;
...@@ -145,7 +155,7 @@ CMathBase.prototype = ...@@ -145,7 +155,7 @@ CMathBase.prototype =
}, },
Get_CompiledCtrPrp_2: function() // without arg Size Get_CompiledCtrPrp_2: function() // without arg Size
{ {
this.Set_CompiledCtrPrp(this.ParaMath); this.Set_CompiledCtrPrp(this.Parent, this.ParaMath);
var CompiledCtrPrp; var CompiledCtrPrp;
...@@ -172,12 +182,11 @@ CMathBase.prototype = ...@@ -172,12 +182,11 @@ CMathBase.prototype =
}, },
// для управляющих символов в приоритете GetFirstRunPrp // для управляющих символов в приоритете GetFirstRunPrp
// если первый элемент - мат объект, то берутся его CtrPrp // если первый элемент - мат объект, то берутся его CtrPrp
getPrpToControlLetter: function() GetTPrpToControlLetter: function()
{ {
var rPrp = new CTextPr(); this.Set_CompiledCtrPrp(this.Parent, this.ParaMath);
rPrp.Merge( this.ParaMath.GetFirstRPrp() );
return rPrp; return this.TextPrControlLetter;
}, },
fillPlaceholders: function() fillPlaceholders: function()
{ {
...@@ -344,6 +353,26 @@ CMathBase.prototype = ...@@ -344,6 +353,26 @@ CMathBase.prototype =
{ {
return this.Parent.remove(order); return this.Parent.remove(order);
}, },
ApplyProperties: function(RPI)
{},
PreRecalc: function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
this.ApplyProperties(RPI);
// setGaps обязательно после того как смержили CtrPrp (Set_CompiledCtrPrp)
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].PreRecalc(this, ParaMath, ArgSize, RPI);
},
recalculateSize: function(oMeasure, RPI) recalculateSize: function(oMeasure, RPI)
{ {
var width = 0; var width = 0;
...@@ -366,20 +395,16 @@ CMathBase.prototype = ...@@ -366,20 +395,16 @@ CMathBase.prototype =
width += this.dW*(this.nCol - 1) + this.GapLeft + this.GapRight; width += this.dW*(this.nCol - 1) + this.GapLeft + this.GapRight;
var ascent = this.getAscent(oMeasure, height, RPI); var ascent = this.getAscent(oMeasure, height);
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
}, },
Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) Resize: function(oMeasure, RPI)
{ {
this.Parent = Parent;
this.ParaMath = ParaMath;
//this.Set_CompiledCtrPrp(ParaMath);
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
this.elements[i][j].Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.elements[i][j].Resize(oMeasure, RPI);
this.recalculateSize(oMeasure, RPI); this.recalculateSize(oMeasure, RPI);
}, },
...@@ -390,7 +415,58 @@ CMathBase.prototype = ...@@ -390,7 +415,58 @@ CMathBase.prototype =
if(!this.elements[i][j].IsJustDraw()) if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].Resize_2(oMeasure, this, ParaMath, RPI, ArgSize); this.elements[i][j].Resize_2(oMeasure, this, ParaMath, RPI, ArgSize);
}, },
Set_CompiledCtrPrp: function(ParaMath) Set_CompiledCtrPrp: function(Parent, ParaMath)
{
if(this.RecalcInfo.bCtrPrp == true)
{
// for Ctr Prp
//this.CompiledCtrPrp = ParaMath.GetFirstRPrp();
var defaultTxtPrp = ParaMath.Get_Default_TPrp();
this.CompiledCtrPrp.FontFamily =
{
Name: defaultTxtPrp.FontFamily.Name,
Index: defaultTxtPrp.FontFamily.Index
};
this.CompiledCtrPrp.FontSize = defaultTxtPrp.FontSize;
this.CompiledCtrPrp.Merge(this.CtrPrp);
// for Control Letter
var FontSize = ParaMath.GetFirstRPrp().FontSize;
if(this.bInside == true)
{
var TxtPr = Parent.Get_TxtPrControlLetter();
FontSize = TxtPr.FontSize;
FontSize = ParaMath.ApplyArgSize(FontSize, this.ArgSize.value);
}
else
{
FontSize = ParaMath.ApplyArgSize(FontSize, Parent.Get_CompiledArgSize().value);
FontSize = ParaMath.ApplyArgSize(FontSize, this.ArgSize.value);
}
this.TextPrControlLetter.FontSize = FontSize;
this.TextPrControlLetter.FontFamily =
{
Name: defaultTxtPrp.FontFamily.Name,
Index: defaultTxtPrp.FontFamily.Index
};
this.RecalcInfo.bCtrPrp = false;
}
},
Get_TxtPrControlLetter: function() // TextPrControlLetter не копируются !
{
this.Set_CompiledCtrPrp(this.Parent, this.ParaMath);
return this.TextPrControlLetter;
},
old_Set_CompiledCtrPrp: function(ParaMath)
{ {
if(this.RecalcInfo.bCtrPrp == true) if(this.RecalcInfo.bCtrPrp == true)
{ {
...@@ -488,8 +564,8 @@ CMathBase.prototype = ...@@ -488,8 +564,8 @@ CMathBase.prototype =
}, },
SetGaps: function(GapsInfo) SetGaps: function(GapsInfo)
{ {
this.Parent = GapsInfo.Parent; //this.Parent = GapsInfo.Parent;
this.ParaMath = GapsInfo.ParaMath; //this.ParaMath = GapsInfo.ParaMath;
GapsInfo.Left = GapsInfo.Current; GapsInfo.Left = GapsInfo.Current;
...@@ -566,6 +642,9 @@ CMathBase.prototype = ...@@ -566,6 +642,9 @@ CMathBase.prototype =
}, },
Apply_TextPr: function(TextPr, IncFontSize, ApplyToAll) Apply_TextPr: function(TextPr, IncFontSize, ApplyToAll)
{ {
if(ApplyToAll == true)
this.RecalcInfo.bCtrPrp = true;
if(TextPr == undefined) if(TextPr == undefined)
{ {
var CtrPrp = this.Get_CompiledCtrPrp_2(); var CtrPrp = this.Get_CompiledCtrPrp_2();
......
"use strict"; "use strict";
function CMathBreak()
{
this.AlnAt = undefined;
}
CMathBreak.prototype.Set_FromObj = function(Obj)
{
if(Obj.AlnAt !== undefined && Obj.AlnAt !== null && Obj.AlnAt - 0 == 0)
{
if(Obj.AlnAt >= 0 && Obj.AlnAt <= 255)
this.AlnAt = Obj.AlnAt;
}
}
function CMathBorderBoxPr() function CMathBorderBoxPr()
{ {
this.hideBot = false; this.hideBot = false;
...@@ -139,7 +152,7 @@ CBorderBox.prototype.recalculateSize = function() ...@@ -139,7 +152,7 @@ CBorderBox.prototype.recalculateSize = function()
var height = base.height; var height = base.height;
var ascent = base.ascent; var ascent = base.ascent;
this.gapBrd = this.Get_CompiledCtrPrp().FontSize*0.08104587131076388; this.gapBrd = this.GetTPrpToControlLetter().FontSize*0.08104587131076388;
if(this.Pr.hideTop == false) if(this.Pr.hideTop == false)
{ {
...@@ -162,7 +175,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics) ...@@ -162,7 +175,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{ {
this.elements[0][0].draw(x, y, pGraphics); this.elements[0][0].draw(x, y, pGraphics);
var penW = this.Get_CompiledCtrPrp().FontSize*0.02; var penW = this.GetTPrpToControlLetter().FontSize*0.02;
var Width = this.size.width - this.GapLeft - this.GapRight, var Width = this.size.width - this.GapLeft - this.GapRight,
Height = this.size.height; Height = this.size.height;
...@@ -523,28 +536,24 @@ CBar.prototype.fillContent = function() ...@@ -523,28 +536,24 @@ CBar.prototype.fillContent = function()
this.setDimension(1, 1); this.setDimension(1, 1);
this.elements[0][0] = this.getBase(); this.elements[0][0] = this.getBase();
} }
CBar.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CBar.prototype.ApplyProperties = function(RPI)
{ {
if(this.RecalcInfo.bProps == true) if(this.RecalcInfo.bProps == true)
{ {
var prp = var prp = {loc: this.Pr.pos, type: DELIMITER_LINE };
{
loc: this.Pr.pos,
type: DELIMITER_LINE
};
var defaultProps = var defaultProps = { loc: LOCATION_BOT};
{
loc: LOCATION_BOT
};
this.setCharacter(prp, defaultProps); this.setCharacter(prp, defaultProps);
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
}
CBar.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
this.operator.PreRecalc(this, ParaMath);
//this.Set_CompiledCtrPrp(ParaMath); CBar.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
CBar.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize);
} }
CBar.prototype.getAscent = function() CBar.prototype.getAscent = function()
{ {
......
...@@ -46,6 +46,7 @@ function CDegreeBase(props, bInside) ...@@ -46,6 +46,7 @@ function CDegreeBase(props, bInside)
if(props !== null && typeof(props) !== "undefined") if(props !== null && typeof(props) !== "undefined")
this.init(props); this.init(props);
//CDegreeBase.prototype.init.call(this, props);
} }
Asc.extendClass(CDegreeBase, CMathBase); Asc.extendClass(CDegreeBase, CMathBase);
CDegreeBase.prototype.init = function(props) CDegreeBase.prototype.init = function(props)
...@@ -59,19 +60,41 @@ CDegreeBase.prototype.fillContent = function() ...@@ -59,19 +60,41 @@ CDegreeBase.prototype.fillContent = function()
this.elements[0][0] = this.baseContent; this.elements[0][0] = this.baseContent;
this.elements[0][1] = this.iterContent; this.elements[0][1] = this.iterContent;
}; };
CDegreeBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CDegreeBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
//this.Set_CompiledCtrPrp(ParaMath); this.Set_CompiledCtrPrp(Parent, ParaMath);
this.ApplyProperties(RPI);
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.baseContent.PreRecalc(this, ParaMath, ArgSize, RPI);
var ArgSzDegr = ArgSize.Copy(); var ArgSzDegr = ArgSize.Copy();
ArgSzDegr.decrease(); ArgSzDegr.decrease();
this.elements[0][1].Resize(oMeasure, this, ParaMath, RPI, ArgSzDegr); var RPIDegr = RPI.Copy();
RPIDegr.bDecreasedComp = true;
this.iterContent.PreRecalc(this, ParaMath, ArgSzDegr, RPIDegr);
}
CDegreeBase.prototype.Resize = function(oMeasure, RPI)
{
//this.Parent = Parent;
//this.ParaMath = ParaMath;
//this.Set_CompiledCtrPrp(ParaMath);
this.baseContent.Resize(oMeasure, RPI);
//var ArgSzDegr = ArgSize.Copy();
//ArgSzDegr.decrease();
this.iterContent.Resize(oMeasure, RPI);
if(this.Pr.type === DEGREE_SUPERSCRIPT) if(this.Pr.type === DEGREE_SUPERSCRIPT)
this.recalculateSup(oMeasure); this.recalculateSup(oMeasure);
...@@ -83,24 +106,20 @@ CDegreeBase.prototype.recalculateSup = function(oMeasure) ...@@ -83,24 +106,20 @@ CDegreeBase.prototype.recalculateSup = function(oMeasure)
var base = this.elements[0][0].size, var base = this.elements[0][0].size,
iter = this.elements[0][1].size; iter = this.elements[0][1].size;
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
this.upBase = 0; this.upBase = 0;
this.upIter = 0; this.upIter = 0;
var oBase = this.elements[0][0]; var oBase = this.elements[0][0];
//var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText
var bOneLineText = oBase.IsJustDraw() ? false : oBase.IsOneLineText(); var bOneLineText = oBase.IsJustDraw() ? false : oBase.IsOneLineText();
if(bOneLineText) if(bOneLineText)
{ {
//var UpBaseline = 1.786*shCenter; // baseline итератора
var UpBaseline = 1.65*shCenter; // baseline итератора var UpBaseline = 1.65*shCenter; // baseline итератора
// iter.height - UpBaseline - iter.ascent + base.ascent > 2/3 * base.height
if(iter.height - UpBaseline - iter.ascent + base.ascent > 2/3 * base.ascent) if(iter.height - UpBaseline - iter.ascent + base.ascent > 2/3 * base.ascent)
this.upBase = iter.height - 2/3*base.ascent; this.upBase = iter.height - 2/3*base.ascent;
else if(UpBaseline + iter.ascent > base.ascent) else if(UpBaseline + iter.ascent > base.ascent)
...@@ -138,15 +157,13 @@ CDegreeBase.prototype.recalculateSubScript = function(oMeasure) ...@@ -138,15 +157,13 @@ CDegreeBase.prototype.recalculateSubScript = function(oMeasure)
var base = this.elements[0][0].size, var base = this.elements[0][0].size,
iter = this.elements[0][1].size; iter = this.elements[0][1].size;
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var width = base.width + iter.width + this.dW; var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
var oBase = this.elements[0][0]; var oBase = this.elements[0][0];
//var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText
var bOneLineText = oBase.IsJustDraw() ? false : oBase.IsOneLineText(); var bOneLineText = oBase.IsJustDraw() ? false : oBase.IsOneLineText();
if(bOneLineText) if(bOneLineText)
...@@ -278,6 +295,24 @@ CIterators.prototype.init = function() ...@@ -278,6 +295,24 @@ CIterators.prototype.init = function()
this.elements[0][0] = this.iterUp; this.elements[0][0] = this.iterUp;
this.elements[1][0] = this.iterDn; this.elements[1][0] = this.iterDn;
}; };
CIterators.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
this.ArgSize.SetValue(-1);
var ArgSzIters = ArgSize.Copy();
ArgSzIters.Merge(this.ArgSize);
this.Set_CompiledCtrPrp(Parent, ParaMath);
var RPI_ITER = RPI.Copy();
RPI_ITER.bDecreasedComp = true;
this.iterUp.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
};
CIterators.prototype.getUpperIterator = function() CIterators.prototype.getUpperIterator = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
...@@ -294,10 +329,6 @@ CIterators.prototype.setLowerIterator = function(iterator) ...@@ -294,10 +329,6 @@ CIterators.prototype.setLowerIterator = function(iterator)
{ {
this.elements[1][0] = iterator; this.elements[1][0] = iterator;
}; };
CIterators.prototype.Get_CompiledCtrPrp = function()
{
return this.Parent.Get_CompiledCtrPrp();
};
CIterators.prototype.alignIterators = function(mcJc) CIterators.prototype.alignIterators = function(mcJc)
{ {
this.alignment.wdt[0] = mcJc; this.alignment.wdt[0] = mcJc;
...@@ -354,6 +385,7 @@ function CDegreeSubSupBase(props, bInside) ...@@ -354,6 +385,7 @@ function CDegreeSubSupBase(props, bInside)
CDegreeSubSupBase.superclass.constructor.call(this, bInside); CDegreeSubSupBase.superclass.constructor.call(this, bInside);
this.gapBase = 0; this.gapBase = 0;
this.bNaryInline = false;
this.Pr = new CMathDegreeSubSupPr(); this.Pr = new CMathDegreeSubSupPr();
...@@ -392,7 +424,29 @@ CDegreeSubSupBase.prototype.fillContent = function() ...@@ -392,7 +424,29 @@ CDegreeSubSupBase.prototype.fillContent = function()
oIters.alignIterators(MCJC_RIGHT); oIters.alignIterators(MCJC_RIGHT);
} }
}; };
CDegreeSubSupBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CDegreeSubSupBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.bNaryInline = RPI.bNaryInline;
CDegreeSubSupBase.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
};
/*CDegreeSubSupBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
var ArgSzIters = ArgSize.Copy();
ArgSzIters.decrease();
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
this.baseContent.PreRecalc(this, ParaMath, ArgSize, RPI);
this.iters.PreRecalc(this, ParaMath, ArgSzIters, RPI);
};*/
/*CDegreeSubSupBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
...@@ -406,10 +460,14 @@ CDegreeSubSupBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, A ...@@ -406,10 +460,14 @@ CDegreeSubSupBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, A
this.iters.Resize(oMeasure, this, ParaMath, RPI, ArgSzIters); this.iters.Resize(oMeasure, this, ParaMath, RPI, ArgSzIters);
this.recalculateSize(oMeasure, RPI); this.recalculateSize(oMeasure, RPI);
}; };*/
CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI) CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI)
{ {
var mgCtrPrp = this.Get_CompiledCtrPrp(); //var mgCtrPrp = this.GetTPrpToControlLetter();
var mgCtrPrp = this.Get_CompiledCtrPrp(); // Get_CompiledCtrPrp - чтобы итераторы не разъезжались
// половину ascent брать нельзя, т.к. черта дроби будет разделительной для верхнего и нижнего итератора => соответственно
// если числитель меньше/больше знаменателя расположение итераторов у степени будет неправильным
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.4; shCenter *= 1.4;
...@@ -433,16 +491,17 @@ CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -433,16 +491,17 @@ CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI)
iterDown = iters.elements[1][0].size; iterDown = iters.elements[1][0].size;
var lUp = base.size.ascent - shCenter; // center of base var lUp = base.size.ascent - shCenter; // center of base
//var lUp = base.size.height/2; // center of base
var lDown = base.size.height - lUp; // height - center of base var lDown = base.size.height - lUp; // height - center of base
var ctrPrpIter = iters.Get_CompiledCtrPrp(); var ctrPrpIter = iters.GetTPrpToControlLetter();
var shIter = this.ParaMath.GetShiftCenter(oMeasure, ctrPrpIter); //смещение var shIter = this.ParaMath.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
var minGap = 0.7*shIter; var minGap = 0.7*shIter;
var up, down; var up, down;
if(RPI.bNaryInline == true) if(this.bNaryInline)
{ {
up = down = 0; up = down = 0;
} }
...@@ -467,7 +526,6 @@ CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -467,7 +526,6 @@ CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI)
} }
if(up + down > minGap) if(up + down > minGap)
{ {
this.gapBase = iterUp.height + up - lUp; this.gapBase = iterUp.height + up - lUp;
......
...@@ -75,9 +75,7 @@ CFraction.prototype.draw = function(x, y, pGraphics) ...@@ -75,9 +75,7 @@ CFraction.prototype.draw = function(x, y, pGraphics)
} }
CFraction.prototype.drawBarFraction = function(x, y, pGraphics) CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
{ {
//var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var mgCtrPrp = this.Get_CompiledCtrPrp_2();
mgCtrPrp.FontSize = this.ParaMath.ApplyArgSize(mgCtrPrp.FontSize, this.Parent.Get_CompiledArgSize().value);
var penW = mgCtrPrp.FontSize* 25.4/96 * 0.08; var penW = mgCtrPrp.FontSize* 25.4/96 * 0.08;
...@@ -102,8 +100,7 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics) ...@@ -102,8 +100,7 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
} }
CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics) CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics)
{ {
//var ctrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm; var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
...@@ -208,8 +205,7 @@ CFraction.prototype.drawLinearFraction = function(x, y, pGraphics) ...@@ -208,8 +205,7 @@ CFraction.prototype.drawLinearFraction = function(x, y, pGraphics)
x2 = X + this.elements[0][0].size.width + shift, x2 = X + this.elements[0][0].size.width + shift,
y2 = Y + this.size.height; y2 = Y + this.size.height;
//var ctrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm; var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
pGraphics.SetFont(mgCtrPrp); pGraphics.SetFont(mgCtrPrp);
...@@ -247,7 +243,45 @@ CFraction.prototype.getDenominator = function() ...@@ -247,7 +243,45 @@ CFraction.prototype.getDenominator = function()
return denominator; return denominator;
} }
CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
var ArgSzNumDen = ArgSize.Copy();
if(RPI.bInline == true && (this.Pr.type === BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)) // уменьшае размер числителя и знаменателя
{
ArgSzNumDen.decrease(); // для контентов числителя и знаменателя
this.ArgSize.SetValue(-1); // для CtrPrp
}
else if(RPI.bDecreasedComp == true) // уменьшаем расстояние между числителем и знаменателем (размер FontSize для TxtPr ControlLetter)
// this.ArgSize отвечает за TxtPr ControlLetter
{
this.ArgSize.SetValue(-1); // для CtrPrp
}
else
{
this.ArgSize.SetValue(0);
}
this.Set_CompiledCtrPrp(Parent, ParaMath);
this.ApplyProperties(RPI);
var NewRPI = RPI.Copy();
if(this.Pr.type !== LINEAR_FRACTION)
NewRPI.bDecreasedComp = true;
// setGaps обязательно после того как смержили CtrPrp (Set_CompiledCtrPrp)
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
}
/*CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
var ArgSzFr = ArgSize.Copy(); var ArgSzFr = ArgSize.Copy();
...@@ -265,6 +299,8 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -265,6 +299,8 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.ArgSize.SetValue(0); this.ArgSize.SetValue(0);
} }
// ??!!
if(this.Pr.type == NO_BAR_FRACTION) if(this.Pr.type == NO_BAR_FRACTION)
{ {
ArgSzFr.decrease(); ArgSzFr.decrease();
...@@ -279,10 +315,11 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -279,10 +315,11 @@ CFraction.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
//this.Set_CompiledCtrPrp(ParaMath); //this.Set_CompiledCtrPrp(ParaMath);
var NewRPI = RPI.Copy(); var NewRPI = RPI.Copy();
NewRPI.bInsideFraction = true; if(this.Pr.type !== LINEAR_FRACTION)
NewRPI.bInsideFraction = true;
CFraction.superclass.Resize.call(this, oMeasure, Parent, ParaMath, NewRPI, ArgSzFr); CFraction.superclass.Resize.call(this, oMeasure, Parent, ParaMath, NewRPI, ArgSzFr);
} }*/
CFraction.prototype.recalculateSize = function(oMeasure) CFraction.prototype.recalculateSize = function(oMeasure)
{ {
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
...@@ -297,8 +334,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure) ...@@ -297,8 +334,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
var num = this.elements[0][0].size, var num = this.elements[0][0].size,
den = this.elements[1][0].size; den = this.elements[1][0].size;
//var ctrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var width = num.width > den.width ? num.width : den.width; var width = num.width > den.width ? num.width : den.width;
var height = num.height + den.height; var height = num.height + den.height;
...@@ -310,8 +346,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure) ...@@ -310,8 +346,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
} }
CFraction.prototype.recalculateSkewed = function(oMeasure) CFraction.prototype.recalculateSkewed = function(oMeasure)
{ {
//var ctrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var mgCtrPrp = this.Get_CompiledCtrPrp();
//this.gapSlash = 5.011235894097222 * mgCtrPrp.FontSize/36; //this.gapSlash = 5.011235894097222 * mgCtrPrp.FontSize/36;
this.dW = 5.011235894097222 * mgCtrPrp.FontSize/36; this.dW = 5.011235894097222 * mgCtrPrp.FontSize/36;
...@@ -331,8 +366,8 @@ CFraction.prototype.recalculateLinear = function() ...@@ -331,8 +366,8 @@ CFraction.prototype.recalculateLinear = function()
DescentSecond = this.elements[0][1].size.height - this.elements[0][1].size.ascent; DescentSecond = this.elements[0][1].size.height - this.elements[0][1].size.ascent;
var H = AscentFirst + DescentSecond; var H = AscentFirst + DescentSecond;
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var gap = 5.011235894097222*mgCtrPrp.FontSize/36; var gap = 5.011235894097222*mgCtrPrp.FontSize/36;
...@@ -428,7 +463,7 @@ CFractionBase.prototype.init = function(MathContent) ...@@ -428,7 +463,7 @@ CFractionBase.prototype.init = function(MathContent)
this.setDimension(1, 1); this.setDimension(1, 1);
this.elements[0][0] = MathContent; this.elements[0][0] = MathContent;
} }
CFractionBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) /*CFractionBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
...@@ -438,7 +473,7 @@ CFractionBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSi ...@@ -438,7 +473,7 @@ CFractionBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSi
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
this.recalculateSize(); this.recalculateSize();
} }*/
CFractionBase.prototype.getElement = function() CFractionBase.prototype.getElement = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
...@@ -465,7 +500,7 @@ CNumerator.prototype.recalculateSize = function() ...@@ -465,7 +500,7 @@ CNumerator.prototype.recalculateSize = function()
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var Descent = arg.height - arg.ascent; // baseLine var Descent = arg.height - arg.ascent; // baseLine
...@@ -517,7 +552,7 @@ CDenominator.prototype.recalculateSize = function() ...@@ -517,7 +552,7 @@ CDenominator.prototype.recalculateSize = function()
{ {
var arg = this.elements[0][0].size; var arg = this.elements[0][0].size;
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var Ascent = arg.ascent - 4.938888888888888*mgCtrPrp.FontSize/36; var Ascent = arg.ascent - 4.938888888888888*mgCtrPrp.FontSize/36;
......
...@@ -30,6 +30,87 @@ CMathLimitPr.prototype.Read_FromBinary = function(Reader) ...@@ -30,6 +30,87 @@ CMathLimitPr.prototype.Read_FromBinary = function(Reader)
this.type = Reader.GetLong(); this.type = Reader.GetLong();
}; };
function CLimitPrimary(bInside, Type, FName, Iterator)
{
CLimitPrimary.superclass.constructor.call(this, bInside);
this.Type = Type;
this.FName = null;
this.Iterator = null;
this.init(FName, Iterator);
}
Asc.extendClass(CLimitPrimary, CMathBase);
CLimitPrimary.prototype.init = function(FName, Iterator)
{
this.setDimension(2, 1);
if(this.Type == LIMIT_LOW)
{
this.FName = FName;
this.Iterator = new CDenominator(Iterator);
this.elements[0][0] = this.FName;
this.elements[1][0] = this.Iterator;
}
else
{
this.Iterator = Iterator;
this.FName = FName;
this.elements[0][0] = this.Iterator;
this.elements[1][0] = this.FName;
}
}
CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
this.FName.PreRecalc(this, ParaMath, ArgSize, RPI);
var ArgSzIter = ArgSize.Copy();
ArgSzIter.decrease();
var NewRPI = RPI.Copy();
NewRPI.bDecreasedComp = true;
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI);
}
CLimitPrimary.prototype.Resize = function(oMeasure, RPI)
{
if(this.Type == LIMIT_LOW)
this.dH = 0;
else
this.dH = 0.06*this.GetTPrpToControlLetter().FontSize;
this.FName.Resize(oMeasure, RPI);
this.Iterator.Resize(oMeasure, RPI);
var SizeFName = this.FName.size,
SizeIter = this.Iterator.size;
var width = SizeFName.width > SizeIter.width ? SizeFName.width : SizeIter.width,
height = SizeFName.height + SizeIter.height,
ascent;
if(this.Type == LIMIT_LOW)
ascent = SizeFName.ascent;
else if(this.Type == LIMIT_UP)
ascent = SizeIter.height + this.dH + SizeFName.ascent;
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
function CLimit(props) function CLimit(props)
{ {
CLimit.superclass.constructor.call(this); CLimit.superclass.constructor.call(this);
...@@ -67,121 +148,35 @@ CLimit.prototype.getIterator = function() ...@@ -67,121 +148,35 @@ CLimit.prototype.getIterator = function()
{ {
return this.Content[1]; return this.Content[1];
} }
CLimit.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CLimit.prototype.ApplyProperties = function(RPI)
{ {
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bProps == true || RPI.bChangeInline == true) if(this.RecalcInfo.bProps == true || RPI.bChangeInline == true)
{ {
this.setDimension(1, 1);
if(RPI.bInline == true && RPI.bMathFunc == true) if(RPI.bInline == true && RPI.bMathFunc == true)
{ {
this.setDimension(1, 1);
var props; var props;
if(this.Pr.type == LIMIT_LOW) if(this.Pr.type == LIMIT_LOW)
{ props = {type: DEGREE_SUBSCRIPT, ctrPrp: this.CtrPrp};
props =
{
type: DEGREE_SUBSCRIPT,
ctrPrp: this.CtrPrp
};
}
else else
{ props = {type: DEGREE_SUPERSCRIPT, ctrPrp: this.CtrPrp};
props =
{ this.elements[0][0] = new CDegreeBase(props, true);
type: DEGREE_SUPERSCRIPT,
ctrPrp: this.CtrPrp
};
}
this.elements[0][0] = new CDegreeBase(null, true);
this.elements[0][0].setBase(this.getFName()); this.elements[0][0].setBase(this.getFName());
this.elements[0][0].setIterator(this.getIterator()); this.elements[0][0].setIterator(this.getIterator());
this.elements[0][0].fillContent(); this.elements[0][0].fillContent();
this.FName = this.getFName();
this.Iterator = this.getIterator();
} }
else else
{ {
this.setDimension(2, 1); this.elements[0][0] = new CLimitPrimary(true, this.Pr.type, this.getFName(), this.getIterator());
if(this.Pr.type == LIMIT_LOW)
{
this.dH = 0;
this.FName = this.getFName();
this.Iterator = new CDenominator(this.getIterator());
this.elements[0][0] = this.FName;
this.elements[1][0] = this.Iterator;
}
else
{
this.FName = this.getFName();
this.Iterator = this.getIterator();
this.dH = 0.06*this.Get_CompiledCtrPrp().FontSize;
this.elements[0][0] = this.Iterator;
this.elements[1][0] = this.FName;
}
} }
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
if(RPI.bInline == true && RPI.bMathFunc == true)
{
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize);
this.size =
{
width: this.elements[0][0].size.width,
height: this.elements[0][0].size.height,
ascent: this.elements[0][0].size.ascent
};
}
else
{
this.FName.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
var ArgSzIter = ArgSize.Copy();
ArgSzIter.decrease();
this.Iterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzIter);
var SizeFName = this.FName.size,
SizeIter = this.Iterator.size;
var width = SizeFName.width > SizeIter.width ? SizeFName.width : SizeIter.width,
height = SizeFName.height + SizeIter.height,
ascent;
if(this.Pr.type == LIMIT_LOW)
{
ascent = SizeFName.ascent;
}
else if(this.Pr.type == LIMIT_UP)
{
ascent = SizeIter.height + this.dH + SizeFName.ascent;
}
width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
} }
function CMathFunc(props) function CMathFunc(props)
{ {
CMathFunc.superclass.constructor.call(this); CMathFunc.superclass.constructor.call(this);
...@@ -207,18 +202,16 @@ CMathFunc.prototype.init = function(props) ...@@ -207,18 +202,16 @@ CMathFunc.prototype.init = function(props)
this.setProperties(props); this.setProperties(props);
this.fillContent(); this.fillContent();
} }
CMathFunc.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{ {
RPI.bMathFunc = true; var NewRPI = RPI.Copy();
NewRPI.bMathFunc = true;
CMathFunc.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize);
RPI.bMathFunc = false;
CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
} }
CMathFunc.prototype.setDistance = function() CMathFunc.prototype.setDistance = function()
{ {
this.dW = this.Get_CompiledCtrPrp().FontSize/6*g_dKoef_pt_to_mm; this.dW = this.GetTPrpToControlLetter().FontSize/6*g_dKoef_pt_to_mm;
} }
CMathFunc.prototype.getFName = function() CMathFunc.prototype.getFName = function()
{ {
......
...@@ -32,9 +32,8 @@ ...@@ -32,9 +32,8 @@
function CRPI() function CRPI()
{ {
//this.UpdateMathPr = true;
this.NeedResize = true; this.NeedResize = true;
this.bInsideFraction = false; this.bDecreasedComp = false;
this.bInline = false; this.bInline = false;
this.bChangeInline = false; this.bChangeInline = false;
this.bNaryInline = false; /*для CDegreeSupSub внутри N-арного оператора, этот флаг необходим, чтобы итераторы максимально близко друг к другу расположить*/ this.bNaryInline = false; /*для CDegreeSupSub внутри N-арного оператора, этот флаг необходим, чтобы итераторы максимально близко друг к другу расположить*/
...@@ -46,8 +45,9 @@ CRPI.prototype.Copy = function() ...@@ -46,8 +45,9 @@ CRPI.prototype.Copy = function()
{ {
var RPI = new CRPI(); var RPI = new CRPI();
RPI.NeedResize = this.NeedResize;
RPI.bInline = this.bInline; RPI.bInline = this.bInline;
RPI.bInsideFraction = this.bInsideFraction; RPI.bDecreasedComp = this.bDecreasedComp;
RPI.bChangeInline = this.bChangeInline; RPI.bChangeInline = this.bChangeInline;
RPI.bNaryInline = this.bNaryInline; RPI.bNaryInline = this.bNaryInline;
RPI.bEqqArray = this.bEqqArray; RPI.bEqqArray = this.bEqqArray;
...@@ -324,17 +324,23 @@ var COEFF_GAPS = new CCoeffGaps(); ...@@ -324,17 +324,23 @@ var COEFF_GAPS = new CCoeffGaps();
function CMathArgSize() function CMathArgSize()
{ {
this.value = 0; this.value = undefined;
} }
CMathArgSize.prototype = CMathArgSize.prototype =
{ {
decrease: function() decrease: function()
{ {
if(this.value == undefined)
this.value = 0;
if( this.value > -2 ) if( this.value > -2 )
this.value--; this.value--;
}, },
increase: function() increase: function()
{ {
if(this.value == undefined)
this.value = 0;
if(this.value < 2) if(this.value < 2)
this.value++; this.value++;
}, },
...@@ -361,29 +367,44 @@ CMathArgSize.prototype = ...@@ -361,29 +367,44 @@ CMathArgSize.prototype =
}, },
Merge: function(ArgSize) Merge: function(ArgSize)
{ {
if(this.value == undefined)
this.value = 0;
if(ArgSize.value == undefined)
ArgSize.value = 0;
this.SetValue(this.value + ArgSize.value); this.SetValue(this.value + ArgSize.value);
} }
} }
function CMathGapsInfo(oMeasure, Parent, argSize) function CMathGapsInfo(argSize)
{ {
this.measure = oMeasure; //this.measure = oMeasure;
this.Parent = Parent; //this.Parent = Parent;
this.ParaMath = this.Parent.ParaMath; // для Para_Run //this.ParaMath = this.Parent.ParaMath; // для Para_Run
this.argSize = argSize; // argSize выставляем один раз для всего контента this.argSize = argSize; // argSize выставляем один раз для всего контента
this.leftRunPrp = null; // Run_Prp левого элемента //this.leftRunPrp = null; // Run_Prp левого элемента
this.currRunPrp = null; //this.currRunPrp = null;
this.Left = null; // элемент слева this.Left = null; // элемент слева
this.Current = null; // текущий элемент this.Current = null; // текущий элемент
this.LeftFontSize = null;
this.CurrentFontSize = null;
} }
CMathGapsInfo.prototype = CMathGapsInfo.prototype =
{ {
setGaps: function() setGaps: function(Current, CurrentFontSize)
{ {
this.Left = this.Current;
this.LeftFontSize = this.CurrentFontSize;
this.Current = Current;
this.CurrentFontSize = CurrentFontSize;
if(this.argSize < 0) if(this.argSize < 0)
{ {
this.Current.GapLeft = 0; this.Current.GapLeft = 0;
...@@ -458,12 +479,12 @@ CMathGapsInfo.prototype = ...@@ -458,12 +479,12 @@ CMathGapsInfo.prototype =
leftCoeff = Math.ceil(leftCoeff*10)/10; leftCoeff = Math.ceil(leftCoeff*10)/10;
rightCoeff = Math.ceil(rightCoeff*10)/10; rightCoeff = Math.ceil(rightCoeff*10)/10;
var LGapSign = 0.1513*this.currRunPrp.FontSize; var LGapSign = 0.1513*this.CurrentFontSize;
this.Current.GapLeft = Math.ceil(leftCoeff*LGapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте this.Current.GapLeft = Math.ceil(leftCoeff*LGapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте
if(this.Left != null) if(this.Left != null)
{ {
var RGapSign = 0.1513*this.leftRunPrp.FontSize; var RGapSign = 0.1513*this.LeftFontSize;
this.Left.GapRight = Math.ceil(rightCoeff*RGapSign*10)/10; this.Left.GapRight = Math.ceil(rightCoeff*RGapSign*10)/10;
} }
} }
...@@ -752,7 +773,7 @@ CMathContent.prototype = ...@@ -752,7 +773,7 @@ CMathContent.prototype =
this.size = {width: width, height: ascent + descent, ascent: ascent}; this.size = {width: width, height: ascent + descent, ascent: ascent};
},*/ },*/
Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // пересчитываем всю формулу old_Resize: function(oMeasure, Parent, ParaMath, ArgSize, RPI) // пересчитываем всю формулу
{ {
if(ArgSize !== null && ArgSize !== undefined) if(ArgSize !== null && ArgSize !== undefined)
{ {
...@@ -826,19 +847,7 @@ CMathContent.prototype = ...@@ -826,19 +847,7 @@ CMathContent.prototype =
this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent; this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent;
} }
}, },
Resize_2: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // особый случай: вызываем, когда пересчет всей формулы не нужен, а нужно выставить только Lines (Реализована, чтобы не править Resize у каждого элемента) PreRecalc: function(Parent, ParaMath, ArgSize, RPI)
{
var lng = this.content.length;
for(var i = 0; i < lng; i++)
{
if(this.content[i].Type == para_Math_Composition)
this.content[i].Resize_2(oMeasure, this, ParaMath, RPI, ArgSize);
else
this.content[i].Math_Recalculate(oMeasure, this, ParaMath.Paragraph, RPI, ArgSize, null);
}
},
M_Resize: function(oMeasure, Parent, ParaMath, RPI, ArgSize) // если делать один цикл for для Resize, то надо избавиться от WidthToElement,
// т.к. корректно рассчитывать не получается, либо выставлять WidthToElement для пустыx Run (которые идут после мат объекта) на recalculateSize_2 мат объекта
{ {
if(ArgSize !== null && ArgSize !== undefined) if(ArgSize !== null && ArgSize !== undefined)
{ {
...@@ -853,83 +862,82 @@ CMathContent.prototype = ...@@ -853,83 +862,82 @@ CMathContent.prototype =
this.Parent = Parent; this.Parent = Parent;
} }
this.WidthToElement.length = 0; if(ArgSize !== null && ArgSize !== undefined)
{
this.Compiled_ArgSz.value = this.ArgSize.value;
this.Compiled_ArgSz.Merge(ArgSize);
}
var GapsInfo = new CMathGapsInfo(oMeasure, this, this.Compiled_ArgSz.value); var lng = this.content.length;
if (!this.bRoot && this.content.length == 0) var GapsInfo = new CMathGapsInfo(this.Compiled_ArgSz.value);
this.fillPlaceholders();
for(var pos = 0; pos < lng; pos++)
{
if(this.content[pos].Type == para_Math_Composition)
{
this.content[pos].PreRecalc(this, ParaMath, this.Compiled_ArgSz, RPI, GapsInfo);
}
else if(this.content[pos].Type == para_Math_Run)
this.content[pos].Math_PreRecalc(this, ParaMath, this.Compiled_ArgSz, RPI, GapsInfo);
}
if(GapsInfo.Current !== null)
GapsInfo.Current.GapRight = 0;
},
Resize: function(oMeasure, RPI) // пересчитываем всю формулу
{
this.WidthToElement.length = 0;
this.RecalcInfo.bEqqArray = RPI.bEqqArray; this.RecalcInfo.bEqqArray = RPI.bEqqArray;
var lng = this.content.length; var lng = this.content.length;
this.size.SetZero(); this.size.SetZero();
this.InfoPoints.SetDefault(); this.InfoPoints.SetDefault();
var PosUpdate = -1;
var bEmptyRun;
for(var pos = 0; pos < lng; pos++) for(var pos = 0; pos < lng; pos++)
{ {
bEmptyRun = this.content[pos].Type == para_Math_Run && this.content[pos].Is_Empty();
if(this.content[pos].Type == para_Math_Composition) if(this.content[pos].Type == para_Math_Composition)
{ {
this.content[pos].SetGaps(GapsInfo); var NewRPI = RPI.Copy();
NewRPI.bEqqArray = false;
this.content[pos].Resize(oMeasure, NewRPI);
if(RPI.bEqqArray)
this.InfoPoints.ContentPoints.UpdatePoint(this.content[pos].size.width);
} }
else if(this.content[pos].Type == para_Math_Run) else if(this.content[pos].Type == para_Math_Run)
this.content[pos].Math_SetGaps(GapsInfo); {
//this.content[pos].Recalculate_Range();
this.content[pos].Math_Recalculate(oMeasure, RPI, this.InfoPoints.ContentPoints);
}
// если пропускаем расчет одного из элементов, то WidthToElement будет неправильно выставлен
// если выставлять WidthToElement на recalculateSize_2, то WidthToElement не будет выставлен для пустых Run
this.WidthToElement[pos] = this.size.width; this.WidthToElement[pos] = this.size.width;
// для случая если между двумя мат объектами стоит пустой Run, то Gaps должны рассчитываться между двумя этими мат объектами var oSize = this.content[pos].size;
// и при расчете должны сначала выставиться у правого мат объекта Gaps, а потом рассчитываться размер левого объекта this.size.width += oSize.width;
if(!bEmptyRun)
{
if(PosUpdate >= 0)
this.recalculateSize_2(PosUpdate, oMeasure, Parent, ParaMath, RPI);
PosUpdate = pos;
}
}
if(GapsInfo.Current !== null) var oDescent = oSize.height - oSize.ascent,
GapsInfo.Current.GapRight = 0; SizeDescent = this.size.height - this.size.ascent;
if(PosUpdate != -1) this.size.ascent = this.size.ascent > oSize.ascent ? this.size.ascent : oSize.ascent;
this.recalculateSize_2(PosUpdate, oMeasure, Parent, ParaMath, RPI);
this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent;
}
}, },
recalculateSize_2: function(pos, oMeasure, Parent, ParaMath, RPI) // особый случай: вызываем, когда пересчет всей формулы не нужен, а нужно выставить только Lines (Реализована, чтобы не править Resize у каждого элемента)
Resize_2: function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
if(this.content[pos].Type == para_Math_Composition) var lng = this.content.length;
for(var i = 0; i < lng; i++)
{ {
var NewRPI = RPI.Copy(); if(this.content[i].Type == para_Math_Composition)
NewRPI.bEqqArray = false; this.content[i].Resize_2(oMeasure, this, ParaMath, RPI, ArgSize);
else
this.content[pos].Resize(oMeasure, this, ParaMath, NewRPI, this.Compiled_ArgSz); this.content[i].Math_Recalculate(oMeasure, this, ParaMath.Paragraph, RPI, ArgSize, null);
if(RPI.bEqqArray)
this.InfoPoints.ContentPoints.UpdatePoint(this.content[pos].size.width);
} }
else if(this.content[pos].Type == para_Math_Run)
this.content[pos].Math_Recalculate(oMeasure, this, ParaMath.Paragraph, RPI, this.Compiled_ArgSz, this.InfoPoints.ContentPoints);
var oSize = this.content[pos].size;
this.size.width += oSize.width;
var oDescent = oSize.height - oSize.ascent,
SizeDescent = this.size.height - this.size.ascent;
this.size.ascent = this.size.ascent > oSize.ascent ? this.size.ascent : oSize.ascent;
this.size.height = SizeDescent < oDescent ? oDescent + this.size.ascent : SizeDescent + this.size.ascent;
}, },
getWidthsPoints: function() getWidthsPoints: function()
{ {
...@@ -1140,6 +1148,10 @@ CMathContent.prototype = ...@@ -1140,6 +1148,10 @@ CMathContent.prototype =
{ {
this.ArgSize.SetValue(val); this.ArgSize.SetValue(val);
}, },
GetArgSize: function()
{
return this.ArgSize.value;
},
///////// Перемещение //////////// ///////// Перемещение ////////////
...@@ -1429,7 +1441,8 @@ CMathContent.prototype = ...@@ -1429,7 +1441,8 @@ CMathContent.prototype =
while ( null === TextPr && StartPos <= EndPos ) while ( null === TextPr && StartPos <= EndPos )
{ {
TextPr = this.content[StartPos].Get_CompiledTextPr(Copy); TextPr = this.content[StartPos].Get_CompiledTextPr(true); // true для пустых ранов
// т.к. если пустой ран входит в селект, текстовый настройки не скопируются в ране
StartPos++; StartPos++;
} }
...@@ -1468,6 +1481,11 @@ CMathContent.prototype = ...@@ -1468,6 +1481,11 @@ CMathContent.prototype =
var bSelectOneElement = this.Selection.Use && StartPos == EndPos; var bSelectOneElement = this.Selection.Use && StartPos == EndPos;
var FirstPos = this.Selection.Use ? Math.min(StartPos, EndPos) : this.CurPos;
if(FirstPos == 0)
this.ParaMath.NeedCompiledCtrPr();
if( !this.Selection.Use || (bSelectOneElement && this.content[StartPos].Type == para_Math_Run) ) // TextPr меняем только в одном Run if( !this.Selection.Use || (bSelectOneElement && this.content[StartPos].Type == para_Math_Run) ) // TextPr меняем только в одном Run
{ {
var Pos = !this.Selection.Use ? this.CurPos : StartPos; var Pos = !this.Selection.Use ? this.CurPos : StartPos;
...@@ -1576,6 +1594,37 @@ CMathContent.prototype = ...@@ -1576,6 +1594,37 @@ CMathContent.prototype =
} }
}, },
IsNormalTextInRuns: function()
{
var flag = true;
if(this.Selection.Use)
{
var StartPos = this.Selection.Start,
EndPos = this.Selection.End;
if ( StartPos > EndPos )
{
StartPos = this.Selection.End;
EndPos = this.Selection.Start;
}
for(var i = StartPos; i < EndPos+1; i++)
{
var curr = this.content[i],
currType = curr.Type;
if(currType == para_Math_Composition || (currType == para_Math_Run && false == curr.IsNormalText()))
{
flag = false;
break;
}
}
}
else
flag = false;
return flag;
},
Internal_Content_Add : function(Pos, Item, bUpdatePosition) Internal_Content_Add : function(Pos, Item, bUpdatePosition)
{ {
History.Add( this, { Type : historyitem_Math_AddItem, Pos : Pos, EndPos : Pos, Items : [ Item ] } ); History.Add( this, { Type : historyitem_Math_AddItem, Pos : Pos, EndPos : Pos, Items : [ Item ] } );
...@@ -1608,7 +1657,13 @@ CMathContent.prototype = ...@@ -1608,7 +1657,13 @@ CMathContent.prototype =
ContentPos.Data[Depth]++; ContentPos.Data[Depth]++;
} }
}, },
NeedCompiledCtrPr: function()
{
for(var i = 0; i < this.content.length; i++)
if(this.content[i].Type == para_Math_Composition)
this.content[i].NeedCompiledCtrPr();
},
private_CorrectSelectionPos : function() private_CorrectSelectionPos : function()
{ {
this.Selection.Start = Math.max(0, Math.min(this.content.length - 1, this.Selection.Start)); this.Selection.Start = Math.max(0, Math.min(this.content.length - 1, this.Selection.Start));
......
...@@ -539,7 +539,7 @@ CMathText.prototype = ...@@ -539,7 +539,7 @@ CMathText.prototype =
this.Type = para_Math_Placeholder; this.Type = para_Math_Placeholder;
this.value = StartTextElement; this.value = StartTextElement;
}, },
Resize: function(oMeasure, Parent, RPI) Resize: function(oMeasure, RPI)
{ {
/* /*
var metricsTxt = g_oTextMeasurer.Measure2Code(letter); var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
...@@ -547,10 +547,10 @@ CMathText.prototype = ...@@ -547,10 +547,10 @@ CMathText.prototype =
height = g_oTextMeasurer.GetHeight(); height = g_oTextMeasurer.GetHeight();
*/ */
if(!this.bJDraw) /*if(!this.bJDraw)
this.Parent = Parent; this.Parent = Parent;
else else
this.Parent = null; this.Parent = null;*/
var letter = this.getCode(); var letter = this.getCode();
...@@ -601,6 +601,13 @@ CMathText.prototype = ...@@ -601,6 +601,13 @@ CMathText.prototype =
//this.RecalcInfo.NewLetter = false; //this.RecalcInfo.NewLetter = false;
}, },
PreRecalc: function(Parent, ParaMath, ArgSize, RPI)
{
if(!this.bJDraw)
this.Parent = Parent;
else
this.Parent = null;
},
Get_WidthVisible: function() Get_WidthVisible: function()
{ {
return this.size.width; return this.size.width;
...@@ -786,7 +793,7 @@ function CMathAmp() ...@@ -786,7 +793,7 @@ function CMathAmp()
this.pos = new CMathPosition(); this.pos = new CMathPosition();
this.AmpText = new CMathText(false); this.AmpText = new CMathText(true);
this.AmpText.add(0x26); this.AmpText.add(0x26);
this.size = null; this.size = null;
...@@ -794,9 +801,8 @@ function CMathAmp() ...@@ -794,9 +801,8 @@ function CMathAmp()
} }
CMathAmp.prototype = CMathAmp.prototype =
{ {
Resize: function(oMeasure, Parent, RPI) Resize: function(oMeasure, RPI)
{ {
this.Parent = Parent;
this.bEqqArray = RPI.bEqqArray; this.bEqqArray = RPI.bEqqArray;
this.AmpText.Resize(oMeasure, this, RPI); this.AmpText.Resize(oMeasure, this, RPI);
...@@ -821,6 +827,13 @@ CMathAmp.prototype = ...@@ -821,6 +827,13 @@ CMathAmp.prototype =
} }
}, },
PreRecalc: function(Parent, ParaMath, ArgSize, RPI)
{
if(!this.bJDraw)
this.Parent = Parent;
else
this.Parent = null;
},
Get_WidthVisible: function() Get_WidthVisible: function()
{ {
return this.size.width; return this.size.width;
......
...@@ -242,12 +242,12 @@ CMatrixBase.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -242,12 +242,12 @@ CMatrixBase.prototype.recalculateSize = function(oMeasure, RPI)
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
var txtPrp = this.Get_CompiledCtrPrp(); var FontSize = this.GetTPrpToControlLetter().FontSize;
var metrics = this.getMetrics(); var metrics = this.getMetrics();
if(this.nCol > 1) if(this.nCol > 1)
{ {
var gapsCol = this.getLineGap(this.spaceColumn, txtPrp); var gapsCol = this.getLineGap(this.spaceColumn, FontSize);
for(var i = 0; i < this.nCol - 1; i++) for(var i = 0; i < this.nCol - 1; i++)
this.gaps.column[i] = gapsCol; this.gaps.column[i] = gapsCol;
...@@ -257,12 +257,12 @@ CMatrixBase.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -257,12 +257,12 @@ CMatrixBase.prototype.recalculateSize = function(oMeasure, RPI)
if(this.nRow > 1) if(this.nRow > 1)
{ {
var intervalRow = this.getRowSpace(this.spaceRow, txtPrp); var intervalRow = this.getRowSpace(this.spaceRow, FontSize);
var divCenter = 0; var divCenter = 0;
var plH = 0.2743827160493827 * txtPrp.FontSize; var plH = 0.2743827160493827*FontSize;
var minGp = this.spaceRow.minGap*txtPrp.FontSize*g_dKoef_pt_to_mm; var minGp = this.spaceRow.minGap*FontSize*g_dKoef_pt_to_mm;
minGp -= plH; minGp -= plH;
for(var j = 0; j < this.nRow - 1; j++) for(var j = 0; j < this.nRow - 1; j++)
...@@ -355,7 +355,7 @@ CMatrixBase.prototype.setRuleGap = function(oSpace, rule, gap, minGap) ...@@ -355,7 +355,7 @@ CMatrixBase.prototype.setRuleGap = function(oSpace, rule, gap, minGap)
if(minGap == minGap - 0 && minGap == minGap^0) if(minGap == minGap - 0 && minGap == minGap^0)
oSpace.minGap = minGap; oSpace.minGap = minGap;
}; };
CMatrixBase.prototype.getLineGap = function(spaceColumn, txtPrp) CMatrixBase.prototype.getLineGap = function(spaceColumn, FontSize)
{ {
var spLine; var spLine;
...@@ -377,9 +377,9 @@ CMatrixBase.prototype.getLineGap = function(spaceColumn, txtPrp) ...@@ -377,9 +377,9 @@ CMatrixBase.prototype.getLineGap = function(spaceColumn, txtPrp)
if(spaceColumn.rule == 3) if(spaceColumn.rule == 3)
lineGap = spLine*g_dKoef_pt_to_mm; //pt lineGap = spLine*g_dKoef_pt_to_mm; //pt
else else
lineGap = spLine*txtPrp.FontSize*g_dKoef_pt_to_mm; //em lineGap = spLine*FontSize*g_dKoef_pt_to_mm; //em
var wPlh = 0.3241834852430555 * txtPrp.FontSize; var wPlh = 0.3241834852430555*FontSize;
var min = spaceColumn.minGap / 20 * g_dKoef_pt_to_mm - wPlh; var min = spaceColumn.minGap / 20 * g_dKoef_pt_to_mm - wPlh;
lineGap = Math.max(lineGap, min); lineGap = Math.max(lineGap, min);
...@@ -387,7 +387,7 @@ CMatrixBase.prototype.getLineGap = function(spaceColumn, txtPrp) ...@@ -387,7 +387,7 @@ CMatrixBase.prototype.getLineGap = function(spaceColumn, txtPrp)
return lineGap; return lineGap;
}; };
CMatrixBase.prototype.getRowSpace = function(spaceRow, txtPrp) CMatrixBase.prototype.getRowSpace = function(spaceRow, FontSize)
{ {
var spLine; var spLine;
...@@ -409,10 +409,10 @@ CMatrixBase.prototype.getRowSpace = function(spaceRow, txtPrp) ...@@ -409,10 +409,10 @@ CMatrixBase.prototype.getRowSpace = function(spaceRow, txtPrp)
if(spaceRow.rule == 3) if(spaceRow.rule == 3)
lineGap = spLine*g_dKoef_pt_to_mm; //pt lineGap = spLine*g_dKoef_pt_to_mm; //pt
else else
lineGap = spLine*txtPrp.FontSize*g_dKoef_pt_to_mm; //em lineGap = spLine*FontSize*g_dKoef_pt_to_mm; //em
var min = spaceRow.minGap*txtPrp.FontSize*g_dKoef_pt_to_mm; var min = spaceRow.minGap*FontSize*g_dKoef_pt_to_mm;
lineGap = Math.max(lineGap, min); lineGap = Math.max(lineGap, min);
return lineGap; return lineGap;
...@@ -688,30 +688,22 @@ CEqArray.prototype.fillContent = function() ...@@ -688,30 +688,22 @@ CEqArray.prototype.fillContent = function()
for (var nIndex = 0; nIndex < nRowsCount; nIndex++) for (var nIndex = 0; nIndex < nRowsCount; nIndex++)
this.elements[nIndex][0] = this.Content[nIndex]; this.elements[nIndex][0] = this.Content[nIndex];
}; };
CEqArray.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CEqArray.prototype.Resize = function(oMeasure, RPI)
{ {
// на случай, чтобы не затереть массив // на случай, чтобы не затереть массив
//var CurrAmperWPoints = RPI.AmperWPoints, //var CurrAmperWPoints = RPI.AmperWPoints,
// CurrEqqArray = RPI.bEqqArray; // CurrEqqArray = RPI.bEqqArray;
RPI.bEqqArray = true; var NewRPI = RPI.Copy();
NewRPI.bEqqArray = true;
this.Parent = Parent;
this.ParaMath = ParaMath;
for(var i = 0; i < this.nRow; i++) for(var i = 0; i < this.nRow; i++)
{ {
this.elements[i][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.elements[i][0].Resize(oMeasure, NewRPI);
} }
this.recalculateSize(oMeasure, RPI); this.recalculateSize(oMeasure);
RPI.bEqqArray = false;
//RPI.AmperWPoints = CurrAmperWPoints;
//RPI.bEqqArray = CurrEqqArray;
//CEqArray.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSize);
} }
CEqArray.prototype.getMetrics = function() CEqArray.prototype.getMetrics = function()
{ {
......
...@@ -147,7 +147,7 @@ Asc.extendClass(CNary, CMathBase); ...@@ -147,7 +147,7 @@ Asc.extendClass(CNary, CMathBase);
CNary.prototype.ClassType = historyitem_type_nary; CNary.prototype.ClassType = historyitem_type_nary;
CNary.prototype.kind = MATH_NARY; CNary.prototype.kind = MATH_NARY;
CNary.prototype.init = function(props) CNary.prototype.init = function(props)
{ {
this.Fill_LogicalContent(3); this.Fill_LogicalContent(3);
...@@ -207,7 +207,7 @@ CNary.prototype.fillBase = function(PropsInfo) ...@@ -207,7 +207,7 @@ CNary.prototype.fillBase = function(PropsInfo)
base.setBase(Sign); base.setBase(Sign);
base.setIterator(this.LowerIterator); base.setIterator(this.LowerIterator);
base.fillContent(); base.fillContent();
base.Set_CompiledCtrPrp(this.ParaMath); //base.Set_CompiledCtrPrp(this.ParaMath);
} }
else if( !PropsInfo.supHide && PropsInfo.subHide ) else if( !PropsInfo.supHide && PropsInfo.subHide )
{ {
...@@ -217,7 +217,7 @@ CNary.prototype.fillBase = function(PropsInfo) ...@@ -217,7 +217,7 @@ CNary.prototype.fillBase = function(PropsInfo)
base.setIterator(this.UpperIterator); base.setIterator(this.UpperIterator);
base.fillContent(); base.fillContent();
base.Set_CompiledCtrPrp(this.ParaMath); //base.Set_CompiledCtrPrp(this.ParaMath);
} }
else if(PropsInfo.supHide && PropsInfo.subHide) else if(PropsInfo.supHide && PropsInfo.subHide)
...@@ -233,15 +233,67 @@ CNary.prototype.fillBase = function(PropsInfo) ...@@ -233,15 +233,67 @@ CNary.prototype.fillBase = function(PropsInfo)
base.setUpperIterator(this.UpperIterator); base.setUpperIterator(this.UpperIterator);
base.fillContent(); base.fillContent();
base.Set_CompiledCtrPrp(this.ParaMath); //base.Set_CompiledCtrPrp(this.ParaMath);
} }
} }
this.Base = base; this.Base = base;
this.addMCToContent( [base, this.Arg] ); this.addMCToContent( [base, this.Arg] );
}
CNary.prototype.ApplyProperties = function(RPI)
{
if(this.RecalcInfo.bProps || RPI.bChangeInline == true)
{
var oSign = this.getSign(this.Pr.chr, this.Pr.chrType);
this.Sign = oSign.operator;
var limLoc = this.Pr.limLoc;
if(RPI.bInline == true || RPI.bDecreasedComp == true)
{
limLoc = NARY_SubSup;
this.Sign = new CMathText(true);
this.Sign.add(oSign.chrCode);
}
if(limLoc == null || typeof(limLoc) == "undefined")
{
var bIntegral = oSign.chrCode > 0x222A && oSign.chrCode < 0x2231;
if(bIntegral)
limLoc = g_oMathSettings.intLim;
else
limLoc = g_oMathSettings.naryLim;
}
var PropsInfo =
{
limLoc : limLoc,
sign: this.Sign,
supHide: this.Pr.supHide,
subHide: this.Pr.subHide
};
// пока оставим так, chrType сейчас нигде не используется
this.Pr.chrType = oSign.chrType;
this.fillBase(PropsInfo);
this.RecalcInfo.bProps = false;
}
}
CNary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
var NewRPI = RPI.Copy();
if(RPI.bInline || RPI.bDecreasedComp)
NewRPI.bNaryInline = true;
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
} }
CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) /*CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
...@@ -298,7 +350,7 @@ CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -298,7 +350,7 @@ CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.Arg.Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.Arg.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
this.recalculateSize(oMeasure); this.recalculateSize(oMeasure);
} }*/
CNary.prototype.getSign = function(chrCode, chrType) CNary.prototype.getSign = function(chrCode, chrType)
{ {
var result = var result =
...@@ -417,7 +469,7 @@ CNary.prototype.setCtrPrp = function(txtPrp) ...@@ -417,7 +469,7 @@ CNary.prototype.setCtrPrp = function(txtPrp)
} }
CNary.prototype.setDistance = function() CNary.prototype.setDistance = function()
{ {
this.dW = this.Get_CompiledCtrPrp().FontSize/36*2.45; this.dW = this.GetTPrpToControlLetter().FontSize/36*2.45;
} }
CNary.prototype.getBase = function() CNary.prototype.getBase = function()
{ {
...@@ -444,7 +496,7 @@ function CNaryUnd(bInside) ...@@ -444,7 +496,7 @@ function CNaryUnd(bInside)
Asc.extendClass(CNaryUnd, CMathBase); Asc.extendClass(CNaryUnd, CMathBase);
CNaryUnd.prototype.setDistance = function() CNaryUnd.prototype.setDistance = function()
{ {
var zetta = this.Get_CompiledCtrPrp().FontSize*25.4/96; var zetta = this.GetTPrpToControlLetter().FontSize*25.4/96;
this.dH = zetta*0.25; this.dH = zetta*0.25;
} }
CNaryUnd.prototype.getAscent = function() CNaryUnd.prototype.getAscent = function()
...@@ -455,19 +507,29 @@ CNaryUnd.prototype.getUpperIterator = function() ...@@ -455,19 +507,29 @@ CNaryUnd.prototype.getUpperIterator = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
CNaryUnd.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CNaryUnd.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
var ArgSzUnd = ArgSize.Copy(); var ArgSzUnd = ArgSize.Copy();
ArgSzUnd.decrease(); ArgSzUnd.decrease();
this.elements[0][0].Resize(oMeasure, this, ParaMath, RPI, ArgSzUnd); var RPIUnd = RPI.Copy();
this.elements[1][0].Resize(oMeasure, this, ParaMath, RPI, ArgSize); RPIUnd.bDecreasedComp = true;
this.recalculateSize(oMeasure); this.elements[0][0].PreRecalc(this, ParaMath, ArgSzUnd, RPIUnd);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
} }
/*CNaryUnd.prototype.Resize = function(oMeasure, RPI)
{
this.elements[0][0].Resize(oMeasure, RPI);
this.elements[1][0].Resize(oMeasure, RPI);
this.recalculateSize(oMeasure);
}*/
CNaryUnd.prototype.setBase = function(base) CNaryUnd.prototype.setBase = function(base)
{ {
this.elements[1][0] = base; this.elements[1][0] = base;
...@@ -487,10 +549,26 @@ function CNaryOvr(bInside) ...@@ -487,10 +549,26 @@ function CNaryOvr(bInside)
Asc.extendClass(CNaryOvr, CMathBase); Asc.extendClass(CNaryOvr, CMathBase);
CNaryOvr.prototype.old_setDistance = function() CNaryOvr.prototype.old_setDistance = function()
{ {
var zetta = this.Get_CompiledCtrPrp().FontSize* 25.4/96; var zetta = this.GetTPrpToControlLetter().FontSize* 25.4/96;
this.dH = zetta*0.1; this.dH = zetta*0.1;
} }
CNaryOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CNaryOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
var ArgSzOvr = ArgSize.Copy();
ArgSzOvr.decrease();
var RPIOvr = RPI.Copy();
RPIOvr.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSzOvr, RPIOvr);
}
/*CNaryOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
...@@ -502,10 +580,10 @@ CNaryOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -502,10 +580,10 @@ CNaryOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.elements[1][0].Resize(oMeasure, this, ParaMath, RPI, ArgSzOvr); this.elements[1][0].Resize(oMeasure, this, ParaMath, RPI, ArgSzOvr);
this.recalculateSize(oMeasure); this.recalculateSize(oMeasure);
} }*/
CNaryOvr.prototype.recalculateSize = function() CNaryOvr.prototype.recalculateSize = function()
{ {
var FontSize = this.Get_CompiledCtrPrp().FontSize; var FontSize = this.GetTPrpToControlLetter().FontSize;
var zetta = FontSize*25.4/96; var zetta = FontSize*25.4/96;
var minGapBottom = zetta*0.1, var minGapBottom = zetta*0.1,
...@@ -550,7 +628,25 @@ function CNaryUndOvr(bInside) ...@@ -550,7 +628,25 @@ function CNaryUndOvr(bInside)
this.setDimension(3,1); this.setDimension(3,1);
} }
Asc.extendClass(CNaryUndOvr, CMathBase); Asc.extendClass(CNaryUndOvr, CMathBase);
CNaryUndOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CNaryUndOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
var ArgSzIter = ArgSize.Copy();
ArgSzIter.decrease();
var RPI_Iter = RPI.Copy();
RPI_Iter.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzIter, RPI_Iter);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[2][0].PreRecalc(this, ParaMath, ArgSzIter, RPI_Iter);
}
/*CNaryUndOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
...@@ -566,10 +662,10 @@ CNaryUndOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize ...@@ -566,10 +662,10 @@ CNaryUndOvr.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize
this.elements[2][0].Resize(oMeasure, this, ParaMath, RPI, ArgSzOvr); this.elements[2][0].Resize(oMeasure, this, ParaMath, RPI, ArgSzOvr);
this.recalculateSize(oMeasure); this.recalculateSize(oMeasure);
} }*/
CNaryUndOvr.prototype.recalculateSize = function() CNaryUndOvr.prototype.recalculateSize = function()
{ {
var FontSize = this.Get_CompiledCtrPrp().FontSize; var FontSize = this.GetTPrpToControlLetter().FontSize;
var zetta = FontSize*25.4/96; var zetta = FontSize*25.4/96;
this.gapTop = zetta*0.25; this.gapTop = zetta*0.25;
...@@ -666,7 +762,7 @@ CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics) ...@@ -666,7 +762,7 @@ CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics)
YY = []; YY = [];
//var textScale = this.getTxtPrp().FontSize/850; // 1000 pt //var textScale = this.getTxtPrp().FontSize/850; // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850; // 1000 pt var textScale = this.GetTPrpToControlLetter().FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
// g_dKoef_px_to_mm = 25.4/96 // g_dKoef_px_to_mm = 25.4/96
...@@ -705,12 +801,18 @@ CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics) ...@@ -705,12 +801,18 @@ CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics)
CNaryOperator.prototype.drawTextElem = function(x, y, pGraphics) CNaryOperator.prototype.drawTextElem = function(x, y, pGraphics)
{ {
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
var rPrp = new CTextPr();
rPrp.Merge( this.Get_CompiledCtrPrp() );
rPrp.Italic = false;
rPrp.Bold = false;
pGraphics.SetFont(rPrp); var ctrPrp = this.GetTPrpToControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
pGraphics.SetFont(Font);
CNaryOperator.superclass.call.draw(this, x, y, pGraphics); CNaryOperator.superclass.call.draw(this, x, y, pGraphics);
} }
...@@ -729,20 +831,22 @@ CNaryOperator.prototype.recalculateSize = function() ...@@ -729,20 +831,22 @@ CNaryOperator.prototype.recalculateSize = function()
var height = this.sizeGlyph.height, var height = this.sizeGlyph.height,
width = this.sizeGlyph.width, width = this.sizeGlyph.width,
ascent = this.sizeGlyph.height/2 + DIV_CENT*this.Get_CompiledCtrPrp().FontSize; ascent = this.sizeGlyph.height/2 + DIV_CENT*this.GetTPrpToControlLetter().FontSize;
this.size = {height: height, width: width, ascent: ascent}; this.size = {height: height, width: width, ascent: ascent};
} }
CNaryOperator.prototype.Resize = function(oMeasure, Parent, ParaMath) CNaryOperator.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
}
CNaryOperator.prototype.Resize = function(oMeasure, RPI)
{
this.recalculateSize(); //обычный пересчет, oMeasure не нужен this.recalculateSize(); //обычный пересчет, oMeasure не нужен
} }
CNaryOperator.prototype.Get_CompiledCtrPrp = function() CNaryOperator.prototype.GetTPrpToControlLetter = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.GetTPrpToControlLetter();
} }
/*CNaryOperator.prototype.IsOnlyText = function() /*CNaryOperator.prototype.IsOnlyText = function()
{ {
...@@ -865,7 +969,7 @@ CSigma.prototype.getCoord = function() ...@@ -865,7 +969,7 @@ CSigma.prototype.getCoord = function()
//var textScale = this.getTxtPrp().FontSize/850; // 1000 pt //var textScale = this.getTxtPrp().FontSize/850; // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850; // 1000 pt var textScale = this.GetTPrpToControlLetter().FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; var alpha = textScale*25.4/96 /64;
var h1 = Y[0] - Y[21], var h1 = Y[0] - Y[21],
...@@ -937,7 +1041,7 @@ CSigma.prototype.calculateSizeGlyph = function() ...@@ -937,7 +1041,7 @@ CSigma.prototype.calculateSizeGlyph = function()
// пока размер не меняем в зависимости от высоты аргумента // пока размер не меняем в зависимости от высоты аргумента
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 8.997900390624999*betta, var _width = 8.997900390624999*betta,
_height = 11.994444444444444*betta; _height = 11.994444444444444*betta;
...@@ -1069,7 +1173,7 @@ CProduct.prototype.getCoord = function() ...@@ -1069,7 +1173,7 @@ CProduct.prototype.getCoord = function()
//var textScale = this.getTxtPrp().FontSize/850, // 1000 pt //var textScale = this.getTxtPrp().FontSize/850, // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850, // 1000 pt var textScale = this.GetTPrpToControlLetter().FontSize/850, // 1000 pt
alpha = textScale*25.4/96 /64; alpha = textScale*25.4/96 /64;
var h1 = Y[9], var h1 = Y[9],
...@@ -1100,7 +1204,7 @@ CProduct.prototype.getCoord = function() ...@@ -1100,7 +1204,7 @@ CProduct.prototype.getCoord = function()
CProduct.prototype.calculateSizeGlyph = function() CProduct.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 10.312548828125*betta, var _width = 10.312548828125*betta,
_height = 11.994444444444444*betta; _height = 11.994444444444444*betta;
...@@ -1172,7 +1276,7 @@ CUnion.prototype.getCoord = function() ...@@ -1172,7 +1276,7 @@ CUnion.prototype.getCoord = function()
CUnion.prototype.calculateSizeGlyph = function() CUnion.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
this.gap = 0.93*betta; this.gap = 0.93*betta;
var _width = 9.38*betta, var _width = 9.38*betta,
...@@ -1291,7 +1395,7 @@ CLogicalOr.prototype.getCoord = function() ...@@ -1291,7 +1395,7 @@ CLogicalOr.prototype.getCoord = function()
X[7] = 0; Y[7] = 0; X[7] = 0; Y[7] = 0;
//var textScale = this.getTxtPrp().FontSize/850, // 1000 pt //var textScale = this.getTxtPrp().FontSize/850, // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850, // 1000 pt var textScale = this.GetTPrpToControlLetter().FontSize/850, // 1000 pt
alpha = textScale*25.4/96 /64; alpha = textScale*25.4/96 /64;
var w1 = X[1], var w1 = X[1],
...@@ -1323,7 +1427,7 @@ CLogicalOr.prototype.getCoord = function() ...@@ -1323,7 +1427,7 @@ CLogicalOr.prototype.getCoord = function()
CLogicalOr.prototype.calculateSizeGlyph = function() CLogicalOr.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 9.6159*betta, var _width = 9.6159*betta,
_height = 11.994444444444444*betta; _height = 11.994444444444444*betta;
...@@ -1553,7 +1657,7 @@ CIntegral.prototype.old_drawPath = function(XX, YY) ...@@ -1553,7 +1657,7 @@ CIntegral.prototype.old_drawPath = function(XX, YY)
CIntegral.prototype.calculateSizeGlyph = function() CIntegral.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 8.624*betta, var _width = 8.624*betta,
_height = 13.7*betta; _height = 13.7*betta;
...@@ -1594,7 +1698,7 @@ CDoubleIntegral.prototype.drawPath = function(pGraphics, XX, YY) ...@@ -1594,7 +1698,7 @@ CDoubleIntegral.prototype.drawPath = function(pGraphics, XX, YY)
CDoubleIntegral.prototype.calculateSizeGlyph = function() CDoubleIntegral.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 14.2296*betta, var _width = 14.2296*betta,
_height = 13.7*betta; _height = 13.7*betta;
...@@ -1645,7 +1749,7 @@ CTripleIntegral.prototype.drawPath = function(pGraphics, XX, YY) ...@@ -1645,7 +1749,7 @@ CTripleIntegral.prototype.drawPath = function(pGraphics, XX, YY)
CTripleIntegral.prototype.calculateSizeGlyph = function() CTripleIntegral.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 18.925368*betta, var _width = 18.925368*betta,
_height = 13.7*betta; _height = 13.7*betta;
...@@ -2009,7 +2113,7 @@ CContourIntegral.prototype.draw = function(x, y, pGraphics) ...@@ -2009,7 +2113,7 @@ CContourIntegral.prototype.draw = function(x, y, pGraphics)
HH = coord2.H; HH = coord2.H;
//var textScale = this.getTxtPrp().FontSize/850;// 1000 pt //var textScale = this.getTxtPrp().FontSize/850;// 1000 pt
var FontSize = this.Get_CompiledCtrPrp().FontSize; var FontSize = this.GetTPrpToControlLetter().FontSize;
var textScale = FontSize/850;// 1000 pt var textScale = FontSize/850;// 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
...@@ -2057,7 +2161,7 @@ CContourIntegral.prototype.draw = function(x, y, pGraphics) ...@@ -2057,7 +2161,7 @@ CContourIntegral.prototype.draw = function(x, y, pGraphics)
CContourIntegral.prototype.calculateSizeGlyph = function() CContourIntegral.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 8.624*betta, var _width = 8.624*betta,
_height = 13.7*betta; _height = 13.7*betta;
...@@ -2094,7 +2198,7 @@ CSurfaceIntegral.prototype.draw = function(x, y, pGraphics) ...@@ -2094,7 +2198,7 @@ CSurfaceIntegral.prototype.draw = function(x, y, pGraphics)
WW = 1.6*coord2.W, WW = 1.6*coord2.W,
HH = coord2.H; HH = coord2.H;
var FontSize = this.Get_CompiledCtrPrp().FontSize; var FontSize = this.GetTPrpToControlLetter().FontSize;
var textScale = FontSize/850; // 1000 pt var textScale = FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
...@@ -2142,7 +2246,7 @@ CSurfaceIntegral.prototype.draw = function(x, y, pGraphics) ...@@ -2142,7 +2246,7 @@ CSurfaceIntegral.prototype.draw = function(x, y, pGraphics)
CSurfaceIntegral.prototype.calculateSizeGlyph = function() CSurfaceIntegral.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 14.2296*betta, var _width = 14.2296*betta,
_height = 13.7*betta; _height = 13.7*betta;
...@@ -2178,7 +2282,7 @@ CVolumeIntegral.prototype.draw = function(x, y, pGraphics) ...@@ -2178,7 +2282,7 @@ CVolumeIntegral.prototype.draw = function(x, y, pGraphics)
WW = 2.1*coord2.W, WW = 2.1*coord2.W,
HH = coord2.H; HH = coord2.H;
var FontSize = this.Get_CompiledCtrPrp().FontSize; var FontSize = this.GetTPrpToControlLetter().FontSize;
var textScale = FontSize/850; // 1000 pt var textScale = FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
...@@ -2225,7 +2329,7 @@ CVolumeIntegral.prototype.draw = function(x, y, pGraphics) ...@@ -2225,7 +2329,7 @@ CVolumeIntegral.prototype.draw = function(x, y, pGraphics)
CVolumeIntegral.prototype.calculateSizeGlyph = function() CVolumeIntegral.prototype.calculateSizeGlyph = function()
{ {
//var betta = this.getTxtPrp().FontSize/36; //var betta = this.getTxtPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36; var betta = this.GetTPrpToControlLetter().FontSize/36;
var _width = 18.925368*betta, var _width = 18.925368*betta,
_height = 13.7*betta; _height = 13.7*betta;
......
...@@ -403,11 +403,11 @@ CGlyphOperator.prototype.drawOnlyLines = function(x, y, pGraphics) ...@@ -403,11 +403,11 @@ CGlyphOperator.prototype.drawOnlyLines = function(x, y, pGraphics)
} }
CGlyphOperator.prototype.getCtrPrp = function() CGlyphOperator.prototype.getCtrPrp = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.GetTPrpToControlLetter();
} }
CGlyphOperator.prototype.relate = function(parent) CGlyphOperator.prototype.PreRecalc = function(Parent)
{ {
this.Parent = parent; this.Parent = Parent;
} }
...@@ -2937,16 +2937,19 @@ COperator.prototype.draw = function(x, y, pGraphics) ...@@ -2937,16 +2937,19 @@ COperator.prototype.draw = function(x, y, pGraphics)
{ {
// выставляем font, если нужно отрисовать текст // выставляем font, если нужно отрисовать текст
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
var ctrPrp = this.Get_CompiledCtrPrp();
var rPrp = new CTextPr(); var ctrPrp = this.GetTPrpToControlLetter();
//var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;
var defaultRPrp = this.Parent.ParaMath.Get_Default_TPrp(); var Font =
rPrp.Merge(defaultRPrp); {
rPrp.Merge(ctrPrp); FontSize: ctrPrp.FontSize,
rPrp.Italic = false; FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
rPrp.Bold = false; Italic: false,
pGraphics.SetFont(rPrp); Bold: false
};
pGraphics.SetFont(Font);
//////////////////////////////////////////////// ////////////////////////////////////////////////
...@@ -3017,24 +3020,25 @@ COperator.prototype.IsLineGlyph = function() ...@@ -3017,24 +3020,25 @@ COperator.prototype.IsLineGlyph = function()
{ {
return this.typeOper == ACCENT_LINE || this.typeOper == ACCENT_DOUBLE_LINE; return this.typeOper == ACCENT_LINE || this.typeOper == ACCENT_DOUBLE_LINE;
} }
COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch) COperator.prototype.fixSize = function(oMeasure, stretch)
{ {
this.ParaMath = ParaMath;
if(this.typeOper !== OPERATOR_EMPTY) if(this.typeOper !== OPERATOR_EMPTY)
{ {
var width, height, ascent; var width, height, ascent;
var dims; var dims;
var ctrPrp = this.Get_CompiledCtrPrp(); var ctrPrp = this.GetTPrpToControlLetter();
var rPrp = new CTextPr(); var Font =
var defaultRPrp = this.Parent.ParaMath.Get_Default_TPrp(); {
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
rPrp.Merge(defaultRPrp);
rPrp.Merge(ctrPrp);
rPrp.Italic = false;
oMeasure.SetFont(rPrp); oMeasure.SetFont(Font);
var bLine = this.IsLineGlyph(); var bLine = this.IsLineGlyph();
...@@ -3096,8 +3100,8 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch) ...@@ -3096,8 +3100,8 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
// Ascent // Ascent
var mgCtrPrp = this.Parent.Get_CompiledCtrPrp(); var mgCtrPrp = this.Parent.GetTPrpToControlLetter();
var shCenter = this.Parent.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
if(!bLine && (this.operator.loc == LOCATION_TOP || this.operator.loc == LOCATION_BOT)) if(!bLine && (this.operator.loc == LOCATION_TOP || this.operator.loc == LOCATION_BOT))
ascent = dims.Height/2; ascent = dims.Height/2;
...@@ -3162,30 +3166,28 @@ COperator.prototype.IsJustDraw = function() ...@@ -3162,30 +3166,28 @@ COperator.prototype.IsJustDraw = function()
{ {
return true; return true;
} }
COperator.prototype.Resize = function(Parent, ParaMath, oMeasure) COperator.prototype.Resize = function(oMeasure)
{ {
this.ParaMath = ParaMath;
this.Parent = Parent;
if(this.typeOper !== OPERATOR_EMPTY) if(this.typeOper !== OPERATOR_EMPTY)
{ {
var bHor = this.operator.loc == 0 || this.operator.loc == 1; var bHor = this.operator.loc == 0 || this.operator.loc == 1;
if(bHor) if(bHor)
this.fixSize(ParaMath, oMeasure, this.size.width); this.fixSize(oMeasure, this.size.width);
else else
this.fixSize(ParaMath, oMeasure, this.size.height); this.fixSize(oMeasure, this.size.height);
} }
} }
COperator.prototype.relate = function(parent) COperator.prototype.PreRecalc = function(Parent, ParaMath)
{ {
this.Parent = parent; this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.typeOper !== OPERATOR_EMPTY) if(this.typeOper !== OPERATOR_EMPTY)
this.operator.relate(this); this.operator.PreRecalc(this); // в данном случае mathText нужен только один параметр
} }
COperator.prototype.Get_CompiledCtrPrp = function() COperator.prototype.GetTPrpToControlLetter = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.GetTPrpToControlLetter();
} }
COperator.prototype.getChr = function() COperator.prototype.getChr = function()
{ {
...@@ -3235,8 +3237,8 @@ CMathDelimiterPr.prototype.Set_FromObject = function(Obj) ...@@ -3235,8 +3237,8 @@ CMathDelimiterPr.prototype.Set_FromObject = function(Obj)
if(DELIMITER_SHAPE_MATH === Obj.shp || DELIMITER_SHAPE_CENTERED === Obj.shp) if(DELIMITER_SHAPE_MATH === Obj.shp || DELIMITER_SHAPE_CENTERED === Obj.shp)
this.shp = Obj.shp; this.shp = Obj.shp;
if(true === Obj.grow || 1 === Obj.grow) if(false === Obj.grow || 0 === Obj.grow)
this.grow = true; this.grow = false;
if(undefined !== Obj.column && null !== Obj.column) if(undefined !== Obj.column && null !== Obj.column)
this.column = Obj.column; this.column = Obj.column;
...@@ -3421,12 +3423,8 @@ CDelimiter.prototype.fillContent = function() ...@@ -3421,12 +3423,8 @@ CDelimiter.prototype.fillContent = function()
for (var nIndex = 0; nIndex < nColumnsCount; nIndex++) for (var nIndex = 0; nIndex < nColumnsCount; nIndex++)
this.elements[0][nIndex] = this.Content[nIndex]; this.elements[0][nIndex] = this.Content[nIndex];
} }
CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CDelimiter.prototype.ApplyProperties = function(RPI)
{ {
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bProps == true) if(this.RecalcInfo.bProps == true)
{ {
var begPrp = var begPrp =
...@@ -3442,7 +3440,6 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3442,7 +3440,6 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
chr: 0x28 chr: 0x28
}; };
this.begOper.mergeProperties(begPrp, begDefaultPrp); this.begOper.mergeProperties(begPrp, begDefaultPrp);
this.begOper.relate(this);
var endPrp = var endPrp =
{ {
...@@ -3458,7 +3455,6 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3458,7 +3455,6 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
}; };
this.endOper.mergeProperties(endPrp, endDefaultPrp); this.endOper.mergeProperties(endPrp, endDefaultPrp);
this.endOper.relate(this);
var sepPrp = var sepPrp =
{ {
...@@ -3477,12 +3473,22 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3477,12 +3473,22 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
sepPrp.type = OPERATOR_EMPTY; sepPrp.type = OPERATOR_EMPTY;
this.sepOper.mergeProperties(sepPrp, sepDefaultPrp); this.sepOper.mergeProperties(sepPrp, sepDefaultPrp);
this.sepOper.relate(this);
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
}
CDelimiter.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
this.begOper.PreRecalc(this, ParaMath);
this.endOper.PreRecalc(this, ParaMath);
this.sepOper.PreRecalc(this, ParaMath);
CDelimiter.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
}
CDelimiter.prototype.Resize = function(oMeasure, RPI)
{
// размеры аргумента // размеры аргумента
var heightG = 0, widthG = 0, var heightG = 0, widthG = 0,
ascentG = 0, descentG = 0; ascentG = 0, descentG = 0;
...@@ -3491,7 +3497,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3491,7 +3497,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
this.elements[0][j].Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.elements[0][j].Resize(oMeasure, RPI);
var content = this.elements[0][j].size; var content = this.elements[0][j].size;
widthG += content.width; widthG += content.width;
ascentG = content.ascent > ascentG ? content.ascent : ascentG; ascentG = content.ascent > ascentG ? content.ascent : ascentG;
...@@ -3500,7 +3506,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3500,7 +3506,7 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
heightG = ascentG + descentG; heightG = ascentG + descentG;
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.GetTPrpToControlLetter();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var maxAD = ascentG - shCenter > descentG + shCenter ? ascentG - shCenter: descentG + shCenter; var maxAD = ascentG - shCenter > descentG + shCenter ? ascentG - shCenter: descentG + shCenter;
...@@ -3514,9 +3520,9 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -3514,9 +3520,9 @@ CDelimiter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
var heightStretch = b2Max && !bTextContent ? 2*maxAD : ascentG + descentG; var heightStretch = b2Max && !bTextContent ? 2*maxAD : ascentG + descentG;
this.begOper.fixSize(ParaMath, oMeasure, heightStretch); this.begOper.fixSize(oMeasure, heightStretch);
this.endOper.fixSize(ParaMath, oMeasure, heightStretch); this.endOper.fixSize(oMeasure, heightStretch);
this.sepOper.fixSize(ParaMath, 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; var width = widthG + this.begOper.size.width + this.endOper.size.width + (this.nCol - 1)*this.sepOper.size.width;
...@@ -3732,30 +3738,19 @@ CDelimiter.prototype.getBase = function(numb) ...@@ -3732,30 +3738,19 @@ CDelimiter.prototype.getBase = function(numb)
function CCharacter() function CCharacter()
{ {
this.operator = new COperator(OPER_GROUP_CHAR); this.operator = new COperator(OPER_GROUP_CHAR);
CMathBase.call(this); CMathBase.call(this);
} }
Asc.extendClass(CCharacter, CMathBase); Asc.extendClass(CCharacter, CMathBase);
CCharacter.prototype.setCharacter = function(props, defaultProps) CCharacter.prototype.setCharacter = function(props, defaultProps)
{ {
this.operator.mergeProperties(props, defaultProps); this.operator.mergeProperties(props, defaultProps);
this.operator.relate(this);
//this.setDimension(1, 1);
//this.setContent();
} }
CCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CCharacter.prototype.Resize = function(oMeasure, RPI)
{ {
this.Parent = Parent;
this.ParaMath = ParaMath;
var base = this.elements[0][0]; var base = this.elements[0][0];
base.Resize(oMeasure, this, ParaMath, RPI, ArgSize); base.Resize(oMeasure, RPI);
this.operator.fixSize(ParaMath, oMeasure, base.size.width);
var ctrPrp = this.Get_CompiledCtrPrp(); this.operator.fixSize(oMeasure, base.size.width);
oMeasure.SetFont(ctrPrp);
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.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, height = base.size.height + this.operator.size.height,
...@@ -3807,17 +3802,18 @@ CCharacter.prototype.draw = function(x, y, pGraphics) ...@@ -3807,17 +3802,18 @@ CCharacter.prototype.draw = function(x, y, pGraphics)
{ {
this.elements[0][0].draw(x, y, pGraphics); this.elements[0][0].draw(x, y, pGraphics);
var mgCtrPrp = this.Get_CompiledCtrPrp(); var ctrPrp = this.GetTPrpToControlLetter();
var FontSize = mgCtrPrp.FontSize,
FontFamily = {Name: "Cambria Math", Index: -1};
var obj = {FontSize: FontSize, FontFamily: FontFamily}; var Font =
{
var accFont = new CTextPr(); FontSize: ctrPrp.FontSize,
accFont.Set_FromObject(obj); FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false
};
pGraphics.SetFont(accFont); pGraphics.SetFont(Font);
pGraphics.p_color(0,0,0, 255); pGraphics.p_color(0,0,0, 255);
pGraphics.b_color1(0,0,0, 255); pGraphics.b_color1(0,0,0, 255);
...@@ -3848,7 +3844,6 @@ CMathGroupChrPr.prototype.Set_FromObject = function(Obj) ...@@ -3848,7 +3844,6 @@ CMathGroupChrPr.prototype.Set_FromObject = function(Obj)
if(LOCATION_TOP === Obj.pos || LOCATION_BOT === Obj.pos) if(LOCATION_TOP === Obj.pos || LOCATION_BOT === Obj.pos)
this.pos = Obj.pos; this.pos = Obj.pos;
}; };
CMathGroupChrPr.prototype.Copy = function() CMathGroupChrPr.prototype.Copy = function()
{ {
var NewPr = new CMathGroupChrPr(); var NewPr = new CMathGroupChrPr();
...@@ -3947,7 +3942,7 @@ CGroupCharacter.prototype.init = function(props) ...@@ -3947,7 +3942,7 @@ CGroupCharacter.prototype.init = function(props)
this.setProperties(props); this.setProperties(props);
this.fillContent(); this.fillContent();
} }
CGroupCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CGroupCharacter.prototype.ApplyProperties = function(RPI)
{ {
if(this.RecalcInfo.bProps == true) if(this.RecalcInfo.bProps == true)
{ {
...@@ -3967,27 +3962,35 @@ CGroupCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, Arg ...@@ -3967,27 +3962,35 @@ CGroupCharacter.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, Arg
this.setCharacter(operProps, operDefaultPrp); this.setCharacter(operProps, operDefaultPrp);
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
}
var ArgSz = ArgSize.Copy();
if(this.Pr.pos == this.Pr.vertJc) if(this.Pr.pos == this.Pr.vertJc)
{ {
ArgSz.decrease(); var Iterator;
var Iterator; if(this.Pr.pos == LOCATION_TOP)
Iterator = new CDenominator(this.getBase());
else
Iterator = new CNumerator(this.getBase());
if(this.Pr.pos == LOCATION_TOP) this.elements[0][0] = Iterator;
Iterator = new CDenominator(this.getBase()); }
else else
Iterator = new CNumerator(this.getBase()); this.elements[0][0] = this.getBase();
this.elements[0][0] = Iterator;
} }
else }
this.elements[0][0] = this.getBase(); CGroupCharacter.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
this.ApplyProperties(RPI);
this.operator.PreRecalc(this, ParaMath);
var ArgSz = ArgSize.Copy();
if(this.Pr.pos == this.Pr.vertJc)
ArgSz.decrease();
CGroupCharacter.superclass.Resize.call(this, oMeasure, Parent, ParaMath, RPI, ArgSz); CGroupCharacter.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSz, RPI, GapsInfo);
} }
CGroupCharacter.prototype.getBase = function() CGroupCharacter.prototype.getBase = function()
{ {
...@@ -4004,7 +4007,7 @@ CGroupCharacter.prototype.getAscent = function(oMeasure) ...@@ -4004,7 +4007,7 @@ CGroupCharacter.prototype.getAscent = function(oMeasure)
//var shCent = DIV_CENT*this.getCtrPrp().FontSize; //var shCent = DIV_CENT*this.getCtrPrp().FontSize;
var ctrPrp = this.Get_CompiledCtrPrp(); var ctrPrp = this.GetTPrpToControlLetter();
var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp); var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp);
if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_TOP) if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_TOP)
......
...@@ -439,11 +439,31 @@ CRadical.prototype.fillContent = function() ...@@ -439,11 +439,31 @@ CRadical.prototype.fillContent = function()
this.Iterator = this.getDegree(); this.Iterator = this.getDegree();
this.Base = this.getBase(); this.Base = this.getBase();
}; };
CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) CRadical.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{ {
this.Parent = Parent; this.Parent = Parent;
this.ParaMath = ParaMath; this.ParaMath = ParaMath;
this.Set_CompiledCtrPrp(Parent, ParaMath);
this.ApplyProperties(RPI);
if(this.Pr.type == SQUARE_RADICAL)
this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI);
else
{
var ArgSzIter = new CMathArgSize();
ArgSzIter.SetValue(-2);
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI);
}
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
}
CRadical.prototype.ApplyProperties = function(RPI)
{
if(this.RecalcInfo.bProps) if(this.RecalcInfo.bProps)
{ {
if(this.Pr.degHide == true) if(this.Pr.degHide == true)
...@@ -490,20 +510,16 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) ...@@ -490,20 +510,16 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
this.RecalcInfo.bProps = false; this.RecalcInfo.bProps = false;
} }
}
//this.Set_CompiledCtrPrp(ParaMath); CRadical.prototype.Resize = function(oMeasure, RPI)
{
if(this.Pr.type == SQUARE_RADICAL) if(this.Pr.type == SQUARE_RADICAL)
this.RealBase.Resize(oMeasure, this, ParaMath, RPI, ArgSize); this.RealBase.Resize(oMeasure, RPI);
else else
{ {
var ArgSzIter = new CMathArgSize(); this.Iterator.Resize(oMeasure, RPI);
ArgSzIter.SetValue(-2); this.RealBase.Resize(oMeasure, RPI);
//ArgSzIter.Merge(ArgSize);
this.Iterator.Resize(oMeasure, this, ParaMath, RPI, ArgSzIter);
this.RealBase.Resize(oMeasure, this, ParaMath, RPI, ArgSize);
} }
var shTop, var shTop,
......
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