/** * Set zoom.<br> * In the zoom tag inside settings.xml file <br> * it sets the value of zoom * <br> * sample snippet from settings.xml * <pre> * <w:zoom w:percent="50" /> * <pre> */ public void setZoomPercent(long zoomPercent) { if (!ctSettings.isSetZoom()) { ctSettings.addNewZoom(); } CTZoom zoom = ctSettings.getZoom(); zoom.setPercent(BigInteger.valueOf(zoomPercent)); }
private CTDocProtect safeGetDocumentProtection() { CTDocProtect documentProtection = ctSettings.getDocumentProtection(); if (documentProtection == null) { documentProtection = CTDocProtect.Factory.newInstance(); ctSettings.setDocumentProtection(documentProtection); } return ctSettings.getDocumentProtection(); }
boolean isUpdateFields() { return ctSettings.isSetUpdateFields() && ctSettings.getUpdateFields().getVal() == STOnOff.TRUE; }
/** * Enable or disable revision tracking. * * @param enable <code>true</code> to turn on revision tracking, <code>false</code> to turn off revision tracking */ public void setTrackRevisions(boolean enable) { if (enable) { if (!ctSettings.isSetTrackRevisions()) { ctSettings.addNewTrackRevisions(); } } else { if (ctSettings.isSetTrackRevisions()) { ctSettings.unsetTrackRevisions(); } } }
/** * Verifies the documentProtection tag inside settings.xml file <br> * if the protection is enforced (w:enforcement="1") <br> * <p> * <br> * sample snippet from settings.xml * <pre> * <w:settings ... > * <w:documentProtection w:edit="readOnly" w:enforcement="1"/> * </pre> * * @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); }
@Override protected void commit() throws IOException { if (ctSettings == null) { throw new IllegalStateException("Unable to write out settings that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTSettings.type.getName().getNamespaceURI(), "settings")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctSettings.save(out, xmlOptions); out.close(); }
/** * Enforces fields update on document open (in Word). * In the settings.xml file <br> * sets the updateSettings value to true (w:updateSettings w:val="true") * <p> * NOTICES: * <ul> * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?" * (if "Update automatic links at open" is enabled)</li> * <li>Flag is removed after saving with changes in Word </li> * </ul> */ public void setUpdateFields() { CTOnOff onOff = CTOnOff.Factory.newInstance(); onOff.setVal(STOnOff.TRUE); ctSettings.setUpdateFields(onOff); }
/** * Enable or disable revision tracking. * * @param enable <code>true</code> to turn on revision tracking, <code>false</code> to turn off revision tracking */ public void setTrackRevisions(boolean enable) { if (enable) { if (!ctSettings.isSetTrackRevisions()) { ctSettings.addNewTrackRevisions(); } } else { if (ctSettings.isSetTrackRevisions()) { ctSettings.unsetTrackRevisions(); } } }
/** * Verifies the documentProtection tag inside settings.xml file <br> * if the protection is enforced (w:enforcement="1") <br> * and if the kind of protection equals to passed (STDocProtect.Enum editValue) <br> * <p> * <br> * sample snippet from settings.xml * <pre> * <w:settings ... > * <w:documentProtection w:edit="readOnly" w:enforcement="1"/> * </pre> * * @return true if documentProtection is enforced with option readOnly */ public boolean isEnforcedWith(STDocProtect.Enum editValue) { CTDocProtect ctDocProtect = ctSettings.getDocumentProtection(); if (ctDocProtect == null) { return false; } return ctDocProtect.getEnforcement().equals(STOnOff.X_1) && ctDocProtect.getEdit().equals(editValue); }
@Override protected void commit() throws IOException { if (ctSettings == null) { throw new IllegalStateException("Unable to write out settings that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTSettings.type.getName().getNamespaceURI(), "settings")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctSettings.save(out, xmlOptions); out.close(); }
/** * Enforces fields update on document open (in Word). * In the settings.xml file <br/> * sets the updateSettings value to true (w:updateSettings w:val="true") * * NOTICES: * <ul> * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?" * (if "Update automatic links at open" is enabled)</li> * <li>Flag is removed after saving with changes in Word </li> * </ul> */ public void setUpdateFields() { CTOnOff onOff = CTOnOff.Factory.newInstance(); onOff.setVal(STOnOff.TRUE); ctSettings.setUpdateFields(onOff); }
/** * Set zoom.<br> * In the zoom tag inside settings.xml file <br> * it sets the value of zoom * <br> * sample snippet from settings.xml * <pre> * <w:zoom w:percent="50" /> * <pre> * * @return percentage as an integer of zoom level */ public long getZoomPercent() { CTZoom zoom; if (!ctSettings.isSetZoom()) { zoom = ctSettings.addNewZoom(); } else { zoom = ctSettings.getZoom(); } BigInteger percent = zoom.getPercent(); if(percent == null) { return 100; } return percent.longValue(); }
private CTDocProtect safeGetDocumentProtection() { CTDocProtect documentProtection = ctSettings.getDocumentProtection(); if (documentProtection == null) { documentProtection = CTDocProtect.Factory.newInstance(); ctSettings.setDocumentProtection(documentProtection); } return ctSettings.getDocumentProtection(); }
boolean isUpdateFields() { return ctSettings.isSetUpdateFields() && ctSettings.getUpdateFields().getVal() == STOnOff.TRUE; }
/** * Verifies the documentProtection tag inside settings.xml file <br> * if the protection is enforced (w:enforcement="1") <br> * <p> * <br> * sample snippet from settings.xml * <pre> * <w:settings ... > * <w:documentProtection w:edit="readOnly" w:enforcement="1"/> * </pre> * * @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); }
@Override protected void commit() throws IOException { if (ctSettings == null) { throw new IllegalStateException("Unable to write out settings that were never read in!"); } XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTSettings.type.getName().getNamespaceURI(), "settings")); Map<String, String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); ctSettings.save(out, xmlOptions); out.close(); }
/** * Enforces fields update on document open (in Word). * In the settings.xml file <br> * sets the updateSettings value to true (w:updateSettings w:val="true") * <p> * NOTICES: * <ul> * <li>Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?" * (if "Update automatic links at open" is enabled)</li> * <li>Flag is removed after saving with changes in Word </li> * </ul> */ public void setUpdateFields() { CTOnOff onOff = CTOnOff.Factory.newInstance(); onOff.setVal(STOnOff.TRUE); ctSettings.setUpdateFields(onOff); }
/** * Set zoom.<br/> * In the zoom tag inside settings.xml file <br/> * it sets the value of zoom * <br/> * sample snippet from settings.xml * <pre> * <w:zoom w:percent="50" /> * <pre> */ public void setZoomPercent(long zoomPercent) { if (! ctSettings.isSetZoom()) { ctSettings.addNewZoom(); } CTZoom zoom = ctSettings.getZoom(); zoom.setPercent(BigInteger.valueOf(zoomPercent)); }
private CTDocProtect safeGetDocumentProtection() { CTDocProtect documentProtection = ctSettings.getDocumentProtection(); if (documentProtection == null) { documentProtection = CTDocProtect.Factory.newInstance(); ctSettings.setDocumentProtection(documentProtection); } return ctSettings.getDocumentProtection(); }
boolean isUpdateFields() { return ctSettings.isSetUpdateFields() && ctSettings.getUpdateFields().getVal() == STOnOff.TRUE; }