Skip to content

Commit ef8c9b5

Browse files
committed
Minor changes in AbstractRenderer & ImageRenderer
Rename method building AffineTransform from css property; make createTransformationInsideOccupiedArea private; apply generic transformation when calculating AbsolutePdfBBox. DEVSIX-1310 Autoported commit. Original commit hash: [e5f8c0b9d]
1 parent be91d7f commit ef8c9b5

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

itext/itext.layout/itext/layout/renderer/AbstractRenderer.cs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,25 +1511,10 @@ protected internal virtual Rectangle CalculateAbsolutePdfBBox() {
15111511
}
15121512
}
15131513
if (renderer.GetProperty<IList<String[]>>(Property.TRANSFORM) != null) {
1514-
if (renderer is BlockRenderer) {
1515-
BlockRenderer blockRenderer = (BlockRenderer)renderer;
1516-
AffineTransform rotationTransform = blockRenderer.CreateTransformationInsideOccupiedArea();
1514+
if (renderer is BlockRenderer || renderer is ImageRenderer || renderer is TableRenderer) {
1515+
AffineTransform rotationTransform = renderer.CreateTransformationInsideOccupiedArea();
15171516
TransformPoints(contentBoxPoints, rotationTransform);
15181517
}
1519-
else {
1520-
if (renderer is ImageRenderer) {
1521-
ImageRenderer imageRenderer = (ImageRenderer)renderer;
1522-
AffineTransform rotationTransform = imageRenderer.CreateTransformationInsideOccupiedArea();
1523-
TransformPoints(contentBoxPoints, rotationTransform);
1524-
}
1525-
else {
1526-
if (renderer is TableRenderer) {
1527-
TableRenderer tableRenderer = (TableRenderer)renderer;
1528-
AffineTransform rotationTransform = tableRenderer.CreateTransformationInsideOccupiedArea();
1529-
TransformPoints(contentBoxPoints, rotationTransform);
1530-
}
1531-
}
1532-
}
15331518
}
15341519
renderer = (iText.Layout.Renderer.AbstractRenderer)renderer.parent;
15351520
}
@@ -1838,15 +1823,15 @@ private static float CalculatePaddingBorderHeight(iText.Layout.Renderer.Abstract
18381823
/// <see cref="iText.Kernel.Geom.AffineTransform"/>
18391824
/// that transforms the content and places it inside occupied area.
18401825
/// </returns>
1841-
protected internal virtual AffineTransform CreateTransformationInsideOccupiedArea() {
1826+
private AffineTransform CreateTransformationInsideOccupiedArea() {
18421827
Rectangle backgroundArea = ApplyMargins(occupiedArea.Clone().GetBBox(), false);
18431828
float x = backgroundArea.GetX();
18441829
float y = backgroundArea.GetY();
18451830
float height = backgroundArea.GetHeight();
18461831
float width = backgroundArea.GetWidth();
18471832
AffineTransform transform = AffineTransform.GetTranslateInstance(-1 * (x + width / 2), -1 * (y + height /
18481833
2));
1849-
transform.PreConcatenate(new AffineTransform(this.GetCssTransformMatrix(width, height)));
1834+
transform.PreConcatenate(new AffineTransform(this.GetTransformMatrix(width, height)));
18501835
transform.PreConcatenate(AffineTransform.GetTranslateInstance(x + width / 2, y + height / 2));
18511836
return transform;
18521837
}
@@ -1864,7 +1849,7 @@ protected internal virtual void EndTranformationIfApplied(PdfCanvas canvas) {
18641849
}
18651850
}
18661851

1867-
private AffineTransform GetCssTransformMatrix(float width, float height) {
1852+
private AffineTransform GetTransformMatrix(float width, float height) {
18681853
IList<String[]> multipleTransform = this.GetProperty<IList<String[]>>(Property.TRANSFORM);
18691854
AffineTransform affineTransform = new AffineTransform();
18701855
for (int k = multipleTransform.Count - 1; k >= 0; k--) {

itext/itext.layout/itext/layout/renderer/ImageRenderer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,14 @@ public override void Draw(DrawContext drawContext) {
304304
}
305305
}
306306
}
307+
BeginTranformationIfApplied(drawContext.GetCanvas());
307308
float? angle = this.GetPropertyAsFloat(Property.ROTATION_ANGLE);
308309
if (angle != null) {
309310
fixedXPosition += rotatedDeltaX;
310311
fixedYPosition -= rotatedDeltaY;
311312
drawContext.GetCanvas().SaveState();
312313
ApplyConcatMatrix(drawContext, angle);
313314
}
314-
BeginTranformationIfApplied(drawContext.GetCanvas());
315315
base.Draw(drawContext);
316316
if (angle != null) {
317317
drawContext.GetCanvas().RestoreState();
@@ -329,8 +329,8 @@ public override void Draw(DrawContext drawContext) {
329329
BeginElementOpacityApplying(drawContext);
330330
canvas.AddXObject(xObject, matrix[0], matrix[1], matrix[2], matrix[3], (float)fixedXPosition + deltaX, (float
331331
)fixedYPosition);
332-
EndTranformationIfApplied(drawContext.GetCanvas());
333332
EndElementOpacityApplying(drawContext);
333+
EndTranformationIfApplied(drawContext.GetCanvas());
334334
if (true.Equals(GetPropertyAsBoolean(Property.FLUSH_ON_DRAW))) {
335335
xObject.Flush();
336336
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
b5a1ddfe81616c403015e74c54ada0ab9708f6bb
1+
e5f8c0b9d66274cc8153a84a66ba4f9451bf7c9e

0 commit comments

Comments
 (0)