Commit 0fa4717f authored by Anna Pavlova's avatar Anna Pavlova

Поправлен Bug #28463

Поправлен Bug #31826  в коммите 98f68569 [98f68569]
parent 98f68569
...@@ -258,33 +258,29 @@ CMathBase.prototype.align = function(pos_x, pos_y) ...@@ -258,33 +258,29 @@ CMathBase.prototype.align = function(pos_x, pos_y)
if(this.alignment.hgt[pos_x] == MCJC_CENTER) if(this.alignment.hgt[pos_x] == MCJC_CENTER)
{ {
var maxAsc = 0; var maxAsc = 0;
var _ascent;
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
_ascent = this.elements[pos_x][j].size.ascent; var _ascent = this.elements[pos_x][j].size.ascent;
maxAsc = ( maxAsc > _ascent ) ? maxAsc : _ascent; maxAsc = ( maxAsc > _ascent ) ? maxAsc : _ascent;
} }
PosAlign.y = (maxAsc - this.elements[pos_x][pos_y].size.ascent); PosAlign.y = maxAsc - this.elements[pos_x][pos_y].size.ascent;
} }
else else if(this.alignment.hgt[pos_x] == MCJC_LEFT)
{
PosAlign.y = 0;
}
else // MCJC_RIGHT
{ {
var maxH = 0; var maxH = 0;
var _h;
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
_h = this.elements[pos_x][j].size.height; var _h = this.elements[pos_x][j].size.height;
maxH = ( maxH > _h ) ? maxH : _h; maxH = ( maxH > _h ) ? maxH : _h;
} }
var coeffHgt; PosAlign.y = maxH - this.elements[pos_x][pos_y].size.height;
if(this.alignment.hgt[pos_x] == MCJC_RIGHT)
coeffHgt = 1;
else
coeffHgt = 0;
PosAlign.y = (maxH - this.elements[pos_x][pos_y].size.height)*coeffHgt;
} }
var maxW = 0; var maxW = 0;
...@@ -296,16 +292,10 @@ CMathBase.prototype.align = function(pos_x, pos_y) ...@@ -296,16 +292,10 @@ CMathBase.prototype.align = function(pos_x, pos_y)
if(this.alignment.wdt[pos_y] == MCJC_CENTER) if(this.alignment.wdt[pos_y] == MCJC_CENTER)
PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*0.5; PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*0.5;
else else if(this.alignment.hgt[pos_x] == MCJC_LEFT)
{ PosAlign.x = 0;
var coeffWdt; else // MCJC_RIGHT
if(this.alignment.wdt[pos_y] == MCJC_RIGHT) PosAlign.x = maxW - this.elements[pos_x][pos_y].size.width;
coeffWdt = 1;
else
coeffWdt = 0;
PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*coeffWdt;
}
return PosAlign; return PosAlign;
}; };
...@@ -1997,7 +1987,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -1997,7 +1987,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
var bContainCompareOper = PRS.bContainCompareOper; var bContainCompareOper = PRS.bContainCompareOper;
var bOneLine = PRS.bMath_OneLine; var bOneLine = PRS.bMath_OneLine;
var MathFirstItem = PRS.MathFirstItem;
this.bOneLine = this.bCanBreak == false || PRS.bMath_OneLine == true; this.bOneLine = this.bCanBreak == false || PRS.bMath_OneLine == true;
if(this.kind !== MATH_DELIMITER) if(this.kind !== MATH_DELIMITER)
...@@ -2030,7 +2020,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -2030,7 +2020,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.recalculateSize(g_oTextMeasurer); this.recalculateSize(g_oTextMeasurer);
this.UpdatePRS_OneLine(PRS, WordLen, MathFirstItem); this.UpdatePRS_OneLine(PRS, WordLen, PRS.MathFirstItem);
this.Bounds.SetWidth(0, 0, this.size.width); this.Bounds.SetWidth(0, 0, this.size.width);
this.Bounds.UpdateMetrics(0, 0, this.size); this.Bounds.UpdateMetrics(0, 0, this.size);
} }
......
...@@ -346,23 +346,61 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf ...@@ -346,23 +346,61 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
RPI.bDecreasedComp = bDecreasedComp; RPI.bDecreasedComp = bDecreasedComp;
RPI.bSmallFraction = bSmallFraction; RPI.bSmallFraction = bSmallFraction;
}; };
CFraction.prototype.recalculateSize = function(oMeasure) CFraction.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{ {
var WordLen = PRS.WordLen; // запоминаем, чтобы внутр мат объекты не увеличили WordLen
var bContainCompareOper = PRS.bContainCompareOper;
var bOneLine = PRS.bMath_OneLine;
this.bOneLine = this.bCanBreak == false || PRS.bMath_OneLine == true;
this.BrGapLeft = this.GapLeft;
this.BrGapRight = this.GapRight;
PRS.bMath_OneLine = this.bOneLine;
this.Numerator.Recalculate_Reset(PRS.Range, PRS.Line, PRS); // обновим StartLine и StartRange
this.Numerator.Recalculate_Range(PRS, ParaPr, Depth);
var bNumBarFraction = PRS.bSingleBarFraction;
this.Denominator.Recalculate_Reset(PRS.Range, PRS.Line, PRS);
this.Denominator.Recalculate_Range(PRS, ParaPr, Depth);
var bDenBarFraction = PRS.bSingleBarFraction;
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
this.recalculateBarFraction(oMeasure); this.recalculateBarFraction(g_oTextMeasurer, bNumBarFraction, bDenBarFraction);
else if(this.Pr.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
this.recalculateSkewed(oMeasure); this.recalculateSkewed(g_oTextMeasurer);
else if(this.Pr.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
this.recalculateLinear(oMeasure); this.recalculateLinear(g_oTextMeasurer);
this.UpdatePRS_OneLine(PRS, WordLen, PRS.MathFirstItem);
this.Bounds.SetWidth(0, 0, this.size.width);
this.Bounds.UpdateMetrics(0, 0, this.size);
PRS.bMath_OneLine = bOneLine;
PRS.bContainCompareOper = bContainCompareOper;
}; };
CFraction.prototype.recalculateBarFraction = function(oMeasure) CFraction.prototype.recalculateBarFraction = function(oMeasure, bNumBarFraction, bDenBarFraction)
{ {
var ctrPrp = this.Get_TxtPrControlLetter();
var Plh = new CMathText(true);
Plh.add(0x2B1A);
Plh.Measure(g_oTextMeasurer, ctrPrp);
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 NumWidth = bNumBarFraction ? num.width + 0.25*Plh.size.width : num.width;
var DenWidth = bDenBarFraction ? den.width + 0.25*Plh.size.width : den.width;
var mgCtrPrp = this.Get_TxtPrControlLetter(); var mgCtrPrp = this.Get_TxtPrControlLetter();
var width = num.width > den.width ? num.width : den.width; var width = NumWidth > DenWidth ? NumWidth : DenWidth;
var height = num.height + den.height; var height = num.height + den.height;
var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp); var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
...@@ -461,6 +499,24 @@ CFraction.prototype.setPosition = function(pos, PosInfo) ...@@ -461,6 +499,24 @@ CFraction.prototype.setPosition = function(pos, PosInfo)
CFraction.superclass.setPosition.call(this, pos, PosInfo); CFraction.superclass.setPosition.call(this, pos, PosInfo);
} }
}; };
CFraction.prototype.align = function(pos_x, pos_y)
{
var PosAlign = new CMathPosition();
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
{
if(pos_x == 0)
PosAlign.x = (this.size.width - this.Numerator.size.width)*0.5;
else
PosAlign.x = (this.size.width - this.Denominator.size.width)*0.5;
}
else if(this.Pr.type == LINEAR_FRACTION)
{
PosAlign.y = this.size.ascent - this.elements[pos_x][pos_y].size.ascent;
}
return PosAlign;
};
CFraction.prototype.fillContent = function() CFraction.prototype.fillContent = function()
{ {
this.Numerator = new CNumerator(this.Content[0]); this.Numerator = new CNumerator(this.Content[0]);
......
...@@ -4140,6 +4140,30 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -4140,6 +4140,30 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
RangeEndPos = Pos - 1; RangeEndPos = Pos - 1;
} }
var bSingleBarFraction = false;
for(var Pos = 0; Pos < ContentLen; Pos++)
{
if(this.Content[Pos].kind == MATH_FRACTION && this.Content[Pos].Pr.type == BAR_FRACTION)
{
if(bSingleBarFraction)
{
bSingleBarFraction = false;
break;
}
bSingleBarFraction = true;
}
else if( !(this.Content[Pos].Type == para_Math_Run && true == this.Content[Pos].Is_Empty()) ) // не пустой Run, другой мат объект
{
bSingleBarFraction = false;
break;
}
}
PRS.bSingleBarFraction = bSingleBarFraction;
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos); this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
}; };
CMathContent.prototype.private_ForceBreakBox = function(PRS, Box, _Depth, PrevLastPos, LastPos) CMathContent.prototype.private_ForceBreakBox = function(PRS, Box, _Depth, PrevLastPos, LastPos)
......
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