poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwool...@apache.org
Subject svn commit: r1817796 - in /poi/trunk/src: examples/src/org/apache/poi/xssf/usermodel/examples/ ooxml/java/org/apache/poi/xssf/usermodel/ ooxml/java/org/apache/poi/xssf/usermodel/extensions/ ooxml/testcases/org/apache/poi/xssf/usermodel/ ooxml/testcases...
Date Mon, 11 Dec 2017 17:30:05 GMT
Author: gwoolsey
Date: Mon Dec 11 17:30:04 2017
New Revision: 1817796

URL: http://svn.apache.org/viewvc?rev=1817796&view=rev
Log:
Bug 61882 - Some paths can create an XSSFColor instance with a null CTColor reference

Protect against this in the future by introducing a factory method to create XSSFColor instances
from a CTColor instance and the associated workbook style indexed color map.

If the CTColor instance is null, the factory returns null.  All callers already are prepared
for a null instance, but many had their own null check on the CTColor object.  This centralizes
that.

This also further forces the requirement for the indexed color map.  Any time a color is created,
the workbook or styleTable is available in the same context, so passing this is extra parameter
is trivial and allows XSSFColor to properly reference custom/themed indexed colors.

Did not remove any methods yet, only deprecated them.  Changed the signature to one internal
test-only constructor.

Modified:
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java
    poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSimpleShape.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java Mon
Dec 11 17:30:04 2017
@@ -140,7 +140,7 @@ public class CalendarDemo {
         XSSFCellStyle style;
         XSSFFont titleFont = wb.createFont();
         titleFont.setFontHeightInPoints((short)48);
-        titleFont.setColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        titleFont.setColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.CENTER);
@@ -149,12 +149,12 @@ public class CalendarDemo {
 
         XSSFFont monthFont = wb.createFont();
         monthFont.setFontHeightInPoints((short)12);
-        monthFont.setColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
+        monthFont.setColor(new XSSFColor(new java.awt.Color(255, 255, 255), wb.getStylesSource().getIndexedColors()));
         monthFont.setBold(true);
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.CENTER);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         style.setFont(monthFont);
         styles.put("month", style);
@@ -165,64 +165,64 @@ public class CalendarDemo {
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.LEFT);
         style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         style.setBorderLeft(BorderStyle.THIN);
-        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setFont(dayFont);
         styles.put("weekend_left", style);
 
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(228, 232, 243), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         style.setBorderRight(BorderStyle.THIN);
-        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         styles.put("weekend_right", style);
 
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.LEFT);
         style.setVerticalAlignment(VerticalAlignment.TOP);
         style.setBorderLeft(BorderStyle.THIN);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
-        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setLeftBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setFont(dayFont);
         styles.put("workday_left", style);
 
         style = wb.createCellStyle();
         style.setAlignment(HorizontalAlignment.CENTER);
         style.setVerticalAlignment(VerticalAlignment.TOP);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(255, 255, 255), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         style.setBorderRight(BorderStyle.THIN);
-        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         styles.put("workday_right", style);
 
         style = wb.createCellStyle();
         style.setBorderLeft(BorderStyle.THIN);
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         styles.put("grey_left", style);
 
         style = wb.createCellStyle();
-        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234)));
+        style.setFillForegroundColor(new XSSFColor(new java.awt.Color(234, 234, 234), wb.getStylesSource().getIndexedColors()));
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         style.setBorderRight(BorderStyle.THIN);
-        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setRightBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         style.setBorderBottom(BorderStyle.THIN);
-        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89)));
+        style.setBottomBorderColor(new XSSFColor(new java.awt.Color(39, 51, 89), wb.getStylesSource().getIndexedColors()));
         styles.put("grey_right", style);
 
         return styles;

Modified: poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
(original)
+++ poi/trunk/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java
Mon Dec 11 17:30:04 2017
@@ -37,17 +37,17 @@ public class WorkingWithRichText {
 
             XSSFFont font1 = wb.createFont();
             font1.setBold(true);
-            font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0)));
+            font1.setColor(new XSSFColor(new java.awt.Color(255, 0, 0), wb.getStylesSource().getIndexedColors()));
             rt.applyFont(0, 10, font1);
 
             XSSFFont font2 = wb.createFont();
             font2.setItalic(true);
             font2.setUnderline(XSSFFont.U_DOUBLE);
-            font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0)));
+            font2.setColor(new XSSFColor(new java.awt.Color(0, 255, 0), wb.getStylesSource().getIndexedColors()));
             rt.applyFont(10, 19, font2);
 
             XSSFFont font3 = wb.createFont();
