Commit 31269d8c authored by Sergey.Luzyanin's avatar Sergey.Luzyanin

git-svn-id:...

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47756 954022d7-b5bf-4e40-9824-e11837661b57
parent b0b3ea89
...@@ -172,6 +172,8 @@ ...@@ -172,6 +172,8 @@
<script src="model/DrawingObjects/Tracks/ResizeTracks.js"></script> <script src="model/DrawingObjects/Tracks/ResizeTracks.js"></script>
<script src="model/DrawingObjects/Tracks/RotateTracks.js"></script> <script src="model/DrawingObjects/Tracks/RotateTracks.js"></script>
<script src="model/DrawingObjects/Tracks/NewShapeTracks.js"></script> <script src="model/DrawingObjects/Tracks/NewShapeTracks.js"></script>
<script src="model/DrawingObjects/Tracks/PolyLine.js"></script>
<script src="model/DrawingObjects/Tracks/Spline.js"></script>
<script src="model/DrawingObjects/Tracks/MoveTracks.js"></script> <script src="model/DrawingObjects/Tracks/MoveTracks.js"></script>
<script src="model/DrawingObjects/Hit.js"></script> <script src="model/DrawingObjects/Hit.js"></script>
......
...@@ -205,8 +205,20 @@ DrawingObjectsController.prototype = ...@@ -205,8 +205,20 @@ DrawingObjectsController.prototype =
}, },
startTrackNewShape: function(presetGeom) startTrackNewShape: function(presetGeom)
{
switch (presetGeom)
{
case "spline":
{
this.changeCurrentState(new SplineBezierState(this, this.drawingObjects));
break;
}
default :
{ {
this.changeCurrentState(new StartTrackNewShapeState(this, this.drawingObjects, presetGeom)); this.changeCurrentState(new StartTrackNewShapeState(this, this.drawingObjects, presetGeom));
break;
}
}
}, },
drawTracks: function(overlay) drawTracks: function(overlay)
......
...@@ -27,8 +27,13 @@ var STATES_ID_PRE_RESIZE_IN_GROUP = 0x17; ...@@ -27,8 +27,13 @@ var STATES_ID_PRE_RESIZE_IN_GROUP = 0x17;
var STATES_ID_RESIZE_IN_GROUP = 0x18; var STATES_ID_RESIZE_IN_GROUP = 0x18;
var STATES_ID_PRE_MOVE_IN_GROUP = 0x19; var STATES_ID_PRE_MOVE_IN_GROUP = 0x19;
var STATES_ID_MOVE_IN_GROUP = 0x20; var STATES_ID_MOVE_IN_GROUP = 0x20;
var STATES_ID_START_ADD_POLY_LINE = 0x21; var STATES_ID_SPLINE_BEZIER = 0x21;
var STATES_ID_SPLINE_BEZIER = 0x22; var STATES_ID_SPLINE_BEZIER33 = 0x22;
var STATES_ID_SPLINE_BEZIER2 = 0x23;
var STATES_ID_SPLINE_BEZIER3 = 0x24;
var STATES_ID_SPLINE_BEZIER4 = 0x25;
var STATES_ID_SPLINE_BEZIER5 = 0x26;
var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {}); var asc = window["Asc"] ? window["Asc"] : (window["Asc"] = {});
...@@ -1531,226 +1536,152 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj ...@@ -1531,226 +1536,152 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj
function SplineBezierState(drawingObjectsController, drawingObjects) function SplineBezierState(drawingObjectsController, drawingObjects)
{ {
this.id = STATES_ID_SPLINE_BEZIER; this.id = STATES_ID_SPLINE_BEZIER;
this.graphicObjects = graphicObjects; this.drawingObjectsController = drawingObjectsController;
this.polylineFlag = true; this.drawingObjects = drawingObjects;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex: pageIndex}; this.drawingObjectsController.clearTrackObjects();
this.graphicObjects.spline = new Spline(pageIndex, this.graphicObjects.document); var spline = new Spline(this.drawingObjects);
this.graphicObjects.spline.path.push(new SplineCommandMoveTo(x, y)); this.drawingObjectsController.addTrackObject(spline);
this.graphicObjects.changeCurrentState(new SplineBezierState33(this.graphicObjects, x, y)); spline.addPathCommand(new SplineCommandMoveTo(x, y));
var sel_arr = this.graphicObjects.selectionInfo.selectionArray; this.drawingObjectsController.changeCurrentState(new SplineBezierState33(this.drawingObjectsController, this.drawingObjects, x, y, spline));
for(var i = 0; i < sel_arr.length; ++i) this.drawingObjectsController.resetSelection();
this.drawingObjects.selectGraphicObject();
};
this.onMouseMove = function(e, x, y)
{ {
sel_arr[i].deselect();
}
sel_arr.length = 0;
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
}; };
this.OnMouseMove = function(e, X, Y, pageIndex) this.onMouseUp = function(e, X, Y, pageIndex)
{ {
this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
}; };
this.OnMouseUp = function(e, X, Y, pageIndex) this.isPointInDrawingObjects = function(x, y)
{ {
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects)); return null/*TODO*/;
this.graphicObjects.curState.updateAnchorPos();
}; };
this.updateCursorType = function(pageIndex, x, y)
this.drawSelection = function(drawingDocument)
{ {
return false; };
}
} }
function SplineBezierState33(graphicObjects, startX, startY) function SplineBezierState33(drawingObjectsController, drawingObjects, startX, startY, spline)
{ {
this.id = STATES_ID_SPLINE_BEZIER33; this.id = STATES_ID_SPLINE_BEZIER33;
this.graphicObjects = graphicObjects;
this.polylineFlag = true; this.drawingObjectsController = drawingObjectsController;
this.OnMouseDown = function(e, x, y, pageIndex) this.drawingObjects = drawingObjects;
this.startX = startX;
this.startY = startY;
this.spline = spline;
this.onMouseDown = function(e, x, y)
{ {
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
var startPos = this.graphicObjects.startTrackPos; if(this.startX === x && this.startY === y)
if(startPos.x === x && startPos.y === y && startPos.pageIndex === pageIndex)
return; return;
this.spline.addPathCommand(new SplineCommandLineTo(x, y));
this.drawingObjectsController.changeCurrentState(new SplineBezierState2(this.drawingObjectsController, this.drawingObjects, this.startX, this.startY, this.spline));
this.drawingObjects.selectGraphicObject();
this.drawingObjects.showOverlayGraphicObjects();
};
var tr_x, tr_y; this.onMouseUp = function(e, x, y)
if(pageIndex === startPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{ {
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, startPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.spline.path.push(new SplineCommandLineTo(tr_x, tr_y));
this.graphicObjects.changeCurrentState(new SplineBezierState2(this.graphicObjects));
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.isPointInDrawingObjects = function(x, y)
{ {
return null/*TODO*/;
}; };
this.updateCursorType = function(pageIndex, x, y)
this.drawSelection = function(drawingDocument)
{ {
return false; };
}
} }
function SplineBezierState2(graphicObjects) function SplineBezierState2(drawingObjectsController, drawingObjects, startX, startY, spline)
{ {
this.id = STATES_ID_SPLINE_BEZIER2; this.id = STATES_ID_SPLINE_BEZIER2;
this.graphicObjects = graphicObjects; this.drawingObjectsController = drawingObjectsController;
this.polylineFlag = true; this.drawingObjects = drawingObjects;
this.OnMouseDown = function(e, x, y, pageIndex) this.startX = startX;
this.startY = startY;
this.spline = spline;
this.onMouseDown = function(e, x, y)
{ {
if(e.ClickCount >= 2) if(e.ClickCount >= 2)
{ {
var lt = this.graphicObjects.spline.getLeftTopPoint(); this.spline.createShape(null, this.drawingObjects);
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null); asc["editor"].asc_endAddShape();
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex; this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
} }
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{
var startPos = this.graphicObjects.startTrackPos;
var tr_x, tr_y;
if(pageIndex === startPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{ {
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, startPos.pageIndex); this.spline.path[1].changeLastPoint(x, y);
tr_x = tr_point.X; this.drawingObjects.showOverlayGraphicObjects();
tr_y = tr_point.Y;
}
this.graphicObjects.spline.path[1].changePoint(tr_x, tr_y);
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{
if( e.ClickCount < 2)
{
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{ {
tr_x = x; this.drawingObjectsController.changeCurrentState(new SplineBezierState3(this.drawingObjectsController, this.drawingObjects, x, y, this.spline));
tr_y = y; };
}
else this.isPointInDrawingObjects = function(x, y)
{ {
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex); return null/*TODO*/;
tr_x = tr_point.x;
tr_y = tr_point.y;
}
this.graphicObjects.changeCurrentState(new SplineBezierState3(this.graphicObjects,tr_x, tr_y));
}
}; };
this.updateCursorType = function(pageIndex, x, y)
this.drawSelection = function(drawingDocument)
{ {
return false; };
}
} }
function SplineBezierState3(graphicObjects, startX, startY) function SplineBezierState3(drawingObjectsController, drawingObjects, startX, startY, spline)
{ {
this.id = STATES_ID_SPLINE_BEZIER3; this.id = STATES_ID_SPLINE_BEZIER3;
this.graphicObjects = graphicObjects; this.drawingObjects = drawingObjects;
this.drawingObjectsController = drawingObjectsController;
this.spline = spline;
this.startX = startX; this.startX = startX;
this.startY = startY; this.startY = startY;
this.polylineFlag = true; this.onMouseDown = function(e, x, y)
this.OnMouseDown = function(e, x, y, pageIndex)
{ {
if(e.ClickCount >= 2) if(e.ClickCount >= 2)
{ {
var lt = this.graphicObjects.spline.getLeftTopPoint(); this.spline.createShape(this.drawingObjects);
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null); asc["editor"].asc_endAddShape();
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex; this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
} }
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
if(x === this.startX && y === this.startY && pageIndex === this.graphicObjects.startTrackPos.pageIndex) if(x === this.startX && y === this.startY)
{ {
return; return;
} }
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6; var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
var spline = this.graphicObjects.spline; var spline = this.spline;
x0 = spline.path[0].x; x0 = spline.path[0].x;
y0 = spline.path[0].y; y0 = spline.path[0].y;
x3 = spline.path[1].x; x3 = spline.path[1].x;
y3 = spline.path[1].y; y3 = spline.path[1].y;
x6 = tr_x; x6 = x;
y6 = tr_y; y6 = y;
var vx = (x6 - x0)/6; var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6; var vy = (y6 - y0)/6;
...@@ -1770,84 +1701,50 @@ function SplineBezierState3(graphicObjects, startX, startY) ...@@ -1770,84 +1701,50 @@ function SplineBezierState3(graphicObjects, startX, startY)
spline.path.length = 1; spline.path.length = 1;
spline.path.push(new SplineCommandBezier(x1, y1, x2, y2, x3, y3)); spline.path.push(new SplineCommandBezier(x1, y1, x2, y2, x3, y3));
spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6)); spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6));
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay(); this.drawingObjects.showOverlayGraphicObjects();
this.graphicObjects.changeCurrentState(new SplineBezierState4(this.graphicObjects)); this.drawingObjectsController.changeCurrentState(new SplineBezierState4(this.drawingObjectsController, this.drawingObjects, this.spline));
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
if(e.ClickCount >= 2) if(e.ClickCount >= 2)
{ {
var lt = this.graphicObjects.spline.getLeftTopPoint(); this.spline.createShape(this.drawingObjects);
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null); asc["editor"].asc_endAddShape();
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex; this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
} }
}; };
this.updateCursorType = function(pageIndex, x, y)
this.isPointInDrawingObjects = function(x, y)
{ {
return false; return null/*TODO*/;
} };
this.drawSelection = function(drawingDocument)
{
};
} }
function SplineBezierState4(graphicObjects) function SplineBezierState4(drawingObjectsController, drawingObjects, spline)
{ {
this.id = STATES_ID_SPLINE_BEZIER4; this.id = STATES_ID_SPLINE_BEZIER4;
this.graphicObjects = graphicObjects; this.drawingObjects = drawingObjects;
this.polylineFlag = true; this.drawingObjectsController = drawingObjectsController;
this.OnMouseDown = function(e, x, y, pageIndex) this.spline = spline;
this.onMouseDown = function(e, x, y)
{ {
if(e.ClickCount >= 2) if(e.ClickCount >= 2)
{ {
var lt = this.graphicObjects.spline.getLeftTopPoint(); this.spline.createShape(this.drawingObjects);
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null); asc["editor"].asc_endAddShape();
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex; this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
if(near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
} }
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
var spline = this.graphicObjects.spline; var spline = this.spline;
var lastCommand = spline.path[spline.path.length-1]; var lastCommand = spline.path[spline.path.length-1];
var preLastCommand = spline.path[spline.path.length-2]; var preLastCommand = spline.path[spline.path.length-2];
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6; var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
...@@ -1865,20 +1762,8 @@ function SplineBezierState4(graphicObjects) ...@@ -1865,20 +1762,8 @@ function SplineBezierState4(graphicObjects)
x3 = preLastCommand.x3; x3 = preLastCommand.x3;
y3 = preLastCommand.y3; y3 = preLastCommand.y3;
var tr_x, tr_y; x6 = x;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex) y6 = y;
{
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
x6 = tr_x;
y6 = tr_y;
var vx = (x6 - x0)/6; var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6; var vy = (y6 - y0)/6;
...@@ -1910,79 +1795,53 @@ function SplineBezierState4(graphicObjects) ...@@ -1910,79 +1795,53 @@ function SplineBezierState4(graphicObjects)
lastCommand.x3 = x6; lastCommand.x3 = x6;
lastCommand.y3 = y6; lastCommand.y3 = y6;
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay(); this.drawingObjects.showOverlayGraphicObjects();
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
if(e.ClickCount < 2 ) if(e.ClickCount < 2 )
{ {
var tr_x, tr_y; this.graphicObjects.changeCurrentState(new SplineBezierState5(this.drawingObjectsController, this.drawingObjects, x, y));
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
{
tr_x = x;
tr_y = y;
} }
else };
this.isPointInDrawingObjects = function(x, y)
{ {
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex); return null/*TODO*/;
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
this.graphicObjects.changeCurrentState(new SplineBezierState5(graphicObjects, tr_x, tr_y));
}
}; };
this.updateCursorType = function(pageIndex, x, y)
this.drawSelection = function(drawingDocument)
{ {
return false; };
}
} }
function SplineBezierState5(graphicObjects, startX, startY) function SplineBezierState5(drawingObjectsController, drawingObjects, startX, startY)
{ {
this.id = STATES_ID_SPLINE_BEZIER5; this.id = STATES_ID_SPLINE_BEZIER5;
this.graphicObjects = graphicObjects; this.drawingObjectsController = drawingObjectsController;
this.drawingObjects = drawingObjects;
this.startX = startX; this.startX = startX;
this.startY = startY; this.startY = startY;
this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
if(e.ClickCount >= 2) if(e.ClickCount >= 2)
{ {
var lt = this.graphicObjects.spline.getLeftTopPoint(); this.spline.createShape(this.drawingObjects);
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null); asc["editor"].asc_endAddShape();
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex; this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
} }
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
if(x === this.startX && y === this.startY && pageIndex === this.graphicObjects.startTrackPos.pageIndex) if(x === this.startX && y === this.startY)
{ {
return; return;
} }
var spline = this.graphicObjects.spline; var spline = this.spline;
var lastCommand = spline.path[spline.path.length-1]; var lastCommand = spline.path[spline.path.length-1];
var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6; var x0, y0, x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
...@@ -2001,20 +1860,9 @@ function SplineBezierState5(graphicObjects, startX, startY) ...@@ -2001,20 +1860,9 @@ function SplineBezierState5(graphicObjects, startX, startY)
y3 = lastCommand.y3; y3 = lastCommand.y3;
var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex) x6 = x;
{ y6 = y;
tr_x = x;
tr_y = y;
}
else
{
var tr_point = this.graphicObjects.drawingDocument.ConvertCoordsToAnotherPage(x, y, pageIndex, this.graphicObjects.startTrackPos.pageIndex);
tr_x = tr_point.X;
tr_y = tr_point.Y;
}
x6 = tr_x;
y6 = tr_y;
var vx = (x6 - x0)/6; var vx = (x6 - x0)/6;
var vy = (y6 - y0)/6; var vy = (y6 - y0)/6;
...@@ -2042,43 +1890,28 @@ function SplineBezierState5(graphicObjects, startX, startY) ...@@ -2042,43 +1890,28 @@ function SplineBezierState5(graphicObjects, startX, startY)
spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6)); spline.path.push(new SplineCommandBezier(x4, y4, x5, y5, x6, y6));
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay(); this.drawingObjects.showOverlayGraphicObjects();
this.graphicObjects.changeCurrentState(new SplineBezierState4(this.graphicObjects)); this.drawingObjectsController.changeCurrentState(new SplineBezierState4(this.drawingObjectsController, this.drawingObjects, this.spline));
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
if(e.ClickCount >= 2) if(e.ClickCount >= 2)
{ {
var lt = this.graphicObjects.spline.getLeftTopPoint(); this.spline.createShape(this.drawingObjects);
var near_pos = this.graphicObjects.document.Get_NearestPos(this.graphicObjects.startTrackPos.pageIndex, lt.x, lt.y, true, null); asc["editor"].asc_endAddShape();
near_pos.Page = this.graphicObjects.startTrackPos.pageIndex; this.drawingObjectsController.changeCurrentState(new NullState(this.drawingObjectsController, this.drawingObjects));
if(false === editor.isViewMode && near_pos != null &&
false === this.graphicObjects.document.Document_Is_SelectionLocked(changestype_None, {Type : changestype_2_Element_and_Type , Element : near_pos.Paragraph, CheckType : changestype_Paragraph_Content} ))
{
History.Create_NewPoint();
var _new_word_graphic_object = this.graphicObjects.spline.createShape(this.graphicObjects.document);
_new_word_graphic_object.select(this.graphicObjects.startTrackPos.pageIndex);
this.graphicObjects.selectionInfo.selectionArray.push(_new_word_graphic_object);
_new_word_graphic_object.recalculateWrapPolygon();
_new_word_graphic_object.Set_DrawingType(drawing_Anchor);
_new_word_graphic_object.Set_WrappingType(WRAPPING_TYPE_NONE);
_new_word_graphic_object.Set_XYForAdd(_new_word_graphic_object.absOffsetX, _new_word_graphic_object.absOffsetY);
_new_word_graphic_object.Add_ToDocument(near_pos);
}
this.graphicObjects.arrTrackObjects.length = 0;
this.graphicObjects.spline = null;
editor.sync_StartAddShapeCallback(false);
editor.sync_EndAddShape();
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos();
} }
}; };
this.updateCursorType = function(pageIndex, x, y)
this.isPointInDrawingObjects = function(x, y)
{ {
return false; return null/*TODO*/;
} };
this.drawSelection = function(drawingDocument)
{
};
} }
//Состояния прия работе с полилиниями //Состояния прия работе с полилиниями
...@@ -2086,7 +1919,7 @@ function PolyLineAddState(graphicObjects) ...@@ -2086,7 +1919,7 @@ function PolyLineAddState(graphicObjects)
{ {
this.graphicObjects = graphicObjects; this.graphicObjects = graphicObjects;
this.polylineFlag = true; this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex:pageIndex}; this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex:pageIndex};
this.graphicObjects.polyline = new PolyLine(this.graphicObjects.document, pageIndex); this.graphicObjects.polyline = new PolyLine(this.graphicObjects.document, pageIndex);
...@@ -2102,20 +1935,24 @@ function PolyLineAddState(graphicObjects) ...@@ -2102,20 +1935,24 @@ function PolyLineAddState(graphicObjects)
var _min_distance = this.graphicObjects.drawingDocument.GetMMPerDot(1); var _min_distance = this.graphicObjects.drawingDocument.GetMMPerDot(1);
this.graphicObjects.changeCurrentState(new PolyLineAddState2(this.graphicObjects, _min_distance)); this.graphicObjects.changeCurrentState(new PolyLineAddState2(this.graphicObjects, _min_distance));
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects)); this.graphicObjects.changeCurrentState(new NullState(this.graphicObjects));
this.graphicObjects.curState.updateAnchorPos(); this.graphicObjects.curState.updateAnchorPos();
this.graphicObjects.polyline = null; this.graphicObjects.polyline = null;
}; };
this.updateCursorType = function(pageIndex, x, y) this.isPointInDrawingObjects = function(x, y)
{ {
return false; return null/*TODO*/;
} };
this.drawSelection = function(drawingDocument)
{
};
} }
...@@ -2124,10 +1961,10 @@ function PolyLineAddState2(graphicObjects, minDistance) ...@@ -2124,10 +1961,10 @@ function PolyLineAddState2(graphicObjects, minDistance)
this.graphicObjects = graphicObjects; this.graphicObjects = graphicObjects;
this.minDistance = minDistance; this.minDistance = minDistance;
this.polylineFlag = true; this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
var _last_point = this.graphicObjects.polyline.arrPoint[this.graphicObjects.polyline.arrPoint.length - 1]; var _last_point = this.graphicObjects.polyline.arrPoint[this.graphicObjects.polyline.arrPoint.length - 1];
...@@ -2152,7 +1989,7 @@ function PolyLineAddState2(graphicObjects, minDistance) ...@@ -2152,7 +1989,7 @@ function PolyLineAddState2(graphicObjects, minDistance)
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay(); this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
} }
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
if(this.graphicObjects.polyline.arrPoint.length > 1) if(this.graphicObjects.polyline.arrPoint.length > 1)
{ {
...@@ -2193,10 +2030,14 @@ function PolyLineAddState2(graphicObjects, minDistance) ...@@ -2193,10 +2030,14 @@ function PolyLineAddState2(graphicObjects, minDistance)
} }
}; };
this.updateCursorType = function(pageIndex, x, y) this.isPointInDrawingObjects = function(x, y)
{ {
return false; return null/*TODO*/;
} };
this.drawSelection = function(drawingDocument)
{
};
} }
...@@ -2205,7 +2046,7 @@ function AddPolyLine2State(graphicObjects) ...@@ -2205,7 +2046,7 @@ function AddPolyLine2State(graphicObjects)
{ {
this.graphicObjects = graphicObjects; this.graphicObjects = graphicObjects;
this.polylineFlag = true; this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex : pageIndex}; this.graphicObjects.startTrackPos = {x: x, y: y, pageIndex : pageIndex};
var sel_arr = this.graphicObjects.selectionInfo.selectionArray; var sel_arr = this.graphicObjects.selectionInfo.selectionArray;
...@@ -2222,16 +2063,20 @@ function AddPolyLine2State(graphicObjects) ...@@ -2222,16 +2063,20 @@ function AddPolyLine2State(graphicObjects)
this.graphicObjects.changeCurrentState(new AddPolyLine2State2(this.graphicObjects, x, y)); this.graphicObjects.changeCurrentState(new AddPolyLine2State2(this.graphicObjects, x, y));
}; };
this.OnMouseMove = function(AutoShapes, e, X, Y) this.onMouseMove = function(AutoShapes, e, X, Y)
{}; {};
this.OnMouseUp = function(AutoShapes, e, X, Y) this.onMouseUp = function(AutoShapes, e, X, Y)
{
};
this.isPointInDrawingObjects = function(x, y)
{ {
return null/*TODO*/;
}; };
this.updateCursorType = function(pageIndex, x, y)
this.drawSelection = function(drawingDocument)
{ {
return false; };
}
} }
...@@ -2241,7 +2086,7 @@ function AddPolyLine2State2(graphicObjects, x, y) ...@@ -2241,7 +2086,7 @@ function AddPolyLine2State2(graphicObjects, x, y)
this.X = x; this.X = x;
this.Y = y; this.Y = y;
this.polylineFlag = true; this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
if(e.ClickCount > 1) if(e.ClickCount > 1)
{ {
...@@ -2251,7 +2096,7 @@ function AddPolyLine2State2(graphicObjects, x, y) ...@@ -2251,7 +2096,7 @@ function AddPolyLine2State2(graphicObjects, x, y)
} }
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
if(this.X !== x || this.Y !== y || this.graphicObjects.startTrackPos.pageIndex !== pageIndex) if(this.X !== x || this.Y !== y || this.graphicObjects.startTrackPos.pageIndex !== pageIndex)
{ {
...@@ -2273,13 +2118,17 @@ function AddPolyLine2State2(graphicObjects, x, y) ...@@ -2273,13 +2118,17 @@ function AddPolyLine2State2(graphicObjects, x, y)
} }
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
}; };
this.updateCursorType = function(pageIndex, x, y) this.isPointInDrawingObjects = function(x, y)
{ {
return false; return null/*TODO*/;
} };
this.drawSelection = function(drawingDocument)
{
};
} }
function AddPolyLine2State3(graphicObjects) function AddPolyLine2State3(graphicObjects)
...@@ -2287,7 +2136,7 @@ function AddPolyLine2State3(graphicObjects) ...@@ -2287,7 +2136,7 @@ function AddPolyLine2State3(graphicObjects)
this.graphicObjects = graphicObjects; this.graphicObjects = graphicObjects;
this.minSize = graphicObjects.drawingDocument.GetMMPerDot(1); this.minSize = graphicObjects.drawingDocument.GetMMPerDot(1);
this.polylineFlag = true; this.polylineFlag = true;
this.OnMouseDown = function(e, x, y, pageIndex) this.onMouseDown = function(e, x, y)
{ {
var tr_x, tr_y; var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex) if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
...@@ -2331,7 +2180,7 @@ function AddPolyLine2State3(graphicObjects) ...@@ -2331,7 +2180,7 @@ function AddPolyLine2State3(graphicObjects)
} }
}; };
this.OnMouseMove = function(e, x, y, pageIndex) this.onMouseMove = function(e, x, y)
{ {
var tr_x, tr_y; var tr_x, tr_y;
if(pageIndex === this.graphicObjects.startTrackPos.pageIndex) if(pageIndex === this.graphicObjects.startTrackPos.pageIndex)
...@@ -2364,7 +2213,7 @@ function AddPolyLine2State3(graphicObjects) ...@@ -2364,7 +2213,7 @@ function AddPolyLine2State3(graphicObjects)
this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay(); this.graphicObjects.drawingDocument.m_oWordControl.OnUpdateOverlay();
}; };
this.OnMouseUp = function(e, x, y, pageIndex) this.onMouseUp = function(e, x, y)
{ {
if(e.ClickCount > 1) if(e.ClickCount > 1)
{ {
...@@ -2395,10 +2244,14 @@ function AddPolyLine2State3(graphicObjects) ...@@ -2395,10 +2244,14 @@ function AddPolyLine2State3(graphicObjects)
} }
}; };
this.updateCursorType = function(pageIndex, x, y) this.isPointInDrawingObjects = function(x, y)
{ {
return false; return null/*TODO*/;
} };
this.drawSelection = function(drawingDocument)
{
};
} }
......
...@@ -14,7 +14,7 @@ function SplineCommandLineTo(x, y) ...@@ -14,7 +14,7 @@ function SplineCommandLineTo(x, y)
this.id = 1; this.id = 1;
this.x = x; this.x = x;
this.y = y; this.y = y;
this.changePoint = function(x, y) this.changeLastPoint = function(x, y)
{ {
this.x = x; this.x = x;
this.y = y; this.y = y;
...@@ -75,10 +75,9 @@ function Spline(drawingObjects) ...@@ -75,10 +75,9 @@ function Spline(drawingObjects)
} }
this.pen = _calculated_line; this.pen = _calculated_line;
this.splineForDraw = new SplineForDrawer(this);
this.Draw = function(graphics) this.Draw = function(graphics)
{ {
graphics.SetCurrentPage(this.pageIndex);
graphics.SetIntegerGrid(false); graphics.SetIntegerGrid(false);
graphics.transform3(this.Matrix); graphics.transform3(this.Matrix);
...@@ -88,6 +87,8 @@ function Spline(drawingObjects) ...@@ -88,6 +87,8 @@ function Spline(drawingObjects)
}; };
this.draw = function(g) this.draw = function(g)
{ {
this.splineForDraw.Draw(g);
return;
for(var i = 0; i < this.path.length; ++i) for(var i = 0; i < this.path.length; ++i)
{ {
var lastX, lastY; var lastX, lastY;
...@@ -164,7 +165,7 @@ function Spline(drawingObjects) ...@@ -164,7 +165,7 @@ function Spline(drawingObjects)
return {x: min_x, y: min_y}; return {x: min_x, y: min_y};
}; };
this.createShape = function(document) this.createShape = function(drawingObjects)
{ {
var xMax = this.path[0].x, yMax = this.path[0].y, xMin = xMax, yMin = yMax; var xMax = this.path[0].x, yMax = this.path[0].y, xMin = xMax, yMin = yMax;
var i; var i;
...@@ -245,15 +246,11 @@ function Spline(drawingObjects) ...@@ -245,15 +246,11 @@ function Spline(drawingObjects)
xMax = max_x; xMax = max_x;
yMin = min_y; yMin = min_y;
yMax = max_y; yMax = max_y;
var wordGraphicObject = new ParaDrawing(null, null, null, document.DrawingDocument, null, document); var shape = new CShape(null, this.drawingObjects);
var wordShape = new WordShape(wordGraphicObject, document, document.DrawingDocument, null);
wordGraphicObject.Set_GraphicObject(wordShape); shape.setPosition(xMin, yMin);
wordShape.pageIndex = this.pageIndex; shape.setExtents(xMax-xMin, yMax-yMin);
shape.setStyle(CreateDefaultShapeStyle());
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(); var geometry = new CGeometry();
geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin); geometry.AddPathCommand(0, undefined, bClosed ? "norm": "none", undefined, xMax - xMin, yMax-yMin);
...@@ -284,33 +281,65 @@ function Spline(drawingObjects) ...@@ -284,33 +281,65 @@ function Spline(drawingObjects)
geometry.AddPathCommand(6); geometry.AddPathCommand(6);
} }
geometry.Init( xMax-xMin, yMax-yMin); geometry.Init( xMax-xMin, yMax-yMin);
wordShape.spPr.geometry = geometry; shape.spPr.geometry = geometry;
wordShape.calculate(); shape.recalculate();
wordShape.calculateTransformMatrix(); this.drawingObjects.addGraphicObject(shape);
wordGraphicObject.setZIndex(); };
wordGraphicObject.setPageIndex(this.pageIndex);
for(i = 0; i< this.path.length; ++i) this.addPathCommand = function(pathCommand)
{ {
switch (this.path[i].id) this.path.push(pathCommand);
}
}
function SplineForDrawer(spline)
{
this.spline = spline;
this.pen = spline.pen;
this.brush = spline.brush;
this.TransformMatrix = spline.TransformMatrix;
this.Matrix = spline.Matrix;
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)
{
for(var i = 0; i < this.spline.path.length; ++i)
{
var lastX, lastY;
switch (this.spline.path[i].id )
{ {
case 0 : case 0 :
{ {
data.commands.push({id: 1, x: (this.path[i].x - xMin) + "", y:(this.path[i].y - yMin) + ""}); g._m(this.spline.path[i].x, this.spline.path[i].y);
lastX = this.spline.path[i].x;
lastY = this.spline.path[i].y;
break; break;
} }
case 1 : case 1 :
{ {
data.commands.push({id: 2, x: (this.path[i].x - xMin) + "", y:(this.path[i].y - yMin) + ""}); g._l(this.spline.path[i].x, this.spline.path[i].y);
lastX = this.spline.path[i].x;
lastY = this.spline.path[i].y;
break; break;
} }
case 2: case 2 :
{ {
data.commands.push({id: 5, x0: (this.path[i].x1 - xMin) + "", y0: (this.path[i].y1 - yMin) + "", x1:(this.path[i].x2 - xMin) + "", y1:(this.path[i].y2 - yMin) + "", x2:(this.path[i].x3 - xMin) + "", y2:(this.path[i].y3 - yMin) + ""}); g._c(this.spline.path[i].x1, this.spline.path[i].y1, this.spline.path[i].x2, this.spline.path[i].y2, this.spline.path[i].x3, this.spline.path[i].y3);
lastX = this.spline.path[i].x3;
lastY = this.spline.path[i].y3;
break; break;
} }
} }
} }
return wordGraphicObject; g.ds();
} }
} }
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