public void TestShouldUnsetEnforcement() { XWPFDocument document = XWPFTestDataSamples.OpenSampleDocument("documentProtection_readonly_no_password.docx"); Assert.IsTrue(document.IsEnforcedReadonlyProtection()); document.RemoveProtectionEnforcement(); Assert.IsFalse(document.IsEnforcedReadonlyProtection()); }
public void TestShouldEnforceForComments() { XWPFDocument document = XWPFTestDataSamples.OpenSampleDocument("documentProtection_no_protection.docx"); Assert.IsFalse(document.IsEnforcedCommentsProtection()); document.EnforceCommentsProtection(); Assert.IsTrue(document.IsEnforcedCommentsProtection()); }
public void TestShouldEnforceForReadOnly() { // XWPFDocument document = CreateDocumentFromSampleFile("test-data/document/documentProtection_no_protection.docx"); XWPFDocument document = XWPFTestDataSamples.OpenSampleDocument("documentProtection_no_protection.docx"); Assert.IsFalse(document.IsEnforcedReadonlyProtection()); document.EnforceReadonlyProtection(); Assert.IsTrue(document.IsEnforcedReadonlyProtection()); }
public void TestGetSetKeywords() { XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("TestPoiXMLDocumentCorePropertiesGetKeywords.docx"); String keywords = doc.GetProperties().CoreProperties.Keywords; Assert.AreEqual("extractor, test, rdf", keywords); doc.GetProperties().CoreProperties.Keywords = ("test, keywords"); doc = XWPFTestDataSamples.WriteOutAndReadBack(doc); keywords = doc.GetProperties().CoreProperties.Keywords; Assert.AreEqual("test, keywords", keywords); }
public void Test57829() { XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("sample.docx"); Assert.IsNotNull(doc); Assert.AreEqual(3, doc.Paragraphs.Count); foreach (XWPFParagraph paragraph in doc.Paragraphs) { paragraph.RemoveRun(0); Assert.IsNotNull(paragraph.Text); } }
public void TestShouldReadEnforcementProperties() { XWPFDocument documentWithoutDocumentProtectionTag = XWPFTestDataSamples.OpenSampleDocument("documentProtection_no_protection.docx"); Assert.IsFalse(documentWithoutDocumentProtectionTag.IsEnforcedReadonlyProtection()); Assert.IsFalse(documentWithoutDocumentProtectionTag.IsEnforcedFillingFormsProtection()); Assert.IsFalse(documentWithoutDocumentProtectionTag.IsEnforcedCommentsProtection()); Assert.IsFalse(documentWithoutDocumentProtectionTag.IsEnforcedTrackedChangesProtection()); XWPFDocument documentWithoutEnforcement = XWPFTestDataSamples.OpenSampleDocument("documentProtection_no_protection_tag_existing.docx"); Assert.IsFalse(documentWithoutEnforcement.IsEnforcedReadonlyProtection()); Assert.IsFalse(documentWithoutEnforcement.IsEnforcedFillingFormsProtection()); Assert.IsFalse(documentWithoutEnforcement.IsEnforcedCommentsProtection()); Assert.IsFalse(documentWithoutEnforcement.IsEnforcedTrackedChangesProtection()); XWPFDocument documentWithReadonlyEnforcement = XWPFTestDataSamples.OpenSampleDocument("documentProtection_readonly_no_password.docx"); Assert.IsTrue(documentWithReadonlyEnforcement.IsEnforcedReadonlyProtection()); Assert.IsFalse(documentWithReadonlyEnforcement.IsEnforcedFillingFormsProtection()); Assert.IsFalse(documentWithReadonlyEnforcement.IsEnforcedCommentsProtection()); Assert.IsFalse(documentWithReadonlyEnforcement.IsEnforcedTrackedChangesProtection()); XWPFDocument documentWithFillingFormsEnforcement = XWPFTestDataSamples.OpenSampleDocument("documentProtection_forms_no_password.docx"); Assert.IsTrue(documentWithFillingFormsEnforcement.IsEnforcedFillingFormsProtection()); Assert.IsFalse(documentWithFillingFormsEnforcement.IsEnforcedReadonlyProtection()); Assert.IsFalse(documentWithFillingFormsEnforcement.IsEnforcedCommentsProtection()); Assert.IsFalse(documentWithFillingFormsEnforcement.IsEnforcedTrackedChangesProtection()); XWPFDocument documentWithCommentsEnforcement = XWPFTestDataSamples.OpenSampleDocument("documentProtection_comments_no_password.docx"); Assert.IsFalse(documentWithCommentsEnforcement.IsEnforcedFillingFormsProtection()); Assert.IsFalse(documentWithCommentsEnforcement.IsEnforcedReadonlyProtection()); Assert.IsTrue(documentWithCommentsEnforcement.IsEnforcedCommentsProtection()); Assert.IsFalse(documentWithCommentsEnforcement.IsEnforcedTrackedChangesProtection()); XWPFDocument documentWithTrackedChangesEnforcement = XWPFTestDataSamples.OpenSampleDocument("documentProtection_trackedChanges_no_password.docx"); Assert.IsFalse(documentWithTrackedChangesEnforcement.IsEnforcedFillingFormsProtection()); Assert.IsFalse(documentWithTrackedChangesEnforcement.IsEnforcedReadonlyProtection()); Assert.IsFalse(documentWithTrackedChangesEnforcement.IsEnforcedCommentsProtection()); Assert.IsTrue(documentWithTrackedChangesEnforcement.IsEnforcedTrackedChangesProtection()); }
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 }); }
public void Test56392() { XWPFDocument doc = XWPFTestDataSamples.OpenSampleDocument("56392.docx"); Assert.IsNotNull(doc); }