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

fixed problems with drawing measuring

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