]> source.dussan.org Git - poi.git/commitdiff
Finish exposing the name of Named Cell Styles via HSSFCellStyle (normally held on...
authorNick Burch <nick@apache.org>
Mon, 15 Sep 2008 11:02:18 +0000 (11:02 +0000)
committerNick Burch <nick@apache.org>
Mon, 15 Sep 2008 11:02:18 +0000 (11:02 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@695420 13f79535-47bb-0310-9956-ffa450edef68

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

index 5ce7097f263f6d04b01dec4e72d6bf9e491a920d..a43864184ad2368b54863fcbc8dd36e256b6e3be 100644 (file)
@@ -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>
index 926986edbb413b51380dc7da590824f7148404c4..965ceeefa57f564194316d70dccd4bbda0fbdc61 100644 (file)
@@ -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>
index f74c38d09ea9c5cfa84ecc1f17a1fccb748bd429..2afd16d8d1bdae7b4e97c808fa51ba068f19412f 100644 (file)
@@ -254,6 +254,22 @@ public class HSSFCellStyle
     {
         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)
index e2783b4434cc4cdf4b35a416b752d68b9f2b27af..a4cf005a0c2dbbe055392724e5fddb17693f8f83 100644 (file)
@@ -334,10 +334,28 @@ public class TestCellStyle
        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)