Search in sources :

Example 11 with CTTable

use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable in project poi by apache.

the class XSLFCommonSlideData method getDrawingText.

public List<DrawingTextBody> getDrawingText() {
    CTGroupShape gs = data.getSpTree();
    List<DrawingTextBody> out = new ArrayList<DrawingTextBody>();
    processShape(gs, out);
    for (CTGroupShape shape : gs.getGrpSpArray()) {
        processShape(shape, out);
    }
    for (CTGraphicalObjectFrame frame : gs.getGraphicFrameArray()) {
        CTGraphicalObjectData data = frame.getGraphic().getGraphicData();
        XmlCursor c = data.newCursor();
        c.selectPath("declare namespace pic='" + CTTable.type.getName().getNamespaceURI() + "' .//pic:tbl");
        while (c.toNextSelection()) {
            XmlObject o = c.getObject();
            if (o instanceof XmlAnyTypeImpl) {
                // Pesky XmlBeans bug - see Bugzilla #49934
                try {
                    o = CTTable.Factory.parse(o.toString(), DEFAULT_XML_OPTIONS);
                } catch (XmlException e) {
                    throw new POIXMLException(e);
                }
            }
            if (o instanceof CTTable) {
                DrawingTable table = new DrawingTable((CTTable) o);
                for (DrawingTableRow row : table.getRows()) {
                    for (DrawingTableCell cell : row.getCells()) {
                        DrawingTextBody textBody = cell.getTextBody();
                        out.add(textBody);
                    }
                }
            }
        }
        c.dispose();
    }
    return out;
}
Also used : CTGraphicalObjectFrame(org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame) ArrayList(java.util.ArrayList) POIXMLException(org.apache.poi.POIXMLException) CTGroupShape(org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShape) XmlCursor(org.apache.xmlbeans.XmlCursor) CTGraphicalObjectData(org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData) XmlException(org.apache.xmlbeans.XmlException) CTTable(org.openxmlformats.schemas.drawingml.x2006.main.CTTable) XmlAnyTypeImpl(org.apache.xmlbeans.impl.values.XmlAnyTypeImpl) XmlObject(org.apache.xmlbeans.XmlObject)

Aggregations

CTTable (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTable)5 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)4 Test (org.junit.Test)4 CTTable (org.openxmlformats.schemas.drawingml.x2006.main.CTTable)4 FileOutputStream (java.io.FileOutputStream)2 ArrayList (java.util.ArrayList)2 CellReference (org.apache.poi.ss.util.CellReference)2 XmlCursor (org.apache.xmlbeans.XmlCursor)2 XmlException (org.apache.xmlbeans.XmlException)2 CTGraphicalObjectData (org.openxmlformats.schemas.drawingml.x2006.main.CTGraphicalObjectData)2 CTGraphicalObjectFrame (org.openxmlformats.schemas.presentationml.x2006.main.CTGraphicalObjectFrame)2 CTTableColumn (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableColumn)2 CTTableStyleInfo (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableStyleInfo)2 TableDocument (org.openxmlformats.schemas.spreadsheetml.x2006.main.TableDocument)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 QName (javax.xml.namespace.QName)1 POIXMLException (org.apache.poi.POIXMLException)1 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1