poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Lundin <m...@consbio.org>
Subject Error adding pictures to group
Date Fri, 11 Nov 2011 23:21:21 GMT
I am trying to create a consolidated group of small pictures, and keep
getting errors when I have more than 6 pictures in a single group.

I created the following test case in TestXSLFGroupShape to reproduce my
problem:

public void testCreateMultiplePictures() {
        XMLSlideShow ppt = new XMLSlideShow();
        XSLFSlide slide = ppt.createSlide();

        byte[] data1 = new byte[]{1, 2, 3};
        XSLFGroupShape group1 = slide.createGroup();

        for (int i = 0; i < 6; i++) {
            int elementIndex = ppt.addPicture(data1,
XSLFPictureData.PICTURE_TYPE_JPEG);
            group1.createPicture(elementIndex);
        }
    }

If I run this test as is, on the last iteration of the loop, I get the
following error:

org.apache.poi.xslf.usermodel.XSLFSlideLayout cannot be cast to
org.apache.poi.xslf.usermodel.XSLFPictureData
java.lang.ClassCastException: org.apache.poi.xslf.usermodel.XSLFSlideLayout
cannot be cast to org.apache.poi.xslf.usermodel.XSLFPictureData
at
org.apache.poi.xslf.usermodel.XSLFPictureShape.getPictureData(XSLFPictureShape.java:101)
at
org.apache.poi.xslf.usermodel.XSLFPictureShape.getPictureData(XSLFPictureShape.java:101)
at
org.apache.poi.xslf.usermodel.XSLFPictureShape.resize(XSLFPictureShape.java:82)
at
org.apache.poi.xslf.usermodel.XSLFGroupShape.createPicture(XSLFGroupShape.java:215)
at
org.apache.poi.xslf.usermodel.TestXSLFGroupShape.testCreateMultiplePictures(TestXSLFGroupShape.java:110)

If I change the number of iterations to 5, the test passes without fail.
Also, if I instead add the picture to the slide, rather than the group, I
can leave the number of iterations at 6 and not get the error.

I'm digging into the code a bit to see if I can figure out why this is
happening, but was wondering if this was something others have experienced.
I will admit I'm new to POI, so it may be that there's a limit to groups
that I'm not aware of.

Thanks,
Mike

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message