Commit c312b994 authored by AnnaPavlovaOnlyOffice's avatar AnnaPavlovaOnlyOffice

Merge pull request #4 from ONLYOFFICE/feature/math-forced-break

Feature/math forced break
parents f2b509a8 926c3511
This diff is collapsed.
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
/** /**
...@@ -47,7 +23,6 @@ function CMathBase(bInside) ...@@ -47,7 +23,6 @@ function CMathBase(bInside)
this.CtrPrp = new CTextPr(); this.CtrPrp = new CTextPr();
this.CompiledCtrPrp = new CTextPr(); this.CompiledCtrPrp = new CTextPr();
this.TextPrControlLetter = new CTextPr(); this.TextPrControlLetter = new CTextPr();
//this.CtrPr = new CCtrPr();
this.ArgSize = new CMathArgSize(); this.ArgSize = new CMathArgSize();
...@@ -283,33 +258,29 @@ CMathBase.prototype.align = function(pos_x, pos_y) ...@@ -283,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;
...@@ -321,16 +292,10 @@ CMathBase.prototype.align = function(pos_x, pos_y) ...@@ -321,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;
}; };
...@@ -2022,7 +1987,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -2022,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)
...@@ -2055,7 +2020,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -2055,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);
} }
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CMathBreak() function CMathBreak()
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CMathDegreePr() function CMathDegreePr()
...@@ -109,12 +85,14 @@ CDegreeBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsI ...@@ -109,12 +85,14 @@ CDegreeBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsI
var ArgSzDegr = ArgSize.Copy(); var ArgSzDegr = ArgSize.Copy();
ArgSzDegr.Decrease(); ArgSzDegr.Decrease();
var RPIDegr = RPI.Copy();
RPIDegr.bDecreasedComp = true;
this.bNaryInline = RPI.bNaryInline; this.bNaryInline = RPI.bNaryInline;
this.iterContent.PreRecalc(this, ParaMath, ArgSzDegr, RPIDegr); var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.iterContent.PreRecalc(this, ParaMath, ArgSzDegr, RPI);
RPI.bDecreasedComp = bDecreasedComp;
}; };
CDegreeBase.prototype.Resize = function(oMeasure, RPI) CDegreeBase.prototype.Resize = function(oMeasure, RPI)
{ {
...@@ -560,11 +538,13 @@ CIterators.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsIn ...@@ -560,11 +538,13 @@ CIterators.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsIn
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI); this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
var RPI_ITER = RPI.Copy(); var bDecreasedComp = RPI.bDecreasedComp;
RPI_ITER.bDecreasedComp = true; RPI.bDecreasedComp = true;
this.iterUp.PreRecalc(this, ParaMath, ArgSzIters, RPI);
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI);
this.iterUp.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER); RPI.bDecreasedComp = bDecreasedComp;
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
}; };
CIterators.prototype.recalculateSize = function(oMeasure, dH, ascent) CIterators.prototype.recalculateSize = function(oMeasure, dH, ascent)
{ {
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CMathFractionPr() function CMathFractionPr()
...@@ -114,12 +90,10 @@ CFraction.prototype.drawBarFraction = function(PDSE) ...@@ -114,12 +90,10 @@ CFraction.prototype.drawBarFraction = function(PDSE)
var numHeight = this.elements[0][0].size.height; var numHeight = this.elements[0][0].size.height;
var width = this.size.width - this.GapLeft - this.GapRight;
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line, PDSE.Range); var PosLine = this.ParaMath.GetLinePosition(PDSE.Line, PDSE.Range);
var x1 = this.pos.x + PosLine.x + this.GapLeft, var x1 = this.pos.x + PosLine.x + this.GapLeft,
x2 = this.pos.x + PosLine.x + this.GapLeft + width, x2 = this.pos.x + PosLine.x + this.size.width - this.GapRight,
y1 = this.pos.y + PosLine.y + numHeight - penW; y1 = this.pos.y + PosLine.y + numHeight - penW;
if(this.Pr.type == BAR_FRACTION) if(this.Pr.type == BAR_FRACTION)
...@@ -327,7 +301,12 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf ...@@ -327,7 +301,12 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
var ArgSzNumDen = ArgSize.Copy(); var ArgSzNumDen = ArgSize.Copy();
if(RPI.bInline == true && (this.Pr.type === BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)) // уменьшае размер числителя и знаменателя var oMathSettings = Get_WordDocumentDefaultMathSettings();
var bInlineBarFaction = RPI.bInline == true && (this.Pr.type === BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION),
bReduceSize = (RPI.bSmallFraction || RPI.bDecreasedComp == true) && true == oMathSettings.Get_SmallFrac();
if(bInlineBarFaction || bReduceSize) // уменьшае размер числителя и знаменателя
{ {
ArgSzNumDen.Decrease(); // для контентов числителя и знаменателя ArgSzNumDen.Decrease(); // для контентов числителя и знаменателя
this.ArgSize.SetValue(-1); // для CtrPrp this.ArgSize.SetValue(-1); // для CtrPrp
...@@ -346,35 +325,78 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf ...@@ -346,35 +325,78 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
this.ApplyProperties(RPI); this.ApplyProperties(RPI);
var NewRPI = RPI.Copy(); var bDecreasedComp = RPI.bDecreasedComp,
bSmallFraction = RPI.bSmallFraction;
if(this.Pr.type !== LINEAR_FRACTION) if(this.Pr.type !== LINEAR_FRACTION)
NewRPI.bDecreasedComp = true; RPI.bDecreasedComp = true;
RPI.bSmallFraction = true;
// setGaps обязательно после того как смержили CtrPrp (Set_CompiledCtrPrp) // setGaps обязательно после того как смержили CtrPrp (Set_CompiledCtrPrp)
if(this.bInside == false) if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize); GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI); this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, RPI);
this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI); this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, RPI);
RPI.bDecreasedComp = bDecreasedComp;
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 Plh = new CMathText(true);
Plh.add(0x2B1A);
this.MeasureJustDraw(Plh);
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);
...@@ -473,6 +495,26 @@ CFraction.prototype.setPosition = function(pos, PosInfo) ...@@ -473,6 +495,26 @@ 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)
{
var width = this.size.width - this.GapLeft - this.GapRight;
if(pos_x == 0)
PosAlign.x = (width - this.Numerator.size.width)*0.5;
else
PosAlign.x = (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]);
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CMathLimitPr() function CMathLimitPr()
...@@ -111,10 +87,12 @@ CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gap ...@@ -111,10 +87,12 @@ CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gap
var ArgSzIter = ArgSize.Copy(); var ArgSzIter = ArgSize.Copy();
ArgSzIter.Decrease(); ArgSzIter.Decrease();
var NewRPI = RPI.Copy(); var bDecreasedComp = RPI.bDecreasedComp;
NewRPI.bDecreasedComp = true; RPI.bDecreasedComp = true;
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI); this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
}; };
CLimitPrimary.prototype.Resize = function(oMeasure, RPI) CLimitPrimary.prototype.Resize = function(oMeasure, RPI)
{ {
...@@ -367,10 +345,12 @@ CMathFunc.prototype.init = function(props) ...@@ -367,10 +345,12 @@ CMathFunc.prototype.init = function(props)
}; };
CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo) CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{ {
var NewRPI = RPI.Copy(); var bMathFunc = RPI.bMathFunc;
NewRPI.bMathFunc = true; RPI.bMathFunc = true;
CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo); RPI.bMathFunc = bMathFunc;
}; };
CMathFunc.prototype.GetLastElement = function() CMathFunc.prototype.GetLastElement = function()
{ {
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CRPI() function CRPI()
...@@ -34,22 +10,8 @@ function CRPI() ...@@ -34,22 +10,8 @@ function CRPI()
this.bMathFunc = false; this.bMathFunc = false;
this.bRecalcCtrPrp = false; // пересчет ctrPrp нужен, когда на Undo и тп изменился размер первого Run, а ctrPrp уже для мат объектов пересчитались this.bRecalcCtrPrp = false; // пересчет ctrPrp нужен, когда на Undo и тп изменился размер первого Run, а ctrPrp уже для мат объектов пересчитались
this.bCorrect_ConvertFontSize = false; this.bCorrect_ConvertFontSize = false;
this.bSmallFraction = false;
} }
CRPI.prototype.Copy = function()
{
var RPI = new CRPI();
RPI.bInline = this.bInline;
RPI.bDecreasedComp = this.bDecreasedComp;
RPI.bChangeInline = this.bChangeInline;
RPI.bNaryInline = this.bNaryInline;
RPI.bEqArray = this.bEqArray;
RPI.bMathFunc = this.bMathFunc;
RPI.bRecalcCtrPrp = this.bRecalcCtrPrp;
RPI.bCorrect_ConvertFontSize = this.bCorrect_ConvertFontSize;
return RPI;
};
CRPI.prototype.MergeMathInfo = function(MathInfo) CRPI.prototype.MergeMathInfo = function(MathInfo)
{ {
this.bInline = MathInfo.bInline || (MathInfo.bInternalRanges == true && MathInfo.bStartRanges == false); this.bInline = MathInfo.bInline || (MathInfo.bInternalRanges == true && MathInfo.bStartRanges == false);
...@@ -1331,10 +1293,9 @@ CMathContent.prototype.Correct_Content = function(bInnerCorrection) ...@@ -1331,10 +1293,9 @@ CMathContent.prototype.Correct_Content = function(bInnerCorrection)
{ {
bEmptyContent = false; bEmptyContent = false;
} }
} }
if(bEmptyContent) if(bEmptyContent == true && this.bRoot == false)
{ {
this.Content[0].fillPlaceholders(); this.Content[0].fillPlaceholders();
this.Content[0].Recalc_CompiledPr(true); this.Content[0].Recalc_CompiledPr(true);
...@@ -1497,7 +1458,7 @@ CMathContent.prototype.GetMathTextPrForMenu = function(ContentPos, Depth) ...@@ -1497,7 +1458,7 @@ CMathContent.prototype.GetMathTextPrForMenu = function(ContentPos, Depth)
return this.Content[pos].GetMathTextPrForMenu(ContentPos, Depth + 1); return this.Content[pos].GetMathTextPrForMenu(ContentPos, Depth + 1);
}; };
CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll, PosForMenu) CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll, StartPos, EndPos)
{ {
if ( true === ApplyToAll ) if ( true === ApplyToAll )
{ {
...@@ -1508,10 +1469,10 @@ CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll, ...@@ -1508,10 +1469,10 @@ CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll,
{ {
var StartPos, EndPos, bMenu = false; var StartPos, EndPos, bMenu = false;
if(PosForMenu !== undefined) if(StartPos !== undefined && EndPos !== undefined)
{ {
StartPos = PosForMenu.StartPos; StartPos = StartPos;
EndPos = PosForMenu.EndPos; EndPos = EndPos;
bMenu = true; bMenu = true;
} }
...@@ -4179,6 +4140,30 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -4179,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)
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
var MATH_FRACTION = 0; var MATH_FRACTION = 0;
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
var MATH_MC_JC = MCJC_CENTER; var MATH_MC_JC = MCJC_CENTER;
...@@ -1347,17 +1323,15 @@ CEqArray.prototype.getColsCount = function() ...@@ -1347,17 +1323,15 @@ CEqArray.prototype.getColsCount = function()
}; };
CEqArray.prototype.Resize = function(oMeasure, RPI) CEqArray.prototype.Resize = function(oMeasure, RPI)
{ {
// на случай, чтобы не затереть массив var bEqArray = RPI.bEqArray;
//var CurrAmperWPoints = RPI.AmperWPoints, RPI.bEqArray = true;
// CurrEqArray = RPI.bEqArray;
var NewRPI = RPI.Copy();
NewRPI.bEqArray = true;
for(var i = 0; i < this.nRow; i++) for(var i = 0; i < this.nRow; i++)
this.elements[i][0].Resize(oMeasure, NewRPI); this.elements[i][0].Resize(oMeasure, RPI);
this.recalculateSize(oMeasure); this.recalculateSize(oMeasure);
RPI.bEqArray = bEqArray;
}; };
CEqArray.prototype.getMetrics = function() CEqArray.prototype.getMetrics = function()
{ {
...@@ -1367,7 +1341,6 @@ CEqArray.prototype.getMetrics = function() ...@@ -1367,7 +1341,6 @@ CEqArray.prototype.getMetrics = function()
// нумерация начинается с нуля, поэтому все четные точки идут с нечетными номерами в массиве // нумерация начинается с нуля, поэтому все четные точки идут с нечетными номерами в массиве
//var lngW = RPI.Widths.length; // this.nRow
var EndWidths = 0; var EndWidths = 0;
var even, // четная точка var even, // четная точка
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
//величина символа "сигма" не меняется в зависимости от аргумента //величина символа "сигма" не меняется в зависимости от аргумента
...@@ -329,12 +305,14 @@ CNary.prototype.private_GetLimLoc = function() ...@@ -329,12 +305,14 @@ CNary.prototype.private_GetLimLoc = function()
}; };
CNary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo) CNary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{ {
var NewRPI = RPI.Copy(); var bNaryInline = RPI.bNaryInline;
if(RPI.bInline || RPI.bDecreasedComp) if(RPI.bInline || RPI.bDecreasedComp)
NewRPI.bNaryInline = true; RPI.bNaryInline = true;
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo); RPI.bNaryInline = bNaryInline;
}; };
CNary.prototype.getSign = function(chrCode, chrType) CNary.prototype.getSign = function(chrCode, chrType)
{ {
...@@ -895,11 +873,14 @@ CNaryUnd.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI) ...@@ -895,11 +873,14 @@ CNaryUnd.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzUnd = ArgSize.Copy(); var ArgSzUnd = ArgSize.Copy();
ArgSzUnd.Decrease(); ArgSzUnd.Decrease();
var RPIUnd = RPI.Copy();
RPIUnd.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzUnd, RPIUnd);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI); this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzUnd, RPI);
RPI.bDecreasedComp = bDecreasedComp;
}; };
CNaryUnd.prototype.setBase = function(base) CNaryUnd.prototype.setBase = function(base)
{ {
...@@ -933,11 +914,14 @@ CNaryOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI) ...@@ -933,11 +914,14 @@ CNaryOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzOvr = ArgSize.Copy(); var ArgSzOvr = ArgSize.Copy();
ArgSzOvr.Decrease(); ArgSzOvr.Decrease();
var RPIOvr = RPI.Copy();
RPIOvr.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSize, RPI); this.elements[0][0].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSzOvr, RPIOvr);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[1][0].PreRecalc(this, ParaMath, ArgSzOvr, RPI);
RPI.bDecreasedComp = bDecreasedComp;
}; };
CNaryOvr.prototype.recalculateSize = function() CNaryOvr.prototype.recalculateSize = function()
{ {
...@@ -1000,13 +984,16 @@ CNaryUndOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI) ...@@ -1000,13 +984,16 @@ CNaryUndOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzIter = ArgSize.Copy(); var ArgSzIter = ArgSize.Copy();
ArgSzIter.Decrease(); ArgSzIter.Decrease();
var RPI_Iter = RPI.Copy(); this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
RPI_Iter.bDecreasedComp = true;
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzIter, RPI_Iter); this.elements[0][0].PreRecalc(this, ParaMath, ArgSzIter, RPI);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[2][0].PreRecalc(this, ParaMath, ArgSzIter, RPI_Iter); this.elements[2][0].PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
}; };
CNaryUndOvr.prototype.recalculateSize = function() CNaryUndOvr.prototype.recalculateSize = function()
{ {
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CGlyphOperator() function CGlyphOperator()
...@@ -33,7 +9,6 @@ function CGlyphOperator() ...@@ -33,7 +9,6 @@ function CGlyphOperator()
this.stretch = 0; this.stretch = 0;
this.bStretch = true; this.bStretch = true;
this.penW = 1; // px this.penW = 1; // px
} }
CGlyphOperator.prototype.init = function(props) CGlyphOperator.prototype.init = function(props)
...@@ -101,7 +76,7 @@ CGlyphOperator.prototype.getCoordinateGlyph = function() ...@@ -101,7 +76,7 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
var X = coord.XX, Y = coord.YY, var X = coord.XX, Y = coord.YY,
W = this.size.width, H = this.size.height; W = this.size.width, H = this.size.height;
var bHor = this.loc == 0 || this.loc == 1; var bHor = this.loc == LOCATION_TOP || this.loc == LOCATION_BOT;
var glW = 0, glH = 0; var glW = 0, glH = 0;
if(bHor) if(bHor)
...@@ -187,63 +162,6 @@ CGlyphOperator.prototype.getCoordinateGlyph = function() ...@@ -187,63 +162,6 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
} }
} }
/*if(this.loc == LOCATION_TOP)
{
a1 = 1; b1 = 0; c1 = 0;
a2 = 0; b2 = 1; c2 = 0;
}
else if(this.loc == LOCATION_BOT)
{
a1 = 1; b1 = 0; c1 = 0;
if(bLine)
{
a2 = 0; b2 = 1; c2 = (H - glH)/2;
}
else
{
a2 = 0; b2 = 1; c2 = H - glH;
}
}
else if(this.loc == LOCATION_LEFT)
{
a1 = 0; b1 = 1; c1 = 0;
a2 = 1; b2 = 0; c2 = 0;
}
else if(this.loc == LOCATION_RIGHT)
{
if(bLine)
{
a1 = 0; b1 = 1; c1 = (W - glW)/2;
}
else
{
a1 = 0; b1 = 1; c1 = W - glW;
}
a2 = 1; b2 = 0; c2 = 0;
}
else if(this.loc == LOCATION_SEP)
{
a1 = 0; b1 = 1; c1 = 0;
a2 = 1; b2 = 0; c2 = 0;
}*/
/*var shW = 0,
shH = 0;
if(bHor)
{
a1 = 1; b1 = 0; c1 = 0;
a2 = 0; b2 = 1; c2 = 0;
}
else
{
a1 = 0; b1 = 1; c1 = 0;
a2 = 1; b2 = 0; c2 = 0;
}*/
if(this.turn == 1) if(this.turn == 1)
{ {
a1 *= -1; b1 *= -1; c1 += glW; a1 *= -1; b1 *= -1; c1 += glW;
...@@ -285,7 +203,7 @@ CGlyphOperator.prototype.draw = function(pGraphics, XX, YY, PDSE) ...@@ -285,7 +203,7 @@ CGlyphOperator.prototype.draw = function(pGraphics, XX, YY, PDSE)
pGraphics.p_width(this.penW*1000); pGraphics.p_width(this.penW*1000);
pGraphics._s(); pGraphics._s();
this.drawPath(pGraphics, XX,YY, PDSE); this.drawPath(pGraphics, XX, YY, PDSE);
pGraphics.df(); pGraphics.df();
pGraphics._s(); pGraphics._s();
...@@ -2994,7 +2912,6 @@ COperator.prototype.fixSize = function(oMeasure, stretch) ...@@ -2994,7 +2912,6 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
Bold: false //ctrPrp.Bold Bold: false //ctrPrp.Bold
}; };
oMeasure.SetFont(Font); oMeasure.SetFont(Font);
var bLine = this.IsLineGlyph(); var bLine = this.IsLineGlyph();
...@@ -3028,19 +2945,25 @@ COperator.prototype.fixSize = function(oMeasure, stretch) ...@@ -3028,19 +2945,25 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
} }
} }
// Height var mgCtrPrp = this.Parent.Get_TxtPrControlLetter();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
// Height, Ascent
if(this.type === OPER_ACCENT)
{
var letterOperator = new CMathText(true); var letterOperator = new CMathText(true);
letterOperator.add(this.code); letterOperator.add(this.code);
letterOperator.Measure(oMeasure, ctrPrp); letterOperator.Measure(oMeasure, ctrPrp);
if(this.type === OPER_ACCENT)
{
var letterX = new CMathText(true); var letterX = new CMathText(true);
letterX.add(0x78); letterX.add(0x78);
letterX.Measure(oMeasure, ctrPrp); letterX.Measure(oMeasure, ctrPrp);
height = letterOperator.size.ascent - letterX.size.ascent; height = letterOperator.size.ascent - letterX.size.ascent;
ascent = height/2 + shCenter;
} }
else else
{ {
...@@ -3053,17 +2976,16 @@ COperator.prototype.fixSize = function(oMeasure, stretch) ...@@ -3053,17 +2976,16 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
else else
height = dims.Height; height = dims.Height;
} }
}
// Ascent
var mgCtrPrp = this.Parent.Get_TxtPrControlLetter();
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)
ascent = dims.Height/2; ascent = dims.Height;
else if(!bLine && this.operator.loc == LOCATION_BOT)
ascent = this.operator.size.height;
else else
ascent = height/2 + shCenter; ascent = height/2 + shCenter;
}
this.size.width = width; this.size.width = width;
this.size.height = height; this.size.height = height;
...@@ -3078,7 +3000,7 @@ COperator.prototype.Resize = function(oMeasure) ...@@ -3078,7 +3000,7 @@ COperator.prototype.Resize = function(oMeasure)
{ {
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 == LOCATION_TOP || this.operator.loc == LOCATION_BOT;
if(bHor) if(bHor)
this.fixSize(oMeasure, this.size.width); this.fixSize(oMeasure, this.size.width);
...@@ -4135,7 +4057,7 @@ CCharacter.prototype.setCharacter = function(props, defaultProps) ...@@ -4135,7 +4057,7 @@ CCharacter.prototype.setCharacter = function(props, defaultProps)
}; };
CCharacter.prototype.recalculateSize = function(oMeasure) CCharacter.prototype.recalculateSize = function(oMeasure)
{ {
var Base = this.Content[0]; var Base = this.elements[0][0];
this.operator.fixSize(oMeasure, Base.size.width); this.operator.fixSize(oMeasure, Base.size.width);
...@@ -4164,7 +4086,7 @@ CCharacter.prototype.setPosition = function(pos, PosInfo) ...@@ -4164,7 +4086,7 @@ CCharacter.prototype.setPosition = function(pos, PosInfo)
var PosOper = new CMathPosition(), var PosOper = new CMathPosition(),
PosBase = new CMathPosition(); PosBase = new CMathPosition();
var Base = this.Content[0]; var Base = this.elements[0][0];
if(this.Pr.pos === LOCATION_TOP) if(this.Pr.pos === LOCATION_TOP)
{ {
...@@ -4174,14 +4096,14 @@ CCharacter.prototype.setPosition = function(pos, PosInfo) ...@@ -4174,14 +4096,14 @@ CCharacter.prototype.setPosition = function(pos, PosInfo)
this.operator.setPosition(PosOper); this.operator.setPosition(PosOper);
PosBase.x = this.pos.x + this.GapLeft + alignCnt; PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + this.operator.size.height + Base.size.ascent; PosBase.y = this.pos.y + this.operator.size.height;
Base.setPosition(PosBase, PosInfo); Base.setPosition(PosBase, PosInfo);
} }
else if(this.Pr.pos === LOCATION_BOT) else if(this.Pr.pos === LOCATION_BOT)
{ {
PosBase.x = this.pos.x + this.GapLeft + alignCnt; PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + Base.size.ascent; PosBase.y = this.pos.y;
Base.setPosition(PosBase, PosInfo); Base.setPosition(PosBase, PosInfo);
...@@ -4413,22 +4335,17 @@ CGroupCharacter.prototype.getAscent = function(oMeasure) ...@@ -4413,22 +4335,17 @@ CGroupCharacter.prototype.getAscent = function(oMeasure)
{ {
var ascent; var ascent;
//var shCent = DIV_CENT*this.getCtrPrp().FontSize;
var ctrPrp = this.Get_TxtPrControlLetter(); var ctrPrp = this.Get_TxtPrControlLetter();
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)
ascent = this.operator.size.ascent + shCent; ascent = this.operator.size.ascent;
//ascent = this.operator.size.ascent + 1.3*shCent;
else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_TOP ) else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_TOP )
ascent = this.operator.size.height + this.elements[0][0].size.ascent; ascent = this.operator.size.height + this.elements[0][0].size.ascent;
else if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_BOT ) else if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_BOT )
ascent = this.elements[0][0].size.ascent; ascent = this.elements[0][0].size.ascent;
else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_BOT ) else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_BOT )
ascent = this.elements[0][0].size.height + shCent + this.operator.size.height - this.operator.size.ascent; ascent = this.elements[0][0].size.height + this.operator.size.height;
//ascent = this.elements[0][0].size.height + 1.55*shCent + this.operator.size.height - this.operator.size.ascent;
return ascent; return ascent;
}; };
......
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7  3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7  3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
"use strict"; "use strict";
function CSignRadical() function CSignRadical()
...@@ -195,7 +171,9 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg, bInline) ...@@ -195,7 +171,9 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg, bInline)
var Symbol5 = new CMathText(true); var Symbol5 = new CMathText(true);
Symbol5.add(0x35); Symbol5.add(0x35);
Symbol5.Measure(oMeasure, CtrPrp);
// измеряем функцией MeasureJustDraw, чтобы был выставлен Font
this.Parent.MeasureJustDraw(Symbol5);
var measureH = Symbol5.size.height; var measureH = Symbol5.size.height;
...@@ -232,7 +210,9 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg, bInline) ...@@ -232,7 +210,9 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg, bInline)
var letterG = new CMathText(true); var letterG = new CMathText(true);
letterG.add(0x67); letterG.add(0x67);
letterG.Measure(oMeasure, CtrPrp);
// измеряем функцией MeasureJustDraw, чтобы был выставлен Font
this.Parent.MeasureJustDraw(letterG);
var Descent = letterG.size.height - letterG.size.ascent; var Descent = letterG.size.height - letterG.size.ascent;
var bDescentArg = sizeArg.height - sizeArg.ascent > 0.9*Descent; var bDescentArg = sizeArg.height - sizeArg.ascent > 0.9*Descent;
...@@ -442,9 +422,16 @@ CRadical.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo ...@@ -442,9 +422,16 @@ CRadical.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo
var ArgSzIter = new CMathArgSize(); var ArgSzIter = new CMathArgSize();
ArgSzIter.SetValue(-2); ArgSzIter.SetValue(-2);
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI); this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
if(this.bInside == false) if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize); GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
}; };
......
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