You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by on...@apache.org on 2016/06/12 22:57:37 UTC

svn commit: r1748066 - /poi/branches/ss_border_property_template/src/java/org/apache/poi/ss/util/BorderPropertyTemplate.java

Author: onealj
Date: Sun Jun 12 22:57:37 2016
New Revision: 1748066

URL: http://svn.apache.org/viewvc?rev=1748066&view=rev
Log:
move check if border line style is blank before setting the border color to a helper function for readability

Modified:
    poi/branches/ss_border_property_template/src/java/org/apache/poi/ss/util/BorderPropertyTemplate.java

Modified: poi/branches/ss_border_property_template/src/java/org/apache/poi/ss/util/BorderPropertyTemplate.java
URL: http://svn.apache.org/viewvc/poi/branches/ss_border_property_template/src/java/org/apache/poi/ss/util/BorderPropertyTemplate.java?rev=1748066&r1=1748065&r2=1748066&view=diff
==============================================================================
--- poi/branches/ss_border_property_template/src/java/org/apache/poi/ss/util/BorderPropertyTemplate.java (original)
+++ poi/branches/ss_border_property_template/src/java/org/apache/poi/ss/util/BorderPropertyTemplate.java Sun Jun 12 22:57:37 2016
@@ -584,7 +584,7 @@ public final class BorderPropertyTemplat
         for (int i = firstCol; i <= lastCol; i++) {
             CellAddress cell = new CellAddress(row, i);
             // if BORDER_TOP is not set on BorderPropertyTemplate, make a thin border so that there's something to color
-            if (getTemplateProperty(cell, CellUtil.BORDER_TOP) == null) {
+            if (borderIsNotSetOrBlank(cell, CellUtil.BORDER_TOP)) {
                 drawTopBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN);
             }
             addProperty(cell, CellUtil.TOP_BORDER_COLOR, color);
@@ -606,7 +606,7 @@ public final class BorderPropertyTemplat
         for (int i = firstCol; i <= lastCol; i++) {
             CellAddress cell = new CellAddress(row, i);
             // if BORDER_BOTTOM is not set on BorderPropertyTemplate, make a thin border so that there's something to color
-            if (getTemplateProperty(cell, CellUtil.BORDER_BOTTOM) == null) {
+            if (borderIsNotSetOrBlank(cell, CellUtil.BORDER_BOTTOM)) {
                 drawBottomBorder(new CellRangeAddress(row, row, i, i), BorderStyle.THIN);
             }
             addProperty(cell, CellUtil.BOTTOM_BORDER_COLOR, color);
@@ -628,7 +628,7 @@ public final class BorderPropertyTemplat
         for (int i = firstRow; i <= lastRow; i++) {
             CellAddress cell = new CellAddress(i, col);
             // if BORDER_LEFT is not set on BorderPropertyTemplate, make a thin border so that there's something to color
-            if (getTemplateProperty(cell, CellUtil.BORDER_LEFT) == null) {
+            if (borderIsNotSetOrBlank(cell, CellUtil.BORDER_LEFT)) {
                 drawLeftBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN);
             }
             addProperty(cell, CellUtil.LEFT_BORDER_COLOR, color);
@@ -636,6 +636,15 @@ public final class BorderPropertyTemplat
     }
 
     /**
+     * A helper method to set the border line style before setting the color if the
+     * current line style is not set or is set as NONE
+     */
+    private boolean borderIsNotSetOrBlank(CellAddress cell, String borderDirection) {
+        Object borderLineStyle = getTemplateProperty(cell, borderDirection);
+        return (borderLineStyle == null);
+    }
+
+    /**
      * <p>
      * Sets the color of the right border for a range of cells. If the border is
      * not drawn, it defaults to {@link BorderStyle#THIN}
@@ -651,7 +660,7 @@ public final class BorderPropertyTemplat
         for (int i = firstRow; i <= lastRow; i++) {
             CellAddress cell = new CellAddress(i, col);
             // if BORDER_RIGHT is not set on BorderPropertyTemplate, make a thin border so that there's something to color
-            if (getTemplateProperty(cell, CellUtil.BORDER_RIGHT) == null) {
+            if (borderIsNotSetOrBlank(cell, CellUtil.BORDER_RIGHT)) {
                 drawRightBorder(new CellRangeAddress(i, i, col, col), BorderStyle.THIN);
             }
             addProperty(cell, CellUtil.RIGHT_BORDER_COLOR, color);



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