poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ye...@apache.org
Subject svn commit: r706691 - in /poi/branches/ooxml/src: examples/jsp/ examples/src/org/apache/poi/ss/usermodel/examples/ examples/src/org/apache/poi/xssf/usermodel/examples/ ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/ ooxml/java/org/apache/poi/xssf/u...
Date Tue, 21 Oct 2008 17:56:46 GMT
Author: yegor
Date: Tue Oct 21 10:56:34 2008
New Revision: 706691

URL: http://svn.apache.org/viewvc?rev=706691&view=rev
Log:
1. implemented XSSFSheet.autosizeColumn(), for now mostly duplicated HSSF code, will be refactored in future.2. fixed bug #45974: XSSFCell.getCellStyle can return null3. more code cleanup and reaftoring, removed usages of obsolete XSSFCell.getCellNum() in favor of XSSFCell.getColumnIndex(), also more javadoc in core classes
4. fixed a blocker: calling XSSFSheet.getNumMergedRegions() resulted in unreadable workbook, this methods structurally modified worksheet and added unnecessary data 

Modified:
    poi/branches/ooxml/src/examples/jsp/HSSFExample.jsp
    poi/branches/ooxml/src/examples/src/org/apache/poi/ss/usermodel/examples/FromQuickGuide.java
    poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java
    poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java
    poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
    poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFAnchor.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
    poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDialogSheet.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
    poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java

Modified: poi/branches/ooxml/src/examples/jsp/HSSFExample.jsp
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/jsp/HSSFExample.jsp?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/jsp/HSSFExample.jsp (original)
+++ poi/branches/ooxml/src/examples/jsp/HSSFExample.jsp Tue Oct 21 10:56:34 2008
@@ -92,7 +92,7 @@
 %>									
                                     <%= "CELL col=" 
 									
