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/23 19:35:32 UTC

svn commit: r698257 - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/examples/src/org/apache/poi/hssf/eventusermodel/examples/ src/java/org/apache/poi/hssf/extractor/ src/java/org/apache/poi/hssf/record/ src/java/org/apache/poi/hssf/us...

Author: nick
Date: Tue Sep 23 10:35:31 2008
New Revision: 698257

URL: http://svn.apache.org/viewvc?rev=698257&view=rev
Log:
Merged revisions 697562,697580,697584,697589,697595,697599 via svnmerge from 
https://svn.apache.org/repos/asf/poi/trunk

........
  r697562 | nick | 2008-09-21 18:49:20 +0100 (Sun, 21 Sep 2008) | 1 line
  
  Fix bug #45784 - Support long chart titles in SeriesTextRecords
........
  r697580 | nick | 2008-09-21 19:43:49 +0100 (Sun, 21 Sep 2008) | 1 line
  
  Include the sheet name in the output of examples.XLS2CSVmra
........
  r697584 | nick | 2008-09-21 19:56:32 +0100 (Sun, 21 Sep 2008) | 1 line
  
  Test to show that bug #45492 is invalid
........
  r697589 | nick | 2008-09-21 20:17:41 +0100 (Sun, 21 Sep 2008) | 1 line
  
  Update hssf.extractor.ExcelExtractor to optionally output blank cells too
........
  r697595 | nick | 2008-09-21 20:31:34 +0100 (Sun, 21 Sep 2008) | 1 line
  
  Improved tests to show that bugs #45062 and #44292 are fixed
........
  r697599 | nick | 2008-09-21 20:50:21 +0100 (Sun, 21 Sep 2008) | 1 line
  
  Apply part of patch from bug #16936, with the rest made more HSSFCell like - Initial support for whole-row cell styling
........

Added:
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45492.xls
      - copied unchanged from r697599, poi/trunk/src/testcases/org/apache/poi/hssf/data/45492.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/45784.xls
      - copied unchanged from r697599, poi/trunk/src/testcases/org/apache/poi/hssf/data/45784.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java
      - copied unchanged from r697599, poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestRowStyle.java
Modified:
    poi/branches/ooxml/   (props changed)
    poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
    poi/branches/ooxml/src/java/org/apache/poi/ss/   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/EvaluationCache.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/EvaluationTracker.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/FormulaParser.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/LazyAreaEval.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/LazyRefEval.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/OperandClassTransformer.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/ParseNode.java   (props changed)
    poi/branches/ooxml/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java   (props changed)
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/ss/   (props changed)

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk:693591-694881,695264-695420,695621,695649-697145,697520,697559
+/poi/trunk:693591-694881,695264-695420,695621,695649-697145,697520,697559,697562-697599

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-697539,697559
+/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-697539,697559,697562-697599

Modified: poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/changes.xml?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Tue Sep 23 10:35:31 2008
@@ -67,6 +67,10 @@
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
         </release>
         <release version="3.2-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">16936 - Initial support for whole-row cell styling</action>
+           <action dev="POI-DEVELOPERS" type="add">Update hssf.extractor.ExcelExtractor to optionally output blank cells too</action>
+           <action dev="POI-DEVELOPERS" type="add">Include the sheet name in the output of examples.XLS2CSVmra</action>
+           <action dev="POI-DEVELOPERS" type="fix">45784 - Support long chart titles in SeriesTextRecords</action>
            <action dev="POI-DEVELOPERS" type="fix">45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out</action>
            <action dev="POI-DEVELOPERS" type="add">45844 - Addtional diagnostics for HSLF SlideShowRecordDumper</action>
            <action dev="POI-DEVELOPERS" type="fix">45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero</action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/status.xml?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Tue Sep 23 10:35:31 2008
@@ -64,6 +64,10 @@
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling Excel files, irrespective of if they are .xls or .xlsx</action>
         </release>
         <release version="3.2-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">16936 - Initial support for whole-row cell styling</action>
