mirror of https://github.com/apache/poi.git
fixed bug 42484: NullPointerException from ShapeGroup.getAnchor()
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@541281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a0e489bb4d
commit
f89c211539
|
@ -179,4 +179,22 @@ public class ShapeGroup extends Shape{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the anchor (the bounding box rectangle) of this shape group.
|
||||
* All coordinates are expressed in points (72 dpi).
|
||||
*
|
||||
* @return the anchor of this shape group
|
||||
*/
|
||||
public java.awt.Rectangle getAnchor(){
|
||||
EscherContainerRecord groupInfoContainer = (EscherContainerRecord)_escherContainer.getChild(0);
|
||||
EscherSpgrRecord spgr = (EscherSpgrRecord)getEscherChild(groupInfoContainer, EscherSpgrRecord.RECORD_ID);
|
||||
java.awt.Rectangle anchor=null;
|
||||
|
||||
anchor = new java.awt.Rectangle();
|
||||
anchor.x = spgr.getRectX1()*POINT_DPI/MASTER_DPI;
|
||||
anchor.y = spgr.getRectY1()*POINT_DPI/MASTER_DPI;
|
||||
anchor.width = (spgr.getRectX2() - spgr.getRectX1())*POINT_DPI/MASTER_DPI;
|
||||
anchor.height = (spgr.getRectY2() - spgr.getRectY1())*POINT_DPI/MASTER_DPI;
|
||||
return anchor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,4 +140,27 @@ public class TestBugs extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug 42484: NullPointerException from ShapeGroup.getAnchor()
|
||||
*/
|
||||
public void test42484 () throws Exception {
|
||||
FileInputStream is = new FileInputStream(new File(cwd, "42485.ppt")); //test file is the same as for bug 42485
|
||||
HSLFSlideShow hslf = new HSLFSlideShow(is);
|
||||
is.close();
|
||||
|
||||
SlideShow ppt = new SlideShow(hslf);
|
||||
Shape[] shape = ppt.getSlides()[0].getShapes();
|
||||
for (int i = 0; i < shape.length; i++) {
|
||||
if(shape[i] instanceof ShapeGroup){
|
||||
ShapeGroup group = (ShapeGroup)shape[i];
|
||||
assertNotNull(group.getAnchor());
|
||||
Shape[] sh = group.getShapes();
|
||||
for (int j = 0; j < sh.length; j++) {
|
||||
assertNotNull(sh[j].getAnchor());
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue("No Exceptions while reading file", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue