Example usage for org.apache.poi.xslf.usermodel XSLFTableRow getCells

List of usage examples for org.apache.poi.xslf.usermodel XSLFTableRow getCells

Introduction

In this page you can find the example usage for org.apache.poi.xslf.usermodel XSLFTableRow getCells.

Prototype

public List<XSLFTableCell> getCells() 

Source Link

Usage

From source file:mj.ocraptor.extraction.tika.parser.microsoft.ooxml.XSLFPowerPointExtractorDecorator.java

License:Apache License

private void extractContent(XSLFShape[] shapes, boolean skipPlaceholders, XHTMLContentHandler xhtml,
        String slideDesc) throws SAXException {
    for (XSLFShape sh : shapes) {
        if (sh instanceof XSLFTextShape) {
            XSLFTextShape txt = (XSLFTextShape) sh;
            Placeholder ph = txt.getTextType();
            if (skipPlaceholders && ph != null) {
                continue;
            }/*  w ww.j a  v a 2 s.c  o  m*/
            xhtml.element("p", txt.getText());
        } else if (sh instanceof XSLFGroupShape) {
            // recurse into groups of shapes
            XSLFGroupShape group = (XSLFGroupShape) sh;
            extractContent(group.getShapes(), skipPlaceholders, xhtml, slideDesc);
        } else if (sh instanceof XSLFTable) {
            XSLFTable tbl = (XSLFTable) sh;
            for (XSLFTableRow row : tbl) {
                List<XSLFTableCell> cells = row.getCells();
                extractContent(cells.toArray(new XSLFTableCell[cells.size()]), skipPlaceholders, xhtml,
                        slideDesc);
            }
        } else if (sh instanceof XSLFGraphicFrame) {
            XSLFGraphicFrame frame = (XSLFGraphicFrame) sh;
            XmlObject[] sp = frame.getXmlObject().selectPath(
                    "declare namespace p='http://schemas.openxmlformats.org/presentationml/2006/main' .//*/p:oleObj");
            if (sp != null) {
                for (XmlObject emb : sp) {
                    XmlObject relIDAtt = emb.selectAttribute(new QName(
                            "http://schemas.openxmlformats.org/officeDocument/2006/relationships", "id"));
                    if (relIDAtt != null) {
                        String relID = relIDAtt.getDomNode().getNodeValue();
                        if (slideDesc != null) {
                            relID = slideDesc + relID;
                        }
                        AttributesImpl attributes = new AttributesImpl();
                        attributes.addAttribute("", "class", "class", "CDATA", "embedded");
                        attributes.addAttribute("", "id", "id", "CDATA", relID);
                        xhtml.startElement("div", attributes);
                        xhtml.endElement("div");
                    }
                }
            }
        } else if (sh instanceof XSLFPictureShape) {
            if (!skipPlaceholders && (sh.getXmlObject() instanceof CTPicture)) {
                CTPicture ctPic = ((CTPicture) sh.getXmlObject());
                if (ctPic.getBlipFill() != null && ctPic.getBlipFill().getBlip() != null) {
                    String relID = ctPic.getBlipFill().getBlip().getEmbed();
                    if (relID != null) {
                        if (slideDesc != null) {
                            relID = slideDesc + relID;
                        }
                        AttributesImpl attributes = new AttributesImpl();
                        attributes.addAttribute("", "class", "class", "CDATA", "embedded");
                        attributes.addAttribute("", "id", "id", "CDATA", relID);
                        xhtml.startElement("div", attributes);
                        xhtml.endElement("div");
                    }
                }
            }
        }
    }
}

From source file:org.apache.tika.parser.microsoft.ooxml.XSLFPowerPointExtractorDecorator.java

License:Apache License

private void extractTable(XSLFTable tbl, XHTMLContentHandler xhtml) throws SAXException {
    xhtml.startElement("table");
    for (XSLFTableRow row : tbl) {
        xhtml.startElement("tr");
        List<XSLFTableCell> cells = row.getCells();
        for (XSLFTableCell c : row.getCells()) {
            xhtml.startElement("td");
            xhtml.characters(c.getText());
            xhtml.endElement("td");
        }/*from  ww w .j a  va2 s .  c  o  m*/
        xhtml.endElement("tr");
    }
    xhtml.endElement("table");

}