poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r697584 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java java/org/apache/poi/hssf/usermodel/HSSFPalette.java testcases/org/apache/poi/hssf/data/45492.xls testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Date Sun, 21 Sep 2008 18:56:32 GMT
Author: nick
Date: Sun Sep 21 11:56:32 2008
New Revision: 697584

URL: http://svn.apache.org/viewvc?rev=697584&view=rev
Log:
Test to show that bug #45492 is invalid

Added:
    poi/trunk/src/testcases/org/apache/poi/hssf/data/45492.xls   (with props)
Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=697584&r1=697583&r2=697584&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Sun Sep 21 11:56:32
2008
@@ -913,7 +913,9 @@
     }
 
     /**
-     * get the background fill color
+     * Get the background fill color.
+     * Note - many cells are actually filled with a foreground
+     *  fill, not a background fill - see {@link #getFillForegroundColor()}
      * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
      * @return fill color
      */
@@ -939,7 +941,9 @@
     }
 
     /**
-     * get the foreground fill color
+     * Get the foreground fill color.
+     * Many cells are filled with this, instead of a 
+     *  background color ({@link #getFillBackgroundColor()})
      * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
      * @return fill color
      */

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java?rev=697584&r1=697583&r2=697584&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java Sun Sep 21 11:56:32
2008
@@ -57,6 +57,15 @@
     	}
         return null;
     }
+    /**
+     * Retrieves the color at a given index
+     *
+     * @param index the palette index, between 0x8 to 0x40 inclusive
+     * @return the color, or null if the index is not populated
+     */
+    public HSSFColor getColor(int index) {
+    	return getColor((short)index);
+    }
     
     /**
      * Finds the first occurance of a given color

Added: poi/trunk/src/testcases/org/apache/poi/hssf/data/45492.xls
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/data/45492.xls?rev=697584&view=auto
==============================================================================
Binary file - no diff available.

Propchange: poi/trunk/src/testcases/org/apache/poi/hssf/data/45492.xls
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=697584&r1=697583&r2=697584&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sun Sep 21 11:56:32
2008
@@ -1482,6 +1482,41 @@
     	// This used to break
         HSSFWorkbook wb = openSample("45784.xls");
         assertEquals(1, wb.getNumberOfSheets());
+    }
+    
+   /**
+     * Cell background colours
+     */
+    public void test45492() {
+    	HSSFWorkbook wb = openSample("45492.xls");
+    	HSSFSheet s = wb.getSheetAt(0);
+    	HSSFRow r = s.getRow(0);
+    	HSSFPalette p = wb.getCustomPalette();
+    	
+    	HSSFCell auto = r.getCell(0);
+    	HSSFCell grey = r.getCell(1);
+    	HSSFCell red = r.getCell(2);
+    	HSSFCell blue = r.getCell(3);
+    	HSSFCell green = r.getCell(4);
+    	
+    	assertEquals(64, auto.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, auto.getCellStyle().getFillBackgroundColor());
+    	assertEquals("0:0:0", p.getColor(64).getHexString());
+    	
+    	assertEquals(22, grey.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, grey.getCellStyle().getFillBackgroundColor());
+    	assertEquals("C0C0:C0C0:C0C0", p.getColor(22).getHexString());
+    	
+    	assertEquals(10, red.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, red.getCellStyle().getFillBackgroundColor());
+    	assertEquals("FFFF:0:0", p.getColor(10).getHexString());
+    	
+    	assertEquals(12, blue.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, blue.getCellStyle().getFillBackgroundColor());
+    	assertEquals("0:0:FFFF", p.getColor(12).getHexString());
     	
+    	assertEquals(11, green.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, green.getCellStyle().getFillBackgroundColor());
+    	assertEquals("0:FFFF:0", p.getColor(11).getHexString());
     }
 }



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


Mime
View raw message