-            font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255)));
+            font3.setColor(new XSSFColor(new java.awt.Color(0, 0, 255), wb.getStylesSource().getIndexedColors()));
             rt.append(" Jumped over the lazy dog", font3);
 
             cell.setCellValue(rt);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBorderFormatting.java Mon Dec
11 17:30:04 2017
@@ -364,6 +364,6 @@ public class XSSFBorderFormatting implem
     }
     
     private XSSFColor getColor(CTBorderPr pr) {
-        return pr == null ? null : new XSSFColor(pr.getColor(), _colorMap);
+        return pr == null ? null : XSSFColor.from(pr.getColor(), _colorMap);
     }
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Mon Dec 11 17:30:04
2017
@@ -39,6 +39,7 @@ import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorderPr;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellAlignment;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
@@ -755,7 +756,7 @@ public class XSSFCellStyle implements Ce
      */
     @Override
     public void setBottomBorderColor(short color) {
-        XSSFColor clr = new XSSFColor();
+        XSSFColor clr = XSSFColor.from(CTColor.Factory.newInstance(), _stylesSource.getIndexedColors());
         clr.setIndexed(color);
         setBottomBorderColor(clr);
     }
@@ -865,7 +866,7 @@ public class XSSFCellStyle implements Ce
      */
     @Override
     public void setFillBackgroundColor(short bg) {
-        XSSFColor clr = new XSSFColor();
+        XSSFColor clr = XSSFColor.from(CTColor.Factory.newInstance(), _stylesSource.getIndexedColors());
         clr.setIndexed(bg);
         setFillBackgroundColor(clr);
     }
@@ -900,7 +901,7 @@ public class XSSFCellStyle implements Ce
      */
     @Override
     public void setFillForegroundColor(short fg) {
-        XSSFColor clr = new XSSFColor();
+        XSSFColor clr = XSSFColor.from(CTColor.Factory.newInstance(), _stylesSource.getIndexedColors());
         clr.setIndexed(fg);
         setFillForegroundColor(clr);
     }
@@ -1027,7 +1028,7 @@ public class XSSFCellStyle implements Ce
      */
     @Override
     public void setLeftBorderColor(short color) {
-        XSSFColor clr = new XSSFColor();
+        XSSFColor clr = XSSFColor.from(CTColor.Factory.newInstance(), _stylesSource.getIndexedColors());
         clr.setIndexed(color);
         setLeftBorderColor(clr);
     }
@@ -1082,7 +1083,7 @@ public class XSSFCellStyle implements Ce
      */
     @Override
     public void setRightBorderColor(short color) {
-        XSSFColor clr = new XSSFColor();
+        XSSFColor clr = XSSFColor.from(CTColor.Factory.newInstance(), _stylesSource.getIndexedColors());
         clr.setIndexed(color);
         setRightBorderColor(clr);
     }
