You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ug...@apache.org on 2008/02/04 17:55:47 UTC

svn commit: r618325 [1/2] - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/java/org/apache/poi/hssf/dev/ src/java/org/apache/poi/hssf/eventusermodel/ src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/ src/java/org...

Author: ugo
Date: Mon Feb  4 08:55:43 2008
New Revision: 618325

URL: http://svn.apache.org/viewvc?rev=618325&view=rev
Log:
Merged revisions 615190-618235 via svnmerge from 
https://svn.apache.org/repos/asf/poi/trunk

........
  r615190 | nick | 2008-01-25 12:52:39 +0100 (Fri, 25 Jan 2008) | 1 line
  
  Correctly handle the last paragraph via a fix to TableCell - patch from bug #44292
........
  r615255 | nick | 2008-01-25 17:15:49 +0100 (Fri, 25 Jan 2008) | 1 line
  
  Don't swap AreaPtg references from relative to absolute, by correctly processing the fields. Patch from bug #44293
........
  r615259 | nick | 2008-01-25 17:33:59 +0100 (Fri, 25 Jan 2008) | 1 line
  
  Add a test to show the bug #42618 appears to be incorrect
........
  r615310 | yegor | 2008-01-25 20:27:56 +0100 (Fri, 25 Jan 2008) | 1 line
  
  commented failing test42618()
........
  r615315 | yegor | 2008-01-25 20:37:22 +0100 (Fri, 25 Jan 2008) | 1 line
  
  fix bug #44296: HSLF Not Extracting Slide Background Image
........
  r615610 | yegor | 2008-01-27 15:55:32 +0100 (Sun, 27 Jan 2008) | 1 line
  
  fix bug #44297: IntPtg must operate with unsigned short. Reading signed short results in incorrect formula calculation.
........
  r615769 | yegor | 2008-01-28 09:53:19 +0100 (Mon, 28 Jan 2008) | 1 line
  
  start a new POI 3.1 section in the change log
........
  r615859 | nick | 2008-01-28 13:18:12 +0100 (Mon, 28 Jan 2008) | 1 line
  
  Mostly fix bug 42618 (really this time...) - can now open the file properly, but getCellFormula() is still playing up (bug #44306 opened for this)
........
  r617156 | nick | 2008-01-31 17:41:53 +0100 (Thu, 31 Jan 2008) | 1 line
  
  Lots of documentation updates, to make it clearer how the code actually works
........
  r617167 | nick | 2008-01-31 18:30:16 +0100 (Thu, 31 Jan 2008) | 1 line
  
  Convert HSSFEventFactory to using the new HSSFRecordStream, which returns fully-formed HSSFRecords. HSSFRecordStream allows for pull-style eventusermodel processing
........
  r617483 | nick | 2008-02-01 13:13:08 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Tweak the javadoc so it's clearer on the overview what the getFormat method does
........
  r617487 | nick | 2008-02-01 13:29:38 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions - triggered by bug #44326
........
  r617491 | nick | 2008-02-01 14:02:06 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Patch from bug #44336 - correctly escape sheet names in formula references, including tests for this, and fixes to old tests that were expecting the un-escaped sheet names
........
  r617516 | nick | 2008-02-01 16:20:55 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Make a start on the hyperlink record support - not finished yet though, so not enabled
........
  r617523 | nick | 2008-02-01 16:41:32 +0100 (Fri, 01 Feb 2008) | 1 line
  
  Get the Hyperlink record code so that it doesn't break any existing tests, and add in (no usermodel support yet though)
........
  r617555 | nick | 2008-02-01 17:52:58 +0100 (Fri, 01 Feb 2008) | 1 line
  
  More Hyperlink support. Doesn't end up in HSSFCell just yet, as the records are in the wrong bit of the file, so don't get associated with the sheet. All tests still passing though
........
  r617834 | yegor | 2008-02-02 18:06:14 +0100 (Sat, 02 Feb 2008) | 1 line
  
  usermodel support for excel hyperlinks
........
  r618230 | nick | 2008-02-04 11:48:29 +0100 (Mon, 04 Feb 2008) | 1 line
  
  Implement CountA, CountIf, Index, Rows and Columns functions. Patch from Josh Micich in bug #44345
........
  r618235 | nick | 2008-02-04 12:14:49 +0100 (Mon, 04 Feb 2008) | 1 line
  
  Test file with hyperlinks on many sheets, of different types
........

Added:
    poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/HSSFRecordStream.java
      - copied unchanged from r618235, poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/HSSFRecordStream.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
      - copied unchanged from r618235, poi/trunk/src/java/org/apache/poi/hssf/record/HyperlinkRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/SheetNameFormatter.java
      - copied unchanged from r618235, poi/trunk/src/java/org/apache/poi/hssf/record/formula/SheetNameFormatter.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
      - copied unchanged from r618235, poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/data/44296.ppt
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/data/44297.xls
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/data/44297.xls
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/EvalFactory.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/EvalFactory.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestIndex.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestIndex.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRowCol.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestRowCol.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestBug44297.java
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestBug44297.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44292.doc
      - copied unchanged from r618235, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44292.doc
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/HyperlinksOnManySheets.xls
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/data/HyperlinksOnManySheets.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/SimpleWithChoose.xls
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/data/SimpleWithChoose.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/WithHyperlink.xls
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/data/WithHyperlink.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/WithTwoHyperLinks.xls
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/data/WithTwoHyperLinks.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/record/TestHyperlinkRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArea3DPtg.java
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArea3DPtg.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestAreaPtg.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestRef3DPtg.java
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestRef3DPtg.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestSheetNameFormatter.java
      - copied unchanged from r618235, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestSheetNameFormatter.java
Modified:
    poi/branches/ooxml/   (props changed)
    poi/branches/ooxml/build.xml
    poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/BiffViewer.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordFactory.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordInputStream.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ptg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RangePtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java
    poi/branches/ooxml/src/java/org/apache/poi/util/CommonsLogger.java
    poi/branches/ooxml/src/java/org/apache/poi/util/POILogger.java
    poi/branches/ooxml/src/java/org/apache/poi/util/SystemOutLogger.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestProblems.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/HSSFTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AbstractPtgTestCase.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestFuncPtg.java   (props changed)
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestNamedRange.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Feb  4 08:55:43 2008
@@ -1 +1 @@
-/poi/trunk:1-612483,612512,612520,613395-613401,614211,614274,614870,614878-614909
+/poi/trunk:1-612483,612512,612520,613395-613401,614211,614274,614870,614878-614909,615190-618235

Modified: poi/branches/ooxml/build.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/build.xml?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/build.xml (original)
+++ poi/branches/ooxml/build.xml Mon Feb  4 08:55:43 2008
@@ -167,7 +167,7 @@
   <property name="mavendist.poi.dir" location="build/maven-dist/poi"/>
   <property name="mavendist.oap.dir" location="build/maven-dist/org.apache.poi"/>
   <property name="jar.name" value="poi"/>
-  <property name="version.id" value="3.0.2-beta1"/>
+  <property name="version.id" value="3.1-alpha1"/>
   <property name="halt.on.test.failure" value="true"/>
 
   <property name="jdk.version.source" value="1.5"
@@ -279,6 +279,7 @@
         <antcall target="with.clover"/>
         
         <mkdir dir="build"/>
+        <mkdir dir="build/non-ant-classes"/>
         <mkdir dir="${main.output.dir}"/>
         <mkdir dir="${main14.output.dir}"/>
         <mkdir dir="${scratchpad.output.dir}"/>

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=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Mon Feb  4 08:55:43 2008
@@ -35,7 +35,17 @@
     </devs>
 
 		<!-- Don't forget to update status.xml too! -->
-        <release version="3.0.2-FINAL" date="2008-??-??">
+        <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44345 - Implement CountA, CountIf, Index, Rows and Columns functions</action>
+           <action dev="POI-DEVELOPERS" type="fix">44336 - Properly escape sheet names as required when figuring out the text of formulas</action>
+           <action dev="POI-DEVELOPERS" type="add">44326 - Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions</action>
+           <action dev="POI-DEVELOPERS" type="add">Support for a completed Record based "pull" stream, via org.apache.poi.hssf.eventusermodel.HSSFRecordStream, to complement the existing "push" Event User Model listener stuff</action>
+        </release>
+        <release version="3.0.2-FINAL" date="2008-02-04">
+            <action dev="POI-DEVELOPERS" type="fix">44297 - IntPtg must operate with unsigned short. Reading signed short results in incorrect formula calculation</action>
+            <action dev="POI-DEVELOPERS" type="fix">44296 - Fix for reading slide background images</action>
+            <action dev="POI-DEVELOPERS" type="fix">44293 - Avoid swapping AreaPtgs from relative to absolute</action>
+            <action dev="POI-DEVELOPERS" type="fix">44292 - Correctly process the last paragraph in a word file</action>
             <action dev="POI-DEVELOPERS" type="fix">44254 - Avoid some unread byte warnings, and properly understand DVALRecord</action>
             <action dev="POI-DEVELOPERS" type="add">Add another formula evaluation method, evaluateFormulaCell(cell), which will re-calculate the value for a formula, without affecting the formula itself.</action>
             <action dev="POI-DEVELOPERS" type="fix">41726 - Fix how we handle signed cell offsets in relative areas and references</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=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Mon Feb  4 08:55:43 2008
@@ -32,7 +32,17 @@
 
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
-        <release version="3.0.2-FINAL" date="2008-??-??">
+        <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">44345 - Implement CountA, CountIf, Index, Rows and Columns functions</action>
+           <action dev="POI-DEVELOPERS" type="fix">44336 - Properly escape sheet names as required when figuring out the text of formulas</action>
+           <action dev="POI-DEVELOPERS" type="add">44326 - Improvements to how SystemOutLogger and CommonsLogger log messages with exceptions, and avoid an infinite loop with certain log messages with exceptions</action>
+           <action dev="POI-DEVELOPERS" type="add">Support for a completed Record based "pull" stream, via org.apache.poi.hssf.eventusermodel.HSSFRecordStream, to complement the existing "push" Event User Model listener stuff</action>
+        </release>
+        <release version="3.0.2-FINAL" date="2008-02-04">
+            <action dev="POI-DEVELOPERS" type="fix">44297 - IntPtg must operate with unsigned short. Reading signed short results in incorrect formula calculation</action>
+            <action dev="POI-DEVELOPERS" type="fix">44296 - Fix for reading slide background images</action>
+            <action dev="POI-DEVELOPERS" type="fix">44293 - Avoid swapping AreaPtgs from relative to absolute</action>
+            <action dev="POI-DEVELOPERS" type="fix">44292 - Correctly process the last paragraph in a word file</action>
             <action dev="POI-DEVELOPERS" type="fix">44254 - Avoid some unread byte warnings, and properly understand DVALRecord</action>
             <action dev="POI-DEVELOPERS" type="add">Add another formula evaluation method, evaluateFormulaCell(cell), which will re-calculate the value for a formula, without affecting the formula itself.</action>
             <action dev="POI-DEVELOPERS" type="fix">41726 - Fix how we handle signed cell offsets in relative areas and references</action>

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/BiffViewer.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/BiffViewer.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/BiffViewer.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/BiffViewer.java Mon Feb  4 08:55:43 2008
@@ -515,6 +515,9 @@
             case FileSharingRecord.sid:
                 retval = new FileSharingRecord( in );
                 break;
+            case HyperlinkRecord.sid:
+                retval = new HyperlinkRecord( in );
+                break;
             default:
                 retval = new UnknownRecord( in );
         }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/HSSFEventFactory.java Mon Feb  4 08:55:43 2008
