Commit 00150e75 authored by Sergey.Luzyanin's avatar Sergey.Luzyanin Committed by Alexander.Trofimov

Bug 27353 - [Copy&Paste] Некорректная отрисовка автофигуры "textbox" после её...

Bug 27353 - [Copy&Paste] Некорректная отрисовка автофигуры "textbox" после её копирования на другой лист книги ;

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59417 954022d7-b5bf-4e40-9824-e11837661b57
parent 36749c94
...@@ -1462,8 +1462,34 @@ function DrawingObjects() { ...@@ -1462,8 +1462,34 @@ function DrawingObjects() {
if ( (_t.graphicObject.x < 0) || (_t.graphicObject.y < 0) || (_t.graphicObject.extX < 0) || (_t.graphicObject.extY < 0) ) if ( (_t.graphicObject.x < 0) || (_t.graphicObject.y < 0) || (_t.graphicObject.extX < 0) || (_t.graphicObject.extY < 0) )
return; return;
var fromX = mmToPt(_t.graphicObject.x), fromY = mmToPt(_t.graphicObject.y),
toX = mmToPt(_t.graphicObject.x + _t.graphicObject.extX), toY = mmToPt(_t.graphicObject.y + _t.graphicObject.extY); var rot = isRealNumber(_t.graphicObject.rot) ? _t.graphicObject.rot : 0;
rot = normalizeRotate(rot);
var fromX, fromY, toX, toY;
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
fromX = mmToPt(_t.graphicObject.x);
fromY = mmToPt(_t.graphicObject.y);
toX = mmToPt(_t.graphicObject.x + _t.graphicObject.extX);
toY = mmToPt(_t.graphicObject.y + _t.graphicObject.extY);
}
else
{
var _xc, _yc;
_xc = _t.graphicObject.x + _t.graphicObject.extX/2;
_yc = _t.graphicObject.y + _t.graphicObject.extY/2;
fromX = mmToPt(_xc - _t.graphicObject.extY/2);
fromY = mmToPt(_yc - _t.graphicObject.extX/2);
toX = mmToPt(_xc + _t.graphicObject.extY/2);
toY = mmToPt(_yc + _t.graphicObject.extX/2);
}
// var fromX = mmToPt(_t.graphicObject.x), fromY = mmToPt(_t.graphicObject.y),
// toX = mmToPt(_t.graphicObject.x + _t.graphicObject.extX), toY = mmToPt(_t.graphicObject.y + _t.graphicObject.extY);
var bReinitHorScroll = false, bReinitVertScroll = false; var bReinitHorScroll = false, bReinitVertScroll = false;
var fromColCell = worksheet.findCellByXY(fromX, fromY, true, false, true); var fromColCell = worksheet.findCellByXY(fromX, fromY, true, false, true);
...@@ -1852,13 +1878,57 @@ function DrawingObjects() { ...@@ -1852,13 +1878,57 @@ function DrawingObjects() {
var isSerialize = drawingObject.graphicObject.fromSerialize; var isSerialize = drawingObject.graphicObject.fromSerialize;
if(!api.wbModel.bCollaborativeChanges && isSerialize) if(!api.wbModel.bCollaborativeChanges && isSerialize)
{ {
drawingObject.graphicObject.spPr.xfrm.setOffX(metrics.x);
drawingObject.graphicObject.spPr.xfrm.setOffY(metrics.y); var rot = isRealNumber(drawingObject.graphicObject.spPr.xfrm.rot) ? drawingObject.graphicObject.spPr.xfrm.rot : 0;
} rot = normalizeRotate(rot);
if(drawingObject.graphicObject.getObjectType() !== historyitem_type_GroupShape && !api.wbModel.bCollaborativeChanges && isSerialize)
{ var metricExtX, metricExtY;
drawingObject.graphicObject.spPr.xfrm.setExtX(metrics.extX);
drawingObject.graphicObject.spPr.xfrm.setExtY(metrics.extY); if(drawingObject.graphicObject.getObjectType() !== historyitem_type_GroupShape)
{
metricExtX = metrics.extX;
metricExtY = metrics.extY;
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
drawingObject.graphicObject.spPr.xfrm.setExtX(metrics.extX);
drawingObject.graphicObject.spPr.xfrm.setExtY(metrics.extY);
}
else
{
drawingObject.graphicObject.spPr.xfrm.setExtX(metrics.extY);
drawingObject.graphicObject.spPr.xfrm.setExtY(metrics.extX);
}
}
else
{
if(isRealNumber(drawingObject.graphicObject.spPr.xfrm.extX) && isRealNumber(drawingObject.graphicObject.spPr.xfrm.extY))
{
metricExtX = drawingObject.graphicObject.spPr.xfrm.extX;
metricExtY = drawingObject.graphicObject.spPr.xfrm.extY;
}
else
{
metricExtX = metrics.extX;
metricExtY = metrics.extY;
}
}
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
drawingObject.graphicObject.spPr.xfrm.setOffX(metrics.x);
drawingObject.graphicObject.spPr.xfrm.setOffY(metrics.y);
}
else
{
drawingObject.graphicObject.spPr.xfrm.setOffX(metrics.x + metricExtX/2 - metricExtY/2);
drawingObject.graphicObject.spPr.xfrm.setOffY(metrics.y + metricExtY/2 - metricExtX/2);
}
} }
delete drawingObject.graphicObject.fromSerialize; delete drawingObject.graphicObject.fromSerialize;
...@@ -3211,9 +3281,24 @@ function DrawingObjects() { ...@@ -3211,9 +3281,24 @@ function DrawingObjects() {
obj.to.row = metrics.to.row; obj.to.row = metrics.to.row;
obj.to.rowOff = metrics.to.rowOff; obj.to.rowOff = metrics.to.rowOff;
var coords = _this.coordsManager.calculateCoords(obj.from); var coords = _this.coordsManager.calculateCoords(obj.from);
obj.graphicObject.spPr.xfrm.setOffX( pxToMm(coords.x));
obj.graphicObject.spPr.xfrm.setOffY( pxToMm(coords.y));
var rot = isRealNumber(obj.graphicObject.spPr.xfrm.rot) ? obj.graphicObject.spPr.xfrm.rot : 0;
rot = normalizeRotate(rot);
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
obj.graphicObject.spPr.xfrm.setOffX(pxToMm(coords.x));
obj.graphicObject.spPr.xfrm.setOffY(pxToMm(coords.y));
}
else
{
obj.graphicObject.spPr.xfrm.setOffX(pxToMm(coords.x) - obj.graphicObject.spPr.xfrm.extX/2 + obj.graphicObject.spPr.xfrm.extY/2);
obj.graphicObject.spPr.xfrm.setOffY(pxToMm(coords.y) - obj.graphicObject.spPr.xfrm.extY/2 + obj.graphicObject.spPr.xfrm.extX/2);
}
obj.graphicObject.checkDrawingBaseCoords(); obj.graphicObject.checkDrawingBaseCoords();
obj.graphicObject.recalculate(); obj.graphicObject.recalculate();
bNeedRedraw = true; bNeedRedraw = true;
...@@ -3954,8 +4039,23 @@ function DrawingObjects() { ...@@ -3954,8 +4039,23 @@ function DrawingObjects() {
{ {
coords = _this.coordsManager.calculateCoords(drawingObject.from); coords = _this.coordsManager.calculateCoords(drawingObject.from);
CheckSpPrXfrm(drawingObject.graphicObject); CheckSpPrXfrm(drawingObject.graphicObject);
drawingObject.graphicObject.spPr.xfrm.setOffX( pxToMm(coords.x));
drawingObject.graphicObject.spPr.xfrm.setOffY( pxToMm(coords.y) ); var rot = isRealNumber(drawingObject.graphicObject.spPr.xfrm.rot) ? drawingObject.graphicObject.spPr.xfrm.rot : 0;
rot = normalizeRotate(rot);
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
drawingObject.graphicObject.spPr.xfrm.setOffX(pxToMm(coords.x));
drawingObject.graphicObject.spPr.xfrm.setOffY(pxToMm(coords.y));
}
else
{
drawingObject.graphicObject.spPr.xfrm.setOffX(pxToMm(coords.x) - drawingObject.graphicObject.spPr.xfrm.extX/2 + drawingObject.graphicObject.spPr.xfrm.extY/2);
drawingObject.graphicObject.spPr.xfrm.setOffY(pxToMm(coords.y) - drawingObject.graphicObject.spPr.xfrm.extY/2 + drawingObject.graphicObject.spPr.xfrm.extX/2);
}
//drawingObject.graphicObject.spPr.xfrm.setOffX( pxToMm(coords.x));
//drawingObject.graphicObject.spPr.xfrm.setOffY( pxToMm(coords.y) );
drawingObject.graphicObject.checkDrawingBaseCoords(); drawingObject.graphicObject.checkDrawingBaseCoords();
bNeedRecalc = true; bNeedRecalc = true;
} }
...@@ -3970,8 +4070,24 @@ function DrawingObjects() { ...@@ -3970,8 +4070,24 @@ function DrawingObjects() {
{ {
coords = _this.coordsManager.calculateCoords(drawingObject.from); coords = _this.coordsManager.calculateCoords(drawingObject.from);
CheckSpPrXfrm(drawingObject.graphicObject); CheckSpPrXfrm(drawingObject.graphicObject);
drawingObject.graphicObject.spPr.xfrm.setOffX( pxToMm(coords.x));
drawingObject.graphicObject.spPr.xfrm.setOffY( pxToMm(coords.y) ); var rot = isRealNumber(drawingObject.graphicObject.spPr.xfrm.rot) ? drawingObject.graphicObject.spPr.xfrm.rot : 0;
rot = normalizeRotate(rot);
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
drawingObject.graphicObject.spPr.xfrm.setOffX(pxToMm(coords.x));
drawingObject.graphicObject.spPr.xfrm.setOffY(pxToMm(coords.y));
}
else
{
drawingObject.graphicObject.spPr.xfrm.setOffX(pxToMm(coords.x) - drawingObject.graphicObject.spPr.xfrm.extX/2 + drawingObject.graphicObject.spPr.xfrm.extY/2);
drawingObject.graphicObject.spPr.xfrm.setOffY(pxToMm(coords.y) - drawingObject.graphicObject.spPr.xfrm.extY/2 + drawingObject.graphicObject.spPr.xfrm.extX/2);
}
//drawingObject.graphicObject.spPr.xfrm.setOffX( pxToMm(coords.x));
//drawingObject.graphicObject.spPr.xfrm.setOffY( pxToMm(coords.y) );
drawingObject.graphicObject.checkDrawingBaseCoords(); drawingObject.graphicObject.checkDrawingBaseCoords();
bNeedRecalc = true; bNeedRecalc = true;
} }
......
"use strict"; "use strict";
function CGroupShape(parent) function CGroupShape()
{ {
this.nvGrpSpPr = null; this.nvGrpSpPr = null;
...@@ -297,21 +297,25 @@ CGroupShape.prototype = ...@@ -297,21 +297,25 @@ CGroupShape.prototype =
convertToPPTX: function(drawingDocument, worksheet) convertToPPTX: function(drawingDocument, worksheet)
{ {
var sp_tree_copy = [].concat(this.spTree), i; var c = new CGroupShape();
for(i = this.spTree.length-1; i > -1; --i) c.setBDeleted(false);
c.setWorksheet(worksheet);
if(this.nvGrpSpPr)
{ {
this.removeFromSpTreeByPos(i); c.setNvSpPr(this.nvGrpSpPr.createDuplicate());
}
if(this.spPr)
{
c.setSpPr(this.spPr.createDuplicate());
c.spPr.setParent(c);
} }
this.setWorksheet(worksheet); for(var i = 0; i < this.spTree.length; ++i)
this.setParent(null);
this.setBDeleted(false);
for(i = 0; i < sp_tree_copy.length; ++i)
{ {
this.addToSpTree(this.spTree.length, sp_tree_copy[i].convertToPPTX(drawingDocument, worksheet)); c.addToSpTree(c.spTree.length, this.spTree[i].convertToPPTX(drawingDocument, worksheet));
this.spTree[this.spTree.length - 1].setGroup(this); c.spTree[c.spTree.length - 1].setGroup(c);
} }
return this; return c;
}, },
isSimpleObject: function() isSimpleObject: function()
......
...@@ -61,6 +61,7 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor) ...@@ -61,6 +61,7 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor)
{ {
drawingObjects = new DrawingObjects(); drawingObjects = new DrawingObjects();
} }
var oldDrawingBase = graphic.drawingBase;
var drawingObject = drawingObjects.createDrawingObject(anchor); var drawingObject = drawingObjects.createDrawingObject(anchor);
drawingObject.graphicObject = graphic; drawingObject.graphicObject = graphic;
...@@ -83,11 +84,28 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor) ...@@ -83,11 +84,28 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor)
_this.objectLocker.checkObjects( function(result) {} ); _this.objectLocker.checkObjects( function(result) {} );
} }
worksheet.setSelectionShape(true); */ worksheet.setSelectionShape(true); */
if(oldDrawingBase)
{
drawingObject.from.col = oldDrawingBase.from.col;
drawingObject.from.colOff = oldDrawingBase.from.colOff;
drawingObject.from.row = oldDrawingBase.from.row;
drawingObject.from.rowOff = oldDrawingBase.from.rowOff;
drawingObject.to.col = oldDrawingBase.to.col;
drawingObject.to.colOff = oldDrawingBase.to.colOff;
drawingObject.to.row = oldDrawingBase.to.row;
drawingObject.to.rowOff = oldDrawingBase.to.rowOff;
}
if(graphic.recalcTransform) if(graphic.recalcTransform)
{ {
graphic.recalcTransform(); graphic.recalcTransform();
if(graphic.recalcBounds)
{
graphic.recalcBounds();
}
graphic.addToRecalculate(); graphic.addToRecalculate();
} }
return ret; return ret;
} }
......
...@@ -3023,7 +3023,7 @@ ...@@ -3023,7 +3023,7 @@
_insertImagesFromBinary: function(ws, data, isIntoShape) _insertImagesFromBinary: function(ws, data, isIntoShape)
{ {
var activeRange = ws.activeRange; var activeRange = ws.activeRange;
var curCol, drawingObject, curRow, startCol, startRow, xfrm, aImagesSync = [], activeRow, activeCol, tempArr; var curCol, drawingObject, curRow, startCol, startRow, xfrm, aImagesSync = [], activeRow, activeCol, tempArr, offX, offY, rot;
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
...@@ -3035,20 +3035,44 @@ ...@@ -3035,20 +3035,44 @@
xfrm = drawingObject.graphicObject.spPr.xfrm; xfrm = drawingObject.graphicObject.spPr.xfrm;
if(xfrm) if(xfrm)
{ {
offX = 0;
offY = 0;
rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
rot = normalizeRotate(rot);
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
if(isRealNumber(xfrm.offX) && isRealNumber(xfrm.offY))
{
offX = xfrm.offX;
offY = xfrm.offY;
}
}
else
{
if(isRealNumber(xfrm.offX) && isRealNumber(xfrm.offY)
&& isRealNumber(xfrm.extX) && isRealNumber(xfrm.extY))
{
offX = xfrm.offX + xfrm.extX/2 - xfrm.extY/2;
offY = xfrm.offY + xfrm.extY/2 - xfrm.extX/2;
}
}
if(i == 0) if(i == 0)
{ {
startCol = xfrm.offX; startCol = offX;
startRow = xfrm.offY; startRow = offY;
} }
else else
{ {
if(startCol > xfrm.offX) if(startCol > offX)
{ {
startCol = xfrm.offX; startCol = offX;
} }
if(startRow > xfrm.offY) if(startRow > offY)
{ {
startRow = xfrm.offY; startRow = offY;
} }
} }
} }
...@@ -3072,7 +3096,16 @@ ...@@ -3072,7 +3096,16 @@
} }
} }
}; };
if(startRow < 0)
{
startRow = 0;
}
if(startCol < 0)
{
startCol = 0;
}
for(var i = 0; i < data.Drawings.length; i++) for(var i = 0; i < data.Drawings.length; i++)
{ {
data.Drawings[i].graphicObject = data.Drawings[i].graphicObject.copy(); data.Drawings[i].graphicObject = data.Drawings[i].graphicObject.copy();
...@@ -3105,6 +3138,10 @@ ...@@ -3105,6 +3138,10 @@
//drawingObject.graphicObject.setDrawingDocument(ws.objectRender.drawingDocument); //drawingObject.graphicObject.setDrawingDocument(ws.objectRender.drawingDocument);
drawingObject.graphicObject.addToDrawingObjects(); drawingObject.graphicObject.addToDrawingObjects();
if(drawingObject.graphicObject.checkDrawingBaseCoords)
{
drawingObject.graphicObject.checkDrawingBaseCoords();
}
drawingObject.graphicObject.recalculate(); drawingObject.graphicObject.recalculate();
drawingObject.graphicObject.select(ws.objectRender.controller, 0); drawingObject.graphicObject.select(ws.objectRender.controller, 0);
...@@ -3138,7 +3175,7 @@ ...@@ -3138,7 +3175,7 @@
_insertImagesFromBinaryWord: function(ws, data) _insertImagesFromBinaryWord: function(ws, data)
{ {
var activeRange = ws.activeRange; var activeRange = ws.activeRange;
var curCol, drawingObject, curRow, startCol, startRow, xfrm, drawingBase, graphicObject, aImagesSync = []; var curCol, drawingObject, curRow, startCol = 0, startRow = 0, xfrm, drawingBase, graphicObject, aImagesSync = [], offX, offY, rot;
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
...@@ -3162,24 +3199,48 @@ ...@@ -3162,24 +3199,48 @@
//create new drawingBase //create new drawingBase
drawingObject = ws.objectRender.createDrawingObject(); drawingObject = ws.objectRender.createDrawingObject();
drawingObject.graphicObject = graphicObject; drawingObject.graphicObject = graphicObject;
xfrm = drawingObject.graphicObject.spPr.xfrm; if(drawingObject.graphicObject.spPr && drawingObject.graphicObject.spPr.xfrm)
if(xfrm)
{ {
xfrm = drawingObject.graphicObject.spPr.xfrm;
offX = 0;
offY = 0;
rot = isRealNumber(xfrm.rot) ? xfrm.rot : 0;
rot = normalizeRotate(rot);
if ((rot >= 0 && rot < Math.PI * 0.25)
|| (rot > 3 * Math.PI * 0.25 && rot < 5 * Math.PI * 0.25)
|| (rot > 7 * Math.PI * 0.25 && rot < 2 * Math.PI))
{
if(isRealNumber(xfrm.offX) && isRealNumber(xfrm.offY))
{
offX = xfrm.offX;
offY = xfrm.offY;
}
}
else
{
if(isRealNumber(xfrm.offX) && isRealNumber(xfrm.offY)
&& isRealNumber(xfrm.extX) && isRealNumber(xfrm.extY))
{
offX = xfrm.offX + xfrm.extX/2 - xfrm.extY/2;
offY = xfrm.offY + xfrm.extY/2 - xfrm.extX/2;
}
}
if(i == 0) if(i == 0)
{ {
startCol = xfrm.offX; startCol = offX;
startRow = xfrm.offY; startRow = offY;
} }
else else
{ {
if(startCol > xfrm.offX) if(startCol > offX)
{ {
startCol = xfrm.offX; startCol = offX;
} }
if(startRow > xfrm.offY) if(startRow > offY)
{ {
startRow = xfrm.offY; startRow = offY;
} }
} }
} }
...@@ -3221,6 +3282,10 @@ ...@@ -3221,6 +3282,10 @@
drawingObject.graphicObject.checkRemoveCache && drawingObject.graphicObject.checkRemoveCache(); drawingObject.graphicObject.checkRemoveCache && drawingObject.graphicObject.checkRemoveCache();
//drawingObject.graphicObject.setDrawingDocument(ws.objectRender.drawingDocument); //drawingObject.graphicObject.setDrawingDocument(ws.objectRender.drawingDocument);
drawingObject.graphicObject.addToDrawingObjects(); drawingObject.graphicObject.addToDrawingObjects();
if(drawingObject.graphicObject.checkDrawingBaseCoords)
{
drawingObject.graphicObject.checkDrawingBaseCoords();
}
drawingObject.graphicObject.recalculate(); drawingObject.graphicObject.recalculate();
drawingObject.graphicObject.select(ws.objectRender.controller, 0); drawingObject.graphicObject.select(ws.objectRender.controller, 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