Commit 69c13eea authored by SergeyLuzyanin's avatar SergeyLuzyanin

Connectors for charts and tables

parent 680a0497
......@@ -754,17 +754,60 @@ DrawingObjectsController.prototype =
return _ret;
},
getAllConnectorsByDrawings: function(aDrawings, result, aConnectors, bInsideGroup){
var _ret;
if(Array.isArray(result)){
_ret = result;
}
else{
_ret = [];
}
var _aConnectors;
if(Array.isArray(aConnectors)){
_aConnectors = aConnectors;
}
else{
_aConnectors = this.getAllConnectors(this.getDrawingArray(), []);
}
for(var i = 0; i < _aConnectors.length; ++i){
for(var j = 0; j < aDrawings.length; ++j){
if(aDrawings[j].getObjectType() === AscDFH.historyitem_type_GroupShape){
if(bInsideGroup){
this.getAllConnectorsByDrawings(aDrawings[j].spTree, _ret, _aConnectors, bInsideGroup);
}
}
else{
if(aDrawings[j].Get_Id() === _aConnectors[i].getStCxnId() || aDrawings[j].Get_Id() === _aConnectors[i].getEndCxnId()){
_ret.push(_aConnectors[i]);
}
}
}
}
return _ret;
},
getAllSingularDrawings: function(aDrawings, _ret){
for(var i = 0; i < aDrawings.length; ++i){
if(aDrawings[i].getObjectType() === AscDFH.historyitem_type_GroupShape){
this.getAllSingularDrawings(aDrawings[i].spTree, _ret);
}
else{
_ret.push(aDrawings[i]);
}
}
},
checkConnectorsPreTrack: function(){
if(this.arrPreTrackObjects.length > 0 && this.arrPreTrackObjects[0].originalObject){
if(this.arrPreTrackObjects.length > 0 && this.arrPreTrackObjects[0].originalObject && this.arrPreTrackObjects[0].overlayObject){
var aAllConnectors = this.getAllConnectors(this.getDrawingArray());
var oPreTrack;
var stId = null, endId = null, oBeginTrack = null, oEndTrack = null, oBeginShape = null, oEndShape = null;
var aConnectionPreTracks = [];
for(var i = 0; i < aAllConnectors.length; ++i){
stId = aAllConnectors[i].nvSpPr.nvUniSpPr.stCnxId;
endId = aAllConnectors[i].nvSpPr.nvUniSpPr.endCnxId;
stId = aAllConnectors[i].getStCxnId();
endId = aAllConnectors[i].getEndCxnId();
oBeginTrack = null;
oEndTrack = null;
oBeginShape = null;
......@@ -773,13 +816,11 @@ DrawingObjectsController.prototype =
if(stId !== null || endId !== null){
for(var j = 0; j < this.arrPreTrackObjects.length; ++j){
oPreTrack = this.arrPreTrackObjects[j].originalObject;
if(oPreTrack.getObjectType() === AscDFH.historyitem_type_Shape && oPreTrack.nvSpPr){
if(oPreTrack.Id === stId){
oBeginTrack = this.arrPreTrackObjects[j];
}
if(oPreTrack.Id === endId){
oEndTrack = this.arrPreTrackObjects[j];
}
if(oPreTrack.Id === stId){
oBeginTrack = this.arrPreTrackObjects[j];
}
if(oPreTrack.Id === endId){
oEndTrack = this.arrPreTrackObjects[j];
}
}
}
......@@ -5048,7 +5089,7 @@ DrawingObjectsController.prototype =
}
else
{
this.getAllShapes(this.selection.groupSelection.selectedObjects, aAllShapes);
this.resetConnectors(this.selection.groupSelection.selectedObjects);
var group_map = {}, group_arr = [], i, cur_group, sp, xc, yc, hc, vc, rel_xc, rel_yc, j;
for(i = 0; i < this.selection.groupSelection.selectedObjects.length; ++i)
{
......@@ -5065,7 +5106,6 @@ DrawingObjectsController.prototype =
group_arr.push(group_map[key]);
}
group_arr.sort(CompareGroups);
var a_objects = [];
for(i = 0; i < group_arr.length; ++i)
{
cur_group = group_arr[i];
......@@ -5141,7 +5181,7 @@ DrawingObjectsController.prototype =
}
else
{
this.getAllShapes(this.selectedObjects, aAllShapes);
this.resetConnectors(this.selectedObjects);
for(var i = 0; i < this.selectedObjects.length; ++i)
{
this.selectedObjects[i].deleteDrawingBase(true);
......@@ -5150,7 +5190,6 @@ DrawingObjectsController.prototype =
}
}
this.resetConnectors(aAllShapes);
this.resetSelection();
this.recalculate();
}
......@@ -8119,13 +8158,25 @@ DrawingObjectsController.prototype =
}
},
checkSelectedObjectsAndCallback: function(callback, args, bNoSendProps, nHistoryPointType)
checkSelectedObjectsAndCallback: function(callback, args, bNoSendProps, nHistoryPointType, bCheckConnectors)
{
var selection_state = this.getSelectionState();
this.drawingObjects.objectLocker.reset();
var oMapId = {};
for(var i = 0; i < this.selectedObjects.length; ++i)
{
this.drawingObjects.objectLocker.addObjectId(this.selectedObjects[i].Get_Id());
oMapId[this.selectedObjects[i].Get_Id()] = true;
}
if(bCheckConnectors){
var _aDrawings = this.selection.groupSelection ? this.selection.groupSelection.selectedObjects : this.selectedObjects;
var _aConnectors = [];
this.getAllConnectorsByDrawings(_aDrawings, _aConnectors, undefined, true);
for(var i = 0; i < _aConnectors.length; ++i){
if(!oMapId[_aConnectors[i].Get_Id()]){
this.drawingObjects.objectLocker.addObjectId(_aConnectors[i].Get_Id());
}
}
}
var _this = this;
var callback2 = function(bLock, bSync)
......
......@@ -507,6 +507,12 @@
}
};
CConnectionShape.prototype.getStCxnId = function(){
return this.nvSpPr.nvUniSpPr.stCnxId;
};
CConnectionShape.prototype.getEndCxnId = function(){
return this.nvSpPr.nvUniSpPr.endCnxId;
};
window['AscFormat'] = window['AscFormat'] || {};
window['AscFormat'].fCalculateSpPr = fCalculateSpPr;
window['AscFormat'].fCalculateConnectionInfo = fCalculateConnectionInfo;
......
......@@ -4587,6 +4587,12 @@ DefaultShapeDefinition.prototype=
}
};
function CHyperlink(){
}
function CNvPr()
{
this.id = 0;
......
......@@ -97,6 +97,8 @@ CGraphicFrame.prototype.getBase64Img = CShape.prototype.getBase64Img;
CGraphicFrame.prototype.checkDrawingBaseCoords = CShape.prototype.checkDrawingBaseCoords;
CGraphicFrame.prototype.getSlideIndex = CShape.prototype.getSlideIndex;
CGraphicFrame.prototype.Is_UseInDocument = CShape.prototype.Is_UseInDocument;
CGraphicFrame.prototype.convertPixToMM = CShape.prototype.convertPixToMM;
CGraphicFrame.prototype.hit = CShape.prototype.hit;
CGraphicFrame.prototype.GetDocumentPositionFromObject= function(PosArray)
{
......
......@@ -766,6 +766,7 @@
return null;
};
CGraphicObjectBase.prototype.setTitle = function(sTitle){
if(undefined === sTitle || null === sTitle){
return;
......@@ -817,18 +818,99 @@
CGraphicObjectBase.prototype.Restart_CheckSpelling = function()
{
};
CGraphicObjectBase.prototype.findConnector = function()
{
CGraphicObjectBase.prototype.convertToConnectionParams = function(rot, flipH, flipV, 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;
if(flipH){
_ret.dir = AscFormat.CARD_DIRECTION_W;
}
}
else if(_normalized_rot >= Math.PI * 0.25 && _normalized_rot < 3 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_S;
if(flipV){
_ret.dir = AscFormat.CARD_DIRECTION_N;
}
}
else if(_normalized_rot >= 3 * Math.PI * 0.25 && _normalized_rot < 5 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_W;
if(flipH){
_ret.dir = AscFormat.CARD_DIRECTION_E;
}
}
else if(_normalized_rot >= 5 * Math.PI * 0.25 && _normalized_rot < 7 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_N;
if(flipV){
_ret.dir = AscFormat.CARD_DIRECTION_S;
}
}
_ret.x = oTransform.TransformPointX(oConnectorInfo.x, oConnectorInfo.y);
_ret.y = oTransform.TransformPointY(oConnectorInfo.x, oConnectorInfo.y);
_ret.bounds.fromOther(oBounds);
_ret.idx = oConnectorInfo.idx;
return _ret;
};
CGraphicObjectBase.prototype.getRectGeometry = function(){
return AscFormat.ExecuteNoHistory(
function(){
var _ret = AscFormat.CreateGeometry("rect");
_ret.Recalculate(this.extX, this.extY);
return _ret;
}, this, []
);
};
CGraphicObjectBase.prototype.getGeom = function () {
var _geom;
if(this.rectGeometry){
_geom = this.rectGeometry;
}
else if(this.spPr && this.spPr.geometry){
_geom = this.spPr.geometry;
}
else{
_geom = this.getRectGeometry();
}
return _geom;
};
CGraphicObjectBase.prototype.findGeomConnector = function(x, y){
var _geom = this.getGeom();
var oInvertTransform = this.invertTransform;
var _x = oInvertTransform.TransformPointX(x, y);
var _y = oInvertTransform.TransformPointY(x, y);
return _geom.findConnector(_x, _y, this.convertPixToMM(AscCommon.global_mouseEvent.KoefPixToMM * AscCommon.TRACK_CIRCLE_RADIUS));
};
CGraphicObjectBase.prototype.findConnector = function(x, y){
var oConnGeom = this.findGeomConnector(x, y);
if(oConnGeom){
return this.convertToConnectionParams(this.rot, this.flipH, this.flipV, this.transform, this.bounds, oConnGeom);
}
return null;
};
CGraphicObjectBase.prototype.findConnectionShape = function(x, y)
{
CGraphicObjectBase.prototype.findConnectionShape = function(x, y){
if(this.hit(x, y)){
return this;
}
return null;
};
CGraphicObjectBase.prototype.drawConnectors = function(overlay)
{
var _geom = this.getGeom();
_geom.drawConnectors(overlay, this.transform);
};
CGraphicObjectBase.prototype.GetAllContentControls = function(arrContentControls)
{
};
......
......@@ -660,6 +660,7 @@ CImageShape.prototype.draw = function(graphics, transform)
CImageShape.prototype.select = CShape.prototype.select;
CImageShape.prototype.recalculateLocalTransform = CShape.prototype.recalculateLocalTransform;
CImageShape.prototype.hit = CShape.prototype.hit;
CImageShape.prototype.deselect = function(drawingObjectsController)
{
......
......@@ -5444,77 +5444,6 @@ CShape.prototype.getColumnNumber = function(){
}
};
CShape.prototype.convertToConnectionParams = function(rot, flipH, flipV, 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;
if(flipH){
_ret.dir = AscFormat.CARD_DIRECTION_W;
}
}
else if(_normalized_rot >= Math.PI * 0.25 && _normalized_rot < 3 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_S;
if(flipV){
_ret.dir = AscFormat.CARD_DIRECTION_N;
}
}
else if(_normalized_rot >= 3 * Math.PI * 0.25 && _normalized_rot < 5 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_W;
if(flipH){
_ret.dir = AscFormat.CARD_DIRECTION_E;
}
}
else if(_normalized_rot >= 5 * Math.PI * 0.25 && _normalized_rot < 7 * Math.PI * 0.25){
_ret.dir = AscFormat.CARD_DIRECTION_N;
if(flipV){
_ret.dir = AscFormat.CARD_DIRECTION_S;
}
}
_ret.x = oTransform.TransformPointX(oConnectorInfo.x, oConnectorInfo.y);
_ret.y = oTransform.TransformPointY(oConnectorInfo.x, oConnectorInfo.y);
_ret.bounds.fromOther(oBounds);
_ret.idx = oConnectorInfo.idx;
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.flipH, this.flipV, 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)
{
......
......@@ -98,7 +98,7 @@
if(!_startConnectionParams){
if(this.beginShape && oConnectorInfo.stCnxIdx !== null){
oConnectionObject = this.beginShape.spPr.geometry.cnxLst[oConnectorInfo.stCnxIdx];
oConnectionObject = this.beginShape.getGeom().cnxLst[oConnectorInfo.stCnxIdx];
g_conn_info = {idx: oConnectorInfo.stCnxIdx, ang: oConnectionObject.ang, x: oConnectionObject.x, y: oConnectionObject.y};
_rot = this.beginShape.rot;
_flipH = this.beginShape.flipH;
......@@ -129,7 +129,7 @@
if(!_endConnectionParams){
if(this.endShape && oConnectorInfo.endCnxIdx !== null){
oConnectionObject = this.endShape.spPr.geometry.cnxLst[oConnectorInfo.endCnxIdx];
oConnectionObject = this.endShape.getGeom().cnxLst[oConnectorInfo.endCnxIdx];
g_conn_info = {idx: oConnectorInfo.endCnxIdx, ang: oConnectionObject.ang, x: oConnectionObject.x, y: oConnectionObject.y};
_rot = this.endShape.rot;
_flipH = this.endShape.flipH;
......
......@@ -65,7 +65,7 @@ function MoveShapeImageTrack(originalObject)
this.brush = pen_brush.brush;
this.pen = pen_brush.pen;
}
this.overlayObject = new AscFormat.OverlayObject(!(this.originalObject.getObjectType() === AscDFH.historyitem_type_ChartSpace)&& this.originalObject.spPr && this.originalObject.spPr.geometry, this.originalObject.extX, this.originalObject.extY, this.brush, this.pen, this.transform);
this.overlayObject = new AscFormat.OverlayObject(originalObject.getGeom(), this.originalObject.extX, this.originalObject.extY, this.brush, this.pen, this.transform);
this.groupInvertMatrix = null;
if(this.originalObject.group)
......@@ -219,7 +219,7 @@ function MoveGroupTrack(originalObject)
var gr_obj_transform_copy = arr_graphic_objects[i].transform.CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new AscFormat.OverlayObject(!( arr_graphic_objects[i].getObjectType() === AscDFH.historyitem_type_ChartSpace)&& arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
this.overlayObjects[i] = new AscFormat.OverlayObject(arr_graphic_objects[i].getGeom(), arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, new CMatrix());
}
......
......@@ -280,7 +280,8 @@ function NewShapeTrack(presetGeom, startX, startY, theme, master, layout, slide,
this.endConnectionInfo = null;
if(this.bConnector){
var aSpTree = this.drawingsController.getAllShapes(this.drawingsController.getDrawingArray());
var aSpTree = [];
this.drawingsController.getAllSingularDrawings(this.drawingsController.getDrawingArray(), aSpTree);
var oConnector = null;
var oEndConnectionInfo = null;
for(var i = aSpTree.length - 1; i > -1; --i){
......
......@@ -309,7 +309,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection, drawingsController
this.resizedRot = originalObject.rot;
this.transform = originalObject.transform.CreateDublicate();
this.geometry = !(originalObject.getObjectType() === AscDFH.historyitem_type_ChartSpace) && originalObject.spPr && originalObject.spPr.geometry ? originalObject.spPr.geometry.createDuplicate() : (function(){ var geometry = AscFormat.CreateGeometry("rect"); geometry.Recalculate(5, 5); return geometry})();
this.geometry = (function(){ var geometry = originalObject.getGeom(); geometry.Recalculate(5, 5); return geometry})();
if(!originalObject.isChart())
{
......@@ -349,7 +349,8 @@ function ResizeTrackShapeImage(originalObject, cardDirection, drawingsController
if(oEndShape && oEndShape.bDeleted){
oEndShape = null;
}
var aDrawings = this.drawingsController.getAllShapes(this.drawingsController.getDrawingArray());
var aDrawings = [];
this.drawingsController.getAllSingularDrawings(this.drawingsController.getDrawingArray(), aDrawings);
var oConnectionInfo = null;
var oNewShape = null;
this.oNewShape = null;
......@@ -379,7 +380,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection, drawingsController
var _beginConnectionInfo, _endConnectionInfo;
if(this.numberHandle === 0){
if(oEndShape){
var oConectionObject = oEndShape.spPr.geometry.cnxLst[oConnectorInfo.endCnxIdx];
var oConectionObject = oEndShape.getGeom().cnxLst[oConnectorInfo.endCnxIdx];
var g_conn_info = {idx: oConnectorInfo.endCnxIdx, ang: oConectionObject.ang, x: oConectionObject.x, y: oConectionObject.y};
_endConnectionInfo = oEndShape.convertToConnectionParams(oEndShape.rot, oEndShape.flipH, oEndShape.flipV, oEndShape.transform, oEndShape.bounds, g_conn_info);
}
......@@ -391,7 +392,7 @@ function ResizeTrackShapeImage(originalObject, cardDirection, drawingsController
}
else{
if(oBeginShape){
var oConectionObject = oBeginShape.spPr.geometry.cnxLst[oConnectorInfo.stCnxIdx];
var oConectionObject = oBeginShape.getGeom().cnxLst[oConnectorInfo.stCnxIdx];
var g_conn_info = {idx: oConnectorInfo.stCnxIdx, ang: oConectionObject.ang, x: oConectionObject.x, y: oConectionObject.y};
_beginConnectionInfo = oBeginShape.convertToConnectionParams(oBeginShape.rot, oBeginShape.flipH, oBeginShape.flipV, oBeginShape.transform, oBeginShape.bounds, g_conn_info);
}
......@@ -1734,7 +1735,7 @@ function ShapeForResizeInGroup(originalObject, parentTrack)
this.bSwapCoef = !(AscFormat.checkNormalRotate(this.rot));
this.centerDistX = this.x + this.extX*0.5 - this.parentTrack.extX*0.5;
this.centerDistY = this.y + this.extY*0.5 - this.parentTrack.extY*0.5;
this.geometry = !(originalObject.getObjectType() === AscDFH.historyitem_type_ChartSpace) && originalObject.spPr.geometry !== null ? originalObject.spPr.geometry.createDuplicate() : null;
this.geometry = originalObject.getGeom();
if(this.geometry)
{
this.geometry.Recalculate(this.extX, this.extY);
......
......@@ -362,7 +362,7 @@ function RotateTrackShapeImage(originalObject)
{
brush = originalObject.brush;
}
this.overlayObject = new OverlayObject(originalObject.spPr.geometry, originalObject.extX, originalObject.extY, brush, originalObject.pen, this.transform);
this.overlayObject = new OverlayObject(originalObject.getGeom(), originalObject.extX, originalObject.extY, brush, originalObject.pen, this.transform);
this.angle = originalObject.rot;
var full_flip_h = this.originalObject.getFullFlipH();
......@@ -495,7 +495,7 @@ function RotateTrackGroup(originalObject)
var gr_obj_transform_copy = arr_graphic_objects[i].getTransformMatrix().CreateDublicate();
global_MatrixTransformer.MultiplyAppend(gr_obj_transform_copy, group_invert_transform);
this.arrTransforms2[i] = gr_obj_transform_copy;
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].spPr.geometry, arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
this.overlayObjects[i] = new OverlayObject(arr_graphic_objects[i].getGeom(), arr_graphic_objects[i].extX, arr_graphic_objects[i].extY,
arr_graphic_objects[i].brush, arr_graphic_objects[i].pen, new CMatrix());
}
......
......@@ -224,7 +224,6 @@ CImageShape.prototype.getRecalcObject = CShape.prototype.getRecalcObject;
CImageShape.prototype.setRecalcObject = CShape.prototype.setRecalcObject;
CImageShape.prototype.checkContentDrawings = function()
{};
CImageShape.prototype.hit = CShape.prototype.hit;
CImageShape.prototype.checkShapeChildTransform = function()
{
};
\ No newline at end of file
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