Examples of PackageRelationshipCollection


Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     *  Fetches the InputStream to read the contents, based
     *  of the specified core part, for which we are defined
     *  as a suitable relationship
     */
    public InputStream getContents(PackagePart corePart) throws IOException, InvalidFormatException {
        PackageRelationshipCollection prc =
            corePart.getRelationshipsByType(_relation);
        Iterator<PackageRelationship> it = prc.iterator();
        if(it.hasNext()) {
            PackageRelationship rel = it.next();
            PackagePartName relName = PackagingURIHelper.createPartName(rel.getTargetURI());
            PackagePart part = corePart.getPackage().getPart(relName);
            return part.getInputStream();
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     * Retrieves all the PackageParts which are defined as
     *  relationships of the base document with the
     *  specified content type.
     */
    protected PackagePart[] getRelatedByType(String contentType) throws InvalidFormatException {
        PackageRelationshipCollection partsC =
            getPackagePart().getRelationshipsByType(contentType);

        PackagePart[] parts = new PackagePart[partsC.size()];
        int count = 0;
        for (PackageRelationship rel : partsC) {
            parts[count] = getPackagePart().getRelatedPart(rel);
            count++;
        }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

        hyperlinks = new ArrayList<XSSFHyperlink>();

        if(!worksheet.isSetHyperlinks()) return;

        try {
            PackageRelationshipCollection hyperRels =
                getPackagePart().getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation());

            // Turn each one into a XSSFHyperlink
            for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkList()) {
                PackageRelationship hyperRel = null;
                if(hyperlink.getId() != null) {
                    hyperRel = hyperRels.getRelationshipByID(hyperlink.getId());
                }

                hyperlinks.add( new XSSFHyperlink(hyperlink, hyperRel) );
            }
        } catch (InvalidFormatException e){
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     * Retrieves all the PackageParts which are defined as
     *  relationships of the base document with the
     *  specified content type.
     */
    protected PackagePart[] getRelatedByType(String contentType) throws InvalidFormatException {
        PackageRelationshipCollection partsC =
            getPackagePart().getRelationshipsByType(contentType);

        PackagePart[] parts = new PackagePart[partsC.size()];
        int count = 0;
        for (PackageRelationship rel : partsC) {
            parts[count] = getPackagePart().getRelatedPart(rel);
            count++;
        }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

        hyperlinks = new ArrayList<XSSFHyperlink>();

        if(!worksheet.isSetHyperlinks()) return;

        try {
            PackageRelationshipCollection hyperRels =
                getPackagePart().getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation());

            // Turn each one into a XSSFHyperlink
            for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkArray()) {
                PackageRelationship hyperRel = null;
                if(hyperlink.getId() != null) {
                    hyperRel = hyperRels.getRelationshipByID(hyperlink.getId());
                }

                hyperlinks.add( new XSSFHyperlink(hyperlink, hyperRel) );
            }
        } catch (InvalidFormatException e){
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     * When you open something like a theme, call this to
     *  re-base the XML Document onto the core child of the
     *  current core document
     */
    protected final void rebase(OPCPackage pkg) throws InvalidFormatException {
        PackageRelationshipCollection cores =
            packagePart.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
        if(cores.size() != 1) {
            throw new IllegalStateException(
                "Tried to rebase using " + PackageRelationshipTypes.CORE_DOCUMENT +
                " but found " + cores.size() + " parts of the right type"
            );
        }
        packageRel = cores.getRelationship(0);
        packagePart = packagePart.getRelatedPart(packageRel);
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     *
     * @param factory   the factory object that creates POIXMLFactory instances
     * @param context   context map containing already visited noted keyed by targetURI
     */
    protected void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart> context) throws OpenXML4JException {
        PackageRelationshipCollection rels = packagePart.getRelationships();
        for (PackageRelationship rel : rels) {
            if(rel.getTargetMode() == TargetMode.INTERNAL){
                URI uri = rel.getTargetURI();

                PackagePart p;
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     * When you open something like a theme, call this to
     *  re-base the XML Document onto the core child of the
     *  current core document
     */
    protected final void rebase(OPCPackage pkg) throws InvalidFormatException {
        PackageRelationshipCollection cores =
            packagePart.getRelationshipsByType(PackageRelationshipTypes.CORE_DOCUMENT);
        if(cores.size() != 1) {
            throw new IllegalStateException(
                "Tried to rebase using " + PackageRelationshipTypes.CORE_DOCUMENT +
                " but found " + cores.size() + " parts of the right type"
            );
        }
        packageRel = cores.getRelationship(0);
        packagePart = packagePart.getRelatedPart(packageRel);
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

     *
     * @param factory   the factory object that creates POIXMLFactory instances
     * @param context   context map containing already visited noted keyed by targetURI
     */
    protected void read(POIXMLFactory factory, Map<PackagePart, POIXMLDocumentPart> context) throws OpenXML4JException {
        PackageRelationshipCollection rels = packagePart.getRelationships();
        for (PackageRelationship rel : rels) {
            if(rel.getTargetMode() == TargetMode.INTERNAL){
                URI uri = rel.getTargetURI();

                PackagePart p;
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.PackageRelationshipCollection

    // Core properties
    core = new CoreProperties((PackagePropertiesPart)pkg.getPackageProperties() );

    // Extended properties
    PackageRelationshipCollection extRel =
      pkg.getRelationshipsByType(PackageRelationshipTypes.EXTENDED_PROPERTIES);
    if(extRel.size() == 1) {
      extPart = pkg.getPart( extRel.getRelationship(0));
      org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument.Factory.parse(
         extPart.getInputStream()
      );
      ext = new ExtendedProperties(props);
    } else {
      extPart = null;
      ext = new ExtendedProperties((org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument)NEW_EXT_INSTANCE.copy());
    }

    // Custom properties
    PackageRelationshipCollection custRel =
      pkg.getRelationshipsByType(PackageRelationshipTypes.CUSTOM_PROPERTIES);
    if(custRel.size() == 1) {
      custPart = pkg.getPart( custRel.getRelationship(0));
      org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props = org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument.Factory.parse(
          custPart.getInputStream()
      );
      cust = new CustomProperties(props);
    } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.