init repo

This commit is contained in:
nikolay ivanov
2014-07-05 18:22:49 +00:00
commit a8be6b9e72
17348 changed files with 9229832 additions and 0 deletions

View 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 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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddUndo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Undo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
this.originalShape.setAdjustmentValue(this.refX, this.geometry.gdLst[this.adjastment.gdRefX], this.refY, this.geometry.gdLst[this.adjastment.gdRefY]);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Redo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddRedo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.originalShape.recalculateGeometry();
this.originalShape.calculateContent();
this.originalShape.calculateTransformTextMatrix();
};
}
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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddUndo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Undo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
this.originalShape.setAdjustmentValue(this.refR, this.geometry.gdLst[this.adjastment.gdRefR], this.refAng, this.geometry.gdLst[this.adjastment.gdRefAng]);
this.originalShape.recalculateGeometry();
this.originalShape.calculateContent();
this.originalShape.calculateTransformTextMatrix();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterParagraphAddRedo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateGeometry_Redo, null, null, new UndoRedoDataGraphicObjects(this.originalShape.Id, new UndoRedoDataShapeRecalc()), null);
};
}

View File

@@ -0,0 +1,330 @@
/*
* (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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setPosition(this.x, this.y);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
this.originalObject.updateDrawingBaseCoordinates();
};
}
function MoveShapeImageTrackInGroup(originalObject) {
this.originalObject = originalObject;
this.x = null;
this.y = null;
this.transform = new CMatrix();
var pen, brush;
if (! (typeof CChartAsGroup != "undefined" && this.originalObject instanceof CChartAsGroup)) {
pen = this.originalObject.pen;
brush = this.originalObject.brush;
} else {
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
};
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.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.getTransform());
};
this.trackEnd = function () {
var scale_scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
var xfrm = this.originalObject.group.spPr.xfrm;
this.originalObject.setPosition(this.x / scale_scale_coefficients.cx + xfrm.chOffX, this.y / scale_scale_coefficients.cy + xfrm.chOffY);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
};
}
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].getTransform().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
var pen, brush;
if (! (typeof CChartAsGroup != "undefined" && arr_graphic_objects[i] instanceof CChartAsGroup)) {
pen = arr_graphic_objects[i].pen;
brush = arr_graphic_objects[i].brush;
} else {
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
};
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.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY, brush, 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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.originalObject.setPosition(this.x, this.y);
this.originalObject.recalculate();
this.originalObject.updateDrawingBaseCoordinates();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(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.getTransform());
};
this.trackEnd = function () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.chartGroup.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setPosition(this.x, this.y);
this.originalObject.chartGroup.recalculate();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.chartGroup.Id, new UndoRedoDataShapeRecalc()), null);
};
}
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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.x = this.x;
this.originalObject.y = this.y;
this.originalObject.updateDrawingBaseCoordinates();
this.originalObject.setPosition(this.x, this.y);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateTransformTextMatrix();
};
}

View File

@@ -0,0 +1,344 @@
/*
* (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.headEnd = false;
this.tailEnd = false;
this.x = null;
this.y = null;
this.extX = null;
this.extY = null;
this.flipH = null;
this.flipV = null;
this.transform = new CMatrix();
var theme = drawingObjects.getWorkbook().theme;
var color_map = GenerateDefaultColorMap().color_map;
var style;
if (presetGeom !== "textRect") {
style = CreateDefaultShapeStyle();
} else {
style = CreateDefaultTextRectStyle();
}
var brush = theme.getFillStyle(style.fillRef.idx);
style.fillRef.Color.Calculate(theme, color_map, {
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.type == FILL_TYPE_GRAD)) {
brush.fill.color = style.fillRef.Color.createDuplicate();
}
}
var pen = theme.getLnStyle(style.lnRef.idx);
style.lnRef.Color.Calculate(theme, color_map, {
R: 0,
G: 0,
B: 0,
A: 255
});
RGBA = style.lnRef.Color.RGBA;
var final_preset = presetGeom;
var sPreset = presetGeom;
switch (sPreset) {
case "lineWithArrow":
final_preset = "line";
this.tailEnd = true;
break;
case "lineWithTwoArrows":
final_preset = "line";
this.tailEnd = true;
this.headEnd = true;
break;
case "bentConnector5WithArrow":
final_preset = "bentConnector5";
this.tailEnd = true;
break;
case "bentConnector5WithTwoArrows":
final_preset = "bentConnector5";
this.tailEnd = true;
this.headEnd = true;
break;
case "curvedConnector3WithArrow":
final_preset = "curvedConnector3";
this.tailEnd = true;
break;
case "curvedConnector3WithTwoArrows":
final_preset = "curvedConnector3";
this.tailEnd = true;
this.headEnd = true;
break;
case "textRect":
final_preset = "rect";
break;
default:
final_preset = sPreset;
break;
}
if (presetGeom === "textRect") {
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);
}
} else {
if (this.tailEnd || this.headEnd) {
var ln;
ln = new CLn();
if (this.tailEnd) {
ln.tailEnd = new EndArrow();
ln.tailEnd.type = LineEndType.Arrow;
ln.tailEnd.len = LineEndSize.Mid;
}
if (this.headEnd) {
ln.headEnd = new EndArrow();
ln.headEnd.type = LineEndType.Arrow;
ln.headEnd.len = LineEndSize.Mid;
}
pen.merge(ln);
}
}
pen.Fill.calculate(theme, color_map, RGBA);
brush.calculate(theme, color_map, RGBA);
this.finalPreset = final_preset;
var geometry = CreateGeometry(final_preset);
geometry.Init(5, 5);
this.overlayObject = new OverlayObject(geometry, 5, 5, brush, pen, this.transform);
this.lineFlag = CheckLinePreset(final_preset);
this.isLine = this.lineFlag;
this.track = function (e, x, y) {
this.flipH = false;
this.flipV = false;
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);
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);
if (this.presetGeom !== "textRect") {
shape.initDefault(this.x, this.y, this.extX, this.extY, this.flipH === true, this.flipV === true, this.finalPreset, this.tailEnd, this.headEnd);
} else {
shape.initDefaultTextRect(this.x, this.y, this.extX, this.extY, false, false);
}
shape.select(this.drawingObjects.controller);
this.drawingObjects.controller.curState.resultObject = shape;
var bounds_rect = shape.getRectBounds();
var check_position = shape.drawingObjects.checkGraphicObjectPosition(bounds_rect.minX, bounds_rect.minY, bounds_rect.maxX - bounds_rect.minX, bounds_rect.maxY - bounds_rect.minY);
if (!check_position.result) {
shape.setPosition(this.x + check_position.x, this.y + check_position.y);
shape.recalculateTransform();
shape.calculateContent();
shape.calculateTransformTextMatrix();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterInit, null, null, new UndoRedoDataGraphicObjects(shape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
}
shape.addToDrawingObjects();
};
}
function CheckLinePreset(preset) {
return preset === "line";
}

View File

@@ -0,0 +1,191 @@
/*
* (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;
if (Math.sqrt(dx * dx + dy * dy) < this.drawingObjects.convertMetric(3, 0, 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(null, this.drawingObjects);
shape.setXfrmObject(new CXfrm());
shape.setPosition(xMin, yMin);
shape.setExtents(xMax - xMin, yMax - yMin);
shape.setStyleBinary(CreateDefaultShapeStyle());
var geometry = new CGeometry();
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);
}
geometry.Init(xMax - xMin, yMax - yMin);
shape.setGeometry(geometry);
shape.recalculate();
shape.addToDrawingObjects();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterInit, null, null, new UndoRedoDataGraphicObjects(shape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
return shape;
};
}
function PolylineForDrawer(polyline) {
this.polyline = polyline;
this.pen = polyline.pen;
this.brush = polyline.brush;
this.TransformMatrix = polyline.TransformMatrix;
this.Matrix = polyline.Matrix;
this.Draw = function (graphics) {
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function (g) {
g._e();
if (this.polyline.arrPoint.length < 2) {
return;
}
g._m(this.polyline.arrPoint[0].x, this.polyline.arrPoint[0].y);
for (var i = 1; i < this.polyline.arrPoint.length; ++i) {
g._l(this.polyline.arrPoint[i].x, this.polyline.arrPoint[i].y);
}
g.ds();
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,257 @@
/*
* (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) {
overlay.SaveGrState();
overlay.SetIntegerGrid(false);
overlay.transform3(this.TransformMatrix, false);
this.shapeDrawer.fromShape2(this, overlay, this.geometry);
this.shapeDrawer.draw(this.geometry);
overlay.RestoreGrState();
};
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 = originalObject.transform.CreateDublicate();
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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.setRotate(this.angle);
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateTransformRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Id, new UndoRedoDataShapeRecalc()), null);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
};
}
function RotateTrackShapeImageInGroup(originalObject) {
this.originalObject = originalObject;
this.transform = originalObject.transform.CreateDublicate();
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.getTransform());
};
this.trackEnd = function () {
this.originalObject.setRotate(this.angle);
this.originalObject.recalculateTransform();
this.originalObject.calculateContent();
this.originalObject.calculateTransformTextMatrix();
};
}
function RotateTrackGroup(originalObject) {
this.originalObject = originalObject;
this.transform = originalObject.transform.CreateDublicate();
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].getTransform().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, arr_graphic_objects[i].transform.CreateDublicate());
}
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 () {
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateUndo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
this.originalObject.setRotate(this.angle);
this.originalObject.recalculate();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_GroupRecalculateRedo, null, null, new UndoRedoDataGraphicObjects(this.originalObject.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
};
}

View File

@@ -0,0 +1,329 @@
/*
* (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.setXfrmObject(new CXfrm());
shape.setPosition(xMin, yMin);
shape.setExtents(xMax - xMin, yMax - yMin);
shape.setStyleBinary(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.setGeometry(geometry);
shape.recalculate();
shape.addToDrawingObjects();
History.Add(g_oUndoRedoGraphicObjects, historyitem_AutoShapes_RecalculateAfterInit, null, null, new UndoRedoDataGraphicObjects(shape.Get_Id(), new UndoRedoDataGOSingleProp(null, null)));
return 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();
};
}