Example usage for org.apache.poi.xwpf.usermodel XWPFRelation ENDNOTE

List of usage examples for org.apache.poi.xwpf.usermodel XWPFRelation ENDNOTE

Introduction

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

Prototype

XWPFRelation ENDNOTE

To view the source code for org.apache.poi.xwpf.usermodel XWPFRelation ENDNOTE.

Click Source Link

Usage

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

License:Apache License

private void handleDocumentPart(PackagePart documentPart, XHTMLContentHandler xhtml)
        throws IOException, SAXException {
    //load the numbering/list manager and styles from the main document part
    XWPFNumbering numbering = loadNumbering(documentPart);
    XWPFListManager listManager = new XWPFListManager(numbering);
    XWPFStylesShim styles = loadStyles(documentPart);

    //headers//from www .jav  a 2 s  .  co  m
    try {
        PackageRelationshipCollection headersPRC = documentPart
                .getRelationshipsByType(XWPFRelation.HEADER.getRelation());
        if (headersPRC != null) {
            for (int i = 0; i < headersPRC.size(); i++) {
                PackagePart header = documentPart.getRelatedPart(headersPRC.getRelationship(i));
                handlePart(header, styles, listManager, xhtml);
            }
        }
    } catch (InvalidFormatException e) {
        //swallow
    }

    //main document
    handlePart(documentPart, styles, listManager, xhtml);

    //for now, just dump other components at end
    for (XWPFRelation rel : new XWPFRelation[] { XWPFRelation.FOOTNOTE, XWPFRelation.COMMENT,
            XWPFRelation.FOOTER, XWPFRelation.ENDNOTE }) {
        try {
            PackageRelationshipCollection prc = documentPart.getRelationshipsByType(rel.getRelation());
            if (prc != null) {
                for (int i = 0; i < prc.size(); i++) {
                    PackagePart packagePart = documentPart.getRelatedPart(prc.getRelationship(i));
                    handlePart(packagePart, styles, listManager, xhtml);
                }
            }
        } catch (InvalidFormatException e) {
            //swallow
        }
    }
}

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

License:Apache License

private void handleDocumentPart(PackagePart documentPart, StringBuilder sb) throws IOException, SAXException {
    //load the numbering/list manager and styles from the main document part
    XWPFNumbering numbering = loadNumbering(documentPart);
    XWPFListManager xwpfListManager = new XWPFListManager(numbering);
    //TODO: XWPFStyles styles = loadStyles(documentPart);

    //headers/*w  w w.j  a  v a 2  s .  c o  m*/
    try {
        PackageRelationshipCollection headersPRC = documentPart
                .getRelationshipsByType(XWPFRelation.HEADER.getRelation());
        if (headersPRC != null) {
            for (int i = 0; i < headersPRC.size(); i++) {
                PackagePart header = documentPart.getRelatedPart(headersPRC.getRelationship(i));
                handlePart(header, xwpfListManager, sb);
            }
        }
    } catch (InvalidFormatException e) {
        //swallow
    }

    //main document
    handlePart(documentPart, xwpfListManager, sb);

    //for now, just dump other components at end
    for (XWPFRelation rel : new XWPFRelation[] { XWPFRelation.FOOTNOTE, XWPFRelation.COMMENT,
            XWPFRelation.FOOTER, XWPFRelation.ENDNOTE }) {
        try {
            PackageRelationshipCollection prc = documentPart.getRelationshipsByType(rel.getRelation());
            if (prc != null) {
                for (int i = 0; i < prc.size(); i++) {
                    PackagePart packagePart = documentPart.getRelatedPart(prc.getRelationship(i));
                    handlePart(packagePart, xwpfListManager, sb);
                }
            }
        } catch (InvalidFormatException e) {
            //swallow
        }
    }
}