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
|
@ -96,8 +96,8 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
||||||
private void readShapes(Shape<?,?> s) {
|
private void readShapes(Shape<?,?> s) {
|
||||||
// recursively walk group-shapes
|
// recursively walk group-shapes
|
||||||
if(s instanceof GroupShape) {
|
if(s instanceof GroupShape) {
|
||||||
GroupShape<? extends Shape, ?> shapes = (GroupShape<? extends Shape, ?>) s;
|
GroupShape<? extends Shape<?,?>, ?> shapes = (GroupShape<? extends Shape<?,?>, ?>) s;
|
||||||
for (Shape<? extends Shape, ?> shape : shapes) {
|
for (Shape<? extends Shape<?,?>, ?> shape : shapes) {
|
||||||
readShapes(shape);
|
readShapes(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,16 +127,18 @@ public abstract class SlideShowHandler extends POIFSFileHandler {
|
||||||
private void readPictures(SlideShow<?,?> ss) {
|
private void readPictures(SlideShow<?,?> ss) {
|
||||||
for (PictureData pd : ss.getPictureData()) {
|
for (PictureData pd : ss.getPictureData()) {
|
||||||
Dimension dim = pd.getImageDimension();
|
Dimension dim = pd.getImageDimension();
|
||||||
assertTrue(dim.getHeight() >= 0);
|
assertTrue("Expecting a valid height, but had an image with height: " + dim.getHeight(),
|
||||||
assertTrue(dim.getWidth() >= 0);
|
dim.getHeight() >= 0);
|
||||||
|
assertTrue("Expecting a valid width, but had an image with width: " + dim.getWidth(),
|
||||||
|
dim.getWidth() >= 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderSlides(SlideShow<?,?> ss) {
|
private void renderSlides(SlideShow<?,?> ss) {
|
||||||
Dimension pgsize = ss.getPageSize();
|
Dimension pgSize = ss.getPageSize();
|
||||||
|
|
||||||
for (Slide<?,?> s : ss.getSlides()) {
|
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();
|
Graphics2D graphics = img.createGraphics();
|
||||||
|
|
||||||
// default rendering options
|
// default rendering options
|
||||||
|
|
|
@ -89,13 +89,10 @@ public final class HeaderFooterRecord extends StandardRecord {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
return '[' + "HEADERFOOTER" + "] (0x" +
|
||||||
|
Integer.toHexString(sid).toUpperCase(Locale.ROOT) + ")\n" +
|
||||||
sb.append('[').append("HEADERFOOTER").append("] (0x");
|
" rawData=" + HexDump.toHex(_rawData) + "\n" +
|
||||||
sb.append(Integer.toHexString(sid).toUpperCase(Locale.ROOT)).append(")\n");
|
"[/" + "HEADERFOOTER" + "]\n";
|
||||||
sb.append(" rawData=").append(HexDump.toHex(_rawData)).append("\n");
|
|
||||||
sb.append("[/").append("HEADERFOOTER").append("]\n");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -60,7 +60,7 @@ public abstract class HPBFPart {
|
||||||
dir = (DirectoryNode)dir.getEntry(path[i]);
|
dir = (DirectoryNode)dir.getEntry(path[i]);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
throw new IllegalArgumentException("File invalid - failed to find directory entry '"
|
throw new IllegalArgumentException("File invalid - failed to find directory entry '"
|
||||||
+ path[i] + "'");
|
+ path[i] + "': " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
|
|
|
@ -64,7 +64,8 @@ public class ComplexFileTable {
|
||||||
this._grpprls = sprmBuffers.toArray(new SprmBuffer[0]);
|
this._grpprls = sprmBuffers.toArray(new SprmBuffer[0]);
|
||||||
|
|
||||||
if (tableStream[offset] != TEXT_PIECE_TABLE_TYPE) {
|
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);
|
int pieceTableSize = LittleEndian.getInt(tableStream, ++offset);
|
||||||
offset += LittleEndian.INT_SIZE;
|
offset += LittleEndian.INT_SIZE;
|
||||||
|
|
Loading…
Reference in New Issue