Apache POI XSLF Getting Shapes On Either Side of a Connector

Viewed 23

I am using Java and Apache POI to parse a powerpoint slide where there will be a shape, a connector, and another shape. I can extract the connector, but what I am wondering is whether, if I know that I have a connector, whether I can be certain which shape is above and which shape is below that connector. For example, here is the relevant code:

           XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(file));
            List<XSLFSlide> slide = ppt.getSlides();
            System.out.println("These are the shapes in the presentation: ");
            for (int i = 0; i < slide.size(); i++) {
                List<XSLFShape> listOfShapes = slide.get(i).getShapes();
                for (int j = 0; j < listOfShapes.size(); j++) {
                    XSLFShape thisShape = listOfShapes.get(j);
                    String thisShapeName = thisShape.getShapeName();
                    int thisShapeID = thisShape.getShapeId();
                    XSLFShapeContainer thisShapeParent = thisShape.getParent();
                    Rectangle2D thisAnchor = thisShape.getAnchor();
                    String textBody = thisShape.;
                    System.out.println("Name: " + thisShapeName + " ID: " + thisShapeID + " Anchor: " + thisAnchor.toString());
                }
            }

So, as this iterates through, 'thisShape' will, sometimes, be a connector. I would like to stop, when I know I have a connector, and get the shape on either side of the connector. I can see when this prints out that it appears to print out:

rectangle 3

connector

rectangle 4

connector

And so, I can "infer" that the first connector is connecting rectangle 3 and 4 but I was hoping/assuming that the connector object itself contained information about what it was connected to. Does it? If so, do you know how to access it? I am looking at the documentation for the XSLFShape class and I don't see anything that appears on point.

0 Answers
Related