View | Details | Raw Unified | Return to bug 51564
Collapse All | Expand All

(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java (+19 lines)
Lines 30-35 Link Here
30
import org.apache.poi.openxml4j.opc.PackageRelationship;
30
import org.apache.poi.openxml4j.opc.PackageRelationship;
31
import org.apache.xmlbeans.XmlOptions;
31
import org.apache.xmlbeans.XmlOptions;
32
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocProtect;
32
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocProtect;
33
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
33
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSettings;
34
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSettings;
34
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTZoom;
35
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTZoom;
35
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect;
36
import org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect;
Lines 147-152 Link Here
147
        safeGetDocumentProtection().setEnforcement(STOnOff.X_0);
148
        safeGetDocumentProtection().setEnforcement(STOnOff.X_0);
148
    }
149
    }
149
150
151
    /**
152
     * Enforces fields update on document open (in Word).
153
     * In the settings.xml file <br/>
154
     * sets the updateSettings value to true (w:updateSettings w:val="true")
155
     * 
156
     *  NOTICES:
157
     *  <ul>
158
     *  	<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?"
159
     *           (if "Update automatic links at open" is enabled)</li>
160
     *  	<li>Flag is removed after saving with changes in Word </li>
161
     *  </ul> 
162
     */
163
    public void setUpdateFields() {
164
    	CTOnOff onOff = CTOnOff.Factory.newInstance();
165
    	onOff.setVal(STOnOff.TRUE);
166
    	ctSettings.setUpdateFields(onOff);
167
    }
168
    
150
    @Override
169
    @Override
151
    protected void commit() throws IOException {
170
    protected void commit() throws IOException {
152
171
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (+16 lines)
Lines 1016-1021 Link Here
1016
    }
1016
    }
1017
1017
1018
    /**
1018
    /**
1019
     * Enforces fields update on document open (in Word).
1020
     * In the settings.xml file <br/>
1021
     * sets the updateSettings value to true (w:updateSettings w:val="true")
1022
     * 
1023
     *  NOTICES:
1024
     *  <ul>
1025
     *  	<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?"
1026
     *           (if "Update automatic links at open" is enabled)</li>
1027
     *  	<li>Flag is removed after saving with changes in Word </li>
1028
     *  </ul> 
1029
     */
1030
    public void enforceUpdateFields() {
1031
    	settings.setUpdateFields();
1032
    }
1033
    
1034
    /**
1019
     * inserts an existing XWPFTable to the arrays bodyElements and tables
1035
     * inserts an existing XWPFTable to the arrays bodyElements and tables
1020
     * @param pos
1036
     * @param pos
1021
     * @param table
1037
     * @param table

Return to bug 51564