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

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47627 954022d7-b5bf-4e40-9824-e11837661b57
parent b25ebd87
......@@ -76,6 +76,11 @@ CGroupShape.prototypr =
return false;
},
setDrawingBase: function(drawingBase)
{
this.drawingBase = drawingBase;
},
setPosition: function(x, y)
{
this.spPr.xfrm.offX = x;
......
......@@ -34,9 +34,10 @@ function isRealNumber(number)
return number === number && typeof number === "number";
}
function CImage(drawingBase)
function CImage(drawingBase, drawingObjects)
{
this.drawingBase = drawingBase;
this.drawingObjects = drawingObjects;
this.blipFill = new CBlipFill();
this.spPr = new CSpPr();
......@@ -109,6 +110,11 @@ CImage.prototype =
this.recalculate();
},
setDrawingBase: function(drawingBase)
{
this.drawingBase = drawingBase;
},
setPresetGeometry: function(preset)
{
this.spPr.geometry = CreateGeometry(preset);
......
......@@ -5,9 +5,10 @@
* Time: 6:09 PM
* To change this template use File | Settings | File Templates.
*/
function CShape(drawingBase)
function CShape(drawingBase, drawingObjects)
{
this.drawingBase = drawingBase;
this.drawingObjects = drawingObjects;
this.nvSpPr = null;
this.spPr = new CSpPr();
this.style = null;
......@@ -88,6 +89,11 @@ CShape.prototype =
this.group = group;
},
setDrawingBase: function(drawingBase)
{
this.drawingBase = drawingBase;
},
recalculate: function()
{
if(this.recalcInfo.recalculateTransform)
......@@ -263,7 +269,7 @@ CShape.prototype =
recalculateBrush: function()
{
var brush;
var wb = this.drawingBase.getWorkbook();
var wb = this.drawingObjects.getWorkbook();
var theme = wb.theme;
var colorMap = GenerateDefaultColorMap().color_map;
......@@ -295,7 +301,7 @@ CShape.prototype =
recalculatePen: function()
{
var _calculated_line;
var _theme = this.drawingBase.getWorkbook().theme;
var _theme = this.drawingObjects.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"
......@@ -662,7 +668,7 @@ CShape.prototype =
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.drawingBase.getCanvasContext(), x_t, y_t);
return this.spPr.geometry.hitInPath(this.drawingObjects.getCanvasContext(), x_t, y_t);
return false;
},
......@@ -672,7 +678,7 @@ CShape.prototype =
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.drawingBase.getCanvasContext(), x_t, y_t);
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;
},
......@@ -687,7 +693,7 @@ CShape.prototype =
var x_t = invert_transform.TransformPointX(x, y);
var y_t = invert_transform.TransformPointY(x, y);
var _hit_context = this.drawingBase.getCanvasContext();
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)||
......
......@@ -18,6 +18,12 @@ var STATES_ID_PRE_MOVE = 0x08;
var STATES_ID_MOVE = 0x09;
var STATES_ID_PRE_CHANGE_ADJ = 0x10;
var STATES_ID_CHANGE_ADJ = 0x11;
var STATES_ID_GROUP = 0x12;
var STATES_ID_PRE_CHANGE_ADJ_IN_GROUP = 0x13;
var STATES_ID_CHANGE_ADJ_IN_GROUP = 0x14;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
......@@ -91,7 +97,7 @@ function NullState(drawingObjectsController, drawingObjects)
{
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createMoveTrack());
}
this.drawingObjectsController.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects, x, y, e.shiftKey, e.ctrl, selected_objects[i].isGroup() ? selected_objects[i] : null, true));
this.drawingObjectsController.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects, x, y, e.shiftKey, e.ctrl, selected_objects[i], true, false));
return;
}
}
......@@ -111,14 +117,14 @@ function NullState(drawingObjectsController, drawingObjects)
if(hit_in_inner_area && !hit_in_text_rect || hit_in_path)
{
var is_selected = cur_drawing.selected;
if(!(e.ctrlKey || e.shiftKey))
if(!(e.ctrlKey || e.shiftKey) && !is_selected)
this.drawingObjectsController.resetSelection();
cur_drawing.select(this.drawingObjectsController);
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, e.shiftKey, e.ctrl, cur_drawing.isGroup() ? cur_drawing : null, is_selected));
this.drawingObjectsController.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects,x, y, e.shiftKey, e.ctrl, cur_drawing, is_selected, true));
return;
}
else if(hit_in_text_rect)
......@@ -128,7 +134,31 @@ function NullState(drawingObjectsController, drawingObjects)
}
else
{
var grouped_objects = cur_drawing.getArrGraphicObjects();
for(var j = grouped_objects.length - 1; j > -1; --j)
{
var cur_grouped_object = grouped_objects[j];
var hit_in_inner_area = cur_grouped_object.hitInInnerArea(x, y);
var hit_in_path = cur_grouped_object.hitInPath(x, y);
var hit_in_text_rect = cur_grouped_object.hitInTextRect(x, y);
if(hit_in_inner_area && !hit_in_text_rect || hit_in_path)
{
var is_selected = cur_drawing.selected;
if(!(e.ctrlKey || e.shiftKey))
this.drawingObjectsController.resetSelection();
cur_drawing.select(this.drawingObjectsController);
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, e.shiftKey, e.ctrl, cur_drawing, is_selected, true));
return;
}
else if(hit_in_text_rect)
{
//TODO
}
}
}
}
}
......@@ -318,12 +348,13 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects)
this.drawingObjectsController.resetSelection();
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.selectGraphicObject();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
}
function PreMoveState(drawingObjectsController, drawingObjects, startX, startY, shift, ctrl, group, majorObjectIsSelected)
function PreMoveState(drawingObjectsController, drawingObjects, startX, startY, shift, ctrl, majorObject, majorObjectIsSelected, bInside)
{
this.id = STATES_ID_PRE_MOVE;
this.drawingObjectsController = drawingObjectsController;
......@@ -332,8 +363,9 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY,
this.startY = startY;
this.shift = shift;
this.ctrl = ctrl;
this.group = group;
this.majorObject = majorObject;
this.majorObjectIsSelected = majorObjectIsSelected;
this.bInside = bInside;
this.onMouseDown = function(e, x, y)
{
......@@ -367,9 +399,28 @@ function PreMoveState(drawingObjectsController, drawingObjects, startX, startY,
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.clearPreTrackObjects();
if(!(this.majorObject.isGroup() && this.bInside))
{
if(this.shift || this.ctrl)
{
if(this.majorObjectIsSelected)
this.majorObject.deselect(this.drawingObjectsController);
}
}
else
{
if(this.majorObjectIsSelected)
{
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.majorObject));
this.drawingObjectsController.onMouseDown(e, x, y);
this.drawingObjectsController.onMouseUp(e, x, y);
return;
}
}
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
};
}
function MoveState(drawingObjectsController, drawingObjects, startX, startY, rectX, rectY, rectW, rectH)
......@@ -454,8 +505,86 @@ function ChangeAdjState(drawingObjectsController, drawingObjects)
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
};
}
function GroupState(drawingObjectsController, drawingObjects, group)
{
this.id = STATES_ID_GROUP;
this.group = group;
this.onMouseDown = function(e, x, y)
{
var group_selected_objects = this.group.selectedObjects;
if(group_selected_objects.length === 1)
{
var hit_to_adj = group_selected_objects[0].hitToAdjustment(x, y);
if(hit_to_adj.hit)
{
if(hit_to_adj.adjPolarFlag === false)
this.drawingObjectsController.addPreTrackObject(new XYAdjustmentTrack(group_selected_objects[0], hit_to_adj.adjNum));
else
this.drawingObjectsController.addPreTrackObject(new PolarAdjustmentTrack(group_selected_objects[0], hit_to_adj.adjNum));
this.drawingObjectsController.changeCurrentState(new PreChangeAdjInGroupState(this.drawingObjectsController, this.drawingObjects, this.group));
return;
}
}
};
this.onMouseMove = function(e, x, y)
{};
this.onMouseUp = function(e, x, y)
{};
}
function PreChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
{
this.id = STATES_ID_PRE_CHANGE_ADJ_IN_GROUP;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.group = group;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.swapTrackObjects();
this.drawingObjectsController.trackAdjObject(x, y);
this.drawingObjectsController.changeCurrentState(new ChangeAdjInGroupState(this.drawingObjectsController, this.drawingObjects, this.group))
};
this.onMouseUp = function(e, x, y)
{};
}
function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
{
this.id = STATES_ID_CHANGE_ADJ_IN_GROUP;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.group = group;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.trackAdjObject(x, y);
this.drawingObjects.showOverlayGraphicObjects();
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
};
}
......@@ -238,6 +238,8 @@ function NewShapeTrack(drawingObjects, presetGeom, startX, startY)
this.trackEnd = function()
{
this.drawingOjects.addGraphicObject(this.x, this.y, this.extX, this.extY, false, false, this.presetGeom)
var shape = new CShape(null, this.drawingOjects);
shape.initDefault(this.x, this.y, this.extX, this.extY, false, false, this.presetGeom);
this.drawingOjects.addGraphicObject(shape);
};
}
\ No newline at end of file
......@@ -212,7 +212,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
......@@ -227,7 +227,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
......@@ -268,7 +268,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.lineFlag ? _abs_height : MIN_SHAPE_SIZE;
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
......@@ -277,7 +277,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
......@@ -317,7 +317,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
......@@ -332,7 +332,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
......@@ -371,7 +371,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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;
this.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
if(_real_height < 0)
this.resizedflipV = !this.originalFlipV;
else
......@@ -386,7 +386,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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;
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
if(_real_width < 0)
this.resizedflipH = !this.originalFlipH;
else
......@@ -475,7 +475,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
{
_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.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
......@@ -488,7 +488,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.resizedExtY = _abs_height >= MIN_SHAPE_SIZE ? _abs_height : MIN_SHAPE_SIZE;
this.resizedflipV = _real_height < 0 ? !this.originalFlipV : this.originalFlipV;
......@@ -503,13 +503,13 @@ function ResizeTrackShapeImage(originalObject, cardDirection)
_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.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 || this.lineFlag ? _abs_width : MIN_SHAPE_SIZE;
this.resizedExtX = _abs_width >= MIN_SHAPE_SIZE ? _abs_width : MIN_SHAPE_SIZE;
this.resizedflipH = _real_width < 0 ? !this.originalFlipH : this.originalFlipH;
}
......
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