Examples of PackagePropertiesPart


Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

        df.setTimeZone(TimeZone.getTimeZone("UTC"));
        String strDate = "2007-05-12T08:00:00Z";
        Date date = df.parse(strDate);

        OPCPackage pkg = new ZipPackage();
        PackagePropertiesPart props = (PackagePropertiesPart)pkg.getPackageProperties();

        // created
        assertEquals("", props.getCreatedPropertyString());
        assertNull(props.getCreatedProperty().getValue());
        props.setCreatedProperty((String)null);
        assertEquals("", props.getCreatedPropertyString());
        assertNull(props.getCreatedProperty().getValue());
        props.setCreatedProperty(new Nullable<Date>());
        assertEquals("", props.getCreatedPropertyString());
        assertNull(props.getCreatedProperty().getValue());
        props.setCreatedProperty(new Nullable<Date>(date));
        assertEquals(strDate, props.getCreatedPropertyString());
        assertEquals(date, props.getCreatedProperty().getValue());
        props.setCreatedProperty(strDate);
        assertEquals(strDate, props.getCreatedPropertyString());
        assertEquals(date, props.getCreatedProperty().getValue());

        // lastPrinted
        assertEquals("", props.getLastPrintedPropertyString());
        assertNull(props.getLastPrintedProperty().getValue());
        props.setLastPrintedProperty((String)null);
        assertEquals("", props.getLastPrintedPropertyString());
        assertNull(props.getLastPrintedProperty().getValue());
        props.setLastPrintedProperty(new Nullable<Date>());
        assertEquals("", props.getLastPrintedPropertyString());
        assertNull(props.getLastPrintedProperty().getValue());
        props.setLastPrintedProperty(new Nullable<Date>(date));
        assertEquals(strDate, props.getLastPrintedPropertyString());
        assertEquals(date, props.getLastPrintedProperty().getValue());
        props.setLastPrintedProperty(strDate);
        assertEquals(strDate, props.getLastPrintedPropertyString());
        assertEquals(date, props.getLastPrintedProperty().getValue());

        // modified
        assertNull(props.getModifiedProperty().getValue());
        props.setModifiedProperty((String)null);
        assertNull(props.getModifiedProperty().getValue());
        props.setModifiedProperty(new Nullable<Date>());
        assertNull(props.getModifiedProperty().getValue());
        props.setModifiedProperty(new Nullable<Date>(date));
        assertEquals(strDate, props.getModifiedPropertyString());
        assertEquals(date, props.getModifiedProperty().getValue());
        props.setModifiedProperty(strDate);
        assertEquals(strDate, props.getModifiedPropertyString());
        assertEquals(date, props.getModifiedProperty().getValue());
       
        // Tidy
        pkg.close();
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

        assertTrue("Core/Doc Relationship not found in " + p.getRelationships(), foundDocRel);
        assertTrue("Core Props Relationship not found in " + p.getRelationships(), foundCorePropRel);
        assertTrue("Ext Props Relationship not found in " + p.getRelationships(), foundExtPropRel);

        // Get the Core Properties
        PackagePropertiesPart props = (PackagePropertiesPart)p.getPackageProperties();
       
        // Check
        assertEquals("Stefan Kopf", props.getCreatorProperty().getValue());
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

    POIXMLProperties props = workbook.getProperties();
    assertNotNull(props);
    //the Application property must be set for new workbooks, see Bugzilla #47559
    assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());

    PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
    assertNotNull(opcProps);

    opcProps.setTitleProperty("Testing Bugzilla #47460");
    assertEquals("Apache POI", opcProps.getCreatorProperty().getValue());
    opcProps.setCreatorProperty("poi-dev@poi.apache.org");

    workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
    assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
    opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
    assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
    assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

    POIXMLProperties props = workbook.getProperties();
    assertNotNull(props);
    //the Application property must be set for new workbooks, see Bugzilla #47559
    assertEquals("Apache POI", props.getExtendedProperties().getUnderlyingProperties().getApplication());

    PackagePropertiesPart opcProps = props.getCoreProperties().getUnderlyingProperties();
    assertNotNull(opcProps);

    opcProps.setTitleProperty("Testing Bugzilla #47460");
    assertEquals("Apache POI", opcProps.getCreatorProperty().getValue());
    opcProps.setCreatorProperty("poi-dev@poi.apache.org");

    workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
    assertEquals("Apache POI", workbook.getProperties().getExtendedProperties().getUnderlyingProperties().getApplication());
    opcProps = workbook.getProperties().getCoreProperties().getUnderlyingProperties();
    assertEquals("Testing Bugzilla #47460", opcProps.getTitleProperty().getValue());
    assertEquals("poi-dev@poi.apache.org", opcProps.getCreatorProperty().getValue());
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

      pkg.contentTypeManager.addContentType(
          PackagingURIHelper.createPartName("/default.xml"),
          ContentTypes.PLAIN_OLD_XML);

      // Initialise some PackageBase properties
      pkg.packageProperties = new PackagePropertiesPart(pkg,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
      pkg.packageProperties.setCreatorProperty("Generated by Apache POI OpenXML4J");
      pkg.packageProperties.setCreatedProperty(new Nullable<Date>(new Date()));
    } catch (InvalidFormatException e) {
      // Should never happen
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  public PackageProperties getPackageProperties()
      throws InvalidFormatException {
    this.throwExceptionIfWriteOnly();
    // If no properties part has been found then we create one
    if (this.packageProperties == null) {
      this.packageProperties = new PackagePropertiesPart(this,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
    }
    return this.packageProperties;
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

        extractMetadata(extractor.getCoreProperties(), metadata);
        extractMetadata(extractor.getExtendedProperties(), metadata);
    }

    private void extractMetadata(CoreProperties properties, Metadata metadata) {
        PackagePropertiesPart propsHolder = properties
                .getUnderlyingProperties();

        addProperty(metadata, Metadata.CATEGORY, propsHolder.getCategoryProperty());
        addProperty(metadata, Metadata.CONTENT_STATUS, propsHolder
                .getContentStatusProperty());
        addProperty(metadata, Metadata.DATE, propsHolder
                .getCreatedProperty());
        addProperty(metadata, Metadata.CREATION_DATE, propsHolder
                .getCreatedProperty());
        addProperty(metadata, Metadata.CREATOR, propsHolder
                .getCreatorProperty());
        addProperty(metadata, Metadata.AUTHOR, propsHolder
                .getCreatorProperty());
        addProperty(metadata, Metadata.DESCRIPTION, propsHolder
                .getDescriptionProperty());
        addProperty(metadata, Metadata.IDENTIFIER, propsHolder
                .getIdentifierProperty());
        addProperty(metadata, Metadata.KEYWORDS, propsHolder
                .getKeywordsProperty());
        addProperty(metadata, Metadata.LANGUAGE, propsHolder
                .getLanguageProperty());
        addProperty(metadata, Metadata.LAST_AUTHOR, propsHolder
                .getLastModifiedByProperty());
        addProperty(metadata, Metadata.LAST_PRINTED, propsHolder
                .getLastPrintedPropertyString());
        addProperty(metadata, Metadata.LAST_MODIFIED, propsHolder
                .getModifiedProperty());
        addProperty(metadata, Metadata.REVISION_NUMBER, propsHolder
                .getRevisionProperty());
        addProperty(metadata, Metadata.SUBJECT, propsHolder
                .getSubjectProperty());
        addProperty(metadata, Metadata.TITLE, propsHolder.getTitleProperty());
        addProperty(metadata, Metadata.VERSION, propsHolder.getVersionProperty());
    }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  /**
   * Returns the core document properties, eg author
   */
  public String getCorePropertiesText() throws IOException, OpenXML4JException, XmlException {
    StringBuffer text = new StringBuffer();
    PackagePropertiesPart props =
      document.getProperties().getCoreProperties().getUnderlyingProperties();
   
    text.append("Category = " + props.getCategoryProperty().getValue() + "\n");
    text.append("ContentStatus = " + props.getContentStatusProperty().getValue() + "\n");
    text.append("ContentType = " + props.getContentTypeProperty().getValue() + "\n");
    text.append("Created = " + props.getCreatedProperty().getValue() + "\n");
    text.append("CreatedString = " + props.getCreatedPropertyString() + "\n");
    text.append("Creator = " + props.getCreatorProperty().getValue() + "\n");
    text.append("Description = " + props.getDescriptionProperty().getValue() + "\n");
    text.append("Identifier = " + props.getIdentifierProperty().getValue() + "\n");
    text.append("Keywords = " + props.getKeywordsProperty().getValue() + "\n");
    text.append("Language = " + props.getLanguageProperty().getValue() + "\n");
    text.append("LastModifiedBy = " + props.getLastModifiedByProperty().getValue() + "\n");
    text.append("LastPrinted = " + props.getLastPrintedProperty().getValue() + "\n");
    text.append("LastPrintedString = " + props.getLastPrintedPropertyString() + "\n");
    text.append("Modified = " + props.getModifiedProperty().getValue() + "\n");
    text.append("ModifiedString = " + props.getModifiedPropertyString() + "\n");
    text.append("Revision = " + props.getRevisionProperty().getValue() + "\n");
    text.append("Subject = " + props.getSubjectProperty().getValue() + "\n");
    text.append("Title = " + props.getTitleProperty().getValue() + "\n");
    text.append("Version = " + props.getVersionProperty().getValue() + "\n");

    return text.toString();
  }
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

          .addContentType(PackagingURIHelper
              .createPartName("/default.xml"),
              ContentTypes.PLAIN_OLD_XML);

      // Init some Package properties
      pkg.packageProperties = new PackagePropertiesPart(pkg,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
      pkg.packageProperties.setCreatorProperty("Generated by OpenXML4J");
      pkg.packageProperties.setCreatedProperty(new Nullable<Date>(
          new Date()));
    } catch (InvalidFormatException e) {
View Full Code Here

Examples of org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart

  public PackageProperties getPackageProperties()
      throws InvalidFormatException {
    this.throwExceptionIfWriteOnly();
    // If no properties part has been found then we create one
    if (this.packageProperties == null) {
      this.packageProperties = new PackagePropertiesPart(this,
          PackagingURIHelper.CORE_PROPERTIES_PART_NAME);
    }
    return this.packageProperties;
  }
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.