poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r1295078 - in /poi/trunk/src: documentation/content/xdocs/ ooxml/java/org/apache/poi/xwpf/usermodel/ ooxml/testcases/org/apache/poi/xwpf/
Date Wed, 29 Feb 2012 12:52:55 GMT
Author: yegor
Date: Wed Feb 29 12:52:55 2012
New Revision: 1295078

URL: http://svn.apache.org/viewvc?rev=1295078&view=rev
Log:
Bugzilla 51564 -  support for enforcing fields update in XWPF

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
    poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=1295078&r1=1295077&r2=1295078&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Feb 29 12:52:55 2012
@@ -34,6 +34,8 @@
 
     <changes>
         <release version="3.8-beta6" date="2012-??-??">
+           <action dev="poi-developers" type="add">support setting background color
of sheet tab in XSSF</action>
+           <action dev="poi-developers" type="add">51564 - support for enforcing fields
update in XWPF</action>
            <action dev="poi-developers" type="add">51673 - support grouping rows in
SXSSF</action>
            <action dev="poi-developers" type="add">51780 - support replacement of content
types in OPC packages </action>
            <action dev="poi-developers" type="fix">52784 - replace ISO control characters
with question marks in SXSSF to be consistent with XSSF </action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java?rev=1295078&r1=1295077&r2=1295078&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java Wed Feb 29 12:52:55
2012
@@ -974,6 +974,10 @@ public class XWPFDocument extends POIXML
         return settings.isEnforcedWith(STDocProtect.TRACKED_CHANGES);
     }
 
+    public boolean isEnforcedUpdateFields() {
+        return settings.isUpdateFields();
+    }
+
     /**
      * Enforces the readOnly protection.<br/>
      * In the documentProtection tag inside settings.xml file, <br/>
@@ -1048,6 +1052,22 @@ public class XWPFDocument extends POIXML
     }
 
     /**
+     * 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 enforceUpdateFields() {
+    	settings.setUpdateFields();
+    }
+    
+    /**
      * inserts an existing XWPFTable to the arrays bodyElements and tables
      * @param pos
      * @param table

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java?rev=1295078&r1=1295077&r2=1295078&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSettings.java Wed Feb 29 12:52:55
2012
@@ -30,6 +30,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.openxml4j.opc.PackageRelationship;
 import org.apache.xmlbeans.XmlOptions;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTDocProtect;
+import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTOnOff;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTSettings;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTZoom;
 import org.openxmlformats.schemas.wordprocessingml.x2006.main.STDocProtect;
@@ -147,6 +148,28 @@ public class XWPFSettings extends POIXML
         safeGetDocumentProtection().setEnforcement(STOnOff.X_0);
     }
 
+    /**
+     * 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);
+    }
+
+    boolean isUpdateFields() {
+        return ctSettings.isSetUpdateFields() && ctSettings.getUpdateFields().getVal()
== STOnOff.TRUE;
+    }
+
     @Override
     protected void commit() throws IOException {
         if (ctSettings == null) {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java?rev=1295078&r1=1295077&r2=1295078&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/TestDocumentProtection.java Wed Feb
29 12:52:55 2012
@@ -137,4 +137,11 @@ public class TestDocumentProtection exte
         assertTrue(document.isEnforcedCommentsProtection());
     }
 
+    public void testUpdateFields() throws Exception {
+        XWPFDocument doc = new XWPFDocument();
+        assertFalse(doc.isEnforcedUpdateFields());
+        doc.enforceUpdateFields();
+        assertTrue(doc.isEnforcedUpdateFields());
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message