3.0 source code
This commit is contained in:
294
OfficeWeb/sdk/Common/Drawings/TrackObjects/AdjustmentTracks.js
Normal file
294
OfficeWeb/sdk/Common/Drawings/TrackObjects/AdjustmentTracks.js
Normal 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;
|
||||
313
OfficeWeb/sdk/Common/Drawings/TrackObjects/MoveTracks.js
Normal file
313
OfficeWeb/sdk/Common/Drawings/TrackObjects/MoveTracks.js
Normal 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);
|
||||
};
|
||||
}
|
||||
431
OfficeWeb/sdk/Common/Drawings/TrackObjects/NewShapeTracks.js
Normal file
431
OfficeWeb/sdk/Common/Drawings/TrackObjects/NewShapeTracks.js
Normal 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;
|
||||
};
|
||||
}
|
||||
200
OfficeWeb/sdk/Common/Drawings/TrackObjects/PolyLine.js
Normal file
200
OfficeWeb/sdk/Common/Drawings/TrackObjects/PolyLine.js
Normal 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();
|
||||
};
|
||||
}
|
||||
1178
OfficeWeb/sdk/Common/Drawings/TrackObjects/ResizeTracks.js
Normal file
1178
OfficeWeb/sdk/Common/Drawings/TrackObjects/ResizeTracks.js
Normal file
File diff suppressed because it is too large
Load Diff
361
OfficeWeb/sdk/Common/Drawings/TrackObjects/RotateTracks.js
Normal file
361
OfficeWeb/sdk/Common/Drawings/TrackObjects/RotateTracks.js
Normal 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);
|
||||
};
|
||||
}
|
||||
312
OfficeWeb/sdk/Common/Drawings/TrackObjects/Spline.js
Normal file
312
OfficeWeb/sdk/Common/Drawings/TrackObjects/Spline.js
Normal 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();
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user