Commit 59eaaa54 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Sergey.Luzyanin

draw connection points, when user adds connector;

fix bug in calculation connector's params;
parent 602cccbe
......@@ -676,6 +676,14 @@ function getTargetTextObject(controller)
return null;
}
function isConnectorPreset(sPreset){
if(typeof sPreset === "string" && sPreset.length > 0){
return "line" === sPreset || sPreset.toLowerCase().indexOf("connector") > -1;
}
return false;
}
function DrawingObjectsController(drawingObjects)
{
this.drawingObjects = drawingObjects;
......@@ -698,6 +706,8 @@ function DrawingObjectsController(drawingObjects)
this.chartForProps = null;
this.lastOverObject = null;
this.handleEventMode = HANDLE_EVENT_MODE_HANDLE;
}
......@@ -1562,6 +1572,14 @@ DrawingObjectsController.prototype =
{
drawingDocument.DrawTrackSelectShapes(this.selectionRect.x, this.selectionRect.y, this.selectionRect.w, this.selectionRect.h);
}
if(this.connector){
this.connector.drawConnectors(drawingDocument.AutoShapesTrack);
this.connector = null;
}
if (undefined !== drawingDocument.EndDrawTracking)
drawingDocument.EndDrawTracking();
......@@ -10778,4 +10796,5 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){
window['AscFormat'].CollectDLbls = CollectDLbls;
window['AscFormat'].CollectSettingsSpPr = CollectSettingsSpPr;
window['AscFormat'].CheckLinePresetForParagraphAdd = CheckLinePresetForParagraphAdd;
window['AscFormat'].isConnectorPreset = isConnectorPreset;
})(window);
......@@ -261,7 +261,7 @@
posX = (_end.x + _begin.x)/2.0 - extX/2.0;
posY = (_end.y + _begin.y)/2.0 - extY/2.0;
flipH = true;
oMapAdj["adj1"] = (-100000*(CONNECTOR_MARGIN/extX) + 0.5) >> 0;
oMapAdj["adj1"] = (-100000*((_end.bounds.b + CONNECTOR_MARGIN - _end.y)/extX) + 0.5) >> 0;
oMapAdj["adj2"] = 100000 - (100000*(((_begin.bounds.r + _end.bounds.l)/2 - (xc - extY/2))/extY) + 0.5) >> 0;
}
}
......
......@@ -55,6 +55,8 @@ function StartAddNewShape(drawingObjects, preset)
this.startX = null;
this.startY = null;
this.oldConnector = null;
}
StartAddNewShape.prototype =
......@@ -91,6 +93,30 @@ StartAddNewShape.prototype =
this.drawingObjects.arrTrackObjects[0].track(e, x, y);
this.drawingObjects.updateOverlay();
}
else
{
if(AscFormat.isConnectorPreset(this.preset)){
var oOldState = this.drawingObjects.curState;
this.drawingObjects.connector = null;
this.drawingObjects.changeCurrentState(new AscFormat.NullState(this.drawingObjects));
var oResult;
this.drawingObjects.handleEventMode = HANDLE_EVENT_MODE_CURSOR;
oResult = this.drawingObjects.curState.onMouseDown(e, x, y, 0);
this.drawingObjects.handleEventMode = HANDLE_EVENT_MODE_HANDLE;
this.drawingObjects.changeCurrentState(oOldState);
if(oResult){
var oObject = AscCommon.g_oTableId.Get_ById(oResult.objectId);
if(oObject.getObjectType() === AscDFH.historyitem_type_Shape){
this.drawingObjects.connector = oObject;
}
}
if(this.drawingObjects.connector !== this.oldConnector){
this.drawingObjects.updateOverlay();
}
this.oldConnector = this.drawingObjects.connector;
}
}
},
onMouseUp: function(e, x, y)
......
......@@ -138,7 +138,7 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
AscFormat.ExecuteNoHistory(function(){
if(slide){
this.bConnector = presetGeom.toLowerCase().indexOf("connector") > -1;
this.bConnector = AscFormat.isConnectorPreset(presetGeom);
if(this.bConnector){
var aSpTree = slide.cSld.spTree;
var oConnector = null;
......
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