+           <action dev="POI-DEVELOPERS" type="add">Update hssf.extractor.ExcelExtractor to optionally output blank cells too</action>
+           <action dev="POI-DEVELOPERS" type="add">Include the sheet name in the output of examples.XLS2CSVmra</action>
+           <action dev="POI-DEVELOPERS" type="fix">45784 - Support long chart titles in SeriesTextRecords</action>
            <action dev="POI-DEVELOPERS" type="fix">45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out</action>
            <action dev="POI-DEVELOPERS" type="add">45844 - Addtional diagnostics for HSLF SlideShowRecordDumper</action>
            <action dev="POI-DEVELOPERS" type="fix">45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero</action>

Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java Tue Sep 23 10:35:31 2008
@@ -21,6 +21,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.PrintStream;
+import java.util.ArrayList;
 
 import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener;
 import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
@@ -34,6 +35,7 @@
 import org.apache.poi.hssf.record.BOFRecord;
 import org.apache.poi.hssf.record.BlankRecord;
 import org.apache.poi.hssf.record.BoolErrRecord;
+import org.apache.poi.hssf.record.BoundSheetRecord;
 import org.apache.poi.hssf.record.FormulaRecord;
 import org.apache.poi.hssf.record.LabelRecord;
 import org.apache.poi.hssf.record.LabelSSTRecord;
@@ -69,6 +71,11 @@
 	// Records we pick up as we process
 	private SSTRecord sstRecord;
 	private FormatTrackingHSSFListener formatListener;
+	
+	/** So we known which sheet we're on */
+	private int sheetIndex = -1;
+	private BoundSheetRecord[] orderedBSRs;
+	private ArrayList boundSheetRecords = new ArrayList();
 
 	// For handling formulas with string results
 	private int nextRow;
