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

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47735 954022d7-b5bf-4e40-9824-e11837661b57
parent 871a2a12
This diff is collapsed.
......@@ -190,30 +190,32 @@ CGroupShape.prototype =
getResizeCoefficients: function(numHandle, x, y)
{
var t_x, t_y;
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
var invert_transform = this.getInvertTransform();
var t_x = invert_transform.TransformPointX(x, y);
var t_y = invert_transform.TransformPointY(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
return {kd1: (cx-t_x)/cx, kd2: (cy-t_y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
return {kd1: (cy-t_y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
return {kd1: (cy-t_y)/cy, kd2: t_x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
return {kd1: t_x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
return {kd1: t_x/cx, kd2: t_y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
return {kd1: t_y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
return {kd1: t_y/cy, kd2:(cx-t_x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
return {kd1:(cx-t_x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
......
......@@ -201,6 +201,8 @@ CImage.prototype =
this.flipH = xfrm.flipH === true;
this.flipV = xfrm.flipV === true;
}
if(isRealObject(this.spPr.geometry))
this.spPr.geometry.Recalculate(this.extX, this.extY);
this.transform.Reset();
var hc, vc;
hc = this.extX*0.5;
......@@ -215,8 +217,9 @@ CImage.prototype =
global_MatrixTransformer.TranslateAppend(this.transform, this.x + hc, this.y + vc);
if(isRealObject(this.group))
{
global_MatrixTransformer.MultiplyAppend(t, this.group.getTransform());
global_MatrixTransformer.MultiplyAppend(this.transform, this.group.getTransform());
}
this.invertTransform = global_MatrixTransformer.Invert(this.transform);
},
normalize: function()
......@@ -335,6 +338,13 @@ CImage.prototype =
return this.group.getFullFlipV() ? !this.flipV : this.flipV;
},
getAspect: function(num)
{
var _tmp_x = this.extX != 0 ? this.extX : 0.1;
var _tmp_y = this.extY != 0 ? this.extY : 0.1;
return num === 0 || num === 4 ? _tmp_x/_tmp_y : _tmp_y/_tmp_x;
},
setGroup: function(group)
{
this.group = group;
......@@ -515,13 +525,39 @@ CImage.prototype =
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingDocument.CanvasHitContext;
var _hit_context = this.drawingObjects.getCanvasContext();
return (HitInLine(_hit_context, x_t, y_t, 0, 0, this.extX, 0) ||
HitInLine(_hit_context, x_t, y_t, this.extX, 0, this.extX, this.extY)||
HitInLine(_hit_context, x_t, y_t, this.extX, this.extY, 0, this.extY)||
HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) ||
HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE)));
HitInLine(_hit_context, x_t, y_t, 0, this.extY, 0, 0) /*||
HitInLine(_hit_context, x_t, y_t, this.extX*0.5, 0, this.extX*0.5, -this.drawingDocument.GetMMPerDot(TRACK_DISTANCE_ROTATE))*/);
},
hitInInnerArea: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if(isRealObject(this.spPr.geometry))
return this.spPr.geometry.hitInInnerArea(this.drawingObjects.getCanvasContext(), x_t, y_t);
return x_t > 0 && x_t < this.extX && y_t > 0 && y_t < this.extY;
},
hitInPath: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
if(isRealObject(this.spPr.geometry))
return this.spPr.geometry.hitInPath(this.drawingObjects.getCanvasContext(), x_t, y_t);
return false;
},
hitInTextRect: function(x, y)
{
return false;
},
canRotate: function()
......@@ -586,50 +622,79 @@ CImage.prototype =
var rot_x_t = transform.TransformPointX(hc, - rotate_distance);
var rot_y_t = transform.TransformPointY(hc, - rotate_distance);
var invert_transform = this.getInvertTransform();
var rel_x = invert_transform.TransformPointX(x, y);
var v1_x, v1_y, v2_x, v2_y;
v1_x = x - xc_t;
v1_y = y - yc_t;
v2_x = rot_x_t - xc_t;
v2_y = rot_y_t - yc_t;
return Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y);
var flip_h = this.getFullFlipH();
var flip_v = this.getFullFlipV();
var same_flip = flip_h && flip_v || !flip_h && !flip_v;
var angle = rel_x > this.extX*0.5 ? Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y) : -Math.atan2( Math.abs(v1_x*v2_y - v1_y*v2_x), v1_x*v2_x + v1_y*v2_y);
return same_flip ? angle : -angle;
},
getResizeCoefficients: function(numHandle, x, y)
{
var t_x, t_y;
var cx, cy;
cx= this.extX > 0 ? this.extX : 0.01;
cy= this.extY > 0 ? this.extY : 0.01;
var p = this.transformPointRelativeShape(x, y);
var invert_transform = this.getInvertTransform();
var t_x = invert_transform.TransformPointX(x, y);
var t_y = invert_transform.TransformPointY(x, y);
switch(numHandle)
{
case 0:
return {kd1: (cx-p.x)/cx, kd2: (cy-p.y)/cy};
return {kd1: (cx-t_x)/cx, kd2: (cy-t_y)/cy};
case 1:
return {kd1: (cy-p.y)/cy, kd2: 0};
return {kd1: (cy-t_y)/cy, kd2: 0};
case 2:
return {kd1: (cy-p.y)/cy, kd2: p.x/cx};
return {kd1: (cy-t_y)/cy, kd2: t_x/cx};
case 3:
return {kd1: p.x/cx, kd2: 0};
return {kd1: t_x/cx, kd2: 0};
case 4:
return {kd1: p.x/cx, kd2: p.y/cy};
return {kd1: t_x/cx, kd2: t_y/cy};
case 5:
return {kd1: p.y/cy, kd2: 0};
return {kd1: t_y/cy, kd2: 0};
case 6:
return {kd1: p.y/cy, kd2:(cx-p.x)/cx};
return {kd1: t_y/cy, kd2:(cx-t_x)/cx};
case 7:
return {kd1:(cx-p.x)/cx, kd2: 0};
return {kd1:(cx-t_x)/cx, kd2: 0};
}
return {kd1: 1, kd2: 1};
},
getFullRotate: function()
{
return !isRealObject(this.group) ? this.rot : this.rot + this.group.getFullRotate();
},
getBoundsInGroup: function()
{
var r = this.rot;
if((r >= 0 && r < Math.PI*0.25)
|| (r > 3*Math.PI*0.25 && r < 5*Math.PI*0.25)
|| (r > 7*Math.PI*0.25 && r < 2*Math.PI))
{
return {minX: this.x, minY: this.y, maxX: this.x + this.extX, maxY: 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 {minX: xc - vc, minY: yc - hc, maxX: xc + vc, maxY: yc + hc};
}
},
drawAdjustments: function(drawingDocument)
{
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/**
* Created with JetBrains WebStorm.
* User: Sergey.Luzyanin
* Date: 7/4/13
* Time: 5:25 PM
* To change this template use File | Settings | File Templates.
*/
function CTxBody(shape)
{
this.shape = shape;
this.bodyPr = new CBodyPr();
this.lstStyle = null;
this.content = new CDocumentContent(this, editor.WordControl.m_oLogicDocument.DrawingDocument, 0, 0, 0, 20000, false, false);
}
CTxBody.prototype =
{
recalculate: function()
{
},
draw: function(graphics)
{
this.content.Draw(graphics);
},
Get_Styles: function(level)
{
return this.shape.Get_Styles(level);
},
paragraphAdd: function()
{}
};
\ No newline at end of file
This diff is collapsed.
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.Draw = function(graphics)
{
graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix);
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this);
};
this.draw = function(g)
{
if(this.arrPoint.length < 2)
{
return;
}
g._m(this.arrPoint[0].x, this.arrPoint[0].y);
for(var i = 1; i < this.arrPoint.length; ++i)
{
g._l(this.arrPoint[i].x, this.arrPoint[i].y);
}
g.ds();
};
this.getLeftTopPoint = function()
{
if(this.arrPoint.length < 1)
return {x: 0, y: 0};
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
for( i = 1; i<this.arrPoint.length; ++i)
{
if(this.arrPoint[i].x > xMax)
{
xMax = this.arrPoint[i].x;
}
if(this.arrPoint[i].y > yMax)
{
yMax = this.arrPoint[i].y;
}
if(this.arrPoint[i].x < xMin)
{
xMin = this.arrPoint[i].x;
}
if(this.arrPoint[i].y < yMin)
{
yMin = this.arrPoint[i].y;
}
}
return {x: xMin, y: yMin};
};
this.createShape = function(document)
{
var xMax = this.arrPoint[0].x, yMax = this.arrPoint[0].y, xMin = xMax, yMin = yMax;
var i;
var bClosed = false;
if(this.arrPoint.length > 2)
{
var dx = this.arrPoint[0].x - this.arrPoint[this.arrPoint.length-1].x;
var dy = this.arrPoint[0].y - this.arrPoint[this.arrPoint.length-1].y;
if(Math.sqrt(dx*dx +dy*dy) < this.document.DrawingDocument.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 wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
/*W, H, GraphicObj, Drawing*/
wordGraphicObject.Set_GraphicObject(wordShape);
wordShape.pageIndex = this.pageIndex;
wordShape.setAbsoluteTransform(xMin, yMin, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.setXfrm(0, 0, xMax-xMin, yMax-yMin, 0, false, false);
wordShape.style = CreateDefaultShapeStyle();
var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
geometry.AddRect("l", "t", "r", "b");
geometry.AddPathCommand(1, (this.arrPoint[0].x - xMin) + "", (this.arrPoint[0].y - yMin) + "");
for(i = 1; i< _n; ++i)
{
geometry.AddPathCommand(2, (this.arrPoint[i].x - xMin) + "", (this.arrPoint[i].y - yMin) + "");
}
if(bClosed)
{
geometry.AddPathCommand(6);
}
geometry.Init( xMax-xMin, yMax-yMin);
wordShape.spPr.geometry = geometry;
wordShape.calculate();
wordShape.calculateTransformMatrix();
wordGraphicObject.setZIndex();
wordGraphicObject.setPageIndex(this.pageIndex);
var data = {Type:historyitem_CreatePolyine};
data.xMax = xMax;
data.xMin = xMin;
data.yMax = yMax;
data.yMin = yMin;
data.bClosed = bClosed;
data.commands = [];
data.commands.push({id: 1, x: (this.arrPoint[0].x - xMin) + "", y:(this.arrPoint[0].y - yMin) + ""});
for(i = 1; i< _n; ++i)
{
data.commands.push({id: 2, x: (this.arrPoint[i].x - xMin) + "", y:(this.arrPoint[i].y - yMin) + ""});
}
History.Add(wordShape, data);
History.Add(wordGraphicObject, {Type: historyitem_CalculateAfterPaste});
return wordGraphicObject;
}
}
function PolyLineAdapter(drawingObjects)
{
this.polyLine = new PolyLine (drawingObjects);
this.draw = function(graphics)
{
this.polyLine.Draw(graphics);
}
}
\ No newline at end of file
......@@ -1764,30 +1764,6 @@ function ResizeTrackGroup(originalObject, cardDirection, parentTrack)
};
this.updateTransform = function()
{
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, -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);
for(var i = 0; i < this.childs.length; ++i)
{
this.childs[i].updateTransform();
}
};
}
function ShapeForResizeInGroup(originalObject, parentTrack)
......@@ -1847,7 +1823,7 @@ function ShapeForResizeInGroup(originalObject, parentTrack)
{
global_MatrixTransformer.ScaleAppend(t, 1, -1);
}
global_MatrixTransformer.RotateRadAppend(t, this.rot);
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 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