Search in sources :

Example 1 with XWPFNumberingShim

use of org.apache.tika.parser.microsoft.ooxml.xwpf.XWPFNumberingShim in project tika by apache.

the class SXWPFWordExtractorDecorator method loadNumbering.

private XWPFNumbering loadNumbering(PackagePart packagePart) {
    try {
        PackageRelationshipCollection numberingParts = packagePart.getRelationshipsByType(XWPFRelation.NUMBERING.getRelation());
        if (numberingParts.size() > 0) {
            PackageRelationship numberingRelationShip = numberingParts.getRelationship(0);
            if (numberingRelationShip == null) {
                return null;
            }
            PackagePart numberingPart = packagePart.getRelatedPart(numberingRelationShip);
            if (numberingPart == null) {
                return null;
            }
            return new XWPFNumberingShim(numberingPart);
        }
    } catch (IOException | OpenXML4JException e) {
    //swallow
    }
    return null;
}
Also used : PackageRelationship(org.apache.poi.openxml4j.opc.PackageRelationship) OpenXML4JException(org.apache.poi.openxml4j.exceptions.OpenXML4JException) PackageRelationshipCollection(org.apache.poi.openxml4j.opc.PackageRelationshipCollection) IOException(java.io.IOException) PackagePart(org.apache.poi.openxml4j.opc.PackagePart) XWPFNumberingShim(org.apache.tika.parser.microsoft.ooxml.xwpf.XWPFNumberingShim)

Aggregations

IOException (java.io.IOException)1 OpenXML4JException (org.apache.poi.openxml4j.exceptions.OpenXML4JException)1 PackagePart (org.apache.poi.openxml4j.opc.PackagePart)1 PackageRelationship (org.apache.poi.openxml4j.opc.PackageRelationship)1 PackageRelationshipCollection (org.apache.poi.openxml4j.opc.PackageRelationshipCollection)1 XWPFNumberingShim (org.apache.tika.parser.microsoft.ooxml.xwpf.XWPFNumberingShim)1