diff --git a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
index a7cf4dca08..82f545c031 100644
--- a/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
+++ b/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
@@ -919,6 +919,22 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
tables.set(pos, table);
ctDocument.getBody().setTblArray(pos, table.getCTTbl());
}
+
+ /**
+ * Verifies that the documentProtection tag in settings.xml file
+ * specifies that the protection is enforced (w:enforcement="1")
+ *
+ * sample snippet from settings.xml
+ *
+ * <w:settings ... > + * <w:documentProtection w:edit="readOnly" w:enforcement="1"/> + *+ * + * @return true if documentProtection is enforced with option any + */ + public boolean isEnforcedProtection() { + return settings.isEnforcedWith(); + } /** * Verifies that the documentProtection tag in settings.xml file
+ * <w:settings ... > + * <w:documentProtection w:edit="readOnly" w:enforcement="1"/> + *+ * + * @return true if documentProtection is enforced with option any + */ + public boolean isEnforcedWith() { + CTDocProtect ctDocProtect = ctSettings.getDocumentProtection(); + + if (ctDocProtect == null) { + return false; + } + + return ctDocProtect.getEnforcement().equals(STOnOff.X_1); + } /** * Verifies the documentProtection tag inside settings.xml file