@@ -132,6 +139,9 @@
 
 		switch (record.getSid())
 		{
+		case BoundSheetRecord.sid:
+			boundSheetRecords.add(record);
+			break;
 		case BOFRecord.sid:
 			BOFRecord br = (BOFRecord)record;
 			if(br.getType() == BOFRecord.TYPE_WORKSHEET) {
@@ -139,6 +149,17 @@
 				if(workbookBuildingListener != null && stubWorkbook == null) {
 					stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
 				}
+				
+				// Output the worksheet name
+				// Works by ordering the BSRs by the location of
+				//  their BOFRecords, and then knowing that we
+				//  process BOFRecords in byte offset order
+				sheetIndex++;
+				if(orderedBSRs == null) {
+					orderedBSRs = BoundSheetRecord.orderByBofPosition(boundSheetRecords);
+				}
+				output.println();
+				output.println(orderedBSRs[sheetIndex].getSheetname() + ":");
 			}
 			break;
 

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java Tue Sep 23 10:35:31 2008
@@ -45,6 +45,7 @@
 	private boolean includeSheetNames = true;
 	private boolean formulasNotResults = false;
 	private boolean includeCellComments = false;
+	private boolean includeBlankCells = false;
 	
 	public ExcelExtractor(HSSFWorkbook wb) {
 		super(wb);
@@ -77,13 +78,26 @@
     public void setIncludeCellComments(boolean includeCellComments) {
         this.includeCellComments = includeCellComments;
     }
+	/**
+	 * Should blank cells be output? Default is to only
+	 *  output cells that are present in the file and are
+	 *  non-blank.
+	 */
+	public void setIncludeBlankCells(boolean includeBlankCells) {
+		this.includeBlankCells = includeBlankCells;
+	}
 	
 	/**
 	 * Retreives the text contents of the file
 	 */
 	public String getText() {
 		StringBuffer text = new StringBuffer();
+
+		// We don't care about the differnce between
+		//  null (missing) and blank cells
+		wb.setMissingCellPolicy(HSSFRow.RETURN_BLANK_AS_NULL);
 		
+		// Process each sheet in turn
 		for(int i=0;i<wb.getNumberOfSheets();i++) {
 			HSSFSheet sheet = wb.getSheetAt(i);
 			if(sheet == null) { continue; }
@@ -112,63 +126,68 @@
 				// Check each cell in turn
 				int firstCell = row.getFirstCellNum();
 				int lastCell = row.getLastCellNum();
+				if(includeBlankCells) {
+					firstCell = 0;
+				}
+				
 				for(int k=firstCell;k<lastCell;k++) {
 					HSSFCell cell = row.getCell(k);
-					if(cell == null) { continue; }
 					boolean outputContents = true;
-					
-					switch(cell.getCellType()) {
-						case HSSFCell.CELL_TYPE_BLANK:
-							outputContents = false;
-							break;
-						case HSSFCell.CELL_TYPE_STRING:
-							text.append(cell.getRichStringCellValue().getString());
-							break;
-						case HSSFCell.CELL_TYPE_NUMERIC:
-							// Note - we don't apply any formatting!
-							text.append(cell.getNumericCellValue());
-							break;
-						case HSSFCell.CELL_TYPE_BOOLEAN:
-							text.append(cell.getBooleanCellValue());
-							break;
-						case HSSFCell.CELL_TYPE_ERROR:
-							text.append(ErrorEval.getText(cell.getErrorCellValue()));
-							break;
-						case HSSFCell.CELL_TYPE_FORMULA:
-							if(formulasNotResults) {
-								text.append(cell.getCellFormula());
-							} else {
-								switch(cell.getCachedFormulaResultType()) {
-									case HSSFCell.CELL_TYPE_STRING:
-										HSSFRichTextString str = cell.getRichStringCellValue();
-										if(str != null && str.length() > 0) {
-											text.append(str.toString());
-										}
-										break;
-									case HSSFCell.CELL_TYPE_NUMERIC:
-										text.append(cell.getNumericCellValue());
-										break;
-									case HSSFCell.CELL_TYPE_BOOLEAN:
-										text.append(cell.getBooleanCellValue());
-										break;
-									case HSSFCell.CELL_TYPE_ERROR:
-										text.append(ErrorEval.getText(cell.getErrorCellValue()));
-										break;
-										
+
+					if(cell == null) {
+						// Only output if requested
+						outputContents = includeBlankCells;
+					} else {
+						switch(cell.getCellType()) {
+							case HSSFCell.CELL_TYPE_STRING:
+								text.append(cell.getRichStringCellValue().getString());
+								break;
+							case HSSFCell.CELL_TYPE_NUMERIC:
+								// Note - we don't apply any formatting!
+								text.append(cell.getNumericCellValue());
+								break;
+							case HSSFCell.CELL_TYPE_BOOLEAN:
+								text.append(cell.getBooleanCellValue());
+								break;
+							case HSSFCell.CELL_TYPE_ERROR:
+								text.append(ErrorEval.getText(cell.getErrorCellValue()));
+								break;
+							case HSSFCell.CELL_TYPE_FORMULA:
+								if(formulasNotResults) {
+									text.append(cell.getCellFormula());
+								} else {
+									switch(cell.getCachedFormulaResultType()) {
+										case HSSFCell.CELL_TYPE_STRING:
+											HSSFRichTextString str = cell.getRichStringCellValue();
+											if(str != null && str.length() > 0) {
+												text.append(str.toString());
+											}
+											break;
+										case HSSFCell.CELL_TYPE_NUMERIC:
+											text.append(cell.getNumericCellValue());
+											break;
+										case HSSFCell.CELL_TYPE_BOOLEAN:
+											text.append(cell.getBooleanCellValue());
+											break;
+										case HSSFCell.CELL_TYPE_ERROR:
+											text.append(ErrorEval.getText(cell.getErrorCellValue()));
+											break;
+											
+									}
 								}
-							}
-							break;
-						default:
-							throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")");
-					}
-					
-					// Output the comment, if requested and exists
-				    HSSFComment comment = cell.getCellComment();
-					if(includeCellComments && comment != null) {
-					    // Replace any newlines with spaces, otherwise it
-					    //  breaks the output
-					    String commentText = comment.getString().getString().replace('\n', ' ');
-					    text.append(" Comment by "+comment.getAuthor()+": "+commentText);
+								break;
+							default:
+								throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")");
+						}
+						
+						// Output the comment, if requested and exists
+					    HSSFComment comment = cell.getCellComment();
+						if(includeCellComments && comment != null) {
+						    // Replace any newlines with spaces, otherwise it
+						    //  breaks the output
+						    String commentText = comment.getString().getString().replace('\n', ' ');
+						    text.append(" Comment by "+comment.getAuthor()+": "+commentText);
+						}
 					}
 					
 					// Output a tab if we're not on the last cell

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/BoundSheetRecord.java Tue Sep 23 10:35:31 2008
@@ -17,6 +17,10 @@
 
 package org.apache.poi.hssf.record;
 
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
 import org.apache.poi.util.LittleEndian;
@@ -329,4 +333,31 @@
     public void setVeryHidden(boolean veryHidden) {
 	    field_2_option_flags = veryHiddenFlag.setShortBoolean(field_2_option_flags, veryHidden);
     }
+    
+    /**
+     * Takes a list of BoundSheetRecords, and returns the all
+     *  ordered by the position of their BOFs.
+     */
+    public static BoundSheetRecord[] orderByBofPosition(List boundSheetRecords) {
+    	BoundSheetRecord[] bsrs = (BoundSheetRecord[])boundSheetRecords.toArray(
+    			new BoundSheetRecord[boundSheetRecords.size()]);
+    	
+    	// Sort
+    	Arrays.sort(bsrs, new BOFComparator());
+    	
+    	// All done
+    	return bsrs;
+    }
+    private static class BOFComparator implements Comparator {
+		public int compare(Object bsr1, Object bsr2) {
+			return compare((BoundSheetRecord)bsr1, (BoundSheetRecord)bsr2);
+		}
+		public int compare(BoundSheetRecord bsr1, BoundSheetRecord bsr2) {
+			if(bsr1.field_1_position_of_BOF < bsr2.field_1_position_of_BOF)
+				return -1;
+			if(bsr1.field_1_position_of_BOF == bsr2.field_1_position_of_BOF)
+				return 0;
+			return 1;
+		}
+    }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java Tue Sep 23 10:35:31 2008
@@ -75,7 +75,8 @@
         field_1_id                     = in.readShort();
         field_2_textLength             = in.readByte();
         field_3_undocumented           = in.readByte();
-        field_4_text                   = in.readUnicodeLEString(field_2_textLength);
+        field_4_text                   = in.readUnicodeLEString(
+        		LittleEndian.ubyteToInt(field_2_textLength));
     }
 
     public String toString()
@@ -163,18 +164,34 @@
     /**
      * Get the text length field for the SeriesText record.
      */
-    public byte getTextLength()
+    public int getTextLength()
     {
-        return field_2_textLength;
+        return LittleEndian.ubyteToInt(field_2_textLength);
     }
 
     /**
      * Set the text length field for the SeriesText record.
+     * Needs to be wrapped.
      */
     public void setTextLength(byte field_2_textLength)
     {
         this.field_2_textLength = field_2_textLength;
     }
+    /**
+     * Set the text length field for the SeriesText record.
+     */
+    public void setTextLength(int field_2_textLength)
+    {
+    	if(field_2_textLength > 255) {
+    		throw new IllegalArgumentException("Length must be 0-255");
+    	}
+    	if(field_2_textLength > 127) {
+    		this.field_2_textLength = (byte)
+    			(field_2_textLength-256);
+    	} else {
+    		this.field_2_textLength = (byte)field_2_textLength;
+    	}
+    }
 
     /**
      * Get the undocumented field for the SeriesText record.

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Tue Sep 23 10:35:31 2008
@@ -926,7 +926,9 @@
     }
 
     /**
-     * get the background fill color
+     * Get the background fill color.
+     * Note - many cells are actually filled with a foreground
+     *  fill, not a background fill - see {@link #getFillForegroundColor()}
      * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
      * @return fill color
      */
@@ -952,7 +954,9 @@
     }
 
     /**
-     * get the foreground fill color
+     * Get the foreground fill color.
+     * Many cells are filled with this, instead of a 
+     *  background color ({@link #getFillBackgroundColor()})
      * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
      * @return fill color
      */

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPalette.java Tue Sep 23 10:35:31 2008
@@ -58,6 +58,15 @@
     	}
         return null;
     }
+    /**
+     * Retrieves the color at a given index
+     *
+     * @param index the palette index, between 0x8 to 0x40 inclusive
+     * @return the color, or null if the index is not populated
+     */
+    public HSSFColor getColor(int index) {
+    	return getColor((short)index);
+    }
     
     /**
      * Finds the first occurance of a given color

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java Tue Sep 23 10:35:31 2008
@@ -21,6 +21,7 @@
 import java.util.NoSuchElementException;
 
 import org.apache.poi.hssf.record.CellValueRecordInterface;
+import org.apache.poi.hssf.record.ExtendedFormatRecord;
 import org.apache.poi.hssf.record.RowRecord;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
@@ -525,6 +526,33 @@
             return -1;
         return cellnum;
     }
+    
+    /**
+     * Is this row formatted? Most aren't, but some rows
+     *  do have whole-row styles. For those that do, you
+     *  can get the formatting from {@link #getRowStyle()}
+     */
+    public boolean isFormatted() {
+    	return row.getFormatted();
+    }
+    /**
+     * Returns the whole-row cell styles. Most rows won't
+     *  have one of these, so will return null. Call
+     *  {@link #isFormatted()} to check first.
+     */
+    public HSSFCellStyle getRowStyle() {
+    	if(!isFormatted()) { return null; }
+        short styleIndex = row.getXFIndex();
+        ExtendedFormatRecord xf = book.getWorkbook().getExFormatAt(styleIndex);
+        return new HSSFCellStyle(styleIndex, xf, book);
+    }
+    /**
+     * Applies a whole-row cell styling to the row.
+     */
+    public void setRowStyle(HSSFCellStyle style) {
+    	row.setFormatted(true);
+    	row.setXFIndex(style.getIndex());
+    }
 
     /**
      * @return cell iterator of the physically defined cells. 

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss:693591-694881,695264-695420,695621,695649-696627,696860-696898,697145,697520,697559
+/poi/trunk/src/java/org/apache/poi/ss:693591-694881,695264-695420,695621,695649-696627,696860-696898,697145,697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/EvaluationCache.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationCache.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/EvaluationTracker.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/FormulaParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/LazyAreaEval.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/LazyAreaEval.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/LazyAreaEval.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/LazyRefEval.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/LazyRefEval.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/LazyRefEval.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/OperandClassTransformer.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/OperandClassTransformer.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/OperandClassTransformer.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/ParseNode.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/ParseNode.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/ParseNode.java:697520,697559,697562-697599

Propchange: poi/branches/ooxml/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java:697520,697559
+/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java:697520,697559,697562-697599

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java Tue Sep 23 10:35:31 2008
@@ -74,7 +74,8 @@
 	}
 
 	/**
-	 * Test for TableCell not skipping the last paragraph
+	 * Test for TableCell not skipping the last paragraph.
+	 * Bugs #45062 and #44292
 	 */
 	public void testTableCellLastParagraph() throws Exception {
     	HWPFDocument doc = new HWPFDocument(new FileInputStream(
@@ -93,22 +94,27 @@
 		Table t = r.getTable(p);
 		
 		//get the only row
+		assertEquals(1, t.numRows());
 		TableRow row = t.getRow(0);
 		
 		//get the first cell
 		TableCell cell = row.getCell(0);
 		// First cell should have one paragraph
 		assertEquals(1, cell.numParagraphs());
+		assertEquals("One paragraph is ok\7", cell.getParagraph(0).text());
 		
 		//get the second
 		cell = row.getCell(1);
 		// Second cell should be detected as having two paragraphs
 		assertEquals(2, cell.numParagraphs());
+		assertEquals("First para is ok\r", cell.getParagraph(0).text());
+		assertEquals("Second paragraph is skipped\7", cell.getParagraph(1).text());
 				
 		//get the last cell
 		cell = row.getCell(2);
 		// Last cell should have one paragraph
 		assertEquals(1, cell.numParagraphs());
+		assertEquals("One paragraph is ok\7", cell.getParagraph(0).text());
 	}
 
 	public void testRangeDelete() throws Exception {

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/extractor/TestExcelExtractor.java Tue Sep 23 10:35:31 2008
@@ -187,6 +187,27 @@
 		);
 	}
 	
+	public void testWithBlank() throws Exception {
+		ExcelExtractor extractor = createExtractor("MissingBits.xls");
+		String def = extractor.getText();
+		extractor.setIncludeBlankCells(true);
+		String padded = extractor.getText();
+		
+		assertTrue(def.startsWith(
+				"Sheet1\n" +
+				"&[TAB]\t\n" +
+				"Hello\t\n" +
+				"11.0\t23.0\t\n"
+		));
+		
+		assertTrue(padded.startsWith(
+				"Sheet1\n" +
+				"&[TAB]\t\n" +
+				"Hello\t\t\t\t\t\t\t\t\t\t\t\n" +
+				"11.0\t\t\t23.0\t\t\t\t\t\t\t\t\n"
+		));
+	}
+	
 	
 	/**
 	 * Embded in a non-excel file

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestBOFRecord.java Tue Sep 23 10:35:31 2008
@@ -18,6 +18,7 @@
 package org.apache.poi.hssf.record;
 
 import java.io.InputStream;
+import java.util.ArrayList;
 
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
@@ -38,4 +39,24 @@
             throw new AssertionFailedError("Identified bug 42794");
         }
     }
+    
+    public void testOrdering() throws Exception {
+    	BoundSheetRecord bs1 = new BoundSheetRecord();
+    	BoundSheetRecord bs2 = new BoundSheetRecord();
+    	BoundSheetRecord bs3 = new BoundSheetRecord();
+    	bs1.setPositionOfBof(11);
+    	bs2.setPositionOfBof(33);
+    	bs3.setPositionOfBof(22);
+    	
+    	ArrayList l = new ArrayList();
+    	l.add(bs1);
+    	l.add(bs2);
+    	l.add(bs3);
+    	
+    	BoundSheetRecord[] r = BoundSheetRecord.orderByBofPosition(l);
+    	assertEquals(3, r.length);
+    	assertEquals(bs1, r[0]);
+    	assertEquals(bs3, r[1]);
+    	assertEquals(bs2, r[2]);
+    }
 }

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=698257&r1=698256&r2=698257&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Sep 23 10:35:31 2008
@@ -1476,4 +1476,49 @@
     		fail();
     	} catch(IllegalArgumentException e) {}
     }
+    
+    /**
+     * Charts with long titles
+     */
+    public void test45784() {
+    	// This used to break
+        HSSFWorkbook wb = openSample("45784.xls");
+        assertEquals(1, wb.getNumberOfSheets());
+    }
+    
+   /**
+     * Cell background colours
+     */
+    public void test45492() {
+    	HSSFWorkbook wb = openSample("45492.xls");
+    	HSSFSheet s = wb.getSheetAt(0);
+    	HSSFRow r = s.getRow(0);
+    	HSSFPalette p = wb.getCustomPalette();
+    	
+    	HSSFCell auto = r.getCell(0);
+    	HSSFCell grey = r.getCell(1);
+    	HSSFCell red = r.getCell(2);
+    	HSSFCell blue = r.getCell(3);
+    	HSSFCell green = r.getCell(4);
+    	
+    	assertEquals(64, auto.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, auto.getCellStyle().getFillBackgroundColor());
+    	assertEquals("0:0:0", p.getColor(64).getHexString());
+    	
+    	assertEquals(22, grey.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, grey.getCellStyle().getFillBackgroundColor());
+    	assertEquals("C0C0:C0C0:C0C0", p.getColor(22).getHexString());
+    	
+    	assertEquals(10, red.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, red.getCellStyle().getFillBackgroundColor());
+    	assertEquals("FFFF:0:0", p.getColor(10).getHexString());
+    	
+    	assertEquals(12, blue.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, blue.getCellStyle().getFillBackgroundColor());
+    	assertEquals("0:0:FFFF", p.getColor(12).getHexString());
+    	
+    	assertEquals(11, green.getCellStyle().getFillForegroundColor());
+    	assertEquals(64, green.getCellStyle().getFillBackgroundColor());
+    	assertEquals("0:FFFF:0", p.getColor(11).getHexString());
+    }
 }

Propchange: poi/branches/ooxml/src/testcases/org/apache/poi/ss/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Sep 23 10:35:31 2008
@@ -1 +1 @@
-/poi/trunk/src/testcases/org/apache/poi/ss:693591-694881,695264-695420,695621,695649-696813,697145,697520,697559
+/poi/trunk/src/testcases/org/apache/poi/ss:693591-694881,695264-695420,695621,695649-696813,697145,697520,697559,697562-697599



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