Commit f1bae02f authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

delete

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58063 954022d7-b5bf-4e40-9824-e11837661b57
parent bd066bd6
"use strict";
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 7/1/13
* Time: 11:15 AM
* To change this template use File | Settings | File Templates.
*/
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]);
};
}
\ No newline at end of file
"use strict";
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 6/28/13
* Time: 4:14 PM
* To change this template use File | Settings | File Templates.
*/
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,/* this.originalObject.pen*/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);
};
}
"use strict";
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 6/28/13
* Time: 11:18 AM
* To change this template use File | Settings | File Templates.
*/
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;
};
}
\ No newline at end of file
"use strict";
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();
};
}
\ No newline at end of file
"use strict";
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 6/27/13
* Time: 4:35 PM
* To change this template use File | Settings | File Templates.
*/
var TRANSLATE_HANDLE_NO_FLIP = [];
TRANSLATE_HANDLE_NO_FLIP[0] = 0;
TRANSLATE_HANDLE_NO_FLIP[1] = 1;
TRANSLATE_HANDLE_NO_FLIP[2] = 2;
TRANSLATE_HANDLE_NO_FLIP[3] = 3;
TRANSLATE_HANDLE_NO_FLIP[4] = 4;
TRANSLATE_HANDLE_NO_FLIP[5] = 5;
TRANSLATE_HANDLE_NO_FLIP[6] = 6;
TRANSLATE_HANDLE_NO_FLIP[7] = 7;
var TRANSLATE_HANDLE_FLIP_H = [];
TRANSLATE_HANDLE_FLIP_H[0] = 2;
TRANSLATE_HANDLE_FLIP_H[1] = 1;
TRANSLATE_HANDLE_FLIP_H[2] = 0;
TRANSLATE_HANDLE_FLIP_H[3] = 7;
TRANSLATE_HANDLE_FLIP_H[4] = 6;
TRANSLATE_HANDLE_FLIP_H[5] = 5;
TRANSLATE_HANDLE_FLIP_H[6] = 4;
TRANSLATE_HANDLE_FLIP_H[7] = 3;
var TRANSLATE_HANDLE_FLIP_V = [];
TRANSLATE_HANDLE_FLIP_V[0] = 6;
TRANSLATE_HANDLE_FLIP_V[1] = 5;
TRANSLATE_HANDLE_FLIP_V[2] = 4;
TRANSLATE_HANDLE_FLIP_V[3] = 3;
TRANSLATE_HANDLE_FLIP_V[4] = 2;
TRANSLATE_HANDLE_FLIP_V[5] = 1;
TRANSLATE_HANDLE_FLIP_V[6] = 0;
TRANSLATE_HANDLE_FLIP_V[7] = 7;
var TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V = [];
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[0] = 4;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[1] = 5;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[2] = 6;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[3] = 7;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[4] = 0;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[5] = 1;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[6] = 2;
TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[7] = 3;
var SHAPE_ASPECTS = {};
SHAPE_ASPECTS["can"] = 3616635/4810125;
SHAPE_ASPECTS["moon"] = 0.5;
SHAPE_ASPECTS["leftBracket"] = 0.08;
SHAPE_ASPECTS["rightBracket"] = 0.08;
SHAPE_ASPECTS["leftBrace"] = 0.17;
SHAPE_ASPECTS["rightBrace"] = 0.17;
//TODO:
var MIN_SHAPE_SIZE = 1.27;//размер меньше которого нельзя уменшить автофигуру или картинку по горизонтали или вертикали
var MIN_SHAPE_SIZE_DIV2 = MIN_SHAPE_SIZE/2.0;
var MIN_ANGLE = 0.07;
function ResizeTrackShapeImage(originalObject, cardDirection)
{
this.originalObject = originalObject;
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
var numberHandle = this.numberHandle;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
var _flip_h = originalObject.flipH;
var _flip_v = originalObject.flipV;
var _half_height = originalObject.extY*0.5;
var _half_width = originalObject.extX*0.5;
var _sin = Math.sin(originalObject.rot);
var _cos = Math.cos(originalObject.rot);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalObject.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalObject.x;
this.resizedPosY = originalObject.y;
this.resizedRot = originalObject.rot;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = originalObject.spPr.geometry ? originalObject.spPr.geometry.createDuplicate() : (function(){ var geometry = CreateGeometry("rect"); geometry.Init(5, 5); return geometry})();
this.brush = originalObject.brush;
this.pen = originalObject.pen;
this.isLine = originalObject.spPr.geometry && originalObject.spPr.geometry.preset === "line";
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e)
{
if(!e.CtrlKey)
this.resize(kd1, kd2, e.ShiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.ShiftKey)
};
this.resize = function(kd1, kd2, ShiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
}
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV;
if(this.isLine && ShiftKey)
{
this.resizedflipH = !this.originalFlipH;
}
}
else
{
this.resizedflipV = this.originalFlipV;
if(this.isLine && ShiftKey && this.resizedflipH !== this.originalFlipH)
{
this.resizedflipV = !this.originalFlipV;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
if(this.isLine && ShiftKey)
{
this.resizedflipV = !this.originalFlipV;
}
}
else
{
this.resizedflipH = this.originalFlipH;
if(this.isLine && ShiftKey && this.resizedflipV !== this.originalFlipV)
{
this.resizedflipH = !this.originalFlipH;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV;
if(this.isLine && ShiftKey)
{
this.resizedflipH = !this.originalFlipH;
}
}
else
{
this.resizedflipV = this.originalFlipV;
if(this.isLine && ShiftKey && this.resizedflipH !== this.originalFlipH)
{
this.resizedflipV = !this.originalFlipV;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
if(this.isLine && ShiftKey)
{
this.resizedflipV = !this.originalFlipV;
}
}
else
{
this.resizedflipH = this.originalFlipH;
if(this.isLine && ShiftKey && this.resizedflipV !== this.originalFlipV)
{
this.resizedflipH = !this.originalFlipH;
}
}
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.resizeRelativeCenter = function(kd1, kd2, ShiftKey)
{
if(this.isLine)
{
this.resize(kd1, kd2, ShiftKey);
return;
}
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
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.getBoundsRect = function()
{
var t = this.transform;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
this.originalObject.setXfrm(this.resizedPosX, this.resizedPosY, this.resizedExtX, this.resizedExtY, null, this.resizedflipH, this.resizedflipV);
};
}
function ResizeTrackShapeImageInGroup(originalObject, cardDirection)
{
this.originalObject = originalObject;
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
var numberHandle = this.numberHandle;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
var _flip_h = originalObject.flipH;
var _flip_v = originalObject.flipV;
var _half_height = originalObject.extY*0.5;
var _half_width = originalObject.extX*0.5;
var _sin = Math.sin(originalObject.rot);
var _cos = Math.cos(originalObject.rot);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalObject.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalObject.x;
this.resizedPosY = originalObject.y;
this.resizedRot = originalObject.rot;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = originalObject.spPr.geometry.createDuplicate();
this.brush = originalObject.brush;
this.pen = originalObject.pen;
this.isLine = originalObject.spPr.geometry && originalObject.spPr.geometry.preset === "line";
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e)
{
if(!e.CtrlKey)
this.resize(kd1, kd2, e.ShiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.ShiftKey)
};
this.resize = function(kd1, kd2, ShiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.isLine ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.originalObject.group.getTransformMatrix());
};
this.resizeRelativeCenter = function(kd1, kd2, ShiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
global_MatrixTransformer.MultiplyAppend(_transform, this.originalObject.group.getTransformMatrix());
};
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.getBoundsRect = function()
{
var t = this.transform;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
var scale_scale_coefficients = this.originalObject.group.getResultScaleCoefficients();
var xfrm = this.originalObject.group.spPr.xfrm;
this.originalObject.setOffset(this.resizedPosX/scale_scale_coefficients.cx + xfrm.chOffX, this.resizedPosY/scale_scale_coefficients.cy + xfrm.chOffY);
this.originalObject.setExtents(this.resizedExtX/scale_scale_coefficients.cx, this.resizedExtY/scale_scale_coefficients.cy);
this.originalObject.setFlips(this.resizedflipH, this.resizedflipV);
};
}
function ResizeTrackGroup(originalObject, cardDirection, parentTrack)
{
this.original = originalObject;
this.originalObject = originalObject;
this.parentTrack = parentTrack;
var numberHandle;
if(isRealNumber(cardDirection))
{
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
numberHandle = this.numberHandle;
}
this.x = originalObject.x;
this.y = originalObject.y;
this.extX = originalObject.extX;
this.extY = originalObject.extY;
this.rot = originalObject.rot;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
this.transform = originalObject.transform.CreateDublicate();
this.bSwapCoef = !(this.rot < Math.PI*0.25 || this.rot>Math.PI*1.75 || (this.rot>Math.PI*0.75 && this.rot<Math.PI*1.25));
this.childs = [];
var a = originalObject.spTree;
for(var i = 0; i < a.length; ++i)
{
if(a[i].isGroup())
this.childs[i] = new ResizeTrackGroup(a[i], null, this);
else
this.childs[i] = new ShapeForResizeInGroup(a[i], this);
}
if(typeof numberHandle === "number")
{
var _translated_num_handle;
var _flip_h = this.flipH;
var _flip_v = this.flipV;
var _sin = Math.sin(this.rot);
var _cos = Math.cos(this.rot);
var _half_width = this.extX*0.5;
var _half_height = this.extY*0.5;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.original.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + this.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + this.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + this.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + this.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + this.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = this.x + _half_width;
this.centerPointY = this.y + _half_height;
this.lineFlag = false;
this.originalExtX = this.extX;
this.originalExtY = this.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = this.x;
this.resizedPosY = this.y;
this.resizedRot = this.rot;
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
}
if(this.parentTrack)
{
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
}
this.track = function(kd1, kd2, e)
{
if(!e.CtrlKey)
this.resize(kd1, kd2, e.ShiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.ShiftKey)
};
this.resize = function(kd1, kd2, ShiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.x = this.resizedPosX;
this.y = this.resizedPosY;
this.extX = this.resizedExtX;
this.extY = this.resizedExtY;
this.flipH = this.resizedflipH;
this.flipV = this.resizedflipV;
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var xfrm = this.original.spPr.xfrm;
var kw = this.resizedExtX/xfrm.extX;
var kh = this.resizedExtY/xfrm.extY;
for(var i = 0; i < this.childs.length; ++i)
{
var cur_child = this.childs[i];
cur_child.updateSize(kw, kh);
}
};
this.resizeRelativeCenter = function(kd1, kd2, ShiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.x = this.resizedPosX;
this.y = this.resizedPosY;
this.extX = this.resizedExtX;
this.extY = this.resizedExtY;
this.flipH = this.resizedflipH;
this.flipV = this.resizedflipV;
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
var xfrm = this.original.spPr.xfrm;
var kw = this.resizedExtX/xfrm.extX;
var kh = this.resizedExtY/xfrm.extY;
for(var i = 0; i< this.childs.length; ++i)
{
this.childs[i].updateSize(kw, kh);
}
};
this.updateSize = function(kw, kh)
{
var _kw, _kh;
if(this.bSwapCoef)
{
_kw = kh;
_kh = kw;
}
else
{
_kw = kw;
_kh = kh;
}
var xfrm = this.original.spPr.xfrm;
this.extX = xfrm.extX*_kw;
this.extY = xfrm.extY*_kh;
this.x = this.centerDistX*kw + this.parentTrack.extX*0.5 - this.extX*0.5;
this.y = this.centerDistY*kh + this.parentTrack.extY*0.5 - this.extY*0.5;
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(xfrm.flipH == null ? false : xfrm.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(xfrm.flipV == null ? false : xfrm.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, xfrm.rot == null ? 0 : -xfrm.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].updateSize(_kw, _kh);
}
};
this.draw = function(graphics)
{
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].draw(graphics);
}
};
this.getBoundsRect = function()
{
var t = this.transform;
var min_x, max_x, min_y, max_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.extX, y: 0}, {x: this.extX, y: this.extY}, {x: 0, y: this.extY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};};
this.trackEnd = function()
{
if(!isRealObject(this.original.group))
{
this.original.normalize();
}
this.original.setOffset(this.x, this.y);
this.original.setExtents(this.extX, this.extY);
this.original.setChildExtents(this.extX, this.extY);
this.original.setFlips(this.flipH, this.flipV);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].trackEnd();
}
};
}
function ShapeForResizeInGroup(originalObject, parentTrack)
{
this.originalObject = originalObject;
this.parentTrack = parentTrack;
this.x = originalObject.x;
this.y = originalObject.y;
this.extX = originalObject.extX;
this.extY = originalObject.extY;
this.rot = originalObject.rot;
this.flipH = originalObject.flipH;
this.flipV = originalObject.flipV;
this.transform = originalObject.transform.CreateDublicate();
this.bSwapCoef = !(this.rot < Math.PI*0.25 || this.rot>Math.PI*1.75 || (this.rot>Math.PI*0.75 && this.rot<Math.PI*1.25));
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
this.geometry = originalObject.spPr.geometry !== null ? originalObject.spPr.geometry.createDuplicate() : null;
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
}
this.overlayObject = new OverlayObject(this.geometry, this.extX, this.extY, originalObject.brush, originalObject.pen, this.transform);
this.updateSize = function(kw, kh)
{
var _kw, _kh;
if(this.bSwapCoef)
{
_kw = kh;
_kh = kw;
}
else
{
_kw = kw;
_kh = kh;
}
this.extX = this.originalObject.extX*_kw;
this.extY = this.originalObject.extY*_kh;
this.x = this.centerDistX*kw + this.parentTrack.extX*0.5 - this.extX*0.5;
this.y = this.centerDistY*kh + this.parentTrack.extY*0.5 - this.extY*0.5;
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
}
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(this.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.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.trackEnd = function()
{
this.originalObject.setOffset(this.x, this.y);
this.originalObject.setExtents(this.extX, this.extY);
if(this.originalObject.spPr.geometry !== null)
this.originalObject.spPr.geometry.Recalculate(this.extX, this.extY);
};
this.updateTransform = function()
{
this.transform.Reset();
var t = this.transform;
global_MatrixTransformer.TranslateAppend(t, -this.extX*0.5, -this.extY*0.5);
if(this.flipH)
{
global_MatrixTransformer.ScaleAppend(t, -1, 1);
}
if(this.flipV)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, -this.rot);
global_MatrixTransformer.TranslateAppend(t, this.x + this.extX*0.5, this.y+this.extY*0.5);
if(this.parentTrack)
global_MatrixTransformer.MultiplyAppend(t, this.parentTrack.transform);
};
}
function ResizeTrackChart(originalObject, cardDirection)
{
this.originalObject = originalObject;
this.numberHandle = originalObject.getNumByCardDirection(cardDirection);
var numberHandle = this.numberHandle;
this.flipH = false;
this.flipV = false;
var _flip_h = false;
var _flip_v = false;
var _half_height = originalObject.extY*0.5;
var _half_width = originalObject.extX*0.5;
var _sin = Math.sin(0);
var _cos = Math.cos(0);
var _translated_num_handle;
if(!_flip_h && !_flip_v)
{
_translated_num_handle = numberHandle;
}
else if(_flip_h && !_flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H[numberHandle];
}
else if(!_flip_h && _flip_v)
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_V[numberHandle];
}
else
{
_translated_num_handle = TRANSLATE_HANDLE_FLIP_H_AND_FLIP_V[numberHandle];
}
this.bAspect = numberHandle % 2 === 0;
this.aspect = this.bAspect === true ? this.originalObject.getAspect(_translated_num_handle) : 0;
this.sin = _sin;
this.cos = _cos;
this.translatetNumberHandle = _translated_num_handle;
switch (_translated_num_handle)
{
case 0:
case 1:
{
this.fixedPointX = (_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 2:
case 3:
{
this.fixedPointX = (-_half_width*_cos - _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin + _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 4:
case 5:
{
this.fixedPointX = (-_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (-_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
case 6:
case 7:
{
this.fixedPointX = (_half_width*_cos + _half_height*_sin) + _half_width + originalObject.x;
this.fixedPointY = (_half_width*_sin - _half_height*_cos) + _half_height + originalObject.y;
break;
}
}
this.mod = this.translatetNumberHandle % 4;
this.centerPointX = originalObject.x + _half_width;
this.centerPointY = originalObject.y + _half_height;
//this.lineFlag = originalObject.checkLine();
this.originalExtX = originalObject.extX;
this.originalExtY = originalObject.extY;
this.originalFlipH = _flip_h;
this.originalFlipV = _flip_v;
this.usedExtX = this.originalExtX === 0 ? (/*this.lineFlag ? this.originalExtX :*/ 0.01) : this.originalExtX;
this.usedExtY = this.originalExtY === 0 ? (/*this.lineFlag ? this.originalExtY :*/ 0.01) : this.originalExtY;
this.resizedExtX = this.originalExtX;
this.resizedExtY = this.originalExtY;
this.resizedflipH = _flip_h;
this.resizedflipV = _flip_v;
this.resizedPosX = originalObject.x;
this.resizedPosY = originalObject.y;
this.resizedRot = 0;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = originalObject.spPr.geometry.createDuplicate();
this.brush = originalObject.brush;
this.pen = originalObject.pen;
this.geometry = CreateGeometry("rect");
this.geometry.Init(this.originalObject.extX, this.originalObject.extY);
this.geometry.Recalculate(this.originalObject.extX, this.originalObject.extY);
this.brush = new CUniFill();
this.brush.fill = new CSolidFill();
this.brush.fill.color = new CUniColor();
this.brush.fill.color.RGBA = {R:255, G:255, B:255, A:255};
this.brush.fill.color.color = new CRGBColor();
this.brush.fill.color.color.RGBA = {R:255, G:255, B:255, A:255};
this.pen = new CLn();
this.pen.Fill = new CUniFill();
this.pen.Fill.fill = new CSolidFill();
this.pen.Fill.fill.color = new CUniColor();
this.pen.Fill.fill.color.color = new CRGBColor();
this.bChangeCoef = this.translatetNumberHandle % 2 === 0 && this.originalFlipH !== this.originalFlipV;
this.overlayObject = new OverlayObject(this.geometry, this.resizedExtX, this.resizedExtY, this.brush, this.pen, this.transform);
this.track = function(kd1, kd2, e)
{
if(!e.CtrlKey)
this.resize(kd1, kd2, e.ShiftKey);
else
this.resizeRelativeCenter(kd1, kd2, e.ShiftKey)
};
this.resize = function(kd1, kd2, ShiftKey)
{
var _cos = this.cos;
var _sin = this.sin;
var _real_height, _real_width;
var _abs_height, _abs_width;
var _new_resize_half_width;
var _new_resize_half_height;
var _new_used_half_width;
var _new_used_half_height;
var _temp;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
switch (this.translatetNumberHandle)
{
case 0:
case 1:
{
if(this.translatetNumberHandle === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
if(this.translatetNumberHandle === 1)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 2:
case 3:
{
if(this.translatetNumberHandle === 2)
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos + _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin - _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 4:
case 5:
{
if(this.translatetNumberHandle === 4)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
case 6:
case 7:
{
if(this.translatetNumberHandle === 6)
{
_real_height = this.usedExtY*kd1;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
this.resizedflipV = this.originalFlipV;
}
else
{
_temp = kd2;
kd2 = kd1;
kd1 = _temp;
}
_real_width = this.usedExtX*kd2;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
this.resizedflipH = this.originalFlipH;
_new_resize_half_width = this.resizedExtX*0.5;
_new_resize_half_height = this.resizedExtY*0.5;
if(this.resizedflipH !== this.originalFlipH)
{
_new_used_half_width = -_new_resize_half_width;
}
else
{
_new_used_half_width = _new_resize_half_width;
}
if(this.resizedflipV !== this.originalFlipV)
{
_new_used_half_height = -_new_resize_half_height;
}
else
{
_new_used_half_height = _new_resize_half_height;
}
this.resizedPosX = this.fixedPointX + (-_new_used_half_width*_cos - _new_used_half_height*_sin) - _new_resize_half_width;
this.resizedPosY = this.fixedPointY + (-_new_used_half_width*_sin + _new_used_half_height*_cos) - _new_resize_half_height;
break;
}
}
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
this.resizeRelativeCenter = function(kd1, kd2, ShiftKey)
{
kd1 = 2*kd1 - 1;
kd2 = 2*kd2 - 1;
var _real_height, _real_width;
var _abs_height, _abs_width;
if(ShiftKey === true && this.bAspect === true)
{
var _new_aspect = this.aspect*(Math.abs(kd1/ kd2));
if (_new_aspect >= this.aspect)
kd2 = Math.abs(kd1)*(kd2 >= 0 ? 1 : -1 );
else
kd1 = Math.abs(kd2)*(kd1 >= 0 ? 1 : -1);
}
var _temp;
if(this.bChangeCoef)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
if(this.mod === 0 || this.mod === 1)
{
if(this.mod === 0)
{
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
else
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
}
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
else
{
if(this.mod === 2)
{
_temp = kd1;
kd1 = kd2;
kd2 = _temp;
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
}
_real_width = this.usedExtX*kd1;
_abs_width = Math.abs(_real_width);
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
this.resizedPosX = this.centerPointX - this.resizedExtX*0.5;
this.resizedPosY = this.centerPointY - this.resizedExtY*0.5;
this.geometry.Recalculate(this.resizedExtX, this.resizedExtY);
this.overlayObject.updateExtents(this.resizedExtX, this.resizedExtY);
var _transform = this.transform;
_transform.Reset();
var _horizontal_center = this.resizedExtX*0.5;
var _vertical_center = this.resizedExtY*0.5;
global_MatrixTransformer.TranslateAppend(_transform, -_horizontal_center, -_vertical_center);
if(this.resizedflipH)
{
global_MatrixTransformer.ScaleAppend(_transform, -1, 1);
}
if(this.resizedflipV)
{
global_MatrixTransformer.ScaleAppend(_transform, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(_transform, -this.resizedRot);
global_MatrixTransformer.TranslateAppend(_transform, this.resizedPosX, this.resizedPosY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
};
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.getBoundsRect = function()
{
var t = this.transform;
var max_x, min_x, max_y, min_y;
min_x = t.TransformPointX(0, 0);
max_x = min_x;
min_y = t.TransformPointY(0, 0);
max_y = min_y;
var arr = [{x: this.resizedExtX, y: 0}, {x: this.resizedExtX, y: this.resizedExtY}, {x: 0, y: this.resizedExtY}];
var t_x, t_y;
for(var i = 0; i < arr.length; ++i)
{
var p = arr[i];
t_x = t.TransformPointX(p.x, p.y);
t_y = t.TransformPointY(p.x, p.y);
if(t_x < min_x)
min_x = t_x;
if(t_x > max_x)
max_x = t_x;
if(t_y < min_y)
min_y = t_y;
if(t_y > max_y)
max_y = t_y;
}
return {l: min_x, t: min_y, r: max_x, b: max_y};
};
this.trackEnd = function()
{
this.originalObject.x = this.resizedPosX;
this.originalObject.y = this.resizedPosY;
this.originalObject.extX = this.resizedExtX;
this.originalObject.extY = this.resizedExtY;
this.originalObject.setOffset(this.resizedPosX, this.resizedPosY);
this.originalObject.setExtents(this.resizedExtX, this.resizedExtY);
};
}
"use strict";
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 6/27/13
* Time: 3:29 PM
* To change this template use File | Settings | File Templates.
*/
function OverlayObject(geometry, extX, extY, brush, pen, transform)
//({check_bounds: function(){},brush: this.originalShape.brush, pen: this.originalShape.pen, ext:{cx:this.originalShape.absExtX, cy:this.originalShape.absExtY}, geometry: this.geometry, TransformMatrix: this.originalShape.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);
}
}
\ No newline at end of file
"use strict";
var K=1/4;
var mt=0, lt=1, cb=2, cl=3;
function SplineCommandMoveTo(x, y)
{
this.id = 0;
this.x = x;
this.y = y;
}
function SplineCommandLineTo(x, y)
{
this.id = 1;
this.x = x;
this.y = y;
this.changeLastPoint = function(x, y)
{
this.x = x;
this.y = y;
}
}
function SplineCommandBezier(x1, y1, x2, y2, x3, y3)
{
this.id = 2;
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
this.x3 = x3;
this.y3 = y3;
this.changeLastPoint = function(x, y)
{
this.x3 = x;
this.y3 = y;
this.x2 = this.x1 + (this.x3 - this.x1)*0.5;
this.y2 = this.y1 + (this.y3 - this.y1)*0.5;
}
}
function Spline(drawingObjects)
{
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();
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment