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

Bug 25078 - Не рисуются направляющие линии для графики

Поправлен баг с определением попадания в линию.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57037 954022d7-b5bf-4e40-9824-e11837661b57
parent fd87369b
......@@ -235,6 +235,7 @@ CChartSpace.prototype =
select: CShape.prototype.select,
checkHitToBounds: CShape.prototype.checkHitToBounds,
calculateSnapArrays: CShape.prototype.calculateSnapArrays,
recalculateTextPr: function()
......
......@@ -1831,6 +1831,19 @@ CGroupShape.prototype =
recalculateCurPos: DrawingObjectsController.prototype.recalculateCurPos,
checkHitToBounds: CShape.prototype.checkHitToBounds,
calculateSnapArrays: function(snapArrayX, snapArrayY)
{
var sp;
for(var i = 0; i < this.spTree.length; ++i)
{
sp = this.spTree[i];
sp.calculateSnapArrays(snapArrayX, snapArrayY);
sp.snapArrayX.length = 0;
sp.snapArrayY.length = 0;
sp.calculateSnapArrays(sp.snapArrayX, sp.snapArrayY);
}
},
hitToAdj: function(x, y)
{
return {hit: false, num: -1, polar: false};
......
......@@ -153,6 +153,7 @@ CImageShape.prototype =
normalize: CShape.prototype.normalize,
checkHitToBounds: CShape.prototype.checkHitToBounds,
calculateSnapArrays: CShape.prototype.calculateSnapArrays,
sendMouseData: function()
{
......
"use strict";
var BOUNDS_DELTA = 3;
function CheckObjectLine(obj)
{
return (obj instanceof CShape && obj.spPr && obj.spPr.geometry && obj.spPr.geometry.preset === "line");
......@@ -2612,7 +2613,8 @@ CShape.prototype =
_x = x - this.bounds.x;
_y = y - this.bounds.y;
}
return _x >= 0 && _x <= this.bounds.w && _y >= 0 && _y <= this.bounds.h;
var delta = BOUNDS_DELTA + (this.pen && isRealNumber(this.pen.w) ? this.pen.w/36000 : 0);
return _x >= -delta && _x <= this.bounds.w + delta && _y >= -delta && _y <= this.bounds.h + delta;
},
......@@ -3461,6 +3463,22 @@ CShape.prototype =
return this.invertTransform ? this.invertTransform : new CMatrix();
},
calculateSnapArrays: function(snapArrayX, snapArrayY)
{
var t = 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));
},
getFullOffset: function () {
if (!isRealObject(this.group))
return { offX: this.x, offY: this.y };
......
......@@ -7,6 +7,7 @@
* 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;
......@@ -250,7 +251,14 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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(!this.isLine)
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
}
else
{
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : 0;
}
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
......@@ -267,6 +275,16 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_real_height = this.usedExtY*kd2;
_abs_height = Math.abs(_real_height);
if(!this.isLine)
{
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
}
else
{
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : 0;
}
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE || this.isLine ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0 )
{
......@@ -320,7 +338,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
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;
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV;
else
......@@ -329,7 +347,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
......@@ -381,7 +399,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : (this.isLine ? 0 :MIN_SHAPE_SIZE);
if(_real_width < 0 )
this.resizedflipH = !this.originalFlipH;
else
......@@ -396,7 +414,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(_real_height < 0 )
{
this.resizedflipV = !this.originalFlipV;
......@@ -447,7 +465,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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;
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(_real_height < 0 )
this.resizedflipV = !this.originalFlipV;
else
......@@ -462,7 +480,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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;
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : (this.isLine ? 0 : MIN_SHAPE_SIZE);
if(_real_width < 0 )
{
this.resizedflipH = !this.originalFlipH;
......
......@@ -732,9 +732,6 @@ MoveState.prototype =
}
}
var tr_to_start_page_x;
var tr_to_start_page_y;
var t = CheckCoordsNeedPage(x, y, pageIndex, this.majorObject.selectStartPage, this.drawingObjects.drawingDocument);
var startPage = this.drawingObjects.graphicPages[this.majorObject.selectStartPage];
......@@ -745,12 +742,14 @@ MoveState.prototype =
var snap_x = null, snap_y = null;
var snapHorArray = [], snapVerArray = [];
snapHorArray.push(X_Left_Field);
snapHorArray.push(X_Right_Field);
snapHorArray.push(Page_Width/2);
snapVerArray.push(Y_Top_Field);
snapVerArray.push(Y_Bottom_Field);
snapVerArray.push(Page_Height/2);
var page = this.drawingObjects.document.Pages[pageIndex];
snapHorArray.push(page.Margins.Left);
snapHorArray.push(page.Margins.Right);
snapHorArray.push(page.W/2);
snapVerArray.push(page.Margins.Top);
snapVerArray.push(page.Margins.Bottom);
snapVerArray.push(page.H/2);
if(result_x === this.startX)
{
min_dx = 0;
......@@ -2052,4 +2051,114 @@ AddPolyLine2State3.prototype =
StartAddNewShape.prototype.onMouseUp.call(this, e, x, y, pageIndex);
}
}
};
\ No newline at end of file
};
function GetMinSnapDistanceXObject(pointX, arrGrObjects)
{
var min_dx = null;
var ret = null;
for(var i = 0; i < arrGrObjects.length; ++i)
{
var cur_snap_arr_x = arrGrObjects[i].snapArrayX;
var count = cur_snap_arr_x.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dx = cur_snap_arr_x[snap_index] - pointX;
if(min_dx === null)
{
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
min_dx = dx;
}
else
{
if(Math.abs(dx) < Math.abs(min_dx))
{
min_dx = dx;
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
}
}
}
}
return ret;
}
function GetMinSnapDistanceYObject(pointY, arrGrObjects)
{
var min_dy = null;
var ret = null;
for(var i = 0; i < arrGrObjects.length; ++i)
{
var cur_snap_arr_y = arrGrObjects[i].snapArrayY;
var count = cur_snap_arr_y.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dy = cur_snap_arr_y[snap_index] - pointY;
if(min_dy === null)
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
else
{
if(Math.abs(dy) < Math.abs(min_dy))
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
}
}
}
return ret;
}
function GetMinSnapDistanceXObjectByArrays(pointX, snapArrayX)
{
var min_dx = null;
var ret = null;
var cur_snap_arr_x = snapArrayX;
var count = cur_snap_arr_x.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dx = cur_snap_arr_x[snap_index] - pointX;
if(min_dx === null)
{
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
min_dx = dx;
}
else
{
if(Math.abs(dx) < Math.abs(min_dx))
{
min_dx = dx;
ret = {dist: dx, pos: cur_snap_arr_x[snap_index]};
}
}
}
return ret;
}
function GetMinSnapDistanceYObjectByArrays(pointY, snapArrayY)
{
var min_dy = null;
var ret = null;
var cur_snap_arr_y = snapArrayY;
var count = cur_snap_arr_y.length;
for(var snap_index = 0; snap_index < count; ++snap_index)
{
var dy = cur_snap_arr_y[snap_index] - pointY;
if(min_dy === null)
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
else
{
if(Math.abs(dy) < Math.abs(min_dy))
{
min_dy = dy;
ret = {dist: dy, pos: cur_snap_arr_y[snap_index]};
}
}
}
return ret;
}
\ No newline at end of file
......@@ -56,6 +56,8 @@ CShape.prototype.recalcPen = function()
CShape.prototype.recalcTransform = function()
{
this.recalcInfo.recalculateTransform = true;
this.snapArrayX.length = 0;
this.snapArrayY.length = 0;
};
CShape.prototype.recalcTransformText = function()
{
......@@ -479,7 +481,6 @@ CShape.prototype.updateTransformMatrix = function()
global_MatrixTransformer.TranslateAppend(this.transformText, this.posX, this.posY);
this.invertTransformText = global_MatrixTransformer.Invert(this.transformText);
}
this.checkShapeChildTransform();
this.checkContentDrawings();
};
......
......@@ -4464,6 +4464,7 @@ ParaDrawing.prototype =
if( this.GraphicObj.bNeedUpdatePosition || !(isRealNumber(this.wrappingPolygon.posX) && isRealNumber(this.wrappingPolygon.posY)) ||
!(Math.abs(this.wrappingPolygon.posX -_x) < MOVE_DELTA && Math.abs(this.wrappingPolygon.posY-_y) < MOVE_DELTA))
this.wrappingPolygon.updatePosition(_x, _y);
this.calculateSnapArrays();
},
Set_XYForAdd2 : function(X, Y)
......@@ -6222,10 +6223,10 @@ ParaDrawing.prototype =
calculateSnapArrays: function()
{
this.snapArrayX.length = 0;
this.snapArrayY.length = 0;
this.GraphicObj.snapArrayX.length = 0;
this.GraphicObj.snapArrayY.length = 0;
if(isRealObject(this.GraphicObj) && typeof this.GraphicObj.calculateSnapArrays === "function")
this.GraphicObj.calculateSnapArrays(this.snapArrayX, this.snapArrayY);
this.GraphicObj.calculateSnapArrays(this.GraphicObj.snapArrayX, this.GraphicObj.snapArrayY);
},
......
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