Commit 441584da authored by SergeyLuzyanin's avatar SergeyLuzyanin

opens/save connectors in presentations

parent c4372698
...@@ -163,6 +163,43 @@ function BinaryPPTYLoader() ...@@ -163,6 +163,43 @@ function BinaryPPTYLoader()
this.textBodyTextFit = []; this.textBodyTextFit = [];
this.DocReadResult = null; this.DocReadResult = null;
this.arr_connectors = [];
this.map_shapes_by_id = {};
this.ClearConnectorsMaps = function(){
this.arr_connectors.length = 0;
this.map_shapes_by_id = {};
};
this.AssignConnectorsId = function () {
var oPr = null;
for(var i = 0; i < this.arr_connectors.length; ++i){
oPr = this.arr_connectors[i].nvSpPr.nvUniSpPr;
if(AscFormat.isRealNumber(oPr.stCnxId)){
if(AscCommon.isRealObject(this.map_shapes_by_id[oPr.stCnxId])){
oPr.stCnxId = this.map_shapes_by_id[oPr.stCnxId].Id;
}
else{
oPr.stCnxId = null;
oPr.stCnxIdx = null;
}
}
if(AscFormat.isRealNumber(oPr.endCnxId)){
if(AscCommon.isRealObject(this.map_shapes_by_id[oPr.endCnxId])){
oPr.endCnxId = this.map_shapes_by_id[oPr.endCnxId].Id;
}
else{
oPr.endCnxId = null;
oPr.endCnxIdx = null;
}
}
this.arr_connectors[i].nvSpPr.setUniSpPr(oPr.copy());
}
this.ClearConnectorsMaps();
};
this.Start_UseFullUrl = function(insertDocumentUrlsData) this.Start_UseFullUrl = function(insertDocumentUrlsData)
{ {
this.IsUseFullUrl = true; this.IsUseFullUrl = true;
...@@ -3563,7 +3600,9 @@ function BinaryPPTYLoader() ...@@ -3563,7 +3600,9 @@ function BinaryPPTYLoader()
case 1: case 1:
{ {
// SHAPES // SHAPES
this.ClearConnectorsMaps();
csld.spTree = this.ReadGroupShapeMain(); csld.spTree = this.ReadGroupShapeMain();
this.AssignConnectorsId();
break; break;
} }
default: default:
...@@ -5094,7 +5133,7 @@ function BinaryPPTYLoader() ...@@ -5094,7 +5133,7 @@ function BinaryPPTYLoader()
{ {
case 0: case 0:
{ {
var pr = this.ReadNvUniProp(shape.getObjectType()); var pr = this.ReadNvUniProp(shape);
shape.setNvSpPr(pr); shape.setNvSpPr(pr);
if(AscFormat.isRealNumber(pr.locks)) if(AscFormat.isRealNumber(pr.locks))
{ {
...@@ -5175,7 +5214,7 @@ function BinaryPPTYLoader() ...@@ -5175,7 +5214,7 @@ function BinaryPPTYLoader()
{ {
case 0: case 0:
{ {
var pr = this.ReadNvUniProp(shape.getObjectType()); var pr = this.ReadNvUniProp(shape);
shape.setNvSpPr(pr); shape.setNvSpPr(pr);
if(AscFormat.isRealNumber(pr.locks)) if(AscFormat.isRealNumber(pr.locks))
{ {
...@@ -5412,7 +5451,7 @@ function BinaryPPTYLoader() ...@@ -5412,7 +5451,7 @@ function BinaryPPTYLoader()
{ {
case 0: case 0:
{ {
var pr = this.ReadNvUniProp(pic.getObjectType()); var pr = this.ReadNvUniProp(pic);
pic.setNvSpPr(pr); pic.setNvSpPr(pr);
if(AscFormat.isRealNumber(pr.locks)){ if(AscFormat.isRealNumber(pr.locks)){
pic.setLocks(pr.locks); pic.setLocks(pr.locks);
...@@ -5461,7 +5500,7 @@ function BinaryPPTYLoader() ...@@ -5461,7 +5500,7 @@ function BinaryPPTYLoader()
{ {
var s = this.stream; var s = this.stream;
var shape = new AscFormat.CShape(); var shape = new AscFormat.CConnectionShape();
shape.setBDeleted(false); shape.setBDeleted(false);
var _rec_start = s.cur; var _rec_start = s.cur;
...@@ -5501,7 +5540,7 @@ function BinaryPPTYLoader() ...@@ -5501,7 +5540,7 @@ function BinaryPPTYLoader()
} }
} }
} }
this.arr_connectors.push(shape);
s.Seek2(_end_rec); s.Seek2(_end_rec);
return shape; return shape;
} }
...@@ -5538,7 +5577,6 @@ function BinaryPPTYLoader() ...@@ -5538,7 +5577,6 @@ function BinaryPPTYLoader()
var _nvGraphicFramePr = null; var _nvGraphicFramePr = null;
var _xfrm = null; var _xfrm = null;
var _chart = null; var _chart = null;
while (s.cur < _end_rec) while (s.cur < _end_rec)
{ {
var _at = s.GetUChar(); var _at = s.GetUChar();
...@@ -5546,7 +5584,9 @@ function BinaryPPTYLoader() ...@@ -5546,7 +5584,9 @@ function BinaryPPTYLoader()
{ {
case 0: case 0:
{ {
_nvGraphicFramePr = this.ReadNvUniProp(AscDFH.historyitem_type_GraphicFrame); _nvGraphicFramePr = this.ReadNvUniProp(AscFormat.ExecuteNoHistory(function () {
return new AscFormat.CGraphicFrame();
}, this, []));
break; break;
} }
case 1: case 1:
...@@ -5653,7 +5693,7 @@ function BinaryPPTYLoader() ...@@ -5653,7 +5693,7 @@ function BinaryPPTYLoader()
{ {
case 0: case 0:
{ {
_nvGraphicFramePr = this.ReadNvUniProp(AscDFH.historyitem_type_GraphicFrame); _nvGraphicFramePr = this.ReadNvUniProp(_graphic_frame);
break; break;
} }
case 1: case 1:
...@@ -5762,7 +5802,7 @@ function BinaryPPTYLoader() ...@@ -5762,7 +5802,7 @@ function BinaryPPTYLoader()
return _graphic_frame; return _graphic_frame;
} }
this.ReadNvUniProp = function(drawingType) this.ReadNvUniProp = function(drawing)
{ {
var prop = new AscFormat.UniNvPr(); var prop = new AscFormat.UniNvPr();
...@@ -5779,6 +5819,12 @@ function BinaryPPTYLoader() ...@@ -5779,6 +5819,12 @@ function BinaryPPTYLoader()
case 0: case 0:
{ {
this.ReadCNvPr(prop.cNvPr); this.ReadCNvPr(prop.cNvPr);
if(AscCommon.isRealObject(drawing))
{
if(AscDFH.historyitem_type_Shape === drawing.getObjectType()){
this.map_shapes_by_id[prop.cNvPr.id] = drawing;
}
}
break; break;
} }
case 1: case 1:
...@@ -5786,8 +5832,9 @@ function BinaryPPTYLoader() ...@@ -5786,8 +5832,9 @@ function BinaryPPTYLoader()
var end = s.cur + s.GetULong() + 4; var end = s.cur + s.GetULong() + 4;
var locks = 0; var locks = 0;
if(AscFormat.isRealNumber(drawingType)) if(AscCommon.isRealObject(drawing))
{ {
var drawingType = drawing.getObjectType();
switch(drawingType) switch(drawingType)
{ {
case AscDFH.historyitem_type_Shape: case AscDFH.historyitem_type_Shape:
...@@ -6045,6 +6092,90 @@ function BinaryPPTYLoader() ...@@ -6045,6 +6092,90 @@ function BinaryPPTYLoader()
prop.locks = locks; prop.locks = locks;
break; break;
} }
case AscDFH.historyitem_type_Cnx:{
s.Skip2(1); // attribute start
while (true)
{
var _at2 = s.GetUChar();
if (_at2 == g_nodeAttributeEnd)
break;
var value;
switch(_at2)
{
case 0: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noAdjustHandles | (value ? AscFormat.LOCKS_MASKS.noAdjustHandles << 1 : 0));
break;
}
case 1: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noChangeArrowheads | (value ? AscFormat.LOCKS_MASKS.noChangeArrowheads << 1 : 0));
break;
}
case 2: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noChangeAspect | (value ? AscFormat.LOCKS_MASKS.noChangeAspect << 1 : 0));
break;
}
case 3: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noChangeShapeType | (value ? AscFormat.LOCKS_MASKS.noChangeShapeType << 1 : 0));
break;
}
case 4: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noEditPoints | (value ? AscFormat.LOCKS_MASKS.noEditPoints << 1 : 0));
break;
}
case 5: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noGrp | (value ? AscFormat.LOCKS_MASKS.noGrp << 1 : 0));
break;
}
case 6: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noMove | (value ? AscFormat.LOCKS_MASKS.noMove << 1 : 0));
break;
}
case 7: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noResize | (value ? AscFormat.LOCKS_MASKS.noResize << 1 : 0));
break;
}
case 8: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noRot | (value ? AscFormat.LOCKS_MASKS.noRot << 1 : 0));
break;
}
case 9: {
value = s.GetBool();
locks |= (AscFormat.LOCKS_MASKS.noSelect | (value ? AscFormat.LOCKS_MASKS.noSelect << 1 : 0));
break;
}
case 10:{
prop.nvUniSpPr.stCnxId = s.GetULong();
break;
}
case 11:{
prop.nvUniSpPr.stCnxIdx = s.GetULong();
break;
}
case 12:{
prop.nvUniSpPr.endCnxId = s.GetULong();
break;
}
case 13:{
prop.nvUniSpPr.endCnxIdx = s.GetULong();
break;
}
}
}
prop.locks = locks;
prop.setUniSpPr(prop.nvUniSpPr.copy());
break;
}
} }
} }
s.Seek2(end); s.Seek2(end);
...@@ -9172,7 +9303,7 @@ function CPres() ...@@ -9172,7 +9303,7 @@ function CPres()
{ {
var s = this.stream; var s = this.stream;
var shape = new AscFormat.CShape( ); var shape = new AscFormat.CConnectionShape( );
shape.setWordShape(true); shape.setWordShape(true);
shape.setParent(this.TempMainObject == null ? this.ParaDrawing : null); shape.setParent(this.TempMainObject == null ? this.ParaDrawing : null);
var _rec_start = s.cur; var _rec_start = s.cur;
......
...@@ -124,6 +124,9 @@ function CBinaryFileWriter() ...@@ -124,6 +124,9 @@ function CBinaryFileWriter()
this.IsUseFullUrl = false; this.IsUseFullUrl = false;
this.PresentationThemesOrigin = ""; this.PresentationThemesOrigin = "";
this.arr_connectors_pos = [];
this.max_shape_id = 1;
this.DocSaveParams = null; this.DocSaveParams = null;
var oThis = this; var oThis = this;
...@@ -1539,6 +1542,7 @@ function CBinaryFileWriter() ...@@ -1539,6 +1542,7 @@ function CBinaryFileWriter()
oThis.StartRecord(2); oThis.StartRecord(2);
oThis.WriteULong(_len); oThis.WriteULong(_len);
oThis.arr_connectors_pos.length = 0;
for (var i = 0; i < _len; i++) for (var i = 0; i < _len; i++)
{ {
oThis.StartRecord(0); oThis.StartRecord(0);
...@@ -1546,6 +1550,7 @@ function CBinaryFileWriter() ...@@ -1546,6 +1550,7 @@ function CBinaryFileWriter()
switch(spTree[i].getObjectType()) switch(spTree[i].getObjectType())
{ {
case AscDFH.historyitem_type_Shape: case AscDFH.historyitem_type_Shape:
case AscDFH.historyitem_type_Cnx:
{ {
oThis.WriteShape(spTree[i]); oThis.WriteShape(spTree[i]);
break; break;
...@@ -1577,7 +1582,18 @@ function CBinaryFileWriter() ...@@ -1577,7 +1582,18 @@ function CBinaryFileWriter()
oThis.EndRecord(); oThis.EndRecord();
} }
var _oldPos = oThis.pos;
for(var i = 0; i < oThis.arr_connectors_pos.length; ++i){
var oPos = oThis.arr_connectors_pos[i];
var oShape = AscCommon.g_oTableId.Get_ById(oPos.shapeId);
if(oShape && oShape.nvSpPr && oShape.nvSpPr.cNvPr){
oThis.Seek(oPos.pos);
oThis._WriteInt2(oPos.type, oShape.nvSpPr.cNvPr.id);
}
}
oThis.arr_connectors_pos.length = 0;
oThis.Seek(_oldPos);
oThis.EndRecord(); oThis.EndRecord();
} }
...@@ -2881,7 +2897,13 @@ function CBinaryFileWriter() ...@@ -2881,7 +2897,13 @@ function CBinaryFileWriter()
this.WriteShape = function(shape) this.WriteShape = function(shape)
{ {
oThis.StartRecord(1); if(shape.getObjectType() === AscDFH.historyitem_type_Cnx){
oThis.StartRecord(3);
}
else{
oThis.StartRecord(1);
}
oThis.WriteUChar(g_nodeAttributeStart); oThis.WriteUChar(g_nodeAttributeStart);
oThis._WriteBool2(0, shape.attrUseBgFill); oThis._WriteBool2(0, shape.attrUseBgFill);
...@@ -3702,10 +3724,48 @@ function CBinaryFileWriter() ...@@ -3702,10 +3724,48 @@ function CBinaryFileWriter()
oThis.WriteUChar(g_nodeAttributeEnd); oThis.WriteUChar(g_nodeAttributeEnd);
}; };
this.WriteCnxCNvPr = function(pr){
var locks = pr.locks;
oThis.WriteUChar(g_nodeAttributeStart);
if(locks & AscFormat.LOCKS_MASKS.noAdjustHandles)
oThis._WriteBool2(0, !!(locks & (AscFormat.LOCKS_MASKS.noAdjustHandles << 1)));
if(locks & AscFormat.LOCKS_MASKS.noChangeArrowheads)
oThis._WriteBool2(1, !!(locks & (AscFormat.LOCKS_MASKS.noChangeArrowheads << 1)));
if(locks & AscFormat.LOCKS_MASKS.noChangeAspect)
oThis._WriteBool2(2, !!(locks & (AscFormat.LOCKS_MASKS.noChangeAspect << 1)));
if(locks & AscFormat.LOCKS_MASKS.noChangeShapeType)
oThis._WriteBool2(3, !!(locks & (AscFormat.LOCKS_MASKS.noChangeShapeType << 1)));
if(locks & AscFormat.LOCKS_MASKS.noEditPoints)
oThis._WriteBool2(4, !!(locks & (AscFormat.LOCKS_MASKS.noEditPoints << 1)));
if(locks & AscFormat.LOCKS_MASKS.noGrp)
oThis._WriteBool2(5, !!(locks & (AscFormat.LOCKS_MASKS.noGrp << 1)));
if(locks & AscFormat.LOCKS_MASKS.noMove)
oThis._WriteBool2(6, !!(locks & (AscFormat.LOCKS_MASKS.noMove << 1)));
if(locks & AscFormat.LOCKS_MASKS.noResize)
oThis._WriteBool2(7, !!(locks & (AscFormat.LOCKS_MASKS.noResize << 1)));
if(locks & AscFormat.LOCKS_MASKS.noRot)
oThis._WriteBool2(8, !!(locks & (AscFormat.LOCKS_MASKS.noRot << 1)));
if(locks & AscFormat.LOCKS_MASKS.noSelect)
oThis._WriteBool2(9, !!(locks & (AscFormat.LOCKS_MASKS.noSelect << 1)));
if(pr.stCnxId && AscFormat.isRealNumber(pr.stCnxIdx)){
oThis.arr_connectors_pos.push({pos: oThis.pos, shapeId: pr.stCnxId, type: 10});
oThis._WriteInt2(10, -1);
oThis._WriteInt2(11, pr.stCnxIdx);
}
if(pr.endCnxId && AscFormat.isRealNumber(pr.endCnxIdx)){
oThis.arr_connectors_pos.push({pos: oThis.pos, shapeId: pr.endCnxId, type: 12});
oThis._WriteInt2(12, -1);
oThis._WriteInt2(13, pr.endCnxIdx);
}
oThis.WriteUChar(g_nodeAttributeEnd);
};
this.WriteUniNvPr = function(nv) this.WriteUniNvPr = function(nv)
{ {
oThis.WriteRecord2(0, nv.cNvPr, oThis.Write_cNvPr); oThis.WriteRecord2(0, nv.cNvPr, oThis.Write_cNvPr);
if(AscFormat.isRealNumber(nv.locks) && nv.locks !== 0 && AscFormat.isRealNumber(nv.objectType)) if(AscFormat.isRealNumber(nv.locks) && (nv.locks !== 0 || nv.nvUniSpPr) && AscFormat.isRealNumber(nv.objectType))
{ {
switch(nv.objectType) switch(nv.objectType)
{ {
...@@ -3730,6 +3790,12 @@ function CBinaryFileWriter() ...@@ -3730,6 +3790,12 @@ function CBinaryFileWriter()
oThis.WriteRecord1(1, nv.locks, oThis.WriteGrFrameCNvPr); oThis.WriteRecord1(1, nv.locks, oThis.WriteGrFrameCNvPr);
break; break;
} }
case AscDFH.historyitem_type_Cnx:
{
nv.nvUniSpPr.locks = nv.locks;
oThis.WriteRecord1(1, nv.nvUniSpPr, oThis.WriteCnxCNvPr);
break;
}
} }
} }
nv.locks = null; nv.locks = null;
...@@ -3740,6 +3806,7 @@ function CBinaryFileWriter() ...@@ -3740,6 +3806,7 @@ function CBinaryFileWriter()
this.Write_cNvPr = function(cNvPr) this.Write_cNvPr = function(cNvPr)
{ {
oThis.WriteUChar(g_nodeAttributeStart); oThis.WriteUChar(g_nodeAttributeStart);
cNvPr.id = ++oThis.max_shape_id;
oThis._WriteInt1(0, cNvPr.id); oThis._WriteInt1(0, cNvPr.id);
oThis._WriteString1(1, cNvPr.name); oThis._WriteString1(1, cNvPr.name);
oThis._WriteBool1(2, cNvPr.isHidden); oThis._WriteBool1(2, cNvPr.isHidden);
......
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