use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestDocumentProtection method testShouldEnforceForReadOnly.
@Test
public void testShouldEnforceForReadOnly() throws IOException {
// XWPFDocument document = createDocumentFromSampleFile("test-data/document/documentProtection_no_protection.docx");
XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
assertFalse(document.isEnforcedReadonlyProtection());
document.enforceReadonlyProtection();
assertTrue(document.isEnforcedReadonlyProtection());
document.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestDocumentProtection method testShouldEnforceForTrackedChanges.
@Test
public void testShouldEnforceForTrackedChanges() throws IOException {
XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
assertFalse(document.isEnforcedTrackedChangesProtection());
document.enforceTrackedChangesProtection();
assertTrue(document.isEnforcedTrackedChangesProtection());
document.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestDocumentProtection method testShouldReadEnforcementProperties.
@Test
public void testShouldReadEnforcementProperties() throws IOException {
XWPFDocument documentWithoutDocumentProtectionTag = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedReadonlyProtection());
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedFillingFormsProtection());
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedCommentsProtection());
assertFalse(documentWithoutDocumentProtectionTag.isEnforcedTrackedChangesProtection());
documentWithoutDocumentProtectionTag.close();
XWPFDocument documentWithoutEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection_tag_existing.docx");
assertFalse(documentWithoutEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithoutEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithoutEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithoutEnforcement.isEnforcedTrackedChangesProtection());
documentWithoutEnforcement.close();
XWPFDocument documentWithReadonlyEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_readonly_no_password.docx");
assertTrue(documentWithReadonlyEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithReadonlyEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithReadonlyEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithReadonlyEnforcement.isEnforcedTrackedChangesProtection());
documentWithReadonlyEnforcement.close();
XWPFDocument documentWithFillingFormsEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_forms_no_password.docx");
assertTrue(documentWithFillingFormsEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithFillingFormsEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithFillingFormsEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithFillingFormsEnforcement.isEnforcedTrackedChangesProtection());
documentWithFillingFormsEnforcement.close();
XWPFDocument documentWithCommentsEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_comments_no_password.docx");
assertFalse(documentWithCommentsEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithCommentsEnforcement.isEnforcedReadonlyProtection());
assertTrue(documentWithCommentsEnforcement.isEnforcedCommentsProtection());
assertFalse(documentWithCommentsEnforcement.isEnforcedTrackedChangesProtection());
documentWithCommentsEnforcement.close();
XWPFDocument documentWithTrackedChangesEnforcement = XWPFTestDataSamples.openSampleDocument("documentProtection_trackedChanges_no_password.docx");
assertFalse(documentWithTrackedChangesEnforcement.isEnforcedFillingFormsProtection());
assertFalse(documentWithTrackedChangesEnforcement.isEnforcedReadonlyProtection());
assertFalse(documentWithTrackedChangesEnforcement.isEnforcedCommentsProtection());
assertTrue(documentWithTrackedChangesEnforcement.isEnforcedTrackedChangesProtection());
documentWithTrackedChangesEnforcement.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestDocumentProtection method testShouldEnforceForFillingForms.
@Test
public void testShouldEnforceForFillingForms() throws IOException {
XWPFDocument document = XWPFTestDataSamples.openSampleDocument("documentProtection_no_protection.docx");
assertFalse(document.isEnforcedFillingFormsProtection());
document.enforceFillingFormsProtection();
assertTrue(document.isEnforcedFillingFormsProtection());
document.close();
}
use of org.apache.poi.xwpf.usermodel.XWPFDocument in project poi by apache.
the class TestPackageCorePropertiesGetKeywords method testGetSetKeywords.
public void testGetSetKeywords() throws IOException {
XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("TestPoiXMLDocumentCorePropertiesGetKeywords.docx");
String keywords = doc.getProperties().getCoreProperties().getKeywords();
assertEquals("extractor, test, rdf", keywords);
doc.getProperties().getCoreProperties().setKeywords("test, keywords");
doc = XWPFTestDataSamples.writeOutAndReadBack(doc);
keywords = doc.getProperties().getCoreProperties().getKeywords();
assertEquals("test, keywords", keywords);
}
Aggregations