Skip to content

Commit a9f120f

Browse files
committed
Store Property.TRANSFORM as List<String[]> in case of multiple-function declaration
DEVSIX-1310 Autoported commit. Original commit hash: [6b38c9e39]
1 parent 3ef3056 commit a9f120f

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

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

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,8 +1509,7 @@ protected internal virtual Rectangle CalculateAbsolutePdfBBox() {
15091509
TransformPoints(contentBoxPoints, rotationTransform);
15101510
}
15111511
}
1512-
String[] transform = renderer.GetProperty<String[]>(Property.TRANSFORM);
1513-
if (transform != null) {
1512+
if (renderer.GetProperty<IList<String[]>>(Property.TRANSFORM) != null) {
15141513
if (renderer is BlockRenderer) {
15151514
BlockRenderer blockRenderer = (BlockRenderer)renderer;
15161515
AffineTransform rotationTransform = blockRenderer.CreateTransformationInsideOccupiedArea();
@@ -1864,25 +1863,30 @@ protected internal virtual void EndTranformationIfApplied(PdfCanvas canvas) {
18641863
}
18651864
}
18661865

1867-
private float[] GetCssTransformMatrix(float width, float height) {
1868-
String[] strings = this.GetProperty<String[]>(Property.TRANSFORM);
1869-
float[] floats = new float[6];
1870-
for (int i = 0; i < 6; i++) {
1871-
if (i == 4 || i == 5) {
1872-
int indexOfPercent = strings[i].IndexOf('%');
1873-
if (indexOfPercent > 0) {
1874-
floats[i] = float.Parse(strings[i].JSubstring(0, indexOfPercent), System.Globalization.CultureInfo.InvariantCulture
1875-
) / 100 * (i == 4 ? width : height);
1866+
private AffineTransform GetCssTransformMatrix(float width, float height) {
1867+
IList<String[]> multipleTransform = this.GetProperty<IList<String[]>>(Property.TRANSFORM);
1868+
AffineTransform affineTransform = new AffineTransform();
1869+
for (int k = multipleTransform.Count - 1; k >= 0; k--) {
1870+
String[] transform = multipleTransform[k];
1871+
float[] floats = new float[6];
1872+
for (int i = 0; i < 6; i++) {
1873+
if (i == 4 || i == 5) {
1874+
int indexOfPercent = transform[i].IndexOf('%');
1875+
if (indexOfPercent > 0) {
1876+
floats[i] = float.Parse(transform[i].JSubstring(0, indexOfPercent), System.Globalization.CultureInfo.InvariantCulture
1877+
) / 100 * (i == 4 ? width : height);
1878+
}
1879+
else {
1880+
floats[i] = float.Parse(transform[i], System.Globalization.CultureInfo.InvariantCulture);
1881+
}
18761882
}
18771883
else {
1878-
floats[i] = float.Parse(strings[i], System.Globalization.CultureInfo.InvariantCulture);
1884+
floats[i] = float.Parse(transform[i], System.Globalization.CultureInfo.InvariantCulture);
18791885
}
18801886
}
1881-
else {
1882-
floats[i] = float.Parse(strings[i], System.Globalization.CultureInfo.InvariantCulture);
1883-
}
1887+
affineTransform.PreConcatenate(new AffineTransform(floats));
18841888
}
1885-
return floats;
1889+
return affineTransform;
18861890
}
18871891

18881892
public abstract IRenderer GetNextRenderer();

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ee1d5a031e514f0988847742a9c1172a5631af3b
1+
6b38c9e397693f36de7868f21d24f0fa714b1245

0 commit comments

Comments
 (0)