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() {
if ( (_t.graphicObject.x < 0) || (_t.graphicObject.y < 0) || (_t.graphicObject.extX < 0) || (_t.graphicObject.extY < 0) )
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 fromColCell = worksheet.findCellByXY(fromX, fromY, true, false, true);
......@@ -1852,13 +1878,57 @@ function DrawingObjects() {
var isSerialize = drawingObject.graphicObject.fromSerialize;
if(!api.wbModel.bCollaborativeChanges && isSerialize)
{
drawingObject.graphicObject.spPr.xfrm.setOffX(metrics.x);
drawingObject.graphicObject.spPr.xfrm.setOffY(metrics.y);
}
if(drawingObject.graphicObject.getObjectType() !== historyitem_type_GroupShape && !api.wbModel.bCollaborativeChanges && isSerialize)
{
drawingObject.graphicObject.spPr.xfrm.setExtX(metrics.extX);
drawingObject.graphicObject.spPr.xfrm.setExtY(metrics.extY);
var rot = isRealNumber(drawingObject.graphicObject.spPr.xfrm.rot) ? drawingObject.graphicObject.spPr.xfrm.rot : 0;
rot = normalizeRotate(rot);
var metricExtX, metricExtY;
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;
......@@ -3211,9 +3281,24 @@ function DrawingObjects() {
obj.to.row = metrics.to.row;
obj.to.rowOff = metrics.to.rowOff;
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.recalculate();
bNeedRedraw = true;
......@@ -3954,8 +4039,23 @@ function DrawingObjects() {
{
coords = _this.coordsManager.calculateCoords(drawingObject.from);
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();
bNeedRecalc = true;
}
......@@ -3970,8 +4070,24 @@ function DrawingObjects() {
{
coords = _this.coordsManager.calculateCoords(drawingObject.from);
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();
bNeedRecalc = true;
}
......
"use strict";
function CGroupShape(parent)
function CGroupShape()
{
this.nvGrpSpPr = null;
......@@ -297,21 +297,25 @@ CGroupShape.prototype =
convertToPPTX: function(drawingDocument, worksheet)
{
var sp_tree_copy = [].concat(this.spTree), i;
for(i = this.spTree.length-1; i > -1; --i)
var c = new CGroupShape();
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);
this.setParent(null);
this.setBDeleted(false);
for(i = 0; i < sp_tree_copy.length; ++i)
for(var i = 0; i < this.spTree.length; ++i)
{
this.addToSpTree(this.spTree.length, sp_tree_copy[i].convertToPPTX(drawingDocument, worksheet));
this.spTree[this.spTree.length - 1].setGroup(this);
c.addToSpTree(c.spTree.length, this.spTree[i].convertToPPTX(drawingDocument, worksheet));
c.spTree[c.spTree.length - 1].setGroup(c);
}
return this;
return c;
},
isSimpleObject: function()
......
......@@ -61,6 +61,7 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor)
{
drawingObjects = new DrawingObjects();
}
var oldDrawingBase = graphic.drawingBase;
var drawingObject = drawingObjects.createDrawingObject(anchor);
drawingObject.graphicObject = graphic;
......@@ -83,11 +84,28 @@ function addToDrawings(worksheet, graphic, position, lockByDefault, anchor)
_this.objectLocker.checkObjects( function(result) {} );
}
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)
{
graphic.recalcTransform();
if(graphic.recalcBounds)
{
graphic.recalcBounds();
}
graphic.addToRecalculate();
}
return ret;
}
......
......@@ -3023,7 +3023,7 @@
_insertImagesFromBinary: function(ws, data, isIntoShape)
{
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.StartTransaction();
......@@ -3035,20 +3035,44 @@
xfrm = drawingObject.graphicObject.spPr.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)
{
startCol = xfrm.offX;
startRow = xfrm.offY;
startCol = offX;
startRow = offY;
}
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 @@
}
}
};
if(startRow < 0)
{
startRow = 0;
}
if(startCol < 0)
{
startCol = 0;
}
for(var i = 0; i < data.Drawings.length; i++)
{
data.Drawings[i].graphicObject = data.Drawings[i].graphicObject.copy();
......@@ -3105,6 +3138,10 @@
//drawingObject.graphicObject.setDrawingDocument(ws.objectRender.drawingDocument);
drawingObject.graphicObject.addToDrawingObjects();
if(drawingObject.graphicObject.checkDrawingBaseCoords)
{
drawingObject.graphicObject.checkDrawingBaseCoords();
}
drawingObject.graphicObject.recalculate();
drawingObject.graphicObject.select(ws.objectRender.controller, 0);
......@@ -3138,7 +3175,7 @@
_insertImagesFromBinaryWord: function(ws, data)
{
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.StartTransaction();
......@@ -3162,24 +3199,48 @@
//create new drawingBase
drawingObject = ws.objectRender.createDrawingObject();
drawingObject.graphicObject = graphicObject;
xfrm = drawingObject.graphicObject.spPr.xfrm;
if(xfrm)
if(drawingObject.graphicObject.spPr && drawingObject.graphicObject.spPr.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)
{
startCol = xfrm.offX;
startRow = xfrm.offY;
startCol = offX;
startRow = offY;
}
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 @@
drawingObject.graphicObject.checkRemoveCache && drawingObject.graphicObject.checkRemoveCache();
//drawingObject.graphicObject.setDrawingDocument(ws.objectRender.drawingDocument);
drawingObject.graphicObject.addToDrawingObjects();
if(drawingObject.graphicObject.checkDrawingBaseCoords)
{
drawingObject.graphicObject.checkDrawingBaseCoords();
}
drawingObject.graphicObject.recalculate();
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