Commit ffe42081 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@47566 954022d7-b5bf-4e40-9824-e11837661b57
parent b7a6181f
......@@ -150,8 +150,9 @@
<script src="model/DrawingObjects/Format/GroupShape.js"></script>
<script src="model/DrawingObjects/Format/Image.js"></script>
<script src="model/DrawingObjects/Format/Shape.js"></script>
<script src="model/DrawingObjects/Tracks/ResizeTracks.js"></script>
<script src="model/DrawingObjects/Tracks/AdjustmentTracks.js"></script>
<script src="model/DrawingObjects/Tracks/ResizeTracks.js"></script>
<script src="model/DrawingObjects/Tracks/RotateTracks.js"></script>
<script src="model/DrawingObjects/Tracks/NewShapeTracks.js"></script>
<script src="model/DrawingObjects/Hit.js"></script>
......
......@@ -82,6 +82,12 @@ DrawingObjectsController.prototype =
this.arrTrackObjects[i].track(dx, dy);
},
trackAdjObject: function(x, y)
{
if(this.arrTrackObjects.length > 0)
this.arrPreTrackObjects[0].track(x, y);
},
trackEnd: function()
{
for(var i = 0; i < this.arrTrackObjects.length; ++i)
......@@ -99,26 +105,166 @@ DrawingObjectsController.prototype =
this.arrTrackObjects[i].draw(overlay);
},
drawSelection: function(drawingDocument)
{
switch (this.curState.id)
{
default :
{
var selected_objects = this.selectedObjects;
for(var i = 0; i < selected_objects.length; ++i)
{
drawingDocument.DrawTrack(TYPE_TRACK_SHAPE, selected_objects[i].getTransform(), 0, 0, selected_objects[i].extX, selected_objects[i].extY, false, selected_objects[i].canRotate());
}
break;
}
}
},
isPointInDrawingObjects: function(x, y)
{
var selected_objects = this.selectedObjects;
var selected_objects = this.drawingObjectsController.selectedObjects;
if(selected_objects.length === 1)
{
if(selected_objects[0].hitToAdjustment(x, y).hit)
var hit_to_adj = selected_objects[0].hitToAdjustment(x, y);
if(hit_to_adj.hit)
{
return true;
}
}
for(var i = selected_objects.length - 1; i > -1; --i)
{
if(selected_objects[i].hitToHandles(x, y) > -1)
var hit_to_handles = selected_objects[i].hitToHandles(x, y);
if(hit_to_handles > -1)
{
if(hit_to_handles === 8)
{
if(!selected_objects[i].canRotate())
return false;
}
else
{
if(!selected_objects[i].canResize())
return false;
}
return true;
}
}
var arr_objects = [];//TODO
for(i = arr_objects.length - 1; i > -1; --i)
for(i = selected_objects.length - 1; i > -1; --i)
{
if(arr_objects[i].hit(x, y))
return true;
if(selected_objects[i].hitInBoundingRect(x, y))
{
return selected_objects[i].canMove();
}
}
var arr_drawing_objects = this.drawingObjects.getDrawingObjects();
for(i = arr_drawing_objects.length-1; i > -1; --i)
{
var cur_drawing_base = arr_drawing_objects[i];
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)
{
if(!cur_drawing.canMove())
return false;
return true;
}
else if(hit_in_text_rect)
{
return false
}
}
else
{
}
}
}
return false;
},
isPointInDrawingObjects2: function(x, y)
{
var selected_objects = this.drawingObjectsController.selectedObjects;
if(selected_objects.length === 1)
{
var hit_to_adj = selected_objects[0].hitToAdjustment(x, y);
if(hit_to_adj.hit)
{
return true;
}
}
for(var i = selected_objects.length - 1; i > -1; --i)
{
var hit_to_handles = selected_objects[i].hitToHandles(x, y);
if(hit_to_handles > -1)
{
if(hit_to_handles === 8)
{
if(!selected_objects[i].canRotate())
return false;
}
else
{
if(!selected_objects[i].canResize())
return false;
}
return true;
}
}
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 true;
}
}
var arr_drawing_objects = this.drawingObjects.getDrawingObjects();
for(i = arr_drawing_objects.length-1; i > -1; --i)
{
var cur_drawing_base = arr_drawing_objects[i];
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
{
}
}
}
}
};
\ No newline at end of file
......@@ -144,6 +144,37 @@ CShape.prototype =
this.spPr.ln = line;
},
setAdjustmentValue: function(ref1, value1, ref2, value2)
{
if(this.spPr.geometry)
{
/*var data = {};
data.Type = historyitem_SetAdjValue;
data.ref1 = ref1;
data.newValue1 = value1;
data.ref2 = ref2;
data.newValue2 = value2;
data.oldValue1 = this.spPr.geometry.gdLst[ref1];
data.oldValue2 = this.spPr.geometry.gdLst[ref2];
History.Add(this, data);*/
var geometry = this.spPr.geometry;
if(typeof geometry.gdLst[ref1] === "number")
{
geometry.gdLst[ref1] = value1;
}
if(typeof geometry.gdLst[ref2] === "number")
{
geometry.gdLst[ref2] = value2;
}
geometry.Recalculate(this.extX, this.extY);
/*this.calculateContent();
this.calculateTransformTextMatrix(); */
}
},
select: function(drawingObjectsController)
{
this.selected = true;
......
......@@ -16,6 +16,8 @@ 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 STATES_ID_PRE_CHANGE_ADJ = 0x10;
var STATES_ID_CHANGE_ADJ = 0x11;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
......@@ -33,7 +35,12 @@ function NullState(drawingObjectsController, drawingObjects)
var hit_to_adj = selected_objects[0].hitToAdjustment(x, y);
if(hit_to_adj.hit)
{
//TODO
if(hit_to_adj.adjPolarFlag === false)
this.drawingObjectsController.addPreTrackObject(new XYAdjustmentTrack(selected_objects[0], hit_to_adj.adjNum));
else
this.drawingObjectsController.addPreTrackObject(new PolarAdjustmentTrack(selected_objects[0], hit_to_adj.adjNum));
this.drawingObjectsController.changeCurrentState(new PreChangeAdjState(this.drawingObjectsController, this.drawingObjects));
return;
}
}
......@@ -84,7 +91,7 @@ function NullState(drawingObjectsController, drawingObjects)
{
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createMoveTrack());
}
this.drawingObjectsController.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects, x, y));
this.drawingObjectsController.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects, x, y, e.shiftKey, e.ctrl, selected_objects[j].isGroup() ? selected_objects[j] : null));
return;
}
}
......@@ -93,7 +100,6 @@ function NullState(drawingObjectsController, drawingObjects)
for(i = arr_drawing_objects.length-1; i > -1; --i)
{
var cur_drawing_base = arr_drawing_objects[i];
//TODO: пока работаем только с шейпами
if(cur_drawing_base.isGraphicObject())
{
var cur_drawing = cur_drawing_base.graphicObject;
......@@ -104,11 +110,18 @@ function NullState(drawingObjectsController, drawingObjects)
var hit_in_text_rect = cur_drawing.hitInTextRect(x, y);
if(hit_in_inner_area && !hit_in_text_rect || hit_in_path)
{
if(!cur_drawing.canMove())
return;
for(var j = 0; j < selected_objects.length; ++j)
{
this.drawingObjectsController.addPreTrackObject(selected_objects[j].createMoveTrack());
}
this.changeCurrentState(new PreMoveState(this.drawingObjectsController, this.drawingObjects,x, y, e.shiftKey, e.ctrl, cur_drawing.isGroup() ? cur_drawing : null));
return;
}
else if(hit_in_text_rect)
{
//TODO
}
}
else
......@@ -124,7 +137,6 @@ function NullState(drawingObjectsController, drawingObjects)
this.onMouseUp = function(e, x, y)
{
asc.editor.asc_endAddShape();
}
}
......@@ -295,6 +307,7 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects)
this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
asc.editor.asc_endAddShape();
}
}
......@@ -342,6 +355,7 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY)
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.trackMoveObjects(x - this.startX, y - this.startY);
this.drawingObjects.showOverlayGraphicObjects();
};
this.onMouseUp = function(e, x, y)
......@@ -351,3 +365,54 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY)
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
function PreChangeAdjState(drawingObjectsController, drawingObjects)
{
this.id = STATES_ID_PRE_CHANGE_ADJ;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.onMouseDown = function(e, x, y)
{
};
this.onMouseMove = function(e, x, y)
{
this.drawingObjectsController.swapTrackObjects();
this.drawingObjectsController.trackAdjObject(x, y);
this.drawingObjectsController.changeCurrentState(new ChangeAdjState(this.drawingObjectsController, this.drawingObjects))
};
this.onMouseUp = function(e, x, y)
{
this.drawingObjectsController.clearPreTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
function ChangeAdjState(drawingObjectsController, drawingObjects)
{
this.id = STATES_ID_CHANGE_ADJ;
this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
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.clearTrackObjects();
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}
}
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