Author: fanningpj
Date: Wed Jul 20 19:32:28 2022
New Revision: 1902890

URL: http://svn.apache.org/viewvc?rev=1902890&view=rev
Log:
[bug-55330] add setMargin(PageMargin, double)

Modified:
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
    
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Sheet.java

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java?rev=1902890&r1=1902889&r2=1902890&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java 
(original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFSheet.java 
Wed Jul 20 19:32:28 2022
@@ -799,12 +799,33 @@ public class SXSSFSheet implements Sheet
     /**
      * Sets the size of the margin in inches.
      *
-     * @param margin which margin to get
+     * @param margin which margin to set
      * @param size the size of the margin
+     * @see Sheet#LeftMargin
+     * @see Sheet#RightMargin
+     * @see Sheet#TopMargin
+     * @see Sheet#BottomMargin
+     * @see Sheet#HeaderMargin
+     * @see Sheet#FooterMargin
+     * @deprecated use {@link #setMargin(PageMargin, double)} instead
      */
     @Override
+    @Deprecated
+    @Removal(version = "7.0.0")
     public void setMargin(short margin, double size) {
-        _sh.setMargin(margin,size);
+        _sh.setMargin(margin, size);
+    }
+
+    /**
+     * Sets the size of the margin in inches.
+     *
+     * @param margin which margin to set
+     * @param size the size of the margin
+     * @since POI 5.2.3
+     */
+    @Override
+    public void setMargin(PageMargin margin, double size) {
+        _sh.setMargin(margin, size);
     }
 
     /**

Modified: 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1902890&r1=1902889&r2=1902890&view=diff
==============================================================================
--- 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java 
(original)
+++ 
poi/trunk/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java 
Wed Jul 20 19:32:28 2022
@@ -1264,7 +1264,7 @@ public class XSSFSheet extends POIXMLDoc
     /**
      * Sets the size of the margin in inches.
      *
-     * @param margin which margin to get
+     * @param margin which margin to set
      * @param size the size of the margin
      * @see Sheet#LeftMargin
      * @see Sheet#RightMargin
@@ -1272,28 +1272,43 @@ public class XSSFSheet extends POIXMLDoc
      * @see Sheet#BottomMargin
      * @see Sheet#HeaderMargin
      * @see Sheet#FooterMargin
+     * @deprecated use {@link #setMargin(PageMargin, double)} instead
      */
     @Override
+    @Deprecated
+    @Removal(version = "7.0.0")
     public void setMargin(short margin, double size) {
+        setMargin(PageMargin.getByShortValue(margin), size);
+    }
+
+    /**
+     * Sets the size of the margin in inches.
+     *
+     * @param margin which margin to set
+     * @param size the size of the margin
+     * @since POI 5.2.3
+     */
+    @Override
+    public void setMargin(PageMargin margin, double size) {
         CTPageMargins pageMargins = worksheet.isSetPageMargins() ?
                 worksheet.getPageMargins() : worksheet.addNewPageMargins();
         switch (margin) {
-            case LeftMargin:
+            case LEFT:
                 pageMargins.setLeft(size);
                 break;
-            case RightMargin:
+            case RIGHT:
                 pageMargins.setRight(size);
                 break;
-            case TopMargin:
+            case TOP:
                 pageMargins.setTop(size);
                 break;
-            case BottomMargin:
+            case BOTTOM:
                 pageMargins.setBottom(size);
                 break;
-            case HeaderMargin:
+            case HEADER:
                 pageMargins.setHeader(size);
                 break;
-            case FooterMargin:
+            case FOOTER:
                 pageMargins.setFooter(size);
                 break;
             default :

Modified: 
poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=1902890&r1=1902889&r2=1902890&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java 
(original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFSheet.java 
Wed Jul 20 19:32:28 2022
@@ -1341,20 +1341,41 @@ public final class HSSFSheet implements
     /**
      * Sets the size of the margin in inches.
      *
-     * @param margin which margin to get
-     * @param size   the size of the margin
+     * @param margin which margin to set
+     * @param size the size of the margin
+     * @see Sheet#LeftMargin
+     * @see Sheet#RightMargin
+     * @see Sheet#TopMargin
+     * @see Sheet#BottomMargin
+     * @see Sheet#HeaderMargin
+     * @see Sheet#FooterMargin
+     * @deprecated use {@link #setMargin(PageMargin, double)} instead
      */
     @Override
+    @Deprecated
+    @Removal(version = "7.0.0")
     public void setMargin(short margin, double size) {
+        setMargin(PageMargin.getByShortValue(margin), size);
+    }
+
+    /**
+     * Sets the size of the margin in inches.
+     *
+     * @param margin which margin to set
+     * @param size the size of the margin
+     * @since POI 5.2.3
+     */
+    @Override
+    public void setMargin(PageMargin margin, double size) {
         switch (margin) {
-            case FooterMargin:
+            case FOOTER:
                 _sheet.getPageSettings().getPrintSetup().setFooterMargin(size);
                 break;
-            case HeaderMargin:
+            case HEADER:
                 _sheet.getPageSettings().getPrintSetup().setHeaderMargin(size);
                 break;
             default:
-                _sheet.getPageSettings().setMargin(margin, size);
+                _sheet.getPageSettings().setMargin(margin.getLegacyApiValue(), 
size);
         }
     }
 

Modified: poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Sheet.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Sheet.java?rev=1902890&r1=1902889&r2=1902890&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Sheet.java 
(original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/ss/usermodel/Sheet.java Wed Jul 
20 19:32:28 2022
@@ -642,12 +642,24 @@ public interface Sheet extends Iterable<
     /**
      * Sets the size of the margin in inches.
      *
-     * @param margin which margin to get
+     * @param margin which margin to set
      * @param size the size of the margin
+     * @deprecated use {@link #setMargin(PageMargin, double)} instead
      */
+    @Deprecated
+    @Removal(version = "7.0.0")
     void setMargin(short margin, double size);
 
     /**
+     * Sets the size of the margin in inches.
+     *
+     * @param margin which margin to set
+     * @param size the size of the margin
+     * @since POI 5.2.3
+     */
+    void setMargin(PageMargin margin, double size);
+
+    /**
      * Answer whether protection is enabled or disabled
      *
      * @return true =&gt; protection enabled; false =&gt; protection disabled



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to