Commit fda26f50 authored by SergeyLuzyanin's avatar SergeyLuzyanin

fix bug with connectors in group

parent 9b902575
......@@ -707,8 +707,6 @@ function DrawingObjectsController(drawingObjects)
this.chartForProps = null;
this.lastOverObject = null;
this.handleEventMode = HANDLE_EVENT_MODE_HANDLE;
}
......@@ -724,12 +722,6 @@ function CanStartEditText(oController)
DrawingObjectsController.prototype =
{
handleOleDblClick: function(drawing, e, x, y, pageIndex)
{
},
getAllConnectors: function(aDrawings, allDrawings){
var _ret = allDrawings;
if(!_ret){
......
......@@ -261,6 +261,9 @@
this.w = oBounds.w;
this.h = oBounds.h;
};
CGraphicBounds.prototype.copy = function(){
return new CGraphicBounds(this.l, this.t, this.r, this.b);
};
CGraphicBounds.prototype.transform = function(oTransform){
var xlt = oTransform.TransformPointX(this.l, this.t);
......
......@@ -11,9 +11,18 @@
this.beginShape = oBeginShape;
this.endShape = oEndShape;
this.startX = this.connector.transform.TransformPointX(0, 0);
this.startY = this.connector.transform.TransformPointY(0, 0);
if(this.connector.group){
var oInvertTransform = this.connector.group.invertTransform;
var _stX = oInvertTransform.TransformPointX(this.startX, this.startY);
var _stY = oInvertTransform.TransformPointY(this.startX, this.startY);
this.startX = _stX;
this.startY = _stY;
}
this.endX = this.connector.transform.TransformPointX(this.connector.extX, this.connector.extY);
this.endY = this.connector.transform.TransformPointY(this.connector.extX, this.connector.extY);
......@@ -30,34 +39,87 @@
{
var oConnectorInfo = this.connector.nvSpPr.nvUniSpPr;
var _rot, track_bounds, g_conn_info, oConectionObject, _flipH, _flipV;
var _rot, track_bounds, g_conn_info, oConnectionObject, _flipH, _flipV, _bounds, _transform;
var _startConnectionParams = null;
var _endConnectionParams = null;
var _group = null;
if(this.connector.group) {
_group = this.connector.group;
}
if(this.beginTrack){
track_bounds = this.convertTrackBounds(this.beginTrack.getBounds());
_rot = AscFormat.isRealNumber(this.beginTrack.angle) ? this.beginTrack.angle : this.beginTrack.originalObject.rot;
_flipH = AscFormat.isRealBool(this.beginTrack.resizedflipH) ? this.beginTrack.resizedflipH : this.beginTrack.originalObject.flipH;
_flipV = AscFormat.isRealBool(this.beginTrack.resizedflipV) ? this.beginTrack.resizedflipV : this.beginTrack.originalObject.flipV;
oConectionObject = this.beginTrack.overlayObject.geometry.cnxLst[oConnectorInfo.stCnxIdx];
g_conn_info = {idx: oConnectorInfo.stCnxIdx, ang: oConectionObject.ang, x: oConectionObject.x, y: oConectionObject.y};
_startConnectionParams = this.connector.convertToConnectionParams(_rot, _flipH, _flipV, this.beginTrack.overlayObject.TransformMatrix, track_bounds, g_conn_info)
_bounds = track_bounds;
_transform = this.beginTrack.overlayObject.TransformMatrix;
if(_group){
_rot = AscFormat.normalizeRotate((this.beginTrack.originalObject.group ? this.beginTrack.originalObject.group.getFullRotate() : 0) + _rot - _group.getFullRotate());
if(_group.getFullFlipH()){
_flipH = !_flipH;
}
if(_group.getFullFlipV()){
_flipV = !_flipV;
}
_bounds = _bounds.copy();
_bounds.transform(_group.invertTransform);
_transform = _transform.CreateDublicate();
AscCommon.global_MatrixTransformer.MultiplyAppend(_transform, _group.invertTransform);
}
oConnectionObject = this.beginTrack.overlayObject.geometry.cnxLst[oConnectorInfo.stCnxIdx];
g_conn_info = {idx: oConnectorInfo.stCnxIdx, ang: oConnectionObject.ang, x: oConnectionObject.x, y: oConnectionObject.y};
_startConnectionParams = this.connector.convertToConnectionParams(_rot, _flipH, _flipV, _transform, _bounds, g_conn_info);
}
if(this.endTrack){
track_bounds = this.convertTrackBounds(this.endTrack.getBounds());
_rot = AscFormat.isRealNumber(this.endTrack.angle) ? this.endTrack.angle : this.endTrack.originalObject.rot;
_flipH = AscFormat.isRealBool(this.endTrack.resizedflipH) ? this.endTrack.resizedflipH : this.endTrack.originalObject.flipH;
_flipV = AscFormat.isRealBool(this.endTrack.resizedflipV) ? this.endTrack.resizedflipV : this.endTrack.originalObject.flipV;
oConectionObject = this.endTrack.overlayObject.geometry.cnxLst[oConnectorInfo.endCnxIdx];
g_conn_info = {idx: oConnectorInfo.endCnxIdx, ang: oConectionObject.ang, x: oConectionObject.x, y: oConectionObject.y};
_endConnectionParams = this.connector.convertToConnectionParams(_rot, _flipH, _flipV, this.endTrack.overlayObject.TransformMatrix, track_bounds, g_conn_info)
_bounds = track_bounds;
_transform = this.endTrack.overlayObject.TransformMatrix;
if(_group){
_rot = AscFormat.normalizeRotate((this.endTrack.originalObject.group ? this.endTrack.originalObject.group.getFullRotate() : 0) + _rot - _group.getFullRotate());
if(_group.getFullFlipH()){
_flipH = !_flipH;
}
if(_group.getFullFlipV()){
_flipV = !_flipV;
}
_bounds = _bounds.copy();
_bounds.transform(_group.invertTransform);
_transform = _transform.CreateDublicate();
AscCommon.global_MatrixTransformer.MultiplyAppend(_transform, _group.invertTransform);
}
oConnectionObject = this.endTrack.overlayObject.geometry.cnxLst[oConnectorInfo.endCnxIdx];
g_conn_info = {idx: oConnectorInfo.endCnxIdx, ang: oConnectionObject.ang, x: oConnectionObject.x, y: oConnectionObject.y};
_endConnectionParams = this.connector.convertToConnectionParams(_rot, _flipH, _flipV, _transform, _bounds, g_conn_info);
}
if(_startConnectionParams || _endConnectionParams){
if(!_startConnectionParams){
if(this.beginShape && oConnectorInfo.stCnxIdx !== null){
oConectionObject = this.beginShape.spPr.geometry.cnxLst[oConnectorInfo.stCnxIdx];
g_conn_info = {idx: oConnectorInfo.stCnxIdx, ang: oConectionObject.ang, x: oConectionObject.x, y: oConectionObject.y};
_startConnectionParams = this.beginShape.convertToConnectionParams(this.beginShape.rot, this.beginShape.flipH, this.beginShape.flipV, this.beginShape.transform, this.beginShape.bounds, g_conn_info);
oConnectionObject = this.beginShape.spPr.geometry.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;
_flipV = this.beginShape.flipV;
_bounds = this.beginShape.bounds;
_transform = this.beginShape.transform;
if(_group){
_rot = AscFormat.normalizeRotate((this.beginShape.group ? this.beginShape.group.getFullRotate() : 0) + _rot - _group.getFullRotate());
if(_group.getFullFlipH()){
_flipH = !_flipH;
}
if(_group.getFullFlipV()){
_flipV = !_flipV;
}
_bounds = _bounds.copy();
_bounds.transform(_group.invertTransform);
_transform = _transform.CreateDublicate();
AscCommon.global_MatrixTransformer.MultiplyAppend(_transform, _group.invertTransform);
}
_startConnectionParams = this.beginShape.convertToConnectionParams(_rot, _flipH, _flipV, _transform, _bounds, g_conn_info);
}
else{
_startConnectionParams = AscFormat.fCalculateConnectionInfo(_endConnectionParams, this.startX, this.startY);
......@@ -67,9 +129,27 @@
if(!_endConnectionParams){
if(this.endShape && oConnectorInfo.endCnxIdx !== null){
oConectionObject = this.endShape.spPr.geometry.cnxLst[oConnectorInfo.endCnxIdx];
g_conn_info = {idx: oConnectorInfo.endCnxIdx, ang: oConectionObject.ang, x: oConectionObject.x, y: oConectionObject.y};
_endConnectionParams = this.endShape.convertToConnectionParams(this.endShape.rot, this.endShape.flipH, this.endShape.flipV, this.endShape.transform, this.endShape.bounds, g_conn_info);
oConnectionObject = this.endShape.spPr.geometry.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;
_flipV = this.endShape.flipV;
_bounds = this.endShape.bounds;
_transform = this.endShape.transform;
if(_group){
_rot = AscFormat.normalizeRotate((this.endShape.group ? this.endShape.group.getFullRotate() : 0) + _rot - _group.getFullRotate());
if(_group.getFullFlipH()){
_flipH = !_flipH;
}
if(_group.getFullFlipV()){
_flipV = !_flipV;
}
_bounds = _bounds.copy();
_bounds.transform(_group.invertTransform);
_transform = _transform.CreateDublicate();
AscCommon.global_MatrixTransformer.MultiplyAppend(_transform, _group.invertTransform);
}
_endConnectionParams = this.endShape.convertToConnectionParams(_rot, _flipH, _flipV, _transform, _bounds, g_conn_info);
}
else {
_endConnectionParams = AscFormat.fCalculateConnectionInfo(_startConnectionParams, this.endX, this.endY);
......@@ -81,7 +161,7 @@
}
this.geometry.Recalculate(this.oSpPr.xfrm.extX, this.oSpPr.xfrm.extY);
var _transform = this.transform;
_transform = this.transform;
_transform.Reset();
var _horizontal_center = this.oSpPr.xfrm.extX*0.5;
......@@ -98,6 +178,11 @@
global_MatrixTransformer.RotateRadAppend(_transform, -(AscFormat.isRealNumber(this.oSpPr.xfrm.rot) ? this.oSpPr.xfrm.rot : 0 ));
global_MatrixTransformer.TranslateAppend(_transform, this.oSpPr.xfrm.offX, this.oSpPr.xfrm.offY);
global_MatrixTransformer.TranslateAppend(_transform, _horizontal_center, _vertical_center);
if(this.connector.group)
{
global_MatrixTransformer.MultiplyAppend(_transform, this.connector.group.transform);
}
};
CConnectorTrack.prototype.trackEnd = function()
......
......@@ -3472,6 +3472,7 @@ function CBinaryFileWriter()
switch(spTree[i].getObjectType())
{
case AscDFH.historyitem_type_Shape:
case AscDFH.historyitem_type_Cnx:
{
oThis.WriteShape(spTree[i]);
break;
......
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