3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

View File

@@ -0,0 +1,459 @@
/*
* (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 ArcToCurvers = null;
var ArcToOnCanvas = null;
var HitToArc = null;
(function () {
function Arc3(ctx, fX, fY, fWidth, fHeight, fStartAngle, fSweepAngle) {
var sin1 = Math.sin(fStartAngle);
var cos1 = Math.cos(fStartAngle);
var __x = cos1 / fWidth;
var __y = sin1 / fHeight;
var l = 1 / Math.sqrt(__x * __x + __y * __y);
var cx = fX - l * cos1;
var cy = fY - l * sin1;
Arc2(ctx, cx - fWidth, cy - fHeight, 2 * fWidth, 2 * fHeight, fStartAngle, fSweepAngle);
}
function Arc2(ctx, fX, fY, fWidth, fHeight, fStartAngle, fSweepAngle) {
if (0 >= fWidth || 0 >= fHeight) {
return;
}
fStartAngle = -fStartAngle;
fSweepAngle = -fSweepAngle;
if (false) {
var fStartX = fX + fWidth / 2 + fWidth / 2 * Math.cos(AngToEllPrm(fStartAngle, fWidth / 2, fHeight / 2));
var fStartY = fY + fHeight / 2 - fHeight / 2 * Math.sin(AngToEllPrm(fStartAngle, fWidth / 2, fHeight / 2));
if (fSweepAngle < (2 * Math.PI)) {
ctx._m(fStartX, fStartY);
}
}
var bClockDirection = false;
var fEndAngle = (2 * Math.PI) - (fSweepAngle + fStartAngle);
var fSrtAngle = (2 * Math.PI) - fStartAngle;
if (fSweepAngle > 0) {
bClockDirection = true;
}
if (Math.abs(fSweepAngle) >= (2 * Math.PI)) {
Ellipse(ctx, fX + fWidth / 2, fY + fHeight / 2, fWidth / 2, fHeight / 2);
} else {
EllipseArc(ctx, fX + fWidth / 2, fY + fHeight / 2, fWidth / 2, fHeight / 2, fSrtAngle, fEndAngle, bClockDirection);
}
}
function AngToEllPrm(fAngle, fXRad, fYRad) {
return Math.atan2(Math.sin(fAngle) / fYRad, Math.cos(fAngle) / fXRad);
}
function Ellipse(ctx, fX, fY, fXRad, fYRad) {
ctx._m(fX - fXRad, fY);
var c_fKappa = 0.5520000000000001;
ctx._c(fX - fXRad, fY + fYRad * c_fKappa, fX - fXRad * c_fKappa, fY + fYRad, fX, fY + fYRad);
ctx._c(fX + fXRad * c_fKappa, fY + fYRad, fX + fXRad, fY + fYRad * c_fKappa, fX + fXRad, fY);
ctx._c(fX + fXRad, fY - fYRad * c_fKappa, fX + fXRad * c_fKappa, fY - fYRad, fX, fY - fYRad);
ctx._c(fX - fXRad * c_fKappa, fY - fYRad, fX - fXRad, fY - fYRad * c_fKappa, fX - fXRad, fY);
}
function EllipseArc(ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, bClockDirection) {
while (fAngle1 < 0) {
fAngle1 += (2 * Math.PI);
}
while (fAngle1 > (2 * Math.PI)) {
fAngle1 -= (2 * Math.PI);
}
while (fAngle2 < 0) {
fAngle2 += (2 * Math.PI);
}
while (fAngle2 >= (2 * Math.PI)) {
fAngle2 -= (2 * Math.PI);
}
if (!bClockDirection) {
if (fAngle1 <= fAngle2) {
EllipseArc2(ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, false);
} else {
EllipseArc2(ctx, fX, fY, fXRad, fYRad, fAngle1, 2 * Math.PI, false);
EllipseArc2(ctx, fX, fY, fXRad, fYRad, 0, fAngle2, false);
}
} else {
if (fAngle1 >= fAngle2) {
EllipseArc2(ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, true);
} else {
EllipseArc2(ctx, fX, fY, fXRad, fYRad, fAngle1, 0, true);
EllipseArc2(ctx, fX, fY, fXRad, fYRad, 2 * Math.PI, fAngle2, true);
}
}
}
function EllipseArc2(ctx, fX, fY, fXRad, fYRad, dAngle1, dAngle2, bClockDirection) {
var nFirstPointQuard = ((2 * dAngle1 / Math.PI) >> 0) + 1;
var nSecondPointQuard = ((2 * dAngle2 / Math.PI) >> 0) + 1;
nSecondPointQuard = Math.min(4, Math.max(1, nSecondPointQuard));
nFirstPointQuard = Math.min(4, Math.max(1, nFirstPointQuard));
var fStartX = fX + fXRad * Math.cos(AngToEllPrm(dAngle1, fXRad, fYRad));
var fStartY = fY + fYRad * Math.sin(AngToEllPrm(dAngle1, fXRad, fYRad));
var EndPoint = {
X: 0,
Y: 0
};
var fCurX = fStartX,
fCurY = fStartY;
var dStartAngle = dAngle1;
var dEndAngle = 0;
if (!bClockDirection) {
for (var nIndex = nFirstPointQuard; nIndex <= nSecondPointQuard; nIndex++) {
if (nIndex == nSecondPointQuard) {
dEndAngle = dAngle2;
} else {
dEndAngle = nIndex * Math.PI / 2;
}
if (! (nIndex == nFirstPointQuard)) {
dStartAngle = (nIndex - 1) * Math.PI / 2;
}
EndPoint = EllipseArc3(ctx, fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), false);
}
} else {
for (var nIndex = nFirstPointQuard; nIndex >= nSecondPointQuard; nIndex--) {
if (nIndex == nFirstPointQuard) {
dStartAngle = dAngle1;
} else {
dStartAngle = nIndex * Math.PI / 2;
}
if (! (nIndex == nSecondPointQuard)) {
dEndAngle = (nIndex - 1) * Math.PI / 2;
} else {
dEndAngle = dAngle2;
}
EndPoint = EllipseArc3(ctx, fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), false);
}
}
}
function EllipseArc3(ctx, fX, fY, fXRad, fYRad, dAngle1, dAngle2, bClockDirection) {
var fAlpha = Math.sin(dAngle2 - dAngle1) * (Math.sqrt(4 + 3 * Math.tan((dAngle2 - dAngle1) / 2) * Math.tan((dAngle2 - dAngle1) / 2)) - 1) / 3;
var sin1 = Math.sin(dAngle1);
var cos1 = Math.cos(dAngle1);
var sin2 = Math.sin(dAngle2);
var cos2 = Math.cos(dAngle2);
var fX1 = fX + fXRad * cos1;
var fY1 = fY + fYRad * sin1;
var fX2 = fX + fXRad * cos2;
var fY2 = fY + fYRad * sin2;
var fCX1 = fX1 - fAlpha * fXRad * sin1;
var fCY1 = fY1 + fAlpha * fYRad * cos1;
var fCX2 = fX2 + fAlpha * fXRad * sin2;
var fCY2 = fY2 - fAlpha * fYRad * cos2;
if (!bClockDirection) {
ctx._c(fCX1, fCY1, fCX2, fCY2, fX2, fY2);
return {
X: fX2,
Y: fY2
};
} else {
ctx._c(fCX2, fCY2, fCX1, fCY1, fX1, fY1);
return {
X: fX1,
Y: fY1
};
}
}
ArcToCurvers = Arc3;
function _ArcToOnCanvas(context, start_x, start_y, width_r, height_r, start_ang, sweep_ang) {
var _sin = Math.sin(start_ang);
var _cos = Math.cos(start_ang);
var _x = _cos / width_r;
var _y = _sin / height_r;
var _l = 1 / Math.sqrt(_x * _x + _y * _y);
var _cx = start_x - _l * _cos;
var _cy = start_y - _l * _sin;
ArcTo2OnCanvas(context, _cx - width_r, _cy - height_r, 2 * width_r, 2 * height_r, start_ang, sweep_ang);
}
function ArcTo2OnCanvas(context, _l_c_x, _l_c_y, width, height, start_ang, sweep_ang) {
if (0 >= width || 0 >= height) {
return;
}
start_ang = -start_ang;
sweep_ang = -sweep_ang;
var bClockDirection = false;
var fEndAngle = (2 * Math.PI) - (sweep_ang + start_ang);
var fSrtAngle = (2 * Math.PI) - start_ang;
if (sweep_ang > 0) {
bClockDirection = true;
}
if (Math.abs(sweep_ang) >= (2 * Math.PI)) {
EllipseOnCanvas(context, _l_c_x + width / 2, _l_c_y + height / 2, width / 2, height / 2);
} else {
EllipseArcOnCanvas(context, _l_c_x + width / 2, _l_c_y + height / 2, width / 2, height / 2, fSrtAngle, fEndAngle, bClockDirection);
}
}
function EllipseOnCanvas(ctx, fX, fY, fXRad, fYRad) {
ctx.moveTo(fX - fXRad, fY);
var c_fKappa = 0.5520000000000001;
ctx.bezierCurveTo(fX - fXRad, fY + fYRad * c_fKappa, fX - fXRad * c_fKappa, fY + fYRad, fX, fY + fYRad);
ctx.bezierCurveTo(fX + fXRad * c_fKappa, fY + fYRad, fX + fXRad, fY + fYRad * c_fKappa, fX + fXRad, fY);
ctx.bezierCurveTo(fX + fXRad, fY - fYRad * c_fKappa, fX + fXRad * c_fKappa, fY - fYRad, fX, fY - fYRad);
ctx.bezierCurveTo(fX - fXRad * c_fKappa, fY - fYRad, fX - fXRad, fY - fYRad * c_fKappa, fX - fXRad, fY);
}
function EllipseArcOnCanvas(ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, bClockDirection) {
while (fAngle1 < 0) {
fAngle1 += (2 * Math.PI);
}
while (fAngle1 > (2 * Math.PI)) {
fAngle1 -= (2 * Math.PI);
}
while (fAngle2 < 0) {
fAngle2 += (2 * Math.PI);
}
while (fAngle2 >= (2 * Math.PI)) {
fAngle2 -= (2 * Math.PI);
}
if (!bClockDirection) {
if (fAngle1 <= fAngle2) {
EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, false);
} else {
EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, fAngle1, 2 * Math.PI, false);
EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, 0, fAngle2, false);
}
} else {
if (fAngle1 >= fAngle2) {
EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, true);
} else {
EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, fAngle1, 0, true);
EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, 2 * Math.PI, fAngle2, true);
}
}
}
function EllipseArc2OnCanvas(ctx, fX, fY, fXRad, fYRad, dAngle1, dAngle2, bClockDirection) {
var nFirstPointQuard = ((2 * dAngle1 / Math.PI) >> 0) + 1;
var nSecondPointQuard = ((2 * dAngle2 / Math.PI) >> 0) + 1;
nSecondPointQuard = Math.min(4, Math.max(1, nSecondPointQuard));
nFirstPointQuard = Math.min(4, Math.max(1, nFirstPointQuard));
var fStartX = fX + fXRad * Math.cos(AngToEllPrm(dAngle1, fXRad, fYRad));
var fStartY = fY + fYRad * Math.sin(AngToEllPrm(dAngle1, fXRad, fYRad));
var EndPoint = {
X: 0,
Y: 0
};
ctx.lineTo(fStartX, fStartY);
var fCurX = fStartX,
fCurY = fStartY;
var dStartAngle = dAngle1;
var dEndAngle = 0;
if (!bClockDirection) {
for (var nIndex = nFirstPointQuard; nIndex <= nSecondPointQuard; nIndex++) {
if (nIndex == nSecondPointQuard) {
dEndAngle = dAngle2;
} else {
dEndAngle = nIndex * Math.PI / 2;
}
if (! (nIndex == nFirstPointQuard)) {
dStartAngle = (nIndex - 1) * Math.PI / 2;
}
EndPoint = EllipseArc3OnCanvas(ctx, fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), false);
}
} else {
for (var nIndex = nFirstPointQuard; nIndex >= nSecondPointQuard; nIndex--) {
if (nIndex == nFirstPointQuard) {
dStartAngle = dAngle1;
} else {
dStartAngle = nIndex * Math.PI / 2;
}
if (! (nIndex == nSecondPointQuard)) {
dEndAngle = (nIndex - 1) * Math.PI / 2;
} else {
dEndAngle = dAngle2;
}
EndPoint = EllipseArc3OnCanvas(ctx, fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), false);
}
}
}
function EllipseArc3OnCanvas(ctx, fX, fY, fXRad, fYRad, dAngle1, dAngle2, bClockDirection) {
var fAlpha = Math.sin(dAngle2 - dAngle1) * (Math.sqrt(4 + 3 * Math.tan((dAngle2 - dAngle1) / 2) * Math.tan((dAngle2 - dAngle1) / 2)) - 1) / 3;
var sin1 = Math.sin(dAngle1);
var cos1 = Math.cos(dAngle1);
var sin2 = Math.sin(dAngle2);
var cos2 = Math.cos(dAngle2);
var fX1 = fX + fXRad * cos1;
var fY1 = fY + fYRad * sin1;
var fX2 = fX + fXRad * cos2;
var fY2 = fY + fYRad * sin2;
var fCX1 = fX1 - fAlpha * fXRad * sin1;
var fCY1 = fY1 + fAlpha * fYRad * cos1;
var fCX2 = fX2 + fAlpha * fXRad * sin2;
var fCY2 = fY2 - fAlpha * fYRad * cos2;
if (!bClockDirection) {
ctx.bezierCurveTo(fCX1, fCY1, fCX2, fCY2, fX2, fY2);
return {
X: fX2,
Y: fY2
};
} else {
ctx.bezierCurveTo(fCX2, fCY2, fCX1, fCY1, fX1, fY1);
return {
X: fX1,
Y: fY1
};
}
}
function _HitToArc(context, px, py, start_x, start_y, width_r, height_r, start_ang, sweep_ang) {
var _sin = Math.sin(start_ang);
var _cos = Math.cos(start_ang);
var _x = _cos / width_r;
var _y = _sin / height_r;
var _l = 1 / Math.sqrt(_x * _x + _y * _y);
var _cx = start_x - _l * _cos;
var _cy = start_y - _l * _sin;
return HitToArc2(px, py, context, _cx - width_r, _cy - height_r, 2 * width_r, 2 * height_r, start_ang, sweep_ang);
}
function HitToArc2(px, py, context, _l_c_x, _l_c_y, width, height, start_ang, sweep_ang) {
if (0 >= width || 0 >= height) {
return;
}
start_ang = -start_ang;
sweep_ang = -sweep_ang;
var bClockDirection = false;
var fEndAngle = (2 * Math.PI) - (sweep_ang + start_ang);
var fSrtAngle = (2 * Math.PI) - start_ang;
if (sweep_ang > 0) {
bClockDirection = true;
}
if (Math.abs(sweep_ang) >= (2 * Math.PI)) {
return HitToEllipseOnCanvas(px, py, context, _l_c_x + width / 2, _l_c_y + height / 2, width / 2, height / 2);
} else {
return HitToEllipseArcOnCanvas(px, py, context, _l_c_x + width / 2, _l_c_y + height / 2, width / 2, height / 2, fSrtAngle, fEndAngle, bClockDirection);
}
}
function HitToEllipseOnCanvas(px, py, ctx, fX, fY, fXRad, fYRad) {
var c_fKappa = 0.5520000000000001;
return HitInBezier4(ctx, px, py, fX - fXRad, fY, fX - fXRad, fY + fYRad * c_fKappa, fX - fXRad * c_fKappa, fY + fYRad, fX, fY + fYRad) || HitInBezier4(ctx, px, py, fX, fY + fYRad, fX + fXRad * c_fKappa, fY + fYRad, fX + fXRad, fY + fYRad * c_fKappa, fX + fXRad, fY) || HitInBezier4(ctx, px, py, fX + fXRad, fY, fX + fXRad, fY - fYRad * c_fKappa, fX + fXRad * c_fKappa, fY - fYRad, fX, fY - fYRad) || HitInBezier4(ctx, px, py, fX, fY - fYRad, fX - fXRad * c_fKappa, fY - fYRad, fX - fXRad, fY - fYRad * c_fKappa, fX - fXRad, fY);
}
function HitToEllipseArcOnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, bClockDirection) {
while (fAngle1 < 0) {
fAngle1 += (2 * Math.PI);
}
while (fAngle1 > (2 * Math.PI)) {
fAngle1 -= (2 * Math.PI);
}
while (fAngle2 < 0) {
fAngle2 += (2 * Math.PI);
}
while (fAngle2 >= (2 * Math.PI)) {
fAngle2 -= (2 * Math.PI);
}
if (!bClockDirection) {
if (fAngle1 <= fAngle2) {
return HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, false);
} else {
return HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, fAngle1, 2 * Math.PI, false) || HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, 0, fAngle2, false);
}
} else {
if (fAngle1 >= fAngle2) {
return HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, fAngle1, fAngle2, true);
} else {
return HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, fAngle1, 0, true) || HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, 2 * Math.PI, fAngle2, true);
}
}
}
function HitToEllipseArc2OnCanvas(px, py, ctx, fX, fY, fXRad, fYRad, dAngle1, dAngle2, bClockDirection) {
var nFirstPointQuard = ((2 * dAngle1 / Math.PI) >> 0) + 1;
var nSecondPointQuard = ((2 * dAngle2 / Math.PI) >> 0) + 1;
nSecondPointQuard = Math.min(4, Math.max(1, nSecondPointQuard));
nFirstPointQuard = Math.min(4, Math.max(1, nFirstPointQuard));
var fStartX = fX + fXRad * Math.cos(AngToEllPrm(dAngle1, fXRad, fYRad));
var fStartY = fY + fYRad * Math.sin(AngToEllPrm(dAngle1, fXRad, fYRad));
var EndPoint = {
X: fStartX,
Y: fStartY,
hit: false
};
var dStartAngle = dAngle1;
var dEndAngle = 0;
if (!bClockDirection) {
for (var nIndex = nFirstPointQuard; nIndex <= nSecondPointQuard; nIndex++) {
if (nIndex == nSecondPointQuard) {
dEndAngle = dAngle2;
} else {
dEndAngle = nIndex * Math.PI / 2;
}
if (! (nIndex == nFirstPointQuard)) {
dStartAngle = (nIndex - 1) * Math.PI / 2;
}
EndPoint = HitToEllipseArc3OnCanvas(px, py, EndPoint, ctx, fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), false);
if (EndPoint.hit) {
return true;
}
}
} else {
for (var nIndex = nFirstPointQuard; nIndex >= nSecondPointQuard; nIndex--) {
if (nIndex == nFirstPointQuard) {
dStartAngle = dAngle1;
} else {
dStartAngle = nIndex * Math.PI / 2;
}
if (! (nIndex == nSecondPointQuard)) {
dEndAngle = (nIndex - 1) * Math.PI / 2;
} else {
dEndAngle = dAngle2;
}
EndPoint = HitToEllipseArc3OnCanvas(px, py, EndPoint, ctx, fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), false);
if (EndPoint.hit) {
return true;
}
}
}
return false;
}
function HitToEllipseArc3OnCanvas(px, py, EndPoint, ctx, fX, fY, fXRad, fYRad, dAngle1, dAngle2, bClockDirection) {
var fAlpha = Math.sin(dAngle2 - dAngle1) * (Math.sqrt(4 + 3 * Math.tan((dAngle2 - dAngle1) / 2) * Math.tan((dAngle2 - dAngle1) / 2)) - 1) / 3;
var sin1 = Math.sin(dAngle1);
var cos1 = Math.cos(dAngle1);
var sin2 = Math.sin(dAngle2);
var cos2 = Math.cos(dAngle2);
var fX1 = fX + fXRad * cos1;
var fY1 = fY + fYRad * sin1;
var fX2 = fX + fXRad * cos2;
var fY2 = fY + fYRad * sin2;
var fCX1 = fX1 - fAlpha * fXRad * sin1;
var fCY1 = fY1 + fAlpha * fYRad * cos1;
var fCX2 = fX2 + fAlpha * fXRad * sin2;
var fCY2 = fY2 - fAlpha * fYRad * cos2;
if (!bClockDirection) {
return {
X: fX2,
Y: fY2,
hit: HitInBezier4(ctx, px, py, EndPoint.X, EndPoint.Y, fCX1, fCY1, fCX2, fCY2, fX2, fY2)
};
} else {
return {
X: fX1,
Y: fY1,
hit: HitInBezier4(ctx, px, py, EndPoint.X, EndPoint.Y, fCX2, fCY2, fCX1, fCY1, fX1, fY1)
};
}
}
ArcToOnCanvas = _ArcToOnCanvas;
HitToArc = _HitToArc;
})();

View File

@@ -0,0 +1,137 @@
/*
* (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 CShapeColor(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
this.darken = function () {
var hslColor = RGBToHSL(this);
hslColor.l *= 0.9;
return HSLToRGB(hslColor);
};
this.darkenLess = function () {
var hslColor = RGBToHSL(this);
hslColor.l *= 0.85;
return HSLToRGB(hslColor);
};
this.lighten = function () {
var hslColor = RGBToHSL(this);
hslColor.l *= 1.1;
if (hslColor.l > 1) {
hslColor.l = 1;
}
return HSLToRGB(hslColor);
};
this.lightenLess = function () {
var hslColor = RGBToHSL(this);
hslColor.l *= 1.1;
if (hslColor.l > 1) {
hslColor.l = 1;
}
return HSLToRGB(hslColor);
};
this.norm = function (a) {
return this;
};
}
function RGBToHSL(RGBColor) {
var r, g, b;
r = RGBColor.r / 255;
g = RGBColor.g / 255;
b = RGBColor.b / 255;
var max, min;
max = Math.max(r, g, b);
min = Math.min(r, g, b);
var h, s, l;
h = max === min ? 0 : (max == r && g >= b) ? 60 * (g - b) / (max - min) : (max == r && g < b) ? 60 * (g - b) / (max - min) + 360 : (max == g) ? 60 * (b - r) / (max - min) + 120 : 60 * (r - g) / (max - min) + 240;
l = (max + min) * 0.5;
s = l > 0.5 ? (max - min) / (2 - max - min) : (max - min) / (max + min);
while (h < 0) {
h += 360;
}
while (h >= 360) {
h -= 360;
}
return {
h: h,
s: s,
l: l
};
}
function HSLToRGB(HSLColor) {
var h, s, l, r, g, b;
h = HSLColor.h / 360;
s = HSLColor.s;
l = HSLColor.l;
var q, p, tr, tg, tb;
q = l < 0.5 ? (l * (1 + s)) : l + s - l * s;
p = 2 * l - q;
tr = h + 1 / 3;
tg = h;
tb = h - 1 / 3;
if (tr < 0) {
tr += 1;
}
if (tr > 1) {
tr -= 1;
}
if (tg < 0) {
tg += 1;
}
if (tg > 1) {
tg -= 1;
}
if (tb < 0) {
tb += 1;
}
if (tb > 1) {
tb -= 1;
}
r = Math.round(255 * (tr < 1 / 6 ? p + ((q - p) * 6 * tr) : (1 / 6 < tr && tr < 1 / 2) ? q : (1 / 2 < tr && tr < 2 / 3) ? (p + ((q - p) * (2 / 3 - tr) * 6)) : p));
g = Math.round(255 * (tg < 1 / 6 ? p + ((q - p) * 6 * tg) : (1 / 6 < tg && tg < 1 / 2) ? q : (1 / 2 < tg && tg < 2 / 3) ? (p + ((q - p) * (2 / 3 - tg) * 6)) : p));
b = Math.round(255 * (tb < 1 / 6 ? p + ((q - p) * 6 * tb) : (1 / 6 < tb && tb < 1 / 2) ? q : (1 / 2 < tb && tb < 2 / 3) ? (p + ((q - p) * (2 / 3 - tb) * 6)) : p));
if (r > 255) {
r = 255;
}
if (g > 255) {
g = 255;
}
if (b > 255) {
b = 255;
}
return {
r: r,
g: g,
b: b
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,529 @@
/*
* (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 CheckCoordsNeedPage(x, y, pageIndex, needPageIndex, drawingDocument) {
if (pageIndex === needPageIndex) {
return {
x: x,
y: y
};
} else {
var t = drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, needPageIndex);
return {
x: t.X,
y: t.Y
};
}
}
function handleSelectedObjects(drawingObjectsController, e, x, y, group, pageIndex, bWord) {
var selected_objects = group ? group.selectedObjects : drawingObjectsController.getSelectedObjects();
var tx, ty, t;
if (selected_objects.length === 1) {
if (bWord && pageIndex !== selected_objects[0].selectStartPage) {
t = drawingObjectsController.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, selected_objects[0].selectStartPage);
tx = t.X;
ty = t.Y;
} else {
tx = x;
ty = y;
}
var hit_to_adj = selected_objects[0].hitToAdjustment(tx, ty);
if (hit_to_adj.hit) {
return drawingObjectsController.handleAdjustmentHit(hit_to_adj, selected_objects[0], group, pageIndex);
}
}
for (var i = selected_objects.length - 1; i > -1; --i) {
if (bWord && pageIndex !== selected_objects[i].selectStartPage) {
t = drawingObjectsController.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, selected_objects[i].selectStartPage);
tx = t.X;
ty = t.Y;
} else {
tx = x;
ty = y;
}
var hit_to_handles = selected_objects[i].hitToHandles(tx, ty);
if (hit_to_handles > -1) {
return drawingObjectsController.handleHandleHit(hit_to_handles, selected_objects[i], group);
}
}
for (i = selected_objects.length - 1; i > -1; --i) {
if (bWord && pageIndex !== selected_objects[i].selectStartPage) {
t = drawingObjectsController.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, selected_objects[i].selectStartPage);
tx = t.X;
ty = t.Y;
} else {
tx = x;
ty = y;
}
if (selected_objects[i].hitInBoundingRect(x, y) && (!selected_objects[i].hitInTextRect || !selected_objects[i].hitInTextRect(x, y))) {
if (bWord && selected_objects[i].parent && selected_objects[i].parent.Is_Inline()) {
return handleInlineHitNoText(selected_objects[i], drawingObjectsController, e, x, y, pageIndex);
} else {
return drawingObjectsController.handleMoveHit(selected_objects[i], e, x, y, group, true, selected_objects[i].selectStartPage, true);
}
}
}
return false;
}
function handleFloatObjects(drawingObjectsController, drawingArr, e, x, y, group, pageIndex, bWord) {
var ret = null,
drawing;
for (var i = drawingArr.length - 1; i > -1; --i) {
drawing = drawingArr[i];
switch (drawing.getObjectType()) {
case historyitem_type_Shape:
case historyitem_type_ImageShape:
ret = handleShapeImage(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord);
if (ret) {
return ret;
}
break;
case historyitem_type_ChartSpace:
ret = handleChart(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord);
if (ret) {
return ret;
}
break;
case historyitem_type_GroupShape:
ret = handleGroup(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord);
if (ret) {
return ret;
}
break;
case historyitem_type_GraphicFrame:
ret = handleFloatTable(drawing, drawingObjectsController, e, x, y, group, pageIndex);
if (ret) {
return ret;
}
break;
}
}
return ret;
}
function handleShapeImage(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord) {
var hit_in_inner_area = drawing.hitInInnerArea(x, y);
var hit_in_path = drawing.hitInPath(x, y);
var hit_in_text_rect = drawing.hitInTextRect(x, y);
if (!hit_in_text_rect && (hit_in_inner_area || hit_in_path)) {
return drawingObjectsController.handleMoveHit(drawing, e, x, y, group, false, pageIndex, bWord);
} else {
if (hit_in_text_rect) {
if (bWord) {
var all_drawings = drawing.getDocContent().Get_AllDrawingObjects();
var drawings2 = [];
for (var i = 0; i < all_drawings.length; ++i) {
drawings2.push(all_drawings[i].GraphicObj);
}
var ret = handleInlineObjects(drawingObjectsController, drawings2, e, x, y, pageIndex, bWord);
if (ret) {
return ret;
}
}
return drawingObjectsController.handleTextHit(drawing, e, x, y, group, pageIndex, bWord);
}
}
return false;
}
function handleShapeImageInGroup(drawingObjectsController, drawing, shape, e, x, y, pageIndex, bWord) {
var hit_in_inner_area = shape.hitInInnerArea && shape.hitInInnerArea(x, y);
var hit_in_path = shape.hitInPath && shape.hitInPath(x, y);
var hit_in_text_rect = shape.hitInTextRect && shape.hitInTextRect(x, y);
var ret;
if (!hit_in_text_rect && (hit_in_inner_area || hit_in_path)) {
return drawingObjectsController.handleMoveHit(drawing, e, x, y, null, false, pageIndex, true);
} else {
if (hit_in_text_rect) {
var all_drawings = shape.getDocContent().Get_AllDrawingObjects();
var drawings2 = [];
for (var i = 0; i < all_drawings.length; ++i) {
drawings2.push(all_drawings[i].GraphicObj);
}
ret = handleInlineObjects(drawingObjectsController, drawings2, e, x, y, pageIndex, true);
if (ret) {
return ret;
}
return drawingObjectsController.handleTextHit(shape, e, x, y, drawing, pageIndex, bWord);
}
}
}
function handleGroup(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord) {
var grouped_objects = drawing.getArrGraphicObjects();
var ret;
for (var j = grouped_objects.length - 1; j > -1; --j) {
var cur_grouped_object = grouped_objects[j];
switch (cur_grouped_object.getObjectType()) {
case historyitem_type_Shape:
case historyitem_type_ImageShape:
ret = handleShapeImageInGroup(drawingObjectsController, drawing, cur_grouped_object, e, x, y, pageIndex, bWord);
if (ret) {
return ret;
}
break;
case historyitem_type_ChartSpace:
var ret, i, title;
if (cur_grouped_object.hit(x, y)) {
var chart_titles = cur_grouped_object.getAllTitles();
for (i = 0; i < chart_titles.length; ++i) {
title = chart_titles[i];
var hit_in_inner_area = title.hitInInnerArea(x, y);
var hit_in_path = title.hitInPath(x, y);
var hit_in_text_rect = title.hitInTextRect(x, y);
if (hit_in_inner_area && !hit_in_text_rect || hit_in_path) {
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
drawingObjectsController.checkChartTextSelection();
drawingObjectsController.resetSelection();
drawingObjectsController.selectObject(drawing, pageIndex);
drawingObjectsController.selection.groupSelection = drawing;
drawing.selectObject(cur_grouped_object, pageIndex);
drawing.chartSelection = cur_grouped_object;
drawing.selection.title = title;
cur_grouped_object.selectTitle(title, pageIndex);
drawingObjectsController.updateSelectionState();
return true;
} else {
return {
objectId: drawing.Get_Id(),
cursorType: "move",
bMarker: false
};
}
} else {
if (hit_in_text_rect) {
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
drawingObjectsController.checkChartTextSelection();
drawingObjectsController.resetSelection();
drawingObjectsController.selectObject(drawing, pageIndex);
drawingObjectsController.selection.groupSelection = drawing;
drawing.selectObject(cur_grouped_object, pageIndex);
drawing.selection.chartSelection = cur_grouped_object;
cur_grouped_object.selectTitle(title, pageIndex);
cur_grouped_object.selection.textSelection = title;
title.selectionSetStart(e, x, y, pageIndex);
drawingObjectsController.changeCurrentState(new TextAddState(drawingObjectsController, title));
if (e.ClickCount <= 1) {
drawingObjectsController.updateSelectionState();
}
return true;
} else {
if (drawingObjectsController.document) {
var content = title.getDocContent();
var invert_transform_text = title.invertTransformText,
tx, ty;
if (content && invert_transform_text) {
tx = invert_transform_text.TransformPointX(x, y);
ty = invert_transform_text.TransformPointY(x, y);
content.Update_CursorType(tx, ty, pageIndex);
}
}
return {
objectId: drawing.Get_Id(),
cursorType: "text"
};
}
}
}
}
}
ret = handleShapeImageInGroup(drawingObjectsController, drawing, cur_grouped_object, e, x, y, pageIndex, bWord);
if (ret) {
return ret;
}
break;
}
}
return false;
}
function handleChart(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord) {
var ret, i, title;
if (drawing.hit(x, y)) {
var chart_titles = drawing.getAllTitles();
var selector = group ? group : drawingObjectsController;
for (i = 0; i < chart_titles.length; ++i) {
title = chart_titles[i];
var hit_in_inner_area = title.hitInInnerArea(x, y);
var hit_in_path = title.hitInPath(x, y);
var hit_in_text_rect = title.hitInTextRect(x, y);
if (hit_in_inner_area && !hit_in_text_rect || hit_in_path) {
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
var is_selected = drawing.selected;
drawingObjectsController.checkChartTextSelection();
selector.resetSelection();
selector.selectObject(drawing, pageIndex);
selector.selection.chartSelection = drawing;
drawing.selectTitle(title, pageIndex);
drawingObjectsController.updateSelectionState();
return true;
} else {
return {
objectId: drawing.Get_Id(),
cursorType: "move",
bMarker: false
};
}
} else {
if (hit_in_text_rect) {
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
drawingObjectsController.checkChartTextSelection();
selector.resetSelection();
selector.selectObject(drawing, pageIndex);
selector.selection.chartSelection = drawing;
drawing.selectTitle(title, pageIndex);
drawing.selection.textSelection = title;
title.selectionSetStart(e, x, y, pageIndex);
drawingObjectsController.changeCurrentState(new TextAddState(drawingObjectsController, title));
if (e.ClickCount <= 1) {
drawingObjectsController.updateSelectionState();
}
return true;
} else {
if (drawingObjectsController.document) {
var content = title.getDocContent();
var invert_transform_text = title.invertTransformText,
tx, ty;
if (content && invert_transform_text) {
tx = invert_transform_text.TransformPointX(x, y);
ty = invert_transform_text.TransformPointY(x, y);
content.Update_CursorType(tx, ty, pageIndex);
}
}
return {
objectId: drawing.Get_Id(),
cursorType: "text",
title: title
};
}
}
}
}
}
ret = handleShapeImage(drawing, drawingObjectsController, e, x, y, group, pageIndex, bWord);
if (ret) {
return ret;
}
return false;
}
function handleInlineShapeImage(drawing, drawingObjectsController, e, x, y, pageIndex) {
var _hit = drawing.hit && drawing.hit(x, y);
var _hit_to_path = drawing.hitInPath && drawing.hitInPath(x, y);
var b_hit_to_text = drawing.hitInTextRect && drawing.hitInTextRect(x, y);
if ((_hit && !b_hit_to_text) || _hit_to_path) {
return handleInlineHitNoText(drawing, drawingObjectsController, e, x, y, pageIndex);
} else {
if (b_hit_to_text) {
var all_drawings = drawing.getDocContent().Get_AllDrawingObjects();
var drawings2 = [];
for (var i = 0; i < all_drawings.length; ++i) {
drawings2.push(all_drawings[i].GraphicObj);
}
var ret = handleInlineObjects(drawingObjectsController, drawings2, e, x, y, pageIndex, true);
if (ret) {
return ret;
}
return drawingObjectsController.handleTextHit(drawing, e, x, y, null, pageIndex, true);
}
}
}
function handleInlineChart(drawing, drawingObjectsController, e, x, y, pageIndex) {
if (drawing.hit(x, y)) {
var ret, i, title;
var chart_titles = drawing.getAllTitles();
for (i = 0; i < chart_titles.length; ++i) {
title = chart_titles[i];
var hit_in_inner_area = title.hitInInnerArea(x, y);
var hit_in_path = title.hitInPath(x, y);
var hit_in_text_rect = title.hitInTextRect(x, y);
if (hit_in_inner_area && !hit_in_text_rect || hit_in_path) {
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
var is_selected = drawing.selected;
drawingObjectsController.checkChartTextSelection();
drawingObjectsController.resetSelection();
drawingObjectsController.selectObject(drawing, pageIndex);
drawingObjectsController.selection.chartSelection = drawing;
drawing.selectTitle(title, pageIndex);
drawingObjectsController.updateSelectionState();
return true;
} else {
return {
objectId: drawing.Get_Id(),
cursorType: "move",
bMarker: false
};
}
} else {
if (hit_in_text_rect) {
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
drawingObjectsController.checkChartTextSelection();
drawingObjectsController.resetSelection();
drawingObjectsController.selectObject(drawing, pageIndex);
drawingObjectsController.selection.chartSelection = drawing;
drawing.selectTitle(title, pageIndex);
drawing.selection.textSelection = title;
title.selectionSetStart(e, x, y, pageIndex);
drawingObjectsController.changeCurrentState(new TextAddState(drawingObjectsController, title));
if (e.ClickCount <= 1) {
drawingObjectsController.updateSelectionState();
}
return true;
} else {
if (drawingObjectsController.document) {
var content = title.getDocContent();
var invert_transform_text = title.invertTransformText,
tx, ty;
if (content && invert_transform_text) {
tx = invert_transform_text.TransformPointX(x, y);
ty = invert_transform_text.TransformPointY(x, y);
content.Update_CursorType(tx, ty, pageIndex);
}
}
return {
objectId: drawing.Get_Id(),
cursorType: "text",
title: title
};
}
}
}
}
}
return handleInlineShapeImage(drawing, drawingObjectsController, e, x, y, pageIndex);
}
function handleInlineHitNoText(drawing, drawingObjects, e, x, y, pageIndex) {
var selected_objects = drawingObjects.selectedObjects;
if (! (e.CtrlKey || e.ShiftKey) || selected_objects.length === 0 || selected_objects.length === 1 && selected_objects[0] === drawing) {
if (drawingObjects.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
var bIsSelected = drawing.selected;
drawingObjects.checkChartTextSelection();
drawingObjects.resetSelection();
drawing.select(drawingObjects, pageIndex);
drawingObjects.changeCurrentState(new PreMoveInlineObject(drawingObjects, drawing, bIsSelected, true, pageIndex, x, y));
if (e.ClickCount > 1 && !e.ShiftKey && !e.CtrlKey && ((drawingObjects.selection.groupSelection && drawingObjects.selection.groupSelection.selectedObjects.length === 1) || drawingObjects.selectedObjects.length === 1) && drawing.getObjectType() === historyitem_type_ChartSpace && drawingObjects.handleChartDoubleClick) {
drawingObjects.handleChartDoubleClick(drawing.parent, drawing, e, x, y, pageIndex);
}
drawingObjects.updateOverlay();
return true;
} else {
return {
objectId: drawing.Get_Id(),
cursorType: "move"
};
}
}
if (drawingObjects.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
return {
objectId: drawing.Get_Id(),
cursorType: "move"
};
}
return false;
}
function handleInlineObjects(drawingObjectsController, drawingArr, e, x, y, pageIndex, bWord) {
var i;
var drawing, ret;
for (i = drawingArr.length - 1; i > -1; --i) {
drawing = drawingArr[i];
switch (drawing.getObjectType()) {
case historyitem_type_Shape:
case historyitem_type_ImageShape:
ret = handleInlineShapeImage(drawing, drawingObjectsController, e, x, y, pageIndex);
if (ret) {
return ret;
}
break;
case historyitem_type_ChartSpace:
ret = handleInlineChart(drawing, drawingObjectsController, e, x, y, pageIndex);
if (ret) {
return ret;
}
break;
case historyitem_type_GroupShape:
ret = handleGroup(drawing, drawingObjectsController, e, x, y, null, pageIndex, bWord);
if (ret) {
return ret;
}
break;
}
}
return false;
}
function handleMouseUpPreMoveState(drawingObjects, e, x, y, pageIndex, bWord) {
var state = drawingObjects.curState;
state.drawingObjects.clearPreTrackObjects();
state.drawingObjects.changeCurrentState(new NullState(state.drawingObjects));
if (!state.shift && !state.ctrl && state.bInside && state.majorObjectIsSelected && e.Button !== g_mouse_button_right) {
switch (state.majorObject.getObjectType()) {
case historyitem_type_GroupShape:
state.drawingObjects.checkChartTextSelection();
state.drawingObjects.resetSelection();
state.drawingObjects.selectObject(state.majorObject, pageIndex);
state.drawingObjects.selection.groupSelection = state.majorObject;
state.drawingObjects.OnMouseDown(e, x, y, pageIndex);
state.drawingObjects.OnMouseUp(e, x, y, pageIndex);
state.drawingObjects.drawingObjects && state.drawingObjects.drawingObjects.sendGraphicObjectProps && state.drawingObjects.drawingObjects.sendGraphicObjectProps();
state.drawingObjects.document && state.drawingObjects.document.Document_UpdateInterfaceState();
break;
case historyitem_type_ChartSpace:
break;
}
}
}
function handleFloatTable(drawing, drawingObjectsController, e, x, y, group, pageIndex) {
if (drawing.hitInBoundingRect(x, y)) {
return drawingObjectsController.handleMoveHit(drawing, e, x, y, group, false, pageIndex, false);
} else {
if (drawing.hitInInnerArea(x, y)) {
var content, invert_transform_text, tx, ty, hit_paragraph, par, check_hyperlink;
if (drawingObjectsController.handleEventMode === HANDLE_EVENT_MODE_HANDLE) {
drawingObjectsController.resetSelection(true);
(group ? group : drawingObjectsController).selectObject(drawing, pageIndex);
if (!group) {
drawingObjectsController.selection.textSelection = drawing;
drawing.selectionSetStart(e, x, y, pageIndex);
} else {
group.selection.textSelection = drawing;
drawing.selectionSetStart(e, x, y, pageIndex);
drawingObjectsController.selectObject(group, pageIndex);
drawingObjectsController.selection.groupSelection = group;
}
drawingObjectsController.changeCurrentState(new TextAddState(drawingObjectsController, drawing));
return true;
} else {
drawing.updateCursorType(x, y, e);
return {
objectId: drawing.Get_Id(),
cursorType: "text",
updated: true
};
}
}
}
return false;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,797 @@
/*
* (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 CImageShape() {
this.nvPicPr = null;
this.spPr = new CSpPr();
this.blipFill = null;
this.style = null;
this.parent = null;
this.group = null;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.rot = null;
this.flipH = null;
this.flipV = null;
this.transform = new CMatrix();
this.invertTransform = null;
this.cursorTypes = [];
this.brush = null;
this.pen = null;
this.bDeleted = true;
this.selected = false;
this.snapArrayX = [];
this.snapArrayY = [];
this.setRecalculateInfo();
this.Lock = new CLock();
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
CImageShape.prototype = {
Get_Id: function () {
return this.Id;
},
getObjectType: function () {
return historyitem_type_ImageShape;
},
Write_ToBinary2: function (w) {
w.WriteLong(this.getObjectType());
w.WriteString2(this.Get_Id());
},
Read_FromBinary2: function (r) {
this.Id = r.GetString2();
},
setBDeleted: function (pr) {
History.Add(this, {
Type: historyitem_ShapeSetBDeleted,
oldPr: this.bDeleted,
newPr: pr
});
this.bDeleted = pr;
},
setNvPicPr: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetNvPicPr,
oldPr: this.nvPicPr,
newPr: pr
});
this.nvPicPr = pr;
},
setSpPr: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetSpPr,
oldPr: this.spPr,
newPr: pr
});
this.spPr = pr;
},
setBlipFill: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetBlipFill,
oldPr: this.blipFill,
newPr: pr
});
this.blipFill = pr;
},
setParent: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetParent,
oldPr: this.parent,
newPr: pr
});
this.parent = pr;
},
setGroup: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetGroup,
oldPr: this.group,
newPr: pr
});
this.group = pr;
},
setStyle: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetStyle,
oldPr: this.style,
newPr: pr
});
this.style = pr;
},
copy: function () {
var copy = new CImageShape();
if (this.nvPicPr) {
copy.setNvPicPr(this.nvPicPr.createDuplicate());
}
if (this.spPr) {
copy.setSpPr(this.spPr.createDuplicate());
copy.spPr.setParent(copy);
}
if (this.blipFill) {
copy.setBlipFill(this.blipFill.createDuplicate());
}
if (this.style) {
copy.setStyle(this.style.createDuplicate());
}
copy.setBDeleted(this.bDeleted);
copy.cachedImage = this.getBase64Img();
return copy;
},
getImageUrl: function () {
if (isRealObject(this.blipFill)) {
return this.blipFill.RasterImageId;
}
return null;
},
isSimpleObject: function () {
return true;
},
getSnapArrays: function (snapX, snapY) {
var transform = this.getTransformMatrix();
snapX.push(transform.tx);
snapX.push(transform.tx + this.extX * 0.5);
snapX.push(transform.tx + this.extX);
snapY.push(transform.ty);
snapY.push(transform.ty + this.extY * 0.5);
snapY.push(transform.ty + this.extY);
},
getBoundsInGroup: function () {
return getBoundsInGroup(this);
},
normalize: CShape.prototype.normalize,
checkHitToBounds: CShape.prototype.checkHitToBounds,
calculateSnapArrays: CShape.prototype.calculateSnapArrays,
checkDrawingBaseCoords: CShape.prototype.checkDrawingBaseCoords,
setDrawingBaseCoords: CShape.prototype.setDrawingBaseCoords,
sendMouseData: function () {
if (true === this.Lock.Is_Locked()) {
var MMData = new CMouseMoveData();
var Coords = editor.WordControl.m_oLogicDocument.DrawingDocument.ConvertCoordsToCursorWR(this.x, this.y, this.parent.num, null);
MMData.X_abs = Coords.X - 5;
MMData.Y_abs = Coords.Y;
MMData.Type = c_oAscMouseMoveDataTypes.LockedObject;
MMData.UserId = this.Lock.Get_UserId();
MMData.HaveChanges = this.Lock.Have_Changes();
MMData.LockedObjectType = 0;
editor.sync_MouseMoveCallback(MMData);
}
},
isPlaceholder: function () {
return this.nvPicPr != null && this.nvPicPr.nvPr != undefined && this.nvPicPr.nvPr.ph != undefined;
},
isEmptyPlaceholder: function () {
return false;
},
isShape: function () {
return false;
},
isImage: function () {
return true;
},
isChart: function () {
return false;
},
isGroup: function () {
return false;
},
hitToAdj: function (x, y) {
return {
hit: false,
num: -1,
polar: false
};
},
getParentObjects: CShape.prototype.getParentObjects,
hitInPath: CShape.prototype.hitInPath,
hitInInnerArea: CShape.prototype.hitInInnerArea,
getRotateAngle: CShape.prototype.getRotateAngle,
changeSize: CShape.prototype.changeSize,
getFullFlipH: function () {
if (!isRealObject(this.group)) {
return this.flipH;
}
return this.group.getFullFlipH() ? !this.flipH : this.flipH;
},
getFullFlipV: function () {
if (!isRealObject(this.group)) {
return this.flipV;
}
return this.group.getFullFlipV() ? !this.flipV : this.flipV;
},
getAspect: function (num) {
var _tmp_x = this.extX != 0 ? this.extX : 0.1;
var _tmp_y = this.extY != 0 ? this.extY : 0.1;
return num === 0 || num === 4 ? _tmp_x / _tmp_y : _tmp_y / _tmp_x;
},
getFullRotate: function () {
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
},
getRectBounds: function () {
var transform = this.getTransformMatrix();
var w = this.extX;
var h = this.extY;
var rect_points = [{
x: 0,
y: 0
},
{
x: w,
y: 0
},
{
x: w,
y: h
},
{
x: 0,
y: h
}];
var min_x, max_x, min_y, max_y;
min_x = transform.TransformPointX(rect_points[0].x, rect_points[0].y);
min_y = transform.TransformPointY(rect_points[0].x, rect_points[0].y);
max_x = min_x;
max_y = min_y;
var cur_x, cur_y;
for (var i = 1; i < 4; ++i) {
cur_x = transform.TransformPointX(rect_points[i].x, rect_points[i].y);
cur_y = transform.TransformPointY(rect_points[i].x, rect_points[i].y);
if (cur_x < min_x) {
min_x = cur_x;
}
if (cur_x > max_x) {
max_x = cur_x;
}
if (cur_y < min_y) {
min_y = cur_y;
}
if (cur_y > max_y) {
max_y = cur_y;
}
}
return {
minX: min_x,
maxX: max_x,
minY: min_y,
maxY: max_y
};
},
canRotate: function () {
return true;
},
canResize: function () {
return true;
},
canMove: function () {
return true;
},
canGroup: function () {
return true;
},
canChangeAdjustments: function () {
return true;
},
createRotateTrack: function () {
return new RotateTrackShapeImage(this);
},
createResizeTrack: function (cardDirection) {
return new ResizeTrackShapeImage(this, cardDirection);
},
createMoveTrack: function () {
return new MoveShapeImageTrack(this);
},
createRotateInGroupTrack: function () {
return new RotateTrackShapeImageInGroup(this);
},
createResizeInGroupTrack: function (cardDirection) {
return new ResizeTrackShapeImageInGroup(this, cardDirection);
},
createMoveInGroupTrack: function () {
return new MoveShapeImageTrackInGroup(this);
},
getInvertTransform: function () {
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.recalcInfo.recalculateTransform = true;
}
return this.invertTransform;
},
hitInTextRect: function (x, y) {
return false;
},
getBase64Img: CShape.prototype.getBase64Img,
convertToWord: function (document) {
this.setBDeleted(true);
var oCopy = this.copy();
oCopy.setBDeleted(false);
return oCopy;
},
convertToPPTX: function (drawingDocument, worksheet) {
var ret = this.copy();
ret.setWorksheet(worksheet);
ret.setParent(null);
ret.setBDeleted(false);
return ret;
},
recalculateBrush: function () {
var is_on = History.Is_On();
if (is_on) {
History.TurnOff();
}
this.brush = new CUniFill();
this.brush.setFill(this.blipFill);
if (is_on) {
History.TurnOn();
}
},
recalculatePen: function () {},
getAllRasterImages: function (images) {
this.blipFill && typeof this.blipFill.RasterImageId === "string" && this.blipFill.RasterImageId.length > 0 && images.push(this.blipFill.RasterImageId);
},
getHierarchy: function () {
if (this.recalcInfo.recalculateShapeHierarchy) {
this.compiledHierarchy.length = 0;
var hierarchy = this.compiledHierarchy;
if (this.isPlaceholder()) {
var ph_type = this.getPlaceholderType();
var ph_index = this.getPlaceholderIndex();
var b_is_single_body = this.getIsSingleBody();
switch (this.parent.kind) {
case SLIDE_KIND:
hierarchy.push(this.parent.Layout.getMatchingShape(ph_type, ph_index, b_is_single_body));
hierarchy.push(this.parent.Layout.Master.getMatchingShape(ph_type, ph_index, b_is_single_body));
break;
case LAYOUT_KIND:
hierarchy.push(this.parent.Master.getMatchingShape(ph_type, ph_index, b_is_single_body));
break;
}
}
this.recalcInfo.recalculateShapeHierarchy = true;
}
return this.compiledHierarchy;
},
recalculateTransform: function () {
this.cachedImage = null;
if (!isRealObject(this.group)) {
if (this.spPr.xfrm.isNotNull()) {
var xfrm = this.spPr.xfrm;
this.x = xfrm.offX;
this.y = xfrm.offY;
this.extX = xfrm.extX;
this.extY = xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
this.flipH = xfrm.flipH === true;
this.flipV = xfrm.flipV === true;
} else {
if (this.isPlaceholder()) {
var hierarchy = this.getHierarchy();
for (var i = 0; i < hierarchy.length; ++i) {
var hierarchy_sp = hierarchy[i];
if (isRealObject(hierarchy_sp) && hierarchy_sp.spPr.xfrm.isNotNull()) {
var xfrm = hierarchy_sp.spPr.xfrm;
this.x = xfrm.offX;
this.y = xfrm.offY;
this.extX = xfrm.extX;
this.extY = xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
this.flipH = xfrm.flipH === true;
this.flipV = xfrm.flipV === true;
break;
}
}
if (i === hierarchy.length) {
this.x = 0;
this.y = 0;
this.extX = 5;
this.extY = 5;
this.rot = 0;
this.flipH = false;
this.flipV = false;
}
} else {
this.x = 0;
this.y = 0;
this.extX = 5;
this.extY = 5;
this.rot = 0;
this.flipH = false;
this.flipV = false;
}
}
} else {
var xfrm;
if (this.spPr.xfrm.isNotNull()) {
xfrm = this.spPr.xfrm;
} else {
if (this.isPlaceholder()) {
var hierarchy = this.getHierarchy();
for (var i = 0; i < hierarchy.length; ++i) {
var hierarchy_sp = hierarchy[i];
if (isRealObject(hierarchy_sp) && hierarchy_sp.spPr.xfrm.isNotNull()) {
xfrm = hierarchy_sp.spPr.xfrm;
break;
}
}
if (i === hierarchy.length) {
xfrm = new CXfrm();
xfrm.offX = 0;
xfrm.offX = 0;
xfrm.extX = 5;
xfrm.extY = 5;
}
} else {
xfrm = new CXfrm();
xfrm.offX = 0;
xfrm.offY = 0;
xfrm.extX = 5;
xfrm.extY = 5;
}
}
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
this.x = scale_scale_coefficients.cx * (xfrm.offX - this.group.spPr.xfrm.chOffX);
this.y = scale_scale_coefficients.cy * (xfrm.offY - this.group.spPr.xfrm.chOffY);
this.extX = scale_scale_coefficients.cx * xfrm.extX;
this.extY = scale_scale_coefficients.cy * xfrm.extY;
this.rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
this.flipH = xfrm.flipH === true;
this.flipV = xfrm.flipV === true;
}
this.transform.Reset();
var hc = this.extX * 0.5;
var vc = this.extY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (this.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
}
if (this.flipV) {
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(this.transform, -this.rot);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
if (isRealObject(this.group)) {
global_MatrixTransformer.MultiplyAppend(this.transform, this.group.getTransformMatrix());
}
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
if (this.drawingBase && !this.group) {
this.drawingBase.setGraphicObjectCoords();
}
},
Refresh_RecalcData: function (data) {
switch (data.Type) {
case historyitem_ImageShapeSetBlipFill:
this.recalcBrush();
this.recalcFill();
this.addToRecalculate();
break;
}
},
recalculateGeometry: function () {
if (isRealObject(this.spPr.geometry)) {
var transform = this.getTransform();
this.spPr.geometry.Recalculate(transform.extX, transform.extY);
}
},
getTransformMatrix: function () {
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
return this.transform;
},
getTransform: function () {
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.recalcInfo.recalculateTransform = false;
}
return {
x: this.x,
y: this.y,
extX: this.extX,
extY: this.extY,
rot: this.rot,
flipH: this.flipH,
flipV: this.flipV
};
},
draw: function (graphics, transform) {
if (graphics.updatedRect) {
var rect = graphics.updatedRect;
var bounds = this.bounds;
if (bounds.x > rect.x + rect.w || bounds.y > rect.y + rect.h || bounds.x + bounds.w < rect.x || bounds.y + bounds.h < rect.y) {
return;
}
}
var _transform = transform ? transform : this.transform;
graphics.SetIntegerGrid(false);
graphics.transform3(_transform, false);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape2(this, graphics, this.spPr.geometry);
shape_drawer.draw(this.spPr.geometry);
if (locktype_None != this.Lock.Get_Type() && !this.group) {
graphics.DrawLockObjectRect(this.Lock.Get_Type(), 0, 0, this.extX, this.extY);
}
graphics.reset();
graphics.SetIntegerGrid(true);
},
select: CShape.prototype.select,
recalculateLocalTransform: CShape.prototype.recalculateLocalTransform,
deselect: function (drawingObjectsController) {
this.selected = false;
var selected_objects;
if (!isRealObject(this.group)) {
selected_objects = drawingObjectsController.selectedObjects;
} else {
selected_objects = this.group.getMainGroup().selectedObjects;
}
for (var i = 0; i < selected_objects.length; ++i) {
if (selected_objects[i] === this) {
selected_objects.splice(i, 1);
break;
}
}
return this;
},
getMainGroup: function () {
if (!isRealObject(this.group)) {
return null;
}
var cur_group = this.group;
while (isRealObject(cur_group.group)) {
cur_group = cur_group.group;
}
return cur_group;
},
drawAdjustments: function (drawingDocument) {},
hitToAdjustment: function () {
return {
hit: false
};
},
getPlaceholderType: function () {
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.type : null;
},
getPlaceholderIndex: function () {
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.idx : null;
},
getPhType: function () {
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.type : null;
},
getPhIndex: function () {
return this.isPlaceholder() ? this.nvPicPr.nvPr.ph.idx : null;
},
setNvSpPr: function (pr) {
History.Add(this, {
Type: historyitem_ImageShapeSetNvPicPr,
oldPr: this.nvPicPr,
newPr: pr
});
this.nvPicPr = pr;
},
getAllImages: function (images) {
if (this.blipFill instanceof CBlipFill && typeof this.blipFill.RasterImageId === "string") {
images[_getFullImageSrc(this.blipFill.RasterImageId)] = true;
}
},
Undo: function (data) {
switch (data.Type) {
case historyitem_AutoShapes_RemoveFromDrawingObjects:
addToDrawings(this.worksheet, this, data.Pos);
break;
case historyitem_AutoShapes_AddToDrawingObjects:
deleteDrawingBase(this.worksheet.Drawings, this.Get_Id());
break;
case historyitem_AutoShapes_SetWorksheet:
this.worksheet = data.oldPr;
break;
case historyitem_ShapeSetBDeleted:
this.bDeleted = data.oldPr;
break;
case historyitem_ImageShapeSetNvPicPr:
this.nvPicPr = data.oldPr;
break;
case historyitem_ImageShapeSetSpPr:
this.spPr = data.oldPr;
break;
case historyitem_ImageShapeSetBlipFill:
this.blipFill = data.oldPr;
break;
case historyitem_ImageShapeSetParent:
this.parent = data.oldPr;
break;
case historyitem_ImageShapeSetGroup:
this.group = data.oldPr;
break;
case historyitem_ImageShapeSetStyle:
this.style = data.oldPr;
break;
}
},
Redo: function (data) {
switch (data.Type) {
case historyitem_AutoShapes_RemoveFromDrawingObjects:
deleteDrawingBase(this.worksheet.Drawings, this.Get_Id());
break;
case historyitem_AutoShapes_AddToDrawingObjects:
addToDrawings(this.worksheet, this, data.Pos);
break;
case historyitem_AutoShapes_SetWorksheet:
this.worksheet = data.newPr;
break;
case historyitem_ShapeSetBDeleted:
this.bDeleted = data.newPr;
break;
case historyitem_ImageShapeSetNvPicPr:
this.nvPicPr = data.newPr;
break;
case historyitem_ImageShapeSetSpPr:
this.spPr = data.newPr;
break;
case historyitem_ImageShapeSetBlipFill:
this.blipFill = data.newPr;
break;
case historyitem_ImageShapeSetParent:
this.parent = data.newPr;
break;
case historyitem_ImageShapeSetGroup:
this.group = data.newPr;
break;
case historyitem_ImageShapeSetStyle:
this.style = data.newPr;
break;
}
},
Save_Changes: function (data, w) {
w.WriteLong(data.Type);
switch (data.Type) {
case historyitem_AutoShapes_SetDrawingBaseCoors:
writeDouble(w, data.fromCol);
writeDouble(w, data.fromColOff);
writeDouble(w, data.fromRow);
writeDouble(w, data.fromRowOff);
writeDouble(w, data.toCol);
writeDouble(w, data.toColOff);
writeDouble(w, data.toRow);
writeDouble(w, data.toRowOff);
writeDouble(w, data.posX);
writeDouble(w, data.posY);
writeDouble(w, data.cx);
writeDouble(w, data.cy);
break;
case historyitem_AutoShapes_RemoveFromDrawingObjects:
break;
case historyitem_AutoShapes_AddToDrawingObjects:
var Pos = data.UseArray ? data.PosArray[0] : data.Pos;
writeLong(w, Pos);
break;
case historyitem_AutoShapes_SetWorksheet:
writeBool(w, isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
writeString(w, data.newPr.getId());
}
break;
case historyitem_ImageShapeSetNvPicPr:
case historyitem_ImageShapeSetSpPr:
case historyitem_ImageShapeSetParent:
case historyitem_ImageShapeSetGroup:
case historyitem_ImageShapeSetStyle:
writeObject(w, data.newPr);
break;
case historyitem_ShapeSetBDeleted:
writeBool(w, data.newPr);
break;
case historyitem_ImageShapeSetBlipFill:
w.WriteBool(isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
data.newPr.Write_ToBinary(w);
}
break;
}
},
Load_Changes: function (r) {
var type = r.GetLong();
switch (type) {
case historyitem_AutoShapes_SetDrawingBaseCoors:
if (this.drawingBase) {
this.drawingBase.from.col = readDouble(r);
this.drawingBase.from.colOff = readDouble(r);
this.drawingBase.from.row = readDouble(r);
this.drawingBase.from.rowOff = readDouble(r);
this.drawingBase.to.col = readDouble(r);
this.drawingBase.to.colOff = readDouble(r);
this.drawingBase.to.row = readDouble(r);
this.drawingBase.to.rowOff = readDouble(r);
this.drawingBase.Pos.X = readDouble(r);
this.drawingBase.Pos.Y = readDouble(r);
this.drawingBase.ext.cx = readDouble(r);
this.drawingBase.ext.cy = readDouble(r);
}
break;
case historyitem_AutoShapes_RemoveFromDrawingObjects:
deleteDrawingBase(this.worksheet.Drawings, this.Get_Id());
break;
case historyitem_AutoShapes_AddToDrawingObjects:
var pos = readLong(r);
if (this.worksheet) {
pos = this.worksheet.contentChanges.Check(contentchanges_Add, pos);
}
addToDrawings(this.worksheet, this, pos);
break;
case historyitem_AutoShapes_SetWorksheet:
ReadWBModel(this, r);
break;
case historyitem_ShapeSetBDeleted:
this.bDeleted = readBool(r);
break;
case historyitem_ImageShapeSetNvPicPr:
this.nvPicPr = readObject(r);
break;
case historyitem_ImageShapeSetSpPr:
this.spPr = readObject(r);
break;
case historyitem_ImageShapeSetBlipFill:
if (r.GetBool()) {
this.blipFill = new CBlipFill();
r.GetLong();
this.blipFill.Read_FromBinary(r);
if (typeof CollaborativeEditing !== "undefined") {
if (typeof this.blipFill.RasterImageId === "string" && this.blipFill.RasterImageId.length > 0) {
var full_image_src_func;
if ((!editor || !editor.isDocumentEditor && !editor.isPresentationEditor) && typeof getFullImageSrc === "function") {
full_image_src_func = getFullImageSrc;
} else {
if (typeof _getFullImageSrc === "function") {
full_image_src_func = _getFullImageSrc;
}
}
if (full_image_src_func) {
CollaborativeEditing.Add_NewImage(full_image_src_func(this.blipFill.RasterImageId));
}
}
}
} else {
this.blipFill = null;
}
this.handleUpdateFill();
break;
case historyitem_ImageShapeSetParent:
this.parent = readObject(r);
break;
case historyitem_ImageShapeSetGroup:
this.group = readObject(r);
break;
case historyitem_ImageShapeSetStyle:
this.style = readObject(r);
break;
}
},
Load_LinkData: function (linkData) {}
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,619 @@
/*
* (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 field_type_slidenum = 0;
var field_type_datetime = 1;
var field_type_datetime1 = 2;
var field_type_datetime2 = 3;
var field_type_datetime3 = 4;
var field_type_datetime4 = 5;
var field_type_datetime5 = 6;
var field_type_datetime6 = 7;
var field_type_datetime7 = 8;
var field_type_datetime8 = 9;
var field_type_datetime9 = 10;
var field_type_datetime10 = 11;
var field_type_datetime11 = 12;
var field_type_datetime12 = 13;
var field_type_datetime13 = 14;
var pHText = [];
pHText[0] = [];
pHText[0][phType_body] = "Slide text";
pHText[0][phType_chart] = "Chart";
pHText[0][phType_clipArt] = "ClipArt";
pHText[0][phType_ctrTitle] = "Slide title";
pHText[0][phType_dgm] = "Diagram";
pHText[0][phType_dt] = "Date and time";
pHText[0][phType_ftr] = "Footer";
pHText[0][phType_hdr] = "Header";
pHText[0][phType_media] = "Media";
pHText[0][phType_obj] = "Slide text";
pHText[0][phType_pic] = "Picture";
pHText[0][phType_sldImg] = "Image";
pHText[0][phType_sldNum] = "Slide number";
pHText[0][phType_subTitle] = "Slide subtitle";
pHText[0][phType_tbl] = "Table";
pHText[0][phType_title] = "Slide title";
var field_months = [];
field_months[0] = [];
field_months[0][0] = "января";
field_months[0][1] = "февраля";
field_months[0][2] = "марта";
field_months[0][3] = "апреля";
field_months[0][4] = "мая";
field_months[0][5] = "июня";
field_months[0][6] = "июля";
field_months[0][7] = "августа";
field_months[0][8] = "сентября";
field_months[0][9] = "октября";
field_months[0][10] = "ноября";
field_months[0][11] = "декабря";
var nOTClip = 0;
var nOTEllipsis = 1;
var nOTOwerflow = 2;
var nTextATB = 0;
var nTextATCtr = 1;
var nTextATDist = 2;
var nTextATJust = 3;
var nTextATT = 4;
var nVertTTeaVert = 0;
var nVertTThorz = 1;
var nVertTTmongolianVert = 2;
var nVertTTvert = 3;
var nVertTTvert270 = 4;
var nVertTTwordArtVert = 5;
var nVertTTwordArtVertRtl = 6;
var nTWTNone = 0;
var nTWTSquare = 1;
function CTextBody() {
this.bodyPr = null;
this.lstStyle = null;
this.content = null;
this.parent = null;
this.content2 = null;
this.compiledBodyPr = null;
this.parent = null;
this.recalcInfo = {
recalculateBodyPr: true,
recalculateContent2: true
};
this.textPropsForRecalc = [];
this.bRecalculateNumbering = true;
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.Add(this, this.Id);
}
CTextBody.prototype = {
createDuplicate: function () {
var ret = new CTextBody();
if (this.bodyPr) {
ret.setBodyPr(this.bodyPr.createDuplicate());
}
if (this.lstStyle) {
ret.setLstStyle(this.lstStyle.createDuplicate());
}
if (this.content) {
ret.setContent(this.content.Copy(ret, NEW_WORKSHEET_DRAWING_DOCUMENT));
}
return ret;
},
createDuplicate2: function () {
var ret = new CTextBody();
if (this.bodyPr) {
ret.setBodyPr(this.bodyPr.createDuplicate());
}
if (this.lstStyle) {
ret.setLstStyle(this.lstStyle.createDuplicate());
}
if (this.content) {
ret.setContent(this.content.Copy3(ret));
}
return ret;
},
Get_Id: function () {
return this.Id;
},
Is_TopDocument: function () {
return false;
},
Is_DrawingShape: function () {
return true;
},
Get_Theme: function () {
return this.parent.Get_Theme();
},
Get_ColorMap: function () {
return this.parent.Get_ColorMap();
},
setParent: function (pr) {
History.Add(this, {
Type: historyitem_TextBodySetParent,
oldPr: this.parent,
newPr: pr
});
this.parent = pr;
},
setBodyPr: function (pr) {
History.Add(this, {
Type: historyitem_TextBodySetBodyPr,
oldPr: this.bodyPr,
newPr: pr
});
this.bodyPr = pr;
if (this.parent && this.parent.recalcInfo) {
this.parent.recalcInfo.recalcContent = true;
this.parent.recalcInfo.recalcTransformText = true;
if (this.parent.addToRecalculate) {
this.parent.addToRecalculate();
}
}
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart && History && History.Is_On && History.Is_On()) {
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
}
},
setContent: function (pr) {
History.Add(this, {
Type: historyitem_TextBodySetContent,
oldPr: this.content,
newPr: pr
});
this.content = pr;
},
setLstStyle: function (lstStyle) {
History.Add(this, {
Type: historyitem_TextBodySetLstStyle,
oldPr: this.lstStyle,
newPr: lstStyle
});
this.lstStyle = lstStyle;
},
getObjectType: function () {
return historyitem_type_TextBody;
},
Undo: function (data) {
switch (data.Type) {
case historyitem_TextBodySetParent:
this.parent = data.oldPr;
break;
case historyitem_TextBodySetBodyPr:
this.bodyPr = data.oldPr;
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart) {
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
}
break;
case historyitem_TextBodySetContent:
this.content = data.oldPr;
break;
case historyitem_TextBodySetLstStyle:
this.lstStyle = data.oldPr;
break;
}
},
Redo: function (data) {
switch (data.Type) {
case historyitem_TextBodySetParent:
this.parent = data.newPr;
break;
case historyitem_TextBodySetBodyPr:
this.bodyPr = data.newPr;
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart) {
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
}
break;
case historyitem_TextBodySetContent:
this.content = data.newPr;
break;
case historyitem_TextBodySetLstStyle:
this.lstStyle = data.newPr;
break;
}
},
Save_Changes: function (data, w) {
w.WriteLong(historyitem_type_TextBody);
w.WriteLong(data.Type);
switch (data.Type) {
case historyitem_TextBodySetParent:
case historyitem_TextBodySetContent:
writeObject(w, data.newPr);
break;
case historyitem_TextBodySetBodyPr:
case historyitem_TextBodySetLstStyle:
w.WriteBool(isRealObject(data.newPr));
if (isRealObject(data.newPr)) {
data.newPr.Write_ToBinary(w);
}
break;
}
},
Load_Changes: function (r) {
if (r.GetLong() === historyitem_type_TextBody) {
var type = r.GetLong();
switch (type) {
case historyitem_TextBodySetParent:
this.parent = readObject(r);
break;
case historyitem_TextBodySetBodyPr:
if (r.GetBool()) {
this.bodyPr = new CBodyPr();
this.bodyPr.Read_FromBinary(r);
} else {
this.bodyPr = null;
}
if (this.parent && this.parent.parent && this.parent.parent.parent && this.parent.parent.parent.parent && this.parent.parent.parent.parent.parent && this.parent.parent.parent.parent.parent.handleUpdateInternalChart) {
this.parent.parent.parent.parent.parent.handleUpdateInternalChart();
}
break;
case historyitem_TextBodySetContent:
this.content = readObject(r);
break;
case historyitem_TextBodySetLstStyle:
if (r.GetBool()) {
this.lstStyle = new TextListStyle();
this.lstStyle.Read_FromBinary(r);
} else {
this.bodyPr = null;
}
break;
}
}
},
Write_ToBinary2: function (w) {
w.WriteLong(historyitem_type_TextBody);
w.WriteString2(this.Id);
},
Read_FromBinary2: function (r) {
this.Id = r.GetString2();
},
recalculate: function () {},
getFieldText: function (fieldType, slide, firstSlideNum) {
var ret = "";
if (this.parent && this.parent.isPlaceholder()) {
var _ph_type = this.parent.getPlaceholderType();
switch (_ph_type) {
case phType_dt:
var _cur_date = new Date();
var _cur_year = _cur_date.getFullYear();
var _cur_month = _cur_date.getMonth();
var _cur_month_day = _cur_date.getDate();
ret += (_cur_month_day > 9 ? _cur_month_day : "0" + _cur_month_day) + "." + ((_cur_month + 1) > 9 ? (_cur_month + 1) : "0" + (_cur_month + 1)) + "." + _cur_year;
break;
case phType_sldNum:
var _firstSlideNum = isRealNumber(firstSlideNum) ? firstSlideNum : 1;
if (slide instanceof Slide) {
ret += "" + (slide.num + _firstSlideNum);
}
break;
}
}
return ret;
},
recalculateBodyPr: function () {
ExecuteNoHistory(function () {
if (!this.compiledBodyPr) {
this.compiledBodyPr = new CBodyPr();
}
this.compiledBodyPr.setDefault();
if (this.parent && this.parent.isPlaceholder && this.parent.isPlaceholder()) {
var hierarchy = this.parent.getHierarchy();
for (var i = hierarchy.length - 1; i > -1; --i) {
if (isRealObject(hierarchy[i]) && isRealObject(hierarchy[i].txBody) && isRealObject(hierarchy[i].txBody.bodyPr)) {
this.compiledBodyPr.merge(hierarchy[i].txBody.bodyPr);
}
}
}
if (isRealObject(this.bodyPr)) {
this.compiledBodyPr.merge(this.bodyPr);
}
},
this, []);
},
checkTextFit: function () {
if (this.parent && this.parent.parent && this.parent.parent instanceof Slide) {
if (isRealObject(this.bodyPr.textFit)) {
if (this.bodyPr.textFit.type === text_fit_NormAuto) {
var text_fit = this.bodyPr.textFit;
var font_scale, spacing_scale;
if (isRealNumber(text_fit.fontScale)) {
font_scale = text_fit.fontScale / 100000;
}
if (isRealNumber(text_fit.lnSpcReduction)) {
spacing_scale = text_fit.lnSpcReduction / 100000;
}
if (isRealNumber(font_scale) || isRealNumber(spacing_scale)) {
var pars = this.content.Content;
for (var index = 0; index < pars.length; ++index) {
var parg = pars[index];
if (isRealNumber(spacing_scale)) {
var spacing2 = parg.Get_CompiledPr(false).ParaPr.Spacing;
var new_spacing = {};
var spc = spacing2.Line * spacing_scale;
new_spacing.LineRule = spacing2.LineRule;
if (isRealNumber(spc)) {
if (spacing2.LineRule === linerule_Auto) {
new_spacing.Line = spacing2.Line - spacing_scale;
} else {
new_spacing.Line = spc;
}
}
spc = spacing2.Before * spacing_scale;
if (isRealNumber(spc)) {
new_spacing.Before = spc;
}
spc = spacing2.After * spacing_scale;
if (isRealNumber(spc)) {
new_spacing.After = spc;
}
parg.Set_Spacing(new_spacing);
}
if (isRealNumber(font_scale)) {
var redFontSize = Math.round(parg.Get_CompiledPr(false).TextPr.FontSize * font_scale);
this.checkParagraphContent(parg, font_scale, true, redFontSize);
}
}
}
}
}
}
this.bodyPr.textFit = null;
},
checkParagraphContent: function (parg, fontScale, bParagraph, paragrRedFontSize) {
for (var r = 0; r < parg.Content.length; ++r) {
var item = parg.Content[r];
switch (item.Type) {
case para_Run:
if (isRealNumber(item.Pr.FontSize)) {
item.Set_FontSize(Math.round(item.Pr.FontSize * fontScale));
} else {
item.Set_FontSize(paragrRedFontSize);
}
break;
case para_Hyperlink:
this.checkParagraphContent(item, fontScale, false, paragrRedFontSize);
break;
}
}
},
Refresh_RecalcData: function () {
if (this.parent && this.parent.recalcInfo) {
this.parent.recalcInfo.recalcContent = true;
this.parent.recalcInfo.recalcTransformText = true;
this.parent.recalcInfo.recalculateContent = true;
this.parent.recalcInfo.recalculateTransformText = true;
if (this.parent.addToRecalculate) {
this.parent.addToRecalculate();
}
}
},
isEmpty: function () {
return this.content.Is_Empty();
},
OnContentReDraw: function () {},
Get_StartPage_Absolute: function () {
return 0;
},
Get_TextBackGroundColor: function () {
return undefined;
},
Is_HdrFtr: function () {
return false;
},
Get_PageContentStartPos: function (pageNum) {
return {
X: 0,
Y: 0,
XLimit: this.contentWidth,
YLimit: 20000
};
},
Get_Numbering: function () {
return new CNumbering();
},
Set_CurrentElement: function (bUpdate, pageIndex) {
if (this.parent.Set_CurrentElement) {
this.parent.Set_CurrentElement(bUpdate, pageIndex);
}
},
checkDocContent: function () {
this.parent && this.parent.checkDocContent && this.parent.checkDocContent();
},
getBodyPr: function () {
if (this.recalcInfo.recalculateBodyPr) {
this.recalculateBodyPr();
this.recalcInfo.recalculateBodyPr = false;
}
return this.compiledBodyPr;
},
getSummaryHeight: function () {
return this.content.Get_SummaryHeight();
},
getSummaryHeight2: function () {
return this.content2 ? this.content2.Get_SummaryHeight() : 0;
},
getCompiledBodyPr: function () {
this.recalculateBodyPr();
return this.compiledBodyPr;
},
Get_TableStyleForPara: function () {
return null;
},
checkCurrentPlaceholder: function () {
return false;
},
draw: function (graphics) {
if ((!this.content || this.content.Is_Empty()) && this.parent.isEmptyPlaceholder() && !this.checkCurrentPlaceholder()) {
if (graphics.IsNoDrawingEmptyPlaceholder !== true && graphics.IsNoDrawingEmptyPlaceholderText !== true && this.content2) {
if (graphics.IsNoSupportTextDraw) {
var _w2 = this.content2.XLimit;
var _h2 = this.content2.Get_SummaryHeight();
graphics.rect(this.content2.X, this.content2.Y, _w2, _h2);
}
this.content2.Set_StartPage(0);
this.content2.Draw(0, graphics);
}
} else {
if (this.content) {
if (graphics.IsNoSupportTextDraw) {
var _w = this.content.XLimit;
var _h = this.content.Get_SummaryHeight();
graphics.rect(this.content.X, this.content.Y, _w, _h);
}
var old_start_page = this.content.StartPage;
this.content.Set_StartPage(0);
this.content.Draw(0, graphics);
this.content.Set_StartPage(old_start_page);
}
}
},
Get_Styles: function (level) {
return this.parent.getStyles(level);
},
Is_Cell: function () {
return false;
},
OnContentRecalculate: function () {},
getMargins: function () {
var _parent_transform = this.parent.transform;
var _l;
var _r;
var _b;
var _t;
var _body_pr = this.getBodyPr();
var sp = this.parent;
if (isRealObject(sp.spPr) && isRealObject(sp.spPr.geometry) && isRealObject(sp.spPr.geometry.rect)) {
var _rect = sp.spPr.geometry.rect;
_l = _rect.l + _body_pr.lIns;
_t = _rect.t + _body_pr.tIns;
_r = _rect.r - _body_pr.rIns;
_b = _rect.b - _body_pr.bIns;
} else {
_l = _body_pr.lIns;
_t = _body_pr.tIns;
_r = sp.extX - _body_pr.rIns;
_b = sp.extY - _body_pr.bIns;
}
var x_lt, y_lt, x_rb, y_rb;
x_lt = _parent_transform.TransformPointX(_l, _t);
y_lt = _parent_transform.TransformPointY(_l, _t);
x_rb = _parent_transform.TransformPointX(_r, _b);
y_rb = _parent_transform.TransformPointY(_r, _b);
var hc = (_r - _l) / 2;
var vc = (_b - _t) / 2;
var xc = (x_lt + x_rb) / 2;
var yc = (y_lt + y_rb) / 2;
return {
L: xc - hc,
T: yc - vc,
R: xc + hc,
B: yc + vc,
textMatrix: this.parent.transform
};
},
Refresh_RecalcData2: function (pageIndex) {
this.parent && this.parent.Refresh_RecalcData2 && this.parent.Refresh_RecalcData2(pageIndex, this);
},
getContentOneStringSizes: function () {
this.content.Reset(0, 0, 20000, 20000);
this.content.Recalculate_Page(0, true);
return {
w: this.content.Content[0].Lines[0].Ranges[0].W + 0.1,
h: this.content.Get_SummaryHeight() + 0.1
};
},
recalculateByMaxWord: function () {
var max_content = this.content.Recalculate_MinMaxContentWidth().Max;
this.content.Set_ApplyToAll(true);
this.content.Set_ParagraphAlign(align_Center);
this.content.Set_ApplyToAll(false);
this.content.Reset(0, 0, max_content, 20000);
this.content.Recalculate_Page(0, true);
return {
w: max_content,
h: this.content.Get_SummaryHeight()
};
},
getRectWidth: function (maxWidth) {
var body_pr = this.getBodyPr();
var r_ins = body_pr.rIns;
var l_ins = body_pr.lIns;
var max_content_width = maxWidth - r_ins - l_ins;
this.content.Reset(0, 0, max_content_width, 20000);
this.content.Recalculate_Page(0, true);
var max_width = 0;
for (var i = 0; i < this.content.Content.length; ++i) {
var par = this.content.Content[i];
for (var j = 0; j < par.Lines.length; ++j) {
if (par.Lines[j].Ranges[0].W > max_width) {
max_width = par.Lines[j].Ranges[0].W;
}
}
}
return max_width + 2 + r_ins + l_ins;
},
getMaxContentWidth: function (maxWidth, bLeft) {
this.content.Reset(0, 0, maxWidth - 0.01, 20000);
if (bLeft) {
this.content.Set_ApplyToAll(true);
this.content.Set_ParagraphAlign(align_Left);
this.content.Set_ApplyToAll(false);
}
this.content.Recalculate_Page(0, true);
var max_width = 0,
arr_content = this.content.Content,
paragraph_lines, i, j;
for (i = 0; i < arr_content.length; ++i) {
paragraph_lines = arr_content[i].Lines;
for (j = 0; j < paragraph_lines.length; ++j) {
if (paragraph_lines[j].Ranges[0].W > max_width) {
max_width = paragraph_lines[j].Ranges[0].W;
}
}
}
return max_width + 0.01;
},
Get_PrevElementEndInfo: function (CurElement) {
return null;
}
};
function CreateParaContentFromString(str) {
if (str == "\t") {
return new ParaTab();
} else {
if (str == "\n") {
return new ParaNewLine(break_Line);
} else {
if (str != " ") {
return new ParaText(str);
} else {
return new ParaSpace(1);
}
}
}
}

View File

@@ -0,0 +1,112 @@
/*
* (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 HitInLine(context, px, py, x0, y0, x1, y1) {
var tx, ty, dx, dy, d;
tx = x1 - x0;
ty = y1 - y0;
d = 1.5 / Math.sqrt(tx * tx + ty * ty);
if (typeof global_mouseEvent !== "undefined" && isRealObject(global_mouseEvent) && isRealNumber(global_mouseEvent.KoefPixToMM)) {
d *= global_mouseEvent.KoefPixToMM;
}
if (undefined !== window.AscHitToHandlesEpsilon) {
d = window.AscHitToHandlesEpsilon / Math.sqrt(tx * tx + ty * ty);
}
dx = -ty * d;
dy = tx * d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0 + dx, y0 + dy);
context.lineTo(x1 + dx, y1 + dy);
context.lineTo(x1 - dx, y1 - dy);
context.lineTo(x0 - dx, y0 - dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier4(context, px, py, x0, y0, x1, y1, x2, y2, x3, y3) {
var l = Math.min(x0, x1, x2, x3);
var t = Math.min(y0, y1, y2, y3);
var r = Math.max(x0, x1, x2, x3);
var b = Math.max(y0, y1, y2, y3);
if (px < l || px > r || py < t || py > b) {
return false;
}
var tx, ty, dx, dy, d;
tx = x3 - x0;
ty = y3 - y0;
d = 1.5 / Math.sqrt(tx * tx + ty * ty);
if (typeof global_mouseEvent !== "undefined" && isRealObject(global_mouseEvent) && isRealNumber(global_mouseEvent.KoefPixToMM)) {
d *= global_mouseEvent.KoefPixToMM;
}
if (undefined !== window.AscHitToHandlesEpsilon) {
d = window.AscHitToHandlesEpsilon / Math.sqrt(tx * tx + ty * ty);
}
dx = -ty * d;
dy = tx * d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0 + dx, y0 + dy);
context.bezierCurveTo(x1 + dx, y1 + dy, x2 + dx, y2 + dy, x3 + dx, y3 + dy);
context.lineTo(x3 - dx, y3 - dy);
context.bezierCurveTo(x2 - dx, y2 - dy, x1 - dx, y1 - dy, x0 - dx, y0 - dy);
context.closePath();
return context.isPointInPath(px, py);
}
function HitInBezier3(context, px, py, x0, y0, x1, y1, x2, y2) {
var l = Math.min(x0, x1, x2);
var t = Math.min(y0, y1, y2);
var r = Math.max(x0, x1, x2);
var b = Math.max(y0, y1, y2);
if (px < l || px > r || py < t || py > b) {
return false;
}
var tx, ty, dx, dy, d;
tx = x2 - x0;
ty = y2 - y0;
d = 1.5 / Math.sqrt(tx * tx + ty * ty);
if (typeof global_mouseEvent !== "undefined" && isRealObject(global_mouseEvent) && isRealNumber(global_mouseEvent.KoefPixToMM)) {
d *= global_mouseEvent.KoefPixToMM;
}
if (undefined !== window.AscHitToHandlesEpsilon) {
d = window.AscHitToHandlesEpsilon / Math.sqrt(tx * tx + ty * ty);
}
dx = -ty * d;
dy = tx * d;
context.beginPath();
context.moveTo(x0, y0);
context.lineTo(x0 + dx, y0 + dy);
context.quadraticCurveTo(x1 + dx, y1 + dy, x2 + dx, y2 + dy);
context.lineTo(x2 - dx, y2 - dy);
context.quadraticCurveTo(x1 - dx, y1 - dy, x0 - dx, y0 - dy);
context.closePath();
return context.isPointInPath(px, py);
}

View File

@@ -0,0 +1,109 @@
/*
* (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 min_distance_joined = 2;
function JoinedH(shape1, shape2) {
var l, r, l2, r2;
l = shape1.x;
r = l + shape1.extX;
l2 = shape2.x;
r2 = l2 + shape2.extX;
var d = l - l2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = l - r2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = r - l2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = r - r2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
return 0;
}
function JoinedV(shape1, shape2) {
var t, b, t2, b2;
t = shape1.y;
b = t + shape1.extY;
t2 = shape2.y;
b2 = t2 + shape2.extY;
var d = t - t2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = t - b2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = b - t2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = b - b2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
return 0;
}
function JoinedPointH(X, shape2) {
var l2, r2;
l2 = shape2.x;
r2 = l2 + shape2.extX;
var d = X - l2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = X - r2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
return 0;
}
function JoinedPointV(Y, shape2) {
var t2, b2;
t2 = shape2.y;
b2 = t2 + shape2.extY;
var d = Y - t2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
d = Y - b2;
if (Math.abs(d) < min_distance_joined) {
return d;
}
return 0;
}

View File

@@ -0,0 +1,55 @@
/*
* (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 cToRad = Math.PI / (60000 * 180);
var cToDeg = 1 / cToRad;
function Cos(angle) {
return Math.cos(cToRad * angle);
}
function Sin(angle) {
return Math.sin(cToRad * angle);
}
function Tan(angle) {
return Math.tan(cToRad * angle);
}
function ATan(x) {
return cToDeg * Math.atan(x);
}
function ATan2(y, x) {
return cToDeg * Math.atan2(y, x);
}
function CAt2(x, y, z) {
return x * (Cos(ATan2(z, y)));
}
function SAt2(x, y, z) {
return x * (Sin(ATan2(z, y)));
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,294 @@
/*
* (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 XYAdjustmentTrack(originalShape, adjIndex) {
ExecuteNoHistory(function () {
this.originalShape = originalShape;
this.shapeWidth = this.originalShape.extX;
this.shapeHeight = this.originalShape.extY;
this.geometry = originalShape.spPr.geometry.createDuplicate();
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.adjastment = this.geometry.ahXYLst[adjIndex];
this.xFlag = false;
this.yFlag = false;
this.refX = null;
this.refY = null;
if (this.adjastment !== null && typeof this.adjastment === "object") {
var _ref_x = this.adjastment.gdRefX;
var _gd_lst = this.geometry.gdLst;
if (typeof _ref_x === "string" && typeof _gd_lst[_ref_x] === "number" && typeof this.adjastment.minX === "number" && typeof this.adjastment.maxX === "number") {
_gd_lst[_ref_x] = this.adjastment.minX;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.minRealX = this.adjastment.posX;
_gd_lst[_ref_x] = this.adjastment.maxX;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.maxRealX = this.adjastment.posX;
this.maximalRealX = Math.max(this.maxRealX, this.minRealX);
this.minimalRealX = Math.min(this.maxRealX, this.minRealX);
this.minimalRealativeX = Math.min(this.adjastment.minX, this.adjastment.maxX);
this.maximalRealativeX = Math.max(this.adjastment.minX, this.adjastment.maxX);
if (this.maximalRealX - this.minimalRealX > 0) {
this.coeffX = (this.adjastment.maxX - this.adjastment.minX) / (this.maxRealX - this.minRealX);
this.xFlag = true;
}
}
var _ref_y = this.adjastment.gdRefY;
if (typeof _ref_y === "string" && typeof _gd_lst[_ref_y] === "number" && typeof this.adjastment.minY === "number" && typeof this.adjastment.maxY === "number") {
_gd_lst[_ref_y] = this.adjastment.minY;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.minRealY = this.adjastment.posY;
_gd_lst[_ref_y] = this.adjastment.maxY;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.maxRealY = this.adjastment.posY;
this.maximalRealY = Math.max(this.maxRealY, this.minRealY);
this.minimalRealY = Math.min(this.maxRealY, this.minRealY);
this.minimalRealativeY = Math.min(this.adjastment.minY, this.adjastment.maxY);
this.maximalRealativeY = Math.max(this.adjastment.minY, this.adjastment.maxY);
if (this.maximalRealY - this.minimalRealY > 0) {
this.coeffY = (this.adjastment.maxY - this.adjastment.minY) / (this.maxRealY - this.minRealY);
this.yFlag = true;
}
}
if (this.xFlag) {
this.refX = _ref_x;
}
if (this.yFlag) {
this.refY = _ref_y;
}
}
this.overlayObject = new OverlayObject(this.geometry, originalShape.extX, originalShape.extY, originalShape.brush, originalShape.pen, originalShape.transform);
},
this, []);
this.draw = function (overlay) {
if (isRealNumber(this.originalShape.selectStartPage) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.originalShape.selectStartPage);
}
this.overlayObject.draw(overlay);
};
this.track = function (posX, posY) {
var invert_transform = this.originalShape.invertTransform;
var _relative_x = invert_transform.TransformPointX(posX, posY);
var _relative_y = invert_transform.TransformPointY(posX, posY);
var bRecalculate = false;
if (this.xFlag) {
var _new_x = this.adjastment.minX + this.coeffX * (_relative_x - this.minRealX);
if (_new_x <= this.maximalRealativeX && _new_x >= this.minimalRealativeX) {
if (this.geometry.gdLst[this.adjastment.gdRefX] !== _new_x) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefX] = _new_x;
} else {
if (_new_x > this.maximalRealativeX) {
if (this.geometry.gdLst[this.adjastment.gdRefX] !== this.maximalRealativeX) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefX] = this.maximalRealativeX;
} else {
if (this.geometry.gdLst[this.adjastment.gdRefX] !== this.minimalRealativeX) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefX] = this.minimalRealativeX;
}
}
}
if (this.yFlag) {
var _new_y = this.adjastment.minY + this.coeffY * (_relative_y - this.minRealY);
if (_new_y <= this.maximalRealativeY && _new_y >= this.minimalRealativeY) {
if (this.geometry.gdLst[this.adjastment.gdRefY] !== _new_y) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefY] = _new_y;
} else {
if (_new_y > this.maximalRealativeY) {
if (this.geometry.gdLst[this.adjastment.gdRefY] !== this.maximalRealativeY) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefY] = this.maximalRealativeY;
} else {
if (this.geometry.gdLst[this.adjastment.gdRefY] !== this.minimalRealativeY) {
bRecalculate = true;
}
this.geometry.gdLst[this.adjastment.gdRefY] = this.minimalRealativeY;
}
}
}
if (bRecalculate) {
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
}
};
this.trackEnd = function () {
if (this.xFlag) {
this.originalShape.spPr.geometry.setAdjValue(this.refX, this.geometry.gdLst[this.adjastment.gdRefX] + "");
}
if (this.yFlag) {
this.originalShape.spPr.geometry.setAdjValue(this.refY, this.geometry.gdLst[this.adjastment.gdRefY] + "");
}
};
}
XYAdjustmentTrack.prototype.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
this.draw(bounds_checker);
var tr = this.originalShape.transform;
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(tr.TransformPointX(0, 0));
arr_p_y.push(tr.TransformPointY(0, 0));
arr_p_x.push(tr.TransformPointX(this.originalShape.extX, 0));
arr_p_y.push(tr.TransformPointY(this.originalShape.extX, 0));
arr_p_x.push(tr.TransformPointX(this.originalShape.extX, this.originalShape.extY));
arr_p_y.push(tr.TransformPointY(this.originalShape.extX, this.originalShape.extY));
arr_p_x.push(tr.TransformPointX(0, this.originalShape.extY));
arr_p_y.push(tr.TransformPointY(0, this.originalShape.extY));
arr_p_x.push(bounds_checker.Bounds.min_x);
arr_p_x.push(bounds_checker.Bounds.max_x);
arr_p_y.push(bounds_checker.Bounds.min_y);
arr_p_y.push(bounds_checker.Bounds.max_y);
bounds_checker.Bounds.min_x = Math.min.apply(Math, arr_p_x);
bounds_checker.Bounds.max_x = Math.max.apply(Math, arr_p_x);
bounds_checker.Bounds.min_y = Math.min.apply(Math, arr_p_y);
bounds_checker.Bounds.max_y = Math.max.apply(Math, arr_p_y);
bounds_checker.Bounds.posX = this.originalShape.x;
bounds_checker.Bounds.posY = this.originalShape.y;
bounds_checker.Bounds.extX = this.originalShape.extY;
bounds_checker.Bounds.extY = this.originalShape.extY;
return bounds_checker.Bounds;
};
function PolarAdjustmentTrack(originalShape, adjIndex) {
ExecuteNoHistory(function () {
this.originalShape = originalShape;
this.shapeWidth = this.originalShape.extX;
this.shapeHeight = this.originalShape.extY;
this.geometry = originalShape.spPr.geometry.createDuplicate();
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
this.adjastment = this.geometry.ahPolarLst[adjIndex];
this.radiusFlag = false;
this.angleFlag = false;
this.refR = null;
this.refAng = null;
if (this.adjastment !== null && typeof this.adjastment === "object") {
var _ref_r = this.adjastment.gdRefR;
var _gd_lst = this.geometry.gdLst;
if (typeof _ref_r === "string" && typeof _gd_lst[_ref_r] === "number" && typeof this.adjastment.minR === "number" && typeof this.adjastment.maxR === "number") {
_gd_lst[_ref_r] = this.adjastment.minR;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
var _dx = this.adjastment.posX - this.shapeWidth * 0.5;
var _dy = this.adjastment.posY - this.shapeWidth * 0.5;
this.minRealR = Math.sqrt(_dx * _dx + _dy * _dy);
_gd_lst[_ref_r] = this.adjastment.maxR;
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
_dx = this.adjastment.posX - this.shapeWidth * 0.5;
_dy = this.adjastment.posY - this.shapeHeight * 0.5;
this.maxRealR = Math.sqrt(_dx * _dx + _dy * _dy);
this.maximalRealRadius = Math.max(this.maxRealR, this.minRealR);
this.minimalRealRadius = Math.min(this.maxRealR, this.minRealR);
this.minimalRealativeRadius = Math.min(this.adjastment.minR, this.adjastment.maxR);
this.maximalRealativeRadius = Math.max(this.adjastment.minR, this.adjastment.maxR);
if (this.maximalRealRadius - this.minimalRealRadius > 0) {
this.coeffR = (this.adjastment.maxR - this.adjastment.minR) / (this.maxRealR - this.minRealR);
this.radiusFlag = true;
}
}
var _ref_ang = this.adjastment.gdRefAng;
if (typeof _ref_ang === "string" && typeof _gd_lst[_ref_ang] === "number" && typeof this.adjastment.minAng === "number" && typeof this.adjastment.maxAng === "number") {
this.angleFlag = true;
this.minimalAngle = Math.min(this.adjastment.minAng, this.adjastment.maxAng);
this.maximalAngle = Math.max(this.adjastment.minAng, this.adjastment.maxAng);
}
if (this.radiusFlag) {
this.refR = _ref_r;
}
if (this.angleFlag) {
this.refAng = _ref_ang;
}
}
this.overlayObject = new OverlayObject(this.geometry, this.originalShape.extX, this.originalShape.extY, this.originalShape.brush, this.originalShape.pen, this.originalShape.transform);
},
this, []);
this.draw = function (overlay) {
if (this.originalShape.parent && isRealNumber(this.originalShape.selectStartPage) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.originalShape.selectStartPage);
}
this.overlayObject.draw(overlay);
};
this.track = function (posX, posY) {
var invert_transform = this.originalShape.invertTransform;
var _relative_x = invert_transform.TransformPointX(posX, posY);
var _relative_y = invert_transform.TransformPointY(posX, posY);
var _pos_x_relative_center = _relative_x - this.shapeHeight * 0.5;
var _pos_y_relative_center = _relative_y - this.shapeWidth * 0.5;
if (this.radiusFlag) {
var _radius = Math.sqrt(_pos_x_relative_center * _pos_x_relative_center + _pos_y_relative_center * _pos_y_relative_center);
var _new_radius = this.adjastment.minR + this.coeffR * (_radius - this.minRealR);
if (_new_radius <= this.maximalRealativeRadius && _new_radius >= this.minimalRealativeRadius) {
this.geometry.gdLst[this.adjastment.gdRefR] = _new_radius;
} else {
if (_new_radius > this.maximalRealativeRadius) {
this.geometry.gdLst[this.adjastment.gdRefR] = this.maximalRealativeRadius;
} else {
this.geometry.gdLst[this.adjastment.gdRefR] = this.minimalRealativeRadius;
}
}
}
if (this.angleFlag) {
var _angle = Math.atan2(_pos_y_relative_center, _pos_x_relative_center);
while (_angle < 0) {
_angle += 2 * Math.PI;
}
while (_angle >= 2 * Math.PI) {
_angle -= 2 * Math.PI;
}
_angle *= cToDeg;
if (_angle >= this.minimalAngle && _angle <= this.maximalAngle) {
this.geometry.gdLst[this.adjastment.gdRefAng] = _angle;
} else {
if (_angle >= this.maximalAngle) {
this.geometry.gdLst[this.adjastment.gdRefAng] = this.maximalAngle;
} else {
if (_angle <= this.minimalAngle) {
this.geometry.gdLst[this.adjastment.gdRefAng] = this.minimalAngle;
}
}
}
}
this.geometry.Recalculate(this.shapeWidth, this.shapeHeight);
};
this.trackEnd = function () {
if (this.radiusFlag) {
this.originalShape.spPr.geometry.setAdjValue(this.adjastment.gdRefR, this.geometry.gdLst[this.adjastment.gdRefR] + "");
}
if (this.angleFlag) {
this.originalShape.spPr.geometry.setAdjValue(this.adjastment.gdRefAng, this.geometry.gdLst[this.adjastment.gdRefAng] + "");
}
};
}
PolarAdjustmentTrack.prototype.getBounds = XYAdjustmentTrack.prototype.getBounds;

View File

@@ -0,0 +1,313 @@
/*
* (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 MoveShapeImageTrack(originalObject) {
this.originalObject = originalObject;
this.transform = new CMatrix();
this.x = null;
this.y = null;
this.pageIndex = null;
this.originalShape = originalObject;
if (!originalObject.isChart()) {
this.brush = originalObject.brush;
this.pen = originalObject.pen;
} else {
var pen_brush = CreatePenBrushForChartTrack();
this.brush = pen_brush.brush;
this.pen = pen_brush.pen;
}
this.overlayObject = new OverlayObject(!(this.originalObject.getObjectType() === historyitem_type_ChartSpace) && this.originalObject.spPr && this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.brush, this.pen, this.transform);
this.groupInvertMatrix = null;
if (this.originalObject.group) {
this.groupInvertMatrix = this.originalObject.group.invertTransform.CreateDublicate();
this.groupInvertMatrix.tx = 0;
this.groupInvertMatrix.ty = 0;
}
this.getOriginalBoundsRect = function () {
return this.originalObject.getRectBounds();
};
this.track = function (dx, dy, pageIndex) {
var original = this.originalObject;
var dx2, dy2;
if (this.groupInvertMatrix) {
dx2 = this.groupInvertMatrix.TransformPointX(dx, dy);
dy2 = this.groupInvertMatrix.TransformPointY(dx, dy);
} else {
dx2 = dx;
dy2 = dy;
}
this.x = original.x + dx2;
this.y = original.y + dy2;
this.transform.Reset();
var hc = original.extX * 0.5;
var vc = original.extY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (original.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
}
if (original.flipV) {
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(this.transform, -original.rot);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
if (this.originalObject.group) {
global_MatrixTransformer.MultiplyAppend(this.transform, this.originalObject.group.transform);
}
if (isRealNumber(pageIndex)) {
this.pageIndex = pageIndex;
}
};
this.draw = function (overlay) {
if (isRealNumber(this.pageIndex) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.pageIndex);
}
this.overlayObject.draw(overlay);
};
this.trackEnd = function (bWord) {
if (bWord) {
if (this.originalObject.selectStartPage !== this.pageIndex) {
this.originalObject.selectStartPage = this.pageIndex;
}
}
var scale_coefficients, ch_off_x, ch_off_y;
CheckSpPrXfrm(this.originalObject);
if (this.originalObject.group) {
scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
ch_off_x = this.originalObject.group.spPr.xfrm.chOffX;
ch_off_y = this.originalObject.group.spPr.xfrm.chOffY;
} else {
if (bWord) {
if (this.originalObject.spPr.xfrm.offX === 0 && this.originalObject.spPr.xfrm.offY === 0) {
return;
}
}
scale_coefficients = {
cx: 1,
cy: 1
};
ch_off_x = 0;
ch_off_y = 0;
if (bWord) {
this.x = 0;
this.y = 0;
}
}
this.originalObject.spPr.xfrm.setOffX(this.x / scale_coefficients.cx + ch_off_x);
this.originalObject.spPr.xfrm.setOffY(this.y / scale_coefficients.cy + ch_off_y);
this.originalObject.checkDrawingBaseCoords();
};
}
MoveShapeImageTrack.prototype.getBounds = function () {
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
var tr = this.transform;
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(tr.TransformPointX(0, 0));
arr_p_y.push(tr.TransformPointY(0, 0));
arr_p_x.push(tr.TransformPointX(this.originalObject.extX, 0));
arr_p_y.push(tr.TransformPointY(this.originalObject.extX, 0));
arr_p_x.push(tr.TransformPointX(this.originalObject.extX, this.originalObject.extY));
arr_p_y.push(tr.TransformPointY(this.originalObject.extX, this.originalObject.extY));
arr_p_x.push(tr.TransformPointX(0, this.originalObject.extY));
arr_p_y.push(tr.TransformPointY(0, this.originalObject.extY));
arr_p_x.push(boundsChecker.Bounds.min_x);
arr_p_x.push(boundsChecker.Bounds.max_x);
arr_p_y.push(boundsChecker.Bounds.min_y);
arr_p_y.push(boundsChecker.Bounds.max_y);
boundsChecker.Bounds.min_x = Math.min.apply(Math, arr_p_x);
boundsChecker.Bounds.max_x = Math.max.apply(Math, arr_p_x);
boundsChecker.Bounds.min_y = Math.min.apply(Math, arr_p_y);
boundsChecker.Bounds.max_y = Math.max.apply(Math, arr_p_y);
boundsChecker.Bounds.posX = this.x;
boundsChecker.Bounds.posY = this.y;
boundsChecker.Bounds.extX = this.originalObject.extX;
boundsChecker.Bounds.extY = this.originalObject.extY;
return boundsChecker.Bounds;
};
function MoveShapeImageTrackInGroup(originalObject) {
this.originalObject = originalObject;
this.x = null;
this.y = null;
this.transform = new CMatrix();
if (!originalObject.isChart()) {
this.brush = originalObject.brush;
this.pen = originalObject.pen;
} else {
var pen_brush = CreatePenBrushForChartTrack();
this.brush = pen_brush.brush;
this.pen = pen_brush.pen;
}
this.overlayObject = new OverlayObject(!(this.originalObject.getObjectType() === historyitem_type_ChartSpace) && this.originalObject.spPr && this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.brush, this.pen, this.transform);
this.inv = global_MatrixTransformer.Invert(originalObject.group.transform);
this.inv.tx = 0;
this.inv.ty = 0;
this.draw = function (overlay) {
if (isRealNumber(this.pageIndex) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.pageIndex);
}
this.overlayObject.draw(overlay);
};
this.track = function (dx, dy) {
var dx_t = this.inv.TransformPointX(dx, dy);
var dy_t = this.inv.TransformPointY(dx, dy);
this.x = this.originalObject.x + dx_t;
this.y = this.originalObject.y + dy_t;
this.calculateTransform();
};
this.getOriginalBoundsRect = function () {
return this.originalObject.getRectBounds();
};
this.calculateTransform = function () {
var t = this.transform;
t.Reset();
global_MatrixTransformer.TranslateAppend(t, -this.originalObject.extX * 0.5, -this.originalObject.extY * 0.5);
if (this.originalObject.flipH) {
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if (this.originalObject.flipV) {
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.originalObject.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.originalObject.extX * 0.5, this.y + this.originalObject.extY * 0.5);
global_MatrixTransformer.MultiplyAppend(t, this.originalObject.group.getTransformMatrix());
};
this.trackEnd = function () {
var scale_scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
var xfrm = this.originalObject.group.spPr.xfrm;
CheckSpPrXfrm(this.originalObject);
var shape_xfrm = this.originalObject.spPr.xfrm;
shape_xfrm.setOffX(this.x / scale_scale_coefficients.cx + xfrm.chOffX);
shape_xfrm.setOffY(this.y / scale_scale_coefficients.cy + xfrm.chOffY);
};
}
function MoveGroupTrack(originalObject) {
this.x = null;
this.y = null;
this.originalObject = originalObject;
this.transform = new CMatrix();
this.pageIndex = null;
this.overlayObjects = [];
this.arrTransforms2 = [];
var arr_graphic_objects = originalObject.getArrGraphicObjects();
var group_invert_transform = originalObject.invertTransform;
for (var i = 0; i < arr_graphic_objects.length; ++i) {
var gr_obj_transform_copy = arr_graphic_objects[i].transform.CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new OverlayObject(!(arr_graphic_objects[i].getObjectType() === historyitem_type_ChartSpace) && arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY, arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, new CMatrix());
}
this.getOriginalBoundsRect = function () {
return this.originalObject.getRectBounds();
};
this.track = function (dx, dy, pageIndex) {
this.pageIndex = pageIndex;
var original = this.originalObject;
this.x = original.x + dx;
this.y = original.y + dy;
this.transform.Reset();
var hc = original.extX * 0.5;
var vc = original.extY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (original.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
}
if (original.flipV) {
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(this.transform, -original.rot);
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
for (var i = 0; i < this.overlayObjects.length; ++i) {
var new_transform = this.arrTransforms2[i].CreateDublicate();
global_MatrixTransformer.MultiplyAppend(new_transform, this.transform);
this.overlayObjects[i].updateTransformMatrix(new_transform);
}
};
this.draw = function (overlay) {
if (isRealNumber(this.pageIndex) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.pageIndex);
}
for (var i = 0; i < this.overlayObjects.length; ++i) {
this.overlayObjects[i].draw(overlay);
}
};
this.getBounds = function () {
var bounds_checker = new CSlideBoundsChecker();
for (var i = 0; i < this.overlayObjects.length; ++i) {
this.overlayObjects[i].draw(bounds_checker);
}
bounds_checker.Bounds.posX = this.x;
bounds_checker.Bounds.posY = this.y;
bounds_checker.Bounds.extX = this.originalObject.extX;
bounds_checker.Bounds.extY = this.originalObject.extY;
return bounds_checker.Bounds;
};
this.trackEnd = function (bWord) {
if (bWord) {
this.x = 0;
this.y = 0;
}
CheckSpPrXfrm(this.originalObject);
var xfrm = this.originalObject.spPr.xfrm;
xfrm.setOffX(this.x);
xfrm.setOffY(this.y);
if (bWord) {
if (this.originalObject.selectStartPage !== this.pageIndex) {
this.originalObject.selectStartPage = this.pageIndex;
}
}
this.originalObject.checkDrawingBaseCoords();
};
}
function MoveComment(comment) {
this.comment = comment;
this.x = comment.x;
this.y = comment.y;
this.getOriginalBoundsRect = function () {};
this.track = function (dx, dy) {
var original = this.comment;
this.x = original.x + dx;
this.y = original.y + dy;
};
this.draw = function (overlay) {
var Flags = 0;
Flags |= 1;
if (this.comment.Data.m_aReplies.length > 0) {
Flags |= 2;
}
var dd = editor.WordControl.m_oDrawingDocument;
overlay.DrawPresentationComment(Flags, this.x, this.y, dd.GetCommentWidth(Flags), dd.GetCommentHeight(Flags));
};
this.trackEnd = function () {
this.comment.setPosition(this.x, this.y);
};
}

View File

@@ -0,0 +1,431 @@
/*
* (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 NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide, pageIndex) {
this.presetGeom = presetGeom;
this.startX = startX;
this.startY = startY;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.arrowsCount = 0;
this.transform = new CMatrix();
this.pageIndex = pageIndex;
this.theme = theme;
ExecuteNoHistory(function () {
var style;
if (presetGeom.indexOf("WithArrow") > -1) {
presetGeom = presetGeom.substr(0, presetGeom.length - 9);
this.presetGeom = presetGeom;
this.arrowsCount = 1;
}
if (presetGeom.indexOf("WithTwoArrows") > -1) {
presetGeom = presetGeom.substr(0, presetGeom.length - 13);
this.presetGeom = presetGeom;
this.arrowsCount = 2;
}
var spDef = theme.spDef;
if (presetGeom !== "textRect") {
if (spDef && spDef.style) {
style = spDef.style.createDuplicate();
} else {
style = CreateDefaultShapeStyle(this.presetGeom);
}
} else {
style = CreateDefaultTextRectStyle();
}
var brush = theme.getFillStyle(style.fillRef.idx);
style.fillRef.Color.Calculate(theme, slide, layout, master, {
R: 0,
G: 0,
B: 0,
A: 255
});
var RGBA = style.fillRef.Color.RGBA;
if (style.fillRef.Color.color) {
if (brush.fill && (brush.fill.type === FILL_TYPE_SOLID)) {
brush.fill.color = style.fillRef.Color.createDuplicate();
}
}
var pen = theme.getLnStyle(style.lnRef.idx, style.lnRef.Color);
style.lnRef.Color.Calculate(theme, slide, layout, master);
RGBA = style.lnRef.Color.RGBA;
if (presetGeom === "textRect") {
var ln, fill;
ln = new CLn();
ln.w = 6350;
ln.Fill = new CUniFill();
ln.Fill.fill = new CSolidFill();
ln.Fill.fill.color = new CUniColor();
ln.Fill.fill.color.color = new CPrstColor();
ln.Fill.fill.color.color.id = "black";
fill = new CUniFill();
fill.fill = new CSolidFill();
fill.fill.color = new CUniColor();
fill.fill.color.color = new CSchemeColor();
fill.fill.color.color.id = 12;
pen.merge(ln);
brush.merge(fill);
}
if (this.arrowsCount > 0) {
pen.setTailEnd(new EndArrow());
pen.tailEnd.setType(LineEndType.Arrow);
pen.tailEnd.setLen(LineEndSize.Mid);
if (this.arrowsCount === 2) {
pen.setHeadEnd(new EndArrow());
pen.headEnd.setType(LineEndType.Arrow);
pen.headEnd.setLen(LineEndSize.Mid);
}
}
if (presetGeom !== "textRect") {
if (spDef && spDef.spPr) {
if (spDef.spPr.Fill) {
brush.merge(spDef.spPr.Fill);
}
if (spDef.spPr.ln) {
pen.merge(spDef.spPr.ln);
}
}
}
var geometry = CreateGeometry(presetGeom !== "textRect" ? presetGeom : "rect");
if (pen.Fill) {
pen.Fill.calculate(theme, slide, layout, master, RGBA);
}
brush.calculate(theme, slide, layout, master, RGBA);
this.isLine = this.presetGeom === "line";
this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform);
this.shape = null;
},
this, []);
this.track = function (e, x, y) {
var real_dist_x = x - this.startX;
var abs_dist_x = Math.abs(real_dist_x);
var real_dist_y = y - this.startY;
var abs_dist_y = Math.abs(real_dist_y);
this.flipH = false;
this.flipV = false;
if (this.isLine) {
if (x < this.startX) {
this.flipH = true;
}
if (y < this.startY) {
this.flipV = true;
}
}
if (! (e.CtrlKey || e.ShiftKey) || (e.CtrlKey && !e.ShiftKey && this.isLine)) {
this.extX = abs_dist_x >= MIN_SHAPE_SIZE ? abs_dist_x : (this.isLine ? 0 : MIN_SHAPE_SIZE);
this.extY = abs_dist_y >= MIN_SHAPE_SIZE ? abs_dist_y : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if (real_dist_x >= 0) {
this.x = this.startX;
} else {
this.x = abs_dist_x >= MIN_SHAPE_SIZE ? x : this.startX - this.extX;
}
if (real_dist_y >= 0) {
this.y = this.startY;
} else {
this.y = abs_dist_y >= MIN_SHAPE_SIZE ? y : this.startY - this.extY;
}
} else {
if (e.CtrlKey && !e.ShiftKey) {
if (abs_dist_x >= MIN_SHAPE_SIZE_DIV2) {
this.x = this.startX - abs_dist_x;
this.extX = 2 * abs_dist_x;
} else {
this.x = this.startX - MIN_SHAPE_SIZE_DIV2;
this.extX = MIN_SHAPE_SIZE;
}
if (abs_dist_y >= MIN_SHAPE_SIZE_DIV2) {
this.y = this.startY - abs_dist_y;
this.extY = 2 * abs_dist_y;
} else {
this.y = this.startY - MIN_SHAPE_SIZE_DIV2;
this.extY = MIN_SHAPE_SIZE;
}
} else {
if (!e.CtrlKey && e.ShiftKey) {
var new_width, new_height;
var prop_coefficient = (typeof SHAPE_ASPECTS[this.presetGeom] === "number" ? SHAPE_ASPECTS[this.presetGeom] : 1);
if (abs_dist_y === 0) {
new_width = abs_dist_x > MIN_SHAPE_SIZE ? abs_dist_x : MIN_SHAPE_SIZE;
new_height = abs_dist_x / prop_coefficient;
} else {
var new_aspect = abs_dist_x / abs_dist_y;
if (new_aspect >= prop_coefficient) {
new_width = abs_dist_x;
new_height = abs_dist_x / prop_coefficient;
} else {
new_height = abs_dist_y;
new_width = abs_dist_y * prop_coefficient;
}
}
if (new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE) {
var k_wh = new_width / new_height;
if (new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE) {
if (new_height < new_width) {
new_height = MIN_SHAPE_SIZE;
new_width = new_height * k_wh;
} else {
new_width = MIN_SHAPE_SIZE;
new_height = new_width / k_wh;
}
} else {
if (new_height < MIN_SHAPE_SIZE) {
new_height = MIN_SHAPE_SIZE;
new_width = new_height * k_wh;
} else {
new_width = MIN_SHAPE_SIZE;
new_height = new_width / k_wh;
}
}
}
this.extX = new_width;
this.extY = new_height;
if (real_dist_x >= 0) {
this.x = this.startX;
} else {
this.x = this.startX - this.extX;
}
if (real_dist_y >= 0) {
this.y = this.startY;
} else {
this.y = this.startY - this.extY;
}
if (this.isLine) {
var angle = Math.atan2(real_dist_y, real_dist_x);
if (angle >= 0 && angle <= Math.PI / 8 || angle <= 0 && angle >= -Math.PI / 8 || angle >= 7 * Math.PI / 8 && angle <= Math.PI) {
this.extY = 0;
this.y = this.startY;
} else {
if (angle >= 3 * Math.PI / 8 && angle <= 5 * Math.PI / 8 || angle <= -3 * Math.PI / 8 && angle >= -5 * Math.PI / 8) {
this.extX = 0;
this.x = this.startX;
}
}
}
} else {
var new_width, new_height;
var prop_coefficient = (typeof SHAPE_ASPECTS[this.presetGeom] === "number" ? SHAPE_ASPECTS[this.presetGeom] : 1);
if (abs_dist_y === 0) {
new_width = abs_dist_x > MIN_SHAPE_SIZE_DIV2 ? abs_dist_x * 2 : MIN_SHAPE_SIZE;
new_height = new_width / prop_coefficient;
} else {
var new_aspect = abs_dist_x / abs_dist_y;
if (new_aspect >= prop_coefficient) {
new_width = abs_dist_x * 2;
new_height = new_width / prop_coefficient;
} else {
new_height = abs_dist_y * 2;
new_width = new_height * prop_coefficient;
}
}
if (new_width < MIN_SHAPE_SIZE || new_height < MIN_SHAPE_SIZE) {
var k_wh = new_width / new_height;
if (new_height < MIN_SHAPE_SIZE && new_width < MIN_SHAPE_SIZE) {
if (new_height < new_width) {
new_height = MIN_SHAPE_SIZE;
new_width = new_height * k_wh;
} else {
new_width = MIN_SHAPE_SIZE;
new_height = new_width / k_wh;
}
} else {
if (new_height < MIN_SHAPE_SIZE) {
new_height = MIN_SHAPE_SIZE;
new_width = new_height * k_wh;
} else {
new_width = MIN_SHAPE_SIZE;
new_height = new_width / k_wh;
}
}
}
this.extX = new_width;
this.extY = new_height;
this.x = this.startX - this.extX * 0.5;
this.y = this.startY - this.extY * 0.5;
}
}
}
this.overlayObject.updateExtents(this.extX, this.extY);
this.transform.Reset();
var hc = this.extX * 0.5;
var vc = this.extY * 0.5;
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (this.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
}
if (this.flipV) {
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
}
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
};
this.draw = function (overlay) {
if (isRealNumber(this.pageIndex) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.pageIndex);
}
this.overlayObject.draw(overlay);
};
this.getShape = function (bFromWord, DrawingDocument, drawingObjects) {
var shape = new CShape();
if (drawingObjects) {
shape.setDrawingObjects(drawingObjects);
}
shape.setSpPr(new CSpPr());
shape.spPr.setParent(shape);
shape.spPr.setXfrm(new CXfrm());
if (bFromWord) {
shape.setWordShape(true);
}
var xfrm = shape.spPr.xfrm;
xfrm.setParent(shape.spPr);
var x, y;
if (bFromWord) {
x = 0;
y = 0;
} else {
x = this.x;
y = this.y;
}
xfrm.setOffX(x);
xfrm.setOffY(y);
xfrm.setExtX(this.extX);
xfrm.setExtY(this.extY);
xfrm.setFlipH(this.flipH);
xfrm.setFlipV(this.flipV);
shape.setBDeleted(false);
if (this.presetGeom === "textRect") {
shape.spPr.setGeometry(CreateGeometry("rect"));
shape.spPr.geometry.setParent(shape.spPr);
var fill, ln;
if (!drawingObjects || !drawingObjects.cSld) {
shape.setStyle(CreateDefaultTextRectStyle());
fill = new CUniFill();
fill.setFill(new CSolidFill());
fill.fill.setColor(new CUniColor());
fill.fill.color.setColor(new CSchemeColor());
fill.fill.color.color.setId(12);
shape.spPr.setFill(fill);
ln = new CLn();
ln.setW(6350);
ln.setFill(new CUniFill());
ln.Fill.setFill(new CSolidFill());
ln.Fill.fill.setColor(new CUniColor());
ln.Fill.fill.color.setColor(new CPrstColor());
ln.Fill.fill.color.color.setId("black");
shape.spPr.setLn(ln);
} else {
fill = new CUniFill();
fill.setFill(new CNoFill());
shape.spPr.setFill(fill);
}
if (bFromWord) {
shape.setTextBoxContent(new CDocumentContent(shape, DrawingDocument, 0, 0, 0, 0, false, false, false));
var body_pr = new CBodyPr();
body_pr.setDefault();
shape.setBodyPr(body_pr);
} else {
shape.setTxBody(new CTextBody());
var content = new CDocumentContent(shape.txBody, DrawingDocument, 0, 0, 0, 0, false, false, true);
shape.txBody.setParent(shape);
shape.txBody.setContent(content);
var body_pr = new CBodyPr();
body_pr.setDefault();
shape.txBody.setBodyPr(body_pr);
}
} else {
shape.spPr.setGeometry(CreateGeometry(this.presetGeom));
shape.spPr.geometry.setParent(shape.spPr);
shape.setStyle(CreateDefaultShapeStyle(this.presetGeom));
if (this.arrowsCount > 0) {
var ln = new CLn();
ln.setTailEnd(new EndArrow());
ln.tailEnd.setType(LineEndType.Arrow);
ln.tailEnd.setLen(LineEndSize.Mid);
if (this.arrowsCount === 2) {
ln.setHeadEnd(new EndArrow());
ln.headEnd.setType(LineEndType.Arrow);
ln.headEnd.setLen(LineEndSize.Mid);
}
shape.spPr.setLn(ln);
}
var spDef = this.theme && this.theme.spDef;
if (spDef) {
if (spDef.style) {
shape.setStyle(spDef.style.createDuplicate());
}
if (spDef.spPr) {
if (spDef.spPr.Fill) {
shape.spPr.setFill(spDef.spPr.Fill.createDuplicate());
}
if (spDef.spPr.ln) {
if (shape.spPr.ln) {
shape.spPr.ln.merge(spDef.spPr.ln);
} else {
shape.spPr.setLn(spDef.spPr.ln.createDuplicate());
}
}
}
}
}
shape.x = this.x;
shape.y = this.y;
return shape;
};
this.getBounds = function () {
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
var tr = this.transform;
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(tr.TransformPointX(0, 0));
arr_p_y.push(tr.TransformPointY(0, 0));
arr_p_x.push(tr.TransformPointX(this.extX, 0));
arr_p_y.push(tr.TransformPointY(this.extX, 0));
arr_p_x.push(tr.TransformPointX(this.extX, this.extY));
arr_p_y.push(tr.TransformPointY(this.extX, this.extY));
arr_p_x.push(tr.TransformPointX(0, this.extY));
arr_p_y.push(tr.TransformPointY(0, this.extY));
arr_p_x.push(boundsChecker.Bounds.min_x);
arr_p_x.push(boundsChecker.Bounds.max_x);
arr_p_y.push(boundsChecker.Bounds.min_y);
arr_p_y.push(boundsChecker.Bounds.max_y);
boundsChecker.Bounds.min_x = Math.min.apply(Math, arr_p_x);
boundsChecker.Bounds.max_x = Math.max.apply(Math, arr_p_x);
boundsChecker.Bounds.min_y = Math.min.apply(Math, arr_p_y);
boundsChecker.Bounds.max_y = Math.max.apply(Math, arr_p_y);
boundsChecker.Bounds.posX = this.x;
boundsChecker.Bounds.posY = this.y;
boundsChecker.Bounds.extX = this.extX;
boundsChecker.Bounds.extY = this.extY;
return boundsChecker.Bounds;
};
}

View File

@@ -0,0 +1,200 @@
/*
* (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 PolyLine(drawingObjects, theme, master, layout, slide, pageIndex) {
ExecuteNoHistory(function () {
this.drawingObjects = drawingObjects;
this.arrPoint = [];
this.Matrix = new CMatrixL();
this.TransformMatrix = new CMatrixL();
this.pageIndex = pageIndex;
this.style = CreateDefaultShapeStyle();
var style = this.style;
style.fillRef.Color.Calculate(theme, slide, layout, master, {
R: 0,
G: 0,
B: 0,
A: 255
});
var RGBA = style.fillRef.Color.RGBA;
var pen = theme.getLnStyle(style.lnRef.idx, style.lnRef.Color);
style.lnRef.Color.Calculate(theme, slide, layout, master);
RGBA = style.lnRef.Color.RGBA;
if (pen.Fill) {
pen.Fill.calculate(theme, slide, layout, master, RGBA);
}
this.pen = pen;
this.polylineForDrawer = new PolylineForDrawer(this);
},
this, []);
this.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
if (isRealNumber(this.pageIndex) && g.SetCurrentPage) {
g.SetCurrentPage(this.pageIndex);
}
this.polylineForDrawer.Draw(g);
return;
if (this.arrPoint.length < 2) {
return;
}
g._m(this.arrPoint[0].x, this.arrPoint[0].y);
for (var i = 1; i < this.arrPoint.length; ++i) {
g._l(this.arrPoint[i].x, this.arrPoint[i].y);
}
g.ds();
};
this.getBounds = function () {
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.Bounds.posX = boundsChecker.Bounds.min_x;
boundsChecker.Bounds.posY = boundsChecker.Bounds.min_y;
boundsChecker.Bounds.extX = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
boundsChecker.Bounds.extY = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
return boundsChecker.Bounds;
};
this.getShape = function (bWord, drawingDocument, drawingObjects) {
var xMax = this.arrPoint[0].x,
yMax = this.arrPoint[0].y,
xMin = xMax,
yMin = yMax;
var i;
var bClosed = false;
var min_dist;
if (drawingObjects) {
min_dist = drawingObjects.convertPixToMM(3);
} else {
min_dist = editor.WordControl.m_oDrawingDocument.GetMMPerDot(3);
}
if (this.arrPoint.length > 2) {
var dx = this.arrPoint[0].x - this.arrPoint[this.arrPoint.length - 1].x;
var dy = this.arrPoint[0].y - this.arrPoint[this.arrPoint.length - 1].y;
if (Math.sqrt(dx * dx + dy * dy) < min_dist) {
bClosed = true;
}
}
var _n = bClosed ? this.arrPoint.length - 1 : this.arrPoint.length;
for (i = 1; i < _n; ++i) {
if (this.arrPoint[i].x > xMax) {
xMax = this.arrPoint[i].x;
}
if (this.arrPoint[i].y > yMax) {
yMax = this.arrPoint[i].y;
}
if (this.arrPoint[i].x < xMin) {
xMin = this.arrPoint[i].x;
}
if (this.arrPoint[i].y < yMin) {
yMin = this.arrPoint[i].y;
}
}
var shape = new CShape();
shape.setSpPr(new CSpPr());
shape.spPr.setParent(shape);
shape.spPr.setXfrm(new CXfrm());
shape.spPr.xfrm.setParent(shape.spPr);
if (!bWord) {
shape.spPr.xfrm.setOffX(xMin);
shape.spPr.xfrm.setOffY(yMin);
} else {
shape.setWordShape(true);
shape.spPr.xfrm.setOffX(0);
shape.spPr.xfrm.setOffY(0);
}
shape.spPr.xfrm.setExtX(xMax - xMin);
shape.spPr.xfrm.setExtY(yMax - yMin);
shape.setStyle(CreateDefaultShapeStyle());
var geometry = new Geometry();
var w = xMax - xMin,
h = yMax - yMin;
var kw, kh, pathW, pathH;
if (w > 0) {
pathW = 43200;
kw = 43200 / w;
} else {
pathW = 0;
kw = 0;
}
if (h > 0) {
pathH = 43200;
kh = 43200 / h;
} else {
pathH = 0;
kh = 0;
}
geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, pathW, pathH);
geometry.AddRect("l", "t", "r", "b");
geometry.AddPathCommand(1, (((this.arrPoint[0].x - xMin) * kw) >> 0) + "", (((this.arrPoint[0].y - yMin) * kh) >> 0) + "");
for (i = 1; i < _n; ++i) {
geometry.AddPathCommand(2, (((this.arrPoint[i].x - xMin) * kw) >> 0) + "", (((this.arrPoint[i].y - yMin) * kh) >> 0) + "");
}
if (bClosed) {
geometry.AddPathCommand(6);
}
shape.spPr.setGeometry(geometry);
shape.setBDeleted(false);
shape.recalculate();
shape.x = xMin;
shape.y = yMin;
return shape;
};
}
function PolylineForDrawer(polyline) {
this.polyline = polyline;
this.pen = polyline.pen;
this.brush = polyline.brush;
this.TransformMatrix = polyline.TransformMatrix;
this.Matrix = polyline.Matrix;
this.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
g._e();
if (this.polyline.arrPoint.length < 2) {
return;
}
g._m(this.polyline.arrPoint[0].x, this.polyline.arrPoint[0].y);
for (var i = 1; i < this.polyline.arrPoint.length; ++i) {
g._l(this.polyline.arrPoint[i].x, this.polyline.arrPoint[i].y);
}
g.ds();
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,361 @@
/*
* (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 OverlayObject(geometry, extX, extY, brush, pen, transform) {
this.geometry = geometry;
this.ext = {};
this.ext.cx = extX;
this.ext.cy = extY;
this.extX = extX;
this.extY = extY;
var _brush, _pen;
if ((!brush || !brush.fill || brush.fill.type === FILL_TYPE_NOFILL) && (!pen || !pen.Fill || !pen.Fill || !pen.Fill.fill || pen.Fill.fill.type === FILL_TYPE_NOFILL || pen.w === 0)) {
var penBrush = CreatePenBrushForChartTrack();
_brush = penBrush.brush;
_pen = penBrush.pen;
} else {
_brush = brush;
_pen = pen;
}
this.brush = _brush;
this.pen = _pen;
this.TransformMatrix = transform;
this.shapeDrawer = new CShapeDrawer();
this.updateTransform = function (extX, extY, transform) {
this.ext.cx = extX;
this.ext.cy = extY;
this.extX = extX;
this.extY = extY;
this.transform = transform;
};
this.updateExtents = function (extX, extY) {
this.ext.cx = extX;
this.ext.cy = extY;
this.extX = extX;
this.extY = extY;
this.geometry && this.geometry.Recalculate(extX, extY);
};
this.updateTransformMatrix = function (transform) {
this.TransformMatrix = transform;
};
this.draw = function (overlay, transform) {
var oldTransform = this.TransformMatrix;
if (transform) {
this.updateTransformMatrix(transform);
}
if (this.checkDrawGeometry()) {
overlay.SaveGrState();
overlay.SetIntegerGrid(false);
overlay.transform3(this.TransformMatrix, false);
this.shapeDrawer.fromShape2(this, overlay, this.geometry);
this.shapeDrawer.draw(this.geometry);
overlay.RestoreGrState();
} else {
if (window["NATIVE_EDITOR_ENJINE"] === true) {
var _shape = new CShape();
_shape.extX = this.ext.cx;
_shape.extY = this.ext.cy;
_shape.brush = CreateSolidFillRGBA(255, 255, 255, 128);
_shape.pen = new CLn();
_shape.pen.Fill = CreateSolidFillRGBA(0, 0, 0, 160);
_shape.pen.w = 18000;
overlay.SaveGrState();
overlay.SetIntegerGrid(false);
overlay.transform3(this.TransformMatrix, false);
this.shapeDrawer.fromShape2(_shape, overlay, null);
this.shapeDrawer.draw(null);
overlay.RestoreGrState();
} else {
overlay.SaveGrState();
overlay.SetIntegerGrid(false);
overlay.transform3(this.TransformMatrix);
overlay._s();
overlay._m(0, 0);
overlay._l(this.ext.cx, 0);
overlay._l(this.ext.cx, this.ext.cy);
overlay._l(0, this.ext.cy);
overlay._z();
overlay.p_color(0, 0, 0, 160);
overlay.p_width(500);
overlay.ds();
overlay.b_color1(255, 255, 255, 128);
overlay.df();
overlay._e();
overlay.RestoreGrState();
if (overlay.m_oOverlay) {
overlay.m_oOverlay.ClearAll = true;
}
}
}
if (transform) {
this.updateTransformMatrix(oldTransform);
}
};
this.checkDrawGeometry = function () {
return this.geometry && ((this.pen && this.pen.Fill && this.pen.Fill.fill && this.pen.Fill.fill.type != FILL_TYPE_NOFILL && this.pen.Fill.fill.type != FILL_TYPE_NONE) || (this.brush && this.brush.fill && this.brush.fill && this.brush.fill.type != FILL_TYPE_NOFILL && this.brush.fill.type != FILL_TYPE_NONE));
};
this.check_bounds = function (boundsChecker) {
if (this.geometry) {
this.geometry.check_bounds(boundsChecker);
} else {
boundsChecker._s();
boundsChecker._m(0, 0);
boundsChecker._l(this.ext.cx, 0);
boundsChecker._l(this.ext.cx, this.ext.cy);
boundsChecker._l(0, this.ext.cy);
boundsChecker._z();
boundsChecker._e();
}
};
}
function ObjectToDraw(brush, pen, extX, extY, geometry, transform) {
this.brush = brush;
this.pen = pen;
this.extX = extX;
this.extY = extY;
this.transform = transform;
this.TransformMatrix = transform;
this.geometry = geometry;
}
ObjectToDraw.prototype = {
check_bounds: function (boundsChecker) {
if (this.geometry) {
this.geometry.check_bounds(boundsChecker);
} else {
boundsChecker._s();
boundsChecker._m(0, 0);
boundsChecker._l(this.extX, 0);
boundsChecker._l(this.extX, this.extY);
boundsChecker._l(0, this.extY);
boundsChecker._z();
boundsChecker._e();
}
}
};
function RotateTrackShapeImage(originalObject) {
this.originalObject = originalObject;
this.transform = new CMatrix();
this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, originalObject.brush, originalObject.pen, this.transform);
this.angle = originalObject.rot;
var full_flip_h = this.originalObject.getFullFlipH();
var full_flip_v = this.originalObject.getFullFlipV();
this.signum = !full_flip_h && !full_flip_v || full_flip_h && full_flip_v ? 1 : -1;
this.draw = function (overlay, transform) {
if (isRealNumber(this.originalObject.selectStartPage) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.originalObject.selectStartPage);
}
this.overlayObject.draw(overlay, transform);
};
this.track = function (angle, e) {
var new_rot = angle + this.originalObject.rot;
while (new_rot < 0) {
new_rot += 2 * Math.PI;
}
while (new_rot >= 2 * Math.PI) {
new_rot -= 2 * Math.PI;
}
if (new_rot < MIN_ANGLE || new_rot > 2 * Math.PI - MIN_ANGLE) {
new_rot = 0;
}
if (Math.abs(new_rot - Math.PI * 0.5) < MIN_ANGLE) {
new_rot = Math.PI * 0.5;
}
if (Math.abs(new_rot - Math.PI) < MIN_ANGLE) {
new_rot = Math.PI;
}
if (Math.abs(new_rot - 1.5 * Math.PI) < MIN_ANGLE) {
new_rot = 1.5 * Math.PI;
}
if (e.ShiftKey) {
new_rot = (Math.PI / 12) * Math.floor(12 * new_rot / (Math.PI));
}
this.angle = new_rot;
var hc, vc;
hc = this.originalObject.extX * 0.5;
vc = this.originalObject.extY * 0.5;
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (this.originalObject.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
}
if (this.originalObject.flipV) {
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(this.transform, -this.angle);
global_MatrixTransformer.TranslateAppend(this.transform, this.originalObject.x + hc, this.originalObject.y + vc);
if (this.originalObject.group) {
global_MatrixTransformer.MultiplyAppend(this.transform, this.originalObject.group.transform);
}
if (this.originalObject.parent && this.originalObject.parent.isShapeChild) {
var parent_shape = this.originalObject.parent.isShapeChild(true);
if (parent_shape) {
global_MatrixTransformer.MultiplyAppend(this.transform, parent_shape.transformText);
}
}
};
this.trackEnd = function () {
CheckSpPrXfrm(this.originalObject);
this.originalObject.spPr.xfrm.setRot(this.angle);
};
this.getBounds = function () {
var boundsChecker = new CSlideBoundsChecker();
var tr = this.transform;
var parent_shape = this.originalObject && this.originalObject.parent && this.originalObject.parent.isShapeChild && this.originalObject.parent.isShapeChild(true);
if (parent_shape) {
tr = tr.CreateDublicate();
global_MatrixTransformer.MultiplyAppend(tr, parent_shape.invertTransformText);
}
this.draw(boundsChecker, parent_shape ? tr : null);
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(tr.TransformPointX(0, 0));
arr_p_y.push(tr.TransformPointY(0, 0));
arr_p_x.push(tr.TransformPointX(this.originalObject.extX, 0));
arr_p_y.push(tr.TransformPointY(this.originalObject.extX, 0));
arr_p_x.push(tr.TransformPointX(this.originalObject.extX, this.originalObject.extY));
arr_p_y.push(tr.TransformPointY(this.originalObject.extX, this.originalObject.extY));
arr_p_x.push(tr.TransformPointX(0, this.originalObject.extY));
arr_p_y.push(tr.TransformPointY(0, this.originalObject.extY));
arr_p_x.push(boundsChecker.Bounds.min_x);
arr_p_x.push(boundsChecker.Bounds.max_x);
arr_p_y.push(boundsChecker.Bounds.min_y);
arr_p_y.push(boundsChecker.Bounds.max_y);
boundsChecker.Bounds.min_x = Math.min.apply(Math, arr_p_x);
boundsChecker.Bounds.max_x = Math.max.apply(Math, arr_p_x);
boundsChecker.Bounds.min_y = Math.min.apply(Math, arr_p_y);
boundsChecker.Bounds.max_y = Math.max.apply(Math, arr_p_y);
boundsChecker.Bounds.posX = this.originalObject.x;
boundsChecker.Bounds.posY = this.originalObject.y;
boundsChecker.Bounds.extX = this.originalObject.extX;
boundsChecker.Bounds.extY = this.originalObject.extY;
return boundsChecker.Bounds;
};
}
function RotateTrackGroup(originalObject) {
this.originalObject = originalObject;
this.transform = new CMatrix();
this.overlayObjects = [];
this.arrTransforms = [];
this.arrTransforms2 = [];
var arr_graphic_objects = originalObject.getArrGraphicObjects();
var group_invert_transform = originalObject.getInvertTransform();
for (var i = 0; i < arr_graphic_objects.length; ++i) {
var gr_obj_transform_copy = arr_graphic_objects[i].getTransformMatrix().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY, arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, new CMatrix());
}
this.angle = originalObject.rot;
this.draw = function (overlay) {
if (isRealNumber(this.originalObject.selectStartPage) && overlay.SetCurrentPage) {
overlay.SetCurrentPage(this.originalObject.selectStartPage);
}
for (var i = 0; i < this.overlayObjects.length; ++i) {
this.overlayObjects[i].draw(overlay);
}
};
this.getBounds = function () {
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
var tr = this.transform;
var arr_p_x = [];
var arr_p_y = [];
arr_p_x.push(tr.TransformPointX(0, 0));
arr_p_y.push(tr.TransformPointY(0, 0));
arr_p_x.push(tr.TransformPointX(this.originalObject.extX, 0));
arr_p_y.push(tr.TransformPointY(this.originalObject.extX, 0));
arr_p_x.push(tr.TransformPointX(this.originalObject.extX, this.originalObject.extY));
arr_p_y.push(tr.TransformPointY(this.originalObject.extX, this.originalObject.extY));
arr_p_x.push(tr.TransformPointX(0, this.originalObject.extY));
arr_p_y.push(tr.TransformPointY(0, this.originalObject.extY));
arr_p_x.push(boundsChecker.Bounds.min_x);
arr_p_x.push(boundsChecker.Bounds.max_x);
arr_p_y.push(boundsChecker.Bounds.min_y);
arr_p_y.push(boundsChecker.Bounds.max_y);
boundsChecker.Bounds.min_x = Math.min.apply(Math, arr_p_x);
boundsChecker.Bounds.max_x = Math.max.apply(Math, arr_p_x);
boundsChecker.Bounds.min_y = Math.min.apply(Math, arr_p_y);
boundsChecker.Bounds.max_y = Math.max.apply(Math, arr_p_y);
boundsChecker.Bounds.posX = this.originalObject.x;
boundsChecker.Bounds.posY = this.originalObject.y;
boundsChecker.Bounds.extX = this.originalObject.extX;
boundsChecker.Bounds.extY = this.originalObject.extY;
return boundsChecker.Bounds;
};
this.track = function (angle, e) {
var new_rot = angle + this.originalObject.rot;
while (new_rot < 0) {
new_rot += 2 * Math.PI;
}
while (new_rot >= 2 * Math.PI) {
new_rot -= 2 * Math.PI;
}
if (new_rot < MIN_ANGLE || new_rot > 2 * Math.PI - MIN_ANGLE) {
new_rot = 0;
}
if (Math.abs(new_rot - Math.PI * 0.5) < MIN_ANGLE) {
new_rot = Math.PI * 0.5;
}
if (Math.abs(new_rot - Math.PI) < MIN_ANGLE) {
new_rot = Math.PI;
}
if (Math.abs(new_rot - 1.5 * Math.PI) < MIN_ANGLE) {
new_rot = 1.5 * Math.PI;
}
if (e.ShiftKey) {
new_rot = (Math.PI / 12) * Math.floor(12 * new_rot / (Math.PI));
}
this.angle = new_rot;
var hc, vc;
hc = this.originalObject.extX * 0.5;
vc = this.originalObject.extY * 0.5;
this.transform.Reset();
global_MatrixTransformer.TranslateAppend(this.transform, -hc, -vc);
if (this.originalObject.flipH) {
global_MatrixTransformer.ScaleAppend(this.transform, -1, 1);
}
if (this.originalObject.flipV) {
global_MatrixTransformer.ScaleAppend(this.transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(this.transform, -this.angle);
global_MatrixTransformer.TranslateAppend(this.transform, this.originalObject.x + hc, this.originalObject.y + vc);
for (var i = 0; i < this.overlayObjects.length; ++i) {
var new_transform = this.arrTransforms2[i].CreateDublicate();
global_MatrixTransformer.MultiplyAppend(new_transform, this.transform);
this.overlayObjects[i].updateTransformMatrix(new_transform);
}
};
this.trackEnd = function () {
CheckSpPrXfrm(this.originalObject);
this.originalObject.spPr.xfrm.setRot(this.angle);
};
}

View File

@@ -0,0 +1,312 @@
/*
* (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 K = 1 / 4;
var mt = 0,
lt = 1,
cb = 2,
cl = 3;
function SplineCommandMoveTo(x, y) {
this.id = 0;
this.x = x;
this.y = y;
}
function SplineCommandLineTo(x, y) {
this.id = 1;
this.x = x;
this.y = y;
this.changeLastPoint = function (x, y) {
this.x = x;
this.y = y;
};
}
function SplineCommandBezier(x1, y1, x2, y2, x3, y3) {
this.id = 2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.changeLastPoint = function (x, y) {
this.x3 = x;
this.y3 = y;
this.x2 = this.x1 + (this.x3 - this.x1) * 0.5;
this.y2 = this.y1 + (this.y3 - this.y1) * 0.5;
};
}
function Spline(drawingObjects, theme, master, layout, slide, pageIndex) {
ExecuteNoHistory(function () {
this.pageIndex = pageIndex;
this.path = [];
this.drawingObjects = drawingObjects;
this.Matrix = new CMatrix();
this.TransformMatrix = new CMatrix();
this.style = CreateDefaultShapeStyle();
var style = this.style;
style.fillRef.Color.Calculate(theme, slide, layout, master, {
R: 0,
G: 0,
B: 0,
A: 255
});
var RGBA = style.fillRef.Color.RGBA;
var pen = theme.getLnStyle(style.lnRef.idx, style.lnRef.Color);
style.lnRef.Color.Calculate(theme, slide, layout, master);
RGBA = style.lnRef.Color.RGBA;
if (pen.Fill) {
pen.Fill.calculate(theme, slide, layout, master, RGBA);
}
this.pen = pen;
this.splineForDraw = new SplineForDrawer(this);
},
this, []);
this.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
if (isRealNumber(this.pageIndex) && g.SetCurrentPage) {
g.SetCurrentPage(this.pageIndex);
}
this.splineForDraw.Draw(g);
return;
for (var i = 0; i < this.path.length; ++i) {
var lastX, lastY;
switch (this.path[i].id) {
case 0:
g._m(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
case 1:
g._l(this.path[i].x, this.path[i].y);
lastX = this.path[i].x;
lastY = this.path[i].y;
break;
case 2:
g._c(this.path[i].x1, this.path[i].y1, this.path[i].x2, this.path[i].y2, this.path[i].x3, this.path[i].y3);
lastX = this.path[i].x3;
lastY = this.path[i].y3;
break;
}
}
g.ds();
};
this.getShape = function (bWord, drawingDocument, drawingObjects) {
var xMax = this.path[0].x,
yMax = this.path[0].y,
xMin = xMax,
yMin = yMax;
var i;
var bClosed = false;
if (this.path.length > 2) {
var dx = this.path[0].x - this.path[this.path.length - 1].x3;
var dy = this.path[0].y - this.path[this.path.length - 1].y3;
if (Math.sqrt(dx * dx + dy * dy) < 3) {
bClosed = true;
this.path[this.path.length - 1].x3 = this.path[0].x;
this.path[this.path.length - 1].y3 = this.path[0].y;
if (this.path.length > 3) {
var vx = (this.path[1].x3 - this.path[this.path.length - 2].x3) / 6;
var vy = (this.path[1].y3 - this.path[this.path.length - 2].y3) / 6;
} else {
vx = -(this.path[1].y3 - this.path[0].y) / 6;
vy = (this.path[1].x3 - this.path[0].x) / 6;
}
this.path[1].x1 = this.path[0].x + vx;
this.path[1].y1 = this.path[0].y + vy;
this.path[this.path.length - 1].x2 = this.path[0].x - vx;
this.path[this.path.length - 1].y2 = this.path[0].y - vy;
}
}
var min_x = this.path[0].x;
var max_x = min_x;
var min_y = this.path[0].y;
var max_y = min_y;
var last_x = this.path[0].x,
last_y = this.path[0].y;
for (var index = 1; index < this.path.length; ++index) {
var path_command = this.path[index];
if (path_command.id === 1) {
if (min_x > path_command.x) {
min_x = path_command.x;
}
if (max_x < path_command.x) {
max_x = path_command.x;
}
if (min_y > path_command.y) {
min_y = path_command.y;
}
if (max_y < path_command.y) {
max_y = path_command.y;
}
last_x = path_command.x;
last_y = path_command.y;
} else {
var bezier_polygon = partition_bezier4(last_x, last_y, path_command.x1, path_command.y1, path_command.x2, path_command.y2, path_command.x3, path_command.y3, APPROXIMATE_EPSILON);
for (var point_index = 1; point_index < bezier_polygon.length; ++point_index) {
var cur_point = bezier_polygon[point_index];
if (min_x > cur_point.x) {
min_x = cur_point.x;
}
if (max_x < cur_point.x) {
max_x = cur_point.x;
}
if (min_y > cur_point.y) {
min_y = cur_point.y;
}
if (max_y < cur_point.y) {
max_y = cur_point.y;
}
last_x = path_command.x3;
last_y = path_command.y3;
}
}
}
xMin = min_x;
xMax = max_x;
yMin = min_y;
yMax = max_y;
var shape = new CShape();
shape.setSpPr(new CSpPr());
shape.spPr.setParent(shape);
shape.spPr.setXfrm(new CXfrm());
shape.spPr.xfrm.setParent(shape.spPr);
if (!bWord) {
shape.spPr.xfrm.setOffX(xMin);
shape.spPr.xfrm.setOffY(yMin);
} else {
shape.setWordShape(true);
shape.spPr.xfrm.setOffX(0);
shape.spPr.xfrm.setOffY(0);
}
shape.spPr.xfrm.setExtX(xMax - xMin);
shape.spPr.xfrm.setExtY(yMax - yMin);
shape.setStyle(CreateDefaultShapeStyle());
var geometry = new Geometry();
var w = xMax - xMin,
h = yMax - yMin;
var kw, kh, pathW, pathH;
if (w > 0) {
pathW = 43200;
kw = 43200 / w;
} else {
pathW = 0;
kw = 0;
}
if (h > 0) {
pathH = 43200;
kh = 43200 / h;
} else {
pathH = 0;
kh = 0;
}
geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, pathW, pathH);
geometry.AddRect("l", "t", "r", "b");
for (i = 0; i < this.path.length; ++i) {
switch (this.path[i].id) {
case 0:
geometry.AddPathCommand(1, (((this.path[i].x - xMin) * kw) >> 0) + "", (((this.path[i].y - yMin) * kh) >> 0) + "");
break;
case 1:
geometry.AddPathCommand(2, (((this.path[i].x - xMin) * kw) >> 0) + "", (((this.path[i].y - yMin) * kh) >> 0) + "");
break;
case 2:
geometry.AddPathCommand(5, (((this.path[i].x1 - xMin) * kw) >> 0) + "", (((this.path[i].y1 - yMin) * kh) >> 0) + "", (((this.path[i].x2 - xMin) * kw) >> 0) + "", (((this.path[i].y2 - yMin) * kh) >> 0) + "", (((this.path[i].x3 - xMin) * kw) >> 0) + "", (((this.path[i].y3 - yMin) * kh) >> 0) + "");
break;
}
}
if (bClosed) {
geometry.AddPathCommand(6);
}
shape.spPr.setGeometry(geometry);
shape.setBDeleted(false);
shape.recalculate();
shape.x = xMin;
shape.y = yMin;
return shape;
};
this.addPathCommand = function (pathCommand) {
this.path.push(pathCommand);
};
this.getBounds = function () {
var boundsChecker = new CSlideBoundsChecker();
this.draw(boundsChecker);
boundsChecker.Bounds.posX = boundsChecker.Bounds.min_x;
boundsChecker.Bounds.posY = boundsChecker.Bounds.min_y;
boundsChecker.Bounds.extX = boundsChecker.Bounds.max_x - boundsChecker.Bounds.min_x;
boundsChecker.Bounds.extY = boundsChecker.Bounds.max_y - boundsChecker.Bounds.min_y;
return boundsChecker.Bounds;
};
}
function SplineForDrawer(spline) {
this.spline = spline;
this.pen = spline.pen;
this.brush = spline.brush;
this.TransformMatrix = spline.TransformMatrix;
this.Matrix = spline.Matrix;
this.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
g._e();
for (var i = 0; i < this.spline.path.length; ++i) {
var lastX, lastY;
switch (this.spline.path[i].id) {
case 0:
g._m(this.spline.path[i].x, this.spline.path[i].y);
lastX = this.spline.path[i].x;
lastY = this.spline.path[i].y;
break;
case 1:
g._l(this.spline.path[i].x, this.spline.path[i].y);
lastX = this.spline.path[i].x;
lastY = this.spline.path[i].y;
break;
case 2:
g._c(this.spline.path[i].x1, this.spline.path[i].y1, this.spline.path[i].x2, this.spline.path[i].y2, this.spline.path[i].x3, this.spline.path[i].y3);
lastX = this.spline.path[i].x3;
lastY = this.spline.path[i].y3;
break;
}
}
g.ds();
};
}