poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1762859 - /poi/trunk/src/java/org/apache/poi/ss/util/RegionUtil.java
Date Fri, 30 Sep 2016 07:02:02 GMT
Author: onealj
Date: Fri Sep 30 07:02:02 2016
New Revision: 1762859

URL: http://svn.apache.org/viewvc?rev=1762859&view=rev
Log:
bug 60187: set BorderStyle directly instead of through short code

Modified:
    poi/trunk/src/java/org/apache/poi/ss/util/RegionUtil.java

Modified: poi/trunk/src/java/org/apache/poi/ss/util/RegionUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/RegionUtil.java?rev=1762859&r1=1762858&r2=1762859&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/RegionUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/RegionUtil.java Fri Sep 30 07:02:02 2016
@@ -39,14 +39,17 @@ public final class RegionUtil {
     private static final class CellPropertySetter {
 
         private final String _propertyName;
-        private final Short _propertyValue;
+        private final Object _propertyValue;
 
 
         public CellPropertySetter(String propertyName, int value) {
             _propertyName = propertyName;
             _propertyValue = Short.valueOf((short) value);
         }
-
+        public CellPropertySetter(String propertyName, BorderStyle value) {
+            _propertyName = propertyName;
+            _propertyValue = value;
+        }
 
         public void setProperty(Row row, int column) {
             // create cell if it does not exist
@@ -100,7 +103,14 @@ public final class RegionUtil {
      * @since POI 3.16 beta 1
      */
     public static void setBorderLeft(BorderStyle border, CellRangeAddress region, Sheet sheet)
{
-        setBorderLeft(border.getCode(), region, sheet);
+        int rowStart = region.getFirstRow();
+        int rowEnd = region.getLastRow();
+        int column = region.getFirstColumn();
+
+        CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_LEFT, border);
+        for (int i = rowStart; i <= rowEnd; i++) {
+            cps.setProperty(CellUtil.getRow(i, sheet), column);
+        }
     }
 
     /**
@@ -182,7 +192,14 @@ public final class RegionUtil {
      * @since POI 3.16 beta 1
      */
     public static void setBorderRight(BorderStyle border, CellRangeAddress region, Sheet
sheet) {
-        setBorderRight(border.getCode(), region, sheet);
+        int rowStart = region.getFirstRow();
+        int rowEnd = region.getLastRow();
+        int column = region.getLastColumn();
+
+        CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_RIGHT, border);
+        for (int i = rowStart; i <= rowEnd; i++) {
+            cps.setProperty(CellUtil.getRow(i, sheet), column);
+        }
     }
 
     /**
@@ -264,7 +281,14 @@ public final class RegionUtil {
      * @since POI 3.16 beta 1
      */
     public static void setBorderBottom(BorderStyle border, CellRangeAddress region, Sheet
sheet) {
-        setBorderBottom(border.getCode(), region, sheet);
+        int colStart = region.getFirstColumn();
+        int colEnd = region.getLastColumn();
+        int rowIndex = region.getLastRow();
+        CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_BOTTOM, border);
+        Row row = CellUtil.getRow(rowIndex, sheet);
+        for (int i = colStart; i <= colEnd; i++) {
+            cps.setProperty(row, i);
+        }
     }
 
     /**
@@ -346,7 +370,14 @@ public final class RegionUtil {
      * @since POI 3.16 beta 1
      */
     public static void setBorderTop(BorderStyle border, CellRangeAddress region, Sheet sheet)
{
-       setBorderTop(border.getCode(), region, sheet);
+        int colStart = region.getFirstColumn();
+        int colEnd = region.getLastColumn();
+        int rowIndex = region.getFirstRow();
+        CellPropertySetter cps = new CellPropertySetter(CellUtil.BORDER_TOP, border);
+        Row row = CellUtil.getRow(rowIndex, sheet);
+        for (int i = colStart; i <= colEnd; i++) {
+            cps.setProperty(row, i);
+        }
     }
 
     /**



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


Mime
View raw message