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

Поддерка EffectExtent.

Добавлен класс CGraphicObjectBase - базовый для автофигур, картинок, чартов, групп.
parent 088d8993
......@@ -48,6 +48,7 @@
"../common/Drawings/Format/CreateGeometry.js",
"../common/Drawings/Format/Geometry.js",
"../common/Drawings/Format/Format.js",
"../common/Drawings/Format/GraphicObjectBase.js",
"../common/Drawings/Format/Shape.js",
"../common/Drawings/Format/Path.js",
"../common/Drawings/Format/Image.js",
......
......@@ -41,6 +41,7 @@
"../common/Drawings/Format/CreateGeometry.js",
"../common/Drawings/Format/Geometry.js",
"../common/Drawings/Format/Format.js",
"../common/Drawings/Format/GraphicObjectBase.js",
"../common/Drawings/Format/Shape.js",
"../slide/Editor/Format/ShapePrototype.js",
"../common/Drawings/Format/Path.js",
......
......@@ -50,6 +50,7 @@
"../common/Drawings/Format/CreateGeometry.js",
"../common/Drawings/Format/Geometry.js",
"../common/Drawings/Format/Format.js",
"../common/Drawings/Format/GraphicObjectBase.js",
"../common/Drawings/Format/Shape.js",
"../common/Drawings/Format/Path.js",
"../common/Drawings/Format/Image.js",
......
......@@ -45,7 +45,6 @@ CChartSpace.prototype.getNumByCardDirection = CShape.prototype.getNumByCardDirec
CChartSpace.prototype.getCardDirectionByNum = CShape.prototype.getCardDirectionByNum;
CChartSpace.prototype.getResizeCoefficients = CShape.prototype.getResizeCoefficients;
CChartSpace.prototype.check_bounds = CShape.prototype.check_bounds;
CChartSpace.prototype.normalize = CShape.prototype.normalize;
CChartSpace.prototype.getFullFlipH = CShape.prototype.getFullFlipH;
CChartSpace.prototype.getFullFlipV = CShape.prototype.getFullFlipV;
CChartSpace.prototype.setWorksheet = CShape.prototype.setWorksheet;
......@@ -265,7 +264,7 @@ CChartSpace.prototype.recalculate = function()
if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform();
this.calculateSnapArrays();
this.recalculateSnapArrays();
this.rectGeometry.Recalculate(this.extX, this.extY);
this.recalcInfo.recalculateTransform = false;
b_transform = true;
......
......@@ -209,7 +209,7 @@ CGroupShape.prototype.recalculate = function()
if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform();
this.calculateSnapArrays();
this.recalculateSnapArrays();
this.recalcInfo.recalculateTransform = false;
}
if(this.recalcInfo.recalculateArrGraphicObjects)
......
......@@ -145,7 +145,7 @@ CImageShape.prototype.recalculate = function ()
}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.calculateSnapArrays();
this.recalculateSnapArrays();
this.recalcInfo.recalculateTransform = false;
}
......@@ -169,5 +169,4 @@ CImageShape.prototype.getNumByCardDirection = CShape.prototype.getNumByCardDirec
CImageShape.prototype.getCardDirectionByNum = CShape.prototype.getCardDirectionByNum;
CImageShape.prototype.getResizeCoefficients = CShape.prototype.getResizeCoefficients;
CImageShape.prototype.check_bounds = CShape.prototype.check_bounds;
CImageShape.prototype.normalize = CShape.prototype.normalize;
})(window);
......@@ -402,7 +402,7 @@ CShape.prototype.recalculate = function ()
}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.calculateSnapArrays();
this.recalculateSnapArrays();
this.recalcInfo.recalculateTransform = false;
}
......
......@@ -462,11 +462,7 @@ function CheckSpPrXfrm2(object)
}
function checkNormalRotate(rot)
{
var _rot = AscFormat.normalizeRotate(rot);
return (_rot >= 0 && _rot < Math.PI * 0.25) || (_rot >= 3 * Math.PI * 0.25 && _rot < 5 * Math.PI * 0.25) || (_rot >= 7 * Math.PI * 0.25 && _rot < 2 * Math.PI);
}
function getObjectsByTypesFromArr(arr, bGrouped)
{
......@@ -5914,23 +5910,23 @@ DrawingObjectsController.prototype =
getBoundsForGroup: function(arrDrawings)
{
var bounds = arrDrawings[0].getBoundsInGroup();
var max_x = bounds.maxX;
var max_y = bounds.maxY;
var min_x = bounds.minX;
var min_y = bounds.minY;
var max_x = bounds.r;
var max_y = bounds.b;
var min_x = bounds.l;
var min_y = bounds.t;
for(var i = 1; i < arrDrawings.length; ++i)
{
bounds = arrDrawings[i].getBoundsInGroup();
if(max_x < bounds.maxX)
max_x = bounds.maxX;
if(max_y < bounds.maxY)
max_y = bounds.maxY;
if(min_x > bounds.minX)
min_x = bounds.minX;
if(min_y > bounds.minY)
min_y = bounds.minY;
if(max_x < bounds.r)
max_x = bounds.r;
if(max_y < bounds.b)
max_y = bounds.b;
if(min_x > bounds.l)
min_x = bounds.l;
if(min_y > bounds.t)
min_y = bounds.t;
}
return {minX: min_x, maxX: max_x, minY: min_y, maxY: max_y};
return new AscFormat.CGraphicBounds(min_x, min_y, max_x, max_y);
},
......@@ -5941,10 +5937,10 @@ DrawingObjectsController.prototype =
if(arrDrawings.length < 2)
return null;
var bounds = this.getBoundsForGroup(arrDrawings);
var max_x = bounds.maxX;
var max_y = bounds.maxY;
var min_x = bounds.minX;
var min_y = bounds.minY;
var max_x = bounds.r;
var max_y = bounds.b;
var min_x = bounds.l;
var min_y = bounds.t;
var group = new AscFormat.CGroupShape();
group.setSpPr(new AscFormat.CSpPr());
group.spPr.setParent(group);
......@@ -8794,7 +8790,6 @@ function CalcLiterByLength(aAlphaBet, nLength)
window['AscFormat'].CompareGroups = CompareGroups;
window['AscFormat'].CheckSpPrXfrm = CheckSpPrXfrm;
window['AscFormat'].CheckSpPrXfrm2 = CheckSpPrXfrm2;
window['AscFormat'].checkNormalRotate = checkNormalRotate;
window['AscFormat'].getObjectsByTypesFromArr = getObjectsByTypesFromArr;
window['AscFormat'].getTargetTextObject = getTargetTextObject;
window['AscFormat'].DrawingObjectsController = DrawingObjectsController;
......
This diff is collapsed.
This diff is collapsed.
/**
* @param {Window} window
* @param {undefined} undefined
*/
(function (window, undefined) {
function checkNormalRotate(rot)
{
var _rot = AscFormat.normalizeRotate(rot);
return (_rot >= 0 && _rot < Math.PI * 0.25) || (_rot >= 3 * Math.PI * 0.25 && _rot < 5 * Math.PI * 0.25) || (_rot >= 7 * Math.PI * 0.25 && _rot < 2 * Math.PI);
}
function normalizeRotate(rot)
{
var new_rot = rot;
if(AscFormat.isRealNumber(new_rot))
{
while(new_rot >= 2*Math.PI)
new_rot -= 2*Math.PI;
while(new_rot < 0)
new_rot += 2*Math.PI;
return new_rot;
}
return new_rot;
}
/**
* Class represent bounds graphical object
* @param {number} l
* @param {number} t
* @param {number} r
* @param {number} b
* @constructor
*/
function CGraphicBounds(l, t, r, b){
this.l = l;
this.t = t;
this.r = r;
this.b = b;
this.x = l;
this.y = t;
this.w = r - l;
this.h = b - t;
}
/**
* Base class for all graphic objects
* @constructor
*/
function CGraphicObjectBase() {
/*Format fields*/
this.spPr = null;
this.group = null;
this.parent = null;
this.bDeleted = true;
this.Id = '';
/*Calculated fields*/
this.posX = null;
this.posY = null;
this.x = 0;
this.y = 0;
this.extX = 0;
this.extY = 0;
this.rot = 0;
this.flipH = false;
this.flipV = false;
this.bounds = new CGraphicBounds(0, 0, 0, 0);
this.localTransform = new AscCommon.CMatrix();
this.transform = new AscCommon.CMatrix();
this.invertTransform = null;
this.pen = null;
this.brush = null;
this.snapArrayX = [];
this.snapArrayY = [];
this.Lock = new AscCommon.CLock();
this.setRecalculateInfo();
}
/**
* Create a scheme color
* @memberof CGraphicObjectBase
* @returns {CGraphicBounds}
*/
CGraphicObjectBase.prototype.checkBoundsRect = function(){
var aCheckX = [], aCheckY = [];
this.calculateSnapArrays(aCheckX, aCheckY, this.localTransform);
return new CGraphicBounds(Math.min.apply(Math, aCheckX), Math.min.apply(Math, aCheckY), Math.max.apply(Math, aCheckX), Math.max.apply(Math, aCheckY));
};
/**
* Set default recalculate info
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.setRecalculateInfo = function(){};
/**
* Get object Id
* @memberof CGraphicObjectBase
* @returns {string}
*/
CGraphicObjectBase.prototype.Get_Id = function () {
return this.Id;
};
/**
* Get type object
* @memberof CGraphicObjectBase
* @returns {number}
*/
CGraphicObjectBase.prototype.getObjectType = function () {
return AscDFH.historyitem_type_Unknown;
};
/**
* Write object to stream
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.Write_ToBinary2 = function (oWriter) {
oWriter.WriteLong(this.getObjectType());
oWriter.WriteString2(this.Get_Id());
};
/**
* Read object from stream
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.Read_FromBinary2 = function (oReader) {
this.Id = oReader.GetString2();
};
/**
* Get object Id
* @memberof CGraphicObjectBase
* @returns {string}
*/
CGraphicObjectBase.prototype.Get_Id = function () {
return this.Id;
};
/**
* Get object bounds for defining group size
* @memberof CGraphicObjectBase
* @returns {CGraphicBounds}
*/
CGraphicObjectBase.prototype.getBoundsInGroup = function () {
var r = this.rot;
if (!AscFormat.isRealNumber(r) || AscFormat.checkNormalRotate(r)) {
return new CGraphicBounds(this.x, this.y, this.x + this.extX, this.y + this.extY);
}
else {
var hc = this.extX * 0.5;
var vc = this.extY * 0.5;
var xc = this.x + hc;
var yc = this.y + vc;
return new CGraphicBounds(xc - vc, yc - hc, xc + vc, yc + hc);
}
};
/**
* Normalize a size object in group
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.normalize = function () {
var new_off_x, new_off_y, new_ext_x, new_ext_y;
var xfrm = this.spPr.xfrm;
if (!isRealObject(this.group)) {
new_off_x = xfrm.offX;
new_off_y = xfrm.offY;
new_ext_x = xfrm.extX;
new_ext_y = xfrm.extY;
}
else {
var scale_scale_coefficients = this.group.getResultScaleCoefficients();
new_off_x = scale_scale_coefficients.cx * (xfrm.offX - this.group.spPr.xfrm.chOffX);
new_off_y = scale_scale_coefficients.cy * (xfrm.offY - this.group.spPr.xfrm.chOffY);
new_ext_x = scale_scale_coefficients.cx * xfrm.extX;
new_ext_y = scale_scale_coefficients.cy * xfrm.extY;
}
Math.abs(new_off_x - xfrm.offX) > AscFormat.MOVE_DELTA && xfrm.setOffX(new_off_x);
Math.abs(new_off_y - xfrm.offY) > AscFormat.MOVE_DELTA && xfrm.setOffY(new_off_y);
Math.abs(new_ext_x - xfrm.extX) > AscFormat.MOVE_DELTA && xfrm.setExtX(new_ext_x);
Math.abs(new_ext_y - xfrm.extY) > AscFormat.MOVE_DELTA && xfrm.setExtY(new_ext_y);
};
/**
* Check point hit to bounds object
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.checkHitToBounds = function(x, y) {
if(this.parent && (this.parent.Get_ParentTextTransform && this.parent.Get_ParentTextTransform())) {
return true;
}
var _x, _y;
if(AscFormat.isRealNumber(this.posX) && AscFormat.isRealNumber(this.posY)){
_x = x - this.posX - this.bounds.x;
_y = y - this.posY - this.bounds.y;
}
else{
_x = x - this.bounds.x;
_y = y - this.bounds.y;
}
var delta = 3 + (this.pen && AscFormat.isRealNumber(this.pen.w) ? this.pen.w/36000 : 0);
return _x >= -delta && _x <= this.bounds.w + delta && _y >= -delta && _y <= this.bounds.h + delta;
};
/**
* Internal method for calculating snap arrays
* @param {Array} snapArrayX
* @param {Array} snapArrayY
* @param {CMatrix} transform
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.calculateSnapArrays = function(snapArrayX, snapArrayY, transform)
{
var t = transform ? transform : this.transform;
snapArrayX.push(t.TransformPointX(0, 0));
snapArrayY.push(t.TransformPointY(0, 0));
snapArrayX.push(t.TransformPointX(this.extX, 0));
snapArrayY.push(t.TransformPointY(this.extX, 0));
snapArrayX.push(t.TransformPointX(this.extX*0.5, this.extY*0.5));
snapArrayY.push(t.TransformPointY(this.extX*0.5, this.extY*0.5));
snapArrayX.push(t.TransformPointX(this.extX, this.extY));
snapArrayY.push(t.TransformPointY(this.extX, this.extY));
snapArrayX.push(t.TransformPointX(0, this.extY));
snapArrayY.push(t.TransformPointY(0, this.extY));
};
/**
* Public method for calculating snap arrays
* @memberof CGraphicObjectBase
*/
CGraphicObjectBase.prototype.recalculateSnapArrays = function()
{
this.snapArrayX.length = 0;
this.snapArrayY.length = 0;
this.calculateSnapArrays(this.snapArrayX, this.snapArrayY, null);
};
window['AscFormat'] = window['AscFormat'] || {};
window['AscFormat'].CGraphicObjectBase = CGraphicObjectBase;
window['AscFormat'].CGraphicBounds = CGraphicBounds;
window['AscFormat'].checkNormalRotate = checkNormalRotate;
window['AscFormat'].normalizeRotate = normalizeRotate;
})(window);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,8 +15,16 @@ function MoveShapeImageTrack(originalObject)
this.originalShape = originalObject;
if(!originalObject.isChart())
{
if(originalObject.blipFill)
{
this.brush = new AscFormat.CUniFill();
this.brush.fill = originalObject.blipFill;
}
else
{
this.brush = originalObject.brush;
}
this.pen = originalObject.pen;
}
else
......
......@@ -258,8 +258,16 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
this.geometry = !(originalObject.getObjectType() === AscDFH.historyitem_type_ChartSpace) && originalObject.spPr && originalObject.spPr.geometry ? originalObject.spPr.geometry.createDuplicate() : (function(){ var geometry = AscFormat.CreateGeometry("rect"); geometry.Recalculate(5, 5); return geometry})();
if(!originalObject.isChart())
{
if(originalObject.blipFill)
{
this.brush = new AscFormat.CUniFill();
this.brush.fill = originalObject.blipFill;
}
else
{
this.brush = originalObject.brush;
}
this.pen = originalObject.pen;
}
else
......@@ -1540,7 +1548,17 @@ function ShapeForResizeInGroup(originalObject, parentTrack)
{
this.geometry.Recalculate(this.extX, this.extY);
}
this.overlayObject = new AscFormat.OverlayObject(this.geometry, this.extX, this.extY, originalObject.brush, originalObject.pen, this.transform);
var brush;
if(originalObject.blipFill)
{
brush = new AscFormat.CUniFill();
brush.fill = originalObject.blipFill;
}
else
{
brush = originalObject.brush;
}
this.overlayObject = new AscFormat.OverlayObject(this.geometry, this.extX, this.extY, brush, originalObject.pen, this.transform);
this.updateSize = function(kw, kh)
{
var _kw, _kh;
......
......@@ -320,7 +320,17 @@ 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);
var brush;
if(originalObject.blipFill)
{
brush = new AscFormat.CUniFill();
brush.fill = originalObject.blipFill;
}
else
{
brush = originalObject.brush;
}
this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, brush, originalObject.pen, this.transform);
this.angle = originalObject.rot;
var full_flip_h = this.originalObject.getFullFlipH();
......
......@@ -151,7 +151,6 @@ CChartSpace.prototype.getNumByCardDirection = CShape.prototype.getNumByCardDirec
CChartSpace.prototype.getCardDirectionByNum = CShape.prototype.getCardDirectionByNum;
CChartSpace.prototype.getResizeCoefficients = CShape.prototype.getResizeCoefficients;
CChartSpace.prototype.check_bounds = CShape.prototype.check_bounds;
CChartSpace.prototype.normalize = CShape.prototype.normalize;
CChartSpace.prototype.getFullFlipH = CShape.prototype.getFullFlipH;
CChartSpace.prototype.getFullFlipV = CShape.prototype.getFullFlipV;
CChartSpace.prototype.setWorksheet = CShape.prototype.setWorksheet;
......@@ -357,7 +356,7 @@ CChartSpace.prototype.recalculate = function()
this.recalculateTransform();
this.rectGeometry.Recalculate(this.extX, this.extY);
this.recalcInfo.recalculateTransform = false;
this.calculateSnapArrays();
this.recalculateSnapArrays();
b_transform = true;
}
if(this.recalcInfo.recalculateReferences)
......
......@@ -203,7 +203,7 @@ CGroupShape.prototype.recalculate = function()
if(this.recalcInfo.recalculateTransform)
{
this.recalculateTransform();
this.calculateSnapArrays();
this.recalculateSnapArrays();
this.recalcInfo.recalculateTransform = false;
}
if(this.recalcInfo.recalculateArrGraphicObjects)
......
This diff is collapsed.
......@@ -446,7 +446,7 @@ CShape.prototype.recalculate = function ()
}
if (this.recalcInfo.recalculateTransform) {
this.recalculateTransform();
this.calculateSnapArrays();
this.recalculateSnapArrays();
this.recalcInfo.recalculateTransform = false;
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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