Try to avoid one NPE that popped up in commoncrawl-corpus tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1828375 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
af19295590
commit
eb4e20cd69
@ -66,7 +66,7 @@ public class XSLFFileHandler extends SlideShowHandler {
|
|||||||
@Override
|
@Override
|
||||||
@Test
|
@Test
|
||||||
public void test() throws Exception {
|
public void test() throws Exception {
|
||||||
File file = new File("test-data/slideshow/ae.ac.uaeu.faculty_nafaachbili_GeomLec1.pptx");
|
File file = new File("test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx");
|
||||||
try (InputStream stream = new FileInputStream(file)) {
|
try (InputStream stream = new FileInputStream(file)) {
|
||||||
handleFile(stream, file.getPath());
|
handleFile(stream, file.getPath());
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,15 @@ public class DrawShape implements Drawable {
|
|||||||
if (tx == null) {
|
if (tx == null) {
|
||||||
tx = new AffineTransform();
|
tx = new AffineTransform();
|
||||||
}
|
}
|
||||||
final Rectangle2D anchor = tx.createTransformedShape(ps.getAnchor()).getBounds2D();
|
|
||||||
|
// we saw one document failing here, probably the format is slightly broken, but
|
||||||
|
// maybe better to try to handle it more gracefully
|
||||||
|
java.awt.Shape transformedShape = tx.createTransformedShape(ps.getAnchor());
|
||||||
|
if(transformedShape == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Rectangle2D anchor = transformedShape.getBounds2D();
|
||||||
|
|
||||||
char cmds[] = isHSLF ? new char[]{ 'h','v','r' } : new char[]{ 'r','h','v' };
|
char cmds[] = isHSLF ? new char[]{ 'h','v','r' } : new char[]{ 'r','h','v' };
|
||||||
for (char ch : cmds) {
|
for (char ch : cmds) {
|
||||||
@ -184,7 +192,7 @@ public class DrawShape implements Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
|
AffineTransform tx = (AffineTransform)graphics.getRenderingHint(Drawable.GROUP_TRANSFORM);
|
||||||
if(tx != null && !tx.isIdentity()) {
|
if(tx != null && !tx.isIdentity() && tx.createTransformedShape(anchor) != null) {
|
||||||
anchor = tx.createTransformedShape(anchor).getBounds2D();
|
anchor = tx.createTransformedShape(anchor).getBounds2D();
|
||||||
}
|
}
|
||||||
return anchor;
|
return anchor;
|
||||||
|
@ -405,6 +405,9 @@ public class DrawSimpleShape extends DrawShape {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle2D anchor = getAnchor(graphics, sh);
|
Rectangle2D anchor = getAnchor(graphics, sh);
|
||||||
|
if(anchor == null) {
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
for (Path p : geom) {
|
for (Path p : geom) {
|
||||||
|
|
||||||
double w = p.getW(), h = p.getH(), scaleX = Units.toPoints(1), scaleY = scaleX;
|
double w = p.getW(), h = p.getH(), scaleX = Units.toPoints(1), scaleY = scaleX;
|
||||||
|
@ -45,6 +45,10 @@ public class DrawTextShape extends DrawSimpleShape {
|
|||||||
TextShape<?,?> s = getShape();
|
TextShape<?,?> s = getShape();
|
||||||
|
|
||||||
Rectangle2D anchor = DrawShape.getAnchor(graphics, s);
|
Rectangle2D anchor = DrawShape.getAnchor(graphics, s);
|
||||||
|
if(anchor == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Insets2D insets = s.getInsets();
|
Insets2D insets = s.getInsets();
|
||||||
double x = anchor.getX() + insets.left;
|
double x = anchor.getX() + insets.left;
|
||||||
double y = anchor.getY();
|
double y = anchor.getY();
|
||||||
|
BIN
test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx
Executable file
BIN
test-data/slideshow/ca.ubc.cs.people_~emhill_presentations_HowWeRefactor.pptx
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user