Ejemplo n.º 1
0
 public void SetUp()
 {
     XWPFDocument sampleDoc = XWPFTestDataSamples.OpenSampleDocument("documentProperties.docx");
     _props = sampleDoc.GetProperties();
     _coreProperties = _props.CoreProperties;
     Assert.IsNotNull(_props);
 }
Ejemplo n.º 2
0
        public void SetUp()
        {
            XWPFDocument sampleDoc = XWPFTestDataSamples.OpenSampleDocument("documentProperties.docx");

            _props          = sampleDoc.GetProperties();
            _coreProperties = _props.CoreProperties;
            Assert.IsNotNull(_props);
        }
Ejemplo n.º 3
0
        public void TestTransitiveSetters()
        {
            XWPFDocument   doc = new XWPFDocument();
            CoreProperties cp  = doc.GetProperties().CoreProperties;

            DateTime dateCreated = new DateTime(2010, 6, 15, 10, 0, 0);

            cp.Created = new DateTime(2010, 6, 15, 10, 0, 0);
            Assert.AreEqual(dateCreated.ToString(), cp.Created.ToString());

            doc = XWPFTestDataSamples.WriteOutAndReadBack(doc);
            cp  = doc.GetProperties().CoreProperties;
            DateTime?dt3 = cp.Created;

            Assert.AreEqual(dateCreated.ToString(), dt3.ToString());
        }
Ejemplo n.º 4
0
        public POIXMLProperties(OPCPackage docPackage)
        {
            this.pkg = docPackage;

            // 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));
                ExtendedPropertiesDocument props = ExtendedPropertiesDocument.Parse(
                    extPart.GetInputStream()
                    );
                ext = new ExtendedProperties(props);
            }
            else
            {
                extPart = null;
                ext     = new ExtendedProperties((ExtendedPropertiesDocument)NEW_EXT_INSTANCE.Copy());
            }

            // Custom properties
            PackageRelationshipCollection custRel =
                pkg.GetRelationshipsByType(PackageRelationshipTypes.CUSTOM_PROPERTIES);

            if (custRel.Size == 1)
            {
                custPart = pkg.GetPart(custRel.GetRelationship(0));
                CustomPropertiesDocument props = CustomPropertiesDocument.Parse(
                    custPart.GetInputStream()
                    );
                cust = new CustomProperties(props);
            }
            else
            {
                custPart = null;
                cust     = new CustomProperties((CustomPropertiesDocument)NEW_CUST_INSTANCE.Copy());
            }
        }
Ejemplo n.º 5
0
        public POIXMLProperties(OPCPackage docPackage)
        {
            this.pkg = docPackage;

            // 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));
                ExtendedPropertiesDocument props = ExtendedPropertiesDocument.Parse(
                     extPart.GetInputStream()
                );
                ext = new ExtendedProperties(props);
            }
            else
            {
                extPart = null;
                ext = new ExtendedProperties((ExtendedPropertiesDocument)NEW_EXT_INSTANCE.Copy());
            }

            // Custom properties
            PackageRelationshipCollection custRel =
                pkg.GetRelationshipsByType(PackageRelationshipTypes.CUSTOM_PROPERTIES);
            if (custRel.Size == 1)
            {
                custPart = pkg.GetPart(custRel.GetRelationship(0));
                CustomPropertiesDocument props = CustomPropertiesDocument.Parse(
                        custPart.GetInputStream()
                );
                cust = new CustomProperties(props);
            }
            else
            {
                custPart = null;
                cust = new CustomProperties((CustomPropertiesDocument)NEW_CUST_INSTANCE.Copy());
            }
        }