@@ -129,109 +129,25 @@
 	protected short genericProcessEvents(HSSFRequest req, RecordInputStream in)
 		throws IOException, HSSFUserException
 	{
+		boolean going = true;
 		short userCode = 0;
-
-		short sid = 0;
-		process:
-		{
-                  
-			Record rec       = null;
-			Record lastRec   = null;
-			DrawingRecord lastDrawingRecord = new DrawingRecord();
-
-			while (in.hasNextRecord())
-			{
-				in.nextRecord();
-				sid = in.getSid();;
-
-                //
-                // for some reasons we have to make the workbook to be at least 4096 bytes
-                // but if we have such workbook we fill the end of it with zeros (many zeros)
-                //
-                // it is not good:
-                // if the length( all zero records ) % 4 = 1
-                // e.g.: any zero record would be readed as  4 bytes at once ( 2 - id and 2 - size ).
-                // And the last 1 byte will be readed WRONG ( the id must be 2 bytes )
-                //
-                // So we should better to check if the sid is zero and not to read more data
-                // The zero sid shows us that rest of the stream data is a fake to make workbook 
-                // certain size
-                //
-                if ( sid == 0 )
-                    break;
-
-
-				if ((rec != null) && (sid != ContinueRecord.sid))
-				{
-					userCode = req.processRecord(rec);
-					if (userCode != 0) break process;
-				}
-				if (sid != ContinueRecord.sid)
-				{
-                                        //System.out.println("creating "+sid);
-					Record[] recs = RecordFactory.createRecord(in);
-
-					if (recs.length > 1)
-					{                                // we know that the multiple
-						for (int k = 0; k < (recs.length - 1); k++)
-						{                            // record situations do not
-							userCode = req.processRecord(
-								recs[ k ]);          // contain continue records
-							if (userCode != 0) break process;
-						}
-					}
-					rec = recs[ recs.length - 1 ];   // regardless we'll process
-
-					// the last record as though
-					// it might be continued
-					// if there is only one
-					// records, it will go here too.
-				}
-				else {
-					// Normally, ContinueRecords are handled internally
-					// However, in a few cases, there is a gap between a record at
-					//  its Continue, so we have to handle them specially
-					// This logic is much like in RecordFactory.createRecords()
-					Record[] recs = RecordFactory.createRecord(in);
-					ContinueRecord crec = (ContinueRecord)recs[0];
-					if((lastRec instanceof ObjRecord) || (lastRec instanceof TextObjectRecord)) {
-						// You can have Obj records between a DrawingRecord
-						//  and its continue!
-						lastDrawingRecord.processContinueRecord( crec.getData() );
-						// Trigger them on the drawing record, now it's complete
-						rec = lastDrawingRecord;
-					}
-					else if((lastRec instanceof DrawingGroupRecord)) {
-						((DrawingGroupRecord)lastRec).processContinueRecord(crec.getData());
-						// Trigger them on the drawing record, now it's complete
-						rec = lastRec;
-					}
-					else {
-                        if (rec instanceof UnknownRecord) {
-                            ;//silently skip records we don't know about
-                        } else {
-						    throw new RecordFormatException("Records should handle ContinueRecord internally. Should not see this exception");
-                        }
-					}
-				}
-
-				// Update our tracking of the last record
-				lastRec = rec;
-				if(rec instanceof DrawingRecord) {
-					lastDrawingRecord = (DrawingRecord)rec;
-				}
-			}
-			if (rec != null)
-			{
-				userCode = req.processRecord(rec);
-				if (userCode != 0) break process;
+		Record r = null;
+		
+		// Create a new RecordStream and use that
+		HSSFRecordStream recordStream = new HSSFRecordStream(in);
+		
+		// Process each record as they come in
+		while(going) {
+			r = recordStream.nextRecord();
+			if(r != null) {
+				userCode = req.processRecord(r);
+				if (userCode != 0) break;
+			} else {
+				going = false;
 			}
 		}
 		
+		// All done, return our last code
 		return userCode;
-
-		// Record[] retval = new Record[ records.size() ];
-		// retval = ( Record [] ) records.toArray(retval);
-		// return null;
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java Mon Feb  4 08:55:43 2008
@@ -93,6 +93,8 @@
     protected ArrayList        formats = new ArrayList();
 
     protected ArrayList        names = new ArrayList();
+    
+    protected ArrayList        hyperlinks = new ArrayList();
 
     protected int              numxfs      = 0;   // hold the number of extended format records
     protected int              numfonts    = 0;   // hold the number of font records
@@ -133,7 +135,8 @@
         Workbook  retval  = new Workbook();
         ArrayList records = new ArrayList(recs.size() / 3);
 
-        for (int k = 0; k < recs.size(); k++) {
+        int k;
+        for (k = 0; k < recs.size(); k++) {
             Record rec = ( Record ) recs.get(k);
 
             if (rec.getSid() == EOFRecord.sid) {
@@ -248,6 +251,17 @@
         //            retval.records.supbookpos = retval.records.bspos + 1;
         //            retval.records.namepos    = retval.records.supbookpos + 1;
         //        }
+        
+        // Look for other interesting values that
+        //  follow the EOFRecord
+        for ( ; k < recs.size(); k++) {
+            Record rec = ( Record ) recs.get(k);
+            switch (rec.getSid()) {
+            	case HyperlinkRecord.sid:
+            		retval.hyperlinks.add(rec);
+            		break;
+            }
+        }
 
         retval.records.setRecords(records);
         
@@ -2116,6 +2130,11 @@
         return null;
     }
 
+    public List getHyperlinks()
+    {
+    	return hyperlinks;
+    }
+    
     public List getRecords()
     {
         return records.getRecords();

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordFactory.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordFactory.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordFactory.java Mon Feb  4 08:55:43 2008
@@ -76,7 +76,8 @@
                 WriteProtectRecord.class, FilePassRecord.class, PaneRecord.class,
                 NoteRecord.class, ObjectProtectRecord.class, ScenarioProtectRecord.class, 
                 FileSharingRecord.class, ChartTitleFormatRecord.class,
-                DVRecord.class, DVALRecord.class, UncalcedRecord.class
+                DVRecord.class, DVALRecord.class, UncalcedRecord.class,
+                HyperlinkRecord.class
             };
     }
     private static Map           recordsMap  = recordsToMap(records);

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordInputStream.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordInputStream.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordInputStream.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/RecordInputStream.java Mon Feb  4 08:55:43 2008
@@ -249,7 +249,7 @@
    */  
   public String readUnicodeLEString(int length) {
     if ((length < 0) || (((remaining() / 2) < length) && !isContinueNext())) {
-            throw new IllegalArgumentException("Illegal length");
+            throw new IllegalArgumentException("Illegal length - asked for " + length + " but only " + (remaining()/2) + " left!");
     }
 
     StringBuffer buf = new StringBuffer(length);

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Area3DPtg.java Mon Feb  4 08:55:43 2008
@@ -261,13 +261,16 @@
 		setLastRowRelative(  !lastCell.isRowAbsolute() );
 	}
 
+    /**
+     * @return text representation of this area reference that can be used in text
+     *  formulas. The sheet name will get properly delimited if required.
+     */
 	public String toFormulaString(Workbook book)
 	{
-		SheetReferences refs = book == null ? null : book.getSheetReferences();
 		StringBuffer retval = new StringBuffer();
-		if ( refs != null )
-		{
-			retval.append( refs.getSheetName( this.field_1_index_extern_sheet ) );
+		String sheetName = Ref3DPtg.getSheetName(book, field_1_index_extern_sheet);
+		if(sheetName != null) {
+			SheetNameFormatter.appendFormat(retval, sheetName);
 			retval.append( '!' );
 		}
 		retval.append( ( new CellReference( getFirstRow(), getFirstColumn(), !isFirstRowRelative(), !isFirstColRelative() ) ).toString() );

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaPtg.java Mon Feb  4 08:55:43 2008
@@ -43,9 +43,9 @@
     private short             field_3_first_column;
     private short             field_4_last_column;
     
-    private BitField         rowRelative = BitFieldFactory.getInstance(0x8000);
-    private BitField         colRelative = BitFieldFactory.getInstance(0x4000);
-    private BitField         column      = BitFieldFactory.getInstance(0x3FFF);
+    private final static BitField   rowRelative = BitFieldFactory.getInstance(0x8000);
+    private final static BitField   colRelative = BitFieldFactory.getInstance(0x4000);
+    private final static BitField   columnMask      = BitFieldFactory.getInstance(0x3FFF);
 
     protected AreaPtg() {
       //Required for clone methods
@@ -157,7 +157,7 @@
      */
     public short getFirstColumn()
     {
-        return column.getShortValue(field_3_first_column);
+        return columnMask.getShortValue(field_3_first_column);
     }
 
     /**
@@ -204,7 +204,7 @@
      */
     public void setFirstColumn(short column)
     {
-        field_3_first_column = column;   // fixme
+    	field_3_first_column=columnMask.setShortValue(field_3_first_column, column);
     }
 
     /**
@@ -220,7 +220,7 @@
      */
     public short getLastColumn()
     {
-        return column.getShortValue(field_4_last_column);
+        return columnMask.getShortValue(field_4_last_column);
     }
 
     /**
@@ -269,7 +269,7 @@
      */
     public void setLastColumn(short column)
     {
-        field_4_last_column = column;   // fixme
+    	field_4_last_column=columnMask.setShortValue(field_4_last_column, column);
     }
 
     /**

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ConcatPtg.java Mon Feb  4 08:55:43 2008
@@ -34,11 +34,10 @@
     public final static byte sid  = 0x08;
     
     private final static String CONCAT = "&";
-
+    
     public ConcatPtg(RecordInputStream in)
     {
-
-        // doesn't need anything
+    	// No contents
     }
     
     public ConcatPtg() {

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/IntPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/IntPtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/IntPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/IntPtg.java Mon Feb  4 08:55:43 2008
@@ -40,7 +40,7 @@
 {
     public final static int  SIZE = 3;
     public final static byte sid  = 0x1e;
-    private short            field_1_value;
+    private int            field_1_value;
   
     private IntPtg() {
       //Required for clone methods
@@ -48,42 +48,31 @@
 
     public IntPtg(RecordInputStream in)
     {
-        setValue(in.readShort());
+        setValue(in.readUShort());
     }
     
     
     // IntPtg should be able to create itself, shouldnt have to call setValue
     public IntPtg(String formulaToken) {
-        setValue(Short.parseShort(formulaToken));
+        setValue(Integer.parseInt(formulaToken));
     }
 
     /**
      * Sets the wrapped value.
      * Normally you should call with a positive int.
      */
-    public void setValue(short value)
-    {
-        field_1_value = value;
-    }
-
-    /**
-     * Sets the unsigned value.
-     * (Handles conversion to the internal short value) 
-     */
     public void setValue(int value)
     {
-    	if(value > Short.MAX_VALUE) {
-    		// Need to wrap
-    		value -= (Short.MAX_VALUE+1)*2;
-    	}
-    	field_1_value = (short)value;
+        if(value < 0 || value > (Short.MAX_VALUE + 1)*2 )
+            throw new IllegalArgumentException("Unsigned short is out of range: " + value);
+        field_1_value = value;
     }
 
     /**
      * Returns the value as a short, which may have
      *  been wrapped into negative numbers
      */
-    public short getValue()
+    public int getValue()
     {
         return field_1_value;
     }
@@ -102,7 +91,7 @@
     public void writeBytes(byte [] array, int offset)
     {
         array[ offset + 0 ] = sid;
-        LittleEndian.putShort(array, offset + 1, getValue());
+        LittleEndian.putUShort(array, offset + 1, getValue());
     }
 
     public int getSize()

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ptg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ptg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ptg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ptg.java Mon Feb  4 08:55:43 2008
@@ -137,8 +137,8 @@
                  break;
         	  
              case DividePtg.sid :               // 0x06
-        	                  retval = new DividePtg(in);
-        	                  break;
+        	      retval = new DividePtg(in);
+        	      break;
         	  
              case PowerPtg.sid :                // 0x07
                  retval = new PowerPtg(in);
@@ -208,6 +208,7 @@
                 break;
  
              case AttrPtg.sid :                 // 0x19
+             case 0x1a :
                  retval = new AttrPtg(in);
         	                  break;
         	  
@@ -224,8 +225,8 @@
         	                  break;
  
              case NumberPtg.sid :               // 0x1f
-        	                 retval = new NumberPtg(in);
-        	                 break;
+        	      retval = new NumberPtg(in);
+        	      break;
         	  
              case ArrayPtg.sid :                // 0x20
              	retval = new ArrayPtg(in);
@@ -350,9 +351,12 @@
              case DeletedArea3DPtg.sid + 0x40 : // 0x7d
                  retval = new DeletedArea3DPtg(in);
                  break;
-
+                 
+             case 0x00:
+            	 retval = new UnknownPtg();
+            	 break;
+                 
             default :
-
                  //retval = new UnknownPtg();
                  throw new java.lang.UnsupportedOperationException(" Unknown Ptg in Formula: 0x"+
                         Integer.toHexString(( int ) id) + " (" + ( int ) id + ")");

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RangePtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RangePtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RangePtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RangePtg.java Mon Feb  4 08:55:43 2008
@@ -25,22 +25,22 @@
  */
 public class RangePtg extends OperationPtg
 {
+    public final static int  SIZE = 1;
     public final static byte sid  = 0x11;
 
-
     public RangePtg()
     {
     }
 
     public RangePtg(RecordInputStream in)
     {
-        // doesn't need anything
+    	// No contents
     }
 
 
     public int getSize()
     {
-        return 1;
+        return SIZE;
     }
 
     public void writeBytes( byte[] array, int offset )

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/Ref3DPtg.java Mon Feb  4 08:55:43 2008
@@ -157,18 +157,31 @@
 
     }
 
-    public String toFormulaString(Workbook book) {
+    // TODO - find a home for this method
+    // There is already a method on Workbook called getSheetName but it seems to do something different.
+	static String getSheetName(Workbook book, int externSheetIndex) {
+        // TODO - there are 3 ways this method can return null. Is each valid?
+        if (book == null) {
+            return null;
+        }
+
+        SheetReferences refs = book.getSheetReferences();
+        if (refs == null) {
+            return null;
+        }
+        return refs.getSheetName(externSheetIndex);
+    }
+    /**
+     * @return text representation of this cell reference that can be used in text 
+     * formulas. The sheet name will get properly delimited if required.
+     */
+    public String toFormulaString(Workbook book)
+    {
         StringBuffer retval = new StringBuffer();
-        SheetReferences refs = book == null ? null : book.getSheetReferences();
-        if (refs != null) {
-        	String sheetName =refs.getSheetName((int)this.field_1_index_extern_sheet);
-        	boolean appendQuotes = sheetName.indexOf(" ") >= 0;
-        	if (appendQuotes)
-        	  retval.append("'");
-            retval.append(sheetName);
-        	if (appendQuotes)
-          	  retval.append("'");
-            retval.append('!');
+        String sheetName = getSheetName(book, field_1_index_extern_sheet);
+        if(sheetName != null) {
+            SheetNameFormatter.appendFormat(retval, sheetName);
+            retval.append( '!' );
         }
         retval.append((new CellReference(getRow(),getColumn(),!isRowRelative(),!isColRelative())).toString()); 
         return retval.toString();

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/UnknownPtg.java Mon Feb  4 08:55:43 2008
@@ -28,7 +28,7 @@
 public class UnknownPtg
     extends Ptg
 {
-    private short size;
+    private short size = 1;
 
     /** Creates new UnknownPtg */
 

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java Mon Feb  4 08:55:43 2008
@@ -34,20 +34,7 @@
 import org.apache.poi.hssf.model.FormulaParser;
 import org.apache.poi.hssf.model.Sheet;
 import org.apache.poi.hssf.model.Workbook;
-import org.apache.poi.hssf.record.BlankRecord;
-import org.apache.poi.hssf.record.BoolErrRecord;
-import org.apache.poi.hssf.record.CellValueRecordInterface;
-import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
-import org.apache.poi.hssf.record.ExtendedFormatRecord;
-import org.apache.poi.hssf.record.FormulaRecord;
-import org.apache.poi.hssf.record.LabelSSTRecord;
-import org.apache.poi.hssf.record.NoteRecord;
-import org.apache.poi.hssf.record.NumberRecord;
-import org.apache.poi.hssf.record.ObjRecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.SubRecord;
-import org.apache.poi.hssf.record.TextObjectRecord;
-import org.apache.poi.hssf.record.UnicodeString;
+import org.apache.poi.hssf.record.*;
 import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
 import org.apache.poi.hssf.record.formula.Ptg;
 import org.apache.poi.ss.usermodel.Cell;
@@ -1073,4 +1060,31 @@
         }
         return comment;
    }
+
+    /**
+     * Returns hyperlink associated with this cell
+     *
+     * @return hyperlink associated with this cell or null if not found
+     */
+    public HSSFHyperlink getHyperlink(){
+        for (Iterator it = sheet.getRecords().iterator(); it.hasNext(); ) {
+            Record rec = ( Record ) it.next();
+            if (rec instanceof HyperlinkRecord){
+                HyperlinkRecord link = (HyperlinkRecord)rec;
+                if(link.getColumn() == record.getColumn() && link.getRow() == record.getRow()){
+                    return new HSSFHyperlink(link);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Assign a hypelrink to this cell
+     *
+     * @param link hypelrink associated with this cell
+     */
+    public void setHyperlink(HSSFHyperlink link){
+
+    }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFDataFormat.java Mon Feb  4 08:55:43 2008
@@ -206,12 +206,12 @@
     }
 
     /**
-     * get the format index that matches the given format string.
-     * Creates a new format if one is not found.  Aliases text to the proper format.
+     * Get the format index that matches the given format
+     *  string, creating a new format entry if required.
+     * Aliases text to the proper format as required.
      * @param format string matching a built in format
      * @return index of format.
      */
-
     public short getFormat( String format )
     {
         ListIterator i;

Modified: poi/branches/ooxml/src/java/org/apache/poi/util/CommonsLogger.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/util/CommonsLogger.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/util/CommonsLogger.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/util/CommonsLogger.java Mon Feb  4 08:55:43 2008
@@ -22,8 +22,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.util.*;
-
 /**
  * A logger class that strives to make it as easy as possible for
  * developers to write log calls, while simultaneously making those
@@ -53,7 +51,6 @@
      * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
      * @param obj1 The object to log.
      */
-
     public void log(final int level, final Object obj1)
     {
         if(level==FATAL)
@@ -96,6 +93,78 @@
           if(log.isTraceEnabled())
           {
             log.trace(obj1);
+          }
+        }
+    }
+    
+    /**
+     * Log a message
+     *
+     * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+     * @param obj1 The object to log.  This is converted to a string.
+     * @param exception An exception to be logged
+     */
+    public void log(final int level, final Object obj1,
+                    final Throwable exception) 
+    {
+        if(level==FATAL)
+        {
+          if(log.isFatalEnabled())
+          {
+            if(obj1 != null)
+               log.fatal(obj1, exception);
+            else
+               log.fatal(exception);
+          }
+        }
+        else if(level==ERROR)
+        {
+          if(log.isErrorEnabled())
+          {
+            if(obj1 != null)
+               log.error(obj1, exception);
+            else
+               log.error(exception);
+          }
+        }
+        else if(level==WARN)
+        {
+          if(log.isWarnEnabled())
+          {
+            if(obj1 != null)
+               log.warn(obj1, exception);
+            else
+               log.warn(exception);
+          }
+        }
+        else if(level==INFO)
+        {
+          if(log.isInfoEnabled())
+          {
+        	if(obj1 != null)
+               log.info(obj1, exception);
+        	else
+        	   log.info(exception);
+          }
+        }
+        else if(level==DEBUG)
+        {
+          if(log.isDebugEnabled())
+          {
+        	if(obj1 != null)
+               log.debug(obj1, exception);
+        	else
+        	   log.debug(exception);
+          }
+        }
+        else
+        {
+          if(log.isTraceEnabled())
+          {
+        	if(obj1 != null)
+               log.trace(obj1, exception);
+        	else
+        	   log.trace(exception);
           }
         }
 

Modified: poi/branches/ooxml/src/java/org/apache/poi/util/POILogger.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/util/POILogger.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/util/POILogger.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/util/POILogger.java Mon Feb  4 08:55:43 2008
@@ -51,7 +51,24 @@
     
     abstract public void initialize(final String cat);
     
+    /**
+     * Log a message
+     *
+     * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+     * @param obj1 The object to log.  This is converted to a string.
+     */
     abstract public void log(final int level, final Object obj1);
+    
+    /**
+     * Log a message
+     *
+     * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+     * @param obj1 The object to log.  This is converted to a string.
+     * @param exception An exception to be logged
+     */
+    abstract public void log(final int level, final Object obj1,
+                    final Throwable exception);
+
 
     /**
      * Check if a logger is enabled to log at the specified level
@@ -237,17 +254,15 @@
     }
 
     /**
-     * Log a message
+     * Log an exception, without a message
      *
      * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
-     * @param obj1 The object to log.  This is converted to a string.
      * @param exception An exception to be logged
      */
 
-    public void log(final int level, final Object obj1,
-                    final Throwable exception)
+    public void log(final int level, final Throwable exception)
     {
-        log(level , obj1, exception);
+        log(level, null, exception);
     }
 
     /**

Modified: poi/branches/ooxml/src/java/org/apache/poi/util/SystemOutLogger.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/util/SystemOutLogger.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/util/SystemOutLogger.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/util/SystemOutLogger.java Mon Feb  4 08:55:43 2008
@@ -49,8 +49,24 @@
 
     public void log(final int level, final Object obj1)
     {
-        if (check(level))
+    	log(level, obj1, null);
+    }
+    
+    /**
+     * Log a message
+     *
+     * @param level One of DEBUG, INFO, WARN, ERROR, FATAL
+     * @param obj1 The object to log.  This is converted to a string.
+     * @param exception An exception to be logged
+     */
+    public void log(final int level, final Object obj1,
+                    final Throwable exception) {
+        if (check(level)) {
             System.out.println("["+cat+"] "+obj1);
+            if(exception != null) {
+            	exception.printStackTrace(System.out);
+            }
+        }
     }
 
     /**

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Fill.java Mon Feb  4 08:55:43 2008
@@ -23,6 +23,8 @@
 import org.apache.poi.hslf.usermodel.PictureData;
 import org.apache.poi.hslf.usermodel.SlideShow;
 import org.apache.poi.hslf.exceptions.HSLFException;
+import org.apache.poi.util.POILogger;
+import org.apache.poi.util.POILogFactory;
 
 import java.awt.*;
 import java.util.*;
@@ -33,6 +35,9 @@
  * @author Yegor Kozlov
  */
 public class Fill {
+    // For logging
+    protected POILogger logger = POILogFactory.getLogger(this.getClass());
+
     /**
      *  Fill with a solid color
      */
@@ -208,15 +213,18 @@
 
         java.util.List lst = bstore.getChildRecords();
         int idx = p.getPropertyValue();
-        EscherBSERecord bse = (EscherBSERecord)lst.get(idx);
-        for ( int i = 0; i < pict.length; i++ ) {
-			if (pict[i].getOffset() ==  bse.getOffset()){
-                return pict[i];
+        if (idx == 0){
+            logger.log(POILogger.ERROR, "no reference to picture data found ");
+        } else {
+            EscherBSERecord bse = (EscherBSERecord)lst.get(idx - 1);
+            for ( int i = 0; i < pict.length; i++ ) {
+                if (pict[i].getOffset() ==  bse.getOffset()){
+                    return pict[i];
+                }
             }
         }
-        throw new HSLFException("Picture data not found: \n" +
-                "  bse: " + bse + " at " + bse.getOffset() );
 
+        return null;
     }
 
     /**

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Picture.java Mon Feb  4 08:55:43 2008
@@ -109,7 +109,7 @@
      */
     public int getPictureIndex(){
         EscherOptRecord opt = (EscherOptRecord)getEscherChild(_escherContainer, EscherOptRecord.RECORD_ID);
-        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY + 0x4000);
+        EscherSimpleProperty prop = (EscherSimpleProperty)getEscherProperty(opt, EscherProperties.BLIP__BLIPTODISPLAY);
         return prop == null ? 0 : prop.getPropertyValue();
     }
 

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Shape.java Mon Feb  4 08:55:43 2008
@@ -227,7 +227,7 @@
         for ( Iterator iterator = opt.getEscherProperties().iterator(); iterator.hasNext(); )
         {
             EscherProperty prop = (EscherProperty) iterator.next();
-            if (prop.getId() == propId)
+            if (prop.getPropertyNumber() == propId)
                 return prop;
         }
         return null;

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java Mon Feb  4 08:55:43 2008
@@ -262,4 +262,11 @@
         SlideAtom sa = getSlideRecord().getSlideAtom();
         return sa.getFollowMasterBackground();
     }
+
+    public Background getBackground() {
+        if(getFollowMasterBackground())
+            return getMasterSheet().getBackground();
+        else
+            return super.getBackground();
+    }
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Columns.java Mon Feb  4 08:55:43 2008
@@ -14,12 +14,46 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/*
- * Created on May 15, 2005
- *
- */
+
+
 package org.apache.poi.hssf.record.formula.functions;
 
-public class Columns extends NotImplementedFunction {
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.RefEval;
+
+/**
+ * Implementation for Excel COLUMNS function.
+ * 
+ * @author Josh Micich
+ */
+public final class Columns implements Function {
 
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		switch(args.length) {
+			case 1:
+				// expected
+				break;
+			case 0:
+				// too few arguments
+				return ErrorEval.VALUE_INVALID;
+			default:
+				// too many arguments
+				return ErrorEval.VALUE_INVALID;
+		}
+		Eval firstArg = args[0];
+		
+		int result;
+        if (firstArg instanceof AreaEval) {
+            AreaEval ae = (AreaEval) firstArg;
+            result = ae.getLastColumn() - ae.getFirstColumn() + 1;
+        } else if (firstArg instanceof RefEval) {
+            result = 1;
+        } else { // anything else is not valid argument
+            return ErrorEval.VALUE_INVALID;
+        }
+        return new NumberEval(result);
+	}
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Counta.java Mon Feb  4 08:55:43 2008
@@ -14,12 +14,107 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/*
- * Created on May 15, 2005
+
+
+package org.apache.poi.hssf.record.formula.functions;
+
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.BlankEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.RefEval;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * Counts the number of cells that contain data within the list of arguments. 
  *
+ * Excel Syntax
+ * COUNTA(value1,value2,...)
+ * Value1, value2, ...   are 1 to 30 arguments representing the values or ranges to be counted.
+ * 
+ * @author Josh Micich
  */
-package org.apache.poi.hssf.record.formula.functions;
+public final class Counta implements Function {
+
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		int nArgs = args.length;
+		if (nArgs < 1) {
+			// too few arguments
+			return ErrorEval.VALUE_INVALID;
+		}
+
+		if (nArgs > 30) {
+			// too many arguments
+			return ErrorEval.VALUE_INVALID;
+		}
+		
+		int temp = 0;
+		// Note - observed behavior of Excel:
+		// Error values like #VALUE!, #REF!, #DIV/0!, #NAME? etc don't cause this COUNTA to return an error
+		// in fact, they seem to get counted
+		
+		for(int i=0; i<nArgs; i++) {
+			temp += countArg(args[i]);
+			
+		}
+		return new NumberEval(temp);
+	}
+
+	private static int countArg(Eval eval) {
+        if (eval instanceof AreaEval) {
+            AreaEval ae = (AreaEval) eval;
+            return countAreaEval(ae);
+        }
+        if (eval instanceof RefEval) {
+            RefEval refEval = (RefEval)eval;
+			return countValue(refEval.getInnerValueEval());
+        }
+        if (eval instanceof NumberEval) {
+            return 1;
+        }
+        if (eval instanceof StringEval) {
+            return 1;
+        }
+        
+		
+		throw new RuntimeException("Unexpected eval type (" + eval.getClass().getName() + ")");
+	}
+
+	private static int countAreaEval(AreaEval ae) {
+		
+		int temp = 0;
+		ValueEval[] values = ae.getValues();
+		for (int i = 0; i < values.length; i++) {
+			ValueEval val = values[i];
+			if(val == null) {
+				// seems to occur.  Really we would have expected BlankEval
+				continue;
+			}
+			temp += countValue(val);
+			
+		}
+		return temp;
+	}
+
+	private static int countValue(ValueEval valueEval) {
+		
+		if(valueEval == BlankEval.INSTANCE) {
+			return 0;
+		}
+		
+		if(valueEval instanceof BlankEval) {
+			// wouldn't need this if BlankEval was final
+			return 0;
+		}
 
-public class Counta extends NotImplementedFunction {
+		if(valueEval instanceof ErrorEval) {
+			// note - error values are counted
+			return 1;
+		}
+		// also empty strings and zeros are counted too
 
+		return 1;
+	}
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Countif.java Mon Feb  4 08:55:43 2008
@@ -14,12 +14,231 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/*
- * Created on May 15, 2005
- *
- */
+
+
 package org.apache.poi.hssf.record.formula.functions;
 
-public class Countif extends NotImplementedFunction {
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.BoolEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.RefEval;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
+
+/**
+ * Implementation for the function COUNTIF<p/>
+ * 
+ * Syntax: COUNTIF ( range, criteria )
+ *    <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
+ *      <tr><th>range&nbsp;&nbsp;&nbsp;</th><td>is the range of cells to be counted based on the criteria</td></tr>
+ *      <tr><th>criteria</th><td>is used to determine which cells to count</td></tr>
+ *    </table>
+ * <p/>
+ * 
+ * @author Josh Micich
+ */
+public final class Countif implements Function {
+	
+	/**
+	 * Common interface for the matching criteria.
+	 */
+	private interface I_MatchPredicate {
+		boolean matches(Eval x);
+	}
+	
+	private static final class NumberMatcher implements I_MatchPredicate {
+
+		private final double _value;
+
+		public NumberMatcher(double value) {
+			_value = value;
+		}
+
+		public boolean matches(Eval x) {
+			if(x instanceof StringEval) {
+				// if the target(x) is a string, but parses as a number
+				// it may still count as a match
+				StringEval se = (StringEval)x;
+				Double val = parseDouble(se.getStringValue());
+				if(val == null) {
+					// x is text that is not a number
+					return false;
+				}
+				return val.doubleValue() == _value;
+			}
+			if(!(x instanceof NumberEval)) {
+				return false;
+			}
+			NumberEval ne = (NumberEval) x;
+			return ne.getNumberValue() == _value;
+		}
+	}
+	private static final class BooleanMatcher implements I_MatchPredicate {
+
+		private final boolean _value;
+
+		public BooleanMatcher(boolean value) {
+			_value = value;
+		}
+
+		public boolean matches(Eval x) {
+			if(x instanceof StringEval) {
+				StringEval se = (StringEval)x;
+				Boolean val = parseBoolean(se.getStringValue());
+				if(val == null) {
+					// x is text that is not a boolean
+					return false;
+				}
+				if (true) { // change to false to observe more intuitive behaviour
+					// Note - Unlike with numbers, it seems that COUNTA never matches 
+					// boolean values when the target(x) is a string
+					return false;
+				}
+				return val.booleanValue() == _value;
+			}
+			if(!(x instanceof BoolEval)) {
+				return false;
+			}
+			BoolEval be = (BoolEval) x;
+			return be.getBooleanValue() == _value;
+		}
+	}
+	private static final class StringMatcher implements I_MatchPredicate {
+
+		private final String _value;
+
+		public StringMatcher(String value) {
+			_value = value;
+		}
+
+		public boolean matches(Eval x) {
+			if(!(x instanceof StringEval)) {
+				return false;
+			}
+			StringEval se = (StringEval) x;
+			return se.getStringValue() == _value;
+		}
+	}
+
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		switch(args.length) {
+			case 2:
+				// expected
+				break;
+			default:
+				// TODO - it doesn't seem to be possible to enter COUNTIF() into Excel with the wrong arg count
+				// perhaps this should be an exception
+				return ErrorEval.VALUE_INVALID;
+		}
+		
+		AreaEval range = (AreaEval) args[0];
+		Eval criteriaArg = args[1];
+		if(criteriaArg instanceof RefEval) {
+			// criteria is not a literal value, but a cell reference
+			// for example COUNTIF(B2:D4, E1)
+			RefEval re = (RefEval)criteriaArg;
+			criteriaArg = re.getInnerValueEval();
+		} else {
+			// other non literal tokens such as function calls, have been fully evaluated
+			// for example COUNTIF(B2:D4, COLUMN(E1))
+		}
+		I_MatchPredicate mp = createCriteriaPredicate(criteriaArg);
+		return countMatchingCellsInArea(range, mp);
+	}
+	/**
+	 * @return the number of evaluated cells in the range that match the specified criteria
+	 */
+	private Eval countMatchingCellsInArea(AreaEval range, I_MatchPredicate criteriaPredicate) {
+		ValueEval[] values = range.getValues();
+		int result = 0;
+		for (int i = 0; i < values.length; i++) {
+			if(criteriaPredicate.matches(values[i])) {
+				result++;
+			}
+		}
+		return new NumberEval(result);
+	}
+	
+	private static I_MatchPredicate createCriteriaPredicate(Eval evaluatedCriteriaArg) {
+		if(evaluatedCriteriaArg instanceof NumberEval) {
+			return new NumberMatcher(((NumberEval)evaluatedCriteriaArg).getNumberValue());
+		}
+		if(evaluatedCriteriaArg instanceof BoolEval) {
+			return new BooleanMatcher(((BoolEval)evaluatedCriteriaArg).getBooleanValue());
+		}
+		
+		if(evaluatedCriteriaArg instanceof StringEval) {
+			return createGeneralMatchPredicate((StringEval)evaluatedCriteriaArg);
+		}
+		throw new RuntimeException("Unexpected type for criteria (" 
+				+ evaluatedCriteriaArg.getClass().getName() + ")");
+	}
+
+	/**
+	 * When the second argument is a string, many things are possible
+	 */
+	private static I_MatchPredicate createGeneralMatchPredicate(StringEval stringEval) {
+		String value = stringEval.getStringValue();
+		char firstChar = value.charAt(0);
+		Boolean booleanVal = parseBoolean(value);
+		if(booleanVal != null) {
+			return new BooleanMatcher(booleanVal.booleanValue());
+		}
+		
+		Double doubleVal = parseDouble(value);
+		if(doubleVal != null) {
+			return new NumberMatcher(doubleVal.doubleValue());
+		}
+		switch(firstChar) {
+			case '>':
+			case '<':
+			case '=':
+				throw new RuntimeException("Incomplete code - criteria expressions such as '"
+						+ value + "' not supported yet");
+		}
+		
+		//else - just a plain string with no interpretation.
+		return new StringMatcher(value);
+	}
 
+	/**
+	 * Under certain circumstances COUNTA will equate a plain number with a string representation of that number
+	 */
+	/* package */ static Double parseDouble(String strRep) {
+		if(!Character.isDigit(strRep.charAt(0))) {
+			// avoid using NumberFormatException to tell when string is not a number
+			return null;
+		}
+		// TODO - support notation like '1E3' (==1000)
+		
+		double val;
+		try {
+			val = Double.parseDouble(strRep);
+		} catch (NumberFormatException e) {
+			return null;
+		}
+		return new Double(val);
+	}
+	/**
+	 * Boolean literals ('TRUE', 'FALSE') treated similarly but NOT same as numbers. 
+	 */
+	/* package */ static Boolean parseBoolean(String strRep) {
+		switch(strRep.charAt(0)) {
+			case 't':
+			case 'T':
+				if("TRUE".equalsIgnoreCase(strRep)) {
+					return Boolean.TRUE;
+				}
+				break;
+			case 'f':
+			case 'F':
+				if("FALSE".equalsIgnoreCase(strRep)) {
+					return Boolean.FALSE;
+				}
+				break;
+		}
+		return null;
+	}
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Index.java Mon Feb  4 08:55:43 2008
@@ -14,12 +14,95 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/*
- * Created on May 15, 2005
- *
- */
+
+
 package org.apache.poi.hssf.record.formula.functions;
 
-public class Index extends NotImplementedFunction {
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.RefEval;
+
+/**
+ * Implementation for the Excel function INDEX<p/>
+ * 
+ * Syntax : <br/>
+ *  INDEX ( reference, row_num[, column_num [, area_num]])</br>
+ *  INDEX ( array, row_num[, column_num])
+ *    <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
+ *      <tr><th>reference</th><td>typically an area reference, possibly a union of areas</td></tr>
+ *      <tr><th>array</th><td>a literal array value (currently not supported)</td></tr>
+ *      <tr><th>row_num</th><td>selects the row within the array or area reference</td></tr>
+ *      <tr><th>column_num</th><td>selects column within the array or area reference. default is 1</td></tr>
+ *      <tr><th>area_num</th><td>used when reference is a union of areas</td></tr>
+ *    </table>
+ * <p/>
+ * 
+ * @author Josh Micich
+ */
+public final class Index implements Function {
 
+	// TODO - javadoc for interface method
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		int nArgs = args.length;
+		if(nArgs < 2) {
+			// too few arguments
+			return ErrorEval.VALUE_INVALID;
+		}
+		Eval firstArg = args[0];
+		if(firstArg instanceof AreaEval) {
+			AreaEval reference = (AreaEval) firstArg;
+			
+			int rowIx = 0;
+			int columnIx = 0;
+			int areaIx = 0;
+			switch(nArgs) {
+				case 4:
+					areaIx = convertIndexArgToZeroBase(args[3]);
+					throw new RuntimeException("Incomplete code" +
+							" - don't know how to support the 'area_num' parameter yet)");
+					// Excel expression might look like this "INDEX( (A1:B4, C3:D6, D2:E5 ), 1, 2, 3)
+					// In this example, the 3rd area would be used i.e. D2:E5, and the overall result would be E2
+					// Token array might be encoded like this: MemAreaPtg, AreaPtg, AreaPtg, UnionPtg, UnionPtg, ParenthesesPtg
+					// The formula parser doesn't seem to support this yet. Not sure if the evaluator does either
+					
+				case 3:
+					columnIx = convertIndexArgToZeroBase(args[2]);
+				case 2:
+					rowIx = convertIndexArgToZeroBase(args[1]);
+					break;
+				default:
+					// too many arguments
+					return ErrorEval.VALUE_INVALID;
+			}
+			
+	        int nColumns = reference.getLastColumn()-reference.getFirstColumn()+1;
+			int index = rowIx * nColumns + columnIx;
+			
+			return reference.getValues()[index];
+		}
+		
+		// else the other variation of this function takes an array as the first argument
+		// it seems like interface 'ArrayEval' does not even exist yet
+		
+		throw new RuntimeException("Incomplete code - cannot handle first arg of type ("
+				+ firstArg.getClass().getName() + ")");
+	}
+	
+	/**
+	 * takes a NumberEval representing a 1-based index and returns the zero-based int value
+	 */
+	private static int convertIndexArgToZeroBase(Eval ev) {
+		NumberEval ne;
+		if(ev instanceof RefEval) {
+			// TODO - write junit to justify this
+			RefEval re = (RefEval) ev;
+			ne = (NumberEval) re.getInnerValueEval();
+		} else {
+			ne = (NumberEval)ev;
+		}
+		
+		return (int)ne.getNumberValue() - 1;
+	}
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Rows.java Mon Feb  4 08:55:43 2008
@@ -14,12 +14,46 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/*
- * Created on May 15, 2005
- *
- */
+
+
 package org.apache.poi.hssf.record.formula.functions;
 
-public class Rows extends NotImplementedFunction {
+import org.apache.poi.hssf.record.formula.eval.AreaEval;
+import org.apache.poi.hssf.record.formula.eval.ErrorEval;
+import org.apache.poi.hssf.record.formula.eval.Eval;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.RefEval;
+
+/**
+ * Implementation for Excel COLUMNS function.
+ * 
+ * @author Josh Micich
+ */
+public final class Rows implements Function {
 
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		switch(args.length) {
+			case 1:
+				// expected
+				break;
+			case 0:
+				// too few arguments
+				return ErrorEval.VALUE_INVALID;
+			default:
+				// too many arguments
+				return ErrorEval.VALUE_INVALID;
+		}
+		Eval firstArg = args[0];
+		
+		int result;
+        if (firstArg instanceof AreaEval) {
+            AreaEval ae = (AreaEval) firstArg;
+            result = ae.getLastRow() - ae.getFirstRow() + 1;
+        } else if (firstArg instanceof RefEval) {
+            result = 1;
+        } else { // anything else is not valid argument
+            return ErrorEval.VALUE_INVALID;
+        }
+        return new NumberEval(result);
+	}
 }

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/TableRow.java Mon Feb  4 08:55:43 2008
@@ -58,7 +58,7 @@
         p = getParagraph(end);
         s = p.text();
       }
-      _cells[cellIndex] = new TableCell(start, end, this, levelNum,
+      _cells[cellIndex] = new TableCell(start, end+1, this, levelNum,
                                         _tprops.getRgtc()[cellIndex],
                                         _tprops.getRgdxaCenter()[cellIndex],
                                         _tprops.getRgdxaCenter()[cellIndex+1]-_tprops.getRgdxaCenter()[cellIndex]);

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestBugs.java Mon Feb  4 08:55:43 2008
@@ -330,4 +330,24 @@
             assertEquals(tr1[i].getText(), tr2[i].getText());
         }
     }
+
+    /**
+     * Bug 44296: HSLF Not Extracting Slide Background Image
+     */
+    public void test44296  () throws Exception {
+        FileInputStream is = new FileInputStream(new File(cwd, "44296.ppt"));
+        SlideShow ppt = new SlideShow(is);
+        is.close();
+
+        Slide slide = ppt.getSlides()[0];
+
+        Background b = slide.getBackground();
+        Fill f = b.getFill();
+        assertEquals(Fill.FILL_PICTURE, f.getFillType());
+
+        PictureData pict = f.getPictureData();
+        assertNotNull(pict);
+        assertEquals(Picture.JPEG, pict.getType());
+    }
+
 }

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java Mon Feb  4 08:55:43 2008
@@ -82,7 +82,7 @@
 		assertEquals(HSSFCell.CELL_TYPE_FORMULA, wb.getSheetAt(0).getRow(1).getCell((short)2).getCellType());
 		
 		assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell((short)0).getNumericCellValue(), 0);
-		assertEquals("S1!A1", wb.getSheetAt(1).getRow(0).getCell((short)0).getCellFormula());
+		assertEquals("'S1'!A1", wb.getSheetAt(1).getRow(0).getCell((short)0).getCellFormula());
 		assertEquals(HSSFCell.CELL_TYPE_FORMULA, wb.getSheetAt(1).getRow(0).getCell((short)0).getCellType());
 		
 		

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=618325&r1=618324&r2=618325&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 Mon Feb  4 08:55:43 2008
@@ -74,4 +74,34 @@
     		}
     	}
 	}
+
+	/**
+	 * Test for TableCell not skipping the last paragraph
+	 */
+	public void testTableCellLastParagraph() throws Exception {
+    	HWPFDocument doc = new HWPFDocument(new FileInputStream(dirname + "/Bug44292.doc"));
+		Range r = doc.getRange();
+			
+		//get the table
+		Paragraph p = r.getParagraph(0);
+		Table t = r.getTable(p);
+		
+		//get the only row
+		TableRow row = t.getRow(0);
+		
+		//get the first cell
+		TableCell cell = row.getCell(0);
+		// First cell should have one paragraph
+		assertEquals(1, cell.numParagraphs());
+		
+		//get the second
+		cell = row.getCell(1);
+		// Second cell should be detected as having two paragraphs
+		assertEquals(2, cell.numParagraphs());
+				
+		//get the last cell
+		cell = row.getCell(2);
+		// Last cell should have one paragraph
+		assertEquals(1, cell.numParagraphs());
+	}
 }

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/HSSFTests.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/HSSFTests.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/HSSFTests.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/HSSFTests.java Mon Feb  4 08:55:43 2008
@@ -75,13 +75,7 @@
 import org.apache.poi.hssf.record.TestValueRangeRecord;
 import org.apache.poi.hssf.record.aggregates.TestRowRecordsAggregate;
 import org.apache.poi.hssf.record.aggregates.TestValueRecordsAggregate;
-import org.apache.poi.hssf.record.formula.TestAreaErrPtg;
-import org.apache.poi.hssf.record.formula.TestErrPtg;
-import org.apache.poi.hssf.record.formula.TestFuncPtg;
-import org.apache.poi.hssf.record.formula.TestIntersectionPtg;
-import org.apache.poi.hssf.record.formula.TestPercentPtg;
-import org.apache.poi.hssf.record.formula.TestRangePtg;
-import org.apache.poi.hssf.record.formula.TestUnionPtg;
+import org.apache.poi.hssf.record.formula.AllFormulaTests;
 import org.apache.poi.hssf.usermodel.TestBugs;
 import org.apache.poi.hssf.usermodel.TestCellStyle;
 import org.apache.poi.hssf.usermodel.TestCloneSheet;
@@ -215,13 +209,7 @@
         suite.addTest(new TestSuite(TestSheetReferences.class));
         
         
-        suite.addTest(new TestSuite(TestAreaErrPtg.class));
-        suite.addTest(new TestSuite(TestErrPtg.class));
-        suite.addTest(new TestSuite(TestFuncPtg.class));
-        suite.addTest(new TestSuite(TestIntersectionPtg.class));
-        suite.addTest(new TestSuite(TestPercentPtg.class));
-        suite.addTest(new TestSuite(TestRangePtg.class));
-        suite.addTest(new TestSuite(TestUnionPtg.class));
+        suite.addTest(AllFormulaTests.suite());
 		  suite.addTest(new TestSuite(TestValueRecordsAggregate.class));
 		  suite.addTest(new TestSuite(TestNameRecord.class));
                   suite.addTest(new TestSuite(TestEventRecordFactory.class));

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/TestDataValidation.xls?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
Binary files - no diff available.

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java Mon Feb  4 08:55:43 2008
@@ -23,8 +23,13 @@
 import java.io.FileInputStream;
 import java.util.ArrayList;
 
+import org.apache.poi.hssf.record.DVALRecord;
+import org.apache.poi.hssf.record.DVRecord;
+import org.apache.poi.hssf.record.EOFRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.ContinueRecord;
+import org.apache.poi.hssf.record.SelectionRecord;
+import org.apache.poi.hssf.record.WindowTwoRecord;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 import junit.framework.TestCase;
@@ -48,7 +53,15 @@
 		factory.processWorkbookEvents(req, fs);
 
 		// Check we got the records
+		System.out.println("Processed, found " + mockListen.records.size() + " records");
 		assertTrue( mockListen.records.size() > 100 );
+		
+		// Check that the last few records are as we expect
+		// (Makes sure we don't accidently skip the end ones)
+		int numRec = mockListen.records.size();
+		assertEquals(WindowTwoRecord.class, mockListen.records.get(numRec-3).getClass());
+		assertEquals(SelectionRecord.class, mockListen.records.get(numRec-2).getClass());
+		assertEquals(EOFRecord.class,       mockListen.records.get(numRec-1).getClass());
 	}
 
 	public void testWithCrazyContinueRecords() throws Exception {
@@ -66,6 +79,7 @@
 		factory.processWorkbookEvents(req, fs);
 
 		// Check we got the records
+		System.out.println("Processed, found " + mockListen.records.size() + " records");
 		assertTrue( mockListen.records.size() > 100 );
 
 		// And none of them are continue ones
@@ -74,6 +88,13 @@
 		for(int i=0; i<r.length; i++) {
 			assertFalse( r[i] instanceof ContinueRecord );
 		}
+		
+		// Check that the last few records are as we expect
+		// (Makes sure we don't accidently skip the end ones)
+		int numRec = mockListen.records.size();
+		assertEquals(DVALRecord.class, mockListen.records.get(numRec-3).getClass());
+		assertEquals(DVRecord.class, mockListen.records.get(numRec-2).getClass());
+		assertEquals(EOFRecord.class,       mockListen.records.get(numRec-1).getClass());
 	}
 
     /**

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java Mon Feb  4 08:55:43 2008
@@ -379,15 +379,16 @@
 		fp = new FormulaParser("40000", null);
 		fp.parse();
 		ptg=fp.getRPNPtg();
-		assertTrue("ptg should be  Number, is "+ptg[0].getClass(), ptg[0] instanceof NumberPtg);
+		assertTrue("ptg should be  IntPtg, is "+ptg[0].getClass(), ptg[0] instanceof IntPtg);
 	}
+
 	/** bug 33160, testcase by Amol Deshmukh*/
 	public void testSimpleLongFormula() {
 		        FormulaParser fp = new FormulaParser("40000/2", null);
 		        fp.parse();
 		        Ptg[] ptgs = fp.getRPNPtg();
 		        assertTrue("three tokens expected, got "+ptgs.length,ptgs.length == 3);
-		        assertTrue("NumberPtg",(ptgs[0] instanceof NumberPtg));
+		        assertTrue("IntPtg",(ptgs[0] instanceof IntPtg));
 		        assertTrue("IntPtg",(ptgs[1] instanceof IntPtg));
 		        assertTrue("DividePtg",(ptgs[2] instanceof DividePtg));
 	}

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java?rev=618325&r1=618324&r2=618325&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java Mon Feb  4 08:55:43 2008
@@ -21,6 +21,16 @@
 package org.apache.poi.hssf.record;
 
 
+import java.io.ByteArrayInputStream;
+
+import org.apache.poi.hssf.record.formula.AttrPtg;
+import org.apache.poi.hssf.record.formula.ConcatPtg;
+import org.apache.poi.hssf.record.formula.FuncVarPtg;
+import org.apache.poi.hssf.record.formula.IntPtg;
+import org.apache.poi.hssf.record.formula.RangePtg;
+import org.apache.poi.hssf.record.formula.ReferencePtg;
+import org.apache.poi.hssf.record.formula.UnknownPtg;
+
 import junit.framework.TestCase;
 
 /**
@@ -106,6 +116,52 @@
 		byte[] output = record.serialize();
 		assertEquals("Output size", 31, output.length); //includes sid+recordlength
     	assertEquals("Offset 22", 1, output[26]);
+    }
+    
+    public void testWithConcat()  throws Exception {
+    	// =CHOOSE(2,A2,A3,A4)
+    	byte[] data = new byte[] {
+    			6, 0, 68, 0,
+    			1, 0, 1, 0, 15, 0, 0, 0, 0, 0, 0, 0, 57,
+				64, 0, 0, 12, 0, 12, -4, 46, 0, 
+				30, 2, 0,    // Int - 2
+				25, 4, 3, 0, // Attr
+				8, 0,        // Concat 
+				17, 0,       // Range 
+				26, 0, 35, 0, // Bit like an attr
+				36, 1, 0, 0, -64, // Ref - A2
+				25, 8, 21, 0, // Attr
+				36, 2, 0, 0, -64, // Ref - A3
+				25,	8, 12, 0, // Attr
+				36, 3, 0, 0, -64, // Ref - A4
+				25, 8, 3, 0,  // Attr 
+				66, 4, 100, 0 // CHOOSE
+    	};
+    	RecordInputStream inp = new RecordInputStream(
+    			new ByteArrayInputStream(data)
+    	);
+    	inp.nextRecord();
+    	
+    	FormulaRecord fr = new FormulaRecord(inp);
+    	
+    	assertEquals(14, fr.getNumberOfExpressionTokens());
+    	assertEquals(IntPtg.class,       fr.getParsedExpression().get(0).getClass());
+    	assertEquals(AttrPtg.class,      fr.getParsedExpression().get(1).getClass());
+    	assertEquals(ConcatPtg.class,    fr.getParsedExpression().get(2).getClass());
+    	assertEquals(UnknownPtg.class,   fr.getParsedExpression().get(3).getClass());
+    	assertEquals(RangePtg.class,     fr.getParsedExpression().get(4).getClass());
+    	assertEquals(UnknownPtg.class,   fr.getParsedExpression().get(5).getClass());
+    	assertEquals(AttrPtg.class,      fr.getParsedExpression().get(6).getClass());
+    	assertEquals(ReferencePtg.class, fr.getParsedExpression().get(7).getClass());
+    	assertEquals(AttrPtg.class,      fr.getParsedExpression().get(8).getClass());
+    	assertEquals(ReferencePtg.class, fr.getParsedExpression().get(9).getClass());
+    	assertEquals(AttrPtg.class,      fr.getParsedExpression().get(10).getClass());
+    	assertEquals(ReferencePtg.class, fr.getParsedExpression().get(11).getClass());
+    	assertEquals(AttrPtg.class,      fr.getParsedExpression().get(12).getClass());
+    	assertEquals(FuncVarPtg.class,   fr.getParsedExpression().get(13).getClass());
+    	
+    	FuncVarPtg choose = (FuncVarPtg)fr.getParsedExpression().get(13);
+    	assertEquals("CHOOSE", choose.getName());
     }
     
     



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