/** * Enforces the protection with the option specified by passed editValue, password, and * HashAlgorithm for the password. * * @param editValue the protection type * @param password the plaintext password, if null no password will be applied * @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported. * if null, it will default default to sha512 (like Word 2013) * @since 3.3.0 */ public void protectRestrictEditing(org.docx4j.wml.STDocProtect editValue, String password, HashAlgorithm hashAlgo) { safeGetDocumentProtection().setEnforcement(true); safeGetDocumentProtection().setEdit(editValue); // Word 2010 doesn't enforce TRACKED_CHANGES, // unless <w:trackRevisions/> is also set! if (editValue==STDocProtect.TRACKED_CHANGES) { if (this.jaxbElement.getTrackRevisions()==null) { this.jaxbElement.setTrackRevisions(new BooleanDefaultTrue()); } } setProtectionPassword(password, hashAlgo); }
/** * Enforces the protection with the option specified by passed editValue, password, and * HashAlgorithm for the password. * * @param editValue the protection type * @param password the plaintext password, if null no password will be applied * @param hashAlgo the hash algorithm - only md2, m5, sha1, sha256, sha384 and sha512 are supported. * if null, it will default default to sha512 (like Word 2013) * @since 3.3.0 */ public void protectRestrictEditing(org.docx4j.wml.STDocProtect editValue, String password, HashAlgorithm hashAlgo) { safeGetDocumentProtection().setEnforcement(true); safeGetDocumentProtection().setEdit(editValue); // Word 2010 doesn't enforce TRACKED_CHANGES, // unless <w:trackRevisions/> is also set! if (editValue==STDocProtect.TRACKED_CHANGES) { if (this.jaxbElement.getTrackRevisions()==null) { this.jaxbElement.setTrackRevisions(new BooleanDefaultTrue()); } } setProtectionPassword(password, hashAlgo); }