poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1837093 - in /poi/trunk/src/ooxml: java/org/apache/poi/xwpf/usermodel/XWPFDocument.java java/org/apache/poi/xwpf/usermodel/XWPFSettings.java testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
Date Mon, 30 Jul 2018 22:23:25 GMT
Author: fanningpj
Date: Mon Jul 30 22:23:25 2018
New Revision: 1837093

URL: http://svn.apache.org/viewvc?rev=1837093&view=rev
Log:
[github-118] Added get/set for mirror margins setting. This closes #118

Modified:
    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/usermodel/TestXWPFDocument.java

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=1837093&r1=1837092&r2=1837093&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 Mon Jul 30 22:23:25
2018
@@ -1339,6 +1339,40 @@ public class XWPFDocument extends POIXML
     }
 
     /**
+     * Returns the even-and-odd-headings setting
+     *
+     * @return True or false indicating whether or not separate even and odd headings is
turned on.
+     */
+    public boolean getEvenAndOddHeadings() {
+        return settings.getEvenAndOddHeadings();
+    }
+    
+    /**
+     * Sets the even-and-odd-headings setting
+     * @param enable Set to true to turn on separate even and odd headings.
+     */
+    public void setEvenAndOddHeadings(boolean enable) {
+        settings.setEvenAndOddHeadings(enable);
+    }
+    
+    /**
+     * Returns the mirror margins setting
+     *
+     * @return True or false indicating whether or not mirror margins is turned on.
+     */
+    public boolean getMirrorMargins() {
+        return settings.getMirrorMargins();
+    }
+    
+    /**
+     * Sets the mirror margins setting
+     * @param enable Set to true to turn on mirror margins.
+     */
+    public void setMirrorMargins(boolean enable) {
+        settings.setMirrorMargins(enable);
+    }
+    
+    /**
      * inserts an existing XWPFTable to the arrays bodyElements and tables
      *
      * @param pos
@@ -1758,4 +1792,5 @@ public class XWPFDocument extends POIXML
             return false;
         }
     }
+
 }

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=1837093&r1=1837092&r2=1837093&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 Mon Jul 30 22:23:25
2018
@@ -430,4 +430,48 @@ public class XWPFSettings extends POIXML
             throw new RuntimeException(e);
         }
     }
+
+    /**
+     * Check if separate even and odd headings is turned on.
+     *
+     * @return True if even and odd headings is turned on.
+     */
+    public boolean getEvenAndOddHeadings() {
+        return ctSettings.isSetEvenAndOddHeaders();
+    }
+
+    /**
+     * Turn separate even-and-odd headings on or off
+     *
+     * @param enable <code>true</code> to turn on separate even and odd headings,

+     * <code>false</code> to turn off even and odd headings.
+     */
+    public void setEvenAndOddHeadings(boolean enable) {
+        CTOnOff onOff = CTOnOff.Factory.newInstance();
+        onOff.setVal(enable ? STOnOff.TRUE : STOnOff.FALSE);
+        ctSettings.setEvenAndOddHeaders(onOff);
+    }
+
+    /**
+     * Check if mirrored margins is turned on
+     *
+     * @return True if mirrored margins is turned on.
+     */
+    public boolean getMirrorMargins() {
+        return ctSettings.isSetMirrorMargins();
+    }
+
+    /**
+     * Turn mirrored margins on or off
+     *
+     * @param enable <code>true</code> to turn on mirrored margins, 
+     * <code>false</code> to turn off mirrored marginss.
+     */
+    public void setMirrorMargins(boolean enable) {
+        CTOnOff onOff = CTOnOff.Factory.newInstance();
+        onOff.setVal(enable ? STOnOff.TRUE : STOnOff.FALSE);
+        ctSettings.setMirrorMargins(onOff);
+    }
+
+
 }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java?rev=1837093&r1=1837092&r2=1837093&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xwpf/usermodel/TestXWPFDocument.java Mon
Jul 30 22:23:25 2018
@@ -402,6 +402,14 @@ public final class TestXWPFDocument {
         assertEquals(100, settings.getZoomPercent());
         settings.setZoomPercent(50);
         assertEquals(50, settings.getZoomPercent());
+        
+        assertEquals(false, settings.getEvenAndOddHeadings());
+        settings.setEvenAndOddHeadings(true);
+        assertEquals(true, settings.getEvenAndOddHeadings());
+
+        assertEquals(false, settings.getMirrorMargins());
+        settings.setMirrorMargins(true);
+        assertEquals(true, settings.getMirrorMargins());
 
         XWPFDocument doc = new XWPFDocument();
         assertEquals(100, doc.getZoomPercent());
@@ -412,6 +420,14 @@ public final class TestXWPFDocument {
         doc.setZoomPercent(200);
         assertEquals(200, doc.getZoomPercent());
 
+        assertEquals(false, doc.getEvenAndOddHeadings());
+        doc.setEvenAndOddHeadings(true);
+        assertEquals(true, doc.getEvenAndOddHeadings());
+
+        assertEquals(false, doc.getMirrorMargins());
+        doc.setMirrorMargins(true);
+        assertEquals(true, doc.getMirrorMargins());
+
         XWPFDocument back = XWPFTestDataSamples.writeOutAndReadBack(doc);
         assertEquals(200, back.getZoomPercent());
         back.close();



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


Mime
View raw message