poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r639836 - in /poi/trunk/src/java/org/apache/poi/hssf/usermodel: HSSFCell.java HSSFCellStyle.java HSSFWorkbook.java
Date Fri, 21 Mar 2008 21:04:49 GMT
Author: nick
Date: Fri Mar 21 14:04:47 2008
New Revision: 639836

URL: http://svn.apache.org/viewvc?rev=639836&view=rev
Log:
Tweak how you get dataformat strings out of cell styles, to be more logical, and in keeping
with how we'll want to do things for xssf too

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=639836&r1=639835&r2=639836&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Fri Mar 21 14:04:47 2008
@@ -211,7 +211,7 @@
         }
         ExtendedFormatRecord xf = book.getExFormatAt(cval.getXFIndex());
 
-        setCellStyle(new HSSFCellStyle(( short ) cval.getXFIndex(), xf));
+        setCellStyle(new HSSFCellStyle(( short ) cval.getXFIndex(), xf, book));
     }
 
     /**
@@ -914,7 +914,7 @@
     {
       short styleIndex=record.getXFIndex();
       ExtendedFormatRecord xf = book.getExFormatAt(styleIndex);
-      return new HSSFCellStyle(styleIndex, xf);
+      return new HSSFCellStyle(styleIndex, xf, book);
     }
 
     /**

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=639836&r1=639835&r2=639836&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 Fri Mar 21 14:04:47
2008
@@ -20,7 +20,7 @@
 
 import org.apache.poi.hssf.model.Workbook;
 import org.apache.poi.hssf.record.ExtendedFormatRecord;
-import org.apache.poi.hssf.util.*;
+import org.apache.poi.hssf.util.HSSFColor;
 
 /**
  * High level representation of the style of a cell in a sheet of a workbook.
@@ -38,6 +38,7 @@
 {
     private ExtendedFormatRecord format                     = null;
     private short                index                      = 0;
+    private Workbook             workbook                   = null;
 
     /**
      * general (normal) horizontal alignment
@@ -230,9 +231,13 @@
 
 
     /** Creates new HSSFCellStyle why would you want to do this?? */
-
-    protected HSSFCellStyle(short index, ExtendedFormatRecord rec)
+    protected HSSFCellStyle(short index, ExtendedFormatRecord rec, HSSFWorkbook workbook)
+    {
+    	this(index, rec, workbook.getWorkbook());
+    }
+    protected HSSFCellStyle(short index, ExtendedFormatRecord rec, Workbook workbook)
     {
+        this.workbook = workbook;
         this.index = index;
         format     = rec;
     }
@@ -270,6 +275,16 @@
     
     /**
      * Get the contents of the format string, by looking up
+     *  the DataFormat against the bound workbook
+     * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
+     */
+    public String getDataFormatString() {
+    	HSSFDataFormat format = new HSSFDataFormat(workbook);
+    	
+        return format.getFormat(getDataFormat());
+    }
+    /**
+     * Get the contents of the format string, by looking up
      *  the DataFormat against the supplied workbook
      * @see org.apache.poi.hssf.usermodel.HSSFDataFormat
      */
@@ -289,7 +304,7 @@
     public void setFont(HSSFFont font)
     {
         format.setIndentNotParentFont(true);
-        short fontindex = font.getIndex();
+        short fontindex = ((HSSFFont) font).getIndex();
         format.setFontIndex(fontindex);
     }
 
@@ -309,7 +324,7 @@
      * @see org.apache.poi.hssf.usermodel.HSSFWorkbook#getFontAt(short)
      */
     public HSSFFont getFont(HSSFWorkbook parentWorkbook) {
-    	return parentWorkbook.getFontAt(getFontIndex());
+    	return ((HSSFWorkbook) parentWorkbook).getFontAt(getFontIndex());
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=639836&r1=639835&r2=639836&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Fri Mar 21 14:04:47
2008
@@ -903,7 +903,7 @@
     {
         ExtendedFormatRecord xfr = workbook.createCellXF();
         short index = (short) (getNumCellStyles() - 1);
-        HSSFCellStyle style = new HSSFCellStyle(index, xfr);
+        HSSFCellStyle style = new HSSFCellStyle(index, xfr, this);
 
         return style;
     }
@@ -927,7 +927,7 @@
     public HSSFCellStyle getCellStyleAt(short idx)
     {
         ExtendedFormatRecord xfr = workbook.getExFormatAt(idx);
-        HSSFCellStyle style = new HSSFCellStyle(idx, xfr);
+        HSSFCellStyle style = new HSSFCellStyle(idx, xfr, this);
 
         return style;
     }



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


Mime
View raw message