Skip to content

Commit e9ed3a7

Browse files
committed
Update TODOs: add log and exception messages.
1 parent d856bfc commit e9ed3a7

25 files changed

+84
-94
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public void addField(PdfFormField field, PdfPage page){
224224
if (field.getFormType() != null && (field.getFormType().equals(PdfName.Tx) || field.getFormType().equals(PdfName.Ch))) {
225225
List<PdfDictionary> resources = getResources(field.getPdfObject());
226226
for (PdfDictionary resDict : resources) {
227-
mergeResources(defaultResources, resDict, field);
227+
mergeResources(defaultResources, resDict);
228228
}
229229
if (!defaultResources.isEmpty()) {
230230
put(PdfName.DR, defaultResources);
@@ -953,10 +953,8 @@ private List<PdfDictionary> getResources(PdfDictionary field) {
953953
*
954954
* @param result the {@link PdfDictionary} which may get extra entries from source
955955
* @param source the {@link PdfDictionary} whose entries may be merged into result
956-
* @param field
957956
*/
958-
// TODO: determine whether we need the parameter called field
959-
public void mergeResources(PdfDictionary result, PdfDictionary source, PdfFormField field) {
957+
private void mergeResources(PdfDictionary result, PdfDictionary source) {
960958
for (PdfName name : resourceNames) {
961959
PdfDictionary dic = source.getAsDictionary(name);
962960
PdfDictionary res = result.getAsDictionary(name);

io/src/main/java/com/itextpdf/io/LogMessageConstant.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public final class LogMessageConstant {
6969
*/
7070
public static final String ELEMENT_DOES_NOT_FIT_AREA = "Element does not fit current area. {0}";
7171

72+
/**
73+
* Log message.
74+
*/
75+
public static final String REMOVING_PAGE_HAS_ALREADY_BEEN_FLUSHED = "The removing page has already been flushed.";
76+
7277
/**
7378
* Log message.
7479
*/

io/src/main/java/com/itextpdf/io/codec/Base64.java

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,41 +1404,33 @@ else if (i == 0) {
14041404
} // end else if: also padded correctly
14051405
else {
14061406
// Must have broken out from above.
1407-
throw new java.io.IOException(/*MessageLocalization.getComposedMessage("improperly.padded.base64.input")*/); // TODO: correct the message
1407+
throw new java.io.IOException("improperly.padded.base64.input");
14081408
} // end
14091409

14101410
} // end else: decode
14111411
} // end else: get data
1412-
14131412
// Got data?
1414-
if (position >= 0) {
1415-
// End of relevant data?
1416-
if ( /*!encode &&*/ position >= numSigBytes)
1417-
return -1;
1418-
1419-
if (encode && breakLines && lineLength >= MAX_LINE_LENGTH) {
1420-
lineLength = 0;
1421-
return '\n';
1422-
} // end if
1423-
else {
1424-
lineLength++; // This isn't important when decoding
1425-
// but throwing an extra "if" seems
1426-
// just as wasteful.
1413+
assert position >= 0;
1414+
// End of relevant data?
1415+
if ( /*!encode &&*/ position >= numSigBytes)
1416+
return -1;
14271417

1428-
int b = buffer[position++];
1418+
if (encode && breakLines && lineLength >= MAX_LINE_LENGTH) {
1419+
lineLength = 0;
1420+
return '\n';
1421+
} // end if
1422+
else {
1423+
lineLength++; // This isn't important when decoding
1424+
// but throwing an extra "if" seems
1425+
// just as wasteful.
14291426

1430-
if (position >= bufferLength)
1431-
position = -1;
1427+
int b = buffer[position++];
14321428

1433-
return b & 0xFF; // This is how you "cast" a byte that's
1434-
// intended to be unsigned.
1435-
} // end else
1436-
} // end if: position >= 0
1429+
if (position >= bufferLength)
1430+
position = -1;
14371431

1438-
// Else error
1439-
else {
1440-
// When JDK1.4 is more accepted, use an assertion here.
1441-
throw new java.io.IOException(/*MessageLocalization.getComposedMessage("error.in.base64.code.reading.stream")*/); // TODO: correct the message
1432+
return b & 0xFF; // This is how you "cast" a byte that's
1433+
// intended to be unsigned.
14421434
} // end else
14431435
} // end read
14441436

@@ -1602,7 +1594,7 @@ public void write(int theByte) throws java.io.IOException {
16021594
} // end if: enough to output
16031595
} // end if: meaningful base64 character
16041596
else if (decodabet[theByte & 0x7f] != WHITE_SPACE_ENC) {
1605-
throw new java.io.IOException(/*MessageLocalization.getComposedMessage("invalid.character.in.base64.data")*/); // TODO: correct the message
1597+
throw new java.io.IOException("invalid.character.in.base64.data");
16061598
} // end else: not white space either
16071599
} // end else: decoding
16081600
} // end write
@@ -1642,7 +1634,7 @@ public void flushBase64() throws java.io.IOException {
16421634
position = 0;
16431635
} // end if: encoding
16441636
else {
1645-
throw new java.io.IOException(/*MessageLocalization.getComposedMessage("base64.input.not.properly.padded")*/); // TODO: correct the message
1637+
throw new java.io.IOException("base64.input.not.properly.padded");
16461638
} // end else: decoding
16471639
} // end if: buffer partially full
16481640

io/src/main/java/com/itextpdf/io/codec/Jbig2SegmentReader.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,7 @@ void readSegment(Jbig2Segment s) throws java.io.IOException {
253253
ra.seek(last);
254254
Jbig2Page p = pages.get(s.page);
255255
if (p == null) {
256-
throw new IllegalStateException("referring.to.widht.height.of.page.we.havent.seen.yet.1");
257-
//TODO, s.page);
256+
throw new com.itextpdf.io.IOException("referring.to.widht.height.of.page.we.havent.seen.yet.1").setMessageParams(s.page);
258257
}
259258

260259
p.pageBitmapWidth = page_bitmap_width;
@@ -307,8 +306,9 @@ Jbig2Segment readHeader() throws java.io.IOException {
307306
}
308307

309308
} else if (count_of_referred_to_segments == 5 || count_of_referred_to_segments == 6) {
310-
throw new IllegalStateException("count.of.referred.to.segments.had.bad.value.in.header.for.segment.1.starting.at.2");
311-
//TODO, segment_number, ptr));
309+
throw new com.itextpdf.io.IOException("count.of.referred.to.segments.had.bad.value.in.header.for.segment.1.starting.at.2")
310+
.setMessageParams(segment_number, ptr);
311+
312312
}
313313
s.segmentRetentionFlags = segment_retention_flags;
314314
s.countOfReferredToSegments = count_of_referred_to_segments;
@@ -335,8 +335,8 @@ Jbig2Segment readHeader() throws java.io.IOException {
335335
segment_page_association = ra.read();
336336
}
337337
if (segment_page_association < 0) {
338-
throw new IllegalStateException("page.1.invalid.for.segment.2.starting.at.3");
339-
//TODO, String.valueOf(segment_page_association), String.valueOf(segment_number), String.valueOf(ptr)));
338+
throw new com.itextpdf.io.IOException("page.1.invalid.for.segment.2.starting.at.3")
339+
.setMessageParams(segment_page_association, segment_number, ptr);
340340
}
341341
s.page = segment_page_association;
342342
// so we can change the page association at embedding time.
@@ -375,8 +375,7 @@ void readFileHeader() throws java.io.IOException {
375375

376376
for (int i = 0; i < idstring.length; i++) {
377377
if (idstring[i] != refidstring[i]) {
378-
throw new IllegalStateException("file.header.idstring.not.good.at.byte.1");
379-
//TODO, i);
378+
throw new com.itextpdf.io.IOException("file.header.idstring.not.good.at.byte.1").setMessageParams(i);
380379
}
381380
}
382381

@@ -386,7 +385,7 @@ void readFileHeader() throws java.io.IOException {
386385
this.number_of_pages_known = (fileheaderflags & 0x2) == 0x0;
387386

388387
if ((fileheaderflags & 0xfc) != 0x0) {
389-
throw new IllegalStateException("file.header.flags.bits.2.7.not.0");//TODO
388+
throw new com.itextpdf.io.IOException("file.header.flags.bits.2.7.not.0");
390389
}
391390

392391
if (this.number_of_pages_known) {

io/src/main/java/com/itextpdf/io/font/CFFFont.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,9 +961,6 @@ public String[] getNames() {
961961
protected int[] stringOffsets;
962962
protected int[] gsubrOffsets;
963963

964-
/**
965-
* TODO Changed from private to protected by Ygal&Oren
966-
*/
967964
protected final class Font {
968965
public String name;
969966
public String fullName;

io/src/main/java/com/itextpdf/io/font/FontCache.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,10 @@ public class FontCache {
8585
static {
8686
try {
8787
loadRegistry();
88-
8988
for (String font : registryNames.get(FONTS_PROP)) {
9089
allFonts.put(font, readFontProperties(font));
9190
}
9291
} catch (Exception ignored) {
93-
// TODO: add logger (?)
9492
}
9593
}
9694

@@ -161,15 +159,8 @@ public static FontProgram getFont(String fontName) {
161159
}
162160

163161
public static FontProgram saveFont(FontProgram font, String fontName) {
164-
// for most of the fonts we can retrieve encoding from FontProgram, but
165-
// for Cid there is no such possibility, since it is used in conjunction
166-
// with cmap to produce Type0 font, so I added fontName and encoding parameters
167-
// just for convenience.
168-
// TODO: probably it's better to declare saveFont(FontProgram) and saveFont(CidFont, encoding or cmap) in the future
169162
FontProgram fontFound = getFont(fontName);
170163
if (fontFound != null) {
171-
//TODO add close method
172-
//fontBuilt.close();
173164
return fontFound;
174165
}
175166
String key = getFontCacheKey(fontName);

io/src/main/java/com/itextpdf/io/font/FontIdentification.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ protected void setPanose(byte[] panose) {
9191
this.panose = new String(panose);
9292
}
9393

94-
//todo change to protected!
95-
public void setPanose(String panose) {
94+
protected void setPanose(String panose) {
9695
this.panose = panose;
9796
}
9897
}

io/src/main/java/com/itextpdf/io/font/FontMetrics.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,28 +238,23 @@ protected void setGlyphWidths(int[] glyphWidths) {
238238
this.glyphWidths = glyphWidths;
239239
}
240240

241-
//todo change to protected!
242-
public void setTypoAscender(int typoAscender) {
241+
protected void setTypoAscender(int typoAscender) {
243242
this.typoAscender = (int) (typoAscender * normalizationCoef);
244243
}
245244

246-
//todo change to protected!
247-
public void setTypoDescender(int typoDesctender) {
245+
protected void setTypoDescender(int typoDesctender) {
248246
this.typoDescender = (int) (typoDesctender * normalizationCoef);
249247
}
250248

251-
//todo change to protected!
252-
public void setCapHeight(int capHeight) {
249+
protected void setCapHeight(int capHeight) {
253250
this.capHeight = (int) (capHeight * normalizationCoef);
254251
}
255252

256-
//todo change to protected!
257-
public void setXHeight(int xHeight) {
253+
protected void setXHeight(int xHeight) {
258254
this.xHeight = (int) (xHeight * normalizationCoef);
259255
}
260256

261-
//todo change to protected!
262-
public void setItalicAngle(float italicAngle) {
257+
protected void setItalicAngle(float italicAngle) {
263258
this.italicAngle = italicAngle;
264259
}
265260

io/src/main/java/com/itextpdf/io/font/FontNames.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ protected void setFullName(String fullName) {
225225
this.fullName = new String[][]{new String[]{"", "", "", fullName}};
226226
}
227227

228-
// todo change to protected!
229-
public void setFontName(String psFontName) {
228+
protected void setFontName(String psFontName) {
230229
this.fontName = psFontName;
231230
}
232231

io/src/main/java/com/itextpdf/io/font/FontProgram.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,7 @@ public int getKerning(int first, int second) {
164164
*/
165165
public abstract int getKerning(Glyph first, Glyph second);
166166

167-
//TODO change to protected!
168-
public void setRegistry(String registry) {
167+
protected void setRegistry(String registry) {
169168
this.registry = registry;
170169
}
171170

@@ -277,6 +276,10 @@ protected void setFontFamily(String fontFamily) {
277276
fontNames.setFamilyName(fontFamily);
278277
}
279278

279+
protected void setFontName(String psFontName) {
280+
fontNames.setFontName(psFontName);
281+
}
282+
280283
protected void checkFilePath(String path) {
281284
if (path != null && !FontConstants.BUILTIN_FONTS_14.contains(path) && !FileUtil.fileExists(path)) {
282285
throw new IOException(IOException.FontFile1NotFound).setMessageParams(path);

0 commit comments

Comments
 (0)