3.0 source code
This commit is contained in:
536
OfficeWeb/sdk/Word/Math/accent.js
Normal file
536
OfficeWeb/sdk/Word/Math/accent.js
Normal file
@@ -0,0 +1,536 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CAccentCircumflex() {
|
||||
CGlyphOperator.call(this);
|
||||
}
|
||||
Asc.extendClass(CAccentCircumflex, CGlyphOperator);
|
||||
CAccentCircumflex.prototype.calcSize = function (stretch) {
|
||||
var alpha = this.Parent.Get_TxtPrControlLetter().FontSize / 36;
|
||||
var width = 3.88 * alpha;
|
||||
var height = 3.175 * alpha;
|
||||
var augm = 0.8 * stretch / width;
|
||||
if (augm < 1) {
|
||||
augm = 1;
|
||||
} else {
|
||||
if (augm > 5) {
|
||||
augm = 5;
|
||||
}
|
||||
}
|
||||
width *= augm;
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
};
|
||||
CAccentCircumflex.prototype.calcCoord = function (stretch) {
|
||||
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
|
||||
var textScale = fontSize / 1000,
|
||||
alpha = textScale * 25.4 / 96 / 64;
|
||||
var X = [],
|
||||
Y = [];
|
||||
X[0] = 0;
|
||||
Y[0] = 2373;
|
||||
X[1] = 9331;
|
||||
Y[1] = 15494;
|
||||
X[2] = 14913;
|
||||
Y[2] = 15494;
|
||||
X[3] = 23869;
|
||||
Y[3] = 2373;
|
||||
X[4] = 20953;
|
||||
Y[4] = 0;
|
||||
X[5] = 12122;
|
||||
Y[5] = 10118;
|
||||
X[6] = 11664;
|
||||
Y[6] = 10118;
|
||||
X[7] = 2833;
|
||||
Y[7] = 0;
|
||||
X[8] = 0;
|
||||
Y[8] = 2373;
|
||||
var XX = [],
|
||||
YY = [];
|
||||
var W = stretch / alpha;
|
||||
var a1 = X[3] - X[0],
|
||||
b1 = W,
|
||||
c1 = X[2] - X[1],
|
||||
a2 = X[4] - X[7],
|
||||
b2 = W - 2 * X[7],
|
||||
c2 = X[5] - X[6];
|
||||
var RX = [];
|
||||
for (var i = 0; i < X.length; i++) {
|
||||
RX[i] = 1;
|
||||
}
|
||||
RX[0] = RX[2] = (b1 - c1) / (a1 - c1);
|
||||
RX[4] = RX[6] = (b2 - c2) / (a2 - c2);
|
||||
XX[0] = XX[8] = X[0];
|
||||
YY[0] = YY[8] = Y[0];
|
||||
for (var i = 0; i < 4; i++) {
|
||||
XX[1 + i] = XX[i] + RX[i] * (X[1 + i] - X[i]);
|
||||
XX[7 - i] = XX[8 - i] + RX[7 - i] * (X[7 - i] - X[8 - i]);
|
||||
YY[1 + i] = Y[1 + i];
|
||||
YY[7 - i] = Y[7 - i];
|
||||
}
|
||||
for (var i = 0; i < XX.length; i++) {
|
||||
XX[i] = XX[i] * alpha;
|
||||
YY[i] = YY[i] * alpha;
|
||||
}
|
||||
var H = YY[1];
|
||||
W = XX[3];
|
||||
return {
|
||||
XX: XX,
|
||||
YY: YY,
|
||||
W: W,
|
||||
H: H
|
||||
};
|
||||
};
|
||||
CAccentCircumflex.prototype.drawPath = function (pGraphics, XX, YY) {
|
||||
pGraphics._m(XX[0], YY[0]);
|
||||
pGraphics._l(XX[1], YY[1]);
|
||||
pGraphics._l(XX[2], YY[2]);
|
||||
pGraphics._l(XX[3], YY[3]);
|
||||
pGraphics._l(XX[4], YY[4]);
|
||||
pGraphics._l(XX[5], YY[5]);
|
||||
pGraphics._l(XX[6], YY[6]);
|
||||
pGraphics._l(XX[7], YY[7]);
|
||||
pGraphics._l(XX[8], YY[8]);
|
||||
pGraphics._l(XX[9], YY[9]);
|
||||
pGraphics._l(XX[10], YY[10]);
|
||||
pGraphics._l(XX[11], YY[11]);
|
||||
};
|
||||
function CAccentLine() {
|
||||
CGlyphOperator.call(this);
|
||||
}
|
||||
Asc.extendClass(CAccentLine, CGlyphOperator);
|
||||
CAccentLine.prototype.calcSize = function (stretch) {
|
||||
var alpha = this.Parent.Get_TxtPrControlLetter().FontSize / 36;
|
||||
var height = 1.68 * alpha;
|
||||
var width = 4.938 * alpha;
|
||||
width = stretch > width ? stretch : width;
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
};
|
||||
CAccentLine.prototype.draw = function (x, y, pGraphics) {
|
||||
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
|
||||
var penW = fontSize * 0.067 * 25.4 / 96;
|
||||
var x1 = x + 25.4 / 96,
|
||||
x2 = x + this.stretch - 25.4 / 96;
|
||||
pGraphics.drawHorLine(0, y, x1, x2, penW);
|
||||
};
|
||||
function CAccentDoubleLine() {
|
||||
this.diff = 0;
|
||||
CGlyphOperator.call(this);
|
||||
}
|
||||
Asc.extendClass(CAccentDoubleLine, CGlyphOperator);
|
||||
CAccentDoubleLine.prototype.calcSize = function (stretch) {
|
||||
var alpha = this.Parent.Get_TxtPrControlLetter().FontSize / 36;
|
||||
var height = 2.843 * alpha;
|
||||
var width = 4.938 * alpha;
|
||||
width = stretch > width ? stretch : width;
|
||||
var Line = new CMathText(true);
|
||||
Line.add(773);
|
||||
Line.Resize(g_oTextMeasurer);
|
||||
var DoubleLine = new CMathText(true);
|
||||
DoubleLine.add(831);
|
||||
DoubleLine.Resize(g_oTextMeasurer);
|
||||
this.diff = DoubleLine.size.ascent - Line.size.ascent;
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
};
|
||||
CAccentDoubleLine.prototype.draw = function (x, y, pGraphics) {
|
||||
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
|
||||
var diff = this.diff;
|
||||
if (diff < 2 * 25.4 / 96) {
|
||||
diff = 2 * 25.4 / 96;
|
||||
}
|
||||
var penW = fontSize * 0.067 * 25.4 / 96;
|
||||
var x1 = x + 25.4 / 96,
|
||||
x2 = x + this.stretch - 25.4 / 96,
|
||||
y1 = y,
|
||||
y2 = y + diff;
|
||||
pGraphics.drawHorLine(0, y1, x1, x2, penW);
|
||||
pGraphics.drawHorLine(0, y2, x1, x2, penW);
|
||||
};
|
||||
function CAccentTilde() {
|
||||
CGlyphOperator.call(this);
|
||||
}
|
||||
Asc.extendClass(CAccentTilde, CGlyphOperator);
|
||||
CAccentTilde.prototype.calcSize = function (stretch) {
|
||||
var betta = this.Parent.Get_TxtPrControlLetter().FontSize / 36;
|
||||
var width = 9.047509765625 * betta;
|
||||
var height = 2.469444444444444 * betta;
|
||||
var augm = 0.9 * stretch / width;
|
||||
if (augm < 1) {
|
||||
augm = 1;
|
||||
} else {
|
||||
if (augm > 2) {
|
||||
augm = 2;
|
||||
}
|
||||
}
|
||||
width *= augm;
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
};
|
||||
CAccentTilde.prototype.calcCoord = function (stretch) {
|
||||
var X = [],
|
||||
Y = [];
|
||||
X[0] = 0;
|
||||
Y[0] = 3066;
|
||||
X[1] = 2125;
|
||||
Y[1] = 7984;
|
||||
X[2] = 5624;
|
||||
Y[2] = 11256;
|
||||
X[3] = 9123;
|
||||
Y[3] = 14528;
|
||||
X[4] = 13913;
|
||||
Y[4] = 14528;
|
||||
X[5] = 18912;
|
||||
Y[5] = 14528;
|
||||
X[6] = 25827;
|
||||
Y[6] = 10144;
|
||||
X[7] = 32742;
|
||||
Y[7] = 5760;
|
||||
X[8] = 36324;
|
||||
Y[8] = 5760;
|
||||
X[9] = 39865;
|
||||
Y[9] = 5760;
|
||||
X[10] = 42239;
|
||||
Y[10] = 7641;
|
||||
X[11] = 44614;
|
||||
Y[11] = 9522;
|
||||
X[12] = 47030;
|
||||
Y[12] = 13492;
|
||||
X[13] = 50362;
|
||||
Y[13] = 11254;
|
||||
X[14] = 48571;
|
||||
Y[14] = 7544;
|
||||
X[15] = 44697;
|
||||
Y[15] = 3772;
|
||||
X[16] = 40823;
|
||||
Y[16] = 0;
|
||||
X[17] = 35283;
|
||||
Y[17] = 0;
|
||||
X[18] = 29951;
|
||||
Y[18] = 0;
|
||||
X[19] = 23098;
|
||||
Y[19] = 4384;
|
||||
X[20] = 16246;
|
||||
Y[20] = 8768;
|
||||
X[21] = 12622;
|
||||
Y[21] = 8768;
|
||||
X[22] = 9581;
|
||||
Y[22] = 8768;
|
||||
X[23] = 7290;
|
||||
Y[23] = 6845;
|
||||
X[24] = 4999;
|
||||
Y[24] = 4922;
|
||||
X[25] = 3249;
|
||||
Y[25] = 1243;
|
||||
X[26] = 0;
|
||||
Y[26] = 3066;
|
||||
var XX = [],
|
||||
YY = [];
|
||||
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
|
||||
var textScale = fontSize / 1000,
|
||||
alpha = textScale * 25.4 / 96 / 64;
|
||||
var Width = stretch / alpha;
|
||||
var augm = Width / X[13] * 0.5;
|
||||
for (var i = 0; i < X.length; i++) {
|
||||
XX[i] = X[i] * alpha * augm;
|
||||
YY[i] = (Y[5] - Y[i]) * alpha * 0.65;
|
||||
}
|
||||
var H = YY[5];
|
||||
var W = XX[13];
|
||||
return {
|
||||
XX: XX,
|
||||
YY: YY,
|
||||
W: W,
|
||||
H: H
|
||||
};
|
||||
};
|
||||
CAccentTilde.prototype.drawPath = function (pGraphics, XX, YY) {
|
||||
pGraphics._m(XX[0], YY[0]);
|
||||
pGraphics._c(XX[0], YY[0], XX[1], YY[1], XX[2], YY[2]);
|
||||
pGraphics._c(XX[2], YY[2], XX[3], YY[3], XX[4], YY[4]);
|
||||
pGraphics._c(XX[4], YY[4], XX[5], YY[5], XX[6], YY[6]);
|
||||
pGraphics._c(XX[6], YY[6], XX[7], YY[7], XX[8], YY[8]);
|
||||
pGraphics._c(XX[8], YY[8], XX[9], YY[9], XX[10], YY[10]);
|
||||
pGraphics._c(XX[10], YY[10], XX[11], YY[11], XX[12], YY[12]);
|
||||
pGraphics._l(XX[13], YY[13]);
|
||||
pGraphics._c(XX[13], YY[13], XX[14], YY[14], XX[15], YY[15]);
|
||||
pGraphics._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17]);
|
||||
pGraphics._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19]);
|
||||
pGraphics._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21]);
|
||||
pGraphics._c(XX[21], YY[21], XX[22], YY[22], XX[23], YY[23]);
|
||||
pGraphics._c(XX[23], YY[23], XX[24], YY[24], XX[25], YY[25]);
|
||||
pGraphics._l(XX[26], YY[26]);
|
||||
};
|
||||
function CAccentBreve() {
|
||||
CGlyphOperator.call(this);
|
||||
}
|
||||
Asc.extendClass(CAccentBreve, CGlyphOperator);
|
||||
CAccentBreve.prototype.calcSize = function (stretch) {
|
||||
var betta = this.Parent.Get_TxtPrControlLetter().FontSize / 36;
|
||||
var width = 4.233333333333333 * betta;
|
||||
var height = 2.469444444444445 * betta;
|
||||
return {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
};
|
||||
CAccentBreve.prototype.calcCoord = function (stretch) {
|
||||
var X = [],
|
||||
Y = [];
|
||||
X[0] = 25161;
|
||||
Y[0] = 11372;
|
||||
X[1] = 24077;
|
||||
Y[1] = 5749;
|
||||
X[2] = 20932;
|
||||
Y[2] = 2875;
|
||||
X[3] = 17787;
|
||||
Y[3] = 0;
|
||||
X[4] = 12247;
|
||||
Y[4] = 0;
|
||||
X[5] = 7082;
|
||||
Y[5] = 0;
|
||||
X[6] = 4083;
|
||||
Y[6] = 2854;
|
||||
X[7] = 1083;
|
||||
Y[7] = 5707;
|
||||
X[8] = 0;
|
||||
Y[8] = 11372;
|
||||
X[9] = 3208;
|
||||
Y[9] = 12371;
|
||||
X[10] = 4249;
|
||||
Y[10] = 9623;
|
||||
X[11] = 5561;
|
||||
Y[11] = 8083;
|
||||
X[12] = 6873;
|
||||
Y[12] = 6542;
|
||||
X[13] = 8456;
|
||||
Y[13] = 5959;
|
||||
X[14] = 10039;
|
||||
Y[14] = 5376;
|
||||
X[15] = 12414;
|
||||
Y[15] = 5376;
|
||||
X[16] = 14746;
|
||||
Y[16] = 5376;
|
||||
X[17] = 16454;
|
||||
Y[17] = 5980;
|
||||
X[18] = 18162;
|
||||
Y[18] = 6583;
|
||||
X[19] = 19558;
|
||||
Y[19] = 8124;
|
||||
X[20] = 20953;
|
||||
Y[20] = 9665;
|
||||
X[21] = 21953;
|
||||
Y[21] = 12371;
|
||||
X[22] = 25161;
|
||||
Y[22] = 11372;
|
||||
var XX = [],
|
||||
YY = [];
|
||||
var fontSize = this.Parent.Get_TxtPrControlLetter().FontSize;
|
||||
var textScale = fontSize / 1000,
|
||||
alpha = textScale * 25.4 / 96 / 64;
|
||||
for (var i = 0; i < X.length; i++) {
|
||||
XX[i] = X[i] * alpha;
|
||||
YY[i] = Y[i] * alpha;
|
||||
}
|
||||
var H = YY[9],
|
||||
W = XX[0];
|
||||
return {
|
||||
XX: XX,
|
||||
YY: YY,
|
||||
W: W,
|
||||
H: H
|
||||
};
|
||||
};
|
||||
CAccentBreve.prototype.drawPath = function (pGraphics, XX, YY) {
|
||||
pGraphics._m(XX[0], YY[0]);
|
||||
pGraphics._c(XX[0], YY[0], XX[1], YY[1], XX[2], YY[2]);
|
||||
pGraphics._c(XX[2], YY[2], XX[3], YY[3], XX[4], YY[4]);
|
||||
pGraphics._c(XX[4], YY[4], XX[5], YY[5], XX[6], YY[6]);
|
||||
pGraphics._c(XX[6], YY[6], XX[7], YY[7], XX[8], YY[8]);
|
||||
pGraphics._l(XX[9], YY[9]);
|
||||
pGraphics._c(XX[9], YY[9], XX[10], YY[10], XX[11], YY[11]);
|
||||
pGraphics._c(XX[11], YY[11], XX[12], YY[12], XX[13], YY[13]);
|
||||
pGraphics._c(XX[13], YY[13], XX[14], YY[14], XX[15], YY[15]);
|
||||
pGraphics._c(XX[15], YY[15], XX[16], YY[16], XX[17], YY[17]);
|
||||
pGraphics._c(XX[17], YY[17], XX[18], YY[18], XX[19], YY[19]);
|
||||
pGraphics._c(XX[19], YY[19], XX[20], YY[20], XX[21], YY[21]);
|
||||
pGraphics._l(XX[22], YY[22]);
|
||||
};
|
||||
function CMathAccentPr() {
|
||||
this.chr = null;
|
||||
this.chrType = null;
|
||||
}
|
||||
CMathAccentPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.chr && null !== Obj.chr) {
|
||||
this.chr = Obj.chr;
|
||||
} else {
|
||||
this.chr = null;
|
||||
}
|
||||
if (undefined !== Obj.chrType && null !== Obj.chrType) {
|
||||
this.chrType = Obj.chrType;
|
||||
} else {
|
||||
this.chrType = null;
|
||||
}
|
||||
};
|
||||
CMathAccentPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathAccentPr();
|
||||
NewPr.chr = this.chr;
|
||||
NewPr.chrType = this.chrType;
|
||||
return NewPr;
|
||||
};
|
||||
CMathAccentPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(null === this.chr ? -1 : this.chr);
|
||||
Writer.WriteLong(null === this.chrType ? -1 : this.chrType);
|
||||
};
|
||||
CMathAccentPr.prototype.Read_FromBinary = function (Reader) {
|
||||
var chr = Reader.GetLong();
|
||||
var chrType = Reader.GetLong();
|
||||
this.chr = -1 === chr ? null : chr;
|
||||
this.chrType = -1 === chrType ? null : chrType;
|
||||
};
|
||||
function CAccent(props) {
|
||||
CAccent.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathAccentPr();
|
||||
this.gap = 0;
|
||||
this.operator = new COperator(OPER_ACCENT);
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CAccent, CMathBase);
|
||||
CAccent.prototype.ClassType = historyitem_type_acc;
|
||||
CAccent.prototype.kind = MATH_ACCENT;
|
||||
CAccent.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(1);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CAccent.prototype.getBase = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CAccent.prototype.fillContent = function () {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = this.getBase();
|
||||
};
|
||||
CAccent.prototype.IsAccent = function () {
|
||||
return true;
|
||||
};
|
||||
CAccent.prototype.setPosition = function (pos, PosInfo) {
|
||||
this.pos.x = pos.x;
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
var width = this.size.width - this.GapLeft - this.GapRight;
|
||||
var alignOp = (width - this.operator.size.width) / 2,
|
||||
alignCnt = (width - this.elements[0][0].size.width) / 2;
|
||||
var PosOper = new CMathPosition();
|
||||
PosOper.x = this.pos.x + this.GapLeft + alignOp;
|
||||
PosOper.y = this.pos.y;
|
||||
this.operator.setPosition(PosOper);
|
||||
var PosBase = new CMathPosition();
|
||||
PosBase.x = this.pos.x + this.GapLeft + alignCnt;
|
||||
PosBase.y = this.pos.y + this.operator.size.height;
|
||||
this.elements[0][0].setPosition(PosBase, PosInfo);
|
||||
};
|
||||
CAccent.prototype.ApplyProperties = function (RPI) {
|
||||
if (this.RecalcInfo.bProps == true) {
|
||||
var prp = {
|
||||
type: this.Pr.chrType,
|
||||
chr: this.Pr.chr,
|
||||
loc: LOCATION_TOP
|
||||
};
|
||||
var defaultPrp = {
|
||||
type: ACCENT_CIRCUMFLEX
|
||||
};
|
||||
this.operator.mergeProperties(prp, defaultPrp);
|
||||
this.RecalcInfo.bProps = false;
|
||||
}
|
||||
};
|
||||
CAccent.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.ApplyProperties(RPI);
|
||||
this.operator.PreRecalc(this, ParaMath);
|
||||
CAccent.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
|
||||
};
|
||||
CAccent.prototype.Resize = function (oMeasure, RPI) {
|
||||
var base = this.getBase();
|
||||
base.Resize(oMeasure, RPI);
|
||||
this.operator.fixSize(oMeasure, base.size.width);
|
||||
var width = base.size.width,
|
||||
height = base.size.height + this.operator.size.height,
|
||||
ascent = this.operator.size.height + this.elements[0][0].size.ascent;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
height: height,
|
||||
width: width,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CAccent.prototype.draw = function (x, y, pGraphics, PDSE) {
|
||||
var base = this.elements[0][0];
|
||||
base.draw(x, y, pGraphics, PDSE);
|
||||
var Info = {
|
||||
Result: true,
|
||||
sty: null,
|
||||
scr: null,
|
||||
Latin: false,
|
||||
Greek: false
|
||||
};
|
||||
base.getInfoLetter(Info);
|
||||
if (Info.Result == true) {
|
||||
var bAlphabet = Info.Latin || Info.Greek;
|
||||
var bRomanSerif = (Info.sty == STY_BI || Info.sty == STY_ITALIC) && (Info.scr == TXT_ROMAN || Info.scr == TXT_SANS_SERIF),
|
||||
bScript = Info.scr == TXT_SCRIPT;
|
||||
if (bAlphabet && (bRomanSerif || bScript)) {
|
||||
if (this.Pr.chr != 773 && this.Pr.chr >= 768 && this.Pr.chr <= 789 || this.Pr.chr == 8411) {
|
||||
var ascent = this.elements[0][0].size.ascent;
|
||||
x += ascent * 0.1;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.operator.draw(x, y, pGraphics, PDSE);
|
||||
};
|
||||
CAccent.prototype.GetLastElement = function () {
|
||||
return this.Content[0].GetLastElement();
|
||||
};
|
||||
CAccent.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Accent;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
1165
OfficeWeb/sdk/Word/Math/base.js
Normal file
1165
OfficeWeb/sdk/Word/Math/base.js
Normal file
File diff suppressed because it is too large
Load Diff
566
OfficeWeb/sdk/Word/Math/borderBox.js
Normal file
566
OfficeWeb/sdk/Word/Math/borderBox.js
Normal file
@@ -0,0 +1,566 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CMathBreak() {
|
||||
this.AlnAt = undefined;
|
||||
}
|
||||
CMathBreak.prototype.Set_FromObject = function (Obj) {
|
||||
if (Obj.AlnAt !== undefined && Obj.AlnAt !== null && Obj.AlnAt - 0 == Obj.AlnAt) {
|
||||
if (Obj.AlnAt >= 1 && Obj.AlnAt <= 255) {
|
||||
this.AlnAt = Obj.AlnAt;
|
||||
}
|
||||
}
|
||||
};
|
||||
CMathBreak.prototype.Copy = function () {
|
||||
var NewMBreak = new CMathBreak();
|
||||
NewMBreak.AlnAt = this.AlnAt;
|
||||
return NewMBreak;
|
||||
};
|
||||
CMathBreak.prototype.Write_ToBinary = function (Writer) {
|
||||
if (this.AlnAt !== undefined) {
|
||||
Writer.WriteBool(false);
|
||||
Writer.WriteLong(this.AlnAt);
|
||||
} else {
|
||||
Writer.WriteBool(true);
|
||||
}
|
||||
};
|
||||
CMathBreak.prototype.Read_FromBinary = function (Reader) {
|
||||
if (Reader.GetBool() == false) {
|
||||
this.AlnAt = Reader.GetLong();
|
||||
} else {
|
||||
this.AlnAt = undefined;
|
||||
}
|
||||
};
|
||||
function CMathBorderBoxPr() {
|
||||
this.hideBot = false;
|
||||
this.hideLeft = false;
|
||||
this.hideRight = false;
|
||||
this.hideTop = false;
|
||||
this.strikeBLTR = false;
|
||||
this.strikeH = false;
|
||||
this.strikeTLBR = false;
|
||||
this.strikeV = false;
|
||||
}
|
||||
CMathBorderBoxPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.hideBot && null !== Obj.hideBot) {
|
||||
this.hideBot = Obj.hideBot;
|
||||
}
|
||||
if (undefined !== Obj.hideLeft && null !== Obj.hideLeft) {
|
||||
this.hideLeft = Obj.hideLeft;
|
||||
}
|
||||
if (undefined !== Obj.hideRight && null !== Obj.hideRight) {
|
||||
this.hideRight = Obj.hideRight;
|
||||
}
|
||||
if (undefined !== Obj.hideTop && null !== Obj.hideTop) {
|
||||
this.hideTop = Obj.hideTop;
|
||||
}
|
||||
if (undefined !== Obj.strikeBLTR && null !== Obj.strikeBLTR) {
|
||||
this.strikeBLTR = Obj.strikeBLTR;
|
||||
}
|
||||
if (undefined !== Obj.strikeH && null !== Obj.strikeH) {
|
||||
this.strikeH = Obj.strikeH;
|
||||
}
|
||||
if (undefined !== Obj.strikeTLBR && null !== Obj.strikeTLBR) {
|
||||
this.strikeTLBR = Obj.strikeTLBR;
|
||||
}
|
||||
if (undefined !== Obj.strikeV && null !== Obj.strikeV) {
|
||||
this.strikeV = Obj.strikeV;
|
||||
}
|
||||
};
|
||||
CMathBorderBoxPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathBorderBoxPr();
|
||||
NewPr.hideLeft = this.hideLeft;
|
||||
NewPr.hideRight = this.hideRight;
|
||||
NewPr.hideTop = this.hideTop;
|
||||
NewPr.strikeBLTR = this.strikeBLTR;
|
||||
NewPr.strikeH = this.strikeH;
|
||||
NewPr.strikeTLBR = this.strikeTLBR;
|
||||
NewPr.strikeV = this.strikeV;
|
||||
return NewPr;
|
||||
};
|
||||
CMathBorderBoxPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteBool(this.hideBot);
|
||||
Writer.WriteBool(this.hideLeft);
|
||||
Writer.WriteBool(this.hideRight);
|
||||
Writer.WriteBool(this.hideTop);
|
||||
Writer.WriteBool(this.strikeBLTR);
|
||||
Writer.WriteBool(this.strikeH);
|
||||
Writer.WriteBool(this.strikeTLBR);
|
||||
Writer.WriteBool(this.strikeV);
|
||||
};
|
||||
CMathBorderBoxPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.hideBot = Reader.GetBool();
|
||||
this.hideLeft = Reader.GetBool();
|
||||
this.hideRight = Reader.GetBool();
|
||||
this.hideTop = Reader.GetBool();
|
||||
this.strikeBLTR = Reader.GetBool();
|
||||
this.strikeH = Reader.GetBool();
|
||||
this.strikeTLBR = Reader.GetBool();
|
||||
this.strikeV = Reader.GetBool();
|
||||
};
|
||||
function CBorderBox(props) {
|
||||
CBorderBox.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.gapBrd = 0;
|
||||
this.Pr = new CMathBorderBoxPr();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CBorderBox, CMathBase);
|
||||
CBorderBox.prototype.ClassType = historyitem_type_borderBox;
|
||||
CBorderBox.prototype.kind = MATH_BORDER_BOX;
|
||||
CBorderBox.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(1);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CBorderBox.prototype.getBase = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CBorderBox.prototype.fillContent = function () {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = this.getBase();
|
||||
};
|
||||
CBorderBox.prototype.recalculateSize = function () {
|
||||
var base = this.elements[0][0].size;
|
||||
var width = base.width;
|
||||
var height = base.height;
|
||||
var ascent = base.ascent;
|
||||
this.gapBrd = this.Get_TxtPrControlLetter().FontSize * 0.08104587131076388;
|
||||
if (this.Pr.hideTop == false) {
|
||||
height += this.gapBrd;
|
||||
ascent += this.gapBrd;
|
||||
}
|
||||
if (this.Pr.hideBot == false) {
|
||||
height += this.gapBrd;
|
||||
}
|
||||
if (this.Pr.hideLeft == false) {
|
||||
width += this.gapBrd;
|
||||
}
|
||||
if (this.Pr.hideRight == false) {
|
||||
width += this.gapBrd;
|
||||
}
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CBorderBox.prototype.draw = function (x, y, pGraphics, PDSE) {
|
||||
this.elements[0][0].draw(x, y, pGraphics, PDSE);
|
||||
var penW = this.Get_TxtPrControlLetter().FontSize * 0.02;
|
||||
var Width = this.size.width - this.GapLeft - this.GapRight,
|
||||
Height = this.size.height;
|
||||
var X = this.pos.x + x + this.GapLeft,
|
||||
Y = this.pos.y + y;
|
||||
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
|
||||
if (!this.Pr.hideTop) {
|
||||
var x1 = X,
|
||||
x2 = X + Width,
|
||||
y1 = Y;
|
||||
pGraphics.drawHorLine(0, y1, x1, x2, penW);
|
||||
}
|
||||
if (!this.Pr.hideBot) {
|
||||
var x1 = X,
|
||||
x2 = X + Width,
|
||||
y1 = Y + Height;
|
||||
pGraphics.drawHorLine(2, y1, x1, x2, penW);
|
||||
}
|
||||
if (!this.Pr.hideLeft) {
|
||||
var x1 = X,
|
||||
y1 = Y,
|
||||
y2 = Y + Height;
|
||||
pGraphics.drawVerLine(0, x1, y1, y2, penW);
|
||||
}
|
||||
if (!this.Pr.hideRight) {
|
||||
var x1 = X + Width,
|
||||
y1 = Y,
|
||||
y2 = Y + Height;
|
||||
pGraphics.drawVerLine(2, x1, y1, y2, penW);
|
||||
}
|
||||
if (this.Pr.strikeTLBR) {
|
||||
if (penW < 0.3) {
|
||||
var x1 = X,
|
||||
y1 = Y,
|
||||
x2 = X + Width,
|
||||
y2 = Y + Height;
|
||||
pGraphics.p_width(180);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics.ds();
|
||||
} else {
|
||||
var pW = penW * 0.8;
|
||||
var x1 = X,
|
||||
y1 = Y,
|
||||
x2 = X + pW,
|
||||
y2 = Y,
|
||||
x3 = X + Width,
|
||||
y3 = Y + Height - pW,
|
||||
x4 = X + Width,
|
||||
y4 = Y + Height,
|
||||
x5 = X + Width - pW,
|
||||
y5 = Y + Height,
|
||||
x6 = X,
|
||||
y6 = Y + pW,
|
||||
x7 = X,
|
||||
y7 = Y;
|
||||
pGraphics.p_width(1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics._l(x3, y3);
|
||||
pGraphics._l(x4, y4);
|
||||
pGraphics._l(x5, y5);
|
||||
pGraphics._l(x6, y6);
|
||||
pGraphics._l(x7, y7);
|
||||
pGraphics.df();
|
||||
}
|
||||
}
|
||||
if (this.Pr.strikeBLTR) {
|
||||
if (penW < 0.3) {
|
||||
var x1 = X + Width,
|
||||
y1 = Y,
|
||||
x2 = X,
|
||||
y2 = Y + Height;
|
||||
pGraphics.p_width(180);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics.ds();
|
||||
} else {
|
||||
var pW = 0.8 * penW;
|
||||
var x1 = X + Width,
|
||||
y1 = Y,
|
||||
x2 = X + Width - pW,
|
||||
y2 = Y,
|
||||
x3 = X,
|
||||
y3 = Y + Height - pW,
|
||||
x4 = X,
|
||||
y4 = Y + Height,
|
||||
x5 = X + pW,
|
||||
y5 = Y + Height,
|
||||
x6 = X + Width,
|
||||
y6 = Y + pW,
|
||||
x7 = X + Width,
|
||||
y7 = Y;
|
||||
pGraphics.p_width(1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics._l(x3, y3);
|
||||
pGraphics._l(x4, y4);
|
||||
pGraphics._l(x5, y5);
|
||||
pGraphics._l(x6, y6);
|
||||
pGraphics._l(x7, y7);
|
||||
pGraphics.df();
|
||||
}
|
||||
}
|
||||
if (this.Pr.strikeH) {
|
||||
var x1 = X,
|
||||
x2 = X + Width,
|
||||
y1 = Y + Height / 2 - penW / 2;
|
||||
pGraphics.drawHorLine(0, y1, x1, x2, penW);
|
||||
}
|
||||
if (this.Pr.strikeV) {
|
||||
var x1 = X + Width / 2 - penW / 2,
|
||||
y1 = Y,
|
||||
y2 = Y + Height;
|
||||
pGraphics.drawVerLine(0, x1, y1, y2, penW);
|
||||
}
|
||||
};
|
||||
CBorderBox.prototype.setPosition = function (pos, PosInfo) {
|
||||
this.pos.x = pos.x;
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
var NewPos = new CMathPosition();
|
||||
if (this.Pr.hideLeft == false) {
|
||||
NewPos.x = this.pos.x + this.GapLeft + this.gapBrd;
|
||||
} else {
|
||||
NewPos.x = this.pos.x + this.GapLeft;
|
||||
}
|
||||
if (this.Pr.hideTop == false) {
|
||||
NewPos.y = this.pos.y + this.gapBrd;
|
||||
} else {
|
||||
NewPos.y = this.pos.y;
|
||||
}
|
||||
this.elements[0][0].setPosition(NewPos, PosInfo);
|
||||
};
|
||||
function CMathBoxPr() {
|
||||
this.brk = undefined;
|
||||
this.aln = false;
|
||||
this.diff = false;
|
||||
this.noBreak = false;
|
||||
this.opEmu = false;
|
||||
}
|
||||
CMathBoxPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (true === Obj.aln || 1 === Obj.aln) {
|
||||
this.aln = true;
|
||||
} else {
|
||||
this.aln = false;
|
||||
}
|
||||
if (Obj.brk !== null && Obj.brk !== undefined) {
|
||||
this.brk = new CMathBreak();
|
||||
this.brk.Set_FromObject(Obj.brk);
|
||||
}
|
||||
if (true === Obj.diff || 1 === Obj.diff) {
|
||||
this.diff = true;
|
||||
} else {
|
||||
this.diff = false;
|
||||
}
|
||||
if (true === Obj.noBreak || 1 === Obj.noBreak) {
|
||||
this.noBreak = true;
|
||||
} else {
|
||||
this.noBreak = false;
|
||||
}
|
||||
if (true === Obj.opEmu || 1 === Obj.opEmu) {
|
||||
this.opEmu = true;
|
||||
} else {
|
||||
this.opEmu = false;
|
||||
}
|
||||
};
|
||||
CMathBoxPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathBoxPr();
|
||||
NewPr.aln = this.aln;
|
||||
NewPr.diff = this.diff;
|
||||
NewPr.noBreak = this.noBreak;
|
||||
NewPr.opEmu = this.opEmu;
|
||||
if (this.brk !== undefined) {
|
||||
NewPr.brk = this.brk.Copy();
|
||||
}
|
||||
return NewPr;
|
||||
};
|
||||
CMathBoxPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteBool(this.aln);
|
||||
Writer.WriteBool(this.diff);
|
||||
Writer.WriteBool(this.noBreak);
|
||||
Writer.WriteBool(this.opEmu);
|
||||
if (undefined !== this.brk) {
|
||||
Writer.WriteBool(false);
|
||||
this.brk.Write_ToBinary(Writer);
|
||||
} else {
|
||||
Writer.WriteBool(true);
|
||||
}
|
||||
};
|
||||
CMathBoxPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.aln = Reader.GetBool();
|
||||
this.diff = Reader.GetBool();
|
||||
this.noBreak = Reader.GetBool();
|
||||
this.opEmu = Reader.GetBool();
|
||||
if (Reader.GetBool() == false) {
|
||||
this.brk = new CMathBreak();
|
||||
this.brk.Read_FromBinary(Reader);
|
||||
} else {
|
||||
this.brk = undefined;
|
||||
}
|
||||
};
|
||||
function CBox(props) {
|
||||
CBox.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathBoxPr();
|
||||
this.baseContent = new CMathContent();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CBox, CMathBase);
|
||||
CBox.prototype.ClassType = historyitem_type_box;
|
||||
CBox.prototype.kind = MATH_BOX;
|
||||
CBox.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(1);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CBox.prototype.fillContent = function () {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = this.getBase();
|
||||
};
|
||||
CBox.prototype.getBase = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
function CMathBarPr() {
|
||||
this.pos = LOCATION_BOT;
|
||||
}
|
||||
CMathBarPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (LOCATION_TOP === Obj.pos || LOCATION_BOT === Obj.pos) {
|
||||
this.pos = Obj.pos;
|
||||
}
|
||||
};
|
||||
CMathBarPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathBarPr();
|
||||
NewPr.pos = this.pos;
|
||||
return NewPr;
|
||||
};
|
||||
CMathBarPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.pos);
|
||||
};
|
||||
CMathBarPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.pos = Reader.GetLong();
|
||||
};
|
||||
function CBar(props) {
|
||||
CBar.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathBarPr();
|
||||
this.operator = new COperator(OPER_BAR);
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CBar, CCharacter);
|
||||
CBar.prototype.ClassType = historyitem_type_bar;
|
||||
CBar.prototype.kind = MATH_BAR;
|
||||
CBar.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(1);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CBar.prototype.getBase = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CBar.prototype.fillContent = function () {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = this.getBase();
|
||||
};
|
||||
CBar.prototype.ApplyProperties = function (RPI) {
|
||||
if (this.RecalcInfo.bProps == true) {
|
||||
var prp = {
|
||||
loc: this.Pr.pos,
|
||||
type: DELIMITER_LINE
|
||||
};
|
||||
var defaultProps = {
|
||||
loc: LOCATION_BOT
|
||||
};
|
||||
this.setCharacter(prp, defaultProps);
|
||||
this.RecalcInfo.bProps = false;
|
||||
}
|
||||
};
|
||||
CBar.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.ApplyProperties(RPI);
|
||||
this.operator.PreRecalc(this, ParaMath);
|
||||
CBar.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
|
||||
};
|
||||
CBar.prototype.getAscent = function () {
|
||||
var ascent;
|
||||
if (this.Pr.pos === LOCATION_TOP) {
|
||||
ascent = this.operator.size.height + this.elements[0][0].size.ascent;
|
||||
} else {
|
||||
if (this.Pr.pos === LOCATION_BOT) {
|
||||
ascent = this.elements[0][0].size.ascent;
|
||||
}
|
||||
}
|
||||
return ascent;
|
||||
};
|
||||
function CMathPhantomPr() {
|
||||
this.show = true;
|
||||
this.transp = false;
|
||||
this.zeroAsc = false;
|
||||
this.zeroDesc = false;
|
||||
this.zeroWid = false;
|
||||
}
|
||||
CMathPhantomPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (true === Obj.show || 1 === Obj.show) {
|
||||
this.show = true;
|
||||
} else {
|
||||
this.show = false;
|
||||
}
|
||||
if (true === Obj.transp || 1 === Obj.transp) {
|
||||
this.transp = true;
|
||||
} else {
|
||||
this.transp = false;
|
||||
}
|
||||
if (true === Obj.zeroAsc || 1 === Obj.zeroAsc) {
|
||||
this.zeroAsc = true;
|
||||
} else {
|
||||
this.zeroAsc = false;
|
||||
}
|
||||
if (true === Obj.zeroDesc || 1 === Obj.zeroDesc) {
|
||||
this.zeroDesc = true;
|
||||
} else {
|
||||
this.zeroDesc = false;
|
||||
}
|
||||
if (true === Obj.zeroWid || 1 === Obj.zeroWid) {
|
||||
this.zeroWid = true;
|
||||
} else {
|
||||
this.zeroWid = false;
|
||||
}
|
||||
};
|
||||
CMathPhantomPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathPhantomPr();
|
||||
NewPr.show = this.show;
|
||||
NewPr.transp = this.transp;
|
||||
NewPr.zeroAsc = this.zeroAsc;
|
||||
NewPr.zeroDesc = this.zeroDesc;
|
||||
NewPr.zeroWid = this.zeroWid;
|
||||
return NewPr;
|
||||
};
|
||||
CMathPhantomPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteBool(this.show);
|
||||
Writer.WriteBool(this.transp);
|
||||
Writer.WriteBool(this.zeroAsc);
|
||||
Writer.WriteBool(this.zeroDesc);
|
||||
Writer.WriteBool(this.zeroWid);
|
||||
};
|
||||
CMathPhantomPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.show = Reader.GetBool();
|
||||
this.transp = Reader.GetBool();
|
||||
this.zeroAsc = Reader.GetBool();
|
||||
this.zeroDesc = Reader.GetBool();
|
||||
this.zeroWid = Reader.GetBool();
|
||||
};
|
||||
function CPhantom(props) {
|
||||
CPhantom.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathPhantomPr();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CPhantom, CMathBase);
|
||||
CPhantom.prototype.ClassType = historyitem_type_phant;
|
||||
CPhantom.prototype.kind = MATH_PHANTOM;
|
||||
CPhantom.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(1);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CPhantom.prototype.getBase = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CPhantom.prototype.fillContent = function () {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = this.getBase();
|
||||
};
|
||||
510
OfficeWeb/sdk/Word/Math/degree.js
Normal file
510
OfficeWeb/sdk/Word/Math/degree.js
Normal file
@@ -0,0 +1,510 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CMathDegreePr() {
|
||||
this.type = DEGREE_SUPERSCRIPT;
|
||||
}
|
||||
CMathDegreePr.prototype.Set_FromObject = function (Obj) {
|
||||
if (DEGREE_SUPERSCRIPT === Obj.type || DEGREE_SUBSCRIPT === Obj.type) {
|
||||
this.type = Obj.type;
|
||||
} else {
|
||||
this.type = DEGREE_SUPERSCRIPT;
|
||||
}
|
||||
};
|
||||
CMathDegreePr.prototype.Copy = function () {
|
||||
var NewPr = new CMathDegreePr();
|
||||
NewPr.type = this.type;
|
||||
return NewPr;
|
||||
};
|
||||
CMathDegreePr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.type);
|
||||
};
|
||||
CMathDegreePr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.type = Reader.GetLong(Reader);
|
||||
};
|
||||
function CDegreeBase(props, bInside) {
|
||||
CDegreeBase.superclass.constructor.call(this, bInside);
|
||||
this.upBase = 0;
|
||||
this.upIter = 0;
|
||||
this.Pr = new CMathDegreePr();
|
||||
this.baseContent = null;
|
||||
this.iterContent = null;
|
||||
this.bNaryInline = false;
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
}
|
||||
Asc.extendClass(CDegreeBase, CMathBase);
|
||||
CDegreeBase.prototype.init = function (props) {
|
||||
this.setProperties(props);
|
||||
this.setDimension(1, 2);
|
||||
};
|
||||
CDegreeBase.prototype.fillContent = function () {
|
||||
this.setDimension(1, 2);
|
||||
this.elements[0][0] = this.baseContent;
|
||||
this.elements[0][1] = this.iterContent;
|
||||
};
|
||||
CDegreeBase.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.Parent = Parent;
|
||||
this.ParaMath = ParaMath;
|
||||
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
|
||||
this.ApplyProperties(RPI);
|
||||
if (this.bInside == false) {
|
||||
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
|
||||
}
|
||||
this.baseContent.PreRecalc(this, ParaMath, ArgSize, RPI);
|
||||
var ArgSzDegr = ArgSize.Copy();
|
||||
ArgSzDegr.decrease();
|
||||
var RPIDegr = RPI.Copy();
|
||||
RPIDegr.bDecreasedComp = true;
|
||||
this.bNaryInline = RPI.bNaryInline;
|
||||
this.iterContent.PreRecalc(this, ParaMath, ArgSzDegr, RPIDegr);
|
||||
};
|
||||
CDegreeBase.prototype.Resize = function (oMeasure, RPI) {
|
||||
this.baseContent.Resize(oMeasure, RPI);
|
||||
this.iterContent.Resize(oMeasure, RPI);
|
||||
if (this.Pr.type === DEGREE_SUPERSCRIPT) {
|
||||
this.recalculateSup(oMeasure);
|
||||
} else {
|
||||
if (this.Pr.type === DEGREE_SUBSCRIPT) {
|
||||
this.recalculateSubScript(oMeasure);
|
||||
}
|
||||
}
|
||||
};
|
||||
CDegreeBase.prototype.recalculateSup = function (oMeasure) {
|
||||
var base = this.elements[0][0].size,
|
||||
iter = this.elements[0][1].size;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
this.upBase = 0;
|
||||
this.upIter = 0;
|
||||
var bTextElement = false,
|
||||
lastElem;
|
||||
if (!this.baseContent.IsJustDraw()) {
|
||||
lastElem = this.baseContent.GetLastElement();
|
||||
var BaseRun = lastElem.Type == para_Math_Run && mgCtrPrp.FontSize == lastElem.Get_CompiledPr(false).FontSize;
|
||||
bTextElement = BaseRun || (lastElem.Type !== para_Math_Run && lastElem.IsJustDraw());
|
||||
}
|
||||
var PlH = 0.64 * this.ParaMath.GetPlh(oMeasure, mgCtrPrp);
|
||||
var UpBaseline = 0.75 * PlH;
|
||||
if (bTextElement) {
|
||||
var last = lastElem.size,
|
||||
upBaseLast = 0,
|
||||
upBaseIter = 0;
|
||||
if ((last.ascent - UpBaseline) + (iter.height - iter.ascent) > (last.ascent - 2 / 9 * PlH)) {
|
||||
upBaseLast = iter.height - (last.ascent - 2 / 9 * PlH);
|
||||
} else {
|
||||
if (UpBaseline + iter.ascent > last.ascent) {
|
||||
upBaseLast = UpBaseline + iter.ascent - last.ascent;
|
||||
} else {
|
||||
upBaseIter = last.ascent - UpBaseline - iter.ascent;
|
||||
}
|
||||
}
|
||||
if (upBaseLast + last.ascent > base.ascent) {
|
||||
this.upBase = upBaseLast - (base.ascent - last.ascent);
|
||||
this.upIter = upBaseIter;
|
||||
} else {
|
||||
this.upBase = 0;
|
||||
this.upIter = (base.ascent - upBaseLast - last.ascent) + upBaseIter;
|
||||
}
|
||||
} else {
|
||||
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
|
||||
if (iter.height - iter.ascent + shCenter > base.ascent) {
|
||||
this.upBase = iter.height - (base.ascent - shCenter);
|
||||
} else {
|
||||
if (iter.ascent > shCenter) {
|
||||
this.upBase = iter.ascent - shCenter;
|
||||
} else {
|
||||
this.upIter = shCenter - iter.ascent;
|
||||
}
|
||||
}
|
||||
}
|
||||
var height = this.upBase + base.height;
|
||||
var ascent = this.upBase + base.ascent;
|
||||
if (this.bNaryInline) {
|
||||
this.dW = 0.17 * PlH;
|
||||
} else {
|
||||
this.dW = 0.056 * PlH;
|
||||
}
|
||||
var width = base.width + iter.width + this.dW;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CDegreeBase.prototype.recalculateSubScript = function (oMeasure) {
|
||||
var base = this.elements[0][0].size,
|
||||
iter = this.elements[0][1].size;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
|
||||
var bTextElement = false,
|
||||
lastElem;
|
||||
if (!this.baseContent.IsJustDraw()) {
|
||||
lastElem = this.baseContent.GetLastElement();
|
||||
var txtPrpControl = this.ParaMath.GetFirstRPrp();
|
||||
var BaseRun = lastElem.Type == para_Math_Run && txtPrpControl.FontSize == lastElem.Get_CompiledPr(false).FontSize;
|
||||
bTextElement = BaseRun || (lastElem.Type !== para_Math_Run && lastElem.IsJustDraw());
|
||||
}
|
||||
var height, ascent, descent;
|
||||
var PlH = 0.64 * this.ParaMath.GetPlh(oMeasure, mgCtrPrp);
|
||||
if (bTextElement) {
|
||||
var DownBaseline = 0.9 * shCenter;
|
||||
if (iter.ascent - DownBaseline > 3 / 4 * PlH) {
|
||||
this.upIter = 1 / 4 * PlH;
|
||||
} else {
|
||||
this.upIter = PlH + DownBaseline - iter.ascent;
|
||||
}
|
||||
if (base.ascent > PlH) {
|
||||
this.upIter += base.ascent - PlH;
|
||||
}
|
||||
var descentBase = base.height - base.ascent,
|
||||
descentIter = this.upIter + iter.height - base.ascent;
|
||||
descent = descentBase > descentIter ? descentBase : descentIter;
|
||||
ascent = base.ascent;
|
||||
height = ascent + descent;
|
||||
} else {
|
||||
this.upIter = base.height + shCenter - iter.ascent;
|
||||
if (base.ascent - 1.5 * shCenter > this.upIter) {
|
||||
this.upIter = base.ascent - 1.5 * shCenter;
|
||||
}
|
||||
height = this.upIter + iter.height;
|
||||
ascent = base.ascent;
|
||||
}
|
||||
if (this.bNaryInline) {
|
||||
this.dW = 0.17 * PlH;
|
||||
} else {
|
||||
this.dW = 0.056 * PlH;
|
||||
}
|
||||
var width = base.width + iter.width + this.dW;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CDegreeBase.prototype.setPosition = function (pos, PosInfo) {
|
||||
this.pos.x = pos.x;
|
||||
if (this.bInside === true) {
|
||||
this.pos.y = pos.y;
|
||||
} else {
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
}
|
||||
var PosBase = new CMathPosition();
|
||||
PosBase.x = this.pos.x + this.GapLeft;
|
||||
PosBase.y = this.pos.y + this.upBase;
|
||||
var PosIter = new CMathPosition();
|
||||
PosIter.x = this.pos.x + this.GapLeft + this.elements[0][0].size.width + this.dW;
|
||||
PosIter.y = this.pos.y + this.upIter;
|
||||
this.elements[0][0].setPosition(PosBase, PosInfo);
|
||||
this.elements[0][1].setPosition(PosIter, PosInfo);
|
||||
};
|
||||
CDegreeBase.prototype.getIterator = function () {
|
||||
return this.iterContent;
|
||||
};
|
||||
CDegreeBase.prototype.getUpperIterator = function () {
|
||||
return this.iterContent;
|
||||
};
|
||||
CDegreeBase.prototype.getLowerIterator = function () {
|
||||
return this.iterContent;
|
||||
};
|
||||
CDegreeBase.prototype.getBase = function () {
|
||||
return this.baseContent;
|
||||
};
|
||||
CDegreeBase.prototype.IsPlhIterator = function () {
|
||||
return this.iterContent.IsPlaceholder();
|
||||
};
|
||||
CDegreeBase.prototype.setBase = function (base) {
|
||||
this.baseContent = base;
|
||||
};
|
||||
CDegreeBase.prototype.setIterator = function (iterator) {
|
||||
this.iterContent = iterator;
|
||||
};
|
||||
function CDegree(props, bInside) {
|
||||
CDegree.superclass.constructor.call(this, props, bInside);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CDegree, CDegreeBase);
|
||||
CDegree.prototype.ClassType = historyitem_type_deg;
|
||||
CDegree.prototype.kind = MATH_DEGREE;
|
||||
CDegree.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(2);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CDegree.prototype.fillContent = function () {
|
||||
this.iterContent = this.Content[1];
|
||||
this.baseContent = this.Content[0];
|
||||
CDegree.superclass.fillContent.apply(this, arguments);
|
||||
};
|
||||
CDegree.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Script;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
function CIterators(iterUp, iterDn) {
|
||||
CIterators.superclass.constructor.call(this, true);
|
||||
this.lUp = 0;
|
||||
this.lD = 0;
|
||||
this.upper = 0;
|
||||
this.iterUp = iterUp;
|
||||
this.iterDn = iterDn;
|
||||
}
|
||||
Asc.extendClass(CIterators, CMathBase);
|
||||
CIterators.prototype.init = function () {
|
||||
this.setDimension(2, 1);
|
||||
this.elements[0][0] = this.iterUp;
|
||||
this.elements[1][0] = this.iterDn;
|
||||
};
|
||||
CIterators.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.Parent = Parent;
|
||||
this.ParaMath = ParaMath;
|
||||
this.ArgSize.SetValue(-1);
|
||||
var ArgSzIters = ArgSize.Copy();
|
||||
ArgSzIters.Merge(this.ArgSize);
|
||||
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
|
||||
var RPI_ITER = RPI.Copy();
|
||||
RPI_ITER.bDecreasedComp = true;
|
||||
this.iterUp.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
|
||||
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
|
||||
};
|
||||
CIterators.prototype.recalculateSize = function (oMeasure, dH, ascent) {
|
||||
this.dH = dH;
|
||||
var iterUp = this.iterUp.size,
|
||||
iterDown = this.iterDn.size;
|
||||
this.size.ascent = ascent;
|
||||
this.size.height = iterUp.height + dH + iterDown.height;
|
||||
this.size.width = iterUp.width > iterDown.width ? iterUp.width : iterDown.width;
|
||||
};
|
||||
CIterators.prototype.getUpperIterator = function () {
|
||||
return this.elements[0][0];
|
||||
};
|
||||
CIterators.prototype.getLowerIterator = function () {
|
||||
return this.elements[1][0];
|
||||
};
|
||||
CIterators.prototype.setUpperIterator = function (iterator) {
|
||||
this.elements[0][0] = iterator;
|
||||
};
|
||||
CIterators.prototype.setLowerIterator = function (iterator) {
|
||||
this.elements[1][0] = iterator;
|
||||
};
|
||||
CIterators.prototype.alignIterators = function (mcJc) {
|
||||
this.alignment.wdt[0] = mcJc;
|
||||
};
|
||||
function CMathDegreeSubSupPr() {
|
||||
this.type = DEGREE_SubSup;
|
||||
this.alnScr = false;
|
||||
}
|
||||
CMathDegreeSubSupPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (true === Obj.alnScr || 1 === Obj.alnScr) {
|
||||
this.alnScr = true;
|
||||
} else {
|
||||
this.alnScr = false;
|
||||
}
|
||||
if (DEGREE_SubSup === Obj.type || DEGREE_PreSubSup === Obj.type) {
|
||||
this.type = Obj.type;
|
||||
}
|
||||
};
|
||||
CMathDegreeSubSupPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathDegreeSubSupPr();
|
||||
NewPr.type = this.type;
|
||||
NewPr.alnScr = this.alnScr;
|
||||
return NewPr;
|
||||
};
|
||||
CMathDegreeSubSupPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.type);
|
||||
Writer.WriteBool(this.alnScr);
|
||||
};
|
||||
CMathDegreeSubSupPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.type = Reader.GetLong();
|
||||
this.alnScr = Reader.GetBool();
|
||||
};
|
||||
function CDegreeSubSupBase(props, bInside) {
|
||||
CDegreeSubSupBase.superclass.constructor.call(this, bInside);
|
||||
this.gapBase = 0;
|
||||
this.bNaryInline = false;
|
||||
this.Pr = new CMathDegreeSubSupPr();
|
||||
this.baseContent = null;
|
||||
this.iters = new CIterators(null, null);
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
}
|
||||
Asc.extendClass(CDegreeSubSupBase, CMathBase);
|
||||
CDegreeSubSupBase.prototype.init = function (props) {
|
||||
this.setProperties(props);
|
||||
this.setDimension(1, 2);
|
||||
};
|
||||
CDegreeSubSupBase.prototype.fillContent = function () {
|
||||
var oBase = this.baseContent;
|
||||
var oIters = this.iters;
|
||||
this.setDimension(1, 2);
|
||||
oIters.init();
|
||||
oIters.lUp = 0;
|
||||
oIters.lD = 0;
|
||||
if (this.Pr.type == DEGREE_SubSup) {
|
||||
oIters.alignIterators(MCJC_LEFT);
|
||||
this.addMCToContent([oBase, oIters]);
|
||||
} else {
|
||||
if (this.Pr.type == DEGREE_PreSubSup) {
|
||||
this.addMCToContent([oIters, oBase]);
|
||||
oIters.alignIterators(MCJC_RIGHT);
|
||||
}
|
||||
}
|
||||
};
|
||||
CDegreeSubSupBase.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.bNaryInline = RPI.bNaryInline;
|
||||
CDegreeSubSupBase.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
|
||||
};
|
||||
CDegreeSubSupBase.prototype.recalculateSize = function (oMeasure, RPI) {
|
||||
var mgCtrPrp = this.Get_CompiledCtrPrp();
|
||||
var iterUp = this.iters.iterUp.size,
|
||||
iterDown = this.iters.iterDn.size,
|
||||
base = this.baseContent.size;
|
||||
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
|
||||
shCenter *= 1.4;
|
||||
var PlH = 0.26 * this.ParaMath.GetPlh(oMeasure, mgCtrPrp);
|
||||
var height, width, ascent, descent;
|
||||
var dH;
|
||||
var minGap;
|
||||
var TextElement = false;
|
||||
if (!this.baseContent.IsJustDraw()) {
|
||||
var last = this.baseContent.GetLastElement();
|
||||
var BaseRun = last.Type == para_Math_Run && mgCtrPrp.FontSize >= last.Get_CompiledPr(false).FontSize;
|
||||
TextElement = BaseRun || (last.Type !== para_Math_Run && last.IsJustDraw());
|
||||
}
|
||||
if (TextElement) {
|
||||
minGap = 0.5 * PlH;
|
||||
var DivBaseline = 3.034 * PlH;
|
||||
var ascIters, dgrHeight;
|
||||
if (DivBaseline > minGap + iterDown.ascent + (iterUp.height - iterUp.ascent)) {
|
||||
dH = DivBaseline - iterDown.ascent - (iterUp.height - iterUp.ascent);
|
||||
} else {
|
||||
dH = minGap;
|
||||
}
|
||||
var GapDown = PlH;
|
||||
ascIters = iterUp.height + dH + GapDown;
|
||||
dgrHeight = iterDown.height + iterUp.height + dH;
|
||||
ascent = ascIters > base.ascent ? ascIters : base.ascent;
|
||||
var dscIter = dgrHeight - ascIters,
|
||||
dscBase = base.height - base.ascent;
|
||||
descent = dscIter > dscBase ? dscIter : dscBase;
|
||||
height = ascent + descent;
|
||||
this.iters.recalculateSize(oMeasure, dH, ascIters);
|
||||
} else {
|
||||
minGap = 0.7 * PlH;
|
||||
var lUpBase = base.ascent - shCenter;
|
||||
var lDownBase = base.height - lUpBase;
|
||||
var DescUpIter = iterUp.height - iterUp.ascent + PlH;
|
||||
var AscDownIter = iterDown.ascent - PlH;
|
||||
var UpGap, DownGap;
|
||||
if (this.bNaryInline) {
|
||||
UpGap = 0;
|
||||
DownGap = 0;
|
||||
} else {
|
||||
UpGap = lUpBase > DescUpIter ? lUpBase - DescUpIter : 0;
|
||||
DownGap = lDownBase > AscDownIter ? lDownBase - AscDownIter : 0;
|
||||
}
|
||||
if (UpGap + DownGap > minGap) {
|
||||
dH = UpGap + DownGap;
|
||||
} else {
|
||||
dH = minGap;
|
||||
}
|
||||
height = iterUp.height + dH + iterDown.height;
|
||||
ascent = iterUp.height + UpGap + shCenter;
|
||||
this.iters.recalculateSize(oMeasure, dH, ascent);
|
||||
}
|
||||
if (this.bNaryInline) {
|
||||
this.dW = 0.42 * PlH;
|
||||
} else {
|
||||
this.dW = 0.14 * PlH;
|
||||
}
|
||||
width = this.iters.size.width + base.width + this.dW;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CDegreeSubSupBase.prototype.getBase = function () {
|
||||
return this.baseContent;
|
||||
};
|
||||
CDegreeSubSupBase.prototype.getUpperIterator = function () {
|
||||
return this.iters.iterUp;
|
||||
};
|
||||
CDegreeSubSupBase.prototype.getLowerIterator = function () {
|
||||
return this.iters.iterDn;
|
||||
};
|
||||
CDegreeSubSupBase.prototype.setBase = function (base) {
|
||||
this.baseContent = base;
|
||||
};
|
||||
CDegreeSubSupBase.prototype.setUpperIterator = function (iterator) {
|
||||
this.iters.iterUp = iterator;
|
||||
};
|
||||
CDegreeSubSupBase.prototype.setLowerIterator = function (iterator) {
|
||||
this.iters.iterDn = iterator;
|
||||
};
|
||||
function CDegreeSubSup(props, bInside) {
|
||||
CDegreeSubSup.superclass.constructor.call(this, props, bInside);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CDegreeSubSup, CDegreeSubSupBase);
|
||||
CDegreeSubSup.prototype.ClassType = historyitem_type_deg_subsup;
|
||||
CDegreeSubSup.prototype.kind = MATH_DEGREESubSup;
|
||||
CDegreeSubSup.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(3);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CDegreeSubSup.prototype.fillContent = function () {
|
||||
if (DEGREE_SubSup === this.Pr.type) {
|
||||
this.baseContent = this.Content[0];
|
||||
this.iters = new CIterators(this.Content[2], this.Content[1]);
|
||||
} else {
|
||||
this.baseContent = this.Content[2];
|
||||
this.iters = new CIterators(this.Content[1], this.Content[0]);
|
||||
}
|
||||
CDegreeSubSup.superclass.fillContent.apply(this, arguments);
|
||||
};
|
||||
CDegreeSubSup.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Script;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
449
OfficeWeb/sdk/Word/Math/fraction.js
Normal file
449
OfficeWeb/sdk/Word/Math/fraction.js
Normal file
@@ -0,0 +1,449 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CMathFractionPr() {
|
||||
this.type = BAR_FRACTION;
|
||||
}
|
||||
CMathFractionPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.type && null !== Obj.type) {
|
||||
this.type = Obj.type;
|
||||
}
|
||||
};
|
||||
CMathFractionPr.prototype.Copy = function (Obj) {
|
||||
var NewPr = new CMathFractionPr();
|
||||
NewPr.type = this.type;
|
||||
return NewPr;
|
||||
};
|
||||
CMathFractionPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.type);
|
||||
};
|
||||
CMathFractionPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.type = Reader.GetLong();
|
||||
};
|
||||
function CFraction(props) {
|
||||
CFraction.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Numerator = null;
|
||||
this.Denominator = null;
|
||||
this.Pr = new CMathFractionPr();
|
||||
this.bHideBar = false;
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CFraction, CMathBase);
|
||||
CFraction.prototype.ClassType = historyitem_type_frac;
|
||||
CFraction.prototype.kind = MATH_FRACTION;
|
||||
CFraction.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(2);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CFraction.prototype.getType = function () {
|
||||
return this.Pr.type;
|
||||
};
|
||||
CFraction.prototype.draw = function (x, y, pGraphics, PDSE) {
|
||||
if (this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) {
|
||||
this.drawBarFraction(x, y, pGraphics, PDSE);
|
||||
} else {
|
||||
if (this.Pr.type == SKEWED_FRACTION) {
|
||||
this.drawSkewedFraction(x, y, pGraphics, PDSE);
|
||||
} else {
|
||||
if (this.Pr.type == LINEAR_FRACTION) {
|
||||
this.drawLinearFraction(x, y, pGraphics, PDSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CFraction.prototype.drawBarFraction = function (x, y, pGraphics, PDSE) {
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var penW = mgCtrPrp.FontSize * 25.4 / 96 * 0.08;
|
||||
var numHeight = this.elements[0][0].size.height;
|
||||
var width = this.size.width - this.GapLeft - this.GapRight;
|
||||
var x1 = this.pos.x + x + this.GapLeft,
|
||||
x2 = x1 + width,
|
||||
y1 = this.pos.y + y + numHeight - penW;
|
||||
if (!this.bHideBar) {
|
||||
pGraphics.SetFont(mgCtrPrp);
|
||||
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
|
||||
pGraphics.drawHorLine(0, y1, x1, x2, penW);
|
||||
}
|
||||
CFraction.superclass.draw.call(this, x, y, pGraphics, PDSE);
|
||||
};
|
||||
CFraction.prototype.drawSkewedFraction = function (x, y, pGraphics, PDSE) {
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var penW = mgCtrPrp.FontSize / 12.5 * g_dKoef_pix_to_mm;
|
||||
var gap = this.dW / 2 - penW / 7.5;
|
||||
var plh = 9.877777777777776 * mgCtrPrp.FontSize / 36;
|
||||
var minHeight = 2 * this.dW,
|
||||
middleHeight = plh * 4 / 3,
|
||||
maxHeight = (3 * this.dW + 5 * plh) * 2 / 3;
|
||||
var tg;
|
||||
var tg1 = -2.22,
|
||||
tg2 = -3.7;
|
||||
var X = this.pos.x + x + this.GapLeft,
|
||||
Y = this.pos.y + y;
|
||||
var heightSlash = this.size.height * 2 / 3;
|
||||
if (heightSlash < maxHeight) {
|
||||
if (heightSlash < minHeight) {
|
||||
heightSlash = minHeight;
|
||||
tg = tg1;
|
||||
} else {
|
||||
heightSlash = this.size.height * 2 / 3;
|
||||
tg = (heightSlash - maxHeight) * (tg1 - tg2) / (middleHeight - maxHeight) + tg2;
|
||||
}
|
||||
var b = this.elements[0][0].size.height - tg * (this.elements[0][0].size.width + gap);
|
||||
var y1 = this.elements[0][0].size.height / 3,
|
||||
y2 = this.elements[0][0].size.height / 3 + heightSlash;
|
||||
var x1 = (y1 - b) / tg,
|
||||
x2 = (y2 - b) / tg;
|
||||
var xx1 = X + x1,
|
||||
xx2 = X + x2;
|
||||
var yy1 = Y + y1,
|
||||
yy2 = Y + y2;
|
||||
} else {
|
||||
heightSlash = maxHeight;
|
||||
tg = tg2;
|
||||
var coeff = this.elements[0][0].size.height / this.size.height;
|
||||
var shift = heightSlash * coeff;
|
||||
var minVal = plh / 2,
|
||||
maxVal = heightSlash - minVal;
|
||||
if (shift < minVal) {
|
||||
shift = minVal;
|
||||
} else {
|
||||
if (shift > maxVal) {
|
||||
shift = maxVal;
|
||||
}
|
||||
}
|
||||
var y0 = this.elements[0][0].size.height - shift;
|
||||
var b = this.elements[0][0].size.height - tg * (this.elements[0][0].size.width + gap);
|
||||
var y1 = y0,
|
||||
y2 = y0 + heightSlash;
|
||||
var x1 = (y1 - b) / tg,
|
||||
x2 = (y2 - b) / tg;
|
||||
var xx1 = X + x1,
|
||||
xx2 = X + x2;
|
||||
var yy1 = Y + y1,
|
||||
yy2 = Y + y2;
|
||||
}
|
||||
pGraphics.SetFont(mgCtrPrp);
|
||||
pGraphics.p_width(penW * 1000);
|
||||
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
|
||||
pGraphics._s();
|
||||
pGraphics._m(xx1, yy1);
|
||||
pGraphics._l(xx2, yy2);
|
||||
pGraphics.ds();
|
||||
CFraction.superclass.draw.call(this, x, y, pGraphics, PDSE);
|
||||
};
|
||||
CFraction.prototype.drawLinearFraction = function (x, y, pGraphics, PDSE) {
|
||||
var shift = 0.1 * this.dW;
|
||||
var X = this.pos.x + x + this.GapLeft,
|
||||
Y = this.pos.y + y;
|
||||
var x1 = X + this.elements[0][0].size.width + this.dW - shift,
|
||||
y1 = Y,
|
||||
x2 = X + this.elements[0][0].size.width + shift,
|
||||
y2 = Y + this.size.height;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var penW = mgCtrPrp.FontSize / 12.5 * g_dKoef_pix_to_mm;
|
||||
pGraphics.SetFont(mgCtrPrp);
|
||||
pGraphics.p_width(penW * 1000);
|
||||
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp());
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics.ds();
|
||||
CFraction.superclass.draw.call(this, x, y, pGraphics, PDSE);
|
||||
};
|
||||
CFraction.prototype.getNumerator = function () {
|
||||
var numerator;
|
||||
if (this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) {
|
||||
numerator = this.elements[0][0].getElement();
|
||||
} else {
|
||||
numerator = this.elements[0][0];
|
||||
}
|
||||
return numerator;
|
||||
};
|
||||
CFraction.prototype.getDenominator = function () {
|
||||
var denominator;
|
||||
if (this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) {
|
||||
denominator = this.elements[1][0].getElement();
|
||||
} else {
|
||||
denominator = this.elements[0][1];
|
||||
}
|
||||
return denominator;
|
||||
};
|
||||
CFraction.prototype.getNumeratorMathContent = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CFraction.prototype.getDenominatorMathContent = function () {
|
||||
return this.Content[1];
|
||||
};
|
||||
CFraction.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.Parent = Parent;
|
||||
this.ParaMath = ParaMath;
|
||||
var ArgSzNumDen = ArgSize.Copy();
|
||||
if (RPI.bInline == true && (this.Pr.type === BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)) {
|
||||
ArgSzNumDen.decrease();
|
||||
this.ArgSize.SetValue(-1);
|
||||
} else {
|
||||
if (RPI.bDecreasedComp == true) {
|
||||
this.ArgSize.SetValue(-1);
|
||||
} else {
|
||||
this.ArgSize.SetValue(0);
|
||||
}
|
||||
}
|
||||
this.RecalcInfo.bCtrPrp = true;
|
||||
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
|
||||
this.ApplyProperties(RPI);
|
||||
var NewRPI = RPI.Copy();
|
||||
if (this.Pr.type !== LINEAR_FRACTION) {
|
||||
NewRPI.bDecreasedComp = true;
|
||||
}
|
||||
if (this.bInside == false) {
|
||||
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
|
||||
}
|
||||
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
|
||||
this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
|
||||
};
|
||||
CFraction.prototype.recalculateSize = function (oMeasure) {
|
||||
if (this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) {
|
||||
this.recalculateBarFraction(oMeasure);
|
||||
} else {
|
||||
if (this.Pr.type == SKEWED_FRACTION) {
|
||||
this.recalculateSkewed(oMeasure);
|
||||
} else {
|
||||
if (this.Pr.type == LINEAR_FRACTION) {
|
||||
this.recalculateLinear(oMeasure);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CFraction.prototype.recalculateBarFraction = function (oMeasure) {
|
||||
var num = this.elements[0][0].size,
|
||||
den = this.elements[1][0].size;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var width = num.width > den.width ? num.width : den.width;
|
||||
var height = num.height + den.height;
|
||||
var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CFraction.prototype.recalculateSkewed = function (oMeasure) {
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
this.dW = 5.011235894097222 * mgCtrPrp.FontSize / 36;
|
||||
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
|
||||
var height = this.elements[0][0].size.height + this.elements[0][1].size.height;
|
||||
var ascent = this.elements[0][0].size.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CFraction.prototype.recalculateLinear = function () {
|
||||
var AscentFirst = this.elements[0][0].size.ascent,
|
||||
DescentFirst = this.elements[0][0].size.height - this.elements[0][0].size.ascent,
|
||||
AscentSecond = this.elements[0][1].size.ascent,
|
||||
DescentSecond = this.elements[0][1].size.height - this.elements[0][1].size.ascent;
|
||||
var H = AscentFirst + DescentSecond;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var gap = 5.011235894097222 * mgCtrPrp.FontSize / 36;
|
||||
var H3 = gap * 4.942252165543792,
|
||||
H4 = gap * 7.913378248315688,
|
||||
H5 = gap * 9.884504331087584;
|
||||
if (H < H3) {
|
||||
this.dW = gap;
|
||||
} else {
|
||||
if (H < H4) {
|
||||
this.dW = 2 * gap;
|
||||
} else {
|
||||
if (H < H5) {
|
||||
this.dW = 2.8 * gap;
|
||||
} else {
|
||||
this.dW = 3.4 * gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
var ascent = AscentFirst > AscentSecond ? AscentFirst : AscentSecond;
|
||||
var descent = DescentFirst > DescentSecond ? DescentFirst : DescentSecond;
|
||||
var height = ascent + descent;
|
||||
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
height: height,
|
||||
width: width,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CFraction.prototype.setPosition = function (pos, PosInfo) {
|
||||
if (this.Pr.type == SKEWED_FRACTION) {
|
||||
this.pos.x = pos.x;
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
var X = this.pos.x + this.GapLeft,
|
||||
Y = this.pos.y;
|
||||
var PosNum = new CMathPosition();
|
||||
PosNum.x = X;
|
||||
PosNum.y = Y;
|
||||
var PosDen = new CMathPosition();
|
||||
PosDen.x = X + this.elements[0][0].size.width + this.dW;
|
||||
PosDen.y = Y + this.elements[0][0].size.height;
|
||||
this.elements[0][0].setPosition(PosNum, PosInfo);
|
||||
this.elements[0][1].setPosition(PosDen, PosInfo);
|
||||
} else {
|
||||
CFraction.superclass.setPosition.call(this, pos, PosInfo);
|
||||
}
|
||||
};
|
||||
CFraction.prototype.fillContent = function () {
|
||||
this.Numerator = new CNumerator(this.Content[0]);
|
||||
this.Denominator = new CDenominator(this.Content[1]);
|
||||
if (this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) {
|
||||
this.setDimension(2, 1);
|
||||
if (this.Pr.type == NO_BAR_FRACTION) {
|
||||
this.bHideBar = true;
|
||||
}
|
||||
this.elements[0][0] = this.Numerator;
|
||||
this.elements[1][0] = this.Denominator;
|
||||
} else {
|
||||
if (this.Pr.type == SKEWED_FRACTION) {
|
||||
this.setDimension(1, 2);
|
||||
this.elements[0][0] = this.Numerator.getElement();
|
||||
this.elements[0][1] = this.Denominator.getElement();
|
||||
} else {
|
||||
if (this.Pr.type == LINEAR_FRACTION) {
|
||||
this.setDimension(1, 2);
|
||||
this.elements[0][0] = this.Numerator.getElement();
|
||||
this.elements[0][1] = this.Denominator.getElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CFraction.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Fraction;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
function CFractionBase(bInside, MathContent) {
|
||||
CFractionBase.superclass.constructor.call(this, bInside);
|
||||
this.gap = 0;
|
||||
this.init(MathContent);
|
||||
}
|
||||
Asc.extendClass(CFractionBase, CMathBase);
|
||||
CFractionBase.prototype.init = function (MathContent) {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = MathContent;
|
||||
};
|
||||
CFractionBase.prototype.getElement = function () {
|
||||
return this.elements[0][0];
|
||||
};
|
||||
CFractionBase.prototype.setElement = function (Element) {
|
||||
this.elements[0][0] = Element;
|
||||
};
|
||||
CFractionBase.prototype.getPropsForWrite = function () {
|
||||
return {};
|
||||
};
|
||||
CFractionBase.prototype.Get_Id = function () {
|
||||
return this.elements[0][0].Get_Id();
|
||||
};
|
||||
function CNumerator(MathContent) {
|
||||
CNumerator.superclass.constructor.call(this, true, MathContent);
|
||||
}
|
||||
Asc.extendClass(CNumerator, CFractionBase);
|
||||
CNumerator.prototype.recalculateSize = function () {
|
||||
var arg = this.elements[0][0].size;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var Descent = arg.height - arg.ascent;
|
||||
g_oTextMeasurer.SetFont(mgCtrPrp);
|
||||
var Height = g_oTextMeasurer.GetHeight();
|
||||
var gapNum, minGap;
|
||||
if (this.Parent.kind == MATH_LIMIT || this.Parent.kind == MATH_GROUP_CHARACTER) {
|
||||
gapNum = Height / 4.14;
|
||||
minGap = Height / 13.8;
|
||||
var delta = gapNum - Descent;
|
||||
this.gap = delta > minGap ? delta : minGap;
|
||||
} else {
|
||||
gapNum = Height / 3.05;
|
||||
minGap = Height / 9.77;
|
||||
var delta = gapNum - Descent;
|
||||
this.gap = delta > minGap ? delta : minGap;
|
||||
}
|
||||
var width = arg.width;
|
||||
var height = arg.height + this.gap;
|
||||
var ascent = arg.ascent;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CNumerator.prototype.setPosition = function (pos, PosInfo) {
|
||||
this.elements[0][0].setPosition(pos, PosInfo);
|
||||
};
|
||||
function CDenominator(MathContent) {
|
||||
CDenominator.superclass.constructor.call(this, true, MathContent);
|
||||
}
|
||||
Asc.extendClass(CDenominator, CFractionBase);
|
||||
CDenominator.prototype.recalculateSize = function () {
|
||||
var arg = this.elements[0][0].size;
|
||||
var mgCtrPrp = this.Get_TxtPrControlLetter();
|
||||
var Ascent = arg.ascent - 4.938888888888888 * mgCtrPrp.FontSize / 36;
|
||||
g_oTextMeasurer.SetFont(mgCtrPrp);
|
||||
var Height = g_oTextMeasurer.GetHeight();
|
||||
var gapDen, minGap;
|
||||
if (this.Parent.kind == MATH_LIMIT || this.Parent.kind == MATH_GROUP_CHARACTER) {
|
||||
gapDen = Height / 2.6;
|
||||
minGap = Height / 10;
|
||||
} else {
|
||||
gapDen = Height / 2.03;
|
||||
minGap = Height / 6.1;
|
||||
}
|
||||
var delta = gapDen - Ascent;
|
||||
this.gap = delta > minGap ? delta : minGap;
|
||||
var width = arg.width;
|
||||
var height = arg.height + this.gap;
|
||||
var ascent = arg.ascent + this.gap;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CDenominator.prototype.setPosition = function (pos, PosInfo) {
|
||||
var NewPos = new CMathPosition();
|
||||
NewPos.x = pos.x;
|
||||
NewPos.y = pos.y + this.gap;
|
||||
this.elements[0][0].setPosition(NewPos, PosInfo);
|
||||
};
|
||||
215
OfficeWeb/sdk/Word/Math/limit.js
Normal file
215
OfficeWeb/sdk/Word/Math/limit.js
Normal file
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CMathLimitPr() {
|
||||
this.type = LIMIT_LOW;
|
||||
}
|
||||
CMathLimitPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.type && null !== Obj.type) {
|
||||
this.type = Obj.type;
|
||||
}
|
||||
};
|
||||
CMathLimitPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathLimitPr();
|
||||
NewPr.type = this.type;
|
||||
return NewPr;
|
||||
};
|
||||
CMathLimitPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.type);
|
||||
};
|
||||
CMathLimitPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.type = Reader.GetLong();
|
||||
};
|
||||
function CLimitPrimary(bInside, Type, FName, Iterator) {
|
||||
CLimitPrimary.superclass.constructor.call(this, bInside);
|
||||
this.Type = Type;
|
||||
this.FName = null;
|
||||
this.Iterator = null;
|
||||
this.init(FName, Iterator);
|
||||
}
|
||||
Asc.extendClass(CLimitPrimary, CMathBase);
|
||||
CLimitPrimary.prototype.init = function (FName, Iterator) {
|
||||
this.setDimension(2, 1);
|
||||
if (this.Type == LIMIT_LOW) {
|
||||
this.FName = FName;
|
||||
this.Iterator = new CDenominator(Iterator);
|
||||
this.elements[0][0] = this.FName;
|
||||
this.elements[1][0] = this.Iterator;
|
||||
} else {
|
||||
this.Iterator = Iterator;
|
||||
this.FName = FName;
|
||||
this.elements[0][0] = this.Iterator;
|
||||
this.elements[1][0] = this.FName;
|
||||
}
|
||||
};
|
||||
CLimitPrimary.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.Parent = Parent;
|
||||
this.ParaMath = ParaMath;
|
||||
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
|
||||
if (this.bInside == false) {
|
||||
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
|
||||
}
|
||||
this.FName.PreRecalc(this, ParaMath, ArgSize, RPI);
|
||||
var ArgSzIter = ArgSize.Copy();
|
||||
ArgSzIter.decrease();
|
||||
var NewRPI = RPI.Copy();
|
||||
NewRPI.bDecreasedComp = true;
|
||||
this.Iterator.ArgSize.decrease();
|
||||
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI);
|
||||
};
|
||||
CLimitPrimary.prototype.Resize = function (oMeasure, RPI) {
|
||||
if (this.Type == LIMIT_LOW) {
|
||||
this.dH = 0;
|
||||
} else {
|
||||
this.dH = 0.06 * this.Get_TxtPrControlLetter().FontSize;
|
||||
}
|
||||
this.FName.Resize(oMeasure, RPI);
|
||||
this.Iterator.Resize(oMeasure, RPI);
|
||||
var SizeFName = this.FName.size,
|
||||
SizeIter = this.Iterator.size;
|
||||
var width = SizeFName.width > SizeIter.width ? SizeFName.width : SizeIter.width,
|
||||
height = SizeFName.height + SizeIter.height,
|
||||
ascent;
|
||||
if (this.Type == LIMIT_LOW) {
|
||||
ascent = SizeFName.ascent;
|
||||
} else {
|
||||
if (this.Type == LIMIT_UP) {
|
||||
ascent = SizeIter.height + this.dH + SizeFName.ascent;
|
||||
}
|
||||
}
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
function CLimit(props) {
|
||||
CLimit.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathLimitPr();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CLimit, CMathBase);
|
||||
CLimit.prototype.ClassType = historyitem_type_lim;
|
||||
CLimit.prototype.kind = MATH_LIMIT;
|
||||
CLimit.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(2);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CLimit.prototype.fillContent = function () {};
|
||||
CLimit.prototype.getFName = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CLimit.prototype.getIterator = function () {
|
||||
return this.Content[1];
|
||||
};
|
||||
CLimit.prototype.ApplyProperties = function (RPI) {
|
||||
if (this.RecalcInfo.bProps == true || RPI.bChangeInline == true) {
|
||||
this.setDimension(1, 1);
|
||||
if (RPI.bInline == true && RPI.bMathFunc == true) {
|
||||
var props;
|
||||
if (this.Pr.type == LIMIT_LOW) {
|
||||
props = {
|
||||
type: DEGREE_SUBSCRIPT,
|
||||
ctrPrp: this.CtrPrp
|
||||
};
|
||||
} else {
|
||||
props = {
|
||||
type: DEGREE_SUPERSCRIPT,
|
||||
ctrPrp: this.CtrPrp
|
||||
};
|
||||
}
|
||||
this.elements[0][0] = new CDegreeBase(props, true);
|
||||
this.elements[0][0].setBase(this.getFName());
|
||||
this.elements[0][0].setIterator(this.getIterator());
|
||||
this.elements[0][0].fillContent();
|
||||
} else {
|
||||
this.elements[0][0] = new CLimitPrimary(true, this.Pr.type, this.getFName(), this.getIterator());
|
||||
}
|
||||
this.RecalcInfo.bProps = false;
|
||||
}
|
||||
};
|
||||
CLimit.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Limit;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
function CMathFunc(props) {
|
||||
CMathFunc.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathBasePr();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CMathFunc, CMathBase);
|
||||
CMathFunc.prototype.ClassType = historyitem_type_mathFunc;
|
||||
CMathFunc.prototype.kind = MATH_FUNCTION;
|
||||
CMathFunc.prototype.init = function (props) {
|
||||
this.Fill_LogicalContent(2);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CMathFunc.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
var NewRPI = RPI.Copy();
|
||||
NewRPI.bMathFunc = true;
|
||||
CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
|
||||
};
|
||||
CMathFunc.prototype.GetLastElement = function () {
|
||||
return this.Content[1].GetFirstElement();
|
||||
};
|
||||
CMathFunc.prototype.GetFirstElement = function () {
|
||||
return this.Content[0].GetFirstElement();
|
||||
};
|
||||
CMathFunc.prototype.setDistance = function () {
|
||||
this.dW = this.Get_TxtPrControlLetter().FontSize / 6 * g_dKoef_pt_to_mm;
|
||||
};
|
||||
CMathFunc.prototype.getFName = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CMathFunc.prototype.getArgument = function () {
|
||||
return this.Content[1];
|
||||
};
|
||||
CMathFunc.prototype.fillContent = function () {
|
||||
this.setDimension(1, 2);
|
||||
this.elements[0][0] = this.getFName();
|
||||
this.elements[0][1] = this.getArgument();
|
||||
};
|
||||
CMathFunc.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Function;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
4286
OfficeWeb/sdk/Word/Math/mathContent.js
Normal file
4286
OfficeWeb/sdk/Word/Math/mathContent.js
Normal file
File diff suppressed because one or more lines are too long
1231
OfficeWeb/sdk/Word/Math/mathText.js
Normal file
1231
OfficeWeb/sdk/Word/Math/mathText.js
Normal file
File diff suppressed because it is too large
Load Diff
187
OfficeWeb/sdk/Word/Math/mathTypes.js
Normal file
187
OfficeWeb/sdk/Word/Math/mathTypes.js
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
var MATH_FRACTION = 0;
|
||||
var MATH_DEGREE = 1;
|
||||
var MATH_DEGREESubSup = 2;
|
||||
var MATH_RADICAL = 3;
|
||||
var MATH_NARY = 4;
|
||||
var MATH_DELIMITER = 5;
|
||||
var MATH_GROUP_CHARACTER = 6;
|
||||
var MATH_FUNCTION = 7;
|
||||
var MATH_ACCENT = 8;
|
||||
var MATH_BORDER_BOX = 9;
|
||||
var MATH_LIMIT = 10;
|
||||
var MATH_MATRIX = 11;
|
||||
var MATH_BOX = 12;
|
||||
var MATH_EQ_ARRAY = 13;
|
||||
var MATH_BAR = 14;
|
||||
var MATH_PHANTOM = 15;
|
||||
var MATH_RUN = 16;
|
||||
var BAR_FRACTION = 0;
|
||||
var SKEWED_FRACTION = 1;
|
||||
var LINEAR_FRACTION = 2;
|
||||
var NO_BAR_FRACTION = 3;
|
||||
var DEGREE_SUPERSCRIPT = 1;
|
||||
var DEGREE_SUBSCRIPT = -1;
|
||||
var DEGREE_SubSup = 1;
|
||||
var DEGREE_PreSubSup = -1;
|
||||
var SQUARE_RADICAL = 0;
|
||||
var DEGREE_RADICAL = 1;
|
||||
var NARY_INTEGRAL = 0;
|
||||
var NARY_DOUBLE_INTEGRAL = 1;
|
||||
var NARY_TRIPLE_INTEGRAL = 2;
|
||||
var NARY_CONTOUR_INTEGRAL = 3;
|
||||
var NARY_SURFACE_INTEGRAL = 4;
|
||||
var NARY_VOLUME_INTEGRAL = 5;
|
||||
var NARY_SIGMA = 6;
|
||||
var NARY_PRODUCT = 7;
|
||||
var NARY_COPRODUCT = 8;
|
||||
var NARY_UNION = 9;
|
||||
var NARY_INTERSECTION = 10;
|
||||
var NARY_LOGICAL_OR = 11;
|
||||
var NARY_LOGICAL_AND = 12;
|
||||
var NARY_TEXT_OPER = 13;
|
||||
var NARY_UndOvr = 0;
|
||||
var NARY_SubSup = 1;
|
||||
var BOX_DIFF = 0;
|
||||
var BOX_OpEmu = 1;
|
||||
var BOX_ALIGN = 2;
|
||||
var BOX_BREAK = 3;
|
||||
var BOX_NOBREAK = 4;
|
||||
var OPERATOR_EMPTY = -1;
|
||||
var OPERATOR_TEXT = 0;
|
||||
var PARENTHESIS_LEFT = 1;
|
||||
var PARENTHESIS_RIGHT = 2;
|
||||
var BRACKET_CURLY_LEFT = 3;
|
||||
var BRACKET_CURLY_RIGHT = 4;
|
||||
var BRACKET_SQUARE_LEFT = 5;
|
||||
var BRACKET_SQUARE_RIGHT = 6;
|
||||
var BRACKET_ANGLE_LEFT = 7;
|
||||
var BRACKET_ANGLE_RIGHT = 8;
|
||||
var HALF_SQUARE_LEFT = 9;
|
||||
var HALF_SQUARE_RIGHT = 10;
|
||||
var HALF_SQUARE_LEFT_UPPER = 11;
|
||||
var HALF_SQUARE_RIGHT_UPPER = 12;
|
||||
var DELIMITER_LINE = 13;
|
||||
var DELIMITER_DOUBLE_LINE = 14;
|
||||
var WHITE_SQUARE_LEFT = 15;
|
||||
var WHITE_SQUARE_RIGHT = 16;
|
||||
var BRACKET_CURLY_TOP = 17;
|
||||
var BRACKET_CURLY_BOTTOM = 18;
|
||||
var ARROW_LEFT = 19;
|
||||
var ARROW_RIGHT = 20;
|
||||
var ARROW_LR = 21;
|
||||
var DOUBLE_LEFT_ARROW = 22;
|
||||
var DOUBLE_RIGHT_ARROW = 23;
|
||||
var DOUBLE_ARROW_LR = 24;
|
||||
var ACCENT_ARROW_LEFT = 26;
|
||||
var ACCENT_ARROW_RIGHT = 27;
|
||||
var ACCENT_ARROW_LR = 28;
|
||||
var ACCENT_HALF_ARROW_LEFT = 29;
|
||||
var ACCENT_HALF_ARROW_RIGHT = 30;
|
||||
var PARENTHESIS_TOP = 31;
|
||||
var PARENTHESIS_BOTTOM = 32;
|
||||
var BRACKET_SQUARE_TOP = 33;
|
||||
var ACCENT_ONE_DOT = 31;
|
||||
var ACCENT_TWO_DOTS = 32;
|
||||
var ACCENT_THREE_DOTS = 33;
|
||||
var ACCENT_GRAVE = 34;
|
||||
var ACCENT_ACUTE = 35;
|
||||
var ACCENT_CIRCUMFLEX = 36;
|
||||
var ACCENT_COMB_CARON = 37;
|
||||
var ACCENT_LINE = 38;
|
||||
var ACCENT_DOUBLE_LINE = 39;
|
||||
var SINGLE_LINE = 40;
|
||||
var DOUBLE_LINE = 41;
|
||||
var ACCENT_TILDE = 42;
|
||||
var ACCENT_BREVE = 43;
|
||||
var ACCENT_INVERT_BREVE = 44;
|
||||
var ACCENT_SIGN = 45;
|
||||
var ACCENT_TEXT = 46;
|
||||
var TXT_ROMAN = 0;
|
||||
var TXT_SCRIPT = 1;
|
||||
var TXT_FRAKTUR = 2;
|
||||
var TXT_DOUBLE_STRUCK = 3;
|
||||
var TXT_SANS_SERIF = 4;
|
||||
var TXT_MONOSPACE = 5;
|
||||
var OPER_DELIMITER = 0;
|
||||
var OPER_SEPARATOR = 1;
|
||||
var OPER_GROUP_CHAR = 2;
|
||||
var OPER_ACCENT = 3;
|
||||
var OPER_BAR = 4;
|
||||
var TURN_0 = 0;
|
||||
var TURN_180 = 1;
|
||||
var TURN_MIRROR_0 = 2;
|
||||
var TURN_MIRROR_180 = 3;
|
||||
var DELIMITER_SHAPE_MATH = 0;
|
||||
var DELIMITER_SHAPE_CENTERED = 1;
|
||||
var LIMIT_LOW = 0;
|
||||
var LIMIT_UP = 1;
|
||||
var MCJC_CENTER = 0;
|
||||
var MCJC_LEFT = 1;
|
||||
var MCJC_RIGHT = 2;
|
||||
var MCJC_INSIDE = 0;
|
||||
var MCJC_OUTSIDE = 0;
|
||||
var BASEJC_CENTER = 0;
|
||||
var BASEJC_TOP = 1;
|
||||
var BASEJC_BOTTOM = 2;
|
||||
var BASEJC_INLINE = 0;
|
||||
var BASEJC_INSIDE = 0;
|
||||
var BASEJC_OUTSIDE = 0;
|
||||
var JC_CENTER = 0;
|
||||
var JC_CENTERGROUP = 1;
|
||||
var JC_LEFT = 2;
|
||||
var JC_RIGHT = 3;
|
||||
var MATH_TEXT = 0;
|
||||
var MATH_RUN_PRP = 1;
|
||||
var MATH_COMP = 2;
|
||||
var MATH_EMPTY = 3;
|
||||
var MATH_PLACEHOLDER = 4;
|
||||
var MATH_PARA_RUN = 5;
|
||||
var LOCATION_TOP = 0;
|
||||
var LOCATION_BOT = 1;
|
||||
var LOCATION_LEFT = 2;
|
||||
var LOCATION_RIGHT = 3;
|
||||
var LOCATION_SEP = 4;
|
||||
var VJUST_TOP = 0;
|
||||
var VJUST_BOT = 1;
|
||||
var BREAK_BEFORE = 0;
|
||||
var BREAK_AFTER = 1;
|
||||
var BREAK_REPEAT = 2;
|
||||
var BREAK_MIN_MIN = 0;
|
||||
var BREAK_PLUS_MIN = 1;
|
||||
var BREAK_MIN_PLUS = 2;
|
||||
var STY_BOLD = 0;
|
||||
var STY_BI = 1;
|
||||
var STY_ITALIC = 2;
|
||||
var STY_PLAIN = 3;
|
||||
671
OfficeWeb/sdk/Word/Math/matrix.js
Normal file
671
OfficeWeb/sdk/Word/Math/matrix.js
Normal file
@@ -0,0 +1,671 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
var MATH_MC_JC = MCJC_CENTER;
|
||||
function CMathMatrixColumnPr() {
|
||||
this.count = 1;
|
||||
this.mcJc = MCJC_CENTER;
|
||||
}
|
||||
CMathMatrixColumnPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.count && null !== Obj.count) {
|
||||
this.count = Obj.count;
|
||||
} else {
|
||||
this.count = 1;
|
||||
}
|
||||
if (MCJC_LEFT === Obj.mcJc || MCJC_RIGHT === Obj.mcJc || MCJC_CENTER === Obj.mcJc) {
|
||||
this.mcJc = Obj.mcJc;
|
||||
} else {
|
||||
this.mcJc = MCJC_CENTER;
|
||||
}
|
||||
};
|
||||
CMathMatrixColumnPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathMatrixColumnPr();
|
||||
NewPr.count = this.count;
|
||||
NewPr.mcJc = this.mcJc;
|
||||
return NewPr;
|
||||
};
|
||||
CMathMatrixColumnPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.count);
|
||||
Writer.WriteLong(this.mcJc);
|
||||
};
|
||||
CMathMatrixColumnPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.count = Reader.GetLong();
|
||||
this.mcJc = Reader.GetLong();
|
||||
};
|
||||
function CMathMatrixPr() {
|
||||
this.row = 1;
|
||||
this.cGp = 0;
|
||||
this.cGpRule = 0;
|
||||
this.cSp = 0;
|
||||
this.rSp = 0;
|
||||
this.rSpRule = 0;
|
||||
this.mcs = [];
|
||||
this.baseJc = BASEJC_CENTER;
|
||||
this.plcHide = false;
|
||||
}
|
||||
CMathMatrixPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.row && null !== Obj.row) {
|
||||
this.row = Obj.row;
|
||||
}
|
||||
if (undefined !== Obj.cGp && null !== Obj.cGp) {
|
||||
this.cGp = Obj.cGp;
|
||||
}
|
||||
if (undefined !== Obj.cGpRule && null !== Obj.cGpRule) {
|
||||
this.cGpRule = Obj.cGpRule;
|
||||
}
|
||||
if (undefined !== Obj.cSp && null !== Obj.cSp) {
|
||||
this.cSp = Obj.cSp;
|
||||
}
|
||||
if (undefined !== Obj.rSpRule && null !== Obj.rSpRule) {
|
||||
this.rSpRule = Obj.rSpRule;
|
||||
}
|
||||
if (undefined !== Obj.rSp && null !== Obj.rSp) {
|
||||
this.rSp = Obj.rSp;
|
||||
}
|
||||
if (true === Obj.plcHide || 1 === Obj.plcHide) {
|
||||
this.plcHide = true;
|
||||
} else {
|
||||
this.plcHide = false;
|
||||
}
|
||||
if (BASEJC_CENTER === Obj.baseJc || BASEJC_TOP === Obj.baseJc || BASEJC_BOTTOM === Obj.baseJc) {
|
||||
this.baseJc = Obj.baseJc;
|
||||
}
|
||||
var nColumnsCount = 0;
|
||||
if (undefined !== Obj.mcs.length) {
|
||||
var nMcsCount = Obj.mcs.length;
|
||||
if (0 !== nMcsCount) {
|
||||
this.mcs.length = nMcsCount;
|
||||
for (var nMcsIndex = 0; nMcsIndex < nMcsCount; nMcsIndex++) {
|
||||
this.mcs[nMcsIndex] = new CMathMatrixColumnPr();
|
||||
this.mcs[nMcsIndex].Set_FromObject(Obj.mcs[nMcsIndex]);
|
||||
nColumnsCount += this.mcs[nMcsIndex].count;
|
||||
}
|
||||
} else {
|
||||
if (undefined !== Obj.column) {
|
||||
nColumnsCount = Obj.column;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nColumnsCount;
|
||||
};
|
||||
CMathMatrixPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathMatrixPr();
|
||||
NewPr.row = this.row;
|
||||
NewPr.cGp = this.cGp;
|
||||
NewPr.cGpRule = this.cGpRule;
|
||||
NewPr.cSp = this.cSp;
|
||||
NewPr.rSp = this.rSp;
|
||||
NewPr.rSpRule = this.rSpRule;
|
||||
NewPr.baseJc = this.baseJc;
|
||||
NewPr.plcHide = this.plcHide;
|
||||
var nCount = this.mcs.length;
|
||||
for (var nMcsIndex = 0; nMcsIndex < nCount; nMcsIndex++) {
|
||||
NewPr.mcs[nMcsIndex] = this.mcs[nMcsIndex].Copy();
|
||||
}
|
||||
return NewPr;
|
||||
};
|
||||
CMathMatrixPr.prototype.Get_ColumnsCount = function () {
|
||||
var nColumnsCount = 0;
|
||||
for (var nMcsIndex = 0, nMcsCount = this.mcs.length; nMcsIndex < nMcsCount; nMcsIndex++) {
|
||||
nColumnsCount += this.mcs[nMcsIndex].count;
|
||||
}
|
||||
return nColumnsCount;
|
||||
};
|
||||
CMathMatrixPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.row);
|
||||
Writer.WriteLong(this.cGp);
|
||||
Writer.WriteLong(this.cGpRule);
|
||||
Writer.WriteLong(this.rSp);
|
||||
Writer.WriteLong(this.rSpRule);
|
||||
Writer.WriteLong(this.baseJc);
|
||||
Writer.WriteBool(this.plcHide);
|
||||
var nMcsCount = this.mcs.length;
|
||||
Writer.WriteLong(nMcsCount);
|
||||
for (var nIndex = 0; nIndex < nMcsCount; nIndex++) {
|
||||
this.mcs[nIndex].Write_ToBinary(Writer);
|
||||
}
|
||||
};
|
||||
CMathMatrixPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.row = Reader.GetLong();
|
||||
this.cGp = Reader.GetLong();
|
||||
this.cGpRule = Reader.GetLong();
|
||||
this.rSp = Reader.GetLong();
|
||||
this.rSpRule = Reader.GetLong();
|
||||
this.baseJc = Reader.GetLong();
|
||||
this.plcHide = Reader.GetBool();
|
||||
var nMcsCount = Reader.GetLong();
|
||||
this.mcs.length = nMcsCount;
|
||||
for (var nIndex = 0; nIndex < nMcsCount; nIndex++) {
|
||||
this.mcs[nIndex] = new CMathMatrixColumnPr();
|
||||
this.mcs[nIndex].Read_FromBinary(Reader);
|
||||
}
|
||||
};
|
||||
function CMatrixBase() {
|
||||
CMatrixBase.superclass.constructor.call(this);
|
||||
}
|
||||
Asc.extendClass(CMatrixBase, CMathBase);
|
||||
CMatrixBase.prototype.recalculateSize = function (oMeasure, RPI) {
|
||||
if (this.RecalcInfo.bProps) {
|
||||
if (this.nRow > 1) {
|
||||
this.setRuleGap(this.spaceRow, this.Pr.rSpRule, this.Pr.rSp);
|
||||
}
|
||||
if (this.nCol > 1) {
|
||||
this.setRuleGap(this.spaceColumn, this.Pr.cGpRule, this.Pr.cGp, this.Pr.cSp);
|
||||
}
|
||||
if (this.kind == MATH_MATRIX) {
|
||||
if (this.Pr.mcs !== undefined) {
|
||||
var lng = this.Pr.mcs.length;
|
||||
var col = 0;
|
||||
this.alignment.wdt.length = 0;
|
||||
for (var j = 0; j < lng; j++) {
|
||||
var mc = this.Pr.mcs[j],
|
||||
count = mc.count;
|
||||
for (var i = 0; i < count; i++) {
|
||||
this.alignment.wdt[col] = mc.mcJc;
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.Pr.plcHide) {
|
||||
this.hidePlaceholder(true);
|
||||
}
|
||||
}
|
||||
this.RecalcInfo.bProps = false;
|
||||
}
|
||||
var FontSize = this.Get_TxtPrControlLetter().FontSize;
|
||||
var metrics = this.getMetrics();
|
||||
if (this.nCol > 1) {
|
||||
var gapsCol = this.getLineGap(this.spaceColumn, FontSize);
|
||||
for (var i = 0; i < this.nCol - 1; i++) {
|
||||
this.gaps.column[i] = gapsCol;
|
||||
}
|
||||
}
|
||||
this.gaps.column[this.nCol - 1] = 0;
|
||||
if (this.nRow > 1) {
|
||||
var intervalRow = this.getRowSpace(this.spaceRow, FontSize);
|
||||
var divCenter = 0;
|
||||
var plH = 0.2743827160493827 * FontSize;
|
||||
var minGp = this.spaceRow.minGap * FontSize * g_dKoef_pt_to_mm;
|
||||
minGp -= plH;
|
||||
for (var j = 0; j < this.nRow - 1; j++) {
|
||||
divCenter = intervalRow - (metrics.descents[j] + metrics.ascents[j + 1]);
|
||||
this.gaps.row[j] = minGp > divCenter ? minGp : divCenter;
|
||||
}
|
||||
}
|
||||
this.gaps.row[this.nRow - 1] = 0;
|
||||
var height = 0,
|
||||
width = 0;
|
||||
for (var i = 0; i < this.nCol; i++) {
|
||||
width += this.gaps.column[i] + metrics.widths[i];
|
||||
}
|
||||
for (var j = 0; j < this.nRow; j++) {
|
||||
height += this.gaps.row[j] + metrics.ascents[j] + metrics.descents[j];
|
||||
}
|
||||
var ascent = 0;
|
||||
if (this.Pr.baseJc == BASEJC_TOP) {
|
||||
for (var j = 0; j < this.nCol; j++) {
|
||||
ascent = this.elements[0][j].size.ascent > ascent ? this.elements[0][j].size.ascent : ascent;
|
||||
}
|
||||
} else {
|
||||
if (this.Pr.baseJc == BASEJC_BOTTOM) {
|
||||
var descent = 0,
|
||||
currDsc;
|
||||
for (var j = 0; j < this.nCol; j++) {
|
||||
currDsc = this.elements[this.nRow - 1][j].size.height - this.elements[this.nRow - 1][j].size.ascent;
|
||||
descent = currDsc > descent ? currDsc : descent;
|
||||
ascent = height - descent;
|
||||
}
|
||||
} else {
|
||||
ascent = this.getAscent(oMeasure, height);
|
||||
}
|
||||
}
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
};
|
||||
CMatrixBase.prototype.baseJustification = function (type) {
|
||||
this.Pr.baseJc = type;
|
||||
};
|
||||
CMatrixBase.prototype.setDefaultSpace = function () {
|
||||
this.spaceRow = {
|
||||
rule: 0,
|
||||
gap: 0,
|
||||
minGap: 13 / 12
|
||||
};
|
||||
this.spaceColumn = {
|
||||
rule: 0,
|
||||
gap: 0,
|
||||
minGap: 0
|
||||
};
|
||||
this.gaps = {
|
||||
row: [],
|
||||
column: []
|
||||
};
|
||||
};
|
||||
CMatrixBase.prototype.setRuleGap = function (oSpace, rule, gap, minGap) {
|
||||
var bInt = rule == rule - 0 && rule == rule ^ 0,
|
||||
bRule = rule >= 0 && rule <= 4;
|
||||
if (bInt && bRule) {
|
||||
oSpace.rule = rule;
|
||||
} else {
|
||||
oSpace.rule = 0;
|
||||
}
|
||||
if (gap == gap - 0 && gap == gap ^ 0) {
|
||||
oSpace.gap = gap;
|
||||
} else {
|
||||
oSpace.gap = 0;
|
||||
}
|
||||
if (minGap == minGap - 0 && minGap == minGap ^ 0) {
|
||||
oSpace.minGap = minGap;
|
||||
}
|
||||
};
|
||||
CMatrixBase.prototype.getLineGap = function (spaceColumn, FontSize) {
|
||||
var spLine;
|
||||
if (spaceColumn.rule == 0) {
|
||||
spLine = 1;
|
||||
} else {
|
||||
if (spaceColumn.rule == 1) {
|
||||
spLine = 1.5;
|
||||
} else {
|
||||
if (spaceColumn.rule == 2) {
|
||||
spLine = 2;
|
||||
} else {
|
||||
if (spaceColumn.rule == 3) {
|
||||
spLine = spaceColumn.gap / 20;
|
||||
} else {
|
||||
if (spaceColumn.rule == 4) {
|
||||
spLine = spaceColumn.gap / 2;
|
||||
} else {
|
||||
spLine = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var lineGap;
|
||||
if (spaceColumn.rule == 3) {
|
||||
lineGap = spLine * g_dKoef_pt_to_mm;
|
||||
} else {
|
||||
lineGap = spLine * FontSize * g_dKoef_pt_to_mm;
|
||||
}
|
||||
var wPlh = 0.3241834852430555 * FontSize;
|
||||
var min = spaceColumn.minGap / 20 * g_dKoef_pt_to_mm - wPlh;
|
||||
lineGap = Math.max(lineGap, min);
|
||||
return lineGap;
|
||||
};
|
||||
CMatrixBase.prototype.getRowSpace = function (spaceRow, FontSize) {
|
||||
var spLine;
|
||||
if (spaceRow.rule == 0) {
|
||||
spLine = 7 / 6;
|
||||
} else {
|
||||
if (spaceRow.rule == 1) {
|
||||
spLine = 7 / 6 * 1.5;
|
||||
} else {
|
||||
if (spaceRow.rule == 2) {
|
||||
spLine = 7 / 6 * 2;
|
||||
} else {
|
||||
if (spaceRow.rule == 3) {
|
||||
spLine = spaceRow.gap / 20;
|
||||
} else {
|
||||
if (spaceRow.rule == 4) {
|
||||
spLine = 7 / 6 * spaceRow.gap / 2;
|
||||
} else {
|
||||
spLine = 7 / 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var lineGap;
|
||||
if (spaceRow.rule == 3) {
|
||||
lineGap = spLine * g_dKoef_pt_to_mm;
|
||||
} else {
|
||||
lineGap = spLine * FontSize * g_dKoef_pt_to_mm;
|
||||
}
|
||||
var min = spaceRow.minGap * FontSize * g_dKoef_pt_to_mm;
|
||||
lineGap = Math.max(lineGap, min);
|
||||
return lineGap;
|
||||
};
|
||||
function CMathMatrix(props) {
|
||||
CMathMatrix.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathMatrixPr();
|
||||
this.spaceRow = null;
|
||||
this.spaceColumn = null;
|
||||
this.gaps = null;
|
||||
this.column = 0;
|
||||
this.setDefaultSpace();
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CMathMatrix, CMatrixBase);
|
||||
CMathMatrix.prototype.ClassType = historyitem_type_matrix;
|
||||
CMathMatrix.prototype.kind = MATH_MATRIX;
|
||||
CMathMatrix.prototype.init = function (props) {
|
||||
this.setProperties(props);
|
||||
this.column = this.Pr.Get_ColumnsCount();
|
||||
var nRowsCount = this.getRowsCount();
|
||||
var nColsCount = this.getColsCount();
|
||||
this.Fill_LogicalContent(nRowsCount * nColsCount);
|
||||
this.fillContent();
|
||||
};
|
||||
CMathMatrix.prototype.setPosition = function (pos, PosInfo) {
|
||||
this.pos.x = pos.x;
|
||||
if (this.bInside === true) {
|
||||
this.pos.y = pos.y;
|
||||
} else {
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
}
|
||||
var maxWH = this.getWidthsHeights();
|
||||
var Widths = maxWH.widths;
|
||||
var Heights = maxWH.heights;
|
||||
var NewPos = new CMathPosition();
|
||||
var h = 0,
|
||||
w = 0;
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
w = 0;
|
||||
for (var j = 0; j < this.nCol; j++) {
|
||||
var al = this.align(i, j);
|
||||
NewPos.x = this.pos.x + this.GapLeft + al.x + w;
|
||||
NewPos.y = this.pos.y + al.y + h;
|
||||
this.elements[i][j].setPosition(NewPos, PosInfo);
|
||||
w += Widths[j] + this.gaps.column[j];
|
||||
}
|
||||
h += Heights[i] + this.gaps.row[i];
|
||||
}
|
||||
};
|
||||
CMathMatrix.prototype.getMetrics = function (RPI) {
|
||||
var Ascents = [];
|
||||
var Descents = [];
|
||||
var Widths = [];
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
Ascents[i] = 0;
|
||||
Descents[i] = 0;
|
||||
for (var j = 0; j < this.nCol; j++) {
|
||||
var size = this.elements[i][j].size;
|
||||
Widths[j] = i > 0 && (Widths[j] > size.width) ? Widths[j] : size.width;
|
||||
Ascents[i] = (Ascents[i] > size.ascent) ? Ascents[i] : size.ascent;
|
||||
Descents[i] = (Descents[i] > size.height - size.ascent) ? Descents[i] : size.height - size.ascent;
|
||||
}
|
||||
}
|
||||
return {
|
||||
ascents: Ascents,
|
||||
descents: Descents,
|
||||
widths: Widths
|
||||
};
|
||||
};
|
||||
CMathMatrix.prototype.setRowGapRule = function (rule, gap) {
|
||||
this.spaceRow.rule = rule;
|
||||
this.spaceRow.gap = gap;
|
||||
};
|
||||
CMathMatrix.prototype.setColumnGapRule = function (rule, gap, minGap) {
|
||||
this.spaceColumn.rule = rule;
|
||||
this.spaceColumn.gap = gap;
|
||||
if (minGap !== null && typeof(minGap) !== "undefined") {
|
||||
this.spaceColumn.minGap = minGap;
|
||||
}
|
||||
};
|
||||
CMathMatrix.prototype.getContentElement = function (nRowIndex, nColIndex) {
|
||||
return this.Content[nRowIndex * this.getColsCount() + nColIndex];
|
||||
};
|
||||
CMathMatrix.prototype.fillContent = function () {
|
||||
this.column = this.Pr.Get_ColumnsCount();
|
||||
var nRowsCount = this.getRowsCount();
|
||||
var nColsCount = this.getColsCount();
|
||||
this.setDimension(nRowsCount, nColsCount);
|
||||
for (var nRowIndex = 0; nRowIndex < nRowsCount; nRowIndex++) {
|
||||
for (var nColIndex = 0; nColIndex < nColsCount; nColIndex++) {
|
||||
this.elements[nRowIndex][nColIndex] = this.getContentElement(nRowIndex, nColIndex);
|
||||
}
|
||||
}
|
||||
};
|
||||
CMathMatrix.prototype.getRowsCount = function () {
|
||||
return this.Pr.row;
|
||||
};
|
||||
CMathMatrix.prototype.getColsCount = function () {
|
||||
return this.column;
|
||||
};
|
||||
CMathMatrix.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Matrix;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
function CMathPoint() {
|
||||
this.even = -1;
|
||||
this.odd = -1;
|
||||
}
|
||||
function CMathEqArrPr() {
|
||||
this.maxDist = 0;
|
||||
this.objDist = 0;
|
||||
this.rSp = 0;
|
||||
this.rSpRule = 0;
|
||||
this.baseJc = BASEJC_CENTER;
|
||||
this.row = 1;
|
||||
}
|
||||
CMathEqArrPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (undefined !== Obj.maxDist && null !== Obj.maxDist) {
|
||||
this.maxDist = Obj.maxDist;
|
||||
}
|
||||
if (undefined !== Obj.objDist && null !== Obj.objDist) {
|
||||
this.objDist = Obj.objDist;
|
||||
}
|
||||
if (undefined !== Obj.rSp && null !== Obj.rSp) {
|
||||
this.rSp = Obj.rSp;
|
||||
}
|
||||
if (undefined !== Obj.rSpRule && null !== Obj.rSpRule) {
|
||||
this.rSpRule = Obj.rSpRule;
|
||||
}
|
||||
if (undefined !== Obj.baseJc && null !== Obj.baseJc) {
|
||||
this.baseJc = Obj.baseJc;
|
||||
}
|
||||
this.row = Obj.row;
|
||||
};
|
||||
CMathEqArrPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathEqArrPr();
|
||||
NewPr.maxDist = this.maxDist;
|
||||
NewPr.objDist = this.objDist;
|
||||
NewPr.rSp = this.rSp;
|
||||
NewPr.rSpRule = this.rSpRule;
|
||||
NewPr.baseJc = this.baseJc;
|
||||
NewPr.row = this.row;
|
||||
return NewPr;
|
||||
};
|
||||
CMathEqArrPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.maxDist);
|
||||
Writer.WriteLong(this.objDist);
|
||||
Writer.WriteLong(this.rSp);
|
||||
Writer.WriteLong(this.rSpRule);
|
||||
Writer.WriteLong(this.baseJc);
|
||||
Writer.WriteLong(this.row);
|
||||
};
|
||||
CMathEqArrPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.maxDist = Reader.GetLong();
|
||||
this.objDist = Reader.GetLong();
|
||||
this.rSp = Reader.GetLong();
|
||||
this.rSpRule = Reader.GetLong();
|
||||
this.baseJc = Reader.GetLong();
|
||||
this.row = Reader.GetLong();
|
||||
};
|
||||
function CEqArray(props) {
|
||||
CEqArray.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Pr = new CMathEqArrPr();
|
||||
this.spaceRow = null;
|
||||
this.spaceColumn = null;
|
||||
this.gaps = null;
|
||||
this.setDefaultSpace();
|
||||
this.WidthsPoints = [];
|
||||
this.Points = [];
|
||||
this.MaxDimWidths = [];
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CEqArray, CMatrixBase);
|
||||
CEqArray.prototype.ClassType = historyitem_type_eqArr;
|
||||
CEqArray.prototype.kind = MATH_EQ_ARRAY;
|
||||
CEqArray.prototype.init = function (props) {
|
||||
var nRowsCount = props.row;
|
||||
this.Fill_LogicalContent(nRowsCount);
|
||||
this.setProperties(props);
|
||||
this.fillContent();
|
||||
};
|
||||
CEqArray.prototype.addRow = function () {
|
||||
var NewContent = new CMathContent();
|
||||
this.protected_AddToContent(this.CurPos + 1, [NewContent], true);
|
||||
this.CurPos++;
|
||||
var NewPr = this.Pr.Copy();
|
||||
NewPr.row = this.Content.length;
|
||||
this.setPr(NewPr);
|
||||
return NewContent;
|
||||
};
|
||||
CEqArray.prototype.setPr = function (NewPr) {
|
||||
History.Add(this, new CChangesMathEqArrayPr(NewPr, this.Pr));
|
||||
this.raw_SetPr(NewPr);
|
||||
};
|
||||
CEqArray.prototype.raw_SetPr = function (NewPr) {
|
||||
this.Pr = NewPr;
|
||||
this.private_SetNeedResize();
|
||||
};
|
||||
CEqArray.prototype.fillContent = function () {
|
||||
var nRowsCount = this.Content.length;
|
||||
this.setDimension(nRowsCount, 1);
|
||||
for (var nIndex = 0; nIndex < nRowsCount; nIndex++) {
|
||||
this.elements[nIndex][0] = this.Content[nIndex];
|
||||
}
|
||||
};
|
||||
CEqArray.prototype.Resize = function (oMeasure, RPI) {
|
||||
var NewRPI = RPI.Copy();
|
||||
NewRPI.bEqqArray = true;
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
this.elements[i][0].Resize(oMeasure, NewRPI);
|
||||
}
|
||||
this.recalculateSize(oMeasure);
|
||||
};
|
||||
CEqArray.prototype.getMetrics = function () {
|
||||
var AscentsMetrics = [];
|
||||
var DescentsMetrics = [];
|
||||
var WidthsMetrics = [];
|
||||
var EndWidths = 0;
|
||||
var even, odd, last;
|
||||
var maxDim, maxDimWidth;
|
||||
var Pos = 0;
|
||||
this.WidthsPoints.length = 0;
|
||||
this.Points.length = 0;
|
||||
this.MaxDimWidths.length = 0;
|
||||
WidthsMetrics[0] = 0;
|
||||
while (EndWidths < this.nRow) {
|
||||
even = 0;
|
||||
odd = 0;
|
||||
last = 0;
|
||||
maxDim = 0;
|
||||
maxDimWidth = 0;
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
var WidthsRow = this.elements[i][0].getWidthsPoints(),
|
||||
len = WidthsRow.length;
|
||||
if (Pos < len) {
|
||||
if (WidthsRow[Pos].odd !== -1) {
|
||||
if (maxDim < WidthsRow[Pos].even || maxDim < WidthsRow[Pos].odd) {
|
||||
maxDim = WidthsRow[Pos].even < WidthsRow[Pos].odd ? WidthsRow[Pos].odd : WidthsRow[Pos].even;
|
||||
maxDimWidth = WidthsRow[Pos].even + WidthsRow[Pos].odd;
|
||||
}
|
||||
even = even > WidthsRow[Pos].even ? even : WidthsRow[Pos].even;
|
||||
odd = odd > WidthsRow[Pos].odd ? odd : WidthsRow[Pos].odd;
|
||||
} else {
|
||||
if (maxDim < WidthsRow[Pos].even) {
|
||||
maxDim = WidthsRow[Pos].even;
|
||||
maxDimWidth = maxDim;
|
||||
}
|
||||
last = last > WidthsRow[Pos].even ? last : WidthsRow[Pos].even;
|
||||
}
|
||||
if (Pos == len - 1) {
|
||||
EndWidths++;
|
||||
}
|
||||
}
|
||||
}
|
||||
var w = even + odd > last ? even + odd : last;
|
||||
var NewPoint = new CMathPoint();
|
||||
NewPoint.even = even;
|
||||
NewPoint.odd = odd;
|
||||
this.WidthsPoints.push(w);
|
||||
this.MaxDimWidths.push(maxDimWidth);
|
||||
this.Points.push(NewPoint);
|
||||
WidthsMetrics[0] += w;
|
||||
Pos++;
|
||||
}
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
this.elements[i][0].ApplyPoints(this.WidthsPoints, this.Points, this.MaxDimWidths);
|
||||
}
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
var size = this.elements[i][0].size;
|
||||
AscentsMetrics[i] = size.ascent;
|
||||
DescentsMetrics[i] = size.height - size.ascent;
|
||||
}
|
||||
return {
|
||||
ascents: AscentsMetrics,
|
||||
descents: DescentsMetrics,
|
||||
widths: WidthsMetrics
|
||||
};
|
||||
};
|
||||
CEqArray.prototype.setPosition = function (pos) {
|
||||
this.pos.x = pos.x;
|
||||
if (this.bInside === true) {
|
||||
this.pos.y = pos.y;
|
||||
} else {
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
}
|
||||
var maxWH = this.getWidthsHeights();
|
||||
var Heights = maxWH.heights;
|
||||
var NewPos = new CMathPosition();
|
||||
var h = 0;
|
||||
for (var i = 0; i < this.nRow; i++) {
|
||||
NewPos.x = this.pos.x + this.GapLeft;
|
||||
NewPos.y = this.pos.y + h;
|
||||
this.elements[i][0].setPosition(NewPos);
|
||||
h += Heights[i] + this.gaps.row[i];
|
||||
}
|
||||
};
|
||||
CEqArray.prototype.getElement = function (num) {
|
||||
return this.elements[num][0];
|
||||
};
|
||||
CEqArray.prototype.getElementMathContent = function (Index) {
|
||||
return this.Content[Index];
|
||||
};
|
||||
CEqArray.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.EqArray;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
1955
OfficeWeb/sdk/Word/Math/nary.js
Normal file
1955
OfficeWeb/sdk/Word/Math/nary.js
Normal file
File diff suppressed because it is too large
Load Diff
3315
OfficeWeb/sdk/Word/Math/operators.js
Normal file
3315
OfficeWeb/sdk/Word/Math/operators.js
Normal file
File diff suppressed because it is too large
Load Diff
448
OfficeWeb/sdk/Word/Math/radical.js
Normal file
448
OfficeWeb/sdk/Word/Math/radical.js
Normal file
@@ -0,0 +1,448 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2015
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL 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
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
"use strict";
|
||||
function CSignRadical() {
|
||||
this.Parent = null;
|
||||
this.pos = null;
|
||||
this.size = null;
|
||||
this.gapArg = 0;
|
||||
this.gapSign = 0;
|
||||
this.measure = {
|
||||
heightTick: 0,
|
||||
widthTick: 0,
|
||||
widthSlash: 0,
|
||||
bHigh: false
|
||||
};
|
||||
}
|
||||
CSignRadical.prototype.new_draw = function (x, y, pGraphics) {
|
||||
var txtPrp = this.Parent.Get_CompiledCtrPrp();
|
||||
var penW = txtPrp.FontSize * g_dKoef_pt_to_mm * 0.042;
|
||||
y += this.gapTop + penW / 2;
|
||||
var x1 = this.pos.x + x,
|
||||
x2 = x1 + 0.048 * txtPrp.FontSize;
|
||||
var Height = this.size.height - this.gapTop;
|
||||
var y2 = this.pos.y + y + Height - this.measure.heightTick,
|
||||
y1 = y2 + 0.0242 * txtPrp.FontSize;
|
||||
var tg = 0.048 / 0.0242;
|
||||
var tX = tg * 0.85 * penW,
|
||||
tY = 0.92 * penW / tg;
|
||||
var x3 = x2,
|
||||
y3 = y2 - tY;
|
||||
var sin = 0.876,
|
||||
cos = 0.474;
|
||||
var y4 = this.pos.y + y + Height - penW;
|
||||
var y5 = y4 + penW / 2 * cos;
|
||||
var x4, x5;
|
||||
if (!this.measure.bHigh) {
|
||||
x4 = x3 + (y4 - y3) / tg;
|
||||
x5 = x4 + penW / 2 * sin;
|
||||
} else {
|
||||
x4 = x1 + this.measure.widthSlash - penW / 3 * sin;
|
||||
x5 = x1 + this.measure.widthSlash;
|
||||
}
|
||||
var x6 = x1 + this.measure.widthSlash,
|
||||
x7 = this.pos.x + x + this.size.width;
|
||||
var y6 = this.pos.y + y,
|
||||
y7 = this.pos.y + y;
|
||||
pGraphics.p_width(penW * 0.8 * 1000);
|
||||
pGraphics.p_color(0, 0, 0, 255);
|
||||
pGraphics.b_color1(0, 0, 0, 255);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics.ds();
|
||||
pGraphics.p_width(1.7 * penW * 1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x3, y3);
|
||||
pGraphics._l(x4, y4);
|
||||
pGraphics.ds();
|
||||
pGraphics.p_width(penW * 1000);
|
||||
pGraphics.p_color(0, 0, 0, 255);
|
||||
pGraphics.b_color1(0, 0, 0, 255);
|
||||
pGraphics.p_width(penW * 1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x5, y5);
|
||||
pGraphics._l(x6, y6);
|
||||
pGraphics._l(x7, y7);
|
||||
pGraphics.ds();
|
||||
pGraphics.p_color(0, 0, 0, 255);
|
||||
pGraphics.b_color1(0, 0, 0, 255);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x4 - penW * 0.6 * sin, y4 - penW / 5);
|
||||
pGraphics._l(x5 + penW / 3 * sin, y4 - penW / 5);
|
||||
pGraphics.ds();
|
||||
};
|
||||
CSignRadical.prototype.draw = function (x, y, pGraphics, PDSE) {
|
||||
var txtPrp = this.Parent.Get_CompiledCtrPrp();
|
||||
var penW = txtPrp.FontSize * g_dKoef_pt_to_mm * 0.042;
|
||||
y += penW / 2 + this.gapSign;
|
||||
var x1 = this.pos.x + x,
|
||||
x2 = x1 + 0.048 * txtPrp.FontSize;
|
||||
var Height = this.size.height - this.gapSign;
|
||||
var y2 = this.pos.y + y + Height - this.measure.heightTick,
|
||||
y1 = y2 + 0.0242 * txtPrp.FontSize;
|
||||
var tg = 0.048 / 0.0242;
|
||||
var tX = tg * 0.85 * penW,
|
||||
tY = 0.92 * penW / tg;
|
||||
var x3 = x2,
|
||||
y3 = y2 - tY;
|
||||
var sin = 0.876,
|
||||
cos = 0.474;
|
||||
var y4 = this.pos.y + y + Height - penW;
|
||||
var y7 = y4 + penW / 2 * cos;
|
||||
var x4, x7;
|
||||
if (!this.measure.bHigh) {
|
||||
x4 = x3 + (y4 - y3) / tg;
|
||||
x7 = x4 + penW / 2 * sin;
|
||||
} else {
|
||||
x4 = x1 + this.measure.widthSlash - penW / 3 * sin;
|
||||
x7 = x1 + this.measure.widthSlash;
|
||||
}
|
||||
var x5 = x4 - penW * 0.6 * sin,
|
||||
y5 = y4 - penW / 5,
|
||||
x6 = x7 + penW / 3 * sin,
|
||||
y6 = y5;
|
||||
var x8 = x1 + this.measure.widthSlash,
|
||||
x9 = this.pos.x + x + this.size.width;
|
||||
var y8 = this.pos.y + y,
|
||||
y9 = this.pos.y + y;
|
||||
pGraphics.p_width(penW * 0.8 * 1000);
|
||||
this.Parent.Make_ShdColor(PDSE, txtPrp);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x1, y1);
|
||||
pGraphics._l(x2, y2);
|
||||
pGraphics.ds();
|
||||
pGraphics.p_width(1.7 * penW * 1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x3, y3);
|
||||
pGraphics._l(x4, y4);
|
||||
pGraphics.ds();
|
||||
pGraphics.p_width(penW * 1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x5, y5);
|
||||
pGraphics._l(x6, y6);
|
||||
pGraphics.ds();
|
||||
pGraphics.p_width(penW * 1000);
|
||||
pGraphics._s();
|
||||
pGraphics._m(x7, y7);
|
||||
pGraphics._l(x8, y8);
|
||||
pGraphics._l(x9, y9);
|
||||
pGraphics.ds();
|
||||
};
|
||||
CSignRadical.prototype.recalculateSize = function (oMeasure, sizeArg) {
|
||||
var txtPrp = this.Parent.Get_CompiledCtrPrp();
|
||||
var height, width;
|
||||
var plH = 9.877777777777776 * txtPrp.FontSize / 36;
|
||||
this.gapArg = txtPrp.FontSize * g_dKoef_pt_to_mm * 0.077108;
|
||||
this.gapSign = txtPrp.FontSize * g_dKoef_pt_to_mm * 0.09449200000000001;
|
||||
var heightArg = sizeArg.height + this.gapArg,
|
||||
widthArg = sizeArg.width;
|
||||
var H0 = plH * 1.07,
|
||||
H1 = plH * 1.623478883321404,
|
||||
H2 = plH * 2.8,
|
||||
H3 = plH * 4.08,
|
||||
H4 = plH * 5.7,
|
||||
H5 = plH * 7.15;
|
||||
this.measure.bHigh = false;
|
||||
var bDescentArg = sizeArg.height - sizeArg.ascent > 0.4 * txtPrp.FontSize / 11;
|
||||
if (heightArg < H0 && !bDescentArg) {
|
||||
height = H0 * 1.12;
|
||||
} else {
|
||||
if (heightArg < H1) {
|
||||
height = H1;
|
||||
} else {
|
||||
if (heightArg < H2) {
|
||||
height = H2;
|
||||
} else {
|
||||
if (heightArg < H3) {
|
||||
height = H3 * 1.04;
|
||||
} else {
|
||||
if (heightArg < H4) {
|
||||
height = H4;
|
||||
} else {
|
||||
if (heightArg < H5) {
|
||||
height = H5;
|
||||
} else {
|
||||
height = heightArg;
|
||||
this.measure.bHigh = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var minHgtRad = plH * 1.130493164,
|
||||
maxHgtRad = plH * 7.029296875;
|
||||
var minHgtTick = plH * 0.6,
|
||||
maxHgtTick = 1.2 * plH;
|
||||
var heightTick, widthSlash, gapLeft;
|
||||
if (heightArg > maxHgtRad) {
|
||||
heightTick = maxHgtTick;
|
||||
widthSlash = plH * 0.67;
|
||||
gapLeft = 0.2 * plH;
|
||||
} else {
|
||||
var H;
|
||||
if (heightArg < H1) {
|
||||
H = H1;
|
||||
var zetta = height < H1 ? 0.75 : 0.82;
|
||||
widthSlash = plH * zetta;
|
||||
} else {
|
||||
H = height;
|
||||
widthSlash = plH * 0.8681086138556986;
|
||||
}
|
||||
var alpha = (H - minHgtRad) / (2 * maxHgtRad);
|
||||
heightTick = minHgtTick * (1 + alpha);
|
||||
gapLeft = 0.1268310546875002 * plH;
|
||||
}
|
||||
this.measure.widthSlash = widthSlash;
|
||||
this.measure.heightTick = heightTick;
|
||||
this.measure.widthTick = 0.1196002747872799 * txtPrp.FontSize;
|
||||
width = widthSlash + gapLeft + widthArg;
|
||||
height += this.gapSign;
|
||||
this.size = {
|
||||
height: height,
|
||||
width: width
|
||||
};
|
||||
};
|
||||
CSignRadical.prototype.setPosition = function (pos) {
|
||||
this.pos = pos;
|
||||
};
|
||||
CSignRadical.prototype.relate = function (parent) {
|
||||
this.Parent = parent;
|
||||
};
|
||||
function CMathRadicalPr() {
|
||||
this.type = DEGREE_RADICAL;
|
||||
this.degHide = false;
|
||||
}
|
||||
CMathRadicalPr.prototype.Set_FromObject = function (Obj) {
|
||||
if (SQUARE_RADICAL === Obj.type || DEGREE_RADICAL === Obj.type) {
|
||||
this.type = Obj.type;
|
||||
}
|
||||
if (true === Obj.degHide || 1 === Obj.degHide) {
|
||||
this.degHide = true;
|
||||
this.type = SQUARE_RADICAL;
|
||||
} else {
|
||||
if (false === Obj.degHide || 0 === Obj.degHide) {
|
||||
this.degHide = false;
|
||||
this.type = DEGREE_RADICAL;
|
||||
}
|
||||
}
|
||||
};
|
||||
CMathRadicalPr.prototype.Copy = function () {
|
||||
var NewPr = new CMathRadicalPr();
|
||||
NewPr.type = this.type;
|
||||
NewPr.degHide = this.degHide;
|
||||
return NewPr;
|
||||
};
|
||||
CMathRadicalPr.prototype.Write_ToBinary = function (Writer) {
|
||||
Writer.WriteLong(this.type);
|
||||
Writer.WriteBool(this.degHide);
|
||||
};
|
||||
CMathRadicalPr.prototype.Read_FromBinary = function (Reader) {
|
||||
this.type = Reader.GetLong();
|
||||
this.degHide = Reader.GetBool();
|
||||
};
|
||||
function CRadical(props) {
|
||||
CRadical.superclass.constructor.call(this);
|
||||
this.Id = g_oIdCounter.Get_NewId();
|
||||
this.Iterator = null;
|
||||
this.Base = null;
|
||||
this.RealBase = null;
|
||||
this.signRadical = new CSignRadical();
|
||||
this.signRadical.relate(this);
|
||||
this.Pr = new CMathRadicalPr();
|
||||
this.gapDegree = 0;
|
||||
this.gapWidth = 0;
|
||||
if (props !== null && typeof(props) !== "undefined") {
|
||||
this.init(props);
|
||||
}
|
||||
g_oTableId.Add(this, this.Id);
|
||||
}
|
||||
Asc.extendClass(CRadical, CMathBase);
|
||||
CRadical.prototype.ClassType = historyitem_type_rad;
|
||||
CRadical.prototype.kind = MATH_RADICAL;
|
||||
CRadical.prototype.init = function (props) {
|
||||
this.setProperties(props);
|
||||
this.Fill_LogicalContent(2);
|
||||
this.fillContent();
|
||||
};
|
||||
CRadical.prototype.fillContent = function () {
|
||||
this.Iterator = this.getDegree();
|
||||
this.Base = this.getBase();
|
||||
};
|
||||
CRadical.prototype.PreRecalc = function (Parent, ParaMath, ArgSize, RPI, GapsInfo) {
|
||||
this.Parent = Parent;
|
||||
this.ParaMath = ParaMath;
|
||||
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
|
||||
this.ApplyProperties(RPI);
|
||||
if (this.Pr.type == SQUARE_RADICAL) {
|
||||
this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI);
|
||||
} else {
|
||||
var ArgSzIter = new CMathArgSize();
|
||||
ArgSzIter.SetValue(-2);
|
||||
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
|
||||
this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI);
|
||||
}
|
||||
if (this.bInside == false) {
|
||||
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
|
||||
}
|
||||
};
|
||||
CRadical.prototype.ApplyProperties = function (RPI) {
|
||||
if (this.RecalcInfo.bProps) {
|
||||
if (this.Pr.degHide == true) {
|
||||
this.setDimension(1, 1);
|
||||
this.elements[0][0] = this.Base;
|
||||
this.RealBase = this.elements[0][0];
|
||||
} else {
|
||||
this.setDimension(1, 2);
|
||||
this.elements[0][0] = this.Iterator;
|
||||
this.elements[0][1] = this.Base;
|
||||
this.RealBase = this.Base;
|
||||
}
|
||||
this.RecalcInfo.bProps = false;
|
||||
}
|
||||
};
|
||||
CRadical.prototype.Resize = function (oMeasure, RPI) {
|
||||
if (this.Pr.type == SQUARE_RADICAL) {
|
||||
this.RealBase.Resize(oMeasure, RPI);
|
||||
} else {
|
||||
this.Iterator.Resize(oMeasure, RPI);
|
||||
this.RealBase.Resize(oMeasure, RPI);
|
||||
}
|
||||
var shTop, height, width, ascent;
|
||||
this.signRadical.recalculateSize(oMeasure, this.RealBase.size);
|
||||
var txtPrp = this.Get_CompiledCtrPrp();
|
||||
var sign = this.signRadical.size,
|
||||
gSign = this.signRadical.gapSign,
|
||||
gArg = this.signRadical.gapArg > 2 * g_dKoef_pt_to_mm ? this.signRadical.gapArg : 2 * g_dKoef_pt_to_mm;
|
||||
var gapBase = gSign + gArg;
|
||||
if (this.Pr.type == SQUARE_RADICAL) {
|
||||
shTop = (sign.height - gSign - this.RealBase.size.height) / 2;
|
||||
shTop = shTop > 0 ? shTop : 0;
|
||||
ascent = gapBase + shTop + this.RealBase.size.ascent;
|
||||
height = sign.height > ascent - this.RealBase.size.ascent + this.RealBase.size.height ? sign.height : ascent - this.RealBase.size.ascent + this.RealBase.size.height;
|
||||
width = sign.width;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
} else {
|
||||
if (this.Pr.type == DEGREE_RADICAL) {
|
||||
var wTick = this.signRadical.measure.widthTick,
|
||||
hTick = this.signRadical.measure.heightTick;
|
||||
var plH = 9.877777777777776 * txtPrp.FontSize / 36;
|
||||
var gapHeight = 0.011 * txtPrp.FontSize;
|
||||
this.gapWidth = 0.011 * txtPrp.FontSize;
|
||||
var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0;
|
||||
width = wDegree + sign.width + this.gapWidth;
|
||||
width += this.GapLeft + this.GapRight;
|
||||
var gapDegree;
|
||||
if (this.RealBase.size.height < plH) {
|
||||
gapDegree = 1.5 * txtPrp.FontSize / 36;
|
||||
} else {
|
||||
gapDegree = 3 * txtPrp.FontSize / 36;
|
||||
}
|
||||
var h1 = gapHeight + this.Iterator.size.height + gapDegree + hTick,
|
||||
h2 = sign.height;
|
||||
shTop = (sign.height - gSign - this.RealBase.size.height) / 2;
|
||||
if (h1 > h2) {
|
||||
height = h1;
|
||||
ascent = height - sign.height + gapBase + shTop + this.RealBase.size.ascent;
|
||||
} else {
|
||||
height = h2;
|
||||
ascent = gapBase + shTop + this.RealBase.size.ascent;
|
||||
}
|
||||
this.gapDegree = height - h1 + gapHeight;
|
||||
this.size = {
|
||||
width: width,
|
||||
height: height,
|
||||
ascent: ascent
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
CRadical.prototype.setPosition = function (pos, PosInfo) {
|
||||
this.pos.x = pos.x;
|
||||
this.pos.y = pos.y - this.size.ascent;
|
||||
var PosBase = new CMathPosition(),
|
||||
PosRadical = new CMathPosition();
|
||||
if (this.Pr.type == SQUARE_RADICAL) {
|
||||
var gapLeft = this.size.width - this.RealBase.size.width - this.GapRight;
|
||||
var gapTop = this.size.ascent - this.RealBase.size.ascent;
|
||||
PosRadical.x = this.pos.x + this.GapLeft;
|
||||
PosRadical.y = this.pos.y;
|
||||
PosBase.x = this.pos.x + gapLeft;
|
||||
PosBase.y = this.pos.y + gapTop;
|
||||
this.signRadical.setPosition(PosRadical);
|
||||
this.RealBase.setPosition(PosBase, PosInfo);
|
||||
} else {
|
||||
if (this.Pr.type == DEGREE_RADICAL) {
|
||||
var wTick = this.signRadical.measure.widthTick;
|
||||
var PosDegree = new CMathPosition();
|
||||
PosDegree.x = this.pos.x + this.GapLeft + this.gapWidth;
|
||||
PosDegree.y = this.pos.y + this.gapDegree;
|
||||
this.Iterator.setPosition(PosDegree, PosInfo);
|
||||
var wDegree = this.Iterator.size.width > wTick ? this.Iterator.size.width - wTick : 0;
|
||||
PosRadical.x = this.pos.x + this.GapLeft + wDegree;
|
||||
PosRadical.y = this.pos.y + this.size.height - this.signRadical.size.height;
|
||||
this.signRadical.setPosition(PosRadical);
|
||||
PosBase.x = this.pos.x + this.size.width - this.RealBase.size.width - this.GapRight;
|
||||
PosBase.y = this.pos.y + this.size.ascent - this.RealBase.size.ascent;
|
||||
this.RealBase.setPosition(PosBase, PosInfo);
|
||||
}
|
||||
}
|
||||
};
|
||||
CRadical.prototype.draw = function (x, y, pGraphics, PDSE) {
|
||||
this.signRadical.draw(x, y, pGraphics, PDSE);
|
||||
CRadical.superclass.draw.call(this, x, y, pGraphics, PDSE);
|
||||
};
|
||||
CRadical.prototype.getBase = function () {
|
||||
return this.Content[1];
|
||||
};
|
||||
CRadical.prototype.getDegree = function () {
|
||||
return this.Content[0];
|
||||
};
|
||||
CRadical.prototype.Document_UpdateInterfaceState = function (MathProps) {
|
||||
MathProps.Type = c_oAscMathInterfaceType.Radical;
|
||||
MathProps.Pr = null;
|
||||
};
|
||||
CRadical.prototype.Is_ContentUse = function (MathContent) {
|
||||
if (MathContent === this.Content[1]) {
|
||||
return true;
|
||||
}
|
||||
if (DEGREE_RADICAL === this.Pr.type && MathContent === this.Content[0]) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user