https://issues.apache.org/bugzilla/show_bug.cgi?id=54433

            Bug ID: 54433
           Summary: NullPointerException when Initializing the
                    AffineTransform Object as part of the
                    XSLFGroupShape.draw(Graphics2D graphics) method
           Product: POI
           Version: 3.8
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLF
          Assignee: [email protected]
          Reporter: [email protected]
    Classification: Unclassified

Attempting to transform all XSLFShapes to PNGs using PPTX2PNG as an example I
used this modified code:

        XMLSlideShow ppt = new XMLSlideShow(OPCPackage.open(file));

        Dimension pgsize = ppt.getPageSize();
        int width = (int) (pgsize.width * scale);
        int height = (int) (pgsize.height * scale);

        XSLFSlide[] slide = ppt.getSlides();
        for (int i = 0; i < slide.length; i++) {
            if (slidenum != -1 && slidenum != (i + 1)) continue;

            String title = slide[i].getTitle();
            System.out.println("Rendering slide " + (i + 1) + (title == null ?
"" : ": " + title));

            XSLFShape[] pdps = slide[i].getShapes();
            int count = 0;
             for(XSLFShape pdp : pdps){
                BufferedImage img = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
                Graphics2D graphics = img.createGraphics();

                // default rendering options
                graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
                graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
                graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);

                graphics.setColor(Color.BLUE);
                graphics.clearRect(0, 0, width, height);

                graphics.scale(scale, scale);

               graphics.getTransform().setToIdentity();
                // draw stuff

               // save the result
                int sep = file.lastIndexOf(".");
                String fname = file.substring(0, sep == -1 ? file.length() :
sep) + "-" + (i + 1) +"_"+ count++ + ".png";
                pdp.draw(graphics);
                FileOutputStream out = new FileOutputStream(fname);

                ImageIO.write(img, "png", out);
                out.close();
            }

When pdp instanceof XSLFGroupShape is true, I receive:
Exception in thread "main" java.lang.NullPointerException
    at java.awt.geom.AffineTransform.<init>(Unknown Source)
    at
org.apache.poi.xslf.usermodel.XSLFGroupShape.draw(XSLFGroupShape.java:296)
...

As far as I can tell this is a bug. I cannot find the Null Object that is being
used.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to