mirror of https://github.com/apache/poi.git
Improve some assertions and error messages for exceptions seen in the regression tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1873385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
522ee9c554
commit
d3767e1de7
|
@ -50,7 +50,7 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
|||
|
||||
// write out the file
|
||||
ByteArrayOutputStream out = writeToArray(ss);
|
||||
|
||||
|
||||
readContent(ss);
|
||||
|
||||
// read in the written file
|
||||
|
@ -67,11 +67,11 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
|||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void readContent(SlideShow<?,?> ss) {
|
||||
for (Slide<?,?> s : ss.getSlides()) {
|
||||
s.getTitle();
|
||||
|
@ -96,8 +96,8 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
|||
private void readShapes(Shape<?,?> s) {
|
||||
// recursively walk group-shapes
|
||||
if(s instanceof GroupShape) {
|
||||
GroupShape<? extends Shape, ?> shapes = (GroupShape<? extends Shape, ?>) s;
|
||||
for (Shape<? extends Shape, ?> shape : shapes) {
|
||||
GroupShape<? extends Shape<?,?>, ?> shapes = (GroupShape<? extends Shape<?,?>, ?>) s;
|
||||
for (Shape<? extends Shape<?,?>, ?> shape : shapes) {
|
||||
readShapes(shape);
|
||||
}
|
||||
}
|
||||
|
@ -123,20 +123,22 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void readPictures(SlideShow<?,?> ss) {
|
||||
for (PictureData pd : ss.getPictureData()) {
|
||||
Dimension dim = pd.getImageDimension();
|
||||
assertTrue(dim.getHeight() >= 0);
|
||||
assertTrue(dim.getWidth() >= 0);
|
||||
assertTrue("Expecting a valid height, but had an image with height: " + dim.getHeight(),
|
||||
dim.getHeight() >= 0);
|
||||
assertTrue("Expecting a valid width, but had an image with width: " + dim.getWidth(),
|
||||
dim.getWidth() >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void renderSlides(SlideShow<?,?> ss) {
|
||||
Dimension pgsize = ss.getPageSize();
|
||||
Dimension pgSize = ss.getPageSize();
|
||||
|
||||
for (Slide<?,?> s : ss.getSlides()) {
|
||||
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_ARGB);
|
||||
BufferedImage img = new BufferedImage(pgSize.width, pgSize.height, BufferedImage.TYPE_INT_ARGB);
|
||||
Graphics2D graphics = img.createGraphics();
|
||||
|
||||
// default rendering options
|
||||
|
@ -145,10 +147,10 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
|||
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
||||
graphics.setRenderingHint(Drawable.BUFFERED_IMAGE, new WeakReference<>(img));
|
||||
|
||||
|
||||
// draw stuff
|
||||
s.draw(graphics);
|
||||
|
||||
|
||||
graphics.dispose();
|
||||
img.flush();
|
||||
}
|
||||
|
|
|
@ -89,13 +89,10 @@ public final class HeaderFooterRecord extends StandardRecord {
|
|||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append('[').append("HEADERFOOTER").append("] (0x");
|
||||
sb.append(Integer.toHexString(sid).toUpperCase(Locale.ROOT)).append(")\n");
|
||||
sb.append(" rawData=").append(HexDump.toHex(_rawData)).append("\n");
|
||||
sb.append("[/").append("HEADERFOOTER").append("]\n");
|
||||
return sb.toString();
|
||||
return '[' + "HEADERFOOTER" + "] (0x" +
|
||||
Integer.toHexString(sid).toUpperCase(Locale.ROOT) + ")\n" +
|
||||
" rawData=" + HexDump.toHex(_rawData) + "\n" +
|
||||
"[/" + "HEADERFOOTER" + "]\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -60,7 +60,7 @@ public abstract class HPBFPart {
|
|||
dir = (DirectoryNode)dir.getEntry(path[i]);
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new IllegalArgumentException("File invalid - failed to find directory entry '"
|
||||
+ path[i] + "'");
|
||||
+ path[i] + "': " + e);
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
|
@ -101,7 +101,7 @@ public abstract class HPBFPart {
|
|||
public final byte[] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
protected final void setData(byte[] data) {
|
||||
this.data = data.clone();
|
||||
}
|
||||
|
|
|
@ -64,7 +64,8 @@ public class ComplexFileTable {
|
|||
this._grpprls = sprmBuffers.toArray(new SprmBuffer[0]);
|
||||
|
||||
if (tableStream[offset] != TEXT_PIECE_TABLE_TYPE) {
|
||||
throw new IOException("The text piece table is corrupted");
|
||||
throw new IOException("The text piece table is corrupted, expected byte value " + TEXT_PIECE_TABLE_TYPE +
|
||||
" but had " + tableStream[offset]);
|
||||
}
|
||||
int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
|
||||
offset += LittleEndian.INT_SIZE;
|
||||
|
|
Loading…
Reference in New Issue