/**
         * Returns the extended document properties, eg
         *  application
         */

        public String GetExtendedPropertiesText()
        {
            if (Document == null)
            {  // event based extractor does not have a document
                return("");
            }
            StringBuilder text = new StringBuilder();
            CT_ExtendedProperties
                props = Document.GetProperties().ExtendedProperties.GetUnderlyingProperties();

            AppendIfPresent(text, "Application", props.Application);
            AppendIfPresent(text, "AppVersion", props.AppVersion);
            AppendIfPresent(text, "Characters", props.Characters);
            AppendIfPresent(text, "CharactersWithSpaces", props.CharactersWithSpaces);
            AppendIfPresent(text, "Company", props.Company);
            AppendIfPresent(text, "HyperlinkBase", props.HyperlinkBase);
            AppendIfPresent(text, "HyperlinksChanged", props.HyperlinksChanged);
            AppendIfPresent(text, "Lines", props.Lines);
            AppendIfPresent(text, "LinksUpToDate", props.LinksUpToDate);
            AppendIfPresent(text, "Manager", props.Manager);
            AppendIfPresent(text, "Pages", props.Pages);
            AppendIfPresent(text, "Paragraphs", props.Paragraphs);
            AppendIfPresent(text, "PresentationFormat", props.PresentationFormat);
            AppendIfPresent(text, "Template", props.Template);
            AppendIfPresent(text, "TotalTime", props.TotalTime);

            return(text.ToString());
        }
        public void TestWorkbookExtendedProperties()
        {
            XSSFWorkbook     workbook = new XSSFWorkbook();
            POIXMLProperties props    = workbook.GetProperties();

            Assert.IsNotNull(props);

            ExtendedProperties properties =
                props.ExtendedProperties;

            CT_ExtendedProperties
                ctProps = properties.GetUnderlyingProperties();


            String appVersion  = "3.5 beta";
            String application = "POI";

            ctProps.Application = (application);
            ctProps.AppVersion  = (appVersion);

            ctProps    = null;
            properties = null;
            props      = null;

            XSSFWorkbook newWorkbook =
                (XSSFWorkbook)XSSFTestDataSamples.WriteOutAndReadBack(workbook);

            Assert.IsTrue(workbook != newWorkbook);


            POIXMLProperties newProps = newWorkbook.GetProperties();

            Assert.IsNotNull(newProps);
            ExtendedProperties newProperties =
                newProps.ExtendedProperties;

            Assert.AreEqual(application, newProperties.Application);
            Assert.AreEqual(appVersion, newProperties.AppVersion);


            CT_ExtendedProperties
                newCtProps = newProperties.GetUnderlyingProperties();

            Assert.AreEqual(application, newCtProps.Application);
            Assert.AreEqual(appVersion, newCtProps.AppVersion);
        }
        public string GetExtendedPropertiesText()
        {
            StringBuilder         text = new StringBuilder();
            CT_ExtendedProperties underlyingProperties = this.Document.GetProperties().GetExtendedProperties().GetUnderlyingProperties();

            this.AppendIfPresent(text, "Application", underlyingProperties.Application);
            this.AppendIfPresent(text, "AppVersion", underlyingProperties.AppVersion);
            this.AppendIfPresent(text, "Characters", underlyingProperties.Characters);
            this.AppendIfPresent(text, "CharactersWithSpaces", underlyingProperties.CharactersWithSpaces);
            this.AppendIfPresent(text, "Company", underlyingProperties.Company);
            this.AppendIfPresent(text, "HyperlinkBase", underlyingProperties.HyperlinkBase);
            this.AppendIfPresent(text, "HyperlinksChanged", underlyingProperties.HyperlinksChanged);
            this.AppendIfPresent(text, "Lines", underlyingProperties.Lines);
            this.AppendIfPresent(text, "LinksUpToDate", underlyingProperties.LinksUpToDate);
            this.AppendIfPresent(text, "Manager", underlyingProperties.Manager);
            this.AppendIfPresent(text, "Pages", underlyingProperties.Pages);
            this.AppendIfPresent(text, "Paragraphs", underlyingProperties.Paragraphs);
            this.AppendIfPresent(text, "PresentationFormat", underlyingProperties.PresentationFormat);
            this.AppendIfPresent(text, "Template", underlyingProperties.Template);
            this.AppendIfPresent(text, "TotalTime", underlyingProperties.TotalTime);
            return(text.ToString());
        }
