Commit 0703ec84 authored by Sergey Luzyanin's avatar Sergey Luzyanin

fix bug 34568

parent a63bf7c9
......@@ -167,7 +167,7 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor)
if(!worksheet)
return;
var ret, aObjects = worksheet.Drawings;
if (AscFormat.isRealNumber(position)) {
if (AscFormat.isRealNumber(position) && position > -1 && position <= aObjects.length) {
aObjects.splice(position, 0, drawingObject);
ret = position;
}
......@@ -212,7 +212,7 @@ function CChangesDrawingObjectsAddToDrawingObjects(Class, Pos){
this.Type = AscDFH.historyitem_AutoShapes_AddToDrawingObjects;
AscDFH.CChangesBase.call(this, Class);
}
CChangesDrawingObjectsAddToDrawingObjects.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesDrawingObjectsAddToDrawingObjects.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesDrawingObjectsAddToDrawingObjects.prototype.constructor = CChangesDrawingObjectsAddToDrawingObjects;
CChangesDrawingObjectsAddToDrawingObjects.prototype.Undo = function(){
AscFormat.deleteDrawingBase(this.Class.worksheet.Drawings, this.Class.Get_Id());
......@@ -237,7 +237,7 @@ function CChangesDrawingObjectsRemoveFromDrawingObjects(Class, Pos){
this.Pos = Pos;
AscDFH.CChangesBase.call(this, Class);
}
CChangesDrawingObjectsRemoveFromDrawingObjects.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesDrawingObjectsRemoveFromDrawingObjects.prototype = Object.create(AscDFH.CChangesBase.prototype);
CChangesDrawingObjectsRemoveFromDrawingObjects.prototype.constructor = CChangesDrawingObjectsRemoveFromDrawingObjects;
CChangesDrawingObjectsRemoveFromDrawingObjects.prototype.Undo = function(){
AscFormat.addToDrawings(this.Class.worksheet, this.Class, this.Pos);
......
......@@ -6439,15 +6439,29 @@ DrawingObjectsController.prototype =
unGroupCallback: function()
{
var ungroup_arr = this.canUnGroup(true);
var ungroup_arr = this.canUnGroup(true), aGraphicObjects;
if(ungroup_arr.length > 0)
{
this.resetSelection();
var i, j, cur_group, sp_tree, sp;
var i, j, cur_group, sp_tree, sp, nInsertPos;
for(i = 0; i < ungroup_arr.length; ++i)
{
cur_group = ungroup_arr[i];
cur_group.normalize();
aGraphicObjects = this.getDrawingObjects();
nInsertPos = undefined;
for(j = 0; j < aGraphicObjects.length; ++j)
{
if(aGraphicObjects[j] === cur_group)
{
nInsertPos = j;
break;
}
}
sp_tree = cur_group.spTree;
for(j = 0; j < sp_tree.length; ++j)
{
......@@ -6462,7 +6476,12 @@ DrawingObjectsController.prototype =
{
sp.spPr.setFill(cur_group.spPr.Fill.createDuplicate());
}
sp.addToDrawingObjects();
if(AscFormat.isRealNumber(nInsertPos)){
sp.addToDrawingObjects(nInsertPos + j);
}
else {
sp.addToDrawingObjects();
}
sp.checkDrawingBaseCoords();
this.selectObject(sp, 0);
}
......
......@@ -617,7 +617,7 @@ Slide.prototype =
shapeAdd: function(pos, item)
{
this.checkDrawingUniNvPr(item);
var _pos = AscFormat.isRealNumber(pos) ? pos : this.cSld.spTree.length;
var _pos = (AscFormat.isRealNumber(pos) && pos > -1 && pos <= this.cSld.spTree.length) ? pos : this.cSld.spTree.length;
History.Add(new AscDFH.CChangesDrawingsContentPresentation(this, AscDFH.historyitem_SlideAddToSpTree, _pos, [item], true));
this.cSld.spTree.splice(_pos, 0, item);
},
......
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