-	+ cell.getCellNum()
+	+ cell.getColumnIndex()
                                         + " VALUE=" + value %>
 <%
                                 } 

Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/ss/usermodel/examples/FromQuickGuide.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/ss/usermodel/examples/FromQuickGuide.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/ss/usermodel/examples/FromQuickGuide.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/ss/usermodel/examples/FromQuickGuide.java Tue Oct 21 10:56:34 2008
@@ -143,7 +143,7 @@
 	public static void getCellContents(Sheet sheet) {
 	    for (Row row : sheet) {
 	        for (Cell cell : row) {
-	        	CellReference cellRef = new CellReference(row.getRowNum(), cell.getCellNum());
+	        	CellReference cellRef = new CellReference(row.getRowNum(), cell.getColumnIndex());
 	        	System.out.print(cellRef.formatAsString());
 	        	System.out.print(" - ");
 	        	

Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java Tue Oct 21 10:56:34 2008
@@ -28,7 +28,7 @@
 public class IterateCells {
 
     public static void main(String[] args) throws Exception {
-        Workbook wb = new XSSFWorkbook(args[0]);
+        Workbook wb = null;
         for (int i = 0; i < wb.getNumberOfSheets(); i++) {
             Sheet sheet = wb.getSheetAt(i);
             System.out.println(wb.getSheetName(i));

Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Row.java Tue Oct 21 10:56:34 2008
@@ -45,12 +45,12 @@
      *
      * @param column - the column number this cell represents
      *
-     * @return HSSFCell a high level representation of the created cell.
+     * @return Cell a high level representation of the created cell.
      */
     Cell createCell(int column, int type);
 
     /**
-     * remove the HSSFCell from this row.
+     * remove the Cell from this row.
      * @param cell to remove
      */
     void removeCell(Cell cell);
@@ -71,7 +71,7 @@
     int getRowNum();
 
     /**
-     * get the hssfcell representing a given column (logical cell) 0-based.  If you
+     * get the cell representing a given column (logical cell) 0-based.  If you
      * ask for a cell that is not defined....you get a null.
      *
      * @param cellnum  0 based column number
@@ -80,7 +80,7 @@
     Cell getCell(int cellnum);
     
     /**
-     * Get the hssfcell representing a given column (logical cell)
+     * Get the cell representing a given column (logical cell)
      *  0-based.  If you ask for a cell that is not defined, then
      *  your supplied policy says what to do
      *
@@ -158,12 +158,6 @@
      */
     Iterator<Cell> cellIterator();
 
-	/**
-	 * Alias for {@link #cellIterator()} to allow
-	 * foreach loops
-	 */
-	Iterator<Cell> iterator();
-
     /**
      * Used to specify the different possible policies
      *  if for the case of null and blank cells

Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Sheet.java Tue Oct 21 10:56:34 2008
@@ -19,7 +19,6 @@
 
 import java.util.Iterator;
 
-import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.util.PaneInformation;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.Region;
@@ -27,13 +26,17 @@
 public interface Sheet extends Iterable<Row> {
 
     /* Constants for margins */
-    public static final short LeftMargin = Sheet.LeftMargin;
+    public static final short LeftMargin = 0;
 
-    public static final short RightMargin = Sheet.RightMargin;
+    public static final short RightMargin = 1;
 
-    public static final short TopMargin = Sheet.TopMargin;
+    public static final short TopMargin = 2;
 
-    public static final short BottomMargin = Sheet.BottomMargin;
+    public static final short BottomMargin = 3;
+
+    public static final short HeaderMargin = 4;
+
+    public static final short FooterMargin = 5;
 
     public static final byte PANE_LOWER_RIGHT = (byte) 0;
 
@@ -57,7 +60,7 @@
      * @param rownum  row number
      * @return High level HSSFRow object representing a row in the sheet
      * @see org.apache.poi.hssf.usermodel.HSSFRow
-     * @see #removeRow(HSSFRow)
+     * @see #removeRow(Row)
      */
     Row createRow(int rownum);
 
@@ -246,12 +249,6 @@
      * be the third row if say for instance the second row is undefined.
      */
     Iterator<Row> rowIterator();
-    
-    /**
-     * Alias for {@link #rowIterator()} to allow 
-     *  foreach loops
-     */
-    Iterator<Row> iterator();
 
     /**
      * whether alternate expression evaluation is on
@@ -275,13 +272,6 @@
     void setAutobreaks(boolean b);
 
     /**
-     * set whether sheet is a dialog sheet or not
-     * @param b  isDialog or not
-     */
-
-    void setDialog(boolean b);
-
-    /**
      * set whether to display the guts or not
      *
      * @param b  guts or no guts (or glory)
@@ -332,13 +322,6 @@
     boolean getAutobreaks();
 
     /**
-     * get whether sheet is a dialog sheet or not
-     * @return isDialog or not
-     */
-
-    boolean getDialog();
-
-    /**
      * get whether to display the guts or not
      *
      * @return guts or no guts (or glory)

Modified: poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java (original)
+++ poi/branches/ooxml/src/ooxml/interfaces-jdk15/org/apache/poi/ss/usermodel/Workbook.java Tue Oct 21 10:56:34 2008
@@ -172,22 +172,6 @@
     void removeSheetAt(int index);
     
     /**
-     * determine whether the Excel GUI will backup the workbook when saving.
-     *
-     * @param backupValue   true to indicate a backup will be performed.
-     */
-
-    void setBackupFlag(boolean backupValue);
-
-    /**
-     * determine whether the Excel GUI will backup the workbook when saving.
-     *
-     * @return the current setting for backups.
-     */
-
-    boolean getBackupFlag();
-
-    /**
      * Sets the repeating rows and columns for a sheet (as found in
      * File->PageSetup->Sheet).  This is function is included in the workbook
      * because it creates/modifies name records which are stored at the
@@ -337,7 +321,7 @@
 	 * Sets the policy on what to do when
 	 *  getting missing or blank cells from a row.
 	 * This will then apply to all calls to 
-	 *  {@link Row.getCell()}. See
+	 *  {@link Row#getCell(int)} }. See
 	 *  {@link MissingCellPolicy}
 	 */
 	void setMissingCellPolicy(MissingCellPolicy missingCellPolicy);
@@ -392,21 +376,9 @@
     List getAllPictures();
 
     /**
-     * protect a workbook with a password (not encypted, just sets writeprotect
-     * flags and the password.
-     * @param password to set
-     */
-    void writeProtectWorkbook(String password, String username);
-
-    /**
-     * removes the write protect flag
-     */
-    void unwriteProtectWorkbook();
-
-    /**
      * Gets all embedded OLE2 objects from the Workbook.
      *
-     * @return the list of embedded objects (a list of {@link HSSFObjectData} objects.)
+     * @return the list of embedded objects
      */
     List getAllEmbeddedObjects();
 

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFAnchor.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFAnchor.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFAnchor.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFAnchor.java Tue Oct 21 10:56:34 2008
@@ -23,5 +23,14 @@
  * @author Yegor Kozlov
  */
 public abstract class XSSFAnchor {
+    
+    public abstract int getDx1();
+    public abstract void setDx1( int dx1 );
+    public abstract int getDy1();
+    public abstract void setDy1( int dy1 );
+    public abstract int getDy2();
+    public abstract void setDy2( int dy2 );
+    public abstract int getDx2();
+    public abstract void setDx2( int dx2 );
 
 }

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Tue Oct 21 10:56:34 2008
@@ -90,7 +90,7 @@
     }
 
     public Comment getCellComment() {
-        return row.getSheet().getCellComment(row.getRowNum(), getCellNum());
+        return row.getSheet().getCellComment(row.getRowNum(), getColumnIndex());
     }
 
     public String getCellFormula() {
@@ -113,12 +113,15 @@
 		return row.getRowNum();
 	}
 
+    /**
+     * Return the cell's style.
+     *
+     * @return the cell's style. Always not-null. Default cell style has zero index and can be obtained as
+     * <code>workbook.getCellStyleAt(0)</code>
+     */
     public XSSFCellStyle getCellStyle() {
-        // Zero is the empty default
-        if(this.cell.getS() > 0) {
-            return stylesSource.getStyleAt(this.cell.getS());
-        }
-        return null;
+        long idx = cell.isSetS() ? cell.getS() : 0;
+        return stylesSource.getStyleAt(idx);
     }
 
     public int getCellType() {
@@ -156,7 +159,7 @@
     public Date getDateCellValue() {
         if (STCellType.N == this.cell.getT() || STCellType.STR == this.cell.getT()) {
             double value = this.getNumericCellValue();
-            if (false /* book.isUsing1904DateWindowing() */) {  // FIXME
+            if (row.getSheet().getWorkbook().isDate1904()) {
                 return DateUtil.getJavaDate(value,true);
             }
             else {
@@ -269,7 +272,7 @@
 
    
     public void setCellComment(Comment comment) {
-        String cellRef = new CellReference(row.getRowNum(), getCellNum()).formatAsString();
+        String cellRef = new CellReference(row.getRowNum(), getColumnIndex()).formatAsString();
         row.getSheet().setCellComment(cellRef, (XSSFComment)comment);
     }
 
@@ -333,7 +336,7 @@
     }
 
     protected String formatPosition() {
-        int col = this.getCellNum();
+        int col = this.getColumnIndex();
         String result = Character.valueOf((char) (col % 26 + 'A')).toString();
         if (col >= 26){
             col = col / 26;

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java Tue Oct 21 10:56:34 2008
@@ -145,7 +145,12 @@
      * @return HorizontalAlignment - the type of alignment
      */
     public HorizontalAlignment getAlignmentEnum() {
-        return getCellAlignment().getHorizontal();
+        CTCellAlignment align = cellXf.getAlignment();
+        if(align != null && align.isSetHorizontal()) {
+            return HorizontalAlignment.values()[align.getHorizontal().intValue()-1];
+        } else {
+            return HorizontalAlignment.GENERAL;
+        }
     }
 
     /**
@@ -485,7 +490,8 @@
      * @return indent - number of spaces
      */
     public short getIndention() {
-        return (short) getCellAlignment().getIndent();
+        CTCellAlignment align = cellXf.getAlignment();
+        return (short)(align == null ? 0 : align.getIndent());
     }
 
     /**
@@ -571,7 +577,8 @@
      * @return rotation degrees (between 0 and 180 degrees)
      */
     public short getRotation() {
-        return (short) getCellAlignment().getTextRotation();
+        CTCellAlignment align = cellXf.getAlignment();
+        return (short)(align == null ? 0 : align.getTextRotation());
     }
 
     /**
@@ -619,7 +626,12 @@
      * @see VerticalAlignment
      */
     public VerticalAlignment getVerticalAlignmentEnum() {
-        return getCellAlignment().getVertical();
+        CTCellAlignment align = cellXf.getAlignment();
+        if(align != null && align.isSetVertical()) {
+            return VerticalAlignment.values()[align.getVertical().intValue()-1];
+        } else {
+            return VerticalAlignment.BOTTOM;
+        }
     }
 
     /**
@@ -628,7 +640,8 @@
      * @return  a boolean value indicating if the text in a cell should be line-wrapped within the cell.
      */
     public boolean getWrapText() {
-        return getCellAlignment().getWrapText();
+        CTCellAlignment align = cellXf.getAlignment();
+        return align != null && align.getWrapText();
     }
 
     /**

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFDialogsheet.java Tue Oct 21 10:56:34 2008
@@ -27,6 +27,7 @@
 import java.io.IOException;
 
 public class XSSFDialogsheet extends XSSFSheet implements Sheet{
+    protected CTDialogsheet dialogsheet;
 
     public XSSFDialogsheet(XSSFSheet sheet) {
         this.packagePart = sheet.getPackagePart();
@@ -96,4 +97,7 @@
         return dialogsheet.getSheetProtection();
     }
 
+    public boolean getDialog(){
+        return true;
+    }
 }

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java Tue Oct 21 10:56:34 2008
@@ -58,7 +58,7 @@
 		return _cell.getCellType();
 	}
 	public int getColumnIndex() {
-		return _cell.getCellNum();
+		return _cell.getColumnIndex();
 	}
 	public int getErrorCellValue() {
 		return _cell.getErrorCellValue();

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java Tue Oct 21 10:56:34 2008
@@ -488,9 +488,7 @@
 
 
     public String toString() {
-        return "org.apache.poi.xssf.usermodel.XSSFFont{" +
-                ctFont +
-                "}";
+        return ctFont.toString();
     }
 
 

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFName.java Tue Oct 21 10:56:34 2008
@@ -33,13 +33,13 @@
     /**
      * this defined name specifies the workbook's print area
      */
-    public final static String  BUILTIN_PRINT_AREA            = "_xlnm.Print_Area";
+    public final static String BUILTIN_PRINT_AREA = "_xlnm.Print_Area";
 
     /**
      * this defined name specifies the row(s) or column(s) to repeat
-     *	at the top of each printed page.
+     * at the top of each printed page.
      */
-    public final static String  BUILTIN_PRINT_TITLE           = "_xlnm.Print_Titles";
+    public final static String BUILTIN_PRINT_TITLE = "_xlnm.Print_Titles";
 
     //Filter & Advanced Filter
 
@@ -47,7 +47,7 @@
      * this defined name refers to a range containing the criteria values
      * to be used in applying an advanced filter to a range of data
      */
-    public final static String  BUILTIN_CRITERIA              = "_xlnm.Criteria:";
+    public final static String BUILTIN_CRITERIA = "_xlnm.Criteria:";
 
 
     /**
@@ -55,7 +55,7 @@
      * output values resulting from applying an advanced filter criteria to a source
      * range
      */
-    public final static String  BUILTIN_EXTRACT              = "_xlnm.Extract:";
+    public final static String BUILTIN_EXTRACT = "_xlnm.Extract:";
 
     /**
      * can be one of the following
@@ -64,123 +64,127 @@
      * b. This defined name refers to a range to which an AutoFilter has been
      * applied
      */
-    public final static String  BUILTIN_FILTER_DB             = "_xlnm._FilterDatabase:";
-
+    public final static String BUILTIN_FILTER_DB = "_xlnm._FilterDatabase:";
 
     //Miscellaneous
 
     /**
      * the defined name refers to a consolidation area
      */
-    public final static String  BUILTIN_CONSOLIDATE_AREA      = "_xlnm.Consolidate_Area";
+    public final static String BUILTIN_CONSOLIDATE_AREA = "_xlnm.Consolidate_Area";
 
     /**
      * the range specified in the defined name is from a database data source
      */
-    public final static String  BUILTIN_DATABASE              = "_xlnm.Database";
+    public final static String BUILTIN_DATABASE = "_xlnm.Database";
 
     /**
      * the defined name refers to a sheet title.
      */
-    public final static String  BUILTIN_SHEET_TITLE           = "_xlnm.Sheet_Title";
+    public final static String BUILTIN_SHEET_TITLE = "_xlnm.Sheet_Title";
 
     private XSSFWorkbook workbook;
     private CTDefinedName ctName;
 
     protected XSSFName(XSSFWorkbook workbook) {
-	this.workbook = workbook;
-	this.ctName = CTDefinedName.Factory.newInstance();
+        this.workbook = workbook;
+        this.ctName = CTDefinedName.Factory.newInstance();
     }
+
     protected XSSFName(CTDefinedName name, XSSFWorkbook workbook) {
-	this.workbook = workbook;
-	this.ctName = name;
+        this.workbook = workbook;
+        this.ctName = name;
     }
 
     public boolean isFunctionName() {
-	// TODO Figure out how HSSF does this, and do the same!
-	return ctName.getFunction(); // maybe this works - verify
+        // TODO Figure out how HSSF does this, and do the same!
+        return ctName.getFunction(); // maybe this works - verify
     }
+
     /**
      * Returns the underlying named range object
      */
     protected CTDefinedName getCTName() {
-	return ctName;
+        return ctName;
     }
 
     public String getNameName() {
-	return ctName.getName();
+        return ctName.getName();
     }
+
     public void setNameName(String nameName) {
-	ctName.setName(nameName);
+        ctName.setName(nameName);
     }
 
     public String getReference() {
-	return ctName.getStringValue();
+        return ctName.getStringValue();
     }
+
     public void setReference(String ref) {
-	ctName.setStringValue(ref);
+        ctName.setStringValue(ref);
     }
 
     public void setLocalSheetId(int sheetId) {
-	ctName.setLocalSheetId(sheetId);
+        ctName.setLocalSheetId(sheetId);
     }
 
     public int getLocalSheetId() {
-	return (int)ctName.getLocalSheetId();
+        return (int) ctName.getLocalSheetId();
     }
 
 
     public void setFunction(boolean value) {
-	ctName.setFunction(value);
+        ctName.setFunction(value);
     }
 
     public boolean getFunction() {
-	return ctName.getFunction();
+        return ctName.getFunction();
     }
 
     public void setFunctionGroupId(int functionGroupId) {
-	ctName.setFunctionGroupId(functionGroupId);
+        ctName.setFunctionGroupId(functionGroupId);
     }
 
     public int getFunctionGroupId() {
-	return (int)ctName.getFunctionGroupId();
+        return (int) ctName.getFunctionGroupId();
     }
 
     public String getSheetName() {
-	if(ctName.isSetLocalSheetId()) {
-	    // Given as explicit sheet id
-	    long sheetId = ctName.getLocalSheetId();
-	    if(sheetId >= 0) {
-		return workbook.getSheetName((int)sheetId);
-	    }
-	} else {
-	    // Is it embeded in the reference itself?
-	    int excl = getReference().indexOf('!');
-	    if(excl > -1) {
-		return getReference().substring(0, excl);
-	    }
-	}
+        if (ctName.isSetLocalSheetId()) {
+            // Given as explicit sheet id
+            long sheetId = ctName.getLocalSheetId();
+            if (sheetId >= 0) {
+                return workbook.getSheetName((int) sheetId);
+            }
+        } else {
+            // Is it embeded in the reference itself?
+            int excl = getReference().indexOf('!');
+            if (excl > -1) {
+                return getReference().substring(0, excl);
+            }
+        }
 
-	// Not given at all
-	return null;
+        // Not given at all
+        return null;
     }
 
     public String getComment() {
-	return ctName.getComment();
+        return ctName.getComment();
     }
+
     public void setComment(String comment) {
-	ctName.setComment(comment);
+        ctName.setComment(comment);
     }
 
 
-    public int hashCode(){
-	return ctName.toString().hashCode();
+    public int hashCode() {
+        return ctName.toString().hashCode();
     }
 
-    public boolean equals(Object o){
-	if(!(o instanceof XSSFName)) return false;
-	XSSFName cf = (XSSFName)o;
-	return ctName.toString().equals(cf.getCTName().toString());
+    public boolean equals(Object o) {
+        if (!(o instanceof XSSFName)) return false;
+        XSSFName cf = (XSSFName) o;
+        return ctName.toString().equals(cf.getCTName().toString());
     }
 
 

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java Tue Oct 21 10:56:34 2008
@@ -48,12 +48,6 @@
     private static CTPicture prototype = null;
 
     /**
-     * Width of one character in pixels. Same for Calibry and Arial.
-     */
-    private static final float CHARACTER_WIDTH = 7.0017f;
-
-
-    /**
      * This object specifies a picture object and all its properties
      */
     private CTPicture ctPicture;
@@ -214,7 +208,7 @@
         XSSFSheet sheet = (XSSFSheet)getDrawing().getParent();
         float numChars = (float)sheet.getColumnWidth(columnIndex)/256;
 
-        return numChars*CHARACTER_WIDTH;
+        return numChars*XSSFWorkbook.DEFAULT_CHARACTER_WIDTH;
     }
 
     private float getRowHeightInPixels(int rowIndex){

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java Tue Oct 21 10:56:34 2008
@@ -453,6 +453,7 @@
             if(c1.isSetTheme()) c2.setTheme(c1.getTheme());
             if(c1.isSetTint()) c2.setTint(c1.getTint());
         }
+        if(pr.sizeOfSzArray() > 0) ctFont.addNewSz().setVal(pr.getSzArray(0).getVal());
         if(pr.sizeOfRFontArray() > 0) ctFont.addNewName().setVal(pr.getRFontArray(0).getVal());
         if(pr.sizeOfFamilyArray() > 0) ctFont.addNewFamily().setVal(pr.getFamilyArray(0).getVal());
         if(pr.sizeOfSchemeArray() > 0) ctFont.addNewScheme().setVal(pr.getSchemeArray(0).getVal());

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Tue Oct 21 10:56:34 2008
@@ -27,7 +27,9 @@
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
 
-
+/**
+ * High level representation of a row of a spreadsheet.
+ */
 public class XSSFRow implements Row, Comparable {
 
     private CTRow row;
@@ -45,20 +47,30 @@
     public XSSFRow(CTRow row, XSSFSheet sheet) {
         this.row = row;
         this.sheet = sheet;
-        this.cells = new LinkedList<Cell>(); 
+        this.cells = new LinkedList<Cell>();
         for (CTCell c : row.getCArray()) {
             this.cells.add(new XSSFCell(this, c));
         }
         
     }
 
+    /**
+     * Returns the XSSFSheet this row belongs to
+     *
+     * @return the XSSFSheet that owns this row
+     */
     public XSSFSheet getSheet() {
         return this.sheet;
     }
     
+    /**
+     * @return Cell iterator of the physically defined cells.  Note element 4 may
+     * actually be row cell depending on how many are defined!
+     */
     public Iterator<Cell> cellIterator() {
         return cells.iterator();
     }
+
     /**
      * Alias for {@link #cellIterator()} to allow
      *  foreach loops
@@ -102,7 +114,7 @@
      * 
      * @param column Cell column number.
      * @param index Position where to insert cell.
-     * @param type TODO
+     * @param type cell type, one of Cell.CELL_TYPE_*
      * @return The new cell.
      */
     protected XSSFCell addCell(int column, int index, int type) {
@@ -148,7 +160,7 @@
         Iterator<Cell> it = cellIterator();
         for ( ; it.hasNext() ; ) {
         	Cell cell = it.next();
-        	if (cell.getCellNum() == cellnum) {
+        	if (cell.getColumnIndex() == cellnum) {
         		return (XSSFCell)cell;
         	}
         }
@@ -157,8 +169,9 @@
     
     /**
      * Returns the cell at the given (0 based) index,
-     *  with the {@link MissingCellPolicy} from the
-     *  parent Workbook.
+     *  with the {@link MissingCellPolicy} from the parent Workbook.
+     *
+     * @return the cell at the given (0 based) index
      */
     public XSSFCell getCell(int cellnum) {
     	return getCell(cellnum, sheet.getWorkbook().getMissingCellPolicy());
@@ -167,6 +180,8 @@
     /**
      * Returns the cell at the given (0 based) index,
      *  with the specified {@link MissingCellPolicy}
+     *
+     * @return the cell at the given (0 based) index
      */
     public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
     	XSSFCell cell = retrieveCell(cellnum);
@@ -189,11 +204,16 @@
     	throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
     }
 
+    /**
+     * Get the number of the first cell contained in this row.
+     *
+     * @return short representing the first logical cell in the row, or -1 if the row does not contain any cells.
+     */
     public short getFirstCellNum() {
     	for (Iterator<Cell> it = cellIterator() ; it.hasNext() ; ) {
     		Cell cell = it.next();
     		if (cell != null) {
-    			return cell.getCellNum();
+    			return (short)cell.getColumnIndex();
     		}
     	}
     	return -1;
@@ -248,12 +268,18 @@
     	for (Iterator<Cell> it = cellIterator() ; it.hasNext() ; ) {
     		Cell cell = it.next();
     		if (cell != null) {
-    			lastCellNum = (short)(cell.getCellNum() + 1);
+    			lastCellNum = (short)(cell.getColumnIndex() + 1);
     		}
     	}
     	return lastCellNum;
     }
 
+    /**
+     * Gets the number of defined cells (NOT number of cells in the actual row!).
+     * That is to say if only columns 0,4,5 have values then there would be 3.
+     *
+     * @return int representing the number of defined cells in the row.
+     */
     public int getPhysicalNumberOfCells() {
     	int count = 0;
     	for (Iterator<Cell> it = cellIterator() ; it.hasNext() ; ) {
@@ -264,19 +290,34 @@
     	return count;
     }
 
+    /**
+     * Get row number this row represents
+     *
+     * @return the row number (0 based)
+     */
     public int getRowNum() {
         return (int) (row.getR() - 1);
     }
 
+    /**
+     * Get whether or not to display this row with 0 height
+     *
+     * @return - height is zero or not.
+     */
     public boolean getZeroHeight() {
     	return this.row.getHidden();
     }
 
+    /**
+     * Remove the Cell from this row.
+     *
+     * @param cell to remove
+     */
     public void removeCell(Cell cell) {
     	int counter = 0;
     	for (Iterator<Cell> it = cellIterator(); it.hasNext(); ) {
     		Cell c = it.next();
-    		if (c.getCellNum() == cell.getCellNum()) {
+    		if (c.getColumnIndex() == cell.getColumnIndex()) {
     			it.remove();
     			row.removeC(counter);
     			continue;
@@ -309,16 +350,31 @@
 	    setHeight((short)(height*20));
     }
 
+    /**
+     * Set the row number of this row.
+     *
+     * @param rowNum  the row number (0-based)
+     */
     public void setRowNum(int rowNum) {
         this.row.setR(rowNum + 1);
 
     }
 
+    /**
+     * Set whether or not to display this row with 0 height
+     *
+     * @param height  height is zero or not.
+     */
     public void setZeroHeight(boolean height) {
     	this.row.setHidden(height);
 
     }
     
+    /**
+     * Returns the underlying CTRow xml bean representing this row
+     *
+     * @return the underlying CTRow bean
+     */
     public CTRow getCTRow(){
     	return this.row;
     }

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Tue Oct 21 10:56:34 2008
@@ -71,20 +71,10 @@
 
     protected CTSheet sheet;
     protected CTWorksheet worksheet;
-    protected CTDialogsheet dialogsheet;
     protected List<Row> rows;
     protected List<XSSFHyperlink> hyperlinks;
     protected ColumnHelper columnHelper;
     private CommentsSource sheetComments;
-    protected CTMergeCells ctMergeCells;
-
-    public static final short LeftMargin = 0;
-    public static final short RightMargin = 1;
-    public static final short TopMargin = 2;
-    public static final short BottomMargin = 3;
-    public static final short HeaderMargin = 4;
-    public static final short FooterMargin = 5;
-
 
     public XSSFSheet() {
         super(null, null);
@@ -203,7 +193,9 @@
 
 
     public int addMergedRegion(Region region) {
-        addNewMergeCell(region);
+        CTMergeCells ctMergeCells = worksheet.isSetMergeCells() ? worksheet.getMergeCells() : worksheet.addNewMergeCells();
+        CTMergeCell ctMergeCell = ctMergeCells.addNewMergeCell();
+        ctMergeCell.setRef(region.getRegionRef());
         return ctMergeCells.sizeOfMergeCellArray();
     }
 
@@ -234,8 +226,12 @@
      * @param useMergedCells whether to use the contents of merged cells when calculating the width of the column
      */
     public void autoSizeColumn(short column, boolean useMergedCells) {
-        //TODO:
-        columnHelper.setColBestFit(column, true);
+        double width = ColumnHelper.getColumnWidth(this, column, useMergedCells);
+        if(width != -1){
+            columnHelper.setColBestFit(column, true);
+            columnHelper.setCustomWidth(column, true);
+            columnHelper.setColWidth(column, width);
+        }
     }
 
     /**
@@ -474,14 +470,6 @@
                worksheet.addNewSheetFormatPr();
     }
 
-    public boolean getDialog() {
-        if (dialogsheet != null) {
-            return true;
-        }
-        return false;
-    }
-
-
     /**
      * Get whether to display the guts or not,
      * default value is true
@@ -677,12 +665,30 @@
     }
 
     public Region getMergedRegionAt(int index) {
-        CTMergeCell ctMergeCell = getMergedCells().getMergeCellArray(index);
+        CTMergeCells ctMergeCells = worksheet.getMergeCells();
+        if(ctMergeCells == null) throw new IllegalStateException("This worksheet does not contain merged regions");
+
+        CTMergeCell ctMergeCell = ctMergeCells.getMergeCellArray(index);
         return new Region(ctMergeCell.getRef());
     }
 
+    /**
+     * @return the merged region at the specified index
+     */
+    public CellRangeAddress getMergedRegion(int index) {
+        CTMergeCells ctMergeCells = worksheet.getMergeCells();
+        if(ctMergeCells == null) throw new IllegalStateException("This worksheet does not contain merged regions");
+
+        CTMergeCell ctMergeCell = ctMergeCells.getMergeCellArray(index);
+        String ref = ctMergeCell.getRef();
+        CellReference cell1 = new CellReference(ref.substring(0, ref.indexOf(":")));
+        CellReference cell2 = new CellReference(ref.substring(ref.indexOf(":") + 1));
+        return new CellRangeAddress(cell1.getRow(), cell2.getRow(), cell1.getCol(), cell2.getCol());
+    }
+
     public int getNumMergedRegions() {
-        return getMergedCells().sizeOfMergeCellArray();
+        CTMergeCells ctMergeCells = worksheet.getMergeCells();
+        return ctMergeCells == null ? 0 : ctMergeCells.sizeOfMergeCellArray();
     }
 
     public int getNumHyperlinks() {
@@ -1040,17 +1046,24 @@
 
     }
 
+    /**
+     * Removes a merged region of cells (hence letting them free)
+     *
+     * @param index of the region to unmerge
+     */
     public void removeMergedRegion(int index) {
-        CTMergeCell[] mergeCellsArray = new CTMergeCell[getMergedCells().sizeOfMergeCellArray() - 1];
-        for (int i = 0 ; i < getMergedCells().sizeOfMergeCellArray() ; i++) {
+        CTMergeCells ctMergeCells = worksheet.getMergeCells();
+
+        CTMergeCell[] mergeCellsArray = new CTMergeCell[ctMergeCells.sizeOfMergeCellArray() - 1];
+        for (int i = 0 ; i < ctMergeCells.sizeOfMergeCellArray() ; i++) {
             if (i < index) {
-                mergeCellsArray[i] = getMergedCells().getMergeCellArray(i);
+                mergeCellsArray[i] = ctMergeCells.getMergeCellArray(i);
             }
             else if (i > index) {
-                mergeCellsArray[i - 1] = getMergedCells().getMergeCellArray(i);
+                mergeCellsArray[i - 1] = ctMergeCells.getMergeCellArray(i);
             }
         }
-        getMergedCells().setMergeCellArray(mergeCellsArray);
+        ctMergeCells.setMergeCellArray(mergeCellsArray);
     }
 
     public void removeRow(Row row) {
@@ -1192,15 +1205,6 @@
 
     }
 
-    public void setDialog(boolean b) {
-        if(b && dialogsheet == null){
-            CTDialogsheet dialogSheet = CTDialogsheet.Factory.newInstance();
-            dialogsheet = dialogSheet;
-        }else{
-            dialogsheet = null;
-        }
-    }
-
     /**
      * Sets the flag indicating whether this sheet should display formulas.
      *
@@ -1623,19 +1627,6 @@
         return sheetComments;
     }
 
-    private void addNewMergeCell(Region region) {
-        ctMergeCells = getMergedCells();
-        CTMergeCell ctMergeCell = ctMergeCells.addNewMergeCell();
-        ctMergeCell.setRef(region.getRegionRef());
-    }
-
-    private CTMergeCells getMergedCells() {
-        if (ctMergeCells == null) {
-            ctMergeCells = worksheet.addNewMergeCells();
-        }
-        return ctMergeCells;
-    }
-
     private CTPageSetUpPr getSheetTypePageSetUpPr() {
         CTSheetPr sheetPr = getSheetTypeSheetPr();
         return sheetPr.isSetPageSetUpPr() ? sheetPr.getPageSetUpPr() : sheetPr.addNewPageSetUpPr();
@@ -1666,10 +1657,12 @@
 
         if(worksheet.getColsArray().length == 1) {
             CTCols col = worksheet.getColsArray(0);
-            if(col.getColArray().length == 0) {
+            CTCol[] cols = col.getColArray();
+            if(cols.length == 0) {
                 worksheet.setColsArray(null);
             }
         }
+
         // Now re-generate our CTHyperlinks, if needed
         if(hyperlinks.size() > 0) {
             if(worksheet.getHyperlinks() == null) {

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java Tue Oct 21 10:56:34 2008
@@ -52,6 +52,11 @@
 public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<XSSFSheet> {
 
     /**
+     * Width of one character of the default font in pixels. Same for Calibry and Arial.
+     */
+    public static final float DEFAULT_CHARACTER_WIDTH = 7.0017f;
+
+    /**
      * The underlying XML bean
      */
     private CTWorkbook workbook;
@@ -140,7 +145,6 @@
      */
     private static Package ensureWriteAccess(Package pkg) throws IOException {
         if(pkg.getPackageAccess() == PackageAccess.READ){
-            //YK: current implementation of OpenXML4J is funny.
             try {
                 return PackageHelper.clone(pkg);
             } catch (OpenXML4JException e){
@@ -358,8 +362,8 @@
         xf.setBorderId(0);
         xf.setXfId(0);
         int xfSize=(stylesSource)._getStyleXfsSize();
-        long indexXf=(stylesSource).putCellXf(xf);
-        XSSFCellStyle style = new XSSFCellStyle(new Long(indexXf-1).intValue(), xfSize-1, stylesSource);
+        int indexXf=(stylesSource).putCellXf(xf);
+        XSSFCellStyle style = new XSSFCellStyle(indexXf-1, xfSize-1, stylesSource);
         return style;
     }
 
@@ -513,11 +517,6 @@
         return pictures;
     }
 
-    public boolean getBackupFlag() {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
     public XSSFCellStyle getCellStyleAt(short idx) {
         return stylesSource.getStyleAt(idx);
     }
@@ -615,7 +614,7 @@
      * @return String Null if no print area has been defined
      */
     public String getPrintArea(int sheetIndex) {	
-        XSSFName name = getSpecificBuiltinRecord(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
+        XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
         if (name == null) return null;
         //adding one here because 0 indicates a global named region; doesnt make sense for print areas
         return name.getReference();
@@ -811,11 +810,6 @@
         }
     }
 
-    public void setBackupFlag(boolean backupValue) {
-        // TODO Auto-generated method stub
-
-    }
-
     /**
      * Gets the first tab that is displayed in the list of tabs in excel.
      *
@@ -846,7 +840,7 @@
      * @param reference Valid name Reference for the Print Area
      */
     public void setPrintArea(int sheetIndex, String reference) {
-        XSSFName name = getSpecificBuiltinRecord(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
+        XSSFName name = getBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
         if (name == null) {
             name = createBuiltInName(XSSFName.BUILTIN_PRINT_AREA, sheetIndex);
             namedRanges.add(name);
@@ -916,7 +910,7 @@
     }
 
 
-    public XSSFName getSpecificBuiltinRecord(String builtInCode, int sheetNumber) {
+    private XSSFName getBuiltInName(String builtInCode, int sheetNumber) {
         for (XSSFName name : namedRanges) {
             if (name.getNameName().equalsIgnoreCase(builtInCode) && name.getLocalSheetId() == sheetNumber) {
                 return name;
@@ -929,7 +923,7 @@
      * Generates a NameRecord to represent a built-in region
      * @return a new NameRecord
      */
-    public XSSFName createBuiltInName(String builtInName, int sheetNumber) {
+    private XSSFName createBuiltInName(String builtInName, int sheetNumber) {
         if (sheetNumber < 0 || sheetNumber+1 > Short.MAX_VALUE) {
             throw new IllegalArgumentException("Sheet number ["+sheetNumber+"]is not valid ");
         }
@@ -939,7 +933,6 @@
         nameRecord.setLocalSheetId(sheetNumber);
    
         XSSFName name=new XSSFName(nameRecord,this);        
-        //while(namedRanges.contains(name)) {
         for(XSSFName nr :  namedRanges){
             if(nr.equals(name))
             throw new RuntimeException("Builtin (" + builtInName 
@@ -993,11 +986,6 @@
         newcts.set(cts);
     }
 
-    public void unwriteProtectWorkbook() {
-        // TODO Auto-generated method stub
-
-    }
-
     /**
      * marshal named ranges from the {@link #namedRanges} collection to the underlying CTWorkbook bean
      */
@@ -1051,11 +1039,6 @@
         getPackage().save(stream);
     }
 
-    public void writeProtectWorkbook(String password, String username) {
-        // TODO Auto-generated method stub
-
-    }
-
     /**
      * Returns SharedStringsTable - tha cache of string for this workbook
      *
@@ -1064,10 +1047,6 @@
     public SharedStringsTable getSharedStringSource() {
         return this.sharedStringSource;
     }
-    //TODO do we really need setSharedStringSource?
-    protected void setSharedStringSource(SharedStringsTable sharedStringSource) {
-        this.sharedStringSource = sharedStringSource;
-    }
 
     /**
      * Return a object representing a collection of shared objects used for styling content,
@@ -1076,10 +1055,6 @@
     public StylesTable getStylesSource() {
         return this.stylesSource;
     }
-    //TODO do we really need setStylesSource?
-    protected void setStylesSource(StylesTable stylesSource) {
-        this.stylesSource = stylesSource;
-    }
 
     /**
      * Returns an object that handles instantiating concrete

Modified: poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java (original)
+++ poi/branches/ooxml/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java Tue Oct 21 10:56:34 2008
@@ -18,10 +18,20 @@
 package org.apache.poi.xssf.usermodel.helpers;
 
 import java.util.Arrays;
+import java.util.Iterator;
+import java.text.AttributedString;
+import java.text.NumberFormat;
+import java.text.DecimalFormat;
+import java.awt.font.TextLayout;
+import java.awt.font.FontRenderContext;
+import java.awt.font.TextAttribute;
+import java.awt.geom.AffineTransform;
 
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.util.CTColComparator;
 import org.apache.poi.xssf.util.NumericRanges;
+import org.apache.poi.xssf.usermodel.*;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
@@ -222,6 +232,10 @@
         CTCol col = getOrCreateColumn1Based(index+1, false);
         col.setBestFit(bestFit);
     }
+    public void setCustomWidth(long index, boolean bestFit) {
+        CTCol col = getOrCreateColumn1Based(index+1, false);
+        col.setCustomWidth(bestFit);
+    }
 
     public void setColWidth(long index, double width) {
         CTCol col = getOrCreateColumn1Based(index+1, false);
@@ -281,4 +295,164 @@
 	    }
 	    return -1;
 	}
+
+    public static double getColumnWidth(XSSFSheet sheet, int column, boolean useMergedCells){
+        AttributedString str;
+        TextLayout layout;
+        /**
+         * Excel measures columns in units of 1/256th of a character width
+         * but the docs say nothing about what particular character is used.
+         * '0' looks to be a good choice.
+         */
+        char defaultChar = '0';
+
+        /**
+         * This is the multiple that the font height is scaled by when determining the
+         * boundary of rotated text.
+         */
+        double fontHeightMultiple = 2.0;
+
+        FontRenderContext frc = new FontRenderContext(null, true, true);
+
+        XSSFWorkbook wb = sheet.getWorkbook();
+        XSSFFont defaultFont = wb.getFontAt((short) 0);
+
+        str = new AttributedString("" + defaultChar);
+        copyAttributes(defaultFont, str, 0, 1);
+        layout = new TextLayout(str.getIterator(), frc);
+        int defaultCharWidth = (int)layout.getAdvance();
+
+        double width = -1;
+        rows:
+        for (Iterator it = sheet.rowIterator(); it.hasNext();) {
+            XSSFRow row = (XSSFRow) it.next();
+            XSSFCell cell = row.getCell(column);
+
+            if (cell == null) {
+                continue;
+            }
+
+            int colspan = 1;
+            for (int i = 0 ; i < sheet.getNumMergedRegions(); i++) {
+                CellRangeAddress region = sheet.getMergedRegion(i);
+                if (containsCell(region, row.getRowNum(), column)) {
+                    if (!useMergedCells) {
+                        // If we're not using merged cells, skip this one and move on to the next.
+                        continue rows;
+                    }
+                    cell = row.getCell(region.getFirstColumn());
+                    colspan = 1 + region.getLastColumn() - region.getFirstColumn();
+                }
+            }
+
+            XSSFCellStyle style = cell.getCellStyle();
+            XSSFFont font = wb.getFontAt(style.getFontIndex());
+
+            if (cell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
+                XSSFRichTextString rt = cell.getRichStringCellValue();
+                String[] lines = rt.getString().split("\\n");
+                for (int i = 0; i < lines.length; i++) {
+                    String txt = lines[i] + defaultChar;
+                    str = new AttributedString(txt);
+                    copyAttributes(font, str, 0, txt.length());
+
+                    if (rt.numFormattingRuns() > 0) {
+                        int pos = 0;
+                        for (int j = 0; j < rt.numFormattingRuns(); j++) {
+                            XSSFFont fnt = rt.getFontOfFormattingRun(j);
+                            if (fnt != null) {
+                                int len = rt.getLengthOfFormattingRun(j);
+                                copyAttributes(fnt, str, pos, pos + len);
+                                pos += len;
+                            }
+                        }
+                    }
+
+                    layout = new TextLayout(str.getIterator(), frc);
+                    if(style.getRotation() != 0){
+                        /*
+                         * Transform the text using a scale so that it's height is increased by a multiple of the leading,
+                         * and then rotate the text before computing the bounds. The scale results in some whitespace around
+                         * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
+                         * is added by the standard Excel autosize.
+                         */
+                        AffineTransform trans = new AffineTransform();
+                        trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
+                        trans.concatenate(
+                        AffineTransform.getScaleInstance(1, fontHeightMultiple)
+                        );
+                        width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
+                    } else {
+                        width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
+                    }
+                }
+            } else {
+                String sval = null;
+                if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
+                    String format = style.getDataFormatString().replaceAll("\"", "");
+                    double value = cell.getNumericCellValue();
+                    try {
+                        NumberFormat fmt;
+                        if ("General".equals(format))
+                            sval = "" + value;
+                        else
+                        {
+                            fmt = new DecimalFormat(format);
+                            sval = fmt.format(value);
+                        }
+                    } catch (Exception e) {
+                        sval = "" + value;
+                    }
+                } else if (cell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
+                    sval = String.valueOf(cell.getBooleanCellValue());
+                }
+                if(sval != null) {
+                    String txt = sval + defaultChar;
+                    str = new AttributedString(txt);
+                    copyAttributes(font, str, 0, txt.length());
+
+                    layout = new TextLayout(str.getIterator(), frc);
+                    if(style.getRotation() != 0){
+                        /*
+                         * Transform the text using a scale so that it's height is increased by a multiple of the leading,
+                         * and then rotate the text before computing the bounds. The scale results in some whitespace around
+                         * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
+                         * is added by the standard Excel autosize.
+                         */
+                        AffineTransform trans = new AffineTransform();
+                        trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
+                        trans.concatenate(
+                        AffineTransform.getScaleInstance(1, fontHeightMultiple)
+                        );
+                        width = Math.max(width, ((layout.getOutline(trans).getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
+                    } else {
+                        width = Math.max(width, ((layout.getBounds().getWidth() / colspan) / defaultCharWidth) + cell.getCellStyle().getIndention());
+                    }
+                }
+            }
+
+        }
+        return width;
+    }
+
+    /**
+     * Copy text attributes from the supplied HSSFFont to Java2D AttributedString
+     */
+    private static void copyAttributes(XSSFFont font, AttributedString str, int startIdx, int endIdx) {
+        str.addAttribute(TextAttribute.FAMILY, font.getFontName(), startIdx, endIdx);
+        str.addAttribute(TextAttribute.SIZE, new Float(font.getFontHeightInPoints()));
+        if (font.getBoldweight() == XSSFFont.BOLDWEIGHT_BOLD) str.addAttribute(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD, startIdx, endIdx);
+        if (font.getItalic() ) str.addAttribute(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, startIdx, endIdx);
+        if (font.getUnderline() == XSSFFont.U_SINGLE ) str.addAttribute(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON, startIdx, endIdx);
+    }
+
+    private static boolean containsCell(CellRangeAddress cr, int rowIx, int colIx) {
+        if (cr.getFirstRow() <= rowIx && cr.getLastRow() >= rowIx
+                && cr.getFirstColumn() <= colIx && cr.getLastColumn() >= colIx)
+        {
+            return true;
+        }
+        return false;
+    }
+
 }

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java Tue Oct 21 10:56:34 2008
@@ -17,7 +17,6 @@
 
 package org.apache.poi.xssf.usermodel;
 
-import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
 
@@ -28,21 +27,13 @@
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Comment;
 import org.apache.poi.ss.usermodel.CreationHelper;
 import org.apache.poi.ss.usermodel.DataFormat;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.XSSFTestDataSamples;
-import org.apache.poi.xssf.model.CommentsTable;
-import org.apache.poi.xssf.model.SharedStringSource;
-import org.apache.poi.xssf.model.SharedStringsTable;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
 
@@ -291,7 +282,8 @@
     	
     	CellStyle cs = workbook.createCellStyle();
     	assertNotNull(cs);
-    	
+        assertTrue(cs.getIndex() > 0);
+
     	assertNotNull(creationHelper);
     	assertNotNull(creationHelper.createDataFormat());
     	
@@ -299,9 +291,10 @@
     			creationHelper.createDataFormat().getFormat("yyyy/mm/dd")
     	);
     	Cell cell = sheet.createRow(0).createCell((short)0);
+        assertNotNull(cell.getCellStyle());
+        assertEquals(0, cell.getCellStyle().getIndex());
     	cell.setCellValue(new Date(654321));
     	
-    	assertNull(cell.getCellStyle());
     	cell.setCellStyle(cs);
     	
     	assertEquals(new Date(654321), cell.getDateCellValue());

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java Tue Oct 21 10:56:34 2008
@@ -532,10 +532,10 @@
 
 	public void testGetSetIndent() {
 		assertEquals((short)0, cellStyle.getIndention());
-		cellXf.getAlignment().setIndent(3);
+		cellStyle.setIndention((short)3);
 		assertEquals((short)3, cellStyle.getIndention());
 		cellStyle.setIndention((short) 13);
-		assertEquals((short)13, cellXf.getAlignment().getIndent());
+		assertEquals((short)13, cellStyle.getIndention());
 	}
 
 	public void testGetSetAlignement() {
@@ -576,10 +576,10 @@
 
 	public void testGetSetWrapText() {
 		assertFalse(cellStyle.getWrapText());
-		cellXf.getAlignment().setWrapText(true);
+		cellStyle.setWrapText(true);
 		assertTrue(cellStyle.getWrapText());
 		cellStyle.setWrapText(false);
-		assertFalse(cellXf.getAlignment().getWrapText());
+        assertFalse(cellStyle.getWrapText());
 	}
 
 	/**

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDialogSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDialogSheet.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDialogSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFDialogSheet.java Tue Oct 21 10:56:34 2008
@@ -36,9 +36,7 @@
     
     public void testGetDialog() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
-        assertFalse(sheet.getDialog());
-        XSSFSheet dialogsheet = (XSSFSheet) workbook.createDialogsheet("Dialogsheet 1", null);
+        XSSFDialogsheet dialogsheet = workbook.createDialogsheet("Dialogsheet 1", null);
         assertTrue(dialogsheet.getDialog());
     	
     }

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java Tue Oct 21 10:56:34 2008
@@ -204,12 +204,12 @@
         assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(5, XSSFRow.CREATE_NULL_AS_BLANK).getCellType());
 
         // Check created ones get the right column
-        assertEquals((short)0, row.getCell(0, XSSFRow.CREATE_NULL_AS_BLANK).getCellNum());
-        assertEquals((short)1, row.getCell(1, XSSFRow.CREATE_NULL_AS_BLANK).getCellNum());
-        assertEquals((short)2, row.getCell(2, XSSFRow.CREATE_NULL_AS_BLANK).getCellNum());
-        assertEquals((short)3, row.getCell(3, XSSFRow.CREATE_NULL_AS_BLANK).getCellNum());
-        assertEquals((short)4, row.getCell(4, XSSFRow.CREATE_NULL_AS_BLANK).getCellNum());
-        assertEquals((short)5, row.getCell(5, XSSFRow.CREATE_NULL_AS_BLANK).getCellNum());
+        assertEquals((short)0, row.getCell(0, XSSFRow.CREATE_NULL_AS_BLANK).getColumnIndex());
+        assertEquals((short)1, row.getCell(1, XSSFRow.CREATE_NULL_AS_BLANK).getColumnIndex());
+        assertEquals((short)2, row.getCell(2, XSSFRow.CREATE_NULL_AS_BLANK).getColumnIndex());
+        assertEquals((short)3, row.getCell(3, XSSFRow.CREATE_NULL_AS_BLANK).getColumnIndex());
+        assertEquals((short)4, row.getCell(4, XSSFRow.CREATE_NULL_AS_BLANK).getColumnIndex());
+        assertEquals((short)5, row.getCell(5, XSSFRow.CREATE_NULL_AS_BLANK).getColumnIndex());
     }
 
     /**

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java Tue Oct 21 10:56:34 2008
@@ -32,7 +32,6 @@
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
 import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
@@ -305,7 +304,7 @@
 		XSSFOddFooter ftr;
 
 		// Sheet 1 has a header with center and right text
-		XSSFSheet s1 = (XSSFSheet)workbook.getSheetAt(0);
+		XSSFSheet s1 = workbook.getSheetAt(0);
 		assertNotNull(s1.getHeader());
 		assertNotNull(s1.getFooter());
 		hdr = (XSSFOddHeader)s1.getHeader();
@@ -324,7 +323,7 @@
 
 
 		// Sheet 2 has a footer, but it's empty
-		XSSFSheet s2 = (XSSFSheet)workbook.getSheetAt(1);
+		XSSFSheet s2 = workbook.getSheetAt(1);
 		assertNotNull(s2.getHeader());
 		assertNotNull(s2.getFooter());
 		hdr = (XSSFOddHeader)s2.getHeader();
@@ -359,7 +358,7 @@
 
     public void testGetAllHeadersFooters() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertNotNull(sheet.getOddFooter());
         assertNotNull(sheet.getEvenFooter());
         assertNotNull(sheet.getFirstFooter());
@@ -447,28 +446,19 @@
     
     public void testAutoSizeColumn() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
+        sheet.createRow(0).createCell(13).setCellValue("test");
+
+        sheet.autoSizeColumn((short)13);
+
         ColumnHelper columnHelper = sheet.getColumnHelper();
         CTCol col = columnHelper.getColumn(13, false);
-        assertNull(col);
-        sheet.autoSizeColumn((short)13);
-        col = columnHelper.getColumn(13, false);
-        assertNotNull(col);
-        assertTrue(col.getBestFit());	
-    }
-    
-    public void testGetDialog() {
-        XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = workbook.createSheet("Sheet 1");
-        assertFalse(sheet.getDialog());
-        XSSFSheet dialogsheet = workbook.createDialogsheet("Dialogsheet 1", null);
-        assertTrue(dialogsheet.getDialog());
-    	
+        assertTrue(col.getBestFit());
     }
     
     public void testGetSetHorizontallyCentered() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertFalse(sheet.getHorizontallyCenter());
         sheet.setHorizontallyCenter(true);
         assertTrue(sheet.getHorizontallyCenter());
@@ -478,7 +468,7 @@
     
     public void testGetSetVerticallyCentered() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertFalse(sheet.getVerticallyCenter());
         sheet.setVerticallyCenter(true);
         assertTrue(sheet.getVerticallyCenter());
@@ -488,7 +478,7 @@
     
     public void testIsSetPrintGridlines() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertFalse(sheet.isPrintGridlines());
         sheet.setPrintGridlines(true);
         assertTrue(sheet.isPrintGridlines());
@@ -496,7 +486,7 @@
     
     public void testIsSetDisplayFormulas() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertFalse(sheet.isDisplayFormulas());
         sheet.setDisplayFormulas(true);
         assertTrue(sheet.isDisplayFormulas());
@@ -504,7 +494,7 @@
     
     public void testIsSetDisplayGridLines() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertTrue(sheet.isDisplayGridlines());
         sheet.setDisplayGridlines(false);
         assertFalse(sheet.isDisplayGridlines());
@@ -512,7 +502,7 @@
     
     public void testIsSetDisplayGuts() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertTrue(sheet.getDisplayGuts());
         sheet.setDisplayGuts(false);
         assertFalse(sheet.getDisplayGuts());
@@ -520,7 +510,7 @@
     
     public void testIsSetDisplayRowColHeadings() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertTrue(sheet.isDisplayRowColHeadings());
         sheet.setDisplayRowColHeadings(false);
         assertFalse(sheet.isDisplayRowColHeadings());
@@ -528,7 +518,7 @@
     
     public void testGetScenarioProtect() {
         XSSFWorkbook workbook = new XSSFWorkbook();
-        XSSFSheet sheet = (XSSFSheet) workbook.createSheet("Sheet 1");
+        XSSFSheet sheet = workbook.createSheet("Sheet 1");
         assertFalse(sheet.getScenarioProtect());
     }
     
@@ -720,8 +710,8 @@
     	
     	sheet.setDefaultColumnStyle((short) 3, cellStyle);
     	assertEquals(1, ctWorksheet.getColsArray(0).getColArray(0).getStyle());
-    	XSSFRow row = (XSSFRow) sheet.createRow(0);
-    	XSSFCell cell = (XSSFCell) sheet.getRow(0).createCell(3);
+    	XSSFRow row = sheet.createRow(0);
+    	XSSFCell cell = sheet.getRow(0).createCell(3);
     	
     }
     

Modified: poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java?rev=706691&r1=706690&r2=706691&view=diff
==============================================================================
--- poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java (original)
+++ poi/branches/ooxml/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java Tue Oct 21 10:56:34 2008
@@ -322,8 +322,6 @@
 		((XSSFFont)font).setBold(true);
 		font.setUnderline(Font.U_DOUBLE);
 		StylesTable styleSource=new StylesTable();
-		long index=styleSource.putFont(font);
-		workbook.setStylesSource(styleSource);
 		fontFind=workbook.findFont(Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK.getIndex(), (short)15, "Calibri", false, false, Font.SS_NONE, Font.U_DOUBLE);
 		assertNull(fontFind);
 	}
@@ -399,7 +397,7 @@
 	
 	public void testSetDisplayedTab(){
 		XSSFWorkbook workbook = new XSSFWorkbook();
-		workbook.setFirstVisibleTab(new Integer(1).shortValue());
+		workbook.setFirstVisibleTab(1);
 		short i = (short) workbook.getFirstVisibleTab();
 		//0 (defualt value) is not longer set
 		assertNotSame(0, i);



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


Mime
View raw message