Commit 6c4898da authored by SergeyLuzyanin's avatar SergeyLuzyanin

connectors in presentation editor

parent 266b5e42
......@@ -55,6 +55,7 @@
"../common/Drawings/Format/Format.js",
"../common/Drawings/Format/GraphicObjectBase.js",
"../common/Drawings/Format/Shape.js",
"../common/Drawings/Format/CnxShape.js",
"../common/Drawings/Format/Path.js",
"../common/Drawings/Format/Image.js",
"../common/Drawings/Format/GroupShape.js",
......
......@@ -55,6 +55,7 @@
"../common/Drawings/Format/Format.js",
"../common/Drawings/Format/GraphicObjectBase.js",
"../common/Drawings/Format/Shape.js",
"../common/Drawings/Format/CnxShape.js",
"../slide/Editor/Format/ShapePrototype.js",
"../common/Drawings/Format/Path.js",
"../common/Drawings/Format/Image.js",
......
......@@ -57,6 +57,7 @@
"../common/Drawings/Format/Format.js",
"../common/Drawings/Format/GraphicObjectBase.js",
"../common/Drawings/Format/Shape.js",
"../common/Drawings/Format/CnxShape.js",
"../common/Drawings/Format/Path.js",
"../common/Drawings/Format/Image.js",
"../common/Drawings/Format/GroupShape.js",
......
......@@ -493,7 +493,7 @@ function CheckStockChart(oDrawingObjects, oApi)
function CheckLinePreset(preset)
{
return preset === "line";
return CheckLinePresetForParagraphAdd(preset);
}
function CheckLinePresetForParagraphAdd(preset)
......@@ -8150,7 +8150,7 @@ DrawingObjectsController.prototype =
if ( undefined != Props.DefaultTab )
{
//this.setDefa( Props.DefaultTab );
this.setDefaltTabSize( Props.DefaultTab );
}
......@@ -10629,6 +10629,15 @@ function ApplyPresetToChartSpace(oChartSpace, aPreset, bCreate){
window['AscFormat'].SCATTER_STYLE_SMOOTH = SCATTER_STYLE_SMOOTH;
window['AscFormat'].SCATTER_STYLE_SMOOTH_MARKER = SCATTER_STYLE_SMOOTH_MARKER;
window['AscFormat'].CARD_DIRECTION_N = CARD_DIRECTION_N;
window['AscFormat'].CARD_DIRECTION_NE = CARD_DIRECTION_NE;
window['AscFormat'].CARD_DIRECTION_E = CARD_DIRECTION_E;
window['AscFormat'].CARD_DIRECTION_SE = CARD_DIRECTION_SE;
window['AscFormat'].CARD_DIRECTION_S = CARD_DIRECTION_S;
window['AscFormat'].CARD_DIRECTION_SW = CARD_DIRECTION_SW;
window['AscFormat'].CARD_DIRECTION_W = CARD_DIRECTION_W;
window['AscFormat'].CARD_DIRECTION_NW = CARD_DIRECTION_NW;
window['AscFormat'].CURSOR_TYPES_BY_CARD_DIRECTION = CURSOR_TYPES_BY_CARD_DIRECTION;
window['AscFormat'].removeDPtsFromSeries = removeDPtsFromSeries;
window['AscFormat'].checkTxBodyDefFonts = checkTxBodyDefFonts;
......
This diff is collapsed.
......@@ -391,7 +391,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
AscDFH.CChangesBase.call(this, Class);
}
CChangesGeometryAddAdj.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddAdj.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddAdj.prototype.constructor = CChangesGeometryAddAdj;
CChangesGeometryAddAdj.prototype.CreateReverseChange = function(){
......@@ -468,7 +468,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
AscDFH.CChangesBase.call(this, Class);
}
CChangesGeometryAddGuide.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddGuide.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddGuide.prototype.constructor = CChangesGeometryAddGuide;
CChangesGeometryAddGuide.prototype.RemoveGuide = function(){
......@@ -535,7 +535,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
AscDFH.CChangesBase.call(this, Class);
}
CChangesGeometryAddCnx.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddCnx.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddCnx.prototype.constructor = CChangesGeometryAddCnx;
......@@ -601,7 +601,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
AscDFH.CChangesBase.call(this, Class);
}
CChangesGeometryAddHandleXY.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddHandleXY.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddHandleXY.prototype.constructor = CChangesGeometryAddHandleXY;
CChangesGeometryAddHandleXY.prototype.RemoveHandleXY = function(){
......@@ -677,7 +677,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
AscDFH.CChangesBase.call(this, Class);
}
CChangesGeometryAddHandlePolar.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddHandlePolar.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddHandlePolar.prototype.constructor = CChangesGeometryAddHandlePolar;
CChangesGeometryAddHandlePolar.prototype.RemoveHandlePolar = function(){
......@@ -749,7 +749,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
AscDFH.CChangesBase.call(this, Class);
}
CChangesGeometryAddRect.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddRect.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesGeometryAddRect.prototype.constructor = CChangesGeometryAddRect;
CChangesGeometryAddRect.prototype.Undo = function(){
if(this.bReverse){
......@@ -1078,6 +1078,41 @@ Geometry.prototype=
this.rectS.b = b;
},
findConnector: function(x, y, distanse){
var dx, dy;
for(var i = 0; i < this.cnxLst.length; i++)
{
dx=x-this.cnxLst[i].x;
dy=y-this.cnxLst[i].y;
if(Math.sqrt(dx*dx+dy*dy) < distanse)
{
return {ang: this.cnxLst[i].ang, x: this.cnxLst[i].x, y: this.cnxLst[i].y};
}
}
return null;
},
drawConnectors: function(overlay, transform){
var dOldAlpha;
var oGraphics = overlay.Graphics ? overlay.Graphics : overlay;
if(AscFormat.isRealNumber(oGraphics.globalAlpha) && oGraphics.put_GlobalAlpha){
dOldAlpha = oGraphics.globalAlpha;
oGraphics.put_GlobalAlpha(false, 1);
}
for(var i = 0; i < this.cnxLst.length; i++)
{
overlay.DrawEditWrapPointsPolygon([{x: this.cnxLst[i].x, y: this.cnxLst[i].y}], transform);
}
if(AscFormat.isRealNumber(dOldAlpha) && oGraphics.put_GlobalAlpha){
oGraphics.put_GlobalAlpha(true, dOldAlpha);
}
},
Recalculate: function(w, h, bResetPathsInfo)
{
this.gdLst["_3cd4"]= 16200000;
......
......@@ -249,6 +249,42 @@
this.w = r - l;
this.h = b - t;
}
CGraphicBounds.prototype.fromOther = function(oBounds){
this.l = oBounds.l;
this.t = oBounds.t;
this.r = oBounds.r;
this.b = oBounds.b;
this.x = oBounds.x;
this.y = oBounds.y;
this.w = oBounds.w;
this.h = oBounds.h;
};
CGraphicBounds.prototype.transform = function(oTransform){
var xlt = oTransform.TransformPointX(this.l, this.t);
var ylt = oTransform.TransformPointY(this.l, this.t);
var xrt = oTransform.TransformPointX(this.r, this.t);
var yrt = oTransform.TransformPointY(this.r, this.t);
var xlb = oTransform.TransformPointX(this.l, this.b);
var ylb = oTransform.TransformPointY(this.l, this.b);
var xrb = oTransform.TransformPointX(this.r, this.b);
var yrb = oTransform.TransformPointY(this.r, this.b);
this.l = Math.min(xlb, xlt, xrb, xrt);
this.t = Math.min(ylb, ylt, yrb, yrt);
this.r = Math.max(xlb, xlt, xrb, xrt);
this.b = Math.max(ylb, ylt, yrb, yrt);
this.x = this.l;
this.y = this.t;
this.w = this.r - this.l;
this.h = this.b - this.t;
};
/**
* Base class for all graphic objects
* @constructor
......@@ -778,6 +814,17 @@
CGraphicObjectBase.prototype.Restart_CheckSpelling = function()
{
};
CGraphicObjectBase.prototype.findConnector = function()
{
return null;
};
CGraphicObjectBase.prototype.findConnectionShape = function(x, y)
{
return null;
};
CGraphicObjectBase.prototype.drawConnectors = function(overlay)
{
};
CGraphicObjectBase.prototype.GetAllContentControls = function(arrContentControls)
{
......
......@@ -1829,6 +1829,26 @@ function CGroupShape()
}
};
CGroupShape.prototype.findConnector = function(x, y){
for(var i = this.spTree.length - 1; i > -1; --i ){
var oConInfo = this.spTree[i].findConnector(x, y);
if(oConInfo){
return oConInfo;
}
}
return null;
};
CGroupShape.prototype.findConnectionShape = function(x, y){
for(var i = this.spTree.length - 1; i > -1; --i){
var _ret = this.spTree[i].findConnectionShape(x, y);
if(_ret){
return _ret;
}
}
return null;
};
CGroupShape.prototype.GetAllContentControls = function(arrContentControls){
for(var i = 0; i < this.spTree.length; ++i)
{
......
......@@ -61,7 +61,7 @@ var c_oAscFill = Asc.c_oAscFill;
function CheckObjectLine(obj)
{
return (obj instanceof CShape && obj.spPr && obj.spPr.geometry && obj.spPr.geometry.preset === "line");
return (obj instanceof CShape && obj.spPr && obj.spPr.geometry && AscFormat.CheckLinePreset(obj.spPr.geometry.preset));
}
......@@ -5370,6 +5370,65 @@ CShape.prototype.getColumnNumber = function(){
}
};
CShape.prototype.convertToConnectionParams = function(rot, oTransform, oBounds, oConnectorInfo){
var _ret = new AscFormat.ConnectionParams();
var _rot = oConnectorInfo.ang*AscFormat.cToRad + rot;
var _normalized_rot = AscFormat.normalizeRotate(_rot);
_ret.dir = AscFormat.CARD_DIRECTION_E;
if(_normalized_rot >= 0 && _normalized_rot < Math.PI * 0.25 || _normalized_rot >= 7 * Math.PI * 0.25 && _normalized_rot < 2 * Math.PI){
_ret.dir = AscFormat.CARD_DIRECTION_E;
}
else if(_normalized_rot >= Math.PI * 0.25 && _normalized_rot < 3 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_S;
}
else if(_normalized_rot >= 3 * Math.PI * 0.25 && _normalized_rot < 5 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_W;
}
else if(_normalized_rot >= 5 * Math.PI * 0.25 && _normalized_rot < 7 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_N;
}
_ret.x = oTransform.TransformPointX(oConnectorInfo.x, oConnectorInfo.y);
_ret.y = oTransform.TransformPointY(oConnectorInfo.x, oConnectorInfo.y);
_ret.bounds.fromOther(this.bounds);
return _ret;
};
CShape.prototype.findGeomConnector = function(x, y){
if(this.spPr && this.spPr.geometry){
var oInvertTransform = this.invertTransform;
var _x = oInvertTransform.TransformPointX(x, y);
var _y = oInvertTransform.TransformPointY(x, y);
return this.spPr.geometry.findConnector(_x, _y, this.convertPixToMM(global_mouseEvent.KoefPixToMM * AscCommon.TRACK_CIRCLE_RADIUS));
}
return null;
};
CShape.prototype.findConnector = function(x, y){
var oConnGeom = this.findGeomConnector(x, y);
if(oConnGeom){
return this.convertToConnectionParams(this.rot, this.transform, this.bounds, oConnGeom);
}
return null;
};
CShape.prototype.findConnectionShape = function(x, y){
if(this.spPr && this.spPr.geometry && this.spPr.geometry.cnxLst.length >0){
if(this.hit(x, y)){
return this;
}
}
return null;
};
CShape.prototype.drawConnectors = function(overlay)
{
if(this.spPr && this.spPr.geometry){
this.spPr.geometry.drawConnectors(overlay, this.transform);
}
};
function CreateBinaryReader(szSrc, offset, srcLen)
{
var nWritten = 0;
......
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