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
/*
*
* (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";
/**
......@@ -36,7 +12,7 @@ function CMathPropertiesSettings()
this.brkBin = null;
this.defJc = null;
this.dispDef = null;
this.dispDef = null; // свойство: применять/ не применять paragraph settings (в тч defJc)
this.intLim = null;
this.naryLim = null;
......@@ -46,22 +22,41 @@ function CMathPropertiesSettings()
this.wrapIndent = null;
this.wrapRight = null;
this.smallFrac = null;
// не реализовано //
this.brkBinSub = null;
this.interSp = null;
// for minus operator
// when brkBin is set to repeat
this.brkBinSub = null;
this.intraSp = null;
//***** WORD IGNORES followings parameters *****//
// mathFont: в качестве font поддерживается только Cambria Math
// остальные шрифты возможно будут поддержаны MS Word в будущем
this.mathFont = null;
// Default font for math zones
// Gives a drop-down list of math fonts that can be used as the default math font to be used in the document.
// Currently only Cambria Math has thorough math support, but others such as the STIX fonts are coming soon.
// http://blogs.msdn.com/b/murrays/archive/2008/10/27/default-document-math-properties.aspx
// http://msdn.microsoft.com/en-us/library/ff529906(v=office.12).aspx
// Word ignores the interSp attribute and fails to write it back out.
this.interSp = null;
// http://msdn.microsoft.com/en-us/library/ff529301(v=office.12).aspx
// Word does not implement this feature and does not write the intraSp element.
this.intraSp = null;
// http://msdn.microsoft.com/en-us/library/ff533406(v=office.12).aspx
this.postSp = null;
this.preSp = null;
this.smallFrac = null;
// RichEdit Hot Keys
// http://blogs.msdn.com/b/murrays/archive/2013/10/30/richedit-hot-keys.aspx
//*********************//
}
......@@ -75,6 +70,7 @@ CMathPropertiesSettings.prototype.SetDefaultPr = function()
this.lMargin = 0;
this.naryLim = NARY_UndOvr;
this.rMargin = 0;
this.smallFrac = false;
this.wrapIndent = 25; // mm
this.wrapRight = false;
};
......@@ -109,6 +105,9 @@ CMathPropertiesSettings.prototype.Merge = function(Pr)
if(Pr.wrapRight !== null && Pr.wrapRight !== undefined)
this.wrapRight = Pr.wrapRight;
if(Pr.smallFrac !== null && Pr.smallFrac !== undefined)
this.smallFrac = Pr.smallFrac;
};
CMathPropertiesSettings.prototype.Copy = function()
{
......@@ -400,6 +399,11 @@ CMathSettings.prototype.Get_WrapRight = function()
this.SetCompiledPr();
return this.CompiledPr.wrapRight;
};
CMathSettings.prototype.Get_SmallFrac = function()
{
this.SetCompiledPr();
return this.CompiledPr.smallFrac;
};
CMathSettings.prototype.Load_Settings = function()
{
var Settings = {};
......@@ -629,6 +633,7 @@ function CMathMenuSettings(oMathPr)
this.RightMargin = oMathPr.rMargin/10;
this.WrapIndent = oMathPr.wrapIndent/10;
this.WrapRight = oMathPr.wrapRight;
this.SmallFraction = oMathPr.smallFrac;
}
else
{
......@@ -641,6 +646,7 @@ function CMathMenuSettings(oMathPr)
this.RightMargin = undefined;
this.WrapIndent = undefined;
this.WrapRight = undefined;
this.SmallFraction = undefined;
}
}
CMathMenuSettings.prototype.get_BreakBin = function(){ return this.BrkBin;};
......@@ -661,6 +667,8 @@ CMathMenuSettings.prototype.get_WrapIndent = function(){return this.WrapIndent;}
CMathMenuSettings.prototype.put_WrapIndent = function(WrapIndent){this.WrapIndent = WrapIndent;};
CMathMenuSettings.prototype.get_WrapRight = function(){ return this.WrapRight;};
CMathMenuSettings.prototype.put_WrapRight = function(WrapRight){ this.WrapRight = WrapRight;};
CMathMenuSettings.prototype.get_SmallFraction = function() {return this.SmallFraction;};
CMathMenuSettings.prototype.put_SmallFraction = function(SmallFrac) {this.SmallFraction = SmallFrac;};
window["CMathMenuSettings"] = CMathMenuSettings;
CMathMenuSettings.prototype["get_BreakBin"] = CMathMenuSettings.prototype.get_BreakBin;
......@@ -681,6 +689,8 @@ CMathMenuSettings.prototype["get_WrapIndent"] = CMathMenuSettings.prototype
CMathMenuSettings.prototype["put_WrapIndent"] = CMathMenuSettings.prototype.put_WrapIndent;
CMathMenuSettings.prototype["get_WrapRight"] = CMathMenuSettings.prototype.get_WrapRight;
CMathMenuSettings.prototype["put_WrapRight"] = CMathMenuSettings.prototype.put_WrapRight;
CMathMenuSettings.prototype["get_SmallFraction"] = CMathMenuSettings.prototype.get_SmallFraction;
CMathMenuSettings.prototype["put_SmallFraction"] = CMathMenuSettings.prototype.put_SmallFraction;
function Get_WordDocumentDefaultMathSettings()
......@@ -1237,6 +1247,7 @@ ParaMath.prototype.Add = function(Item)
this.Get_ParaContentPos(false, false, ContentPos);
var TextPr = this.Root.GetMathTextPrForMenu(ContentPos, 0);
var bPlh = oContent.IsPlaceholder();
// Нам нужно разделить данный Run на 2 части
var RightRun = Run.Split2(Run.State.ContentPos);
......@@ -1251,18 +1262,16 @@ ParaMath.prototype.Add = function(Item)
oContent.Correct_ContentCurPos();
var lng2 = oContent.Content.length;
var Pos_ApplyTextPr =
{
StartPos: StartPos + 1,
EndPos: StartPos + lng2 - lng
};
TextPr.RFonts.Set_All("Cambria Math", -1);
if (true === TrackRevisions)
LogicDocument.Set_TrackRevisions(false);
oContent.Apply_TextPr(TextPr, undefined, false, Pos_ApplyTextPr);
if(bPlh)
oContent.Apply_TextPr(TextPr, undefined, true);
else
oContent.Apply_TextPr(TextPr, undefined, false, StartPos + 1, StartPos + lng2 - lng);
if (true === TrackRevisions)
LogicDocument.Set_TrackRevisions(true);
......@@ -2709,106 +2718,6 @@ ParaMath.prototype.GetPlh = function(oMeasure, font)
return oMeasure.Measure2Code(0x2B1A).Height;
};
ParaMath.prototype.SetMathProperties = function(props)
{
//***** FOR FORMULA *****//
// В документации везде, где нет примера использования свояства, означает, что Word не поддерживает это свойство !
if(props.naryLim == NARY_UndOvr || props.naryLim == NARY_SubSup)
this.MathPr.naryLim = props.naryLim;
if(props.intLim == NARY_UndOvr || props.intLim == NARY_SubSup)
this.MathPr.intLim = props.intLim;
if(props.brkBin == BREAK_BEFORE || props.brkBin == BREAK_AFTER || props.brkBin == BREAK_REPEAT)
this.MathPr.brkBin = props.brkBin;
// for minus operator
// when brkBin is set to repeat
if(props.brkSubBin == BREAK_MIN_MIN || props.brkSubBin == BREAK_PLUS_MIN || props.brkSubBin == BREAK_MIN_PLUS)
this.MathPr.brkSubBin = props.brkSubBin;
// в случае если smallFrac = true,
if(props.smallFrac == true || props.smallFrac == false)
this.MathPr.smallFrac = props.smallFrac;
if(props.wrapIndent + 0 == props.wrapIndent && isNaN(props.wrapIndent)) // проверка на число
this.MathPr.wrapIndent = props.wrapIndent/1440;
//******** check for element 0x1FFD - 0xA721 *******//
// This element specifies the right justification of the wrapped line of an instance of mathematical text
// Instance : Arrows 0x2190-0x21B3, 0x21B6, 0x21B7, 0x21BA-0x21E9, 0x21F4-0x21FF,
// 0x3D, 0x2234 - 0x2237, 0x2239, 0x223B - 0x228B, 0x228F - 0x2292, 0x22A2 - 0x22B9,
// 0x22C8-0x22CD, 0x22D0, 0x22D1, 0x22D5 - 0x22EE,0x22F0-0x22FF, 0x27F0 - 0x297F (arrows and fishes), 0x29CE - 0x29D5
// 0x2A66 - 0x2AF0 (equals), 0x2AF2-0x2AF3, 0x2AF7 - 0x2AFA
if(props.wrapRight == true || props.wrapRight == false)
this.MathPr.wrapRight = props.wrapRight;
//***** FOR DOCUMENT *****//
// defaultJc
// выравнивание формулы в документе
this.MathPr.defJc = props.defJc;
// dispDef
// свойство: применять/ не применять paragraph settings (в тч defaultJc)
this.MathPr.dispDef = props.dispDef;
// added to paragraph settings for margins
// rMargin
// lMargin
this.MathPr.lMargin = props.lMargin;
this.MathPr.rMargin = props.rMargin;
//***** НЕПОДДЕРЖИВАЕМЫЕ Вордом свойства *****//
// mathFont: в качестве font поддерживается только Cambria Math
// остальные шрифты возможно будут поддержаны MS в будущем
this.MathPr.mathFont = props.mathFont;
// Default font for math zones
// Gives a drop-down list of math fonts that can be used as the default math font to be used in the document.
// Currently only Cambria Math has thorough math support, but others such as the STIX fonts are coming soon.
// http://blogs.msdn.com/b/murrays/archive/2008/10/27/default-document-math-properties.aspx
//***** FOR FORMULA *****//
// http://msdn.microsoft.com/en-us/library/ff529906(v=office.12).aspx
// Word ignores the interSp attribute and fails to write it back out.
this.MathPr.interSp = props.interSp;
// http://msdn.microsoft.com/en-us/library/ff529301(v=office.12).aspx
// Word does not implement this feature and does not write the intraSp element.
this.MathPr.intraSp = intraSp;
//***** FOR DOCUMENT *****//
// http://msdn.microsoft.com/en-us/library/ff533406(v=office.12).aspx
// Word ignores and discards postSp
this.MathPr.postSp = props.postSp;
this.MathPr.preSp = props.preSp;
// RichEdit Hot Keys
// http://blogs.msdn.com/b/murrays/archive/2013/10/30/richedit-hot-keys.aspx
};
ParaMath.prototype.GetMathPr = function()
{
return this.MathPr;
};
ParaMath.prototype.Get_Default_TPrp = function()
{
return this.DefaultTextPr;
......
/*
*
* (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";
/**
......@@ -47,7 +23,6 @@ function CMathBase(bInside)
this.CtrPrp = new CTextPr();
this.CompiledCtrPrp = new CTextPr();
this.TextPrControlLetter = new CTextPr();
//this.CtrPr = new CCtrPr();
this.ArgSize = new CMathArgSize();
......@@ -283,33 +258,29 @@ CMathBase.prototype.align = function(pos_x, pos_y)
if(this.alignment.hgt[pos_x] == MCJC_CENTER)
{
var maxAsc = 0;
var _ascent;
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;
}
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 _h;
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;
}
var coeffHgt;
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;
PosAlign.y = maxH - this.elements[pos_x][pos_y].size.height;
}
var maxW = 0;
......@@ -321,16 +292,10 @@ CMathBase.prototype.align = function(pos_x, pos_y)
if(this.alignment.wdt[pos_y] == MCJC_CENTER)
PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*0.5;
else
{
var coeffWdt;
if(this.alignment.wdt[pos_y] == MCJC_RIGHT)
coeffWdt = 1;
else
coeffWdt = 0;
PosAlign.x = (maxW - this.elements[pos_x][pos_y].size.width)*coeffWdt;
}
else if(this.alignment.hgt[pos_x] == MCJC_LEFT)
PosAlign.x = 0;
else // MCJC_RIGHT
PosAlign.x = maxW - this.elements[pos_x][pos_y].size.width;
return PosAlign;
};
......@@ -2022,7 +1987,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
var bContainCompareOper = PRS.bContainCompareOper;
var bOneLine = PRS.bMath_OneLine;
var MathFirstItem = PRS.MathFirstItem;
this.bOneLine = this.bCanBreak == false || PRS.bMath_OneLine == true;
if(this.kind !== MATH_DELIMITER)
......@@ -2055,7 +2020,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
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.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";
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";
function CMathDegreePr()
......@@ -109,12 +85,14 @@ CDegreeBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsI
var ArgSzDegr = ArgSize.Copy();
ArgSzDegr.Decrease();
var RPIDegr = RPI.Copy();
RPIDegr.bDecreasedComp = true;
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)
{
......@@ -560,11 +538,13 @@ CIterators.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsIn
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
var RPI_ITER = RPI.Copy();
RPI_ITER.bDecreasedComp = true;
var bDecreasedComp = RPI.bDecreasedComp;
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);
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
RPI.bDecreasedComp = bDecreasedComp;
};
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";
function CMathFractionPr()
......@@ -114,12 +90,10 @@ CFraction.prototype.drawBarFraction = function(PDSE)
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 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;
if(this.Pr.type == BAR_FRACTION)
......@@ -327,7 +301,12 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
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(); // для контентов числителя и знаменателя
this.ArgSize.SetValue(-1); // для CtrPrp
......@@ -346,35 +325,78 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
this.ApplyProperties(RPI);
var NewRPI = RPI.Copy();
var bDecreasedComp = RPI.bDecreasedComp,
bSmallFraction = RPI.bSmallFraction;
if(this.Pr.type !== LINEAR_FRACTION)
NewRPI.bDecreasedComp = true;
RPI.bDecreasedComp = true;
RPI.bSmallFraction = 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);
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, RPI);
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)
this.recalculateBarFraction(oMeasure);
this.recalculateBarFraction(g_oTextMeasurer, bNumBarFraction, bDenBarFraction);
else if(this.Pr.type == SKEWED_FRACTION)
this.recalculateSkewed(oMeasure);
this.recalculateSkewed(g_oTextMeasurer);
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,
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 width = num.width > den.width ? num.width : den.width;
var width = NumWidth > DenWidth ? NumWidth : DenWidth;
var height = num.height + den.height;
var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
......@@ -473,6 +495,26 @@ CFraction.prototype.setPosition = function(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()
{
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";
function CMathLimitPr()
......@@ -111,10 +87,12 @@ CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gap
var ArgSzIter = ArgSize.Copy();
ArgSzIter.Decrease();
var NewRPI = RPI.Copy();
NewRPI.bDecreasedComp = true;
var bDecreasedComp = RPI.bDecreasedComp;
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)
{
......@@ -367,10 +345,12 @@ CMathFunc.prototype.init = function(props)
};
CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
var NewRPI = RPI.Copy();
NewRPI.bMathFunc = true;
var bMathFunc = RPI.bMathFunc;
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()
{
......
/*
*
* (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";
function CRPI()
......@@ -34,22 +10,8 @@ function CRPI()
this.bMathFunc = false;
this.bRecalcCtrPrp = false; // пересчет ctrPrp нужен, когда на Undo и тп изменился размер первого Run, а ctrPrp уже для мат объектов пересчитались
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)
{
this.bInline = MathInfo.bInline || (MathInfo.bInternalRanges == true && MathInfo.bStartRanges == false);
......@@ -1331,10 +1293,9 @@ CMathContent.prototype.Correct_Content = function(bInnerCorrection)
{
bEmptyContent = false;
}
}
if(bEmptyContent)
if(bEmptyContent == true && this.bRoot == false)
{
this.Content[0].fillPlaceholders();
this.Content[0].Recalc_CompiledPr(true);
......@@ -1497,7 +1458,7 @@ CMathContent.prototype.GetMathTextPrForMenu = function(ContentPos, Depth)
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 )
{
......@@ -1508,10 +1469,10 @@ CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll,
{
var StartPos, EndPos, bMenu = false;
if(PosForMenu !== undefined)
if(StartPos !== undefined && EndPos !== undefined)
{
StartPos = PosForMenu.StartPos;
EndPos = PosForMenu.EndPos;
StartPos = StartPos;
EndPos = EndPos;
bMenu = true;
}
......@@ -4179,6 +4140,30 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
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);
};
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";
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";
var MATH_MC_JC = MCJC_CENTER;
......@@ -1347,17 +1323,15 @@ CEqArray.prototype.getColsCount = function()
};
CEqArray.prototype.Resize = function(oMeasure, RPI)
{
// на случай, чтобы не затереть массив
//var CurrAmperWPoints = RPI.AmperWPoints,
// CurrEqArray = RPI.bEqArray;
var NewRPI = RPI.Copy();
NewRPI.bEqArray = true;
var bEqArray = RPI.bEqArray;
RPI.bEqArray = true;
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);
RPI.bEqArray = bEqArray;
};
CEqArray.prototype.getMetrics = function()
{
......@@ -1367,7 +1341,6 @@ CEqArray.prototype.getMetrics = function()
// нумерация начинается с нуля, поэтому все четные точки идут с нечетными номерами в массиве
//var lngW = RPI.Widths.length; // this.nRow
var EndWidths = 0;
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";
//величина символа "сигма" не меняется в зависимости от аргумента
......@@ -329,12 +305,14 @@ CNary.prototype.private_GetLimLoc = function()
};
CNary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
var NewRPI = RPI.Copy();
var bNaryInline = RPI.bNaryInline;
if(RPI.bInline || RPI.bDecreasedComp)
NewRPI.bNaryInline = true;
RPI.bNaryInline = true;
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
RPI.bNaryInline = bNaryInline;
};
CNary.prototype.getSign = function(chrCode, chrType)
{
......@@ -895,11 +873,14 @@ CNaryUnd.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzUnd = ArgSize.Copy();
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);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzUnd, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CNaryUnd.prototype.setBase = function(base)
{
......@@ -933,11 +914,14 @@ CNaryOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
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);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[1][0].PreRecalc(this, ParaMath, ArgSzOvr, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CNaryOvr.prototype.recalculateSize = function()
{
......@@ -1000,13 +984,16 @@ CNaryUndOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzIter = ArgSize.Copy();
ArgSzIter.Decrease();
var RPI_Iter = RPI.Copy();
RPI_Iter.bDecreasedComp = true;
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzIter, RPI);
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);
this.elements[2][0].PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
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";
function CGlyphOperator()
......@@ -33,7 +9,6 @@ function CGlyphOperator()
this.stretch = 0;
this.bStretch = true;
this.penW = 1; // px
}
CGlyphOperator.prototype.init = function(props)
......@@ -101,7 +76,7 @@ CGlyphOperator.prototype.getCoordinateGlyph = function()
var X = coord.XX, Y = coord.YY,
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;
if(bHor)
......@@ -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)
{
a1 *= -1; b1 *= -1; c1 += glW;
......@@ -285,7 +203,7 @@ CGlyphOperator.prototype.draw = function(pGraphics, XX, YY, PDSE)
pGraphics.p_width(this.penW*1000);
pGraphics._s();
this.drawPath(pGraphics, XX,YY, PDSE);
this.drawPath(pGraphics, XX, YY, PDSE);
pGraphics.df();
pGraphics._s();
......@@ -2994,7 +2912,6 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
Bold: false //ctrPrp.Bold
};
oMeasure.SetFont(Font);
var bLine = this.IsLineGlyph();
......@@ -3028,19 +2945,25 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
}
}
// Height
var mgCtrPrp = this.Parent.Get_TxtPrControlLetter();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var letterOperator = new CMathText(true);
letterOperator.add(this.code);
letterOperator.Measure(oMeasure, ctrPrp);
// Height, Ascent
if(this.type === OPER_ACCENT)
{
var letterOperator = new CMathText(true);
letterOperator.add(this.code);
letterOperator.Measure(oMeasure, ctrPrp);
var letterX = new CMathText(true);
letterX.add(0x78);
letterX.Measure(oMeasure, ctrPrp);
height = letterOperator.size.ascent - letterX.size.ascent;
ascent = height/2 + shCenter;
}
else
{
......@@ -3053,17 +2976,16 @@ COperator.prototype.fixSize = function(oMeasure, stretch)
else
height = dims.Height;
}
if(!bLine && this.operator.loc == LOCATION_TOP)
ascent = dims.Height;
else if(!bLine && this.operator.loc == LOCATION_BOT)
ascent = this.operator.size.height;
else
ascent = height/2 + shCenter;
}
// 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))
ascent = dims.Height/2;
else
ascent = height/2 + shCenter;
this.size.width = width;
this.size.height = height;
......@@ -3078,7 +3000,7 @@ COperator.prototype.Resize = function(oMeasure)
{
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)
this.fixSize(oMeasure, this.size.width);
......@@ -4135,7 +4057,7 @@ CCharacter.prototype.setCharacter = function(props, defaultProps)
};
CCharacter.prototype.recalculateSize = function(oMeasure)
{
var Base = this.Content[0];
var Base = this.elements[0][0];
this.operator.fixSize(oMeasure, Base.size.width);
......@@ -4164,7 +4086,7 @@ CCharacter.prototype.setPosition = function(pos, PosInfo)
var PosOper = new CMathPosition(),
PosBase = new CMathPosition();
var Base = this.Content[0];
var Base = this.elements[0][0];
if(this.Pr.pos === LOCATION_TOP)
{
......@@ -4174,14 +4096,14 @@ CCharacter.prototype.setPosition = function(pos, PosInfo)
this.operator.setPosition(PosOper);
PosBase.x = this.pos.x + this.GapLeft + alignCnt;
PosBase.y = this.pos.y + this.operator.size.height + Base.size.ascent;
PosBase.y = this.pos.y + this.operator.size.height;
Base.setPosition(PosBase, PosInfo);
}
else if(this.Pr.pos === LOCATION_BOT)
{
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);
......@@ -4413,22 +4335,17 @@ CGroupCharacter.prototype.getAscent = function(oMeasure)
{
var ascent;
//var shCent = DIV_CENT*this.getCtrPrp().FontSize;
var ctrPrp = this.Get_TxtPrControlLetter();
var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp);
if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_TOP)
ascent = this.operator.size.ascent + shCent;
//ascent = this.operator.size.ascent + 1.3*shCent;
ascent = this.operator.size.ascent;
else if(this.Pr.vertJc === VJUST_BOT && this.Pr.pos === LOCATION_TOP )
ascent = this.operator.size.height + this.elements[0][0].size.ascent;
else if(this.Pr.vertJc === VJUST_TOP && this.Pr.pos === LOCATION_BOT )
ascent = this.elements[0][0].size.ascent;
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 + 1.55*shCent + this.operator.size.height - this.operator.size.ascent;
ascent = this.elements[0][0].size.height + this.operator.size.height;
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";
function CSignRadical()
......@@ -195,7 +171,9 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg, bInline)
var Symbol5 = new CMathText(true);
Symbol5.add(0x35);
Symbol5.Measure(oMeasure, CtrPrp);
// измеряем функцией MeasureJustDraw, чтобы был выставлен Font
this.Parent.MeasureJustDraw(Symbol5);
var measureH = Symbol5.size.height;
......@@ -232,7 +210,9 @@ CSignRadical.prototype.recalculateSize = function(oMeasure, sizeArg, bInline)
var letterG = new CMathText(true);
letterG.add(0x67);
letterG.Measure(oMeasure, CtrPrp);
// измеряем функцией MeasureJustDraw, чтобы был выставлен Font
this.Parent.MeasureJustDraw(letterG);
var Descent = letterG.size.height - letterG.size.ascent;
var bDescentArg = sizeArg.height - sizeArg.ascent > 0.9*Descent;
......@@ -442,9 +422,16 @@ CRadical.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo
var ArgSzIter = new CMathArgSize();
ArgSzIter.SetValue(-2);
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, 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)
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