poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r982269 - in /poi/trunk/src: documentation/content/xdocs/status.xml ooxml/java/org/apache/poi/xssf/model/StylesTable.java ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
Date Wed, 04 Aug 2010 14:40:55 GMT
Author: nick
Date: Wed Aug  4 14:40:54 2010
New Revision: 982269

URL: http://svn.apache.org/viewvc?rev=982269&view=rev
Log:
Fix bug #49702 - Correct XSSFWorkbook.getNumCellStyles to check the right styles list

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=982269&r1=982268&r2=982269&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Aug  4 14:40:54 2010
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.7-beta2" date="2010-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">49702 - Correct XSSFWorkbook.getNumCellStyles
to check the right styles list</action>
            <action dev="POI-DEVELOPERS" type="add">49690 - Add WorkbookUtil, which
provies a way of generating valid sheet names</action>
            <action dev="POI-DEVELOPERS" type="fix">49694 - Use DataFormatter when autosizing
columns, to better match the real display width of formatted cells</action>
            <action dev="POI-DEVELOPERS" type="add">49441 - Allow overriding and guessing
of HSMF non-unicode string encodings</action>

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java?rev=982269&r1=982268&r2=982269&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java Wed Aug  4 14:40:54
2010
@@ -280,7 +280,9 @@ public class StylesTable extends POIXMLD
 	 * get the size of cell styles
 	 */
 	public int getNumCellStyles(){
-		return styleXfs.size();
+        // Each cell style has a unique xfs entry
+        // Several might share the same styleXfs entry
+        return xfs.size();
 	}
 
 	/**

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=982269&r1=982268&r2=982269&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Wed
Aug  4 14:40:54 2010
@@ -271,7 +271,7 @@ public final class TestXSSFWorkbook exte
 	 * Verify that the attached test data was not modified. If this test method
 	 * fails, the test data is not working properly.
 	 */
-	public void test47668() throws Exception {
+	public void testBug47668() throws Exception {
 		XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("47668.xlsx");
 		List<XSSFPictureData> allPictures = workbook.getAllPictures();
 		assertEquals(2, allPictures.size());
@@ -354,4 +354,55 @@ public final class TestXSSFWorkbook exte
 		assertEquals("Numbers", wb.getSheetName(0));
 		assertEquals("Chart", wb.getSheetName(1));
 	}
+	
+	/**
+	 * Problems with the count of the number of styles
+	 *  coming out wrong
+	 */
+	public void testBug49702() throws Exception {
+	    // First try with a new file
+	    XSSFWorkbook wb = new XSSFWorkbook();
+
+	    // Should have one style
+	    assertEquals(1, wb.getNumCellStyles());
+	    wb.getCellStyleAt((short)0);
+	    try {
+	        wb.getCellStyleAt((short)1);
+	        fail("Shouldn't be able to get style at 1 that doesn't exist");
+	    } catch(IndexOutOfBoundsException e) {}
+
+	    // Add another one
+	    CellStyle cs = wb.createCellStyle();
+	    cs.setDataFormat((short)11);
+
+	    // Re-check
+	    assertEquals(2, wb.getNumCellStyles());
+	    wb.getCellStyleAt((short)0);
+	    wb.getCellStyleAt((short)1);
+	    try {
+	        wb.getCellStyleAt((short)2);
+	        fail("Shouldn't be able to get style at 2 that doesn't exist");
+	    } catch(IndexOutOfBoundsException e) {}
+
+	    // Save and reload
+	    XSSFWorkbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
+	    assertEquals(2, nwb.getNumCellStyles());
+	    nwb.getCellStyleAt((short)0);
+	    nwb.getCellStyleAt((short)1);
+	    try {
+	        nwb.getCellStyleAt((short)2);
+	        fail("Shouldn't be able to get style at 2 that doesn't exist");
+	    } catch(IndexOutOfBoundsException e) {}
+
+	    // Now with an existing file
+	    wb = XSSFTestDataSamples.openSampleWorkbook("sample.xlsx");
+	    assertEquals(3, wb.getNumCellStyles());
+	    wb.getCellStyleAt((short)0);
+	    wb.getCellStyleAt((short)1);
+	    wb.getCellStyleAt((short)2);
+	    try {
+	        wb.getCellStyleAt((short)3);
+	        fail("Shouldn't be able to get style at 3 that doesn't exist");
+	    } catch(IndexOutOfBoundsException e) {}
+	}
 }



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


Mime
View raw message