Exemple #4
0
        private void OnWorkbookCreate()
        {
            this.workbook = new CT_Workbook();
            this.workbook.AddNewWorkbookPr().date1904 = false;
            this.workbook.AddNewBookViews().AddNewWorkbookView().activeTab = 0U;
            this.workbook.AddNewSheets();
            CT_ExtendedProperties underlyingProperties = this.GetProperties().GetExtendedProperties().GetUnderlyingProperties();

            underlyingProperties.Application                = POIXMLDocument.DOCUMENT_CREATOR;
            underlyingProperties.DocSecurity                = 0;
            underlyingProperties.DocSecuritySpecified       = true;
            underlyingProperties.ScaleCrop                  = false;
            underlyingProperties.ScaleCropSpecified         = true;
            underlyingProperties.LinksUpToDate              = false;
            underlyingProperties.LinksUpToDateSpecified     = true;
            underlyingProperties.HyperlinksChanged          = false;
            underlyingProperties.HyperlinksChangedSpecified = true;
            underlyingProperties.SharedDoc                  = false;
            underlyingProperties.SharedDocSpecified         = true;
            this.sharedStringSource = (SharedStringsTable)this.CreateRelationship((POIXMLRelation)XSSFRelation.SHARED_STRINGS, (POIXMLFactory)XSSFFactory.GetInstance());
            this.stylesSource       = (StylesTable)this.CreateRelationship((POIXMLRelation)XSSFRelation.STYLES, (POIXMLFactory)XSSFFactory.GetInstance());
            this.namedRanges        = new List <XSSFName>();
            this.sheets             = new List <XSSFSheet>();
        }
Exemple #5
0
        public void TestGetAllExtendedProperties()
        {
            XWPFDocument          doc     = XWPFTestDataSamples.OpenSampleDocument("TestPoiXMLDocumentCorePropertiesGetKeywords.docx");
            CT_ExtendedProperties ctProps = doc.GetProperties().ExtendedProperties.GetUnderlyingProperties();

            Assert.AreEqual("Microsoft Office Word", ctProps.Application);
            Assert.AreEqual("14.0000", ctProps.AppVersion);
            Assert.AreEqual(57, ctProps.Characters);
            Assert.AreEqual(66, ctProps.CharactersWithSpaces);
            Assert.AreEqual("", ctProps.Company);
            Assert.IsNull(ctProps.DigSig);
            Assert.AreEqual(0, ctProps.DocSecurity);
            //Assert.IsNotNull(ctProps.DomNode);

            CT_VectorVariant vec = ctProps.HeadingPairs;

            Assert.AreEqual(2, vec.vector.SizeOfVariantArray());
            Assert.AreEqual("Title", vec.vector.GetVariantArray(0).lpstr);
            Assert.AreEqual(1, vec.vector.GetVariantArray(1).i4);

            Assert.IsFalse(ctProps.IsSetHiddenSlides());
            Assert.AreEqual(0, ctProps.HiddenSlides);
            Assert.IsFalse(ctProps.IsSetHLinks());
            Assert.IsNull(ctProps.HLinks);
            Assert.IsNull(ctProps.HyperlinkBase);
            Assert.IsTrue(ctProps.IsSetHyperlinksChanged());
            Assert.IsFalse(ctProps.HyperlinksChanged);
            Assert.AreEqual(1, ctProps.Lines);
            Assert.IsTrue(ctProps.IsSetLinksUpToDate());
            Assert.IsFalse(ctProps.LinksUpToDate);
            Assert.IsNull(ctProps.Manager);
            Assert.IsFalse(ctProps.IsSetMMClips());
            Assert.AreEqual(0, ctProps.MMClips);
            Assert.IsFalse(ctProps.IsSetNotes());
            Assert.AreEqual(0, ctProps.Notes);
            Assert.AreEqual(1, ctProps.Pages);
            Assert.AreEqual(1, ctProps.Paragraphs);
            Assert.IsNull(ctProps.PresentationFormat);
            Assert.IsTrue(ctProps.IsSetScaleCrop());
            Assert.IsFalse(ctProps.ScaleCrop);
            Assert.IsTrue(ctProps.IsSetSharedDoc());
            Assert.IsFalse(ctProps.SharedDoc);
            Assert.IsFalse(ctProps.IsSetSlides());
            Assert.AreEqual(0, ctProps.Slides);
            Assert.AreEqual("Normal.dotm", ctProps.Template);

            CT_VectorLpstr vec2 = ctProps.TitlesOfParts;

            Assert.AreEqual(1, vec2.vector.SizeOfLpstrArray());
            Assert.AreEqual("Example Word 2010 Document", vec2.vector.GetLpstrArray(0));

            Assert.AreEqual(3, ctProps.TotalTime);
            Assert.AreEqual(10, ctProps.Words);

            // Check the digital signature part
            // Won't be there in this file, but we
            //  need to do this check so that the
            //  appropriate parts end up in the
            //  smaller ooxml schemas file
            CT_DigSigBlob blob = ctProps.DigSig;

            Assert.IsNull(blob);

            blob      = new CT_DigSigBlob();
            blob.blob = (new byte[] { 2, 6, 7, 2, 3, 4, 5, 1, 2, 3 });
        }