Skip to content

Commit ba50f54

Browse files
committed
Merge branch 'develop' into layoutsharp2
Conflicts: layout/src/main/java/com/itextpdf/layout/ElementPropertyContainer.java layout/src/main/java/com/itextpdf/layout/Property.java layout/src/main/java/com/itextpdf/layout/RootElement.java layout/src/main/java/com/itextpdf/layout/element/BlockElement.java layout/src/main/java/com/itextpdf/layout/element/List.java layout/src/main/java/com/itextpdf/layout/element/Paragraph.java
2 parents 5027188 + d474d89 commit ba50f54

File tree

202 files changed

+2290
-1589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+2290
-1589
lines changed

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
258258

259259
int w = width + 2 * ws;
260260
int h = height + 2 * ws;
261-
int pix[] = new int[w * h];
261+
int[] pix = new int[w * h];
262262
int stride = (w + 7) / 8;
263263
int ptr = 0;
264264
for (int k = 0; k < h; ++k) {

barcodes/src/main/java/com/itextpdf/barcodes/BarcodePDF417.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public class BarcodePDF417 extends Barcode2D {
141141
private static final String MIXED_SET = "0123456789&\r\t,:#-.$/+%*=^";
142142
private static final String PUNCTUATION_SET = ";<>@[\\]_`~!\r\t,:\n-.$/\"|*()?{}'";
143143

144-
private static final int CLUSTERS[][] =
144+
private static final int[][] CLUSTERS =
145145
{{
146146
0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470,
147147
0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0,
@@ -498,7 +498,7 @@ public class BarcodePDF417 extends Barcode2D {
498498
0x1c7ea
499499
}};
500500

501-
private static final int ERROR_LEVEL[][] =
501+
private static final int[][] ERROR_LEVEL =
502502
{{
503503
27, 917
504504
}, {
@@ -875,7 +875,7 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
875875

876876
paintCode();
877877
int h = (int) yHeight;
878-
int pix[] = new int[bitColumns * codeRows * h];
878+
int[] pix = new int[bitColumns * codeRows * h];
879879
int stride = (bitColumns + 7) / 8;
880880
int ptr = 0;
881881
for (int k = 0; k < codeRows; ++k) {
@@ -1130,7 +1130,7 @@ protected void outPaintCode() {
11301130
for (int row = 0; row < codeRows; ++row) {
11311131
bitPtr = ((bitColumns - 1) / 8 + 1) * 8 * row;
11321132
int rowMod = row % 3;
1133-
int cluster[] = CLUSTERS[rowMod];
1133+
int[] cluster = CLUSTERS[rowMod];
11341134
outStartPattern();
11351135
int edge = 0;
11361136
switch (rowMod) {
@@ -1173,7 +1173,7 @@ protected void outPaintCode() {
11731173
protected void calculateErrorCorrection(int dest) {
11741174
if (errorLevel < 0 || errorLevel > 8)
11751175
errorLevel = 0;
1176-
int A[] = ERROR_LEVEL[errorLevel];
1176+
int[] A = ERROR_LEVEL[errorLevel];
11771177
int Alength = 2 << errorLevel;
11781178
for (int k = 0; k < Alength; ++k)
11791179
codewords[dest + k] = 0;
@@ -1288,7 +1288,7 @@ protected void dumpList() {
12881288
for (int k = 0; k < segmentList.size(); ++k) {
12891289
Segment v = segmentList.get(k);
12901290
int len = getSegmentLength(v);
1291-
char c[] = new char[len];
1291+
char[] c = new char[len];
12921292
for (int j = 0; j < len; ++j) {
12931293
c[j] = (char) (code[v.start + j] & 0xff);
12941294
if (c[j] == '\r')
@@ -1573,7 +1573,7 @@ private static int getTextTypeAndValue(byte[] input, int maxLength, int idx) {
15731573
}
15741574

15751575
private void textCompaction(byte[] input, int start, int length) {
1576-
int dest[] = new int[ABSOLUTE_MAX_TEXT_SIZE * 2];
1576+
int[] dest = new int[ABSOLUTE_MAX_TEXT_SIZE * 2];
15771577
int mode = ALPHA;
15781578
int ptr = 0;
15791579
int fullBytes = 0;

barcodes/src/main/java/com/itextpdf/barcodes/BarcodePostnet.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class BarcodePostnet extends Barcode1D {
6060
/**
6161
* The bars for each character.
6262
*/
63-
private static final byte BARS[][] =
63+
private static final byte[][] BARS =
6464
{
6565
{1, 1, 0, 0, 0},
6666
{0, 0, 0, 1, 1},
@@ -94,7 +94,7 @@ public static byte[] getBarsPostnet(String text) {
9494
total += n;
9595
}
9696
text += (char)(((10 - (total % 10)) % 10) + '0');
97-
byte bars[] = new byte[text.length() * 5 + 2];
97+
byte[] bars = new byte[text.length() * 5 + 2];
9898
bars[0] = 1;
9999
bars[bars.length - 1] = 1;
100100
for (int k = 0; k < text.length(); ++k) {
@@ -112,7 +112,7 @@ public Rectangle getBarcodeSize() {
112112

113113
@Override
114114
public void fitWidth(float width) {
115-
byte bars[] = getBarsPostnet(code);
115+
byte[] bars = getBarsPostnet(code);
116116
float currentWidth = getBarcodeSize().getWidth();
117117
x *= width / currentWidth;
118118
n = (width - x) / (bars.length - 1);
@@ -122,7 +122,7 @@ public void fitWidth(float width) {
122122
public Rectangle placeBarcode(PdfCanvas canvas, Color barColor, Color textColor) {
123123
if (barColor != null)
124124
canvas.setFillColor(barColor);
125-
byte bars[] = getBarsPostnet(code);
125+
byte[] bars = getBarsPostnet(code);
126126
byte flip = 1;
127127
if (codeType == TYPE_PLANET) {
128128
flip = 0;
@@ -156,8 +156,8 @@ public Image createAwtImage(java.awt.Color foreground, java.awt.Color background
156156
if (barTall <= barShort)
157157
barTall = barShort + 1;
158158
int width = ((code.length() + 1) * 5 + 1) * barDistance + barWidth;
159-
int pix[] = new int[width * barTall];
160-
byte bars[] = getBarsPostnet(code);
159+
int[] pix = new int[width * barTall];
160+
byte[] bars = getBarsPostnet(code);
161161
byte flip = 1;
162162
if (codeType == TYPE_PLANET) {
163163
flip = 0;

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeQRCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public java.awt.Image createAwtImage(java.awt.Color foreground, java.awt.Color b
233233

234234
int width = bm.getWidth();
235235
int height = bm.getHeight();
236-
int pix[] = new int[width * height];
236+
int[] pix = new int[width * height];
237237
byte[][] mt = bm.getArray();
238238
for (int y = 0; y < height; ++y) {
239239
byte[] line = mt[y];

barcodes/src/main/java/com/itextpdf/barcodes/dmcode/ReedSolomon.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ This file is part of the iText (R) project.
4444
*/
4545
package com.itextpdf.barcodes.dmcode;
4646

47-
public final class ReedSolomon {
47+
public final class ReedSolomon {
4848

49-
private static final int log[] = {
49+
private static final int[] log = {
5050
0, 255, 1, 240, 2, 225, 241, 53, 3, 38, 226, 133, 242, 43, 54, 210,
5151
4, 195, 39, 114, 227, 106, 134, 28, 243, 140, 44, 23, 55, 118, 211, 234,
5252
5, 219, 196, 96, 40, 222, 115, 103, 228, 78, 107, 125, 135, 8, 29, 162,
@@ -65,7 +65,7 @@ public final class ReedSolomon {
6565
214, 250, 168, 71, 201, 156, 64, 60, 237, 130, 111, 20, 93, 122, 177, 150
6666
};
6767

68-
private static final int alog[] = {
68+
private static final int[] alog = {
6969
1, 2, 4, 8, 16, 32, 64, 128, 45, 90, 180, 69, 138, 57, 114, 228,
7070
229, 231, 227, 235, 251, 219, 155, 27, 54, 108, 216, 157, 23, 46, 92, 184,
7171
93, 186, 89, 178, 73, 146, 9, 18, 36, 72, 144, 13, 26, 52, 104, 208,
@@ -84,83 +84,83 @@ public final class ReedSolomon {
8484
3, 6, 12, 24, 48, 96, 192, 173, 119, 238, 241, 207, 179, 75, 150, 1
8585
};
8686

87-
private static final int poly5[] = {
87+
private static final int[] poly5 = {
8888
228, 48, 15, 111, 62
8989
};
9090

91-
private static final int poly7[] = {
91+
private static final int[] poly7 = {
9292
23, 68, 144, 134, 240, 92, 254
9393
};
9494

95-
private static final int poly10[] = {
95+
private static final int[] poly10 = {
9696
28, 24, 185, 166, 223, 248, 116, 255, 110, 61
9797
};
9898

99-
private static final int poly11[] = {
99+
private static final int[] poly11 = {
100100
175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120
101101
};
102102

103-
private static final int poly12[] = {
103+
private static final int[] poly12 = {
104104
41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242
105105
};
106106

107-
private static final int poly14[] = {
107+
private static final int[] poly14 = {
108108
156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185
109109
};
110110

111-
private static final int poly18[] = {
111+
private static final int[] poly18 = {
112112
83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48,
113113
90, 188
114114
};
115115

116-
private static final int poly20[] = {
116+
private static final int[] poly20 = {
117117
15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82,
118118
27, 174, 186, 172
119119
};
120120

121-
private static final int poly24[] = {
121+
private static final int[] poly24 = {
122122
52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172,
123123
254, 124, 12, 181, 184, 96, 50, 193
124124
};
125125

126-
private static final int poly28[] = {
126+
private static final int[] poly28 = {
127127
211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121,
128128
17, 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255
129129
};
130130

131-
private static final int poly36[] = {
131+
private static final int[] poly36 = {
132132
245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80, 182,
133133
229, 18, 2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25,
134134
225, 98, 81, 112
135135
};
136136

137-
private static final int poly42[] = {
137+
private static final int[] poly42 = {
138138
77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8,
139139
175, 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101,
140140
248, 202, 69, 50, 150, 177, 226, 5, 9, 5
141141
};
142142

143-
private static final int poly48[] = {
143+
private static final int[] poly48 = {
144144
245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87,
145145
191, 106, 16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138,
146146
186, 240, 82, 44, 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19
147147
};
148148

149-
private static final int poly56[] = {
149+
private static final int[] poly56 = {
150150
175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235,
151151
150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232,
152152
144, 238, 22, 150, 201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28,
153153
155, 43, 203, 107, 233, 53, 143, 46
154154
};
155155

156-
private static final int poly62[] = {
156+
private static final int[] poly62 = {
157157
242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37,
158158
185, 112, 134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114, 71,
159159
161, 44, 147, 6, 27, 218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31,
160160
176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47, 11, 204
161161
};
162162

163-
private static final int poly68[] = {
163+
private static final int[] poly68 = {
164164
220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127,
165165
213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227, 236,
166166
66, 139, 153, 185, 202, 167, 179, 25, 220, 232, 96, 210, 231, 136, 223, 239,

forms/src/main/java/com/itextpdf/forms/PdfAcroForm.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public class PdfAcroForm extends PdfObjectWrapper<PdfDictionary> {
124124
*/
125125
protected PdfDocument document;
126126

127-
private static PdfName resourceNames[] = {PdfName.Font, PdfName.XObject, PdfName.ColorSpace, PdfName.Pattern};
127+
private static PdfName[] resourceNames = {PdfName.Font, PdfName.XObject, PdfName.ColorSpace, PdfName.Pattern};
128128
private PdfDictionary defaultResources;
129129
private Set<PdfFormField> fieldsForFlattening = new LinkedHashSet<>();
130130
private XfaForm xfaForm;
@@ -136,8 +136,9 @@ public class PdfAcroForm extends PdfObjectWrapper<PdfDictionary> {
136136
*
137137
* @param pdfObject the PdfDictionary to be wrapped
138138
*/
139-
public PdfAcroForm(PdfDictionary pdfObject) {
139+
private PdfAcroForm(PdfDictionary pdfObject, PdfDocument pdfDocument) {
140140
super(pdfObject);
141+
document = pdfDocument;
141142
getFormFields();
142143
xfaForm = new XfaForm(pdfObject);
143144
}
@@ -148,8 +149,8 @@ public PdfAcroForm(PdfDictionary pdfObject) {
148149
*
149150
* @param fields a {@link PdfArray} of {@link PdfDictionary} objects
150151
*/
151-
public PdfAcroForm(PdfArray fields) {
152-
this(createAcroFormDictionaryByFields(fields));
152+
private PdfAcroForm(PdfArray fields) {
153+
this(createAcroFormDictionaryByFields(fields), null);
153154
setForbidRelease();
154155
}
155156

@@ -174,7 +175,7 @@ public static PdfAcroForm getAcroForm(PdfDocument document, boolean createIfNotE
174175
acroForm.setDefaultAppearance("/Helv 0 Tf 0 g ");
175176
}
176177
} else {
177-
acroForm = new PdfAcroForm(acroFormDictionary);
178+
acroForm = new PdfAcroForm(acroFormDictionary, document);
178179
}
179180

180181
if (acroForm != null) {
@@ -265,8 +266,9 @@ public void addFieldAppearanceToPage(PdfFormField field, PdfPage page) {
265266
* @return a map of field names and their associated {@link PdfFormField form field} objects
266267
*/
267268
public Map<String, PdfFormField> getFormFields() {
268-
if (fields.isEmpty()) {
269+
if (fields.size() == 0) {
269270
fields = iterateFields(getFields());
271+
270272
}
271273
return fields;
272274
}
@@ -579,7 +581,7 @@ public void flattenFields() {
579581
throw new PdfException(PdfException.FieldFlatteningIsNotSupportedInAppendMode);
580582
}
581583
Set<PdfFormField> fields;
582-
if (fieldsForFlattening.isEmpty()) {
584+
if (fieldsForFlattening.size() == 0) {
583585
this.fields.clear();
584586
fields = new LinkedHashSet<>(getFormFields().values());
585587
} else {
@@ -688,7 +690,7 @@ public void flattenFields() {
688690
}
689691

690692
getPdfObject().remove(PdfName.NeedAppearances);
691-
if (fieldsForFlattening.isEmpty()) {
693+
if (fieldsForFlattening.size() == 0) {
692694
getFields().clear();
693695
}
694696
if (getFields().isEmpty()) {
@@ -854,7 +856,8 @@ private PdfDictionary processKids(PdfArray kids, PdfDictionary parent, PdfPage p
854856
}
855857
}
856858
} else {
857-
for (PdfObject kid : kids){
859+
for(int i = 0; i < kids.size(); i++) {
860+
PdfObject kid = kids.get(i);
858861
if (kid.isIndirectReference()) {
859862
kid = ((PdfIndirectReference)kid).getRefersTo();
860863
}

forms/src/main/java/com/itextpdf/forms/PdfPageFormCopier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public void copy(PdfPage fromPage, PdfPage toPage) {
9191
List<PdfDictionary> usedParents = new ArrayList<>();
9292
if (formFrom != null) {
9393
Map<String, PdfFormField> fieldsFrom = formFrom.getFormFields();
94-
if (!fieldsFrom.isEmpty()) {
94+
if (fieldsFrom.size() > 0) {
9595
Map<String, PdfFormField> fieldsTo = formTo.getFormFields();
9696
List<PdfAnnotation> annots = toPage.getAnnotations();
9797
for (PdfAnnotation annot : annots) {

0 commit comments

Comments
 (0)