You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2008/09/15 13:02:20 UTC

svn commit: r695420 - in /poi/trunk/src: documentation/content/xdocs/changes.xml documentation/content/xdocs/status.xml java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java

Author: nick
Date: Mon Sep 15 04:02:18 2008
New Revision: 695420

URL: http://svn.apache.org/viewvc?rev=695420&view=rev
Log:
Finish exposing the name of Named Cell Styles via HSSFCellStyle (normally held on the parent style though)

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=695420&r1=695419&r2=695420&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Mon Sep 15 04:02:18 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">Expose the name of Named Cell Styles via HSSFCellStyle (normally held on the parent style though)</action>
            <action dev="POI-DEVELOPERS" type="fix">45978 - Fixed IOOBE in Ref3DPtg.toFormulaString() due eager initialisation of SheetReferences</action>
            <action dev="POI-DEVELOPERS" type="add">Made HSSFFormulaEvaluator no longer require initialisation with sheet or row</action>
            <action dev="POI-DEVELOPERS" type="add">Extended support for cached results of formula cells</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=695420&r1=695419&r2=695420&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Sep 15 04:02:18 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">Expose the name of Named Cell Styles via HSSFCellStyle (normally held on the parent style though)</action>
            <action dev="POI-DEVELOPERS" type="fix">45978 - Fixed IOOBE in Ref3DPtg.toFormulaString() due eager initialisation of SheetReferences</action>
            <action dev="POI-DEVELOPERS" type="add">Made HSSFFormulaEvaluator no longer require initialisation with sheet or row</action>
            <action dev="POI-DEVELOPERS" type="add">Extended support for cached results of formula cells</action>

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=695420&r1=695419&r2=695420&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 Mon Sep 15 04:02:18 2008
@@ -254,6 +254,22 @@
     {
         return index;
     }
+    
+    /**
+     * Return the parent style for this cell style.
+     * In most cases this will be null, but in a few
+     *  cases there'll be a fully defined parent.
+     */
+    public HSSFCellStyle getParentStyle() {
+    	if(format.getParentIndex() == 0) {
+    		return null;
+    	}
+    	return new HSSFCellStyle(
+    			format.getParentIndex(),
+    			workbook.getExFormatAt(format.getParentIndex()),
+    			workbook
+    	);
+    }
 
     /**
      * set the data format (must be a valid format)

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java?rev=695420&r1=695419&r2=695420&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java Mon Sep 15 04:02:18 2008
@@ -334,10 +334,28 @@
     	assertEquals(23, cs2.getIndex());
     	assertEquals(24, cs3.getIndex());
     	
+    	assertNull(cs1.getParentStyle());
+    	assertNotNull(cs2.getParentStyle());
+    	assertNotNull(cs3.getParentStyle());
+    	
+    	assertEquals(21, cs2.getParentStyle().getIndex());
+    	assertEquals(22, cs3.getParentStyle().getIndex());
+    	
+    	// Now check we can get style records for 
+    	//  the parent ones
+    	assertNull(wb.getWorkbook().getStyleRecord(15));
+    	assertNull(wb.getWorkbook().getStyleRecord(23));
+    	assertNull(wb.getWorkbook().getStyleRecord(24));
+    	
+    	assertNotNull(wb.getWorkbook().getStyleRecord(21));
+    	assertNotNull(wb.getWorkbook().getStyleRecord(22));
+    	
     	// Now check the style names
-//    	assertEquals(null, cs1.getUserStyleName());
-//    	assertEquals("style1", cs2.getUserStyleName());
-//    	assertEquals("style2", cs3.getUserStyleName());
+    	assertEquals(null, cs1.getUserStyleName());
+    	assertEquals(null, cs2.getUserStyleName());
+    	assertEquals(null, cs3.getUserStyleName());
+    	assertEquals("style1", cs2.getParentStyle().getUserStyleName());
+    	assertEquals("style2", cs3.getParentStyle().getUserStyleName());
     }
 
     public static void main(String [] ignored_args)



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