@@ -1139,7 +1140,7 @@ public class XSSFCellStyle implements Ce
      */
     @Override
     public void setTopBorderColor(short color) {
-        XSSFColor clr = new XSSFColor();
+        XSSFColor clr = XSSFColor.from(CTColor.Factory.newInstance(), _stylesSource.getIndexedColors());
         clr.setIndexed(color);
         setTopBorderColor(clr);
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java Mon Dec 11 17:30:04
2017
@@ -33,6 +33,15 @@ public class XSSFColor extends ExtendedC
     private final IndexedColorMap indexedColorMap;
 
     /**
+     * @param color
+     * @param map
+     * @return null if color is null, new instance otherwise
+     */
+    public static XSSFColor from(CTColor color, IndexedColorMap map) {
+        return color == null ? null : new XSSFColor(color, map);
+    }
+    
+    /**
      * Create an instance of XSSFColor from the supplied XML bean, with default color indexes
      * @param color The {@link CTColor} to use as color-value.
      * @deprecated 3.17 beta 1 - pass the workbook styles indexed color map, if any
@@ -47,7 +56,9 @@ public class XSSFColor extends ExtendedC
      * Create an instance of XSSFColor from the supplied XML bean, with the given color indexes
      * @param color The {@link CTColor} to use as color-value.
      * @param map The IndexedColorMap to use instead of the default one
+     * @deprecated 4.0.0 - use the factory {@link #from(CTColor, IndexedColorMap)} method
instead to check for null CTColor instances.  Make private eventually
      */
+    @Deprecated
     public XSSFColor(CTColor color, IndexedColorMap map) {
         this.ctColor = color;
         this.indexedColorMap = map;
@@ -56,17 +67,31 @@ public class XSSFColor extends ExtendedC
     /**
      * Create an new instance of XSSFColor, without knowledge of any custom indexed colors.
      * This is OK for just transiently setting indexes, etc. but is discouraged in read/get
uses
+     * @deprecated as of 4.0.0, we want to have the indexed map, and all calling contexts
have access to it.
+     * @see #XSSFColor(IndexedColorMap)
+     * @see #from(CTColor, IndexedColorMap)
      */
+    @Deprecated
+    @Removal(version="4.1")
     public XSSFColor() {
-        this(CTColor.Factory.newInstance(), null);
+        this(CTColor.Factory.newInstance(), new DefaultIndexedColorMap());
     }
 
     /**
-     * TEST ONLY - does not know about custom indexed colors
+     * new color with the given indexed color map
+     * @param colorMap
+     */
+    public XSSFColor(IndexedColorMap colorMap) {
+        this(CTColor.Factory.newInstance(), colorMap);
+    }
+    
+    /**
+     * TEST ONLY
      * @param clr awt Color
+     * @param map 
      */
-    public XSSFColor(java.awt.Color clr) {
-        this();
+    public XSSFColor(java.awt.Color clr, IndexedColorMap map) {
+        this(map);
         setColor(clr);
     }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColorScaleFormatting.java Mon
Dec 11 17:30:04 2017
@@ -56,7 +56,7 @@ public class XSSFColorScaleFormatting im
         CTColor[] ctcols = _scale.getColorArray();
         XSSFColor[] c = new XSSFColor[ctcols.length];
         for (int i=0; i<ctcols.length; i++) {
-            c[i] = new XSSFColor(ctcols[i], _indexedColorMap);
+            c[i] = XSSFColor.from(ctcols[i], _indexedColorMap);
         }
         return c;
     }
@@ -89,7 +89,7 @@ public class XSSFColorScaleFormatting im
      * @return color from scale
      */
     public XSSFColor createColor() {
-        return new XSSFColor(_scale.addNewColor(), _indexedColorMap);
+        return XSSFColor.from(_scale.addNewColor(), _indexedColorMap);
     }
     public XSSFConditionalFormattingThreshold createThreshold() {
         return new XSSFConditionalFormattingThreshold(_scale.addNewCfvo());

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCreationHelper.java Mon Dec
11 17:30:04 2017
@@ -54,7 +54,7 @@ public class XSSFCreationHelper implemen
 
     @Override
     public XSSFColor createExtendedColor() {
-        return new XSSFColor(CTColor.Factory.newInstance(), workbook.getStylesSource().getIndexedColors());
+        return XSSFColor.from(CTColor.Factory.newInstance(), workbook.getStylesSource().getIndexedColors());
     }
     
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDataBarFormatting.java Mon
Dec 11 17:30:04 2017
@@ -66,7 +66,7 @@ public class XSSFDataBarFormatting imple
     }
 
     public XSSFColor getColor() {
-        return new XSSFColor(_databar.getColor(), _colorMap);
+        return XSSFColor.from(_databar.getColor(), _colorMap);
     }
     public void setColor(Color color) {
         _databar.setColor( ((XSSFColor)color).getCTColor() );

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java Mon Dec 11 17:30:04
2017
@@ -157,7 +157,7 @@ public class XSSFFont implements Font {
     public XSSFColor getXSSFColor() {
         CTColor ctColor = _ctFont.sizeOfColorArray() == 0 ? null : _ctFont.getColorArray(0);
         if(ctColor != null) {
-           XSSFColor color = new XSSFColor(ctColor, _indexedColorMap);
+           XSSFColor color = XSSFColor.from(ctColor, _indexedColorMap);
            if(_themes != null) {
               _themes.inheritFromThemeAsRequired(color);
            }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java Mon Dec
11 17:30:04 2017
@@ -113,7 +113,7 @@ public class XSSFFontFormatting implemen
     public XSSFColor getFontColor() {
         if(_font.sizeOfColorArray() == 0) return null;
 
-        return new XSSFColor(_font.getColorArray(0), _colorMap);
+        return XSSFColor.from(_font.getColorArray(0), _colorMap);
     }
 
     @Override

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPatternFormatting.java Mon
Dec 11 17:30:04 2017
@@ -39,12 +39,12 @@ public class XSSFPatternFormatting imple
 
     public XSSFColor getFillBackgroundColorColor() {
         if(!_fill.isSetPatternFill()) return null;
-        return new XSSFColor(_fill.getPatternFill().getBgColor(), _colorMap);
+        return XSSFColor.from(_fill.getPatternFill().getBgColor(), _colorMap);
     }
     public XSSFColor getFillForegroundColorColor() {
         if(!_fill.isSetPatternFill() || ! _fill.getPatternFill().isSetFgColor())
             return null;
-        return new XSSFColor(_fill.getPatternFill().getFgColor(), _colorMap);
+        return XSSFColor.from(_fill.getPatternFill().getFgColor(), _colorMap);
     }
 
     public short getFillPattern() {

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Mon Dec 11 17:30:04
2017
@@ -4022,7 +4022,7 @@ public class XSSFSheet extends POIXMLDoc
         if (!pr.isSetTabColor()) {
             return null;
         }
-        return new XSSFColor(pr.getTabColor(), getWorkbook().getStylesSource().getIndexedColors());
+        return XSSFColor.from(pr.getTabColor(), getWorkbook().getStylesSource().getIndexedColors());
     }
     
     /**

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java
Mon Dec 11 17:30:04 2017
@@ -133,7 +133,7 @@ public class XSSFCellBorder {
         CTBorderPr borderPr = getBorder(side);
         
         if(borderPr != null && borderPr.isSetColor()) { 
-            XSSFColor clr = new XSSFColor(borderPr.getColor(), _indexedColorMap);
+            XSSFColor clr = XSSFColor.from(borderPr.getColor(), _indexedColorMap);
             if(_theme != null) {
                _theme.inheritFromThemeAsRequired(clr);
             }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java Mon
Dec 11 17:30:04 2017
@@ -60,7 +60,7 @@ public final class XSSFCellFill {
         if (ptrn == null) return null;
 
         CTColor ctColor = ptrn.getBgColor();
-        return ctColor == null ? null : new XSSFColor(ctColor, _indexedColorMap);
+        return XSSFColor.from(ctColor, _indexedColorMap);
     }
 
     /**
@@ -81,7 +81,11 @@ public final class XSSFCellFill {
      */
     public void setFillBackgroundColor(XSSFColor color) {
         CTPatternFill ptrn = ensureCTPatternFill();
-        ptrn.setBgColor(color.getCTColor());
+        if (color == null) {
+            ptrn.unsetBgColor();
+        } else {
+            ptrn.setBgColor(color.getCTColor());
+        }
     }
 
     /**
@@ -94,7 +98,7 @@ public final class XSSFCellFill {
         if (ptrn == null) return null;
 
         CTColor ctColor = ptrn.getFgColor();
-        return ctColor == null ? null : new XSSFColor(ctColor, _indexedColorMap);
+        return XSSFColor.from(ctColor, _indexedColorMap);
     }
 
     /**
@@ -115,7 +119,11 @@ public final class XSSFCellFill {
      */
     public void setFillForegroundColor(XSSFColor color) {
         CTPatternFill ptrn = ensureCTPatternFill();
-        ptrn.setFgColor(color.getCTColor());
+        if (color == null) {
+            ptrn.unsetFgColor();
+        } else {
+            ptrn.setFgColor(color.getCTColor());
+        }
     }
 
     /**

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Mon Dec
11 17:30:04 2017
@@ -2921,7 +2921,7 @@ public final class TestXSSFBugs extends
         XSSFWorkbook workbook = new XSSFWorkbook();
         XSSFCell cell = workbook.createSheet().createRow(0).createCell(0);
 
-        XSSFColor color = new XSSFColor(java.awt.Color.RED);
+        XSSFColor color = new XSSFColor(java.awt.Color.RED, workbook.getStylesSource().getIndexedColors());
         XSSFCellStyle style = workbook.createCellStyle();
         style.setFillForegroundColor(color);
         style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
@@ -2941,7 +2941,7 @@ public final class TestXSSFBugs extends
         XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(workbook);
         workbook.close();
         XSSFCell ncell = nwb.getSheetAt(0).getRow(0).getCell(0);
-        XSSFColor ncolor = new XSSFColor(java.awt.Color.RED);
+        XSSFColor ncolor = new XSSFColor(java.awt.Color.RED, workbook.getStylesSource().getIndexedColors());
 
         // Now the cell is all black
         XSSFColor nactual = ncell.getCellStyle().getFillBackgroundColorColor();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Mon
Dec 11 17:30:04 2017
@@ -359,7 +359,7 @@ public class TestXSSFCellStyle {
 
         //setting XSSFColor
         num = stylesTable.getBorders().size();
-        clr = new XSSFColor(java.awt.Color.CYAN);
+        clr = new XSSFColor(java.awt.Color.CYAN, stylesTable.getIndexedColors());
         cellStyle.setBottomBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getBottomBorderXSSFColor().getCTColor().toString());
         byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRGB();
@@ -400,7 +400,7 @@ public class TestXSSFCellStyle {
 
         //setting XSSFColor
         num = stylesTable.getBorders().size();
-        clr = new XSSFColor(java.awt.Color.CYAN);
+        clr = new XSSFColor(java.awt.Color.CYAN, stylesTable.getIndexedColors());
         cellStyle.setTopBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getTopBorderXSSFColor().getCTColor().toString());
         byte[] rgb = cellStyle.getTopBorderXSSFColor().getRGB();
@@ -441,7 +441,7 @@ public class TestXSSFCellStyle {
 
         //setting XSSFColor
         num = stylesTable.getBorders().size();
-        clr = new XSSFColor(java.awt.Color.CYAN);
+        clr = new XSSFColor(java.awt.Color.CYAN, stylesTable.getIndexedColors());
         cellStyle.setLeftBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getLeftBorderXSSFColor().getCTColor().toString());
         byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRGB();
@@ -482,7 +482,7 @@ public class TestXSSFCellStyle {
 
         //setting XSSFColor
         num = stylesTable.getBorders().size();
-        clr = new XSSFColor(java.awt.Color.CYAN);
+        clr = new XSSFColor(java.awt.Color.CYAN, stylesTable.getIndexedColors());
         cellStyle.setRightBorderColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getRightBorderXSSFColor().getCTColor().toString());
         byte[] rgb = cellStyle.getRightBorderXSSFColor().getRGB();
@@ -523,7 +523,7 @@ public class TestXSSFCellStyle {
 
         //setting XSSFColor
         num = stylesTable.getFills().size();
-        clr = new XSSFColor(java.awt.Color.CYAN);
+        clr = new XSSFColor(java.awt.Color.CYAN, stylesTable.getIndexedColors());
         cellStyle.setFillBackgroundColor(clr);
         assertEquals(clr.getCTColor().toString(), cellStyle.getFillBackgroundXSSFColor().getCTColor().toString());
         byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRGB();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFConditionalFormatting.java
Mon Dec 11 17:30:04 2017
@@ -70,7 +70,7 @@ public class TestXSSFConditionalFormatti
 
     @Test
     public void testFontFormattingColor() {
-        Workbook wb = XSSFITestDataProvider.instance.createWorkbook();
+        XSSFWorkbook wb = XSSFITestDataProvider.instance.createWorkbook();
         final Sheet sheet = wb.createSheet();
 
         final SheetConditionalFormatting formatting = sheet.getSheetConditionalFormatting();
@@ -101,7 +101,7 @@ public class TestXSSFConditionalFormatti
         assertEquals(-1, fontFmt.getFontColorIndex());
 
         //fontFmt.setFontColorIndex((short)11);
-        final ExtendedColor extendedColor = new XSSFColor(PEAK_ORANGE);
+        final ExtendedColor extendedColor = new XSSFColor(PEAK_ORANGE, wb.getStylesSource().getIndexedColors());
         fontFmt.setFontColor(extendedColor);
 
         PatternFormatting patternFmt = formattingRule.createPatternFormatting();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDrawing.java Mon Dec
11 17:30:04 2017
@@ -223,7 +223,7 @@ public class TestXSSFDrawing {
         XSSFRichTextString rt = new XSSFRichTextString("Test String");
 
         XSSFFont font = wb.createFont();
-        font.setColor(new XSSFColor(new Color(0, 128, 128)));
+        font.setColor(new XSSFColor(new Color(0, 128, 128), wb.getStylesSource().getIndexedColors()));
         font.setItalic(true);
         font.setBold(true);
         font.setUnderline(FontUnderline.SINGLE);
@@ -297,7 +297,7 @@ public class TestXSSFDrawing {
         XSSFRichTextString rt = new XSSFRichTextString("Test String");
 
         XSSFFont font = wb.createFont();
-        font.setColor(new XSSFColor(new Color(0, 128, 128)));
+        font.setColor(new XSSFColor(new Color(0, 128, 128), wb.getStylesSource().getIndexedColors()));
         font.setFontName("Arial");
         rt.applyFont(font);
 
@@ -328,7 +328,7 @@ public class TestXSSFDrawing {
         XSSFRichTextString rt = new XSSFRichTextString("Test String");
 
         XSSFFont font = wb.createFont();
-        font.setColor(new XSSFColor(new Color(0, 255, 255)));
+        font.setColor(new XSSFColor(new Color(0, 255, 255), wb.getStylesSource().getIndexedColors()));
         font.setFontName("Arial");
         rt.applyFont(font);
 
@@ -389,12 +389,12 @@ public class TestXSSFDrawing {
         XSSFRichTextString rt = new XSSFRichTextString("Test Rich Text String");
 
         XSSFFont font = wb1.createFont();
-        font.setColor(new XSSFColor(new Color(0, 255, 255)));
+        font.setColor(new XSSFColor(new Color(0, 255, 255), wb1.getStylesSource().getIndexedColors()));
         font.setFontName("Arial");
         rt.applyFont(font);
 
         XSSFFont midfont = wb1.createFont();
-        midfont.setColor(new XSSFColor(new Color(0, 255, 0)));
+        midfont.setColor(new XSSFColor(new Color(0, 255, 0), wb1.getStylesSource().getIndexedColors()));
         rt.applyFont(5, 14, midfont);	// set the text "Rich Text" to be green and the default
font
 
         XSSFTextParagraph para = shape.addNewTextParagraph(rt);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java Mon Dec
11 17:30:04 2017
@@ -256,7 +256,7 @@ public final class TestXSSFFont extends
 		
 		byte[] bytes = Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
         color.setRgb(bytes);
-		XSSFColor newColor=new XSSFColor(color, null);
+		XSSFColor newColor=XSSFColor.from(color, null);
 		xssfFont.setColor(newColor);
 		assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRGB()[2]);
 		

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Mon Dec
11 17:30:04 2017
@@ -71,6 +71,7 @@ import org.junit.Test;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIgnoredError;
@@ -1924,7 +1925,7 @@ public final class TestXSSFSheet extends
             assertEquals(expected, wb.getSheet("indexedRed").getTabColor());
 
             // test regular-colored (non-indexed, ARGB) sheet
-            expected = new XSSFColor();
+            expected = XSSFColor.from(CTColor.Factory.newInstance(), wb.getStylesSource().getIndexedColors());
             expected.setARGBHex("FF7F2700");
             assertEquals(expected, wb.getSheet("customOrange").getTabColor());
         }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSimpleShape.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSimpleShape.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSimpleShape.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSimpleShape.java Mon
Dec 11 17:30:04 2017
@@ -38,7 +38,7 @@ public class TestXSSFSimpleShape {
             
             XSSFFont font = wb.createFont();
             Color color = new Color(0, 255, 255);
-            font.setColor(new XSSFColor(color));
+            font.setColor(new XSSFColor(color, wb.getStylesSource().getIndexedColors()));
             font.setFontName("Arial");
             rt.applyFont(font);
     

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFTextParagraph.java
Mon Dec 11 17:30:04 2017
@@ -37,7 +37,7 @@ public class TestXSSFTextParagraph {
     
             XSSFFont font = wb.createFont();
             Color color = new Color(0, 255, 255);
-            font.setColor(new XSSFColor(color));
+            font.setColor(new XSSFColor(color, wb.getStylesSource().getIndexedColors()));
             font.setFontName("Arial");
             rt.applyFont(font);
     

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java?rev=1817796&r1=1817795&r2=1817796&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/extensions/TestXSSFCellFill.java
Mon Dec 11 17:30:04 2017
@@ -20,12 +20,14 @@ package org.apache.poi.xssf.usermodel.ex
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.io.IOException;
 
 import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.xssf.XSSFTestDataSamples;
 import org.apache.poi.xssf.usermodel.XSSFCell;
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFColor;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.Test;
@@ -98,4 +100,14 @@ public class TestXSSFCellFill {
         assertEquals(rgbWithTint[2],-80);
         wb.close();
     }
+    
+    @Test
+    public void testFillWithoutColors() {
+        XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("FillWithoutColor.xlsx");
+        XSSFCell cellWithFill = wb.getSheetAt(0).getRow(5).getCell(1);
+        XSSFCellStyle style = cellWithFill.getCellStyle();
+        assertNotNull(style);
+        assertNull("had an empty background color", style.getFillBackgroundColorColor());
+        assertNull("had an empty background color", style.getFillBackgroundXSSFColor());
+    }
 }



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


Mime
View raw message