Commit 4eb546aa authored by Sergey Luzyanin's avatar Sergey Luzyanin

fixed problems with drawing measuring

parent 4d6a3ce4
......@@ -634,11 +634,32 @@ CWrapPolygon.prototype =
var bounds = drawing.bounds, oDistance = drawing.parent.Get_Distance(), oEffectExtent = drawing.parent.EffectExtent;
if(this.relativeArrPoints.length === 0)
{
var oEffectExtent = drawing.parent.EffectExtent;
var W, H;
if(AscFormat.isRealNumber(drawing.rot)){
if(AscFormat.checkNormalRotate(drawing.rot))
{
W = drawing.parent.Extent.W;
H = drawing.parent.Extent.H;
}
else
{
W = drawing.parent.Extent.H;
H = drawing.parent.Extent.W;
}
}
else{
W = drawing.parent.Extent.W;
H = drawing.parent.Extent.H;
}
var xc = drawing.localTransform.TransformPointX(drawing.extX / 2, drawing.extY / 2);
var yc = drawing.localTransform.TransformPointY(drawing.extX / 2, drawing.extY / 2);
this.arrPoints.length = 0;
this.localLeft = -oDistance.L - AscFormat.getValOrDefault(oEffectExtent.L, 0);
this.localRight = drawing.parent.Extent.W + oDistance.R + AscFormat.getValOrDefault(oEffectExtent.R, 0);
this.localTop = -oDistance.T - AscFormat.getValOrDefault(oEffectExtent.T, 0);
this.localBottom = drawing.parent.Extent.H + oDistance.B + AscFormat.getValOrDefault(oEffectExtent.B, 0);
this.localLeft = - AscFormat.getValOrDefault(oEffectExtent.L, 0) + (xc - W / 2) - oDistance.L ;
this.localRight = AscFormat.getValOrDefault(oEffectExtent.R, 0) + (xc + W / 2) + oDistance.R;
this.localTop = - AscFormat.getValOrDefault(oEffectExtent.T, 0) + (yc - H / 2) - oDistance.T;
this.localBottom = AscFormat.getValOrDefault(oEffectExtent.B, 0) + (yc + H / 2) + oDistance.B;
return;
}
var relArr = this.relativeArrPoints;
......
......@@ -829,30 +829,37 @@ ParaDrawing.prototype.CheckWH = function()
{
if (!this.GraphicObj)
return;
var dW, dH;
this.GraphicObj.recalculate();
var extX, extY;
if (this.GraphicObj.spPr.xfrm && AscFormat.isRealNumber(this.GraphicObj.spPr.xfrm.extX) && AscFormat.isRealNumber(this.GraphicObj.spPr.xfrm.extY))
var extX, extY, rot;
if (this.GraphicObj.spPr.xfrm )
{
extX = this.GraphicObj.spPr.xfrm.extX;
extY = this.GraphicObj.spPr.xfrm.extY;
if(AscFormat.isRealNumber(this.GraphicObj.spPr.xfrm.extX) && AscFormat.isRealNumber(this.GraphicObj.spPr.xfrm.extY))
{
extX = this.GraphicObj.spPr.xfrm.extX;
extY = this.GraphicObj.spPr.xfrm.extY;
}
else
{
extX = 5;
extY = 5;
}
if(AscFormat.isRealNumber(this.GraphicObj.spPr.xfrm.rot))
{
rot = this.GraphicObj.spPr.xfrm.rot;
}
else
{
rot = 0;
}
}
else
{
extX = 5;
extY = 5;
}
if (AscFormat.checkNormalRotate(AscFormat.isRealNumber(this.GraphicObj.rot) ? this.GraphicObj.rot : 0))
{
dW = extX;
dH = extY;
}
else
{
dH = extX;
dW = extY;
rot = 0;
}
this.setExtent(extX, extY);
var xc = this.GraphicObj.localTransform.TransformPointX(this.GraphicObj.extX / 2, this.GraphicObj.extY / 2);
var yc = this.GraphicObj.localTransform.TransformPointY(this.GraphicObj.extX / 2, this.GraphicObj.extY / 2);
var oBounds = this.GraphicObj.bounds;
......@@ -862,11 +869,17 @@ ParaDrawing.prototype.CheckWH = function()
LineCorrect = (this.GraphicObj.pen.w == null) ? 12700 : parseInt(this.GraphicObj.pen.w);
LineCorrect /= 72000.0;
}
var EEL = (xc - this.Extent.W / 2) - oBounds.l - LineCorrect;
var EET = (yc - this.Extent.H / 2) - oBounds.t - LineCorrect;
var EER = oBounds.r + LineCorrect - (xc + this.Extent.W / 2);
var EEB = oBounds.b + LineCorrect - (yc + this.Extent.H / 2);
this.setEffectExtent(EEL > 0 ? EEL : 0, EET > 0 ? EET : 0, EER > 0 ? EER : 0, EEB > 0 ? EEB : 0);
if(!AscFormat.checkNormalRotate(rot)){
var t = extX;
extX = extY;
extY = t;
}
var EEL = (xc - extX / 2) - oBounds.l + LineCorrect;
var EET = (yc - extY / 2) - oBounds.t + LineCorrect;
var EER = oBounds.r + LineCorrect - (xc + extX / 2);
var EEB = oBounds.b + LineCorrect - (yc + extY / 2);
this.setEffectExtent(EEL, EET, EER, EEB);
this.Check_WrapPolygon();
};
ParaDrawing.prototype.Check_WrapPolygon = function()
......@@ -895,6 +908,7 @@ ParaDrawing.prototype.Draw = function( X, Y, pGraphics, pageIndex, align)
pGraphics.End_Command();
}
};
ParaDrawing.prototype.Measure = function()
{
if (!this.GraphicObj)
......@@ -906,20 +920,26 @@ ParaDrawing.prototype.Measure = function()
if (AscFormat.isRealNumber(this.Extent.W) && AscFormat.isRealNumber(this.Extent.H) && (!this.GraphicObj.checkAutofit || !this.GraphicObj.checkAutofit()) && !this.SizeRelH && !this.SizeRelV)
{
var oEffectExtent = this.EffectExtent;
var dW, dH;
if (AscFormat.checkNormalRotate(AscFormat.isRealNumber(this.GraphicObj.rot) ? this.GraphicObj.rot : 0))
{
dW = this.Extent.W;
dH = this.Extent.H;
var W, H;
if(AscFormat.isRealNumber(this.GraphicObj.rot)){
if(AscFormat.checkNormalRotate(this.GraphicObj.rot))
{
W = this.Extent.W;
H = this.Extent.H;
}
else
{
W = this.Extent.H;
H = this.Extent.W;
}
}
else
{
dH = this.Extent.W;
dW = this.Extent.H;
else{
W = this.Extent.W;
H = this.Extent.H;
}
this.Width = dW + AscFormat.getValOrDefault(oEffectExtent.L, 0) + AscFormat.getValOrDefault(oEffectExtent.R, 0);
this.Height = dH + AscFormat.getValOrDefault(oEffectExtent.T, 0) + AscFormat.getValOrDefault(oEffectExtent.B, 0);
this.Width = W + AscFormat.getValOrDefault(oEffectExtent.L, 0) + AscFormat.getValOrDefault(oEffectExtent.R, 0);
this.Height = H + AscFormat.getValOrDefault(oEffectExtent.T, 0) + AscFormat.getValOrDefault(oEffectExtent.B, 0);
this.WidthVisible = this.Width;
}
else
......
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