Commit bf351df7 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@47545 954022d7-b5bf-4e40-9824-e11837661b57
parent 0342fd42
......@@ -76,6 +76,12 @@ DrawingObjectsController.prototype =
this.arrTrackObjects[0].track(e, x, y);
},
trackMoveObjects: function(dx, dy)
{
for(var i = 0; i < this.arrTrackObjects.length; ++i)
this.arrTrackObjects[i].track(dx, dy);
},
trackEnd: function()
{
for(var i = 0; i < this.arrTrackObjects.length; ++i)
......
......@@ -69,6 +69,13 @@ CGroupShape.prototypr =
return false;
},
isSimpleObject: function()
{
return false;
},
setGroup: function(group)
{
this.group = group;
......@@ -139,5 +146,36 @@ CGroupShape.prototypr =
this.arrGraphicObjects.push(arr_graphic_objects[i]);
}
}
},
canRotate: function()
{
return true;
},
canResize: function()
{
return true;//TODO
},
canMove: function()
{
return true;//TODO
},
hitInBoundingRect: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingDocument.CanvasHitContext;
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)));
}
};
\ No newline at end of file
......@@ -84,6 +84,11 @@ CImage.prototype =
return false;/*TODO*/
},
isSimpleObject: function()
{
return true;
},
init: function(x, y, extX, extY, imageId)
{
this.setPosition(x, y);
......@@ -367,6 +372,21 @@ CImage.prototype =
},
hitInBoundingRect: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingDocument.CanvasHitContext;
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)));
},
canRotate: function()
{
return !this.isChart(); //TODO
......@@ -377,6 +397,11 @@ CImage.prototype =
return true;//TODO
},
canMove: function()
{
return true;//TODO
},
createRotateTrack: function()
{
return new RotateTrackShapeImage(this);
......@@ -387,6 +412,12 @@ CImage.prototype =
return new ResizeTrackShapeImage(this, cardDirection);
},
createMoveTrack: function()
{
return new MoveShapeImageTrack(this);
},
getRotateAngle: function(x, y)
{
var transform = this.getTransform();
......
......@@ -66,6 +66,11 @@ CShape.prototype =
return false;
},
isSimpleObject: function()
{
return true;
},
initDefault: function(x, y, extX, extY, flipH, flipV, presetGeom)
{
......@@ -218,12 +223,12 @@ CShape.prototype =
recalculateBrush: function()
{
var theme = this.document.theme;
var brush;
var colorMap = this.document.clrSchemeMap.color_map;
var wb = this.drawingBase.getWorkbook();
var theme = wb.theme;
var colorMap = GenerateDefaultColorMap().color_map;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(colorMap==null)
colorMap = GenerateDefaultColorMap().color_map;
if (theme && this.style != null && this.style.fillRef!=null)
{
brush = theme.getFillStyle(this.style.fillRef.idx);
......@@ -251,10 +256,8 @@ CShape.prototype =
recalculatePen: function()
{
var _calculated_line;
var _theme = this.document.theme;
var colorMap = this.document.clrSchemeMap.color_map;
if(colorMap==null)
colorMap = GenerateDefaultColorMap().color_map;
var _theme = this.drawingBase.getWorkbook().theme;
var colorMap = GenerateDefaultColorMap().color_map;
var RGBA = {R: 0, G: 0, B: 0, A: 255};
if(_theme !== null && typeof _theme === "object" && typeof _theme.getLnStyle === "function"
&& this.style !== null && typeof this.style === "object"
......@@ -479,6 +482,21 @@ CShape.prototype =
return false;
},
hitInBoundingRect: function(x, y)
{
var invert_transform = this.getInvertTransform();
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingDocument.CanvasHitContext;
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)));
},
canRotate: function()
{
return true;
......@@ -489,6 +507,11 @@ CShape.prototype =
return true;//TODO
},
canMove: function()
{
return true;//TODO
},
createRotateTrack: function()
{
return new RotateTrackShapeImage(this);
......@@ -497,6 +520,11 @@ CShape.prototype =
createResizeTrack: function(cardDirection)
{
return new ResizeTrackShapeImage(this, cardDirection);
},
createMoveTrack: function()
{
return new MoveShapeImageTrack(this);
}
};
\ No newline at end of file
......@@ -14,6 +14,8 @@ var STATES_ID_RESIZE = 0x04;
var STATES_ID_START_TRACK_NEW_SHAPE = 0x05;
var STATES_ID_BEGIN_TRACK_NEW_SHAPE = 0x06;
var STATES_ID_TRACK_NEW_SHAPE = 0x07;
var STATES_ID_PRE_MOVE = 0x08;
var STATES_ID_MOVE = 0x09;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
......@@ -34,6 +36,7 @@ function NullState(drawingObjectsController, drawingObjects)
//TODO
}
}
for(var i = selected_objects.length - 1; i > -1; --i)
{
var hit_to_handles = selected_objects[i].hitToHandles(x, y);
......@@ -71,10 +74,48 @@ function NullState(drawingObjectsController, drawingObjects)
}
}
var arr_drawing_objects = [];
for(i = arr_drawing_objects.length-1; i > -1; ++i)
for(i = selected_objects.length - 1; i > -1; --i)
{
if(selected_objects[i].hitInBoundingRect(x, y))
{
if(!selected_objects[i].canMove())
return;
for(var j = 0; j < selected_objects.length; ++j)
{
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createMoveTrack());
}
this.drawingObjectsController.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects, x, y));
return;
}
}
var arr_drawing_objects = this.drawingObjects.getDrawingObjects();
for(i = arr_drawing_objects.length-1; i > -1; --i)
{
var cur_drawing_object = arr_drawing_objects[i];
var cur_drawing_base = arr_drawing_objects[i];
//TODO: пока работаем только с шейпами
if(cur_drawing_base.isGraphicObject())
{
var cur_drawing = cur_drawing_base.graphicObject;
if(cur_drawing.isSimpleObject())
{
var hit_in_inner_area = cur_drawing.hitInInnerArea(x, y);
var hit_in_path = cur_drawing.hitInPath(x, y);
var hit_in_text_rect = cur_drawing.hitInTextRect(x, y);
if(hit_in_inner_area && !hit_in_text_rect || hit_in_path)
{
}
else if(hit_in_text_rect)
{
}
}
else
{
}
}
}
};
......@@ -255,3 +296,57 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects)
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
function PreMoveState(drawingObjectsController, drawingObjects, startX, startY, shift, ctrl, group)
{
this.id = STATES_ID_PRE_MOVE;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.startX = startX;
this.startY = startY;
this.shift = shift;
this.ctrl = ctrl;
this.group = group;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.swapTrackObjects();
this.drawingObjectsController.changeCurrentState(new MoveState(this.drawingObjectsController, this.drawingObjects, this.startX, this.startY))
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.clearPreTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
function MoveState(drawingObjectsController, drawingObjects, startX, startY)
{
this.id = STATES_ID_MOVE;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.startX = startX;
this.startY = startY;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.trackMoveObjects(x - this.startX, y - this.startY);
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
/**
* 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.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.RotateAppend(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()
{
};
}
\ No newline at end of file
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