Example usage for org.apache.poi.xwpf.usermodel XWPFSDT getContent

List of usage examples for org.apache.poi.xwpf.usermodel XWPFSDT getContent

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFSDT getContent.

Prototype

public ISDTContent getContent() 

Source Link

Usage

From source file:fr.opensagres.poi.xwpf.converter.core.XWPFDocumentVisitor.java

License:Open Source License

protected void visitSDTBody(XWPFSDT contents, T sdtContainer) throws Exception {
    ISDTContent content = contents.getContent();
    Field bodyElements;//  ww w . j av a 2  s  .c o  m
    try {
        bodyElements = content.getClass().getDeclaredField("bodyElements");
        bodyElements.setAccessible(true);
        List<ISDTContents> isdtContents = (List<ISDTContents>) bodyElements.get(content);
        for (int i = 0; i < isdtContents.size(); i++) {
            ISDTContents isdtContent = isdtContents.get(i);
            if (isdtContent instanceof XWPFParagraph) {
                visitParagraph((XWPFParagraph) isdtContent, i, sdtContainer);
            } else if (isdtContent instanceof XWPFTable) {
                visitTable((XWPFTable) isdtContent, i, sdtContainer);
            } else if (isdtContent instanceof XWPFRun) {
                visitRun((XWPFParagraph) ((XWPFRun) isdtContent).getParent(), (XmlObject) isdtContent,
                        sdtContainer);
            } else if (isdtContent instanceof XWPFSDT) {
                visitSDT((XWPFSDT) isdtContent, i, sdtContainer);
            }
        }
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

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

License:Apache License

private void extractSDT(XWPFSDT element, XHTMLContentHandler xhtml)
        throws SAXException, XmlException, IOException {
    XWPFSDTContent content = element.getContent();
    String tag = "p";
    xhtml.startElement(tag);/*from w ww. j av a2 s. c  o m*/
    xhtml.characters(content.getText());
    xhtml.endElement(tag);
}

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

License:Apache License

private void processSDTRun(XWPFSDT run, XHTMLContentHandler xhtml)
        throws SAXException, XmlException, IOException {
    xhtml.characters(run.getContent().getText());
}

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

License:Apache License

private void extractSDT(XWPFSDT element, XHTMLContentHandler xhtml)
        throws SAXException, XmlException, IOException {
    ISDTContent content = element.getContent();
    String tag = "p";
    xhtml.startElement(tag);//  w w  w. ja v  a2 s.c om
    xhtml.characters(content.getText());
    xhtml.endElement(tag);
}