init repo
This commit is contained in:
265
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/AdjustmentTracks.js
Normal file
265
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/AdjustmentTracks.js
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
function XYAdjustmentTrack(originalShape, adjIndex) {
|
||||
this.originalShape = originalShape;
|
||||
this.geometry = originalShape.spPr.geometry.createDuplicate();
|
||||
this.adjastment = this.geometry.ahXYLst[adjIndex];
|
||||
this.shapeWidth = this.originalShape.extX;
|
||||
this.shapeHeight = this.originalShape.extY;
|
||||
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.draw = function (overlay) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
this.getBounds = function () {
|
||||
var bounds_checker = new CSlideBoundsChecker();
|
||||
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
|
||||
this.draw(bounds_checker);
|
||||
return {
|
||||
l: bounds_checker.Bounds.min_x,
|
||||
t: bounds_checker.Bounds.min_y,
|
||||
r: bounds_checker.Bounds.max_x,
|
||||
b: bounds_checker.Bounds.max_y
|
||||
};
|
||||
};
|
||||
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 () {
|
||||
this.originalShape.setAdjustmentValue(this.refX, this.geometry.gdLst[this.adjastment.gdRefX], this.refY, this.geometry.gdLst[this.adjastment.gdRefY]);
|
||||
};
|
||||
}
|
||||
function PolarAdjustmentTrack(originalShape, adjIndex) {
|
||||
this.originalShape = originalShape;
|
||||
this.geometry = originalShape.spPr.geometry.createDuplicate();
|
||||
this.adjastment = this.geometry.ahPolarLst[adjIndex];
|
||||
this.shapeWidth = this.originalShape.extX;
|
||||
this.shapeHeight = this.originalShape.extY;
|
||||
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.draw = function (overlay) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
this.getBounds = function () {
|
||||
var bounds_checker = new CSlideBoundsChecker();
|
||||
bounds_checker.init(Page_Width, Page_Height, Page_Width, Page_Height);
|
||||
this.draw(bounds_checker);
|
||||
return {
|
||||
l: bounds_checker.Bounds.min_x,
|
||||
t: bounds_checker.Bounds.min_y,
|
||||
r: bounds_checker.Bounds.max_x,
|
||||
b: bounds_checker.Bounds.max_y
|
||||
};
|
||||
};
|
||||
this.track = function (posX, posY) {
|
||||
var _temp_x = posX - this.xLT;
|
||||
var _temp_y = posY - this.yLT;
|
||||
var _sin = this.sin;
|
||||
var _cos = this.cos;
|
||||
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 () {
|
||||
this.originalShape.setAdjustmentValue(this.refR, this.geometry.gdLst[this.adjastment.gdRefR], this.refAng, this.geometry.gdLst[this.adjastment.gdRefAng]);
|
||||
};
|
||||
}
|
||||
279
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/MoveTracks.js
Normal file
279
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/MoveTracks.js
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
function MoveShapeImageTrack(originalObject) {
|
||||
this.originalObject = originalObject;
|
||||
this.transform = new CMatrix();
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform);
|
||||
this.getOriginalBoundsRect = function () {
|
||||
return this.originalObject.getRectBounds();
|
||||
};
|
||||
this.track = function (dx, dy) {
|
||||
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);
|
||||
};
|
||||
this.draw = function (overlay) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
this.originalObject.setXfrm(this.x, this.y, null, null, null, null, null);
|
||||
};
|
||||
}
|
||||
function MoveShapeImageTrackInGroup(originalObject) {
|
||||
this.originalObject = originalObject;
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.transform = new CMatrix();
|
||||
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, this.originalObject.pen, this.transform);
|
||||
this.inv = global_MatrixTransformer.Invert(originalObject.group.transform);
|
||||
this.inv.tx = 0;
|
||||
this.inv.ty = 0;
|
||||
this.draw = function (overlay) {
|
||||
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;
|
||||
this.originalObject.setOffset(this.x / scale_scale_coefficients.cx + xfrm.chOffX, 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.overlayObjects = [];
|
||||
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.getOriginalBoundsRect = function () {
|
||||
return this.originalObject.getRectBounds();
|
||||
};
|
||||
this.track = function (dx, dy) {
|
||||
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) {
|
||||
for (var i = 0; i < this.overlayObjects.length; ++i) {
|
||||
this.overlayObjects[i].draw(overlay);
|
||||
}
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
this.originalObject.setXfrm(this.x, this.y, null, null, null, null, null);
|
||||
};
|
||||
}
|
||||
function MoveTitleInChart(originalObject) {
|
||||
this.originalObject = originalObject;
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.transform = new CMatrix();
|
||||
var pen = new CLn();
|
||||
pen.Fill = new CUniFill();
|
||||
pen.Fill.fill = new CSolidFill();
|
||||
pen.Fill.fill.color = new CUniColor();
|
||||
pen.Fill.fill.color.color = new CRGBColor();
|
||||
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.originalObject.brush, pen, this.transform);
|
||||
this.inv = global_MatrixTransformer.Invert(originalObject.chartGroup.transform);
|
||||
this.inv.tx = 0;
|
||||
this.inv.ty = 0;
|
||||
this.draw = function (overlay) {
|
||||
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;
|
||||
if (this.x + this.originalObject.extX > this.originalObject.chartGroup.extX) {
|
||||
this.x = this.originalObject.chartGroup.extX - this.originalObject.extX;
|
||||
}
|
||||
if (this.x < 0) {
|
||||
this.x = 0;
|
||||
}
|
||||
if (this.y + this.originalObject.extY > this.originalObject.chartGroup.extY) {
|
||||
this.y = this.originalObject.chartGroup.extY - this.originalObject.extY;
|
||||
}
|
||||
if (this.y < 0) {
|
||||
this.y = 0;
|
||||
}
|
||||
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);
|
||||
global_MatrixTransformer.TranslateAppend(t, this.x + this.originalObject.extX * 0.5, this.y + this.originalObject.extY * 0.5);
|
||||
global_MatrixTransformer.MultiplyAppend(t, this.originalObject.chartGroup.getTransformMatrix());
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
this.originalObject.setPosition(this.x, this.y);
|
||||
this.originalObject.chartGroup.recalculate();
|
||||
};
|
||||
}
|
||||
function MoveTrackChart(originalObject) {
|
||||
this.originalObject = originalObject;
|
||||
this.transform = new CMatrix();
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
var geometry = CreateGeometry("rect");
|
||||
geometry.Init(this.originalObject.extX, this.originalObject.extY);
|
||||
geometry.Recalculate(this.originalObject.extX, this.originalObject.extY);
|
||||
var brush = new CUniFill();
|
||||
brush.fill = new CSolidFill();
|
||||
brush.fill.color = new CUniColor();
|
||||
brush.fill.color.RGBA = {
|
||||
R: 255,
|
||||
G: 255,
|
||||
B: 255,
|
||||
A: 255
|
||||
};
|
||||
brush.fill.color.color = new CRGBColor();
|
||||
brush.fill.color.color.RGBA = {
|
||||
R: 255,
|
||||
G: 255,
|
||||
B: 255,
|
||||
A: 255
|
||||
};
|
||||
var pen = new CLn();
|
||||
pen.Fill = new CUniFill();
|
||||
pen.Fill.fill = new CSolidFill();
|
||||
pen.Fill.fill.color = new CUniColor();
|
||||
pen.Fill.fill.color.color = new CRGBColor();
|
||||
this.overlayObject = new OverlayObject(this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, brush, pen, this.transform);
|
||||
this.getOriginalBoundsRect = function () {
|
||||
return this.originalObject.getRectBounds();
|
||||
};
|
||||
this.track = function (dx, dy) {
|
||||
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);
|
||||
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
|
||||
};
|
||||
this.draw = function (overlay) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
this.originalObject.setXfrm(this.x, this.y, null, null, null, null, null);
|
||||
};
|
||||
}
|
||||
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);
|
||||
};
|
||||
}
|
||||
279
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/NewShapeTracks.js
Normal file
279
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/NewShapeTracks.js
Normal file
@@ -0,0 +1,279 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
function NewShapeTrack(drawingObjects, presetGeom, startX, startY) {
|
||||
this.drawingObjects = drawingObjects;
|
||||
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();
|
||||
var theme = drawingObjects.Layout.Master.Theme;
|
||||
var style;
|
||||
if (presetGeom !== "textRect") {
|
||||
style = CreateDefaultShapeStyle();
|
||||
} else {
|
||||
style = CreateDefaultTextRectStyle();
|
||||
}
|
||||
var brush = theme.getFillStyle(style.fillRef.idx);
|
||||
style.fillRef.Color.Calculate(theme, drawingObjects, drawingObjects.Layout, drawingObjects.Layout.Master, {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
});
|
||||
var RGBA = style.fillRef.Color.RGBA;
|
||||
if (style.fillRef.Color.color != null) {
|
||||
if (brush.fill != null && (brush.fill.type == FILL_TYPE_SOLID)) {
|
||||
brush.fill.color = style.fillRef.Color.createDuplicate();
|
||||
}
|
||||
}
|
||||
var pen = theme.getLnStyle(style.lnRef.idx);
|
||||
style.lnRef.Color.Calculate(theme, drawingObjects, drawingObjects.Layout, drawingObjects.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 (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 geometry = CreateGeometry(presetGeom !== "textRect" ? presetGeom : "rect");
|
||||
geometry.Init(5, 5);
|
||||
pen.Fill.calculate(theme, drawingObjects, drawingObjects.Layout, drawingObjects.Layout.Master, RGBA);
|
||||
brush.calculate(theme, drawingObjects, drawingObjects.Layout, drawingObjects.Layout.Master, RGBA);
|
||||
this.isLine = this.presetGeom === "line";
|
||||
this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform);
|
||||
this.shape = null;
|
||||
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.ctrlDown = function () {};
|
||||
this.shiftDown = function () {};
|
||||
this.draw = function (overlay) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
var shape = new CShape(null, this.drawingObjects);
|
||||
shape.setParent(drawingObjects);
|
||||
if (this.presetGeom !== "textRect") {
|
||||
shape.initDefault(this.x, this.y, this.extX, this.extY, this.flipH === true, this.flipV === true, this.presetGeom, this.arrowsCount);
|
||||
} else {
|
||||
shape.initDefaultTextRect(this.x, this.y, this.extX, this.extY, false, false);
|
||||
}
|
||||
return shape;
|
||||
shape.select(this.drawingObjects.graphicObjects);
|
||||
drawingObjects.shapeAdd(drawingObjects.cSld.spTree.length, shape);
|
||||
this.drawingObjects.graphicObjects.State.resultObject = shape;
|
||||
};
|
||||
}
|
||||
188
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/PolyLine.js
Normal file
188
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/PolyLine.js
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
function PolyLine(drawingObjects) {
|
||||
this.drawingObjects = drawingObjects;
|
||||
this.arrPoint = [];
|
||||
this.Matrix = new CMatrixL();
|
||||
this.TransformMatrix = new CMatrixL();
|
||||
this.style = CreateDefaultShapeStyle();
|
||||
var _calculated_line;
|
||||
var wb = this.drawingObjects.getWorkbook();
|
||||
var _theme = wb.theme;
|
||||
var colorMap = GenerateDefaultColorMap().color_map;
|
||||
var RGBA = {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
};
|
||||
if (isRealObject(_theme) && typeof _theme.getLnStyle === "function" && isRealObject(this.style) && isRealObject(this.style.lnRef) && isRealNumber(this.style.lnRef.idx) && isRealObject(this.style.lnRef.Color) && typeof this.style.lnRef.Color.Calculate === "function") {
|
||||
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
|
||||
this.style.lnRef.Color.Calculate(_theme, colorMap, {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
});
|
||||
RGBA = this.style.lnRef.Color.RGBA;
|
||||
} else {
|
||||
_calculated_line = new CLn();
|
||||
}
|
||||
if (isRealObject(_calculated_line.Fill)) {
|
||||
_calculated_line.Fill.calculate(_theme, colorMap, RGBA);
|
||||
}
|
||||
this.pen = _calculated_line;
|
||||
this.polylineForDrawer = new PolylineForDrawer(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) {
|
||||
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.getLeftTopPoint = function () {
|
||||
if (this.arrPoint.length < 1) {
|
||||
return {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
}
|
||||
var xMax = this.arrPoint[0].x,
|
||||
yMax = this.arrPoint[0].y,
|
||||
xMin = xMax,
|
||||
yMin = yMax;
|
||||
var i;
|
||||
for (i = 1; i < this.arrPoint.length; ++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;
|
||||
}
|
||||
}
|
||||
return {
|
||||
x: xMin,
|
||||
y: yMin
|
||||
};
|
||||
};
|
||||
this.createShape = function (document) {
|
||||
var xMax = this.arrPoint[0].x,
|
||||
yMax = this.arrPoint[0].y,
|
||||
xMin = xMax,
|
||||
yMin = yMax;
|
||||
var i;
|
||||
var bClosed = false;
|
||||
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;
|
||||
var dd = editor.WordControl.m_oDrawingDocument;
|
||||
if (Math.sqrt(dx * dx + dy * dy) < dd.GetMMPerDot(3)) {
|
||||
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(this.drawingObjects);
|
||||
shape.setPosition(xMin, yMin);
|
||||
shape.setExtents(xMax - xMin, yMax - yMin);
|
||||
shape.setStyle(CreateDefaultShapeStyle());
|
||||
var geometry = new Geometry();
|
||||
geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, xMax - xMin, yMax - yMin);
|
||||
geometry.AddRect("l", "t", "r", "b");
|
||||
geometry.AddPathCommand(1, (this.arrPoint[0].x - xMin) + "", (this.arrPoint[0].y - yMin) + "");
|
||||
for (i = 1; i < _n; ++i) {
|
||||
geometry.AddPathCommand(2, (this.arrPoint[i].x - xMin) + "", (this.arrPoint[i].y - yMin) + "");
|
||||
}
|
||||
if (bClosed) {
|
||||
geometry.AddPathCommand(6);
|
||||
}
|
||||
shape.setGeometry(geometry);
|
||||
shape.recalculate();
|
||||
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();
|
||||
};
|
||||
}
|
||||
1946
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/ResizeTracks.js
Normal file
1946
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/ResizeTracks.js
Normal file
File diff suppressed because it is too large
Load Diff
264
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/RotateTracks.js
Normal file
264
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/RotateTracks.js
Normal file
@@ -0,0 +1,264 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
function OverlayObject(geometry, extX, extY, brush, pen, transform) {
|
||||
this.geometry = geometry;
|
||||
this.ext = {};
|
||||
this.ext.cx = extX;
|
||||
this.ext.cy = extY;
|
||||
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.transform = transform;
|
||||
};
|
||||
this.updateExtents = function (extX, extY) {
|
||||
this.ext.cx = extX;
|
||||
this.ext.cy = extY;
|
||||
this.geometry.Recalculate(extX, extY);
|
||||
};
|
||||
this.updateTransformMatrix = function (transform) {
|
||||
this.TransformMatrix = transform;
|
||||
};
|
||||
this.draw = function (overlay) {
|
||||
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 {
|
||||
overlay.SetIntegerGrid(false);
|
||||
overlay.transform3(this.TransformMatrix);
|
||||
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();
|
||||
}
|
||||
};
|
||||
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 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;
|
||||
this.draw = function (overlay) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
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);
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
this.originalObject.setXfrm(null, null, null, null, this.angle, null, null);
|
||||
};
|
||||
}
|
||||
function RotateTrackShapeImageInGroup(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) {
|
||||
this.overlayObject.draw(overlay);
|
||||
};
|
||||
this.track = function (angle, e) {
|
||||
var new_rot = this.signum * 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);
|
||||
global_MatrixTransformer.MultiplyAppend(this.transform, this.originalObject.group.getTransformMatrix());
|
||||
};
|
||||
this.trackEnd = function () {
|
||||
this.originalObject.setRotate(this.angle);
|
||||
};
|
||||
}
|
||||
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) {
|
||||
for (var i = 0; i < this.overlayObjects.length; ++i) {
|
||||
this.overlayObjects[i].draw(overlay);
|
||||
}
|
||||
};
|
||||
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 () {
|
||||
this.originalObject.setRotate(this.angle);
|
||||
};
|
||||
}
|
||||
326
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/Spline.js
Normal file
326
OfficeWeb/sdk/PowerPoint/Editor/TrackObjects/Spline.js
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
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) {
|
||||
this.path = [];
|
||||
this.drawingObjects = drawingObjects;
|
||||
this.Matrix = new CMatrix();
|
||||
this.TransformMatrix = new CMatrix();
|
||||
this.style = CreateDefaultShapeStyle();
|
||||
var _calculated_line;
|
||||
var _theme = drawingObjects.getWorkbook().theme;
|
||||
var colorMap = GenerateDefaultColorMap().color_map;
|
||||
var RGBA = {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
};
|
||||
if (isRealObject(_theme) && typeof _theme.getLnStyle === "function" && isRealObject(this.style) && isRealObject(this.style.lnRef) && isRealNumber(this.style.lnRef.idx) && isRealObject(this.style.lnRef.Color) && typeof this.style.lnRef.Color.Calculate === "function") {
|
||||
_calculated_line = _theme.getLnStyle(this.style.lnRef.idx);
|
||||
this.style.lnRef.Color.Calculate(_theme, colorMap, {
|
||||
R: 0,
|
||||
G: 0,
|
||||
B: 0,
|
||||
A: 255
|
||||
});
|
||||
RGBA = this.style.lnRef.Color.RGBA;
|
||||
} else {
|
||||
_calculated_line = new CLn();
|
||||
}
|
||||
if (isRealObject(_calculated_line.Fill)) {
|
||||
_calculated_line.Fill.calculate(_theme, colorMap, RGBA);
|
||||
}
|
||||
this.pen = _calculated_line;
|
||||
this.splineForDraw = new SplineForDrawer(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) {
|
||||
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.getLeftTopPoint = function () {
|
||||
if (this.path.length < 1) {
|
||||
return {
|
||||
x: 0,
|
||||
y: 0
|
||||
};
|
||||
}
|
||||
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;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
x: min_x,
|
||||
y: min_y
|
||||
};
|
||||
};
|
||||
this.createShape = function (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(null, this.drawingObjects);
|
||||
shape.setPosition(xMin, yMin);
|
||||
shape.setExtents(xMax - xMin, yMax - yMin);
|
||||
shape.setStyle(CreateDefaultShapeStyle());
|
||||
var geometry = new CGeometry();
|
||||
geometry.AddPathCommand(0, undefined, bClosed ? "norm" : "none", undefined, xMax - xMin, yMax - yMin);
|
||||
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) + "", (this.path[i].y - yMin) + "");
|
||||
break;
|
||||
case 1:
|
||||
geometry.AddPathCommand(2, (this.path[i].x - xMin) + "", (this.path[i].y - yMin) + "");
|
||||
break;
|
||||
case 2:
|
||||
geometry.AddPathCommand(5, (this.path[i].x1 - xMin) + "", (this.path[i].y1 - yMin) + "", (this.path[i].x2 - xMin) + "", (this.path[i].y2 - yMin) + "", (this.path[i].x3 - xMin) + "", (this.path[i].y3 - yMin) + "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bClosed) {
|
||||
geometry.AddPathCommand(6);
|
||||
}
|
||||
geometry.Init(xMax - xMin, yMax - yMin);
|
||||
shape.spPr.geometry = geometry;
|
||||
shape.recalculate();
|
||||
this.drawingObjects.addGraphicObject(shape);
|
||||
};
|
||||
this.addPathCommand = function (pathCommand) {
|
||||
this.path.push(pathCommand);
|
||||
};
|
||||
}
|
||||
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