public void SetUp() { sampleDoc = XWPFTestDataSamples.OpenSampleDocument("documentProperties.docx"); sampleNoThumb = XWPFTestDataSamples.OpenSampleDocument("SampleDoc.docx"); Assert.IsNotNull(sampleDoc); Assert.IsNotNull(sampleNoThumb); _props = sampleDoc.GetProperties(); _coreProperties = _props.CoreProperties; Assert.IsNotNull(_props); }
/// <summary> /// 文档属性 /// </summary> /// <param name="filepath">文档地址</param> /// <returns>0.创建者,1分类,2标题</returns> public Tuple <string, string, string> GetDocProperties(string filepath) { using (FileStream fs = File.OpenRead(filepath)) { XWPFDocument doc = new XWPFDocument(fs); XWPFWordExtractor extractor = new XWPFWordExtractor(doc); CoreProperties t = extractor.GetCoreProperties(); return(new Tuple <string, string, string>(t.Creator, t.Category, t.Title)); } }
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()); XWPFDocument doc2 = XWPFTestDataSamples.WriteOutAndReadBack(doc); doc.Close(); cp = doc2.GetProperties().CoreProperties; DateTime?dt3 = cp.Created; Assert.AreEqual(dateCreated.ToString(), dt3.ToString()); doc2.Close(); }
public void SetProperties(CoreProperties property, UnicodeCodePointRange codePointRange) { int firstIndex = FindUcdCodePoint(codePointRange.FirstCodePoint); int lastIndex = FindUcdCodePoint(codePointRange.LastCodePoint); if (firstIndex < 0 && lastIndex < 0) { Insert(new UnicodeCharacterDataBuilder(codePointRange) { CoreProperties = property }); return; } if (firstIndex < 0 || lastIndex < 0 || ucdEntries[firstIndex].CodePointRange.FirstCodePoint <codePointRange.FirstCodePoint || ucdEntries[lastIndex].CodePointRange.LastCodePoint> codePointRange.LastCodePoint) { throw new InvalidOperationException("Unable to find code point for setting core property."); } int i = firstIndex; while (true) { ucdEntries[i].CoreProperties |= property; if (i == lastIndex) { break; } ++i; } }
[InlineData(0xE01EF, CoreProperties.ExtendedIdentifierContinue)] // VARIATION SELECTOR-256 public void CodePointShouldHaveCoreProperties(int codePoint, CoreProperties coreProperties) => Assert.Equal(coreProperties, UnicodeInfo.GetCharInfo(codePoint).CoreProperties & coreProperties);