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/05/06 18:00:38 UTC

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

Author: nick
Date: Tue May  6 09:00:36 2008
New Revision: 653822

URL: http://svn.apache.org/viewvc?rev=653822&view=rev
Log:
Merged revisions 638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-639917,639919-640056,640058-640710,640712-641156,641158-641184,641186-641795,641797-641798,641800-641933,641935-641963,641965-641966,641968-641995,641997-642230,642232-642562,642564-642565,642568-642570,642572-642573,642576-642736,642739-642877,642879,642881-642890,642892-642903,642905-642945,642947-643624,643626-643653,643655-643669,643671,643673-643830,643832-643833,643835-644342,644344-644472,644474-644508,644510-645347,645349-645351,645353-645559,645561-645565,645568-645951,645953-646193,646195-646311,646313-646404,646406-646665,646667-646853,646855-646869,646871-647151,647153-647185,647187-647277,647279-647566,647568-647573,647575,647578-647711,647714-647737,647739-647823,647825-648155,648157-648202,648204-648273,648275,648277-648302,648304-648333,648335-648588,648590-648622,648625-648673,648675-649141,649144,649146-649556,
 649558-649795,649799,649801-649910,649912-649913,649915-650128,650131-650132,650134-650137,650140-650914,650916-653812 via svnmerge from 
https://svn.apache.org:443/repos/asf/poi/trunk

........
  r651992 | nick | 2008-04-27 19:02:13 +0100 (Sun, 27 Apr 2008) | 1 line
  
  Fix from Trejkaz from bug #44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect
........
  r652285 | yegor | 2008-04-30 07:18:05 +0100 (Wed, 30 Apr 2008) | 1 line
  
  start a new section for 3.1-beta2
........
  r652288 | yegor | 2008-04-30 07:19:38 +0100 (Wed, 30 Apr 2008) | 1 line
  
  correctly process PICT blips (see bug #44886)
........
  r652290 | yegor | 2008-04-30 07:21:04 +0100 (Wed, 30 Apr 2008) | 1 line
  
  more flexible creation of a cluster
........
  r652292 | yegor | 2008-04-30 07:22:02 +0100 (Wed, 30 Apr 2008) | 1 line
  
  a few more words in the release guide
........
  r652298 | yegor | 2008-04-30 07:29:11 +0100 (Wed, 30 Apr 2008) | 1 line
  
  more work on rendering ppt slides
........
  r652329 | nick | 2008-04-30 12:10:49 +0100 (Wed, 30 Apr 2008) | 1 line
  
  Tests to show that bugs 44891 and 44861 were both already fixed
........
  r652426 | josh | 2008-05-01 04:25:37 +0100 (Thu, 01 May 2008) | 1 line
  
  fixed bug 44892 - made HSSFWorkbook.getSheet(String) case insensitive
........
  r652446 | josh | 2008-05-01 08:42:18 +0100 (Thu, 01 May 2008) | 1 line
  
  44914 - Fix/suppress warning message - WARN. Unread n bytes of record 0xNN
........
  r652561 | josh | 2008-05-01 16:46:21 +0100 (Thu, 01 May 2008) | 1 line
  
  added disabled junit for bug 44916
........
  r652934 | josh | 2008-05-02 23:36:49 +0100 (Fri, 02 May 2008) | 1 line
  
  44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*)
........
  r652936 | josh | 2008-05-02 23:49:38 +0100 (Fri, 02 May 2008) | 1 line
  
  should have been submitted with r652934
........
  r652994 | josh | 2008-05-03 04:59:32 +0100 (Sat, 03 May 2008) | 1 line
  
  Fixed 44675 - Parameter operand classes (function metadata) required to encode SUM() etc properly. Added parse validation for number of parameters
........
  r653117 | josh | 2008-05-03 20:53:38 +0100 (Sat, 03 May 2008) | 1 line
  
  44929 - Improved error handling in HSSFWorkbook when attempting to read a BIFF5 file
........
  r653125 | josh | 2008-05-03 21:13:56 +0100 (Sat, 03 May 2008) | 1 line
  
  Swapped ArrayIndexOutOfBoundsException for plain array length check in AbstractFunctionPtg.getParameterClass(). (To help debugging when trying to find a real AIOOB)
........
  r653484 | yegor | 2008-05-05 14:59:11 +0100 (Mon, 05 May 2008) | 1 line
  
  take into account indentation in HSSFSheet.autosizeColumn
........
  r653485 | yegor | 2008-05-05 14:59:38 +0100 (Mon, 05 May 2008) | 1 line
  
  take into account indentation in HSSFSheet.autosizeColumn
........
  r653486 | yegor | 2008-05-05 15:00:30 +0100 (Mon, 05 May 2008) | 1 line
  
  getting ready to 3.1-beta2
........
  r653520 | yegor | 2008-05-05 17:12:21 +0100 (Mon, 05 May 2008) | 1 line
  
  bug #44235 is not reproducible in 3.1-beta1
........
  r653521 | yegor | 2008-05-05 17:13:24 +0100 (Mon, 05 May 2008) | 1 line
  
  restored mistakenly commented line
........
  r653551 | josh | 2008-05-05 19:30:49 +0100 (Mon, 05 May 2008) | 1 line
  
  Added test case method javadoc for old bug 44675
........
  r653608 | josh | 2008-05-05 22:38:07 +0100 (Mon, 05 May 2008) | 1 line
  
  Follow-on from 28754 - StringPtg.toFormulaString() should escape double quotes
........
  r653668 | josh | 2008-05-06 03:02:41 +0100 (Tue, 06 May 2008) | 1 line
  
  42564 - fixed ArrayPtg to use ConstantValueParser.  Fixed a few other ArrayPtg encoding issues.
........
  r653675 | josh | 2008-05-06 04:57:15 +0100 (Tue, 06 May 2008) | 1 line
  
  42570 - fixed LabelRecord to use empty string instead of null when the length is zero.
........

Added:
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
      - copied unchanged from r653675, poi/trunk/src/scratchpad/src/org/apache/poi/hslf/record/TextRulerAtom.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java
      - copied unchanged from r653675, poi/trunk/src/scratchpad/testcases/org/apache/poi/hslf/record/TestTextRulerAtom.java
    poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherBlipRecord.java
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/ddf/TestEscherBlipRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/ddf/data/
      - copied from r653675, poi/trunk/src/testcases/org/apache/poi/ddf/data/
    poi/branches/ooxml/src/testcases/org/apache/poi/ddf/data/Container.dat
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/ddf/data/Container.dat
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/44235.xls
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/data/44235.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/44840.xls
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/data/44840.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/44861.xls
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/data/44861.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/44891.xls
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/data/44891.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/ex42570-20305.xls
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/data/ex42570-20305.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/ex44921-21902.xls
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/data/ex44921-21902.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestLabelRecord.java
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/record/TestLabelRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestArrayPtg.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestFuncVarPtg.java
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/TestFuncVarPtg.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.java
      - copied unchanged from r653675, poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPatriarch.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/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/documentation/release-guide.txt
    poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherDggRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherMetafileBlip.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/dev/BiffViewer.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/model/Workbook.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FileSharingRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LabelRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ConstantValueParser.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ErrorConstant.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.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/ArrayPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.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/RefNAPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RefNPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/RefNVPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ReferencePtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/StringPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/function/FunctionDataBuilder.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/function/FunctionMetadata.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/function/FunctionMetadataReader.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFPictureData.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/branches/ooxml/src/ooxml/interfaces-jdk14/org/apache/poi/ss/usermodel/Workbook.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/AutoShapes.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Freeform.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/MasterSheet.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/ShapeGroup.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Sheet.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SimpleShape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/Slide.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/SlideMaster.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextPainter.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextRun.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/model/TextShape.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/PPDrawing.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/RecordTypes.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/record/StyleTextPropAtom.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/RichTextRun.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hslf/usermodel/SlideShow.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestFreeform.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestRichTextRun.java
    poi/branches/ooxml/src/testcases/org/apache/poi/ddf/AllPOIDDFTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/ddf/TestEscherContainerRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/HSSFTestDataSamples.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/AllRecordTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/AllFormulaTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/TestReferencePtg.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/AllUserModelTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFPicture.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May  6 09:00:36 2008
@@ -1 +1 @@
-/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-650920
+/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-653812

Modified: poi/branches/ooxml/build.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/build.xml?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/build.xml (original)
+++ poi/branches/ooxml/build.xml Tue May  6 09:00:36 2008
@@ -579,6 +579,8 @@
         file="${main.src.test}/org/apache/poi/hpsf/data"/> 
       <sysproperty key="POIFS.testdata.path"
         file="${main.src.test}/org/apache/poi/poifs/data"/> 
+      <sysproperty key="DDF.testdata.path"
+        file="${main.src.test}/org/apache/poi/ddf/data"/> 
       <sysproperty key="java.awt.headless" value="true"/>
       <formatter type="plain"/>
       <formatter type="xml"/>

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=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Tue May  6 09:00:36 2008
@@ -43,7 +43,20 @@
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling PowerPoint files, irrespective of if they are .ppt or .pptx</action>
            <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.1-beta1" date="2008-04-??">
+        <release version="3.1-beta2" date="2008-05-??">
+           <action dev="POI-DEVELOPERS" type="fix">42570 - fixed LabelRecord to use empty string instead of null when the length is zero.</action>
+           <action dev="POI-DEVELOPERS" type="fix">42564 - fixed ArrayPtg to use ConstantValueParser.  Fixed a few other ArrayPtg encoding issues.</action>
+           <action dev="POI-DEVELOPERS" type="fix">Follow-on from 28754 - StringPtg.toFormulaString() should escape double quotes</action>
+           <action dev="POI-DEVELOPERS" type="fix">44929 - Improved error handling in HSSFWorkbook when attempting to read a BIFF5 file</action>
+           <action dev="POI-DEVELOPERS" type="fix">44675 - Parameter operand classes (function metadata) required to encode SUM() etc properly. Added parse validation for number of parameters</action>
+           <action dev="POI-DEVELOPERS" type="fix">44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*)</action>
+           <action dev="POI-DEVELOPERS" type="fix">44914 - Fix/suppress warning message "WARN. Unread n bytes of record 0xNN"</action>
+           <action dev="POI-DEVELOPERS" type="fix">44892 - made HSSFWorkbook.getSheet(String) case insensitive</action>
+           <action dev="POI-DEVELOPERS" type="fix">44886] - Correctly process PICT metafile in EscherMetafileBlip</action>
+           <action dev="POI-DEVELOPERS" type="fix">44893 - Take into account indentation in HSSFSheet.autoSizeColumn</action>
+        </release>
+        <release version="3.1-beta1" date="2008-04-28">
+           <action dev="POI-DEVELOPERS" type="fix">44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect</action>
            <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
            <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
            <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting OLE object data from slide show </action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/index.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/index.xml?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/index.xml Tue May  6 09:00:36 2008
@@ -40,7 +40,24 @@
        People interested should follow the
        <link href="mailinglists.html">dev list</link> to track progress.</p>
     </section>
-    <section><title>February 06 2008 - POI 3.0.2 Released</title>
+    <section><title>POI 3.1-BETA1 Released (2008-04028)</title>
+      <p>
+        The POI team is pleased to announce the release of 3.1 BETA1 which is one of the final steps before 3.1 FINAL.
+        The status of this release is a beta, meaning that we encourage users to try it out.
+        If you find any bugs, please report them to the POI <link href="https://issues.apache.org/bugzilla/buglist.cgi?product=POI">bug database</link> or to
+        the <link href="./mailinglists.html">POI Developer List</link>.
+        </p><p>  A full list of changes	is available in
+      <link href="./changes.html">the changelog</link>, and 
+		<link href="http://www.apache.org/dyn/closer.cgi/poi/dev/">download</link>
+		the source and binaries from your
+    <link href="http://www.apache.org/dyn/closer.cgi/poi/dev/">local mirror</link>.
+      </p>
+      <p>
+        The release is also available from the central Maven repository 
+        under Group ID "org.apache.poi" and Version "3.1-beta1".
+      </p>  
+    </section>
+    <section><title>POI 3.0.2 Released</title>
       <p>The POI team is pleased to announce POI 3.0.2, the latest release of Apache POI.
         There have been many important bug fixes since the 3.0.1 release and a lot of new features.  A full list of changes	is available in 
       <link href="./changes.html">the changelog</link>, and 

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=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Tue May  6 09:00:36 2008
@@ -40,7 +40,21 @@
            <action dev="POI-DEVELOPERS" type="add">Created a common interface for handling PowerPoint files, irrespective of if they are .ppt or .pptx</action>
            <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.1-beta1" date="2008-04-??">
+        <release version="3.1-beta2" date="2008-05-??">
+           <action dev="POI-DEVELOPERS" type="fix">42570 - fixed LabelRecord to use empty string instead of null when the length is zero.</action>
+           <action dev="POI-DEVELOPERS" type="fix">42564 - fixed ArrayPtg to use ConstantValueParser.  Fixed a few other ArrayPtg encoding issues.</action>
+           <action dev="POI-DEVELOPERS" type="fix">Follow-on from 28754 - StringPtg.toFormulaString() should escape double quotes</action>
+           <action dev="POI-DEVELOPERS" type="fix">44929 - Improved error handling in HSSFWorkbook when attempting to read a BIFF5 file</action>
+           <action dev="POI-DEVELOPERS" type="fix">44675 - Parameter operand classes (function metadata) required to encode SUM() etc properly. Added parse validation for number of parameters</action>
+           <action dev="POI-DEVELOPERS" type="fix">44921 - allow Ptg.writeBytes() to be called on relative ref Ptgs (RefN* and AreaN*)</action>
+           <action dev="POI-DEVELOPERS" type="fix">44914 - Fix/suppress warning message "WARN. Unread n bytes of record 0xNN"</action>
+           <action dev="POI-DEVELOPERS" type="fix">44892 - made HSSFWorkbook.getSheet(String) case insensitive</action>
+           <action dev="POI-DEVELOPERS" type="fix">44886] - Correctly process PICT metafile in EscherMetafileBlip</action>
+           <action dev="POI-DEVELOPERS" type="fix">44893 - Take into account indentation in HSSFSheet.autoSizeColumn</action>
+        </release>
+        <release version="3.1-beta1" date="2008-04-28">
+           <action dev="POI-DEVELOPERS" type="fix">44857 - Avoid OOM on unknown escher records when EscherMetafileBlip is incorrect</action>
+>>>>>>> .merge-right.r653675
            <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting embedded sounds from slide show </action>
            <action dev="POI-DEVELOPERS" type="add">HSLF: Initial support for rendering slides into images</action>
            <action dev="POI-DEVELOPERS" type="add">HSLF: Support for getting OLE object data from slide show </action>

Modified: poi/branches/ooxml/src/documentation/release-guide.txt
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/release-guide.txt?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/release-guide.txt (original)
+++ poi/branches/ooxml/src/documentation/release-guide.txt Tue May  6 09:00:36 2008
@@ -19,7 +19,11 @@
   POI 3.0.2 and 3.1 were built using Ant 1.6.2 and Forrest 0.5
 
 (II) Making release artefacts
-  1. Update version id in build.xml. 
+  1. Update version id in build.xml
+{code:xml}
+  <property name="version.id" value="3.1-beta1"/>
+{code}
+
   2. Tag current version. Include the current revision number in the comment
 
 {code}
@@ -46,7 +50,7 @@
 
   5. Start a new section in sites.xml and status.xml. 
 
-  6. Build as if the vote had passed. The buid date must be +7 days from current.
+  6. Build as if the vote had passed. The build date must be +7 days from current.
 {code}
 ant build
 {code}
@@ -109,27 +113,68 @@
 
 1. Go to ~/POI-3.1-BETA1
 
+zap previous version first.
+
+{code}
 cd ~/POI-3.1-BETA1/main
+{code}
 
 BETA and ALPHA releases:
+
+{code}
 cp *-src-* /www/www.apache.org/dist/poi/dev/src
 cp *-bin-* /www/www.apache.org/dist/poi/dev/bin
+{code}
 
 FINAL release:
+{code}
 cp *-src-* /www/www.apache.org/dist/poi/release/src
 cp *-bin-* /www/www.apache.org/dist/poi/release/bin
+{code}
 
+{code}
 cd ~/POI-3.1-BETA1/maven
-
 cp -r org.apache.poi /www/people.apache.org/repo/m1-ibiblio-rsync-repository/
 cp -r poi/poms      /www/people.apache.org/repo/m1-ibiblio-rsync-repository/poi
-
+{code}
 
 2. Make sure that the files are owned by the unix group apcvs and that they are writable by this group. 
 
 3. Wait for the distributions to appear on your favourite mirror
 
-4. Send announcements:
+4. test maven
+create a simple project and make sure the release artifacts are accessible by maven:
+
+{code}
+$ mvn archetype:create -DgroupId=org.apache.poi.scratchpad -DartifactId=maven-test
+cd maven-test
+{code}
+edit pom.xml and add the release artefacts to the project dependencies: 
+
+{code:xml}
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi</artifactId>
+      <version>3.1-beta1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.poi</groupId>
+      <artifactId>poi-scratchpad</artifactId>
+      <version>3.1-beta1</version>
+    </dependency>
+{code}
+
+{code}
+mvn compile 
+{code}
+
+You should see [INFO] BUILD SUCCESSFUL in the end.
+
+5. Don't forget to upload the latest version of the site and javadocs
+
+6. Send announcements:
  - to poi-user and poi-dev lists
- - send announcements to announcement@apache.org, announcements@jakarta.apache.org
+ - to announcement@apache.org, announcements@jakarta.apache.org
+
+Note, announcements should be sent from your @apache.org e-mail address.
 

Modified: poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherDggRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherDggRecord.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherDggRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherDggRecord.java Tue May  6 09:00:36 2008
@@ -38,6 +38,7 @@
     private int field_3_numShapesSaved;
     private int field_4_drawingsSaved;
     private FileIdCluster[] field_5_fileIdClusters;
+    private int maxDgId;
 
     public static class FileIdCluster
     {
@@ -87,6 +88,7 @@
         for (int i = 0; i < field_5_fileIdClusters.length; i++)
         {
             field_5_fileIdClusters[i] = new FileIdCluster(LittleEndian.getInt( data, pos + size ), LittleEndian.getInt( data, pos + size + 4 ));
+            maxDgId = Math.max(maxDgId, field_5_fileIdClusters[i].getDrawingGroupId());
             size += 8;
         }
         bytesRemaining         -= size;
@@ -229,7 +231,14 @@
         this.field_4_drawingsSaved = field_4_drawingsSaved;
     }
 
-    public FileIdCluster[] getFileIdClusters()
+    /**
+     * @return The maximum drawing group ID
+     */
+    public int getMaxDrawingGroupId(){
+        return maxDgId;
+    }
+
+     public FileIdCluster[] getFileIdClusters()
     {
         return field_5_fileIdClusters;
     }
@@ -241,9 +250,22 @@
 
     public void addCluster( int dgId, int numShapedUsed )
     {
+        addCluster(dgId, numShapedUsed, true);
+    }
+
+    /**
+     * Add a new cluster
+     *
+     * @param dgId  id of the drawing group (stored in the record options)
+     * @param numShapedUsed initial value of the numShapedUsed field
+     * @param sort if true then sort clusters by drawing group id.(
+     *  In Excel the clusters are sorted but in PPT they are not)
+     */
+    public void addCluster( int dgId, int numShapedUsed, boolean sort )
+    {
         List clusters = new ArrayList(Arrays.asList(field_5_fileIdClusters));
         clusters.add(new FileIdCluster(dgId, numShapedUsed));
-        Collections.sort(clusters, new Comparator()
+        if(sort) Collections.sort(clusters, new Comparator()
         {
             public int compare( Object o1, Object o2 )
             {
@@ -257,6 +279,7 @@
                     return +1;
             }
         } );
+        maxDgId = Math.min(maxDgId, dgId);
         field_5_fileIdClusters = (FileIdCluster[]) clusters.toArray( new FileIdCluster[clusters.size()] );
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherMetafileBlip.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherMetafileBlip.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherMetafileBlip.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/ddf/EscherMetafileBlip.java Tue May  6 09:00:36 2008
@@ -41,9 +41,20 @@
     public static final short RECORD_ID_WMF = (short) 0xF018 + 3;
     public static final short RECORD_ID_PICT = (short) 0xF018 + 4;
 
+    /**
+     * BLIP signatures as defined in the escher spec
+     */
+    public static final short SIGNATURE_EMF  = 0x3D40;
+    public static final short SIGNATURE_WMF  = 0x2160;
+    public static final short SIGNATURE_PICT = 0x5420;
+
     private static final int HEADER_SIZE = 8;
 
     private byte[] field_1_UID;
+    /**
+     * The primary UID is only saved to disk if (blip_instance ^ blip_signature == 1)
+     */
+    private byte[] field_2_UID;
     private int field_2_cb;
     private int field_3_rcBounds_x1;
     private int field_3_rcBounds_y1;
@@ -72,6 +83,12 @@
 
         field_1_UID = new byte[16];
         System.arraycopy( data, pos, field_1_UID, 0, 16 ); pos += 16;
+
+        if((getOptions() ^ getSignature()) == 0x10){
+            field_2_UID = new byte[16];
+            System.arraycopy( data, pos, field_2_UID, 0, 16 ); pos += 16;
+        }
+
         field_2_cb = LittleEndian.getInt( data, pos ); pos += 4;
         field_3_rcBounds_x1 = LittleEndian.getInt( data, pos ); pos += 4;
         field_3_rcBounds_y1 = LittleEndian.getInt( data, pos ); pos += 4;
@@ -118,9 +135,12 @@
         int pos = offset;
         LittleEndian.putShort( data, pos, getOptions() ); pos += 2;
         LittleEndian.putShort( data, pos, getRecordId() ); pos += 2;
-        LittleEndian.putInt( data, getRecordSize() - HEADER_SIZE ); pos += 4;
+        LittleEndian.putInt( data, pos, getRecordSize() - HEADER_SIZE ); pos += 4;
 
-        System.arraycopy( field_1_UID, 0, data, pos, 16 ); pos += 16;
+        System.arraycopy( field_1_UID, 0, data, pos, field_1_UID.length ); pos += field_1_UID.length;
+        if((getOptions() ^ getSignature()) == 0x10){
+            System.arraycopy( field_2_UID, 0, data, pos, field_2_UID.length ); pos += field_2_UID.length;
+        }
         LittleEndian.putInt( data, pos, field_2_cb ); pos += 4;
         LittleEndian.putInt( data, pos, field_3_rcBounds_x1 ); pos += 4;
         LittleEndian.putInt( data, pos, field_3_rcBounds_y1 ); pos += 4;
@@ -135,7 +155,7 @@
         System.arraycopy( raw_pictureData, 0, data, pos, raw_pictureData.length );
 
         listener.afterRecordSerialize(offset + getRecordSize(), getRecordId(), getRecordSize(), this);
-        return HEADER_SIZE + 16 + 1 + raw_pictureData.length;
+        return getRecordSize();
     }
 
     /**
@@ -161,7 +181,7 @@
         }
         catch ( IOException e )
         {
-            log.log(POILogger.INFO, "Possibly corrupt compression or non-compressed data", e);
+            log.log(POILogger.WARN, "Possibly corrupt compression or non-compressed data", e);
             return data;
         }
     }
@@ -173,7 +193,11 @@
      */
     public int getRecordSize()
     {
-        return 8 + 50 + raw_pictureData.length;
+        int size = 8 + 50 + raw_pictureData.length;
+        if((getOptions() ^ getSignature()) == 0x10){
+            size += field_2_UID.length;
+        }
+        return size;
     }
 
     public byte[] getUID()
@@ -186,6 +210,16 @@
         this.field_1_UID = field_1_UID;
     }
 
+    public byte[] getPrimaryUID()
+    {
+        return field_2_UID;
+    }
+
+    public void setPrimaryUID( byte[] field_2_UID )
+    {
+        this.field_2_UID = field_2_UID;
+    }
+
     public int getUncompressedSize()
     {
         return field_2_cb;
@@ -264,6 +298,7 @@
                 "  RecordId: 0x" + HexDump.toHex( getRecordId() ) + nl +
                 "  Options: 0x" + HexDump.toHex( getOptions() ) + nl +
                 "  UID: 0x" + HexDump.toHex( field_1_UID ) + nl +
+                (field_2_UID == null ? "" : ("  UID2: 0x" + HexDump.toHex( field_2_UID ) + nl)) +
                 "  Uncompressed Size: " + HexDump.toHex( field_2_cb ) + nl +
                 "  Bounds: " + getBounds() + nl +
                 "  Size in EMU: " + getSizeEMU() + nl +
@@ -273,4 +308,19 @@
                 "  Extra Data:" + nl + extraData;
     }
 
+    /**
+     * Return the blip signature
+     *
+     * @return the blip signature
+     */
+    public short getSignature(){
+        short sig = 0;
+        switch(getRecordId()){
+            case RECORD_ID_EMF: sig = SIGNATURE_EMF; break;
+            case RECORD_ID_WMF: sig = SIGNATURE_WMF; break;
+            case RECORD_ID_PICT: sig = SIGNATURE_PICT; break;
+            default: log.log(POILogger.WARN, "Unknown metafile: " + getRecordId()); break;
+        }
+        return sig;
+    }
 }

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=653822&r1=653821&r2=653822&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 Tue May  6 09:00:36 2008
@@ -122,7 +122,7 @@
 
     private static void dumpNormal(Record record, int startloc, short rectype, short recsize)
     {
-        //System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
+        System.out.println("Offset 0x" + Integer.toHexString(startloc) + " (" + startloc + ")");
         System.out.println( "recordid = 0x" + Integer.toHexString( rectype ) + ", size = " + recsize );
         System.out.println( record.toString() );
 

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java Tue May  6 09:00:36 2008
@@ -380,12 +380,13 @@
         } else {
             isVarArgs = !fm.hasFixedArgsLength();
             funcIx = fm.getIndex();
+            validateNumArgs(numArgs, fm);
         }
         AbstractFunctionPtg retval;
         if(isVarArgs) {
             retval = new FuncVarPtg(name, (byte)numArgs);
         } else {
-            retval = new FuncPtg(funcIx, (byte)numArgs);
+            retval = new FuncPtg(funcIx);
         }
         if (!name.equals(AbstractFunctionPtg.FUNCTION_NAME_IF)) {
             // early return for everything else besides IF()
@@ -447,6 +448,29 @@
         return retval;
     }
 
+    private void validateNumArgs(int numArgs, FunctionMetadata fm) {
+        if(numArgs < fm.getMinParams()) {
+            String msg = "Too few arguments to function '" + fm.getName() + "'. ";
+            if(fm.hasFixedArgsLength()) {
+                msg += "Expected " + fm.getMinParams();
+            } else {
+                msg += "At least " + fm.getMinParams() + " were expected";
+            }
+            msg += " but got " + numArgs + ".";
+            throw new FormulaParseException(msg);
+         }
+        if(numArgs > fm.getMaxParams()) {
+            String msg = "Too many arguments to function '" + fm.getName() + "'. ";
+            if(fm.hasFixedArgsLength()) {
+                msg += "Expected " + fm.getMaxParams();
+            } else {
+                msg += "At most " + fm.getMaxParams() + " were expected";
+            }
+            msg += " but got " + numArgs + ".";
+            throw new FormulaParseException(msg);
+       }
+    }
+
     private static boolean isArgumentDelimiter(char ch) {
         return ch ==  ',' || ch == ')';
     }

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=653822&r1=653821&r2=653822&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 Tue May  6 09:00:36 2008
@@ -476,9 +476,9 @@
     }
 
     /**
-     * Determines whether a workbook contains the privided sheet name.
+     * Determines whether a workbook contains the provided sheet name.
      *
-     * @param name the name to test
+     * @param name the name to test (case insensitive match)
      * @param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the check.
      * @return true if the sheet contains the name, false otherwise.
      */
@@ -487,7 +487,7 @@
         for ( int i = 0; i < boundsheets.size(); i++ )
         {
             BoundSheetRecord boundSheetRecord = (BoundSheetRecord) boundsheets.get( i );
-            if (excludeSheetIdx != i && name.equals(boundSheetRecord.getSheetname()))
+            if (excludeSheetIdx != i && name.equalsIgnoreCase(boundSheetRecord.getSheetname()))
                 return true;
         }
         return false;

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ColumnInfoRecord.java Tue May  6 09:00:36 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
-/*
- * ColumnInfoRecord.java
- *
- * Created on December 8, 2001, 8:44 AM
- */
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndian;
@@ -29,29 +22,28 @@
 import org.apache.poi.util.BitFieldFactory;
 
 /**
- * Title: ColumnInfo Record<P>
- * Description:  Defines with width and formatting for a range of columns<P>
- * REFERENCE:  PG 293 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
+ * Title: COLINFO Record<p/>
+ * Description:  Defines with width and formatting for a range of columns<p/>
+ * REFERENCE:  PG 293 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<p/>
  * @author Andrew C. Oliver (acoliver at apache dot org)
  * @version 2.0-pre
  */
-
-public class ColumnInfoRecord
-    extends Record
-{
+public final class ColumnInfoRecord extends Record {
     public static final short     sid = 0x7d;
     private short                 field_1_first_col;
     private short                 field_2_last_col;
     private short                 field_3_col_width;
     private short                 field_4_xf_index;
     private short                 field_5_options;
-    static final private BitField hidden    = BitFieldFactory.getInstance(0x01);
-    static final private BitField outlevel  = BitFieldFactory.getInstance(0x0700);
-    static final private BitField collapsed = BitFieldFactory.getInstance(0x1000);
+    private static final BitField hidden    = BitFieldFactory.getInstance(0x01);
+    private static final BitField outlevel  = BitFieldFactory.getInstance(0x0700);
+    private static final BitField collapsed = BitFieldFactory.getInstance(0x1000);
+    // Excel seems write values 2, 10, and 260, even though spec says "must be zero"
     private short                 field_6_reserved;
 
     public ColumnInfoRecord()
     {
+        field_6_reserved = 2; // seems to be the most common value
     }
 
     /**
@@ -71,7 +63,18 @@
         field_3_col_width = in.readShort();
         field_4_xf_index  = in.readShort();
         field_5_options   = in.readShort();
-        field_6_reserved  = in.readShort();
+        switch(in.remaining()) {
+            case 2: // usual case
+                field_6_reserved  = in.readShort();
+                break;
+            case 1:
+                // often COLINFO gets encoded 1 byte short
+                // shouldn't matter because this field is unused
+                field_6_reserved  = in.readByte(); 
+                break;
+            default:
+                throw new RuntimeException("Unusual record size remaining=(" + in.remaining() + ")");
+        }
     }
 
     protected void validateSid(short id)

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FileSharingRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FileSharingRecord.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FileSharingRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FileSharingRecord.java Tue May  6 09:00:36 2008
@@ -14,31 +14,26 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
 import org.apache.poi.util.StringUtil;
 
 /**
- * Title:        FileSharing<P>
+ * Title:        FILESHARING<P>
  * Description:  stores the encrypted readonly for a workbook (write protect) 
- * REFERENCE:  PG 314 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
+ * This functionality is accessed from the options dialog box available when performing 'Save As'.<p/>
+ * REFERENCE:  PG 314 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<p/>
  * @author Andrew C. Oliver (acoliver at apache dot org)
  */
+public final class FileSharingRecord extends Record {
 
-public class FileSharingRecord extends Record {
-    private static POILogger logger = POILogFactory.getLogger(FileSharingRecord.class);
-    	
     public final static short sid = 0x5b;
     private short             field_1_readonly;
     private short             field_2_password;
-    private byte              field_3_username_length;
-    private short             field_4_unknown; // not documented
-    private String            field_5_username;
+    private byte              field_3_username_unicode_options;
+    private String            field_3_username_value;
 
     public FileSharingRecord() {}
     
@@ -61,23 +56,15 @@
     protected void fillFields(RecordInputStream in) {
         field_1_readonly = in.readShort();
         field_2_password = in.readShort();
-        field_3_username_length = in.readByte();
         
-        // Is this really correct? The latest docs
-        //  seem to hint there's nothing between the
-        //  username length and the username string
-        field_4_unknown = in.readShort();
+        int nameLen = in.readShort();
         
-        // Ensure we don't try to read more data than
-        //  there actually is
-        if(field_3_username_length > in.remaining()) {
-        	logger.log(POILogger.WARN, "FileSharingRecord defined a username of length " + field_3_username_length + ", but only " + in.remaining() + " bytes were left, truncating");
-        	field_3_username_length = (byte)in.remaining();
-        }
-        if(field_3_username_length > 0) {
-        	field_5_username = in.readCompressedUnicode(field_3_username_length);
+        if(nameLen > 0) {
+            // TODO - Current examples(3) from junits only have zero length username. 
+            field_3_username_unicode_options = in.readByte();
+            field_3_username_value = in.readCompressedUnicode(nameLen);
         } else {
-        	field_5_username = "";
+            field_3_username_value = "";
         }
     }
 
@@ -135,45 +122,24 @@
     /**
      * @returns byte representing the length of the username field
      */
-    public byte getUsernameLength() {
-        return field_3_username_length ;
-    }
-
-    /**
-     * @param byte representing the length of the username field
-     */
-    public void setUsernameLength(byte length) {
-        this.field_3_username_length = length;
+    public short getUsernameLength() {
+        return (short) field_3_username_value.length();
     }
 
     /**
      * @returns username of the user that created the file
      */
     public String getUsername() {
-        return this.field_5_username;
+        return field_3_username_value;
     }
 
     /**
      * @param username of the user that created the file
      */
     public void setUsername(String username) {
-        this.field_5_username = username;
-        this.field_3_username_length = (byte)username.length();
-    }
-
-    /**
-     * @return short value of a "bonus field" in Excel that was not doc'd
-     */
-    public short getUnknown() {
-        return field_4_unknown;
+        field_3_username_value = username;
     }
 
-    /**
-     * @param unknown field value to set (bonus field that is not doc'd)
-     */
-    public void setUnknown(short unk) {
-        field_4_unknown = unk;
-    }
 
     public String toString() {
         StringBuffer buffer = new StringBuffer();
@@ -183,10 +149,6 @@
             .append(getReadOnly() == 1 ? "true" : "false").append("\n");
         buffer.append("    .password       = ")
             .append(Integer.toHexString(getPassword())).append("\n");
-        buffer.append("    .userlen        = ")
-            .append(Integer.toHexString(getUsernameLength())).append("\n");
-        buffer.append("    .unknown        = ")
-            .append(Integer.toHexString(getUnknown())).append("\n");
         buffer.append("    .username       = ")
             .append(getUsername()).append("\n");
         buffer.append("[/FILESHARING]\n");
@@ -194,18 +156,25 @@
     }
 
     public int serialize(int offset, byte [] data) {
+        // TODO - junit
         LittleEndian.putShort(data, 0 + offset, sid);
         LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize()-4));
         LittleEndian.putShort(data, 4 + offset, getReadOnly());
         LittleEndian.putShort(data, 6 + offset, getPassword());
-        data[ 8 + offset ] =  getUsernameLength();
-        LittleEndian.putShort(data, 9 + offset, getUnknown());
-        StringUtil.putCompressedUnicode( getUsername(), data, 11 + offset );
+        LittleEndian.putShort(data, 8 + offset, getUsernameLength());
+        if(getUsernameLength() > 0) {
+            LittleEndian.putByte(data, 10 + offset, field_3_username_unicode_options);
+            StringUtil.putCompressedUnicode( getUsername(), data, 11 + offset );
+        }
         return getRecordSize();
     }
 
     public int getRecordSize() {
-        return 11+getUsernameLength();
+        short nameLen = getUsernameLength();
+        if (nameLen < 1) {
+            return 10;
+        }
+        return 11+nameLen;
     }
 
     public short getSid() {
@@ -219,10 +188,7 @@
       FileSharingRecord clone = new FileSharingRecord();
       clone.setReadOnly(field_1_readonly);
       clone.setPassword(field_2_password);
-      clone.setUsernameLength(field_3_username_length);
-      clone.setUnknown(field_4_unknown);
-      clone.setUsername(field_5_username);
+      clone.setUsername(field_3_username_value);
       return clone;
     }
-
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java Tue May  6 09:00:36 2008
@@ -40,7 +40,7 @@
  * @version 2.0-pre
  */
 
-public class FormulaRecord
+public final class FormulaRecord
     extends Record
     implements CellValueRecordInterface, Comparable
 {
@@ -108,6 +108,11 @@
         } catch (java.lang.UnsupportedOperationException uoe)  {
           throw new RecordFormatException(uoe);
         }
+        if (in.remaining() == 10) {
+            // TODO - this seems to occur when IntersectionPtg is present
+            // 10 extra bytes are just 0x01 and 0x00
+            // This causes POI stderr: "WARN. Unread 10 bytes of record 0x6"
+        }
     }
 
     //public void setRow(short row)

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LabelRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LabelRecord.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LabelRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LabelRecord.java Tue May  6 09:00:36 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
-/*
- * LabelRecord.java
- *
- * Created on November 11, 2001, 12:51 PM
- */
 package org.apache.poi.hssf.record;
 
 /**
@@ -33,14 +26,10 @@
  * @version 2.0-pre
  * @see org.apache.poi.hssf.record.LabelSSTRecord
  */
-
-public class LabelRecord
-    extends Record
-    implements CellValueRecordInterface
-{
+public final class LabelRecord extends Record implements CellValueRecordInterface {
     public final static short sid = 0x204;
-    //private short             field_1_row;
-    private int             field_1_row;
+
+    private int               field_1_row;
     private short             field_2_column;
     private short             field_3_xf_index;
     private short             field_4_string_len;
@@ -85,35 +74,30 @@
 
     protected void fillFields(RecordInputStream in)
     {
-        //field_1_row          = LittleEndian.getShort(data, 0 + offset);
         field_1_row          = in.readUShort();
         field_2_column       = in.readShort();
         field_3_xf_index     = in.readShort();
         field_4_string_len   = in.readShort();
         field_5_unicode_flag = in.readByte();
         if (field_4_string_len > 0) {
-          if (isUnCompressedUnicode()) {
-            field_6_value = in.readUnicodeLEString(field_4_string_len);
-          } else {
-            field_6_value = in.readCompressedUnicode(field_4_string_len);
+            if (isUnCompressedUnicode()) {
+                field_6_value = in.readUnicodeLEString(field_4_string_len);
+            } else {
+                field_6_value = in.readCompressedUnicode(field_4_string_len);
+            }
+        } else {
+            field_6_value = "";
         }
-        } else field_6_value = null;
     }
 
-/* READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST!
-      public void setRow(short row) {
-        field_1_row = row;
-      }
-
-      public void setColumn(short col) {
-        field_2_column = col;
-      }
-
-      public void setXFIndex(short index) {
-        field_3_xf_index = index;
-      }
-  */
-    //public short getRow()
+/*
+ * READ ONLY ACCESS... THIS IS FOR COMPATIBILITY ONLY...USE LABELSST! public
+ * void setRow(short row) { field_1_row = row; }
+ * 
+ * public void setColumn(short col) { field_2_column = col; }
+ * 
+ * public void setXFIndex(short index) { field_3_xf_index = index; }
+ */
     public int getRow()
     {
         return field_1_row;

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SharedFormulaRecord.java Tue May  6 09:00:36 2008
@@ -33,7 +33,7 @@
  * @author Danny Mui at apache dot org
  */
 public final class SharedFormulaRecord extends Record {
-	 public final static short   sid = 0x4BC;
+    public final static short   sid = 0x4BC;
     
     private int               field_1_first_row;
     private int               field_2_last_row;
@@ -186,6 +186,16 @@
      * counter part
      */
     protected static Stack convertSharedFormulas(Stack ptgs, int formulaRow, int formulaColumn) {
+        if(false) {
+            /*
+             * TODO - (May-2008) Stop converting relative ref Ptgs in shared formula records. 
+             * If/when POI writes out the workbook, this conversion makes an unnecessary diff in the BIFF records.
+             * Disabling this code breaks one existing junit.
+             * Some fix-up will be required to make Ptg.toFormulaString(HSSFWorkbook) work properly.
+             * That method will need 2 extra params: rowIx and colIx.
+             */
+            return ptgs;
+        }
         Stack newPtgStack = new Stack();
 
         if (ptgs != null)
@@ -265,7 +275,7 @@
         throw new RuntimeException("Shared Formula Conversion: Coding Error");
       }
     }
-    
+
     private static int fixupRelativeColumn(int currentcolumn, int column, boolean relative) {
         if(relative) {
             // mask out upper bits to produce 'wrapping' at column 256 ("IV")

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ConstantValueParser.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ConstantValueParser.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ConstantValueParser.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ConstantValueParser.java Tue May  6 09:00:36 2008
@@ -24,9 +24,8 @@
 
 /**
  * To support Constant Values (2.5.7) as required by the CRN record.
- * This class should probably also be used for two dimensional arrays which are encoded by 
+ * This class is also used for two dimensional arrays which are encoded by 
  * EXTERNALNAME (5.39) records and Array tokens.<p/>
- * TODO - code in ArrayPtg should be merged with this code.  It currently supports only 2 of the constant types
  * 
  * @author Josh Micich
  */

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ErrorConstant.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ErrorConstant.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ErrorConstant.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/constant/ErrorConstant.java Tue May  6 09:00:36 2008
@@ -47,18 +47,31 @@
 	public int getErrorCode() {
 		return _errorCode;
 	}
+	public String getText() {
+		if(HSSFErrorConstants.isValidCode(_errorCode)) {
+			return HSSFErrorConstants.getText(_errorCode);
+		}
+		return "unknown error code (" + _errorCode + ")";
+	}
 
 	public static ErrorConstant valueOf(int errorCode) {
 		switch (errorCode) {
-    		case HSSFErrorConstants.ERROR_NULL:  return NULL;
-    		case HSSFErrorConstants.ERROR_DIV_0: return DIV_0;
-    		case HSSFErrorConstants.ERROR_VALUE: return VALUE;
-    		case HSSFErrorConstants.ERROR_REF:   return REF;
-    		case HSSFErrorConstants.ERROR_NAME:  return NAME;
-    		case HSSFErrorConstants.ERROR_NUM:   return NUM;
-    		case HSSFErrorConstants.ERROR_NA:    return NA;
+			case HSSFErrorConstants.ERROR_NULL:  return NULL;
+			case HSSFErrorConstants.ERROR_DIV_0: return DIV_0;
+			case HSSFErrorConstants.ERROR_VALUE: return VALUE;
+			case HSSFErrorConstants.ERROR_REF:   return REF;
+			case HSSFErrorConstants.ERROR_NAME:  return NAME;
+			case HSSFErrorConstants.ERROR_NUM:   return NUM;
+			case HSSFErrorConstants.ERROR_NA:	return NA;
 		}
 		System.err.println("Warning - unexpected error code (" + errorCode + ")");
 		return new ErrorConstant(errorCode);
 	}
+	public String toString() {
+		StringBuffer sb = new StringBuffer(64);
+		sb.append(getClass().getName()).append(" [");
+		sb.append(getText());
+		sb.append("]");
+		return sb.toString();
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AbstractFunctionPtg.java Tue May  6 09:00:36 2008
@@ -147,10 +147,12 @@
     }
 
     public byte getParameterClass(int index) {
-        try {
-            return paramClass[index];
-        } catch (ArrayIndexOutOfBoundsException aioobe) {
+        if (index >= paramClass.length) {
+            // For var-arg (and other?) functions, the metadata does not list all the parameter
+            // operand classes.  In these cases, all extra parameters are assumed to have the 
+            // same operand class as the last one specified.
             return paramClass[paramClass.length - 1];
         }
+        return paramClass[index];
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNAPtg.java Tue May  6 09:00:36 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -16,19 +15,9 @@
    limitations under the License.
 ==================================================================== */
 
-/*
- * AreaPtg.java
- *
- * Created on November 17, 2001, 9:30 PM
- */
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.AreaReference;
-import org.apache.poi.hssf.util.CellReference;
 import org.apache.poi.ss.usermodel.Workbook;
 
 /**
@@ -36,8 +25,7 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  */
 
-public class AreaNAPtg
-    extends AreaPtg
+public final class AreaNAPtg extends AreaPtg
 {
     public final static short sid  = 0x6D;
 
@@ -50,20 +38,16 @@
       super(in);
     }
 
-    public void writeBytes(byte [] array, int offset) {
-      throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
-    }
-
     public String getAreaPtgName() {
       return "AreaNAPtg";
     }
 
     public String toFormulaString(Workbook book)
     {
-      throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+      throw notImplemented();
     }
 
     public Object clone() {
-      throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+      throw notImplemented();
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNPtg.java Tue May  6 09:00:36 2008
@@ -36,8 +36,7 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  */
 
-public class AreaNPtg
-    extends AreaPtg
+public final class AreaNPtg extends AreaPtg
 {
   public final static short sid  = 0x2D;
 
@@ -50,23 +49,16 @@
     super(in);
   }
 
-  public void writeBytes(byte [] array, int offset) {
-    super.writeBytes(array,offset);
-    //this should be a warning...there doesn't seem to be any rationale to throwing an exception here...
-    //this excpeiton appears to break user defined named ranges...
-    //throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
-  }
-
   public String getAreaPtgName() {
     return "AreaNPtg";
   }
 
   public String toFormulaString(Workbook book)
   {
-    throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+    throw notImplemented();
   }
 
   public Object clone() {
-    throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+    throw notImplemented();
   }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/AreaNVPtg.java Tue May  6 09:00:36 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -16,19 +15,9 @@
    limitations under the License.
 ==================================================================== */
 
-/*
- * AreaPtg.java
- *
- * Created on November 17, 2001, 9:30 PM
- */
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.util.AreaReference;
-import org.apache.poi.hssf.util.CellReference;
 import org.apache.poi.ss.usermodel.Workbook;
 
 /**
@@ -36,10 +25,7 @@
  * @author  andy
  * @author Jason Height (jheight at chariot dot net dot au)
  */
-
-public class AreaNVPtg
-    extends AreaPtg
-{
+public final class AreaNVPtg extends AreaPtg {
   public final static short sid  = 0x4D;
 
   protected AreaNVPtg() {
@@ -51,20 +37,16 @@
     super(in);
   }
 
-  public void writeBytes(byte [] array, int offset) {
-    throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
-  }
-
   public String getAreaPtgName() {
     return "AreaNVPtg";
   }
 
   public String toFormulaString(Workbook book)
   {
-    throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+    throw notImplemented();
   }
 
   public Object clone() {
-    throw new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+    throw notImplemented();
   }
 }

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=653822&r1=653821&r2=653822&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 Tue May  6 09:00:36 2008
@@ -15,7 +15,6 @@
    limitations under the License.
 ==================================================================== */
 
-
 package org.apache.poi.hssf.record.formula;
 
 import org.apache.poi.util.LittleEndian;
@@ -32,10 +31,15 @@
  * @author  andy
  * @author Jason Height (jheight at chariot dot net dot au)
  */
+public class AreaPtg extends Ptg implements AreaI {
+    /**
+     * TODO - (May-2008) fix subclasses of AreaPtg 'AreaN~' which are used in shared formulas.
+     * see similar comment in ReferencePtg
+     */
+    protected final RuntimeException notImplemented() {
+          return new RuntimeException("Coding Error: This method should never be called. This ptg should be converted");
+    }
 
-public class AreaPtg
-    extends Ptg implements AreaI
-{
     public final static short sid  = 0x25;
     private final static int  SIZE = 9;
     /** zero based, unsigned 16 bit */

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtg.java Tue May  6 09:00:36 2008
@@ -17,22 +17,17 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.StringUtil;
-
-import org.apache.poi.hssf.util.CellReference;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.hssf.record.RecordFormatException;
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.record.SSTRecord;
 import org.apache.poi.hssf.record.UnicodeString;
+import org.apache.poi.hssf.record.constant.ConstantValueParser;
+import org.apache.poi.hssf.record.constant.ErrorConstant;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * ArrayPtg - handles arrays
  * 
- * The ArrayPtg is a little wierd, the size of the Ptg when parsing initially only
+ * The ArrayPtg is a little weird, the size of the Ptg when parsing initially only
  * includes the Ptg sid and the reserved bytes. The next Ptg in the expression then follows.
  * It is only after the "size" of all the Ptgs is met, that the ArrayPtg data is actually
  * held after this. So Ptg.createParsedExpression keeps track of the number of 
@@ -40,209 +35,160 @@
  *  
  * @author Jason Height (jheight at chariot dot net dot au)
  */
+public class ArrayPtg extends Ptg {
+	public static final byte sid  = 0x20;
 
-public class ArrayPtg extends Ptg
-{
-    public final static byte sid  = 0x20;
-    protected byte field_1_reserved;
-    protected byte field_2_reserved;
-    protected byte field_3_reserved;
-    protected byte field_4_reserved;
-    protected byte field_5_reserved;
-    protected byte field_6_reserved;
-    protected byte field_7_reserved;
-    
-    
-    protected short  token_1_columns;
-    protected short token_2_rows;
-    protected Object[][] token_3_arrayValues;
-
-    protected ArrayPtg() {
-      //Required for clone methods
-    }
-
-    public ArrayPtg(RecordInputStream in)
-    {
-    	field_1_reserved = in.readByte();
-    	field_2_reserved = in.readByte();
-    	field_3_reserved = in.readByte();
-    	field_4_reserved = in.readByte();
-    	field_5_reserved = in.readByte();
-    	field_6_reserved = in.readByte();
-    	field_7_reserved = in.readByte();
-    }
-    
-    /** 
-     * Read in the actual token (array) values. This occurs 
-     * AFTER the last Ptg in the expression.
-     * See page 304-305 of Excel97-2007BinaryFileFormat(xls)Specification.pdf
-     */
-    public void readTokenValues(RecordInputStream in) {    	
-        token_1_columns = (short)(0x00ff & in.readByte());
-        token_2_rows = in.readShort();
-        
-        //The token_1_columns and token_2_rows do not follow the documentation.
-        //The number of physical rows and columns is actually +1 of these values.
-        //Which is not explicitly documented.
-        token_1_columns++;
-        token_2_rows++;        
-        
-        token_3_arrayValues = new Object[token_1_columns][token_2_rows];
-        
-        for (int x=0;x<token_1_columns;x++) {
-			for (int y=0;y<token_2_rows;y++) {
-				byte grbit = in.readByte();
-				if (grbit == 0x01) {
-					token_3_arrayValues[x][y] = new Double(in.readDouble());
-				} else if (grbit == 0x02) {
-					//Ignore the doco, it is actually a unicode string with all the
-					//trimmings ie 16 bit size, option byte etc
-					token_3_arrayValues[x][y] = in.readUnicodeString();
-				} else throw new RecordFormatException("Unknown grbit '"+grbit+"' at " + x + "," + y + " with " + in.remaining() + " bytes left");
+	private static final int RESERVED_FIELD_LEN = 7;
+	// TODO - fix up field visibility and subclasses
+	protected byte[] field_1_reserved;
+	// data from these fields comes after the Ptg data of all tokens in current formula
+	protected short  token_1_columns;
+	protected short token_2_rows;
+	protected Object[] token_3_arrayValues;
+
+	protected ArrayPtg() {
+	  //Required for clone methods
+	}
+
+	public ArrayPtg(RecordInputStream in)
+	{
+		field_1_reserved = new byte[RESERVED_FIELD_LEN];
+		// TODO - add readFully method to RecordInputStream
+		for(int i=0; i< RESERVED_FIELD_LEN; i++) {
+			field_1_reserved[i] = in.readByte();
+		}
+	}
+	
+	/** 
+	 * Read in the actual token (array) values. This occurs 
+	 * AFTER the last Ptg in the expression.
+	 * See page 304-305 of Excel97-2007BinaryFileFormat(xls)Specification.pdf
+	 */
+	public void readTokenValues(RecordInputStream in) {
+		short nColumns = in.readUByte();
+		short nRows = in.readShort();
+		//The token_1_columns and token_2_rows do not follow the documentation.
+		//The number of physical rows and columns is actually +1 of these values.
+		//Which is not explicitly documented.
+		nColumns++;
+		nRows++;
+		
+		token_1_columns = nColumns;
+		token_2_rows = nRows;
+		
+		int totalCount = nRows * nColumns;
+		token_3_arrayValues = ConstantValueParser.parse(in, totalCount);
+	}
+
+	public String toString()
+	{
+		StringBuffer buffer = new StringBuffer("[ArrayPtg]\n");
+
+		buffer.append("columns = ").append(getColumnCount()).append("\n");
+		buffer.append("rows = ").append(getRowCount()).append("\n");
+		for (int x=0;x<getColumnCount();x++) {
+			for (int y=0;y<getRowCount();y++) {
+				Object o = token_3_arrayValues[getValueIndex(x, y)];
+	   			buffer.append("[").append(x).append("][").append(y).append("] = ").append(o).append("\n"); 
 			}
-        }
-    }
-
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer("[ArrayPtg]\n");
-
-        buffer.append("columns = ").append(getColumnCount()).append("\n");
-        buffer.append("rows = ").append(getRowCount()).append("\n");
-        for (int x=0;x<getColumnCount();x++) {
-        	for (int y=0;y<getRowCount();y++) {
-        		Object o = token_3_arrayValues[x][y];
-       			buffer.append("[").append(x).append("][").append(y).append("] = ").append(o).append("\n"); 
-        	}
-        }
-        return buffer.toString();
-    }
-
-    public void writeBytes(byte [] array, int offset)
-    {
-        array[offset++] = (byte) (sid + ptgClass);
-        array[offset++] = field_1_reserved;
-        array[offset++] = field_2_reserved;
-        array[offset++] = field_3_reserved;
-        array[offset++] = field_4_reserved;
-        array[offset++] = field_5_reserved;
-        array[offset++] = field_6_reserved;
-        array[offset++] = field_7_reserved;
-        
-    }
-    public int writeTokenValueBytes(byte [] array, int offset) {
-    	int pos = 0;
-    	array[pos + offset] = (byte)(token_1_columns-1);
-        pos++;
-        LittleEndian.putShort(array, pos+offset, (short)(token_2_rows-1));
-        pos += 2;
-        for (int x=0;x<getColumnCount();x++) {
-        	for (int y=0;y<getRowCount();y++) {
-        		Object o = token_3_arrayValues[x][y];
-        		if (o instanceof Double) {
-        			array[pos+offset] = 0x01;
-        			pos++;
-        			LittleEndian.putDouble(array, pos+offset, ((Double)o).doubleValue());
-        			pos+=8;
-        		} else if (o instanceof UnicodeString) {
-        			array[pos+offset] = 0x02;
-        			pos++;        			
-        			UnicodeString s = (UnicodeString)o;
-        			//JMH TBD Handle string continuation. Id do it now but its 4am.
-        	        UnicodeString.UnicodeRecordStats stats = new UnicodeString.UnicodeRecordStats();
-        	        s.serialize(stats, pos + offset, array);
-        	        pos += stats.recordSize; 
-        		} else throw new RuntimeException("Coding error");
-        	}
-        }
-        return pos;
-    }
-
-    public void setRowCount(short row)
-    {
-        token_2_rows = row;
-    }
-
-    public short getRowCount()
-    {
-        return token_2_rows;
-    }
-
-    public void setColumnCount(short col)
-    {
-        token_1_columns = (byte)col;
-    }
-
-    public short getColumnCount()
-    {
-        return token_1_columns;
-    }
-
-    /** This size includes the size of the array Ptg plus the Array Ptg Token value size*/
-    public int getSize()
-    {
-    	int size = 1+7+1+2;
-        for (int x=0;x<getColumnCount();x++) {
-        	for (int y=0;y<getRowCount();y++) {
-        		Object o = token_3_arrayValues[x][y];
-        		if (o instanceof UnicodeString) {
-        			size++;
-        	        UnicodeString.UnicodeRecordStats rs = new UnicodeString.UnicodeRecordStats();
-                    ((UnicodeString)o).getRecordSize(rs);        			
-        			size += rs.recordSize;
-        		} else if (o instanceof Double) {
-        			size += 9;
-        		}
-        	}
-        }
-        return size;
-    }
-
-    public String toFormulaString(Workbook book)
-    {
-    	StringBuffer b = new StringBuffer();
-    	b.append("{");
-        for (int x=0;x<getColumnCount();x++) {
-          	for (int y=0;y<getRowCount();y++) {
-          		Object o = token_3_arrayValues[x][y];
-        		if (o instanceof String) {
-        			b.append((String)o);
-        		} else if (o instanceof Double) {
-        			b.append(((Double)o).doubleValue());
-        		}
-        		if (y != getRowCount())
-        			b.append(",");
-          	}
-          	if (x != getColumnCount())
-          		b.append(";");
-          }
-        b.append("}");
-        return b.toString();
-    }
-    
-    public byte getDefaultOperandClass() {
-        return Ptg.CLASS_ARRAY;
-    }
-    
-    public Object clone() {
-      ArrayPtg ptg = new ArrayPtg();
-      ptg.field_1_reserved = field_1_reserved;
-      ptg.field_2_reserved = field_2_reserved;
-      ptg.field_3_reserved = field_3_reserved;
-      ptg.field_4_reserved = field_4_reserved;
-      ptg.field_5_reserved = field_5_reserved;
-      ptg.field_6_reserved = field_6_reserved;
-      ptg.field_7_reserved = field_7_reserved;
-      
-      ptg.token_1_columns = token_1_columns;
-      ptg.token_2_rows = token_2_rows;
-      ptg.token_3_arrayValues = new Object[getColumnCount()][getRowCount()];
-      for (int x=0;x<getColumnCount();x++) {
-      	for (int y=0;y<getRowCount();y++) {
-      		ptg.token_3_arrayValues[x][y] = token_3_arrayValues[x][y];
-      	}
-      }      
-      ptg.setClass(ptgClass);
-      return ptg;
-    }
+		}
+		return buffer.toString();
+	}
+
+	/* package */ int getValueIndex(int colIx, int rowIx) {
+		if(colIx < 0 || colIx >= token_1_columns) {
+			throw new IllegalArgumentException("Specified colIx (" + colIx 
+					+ ") is outside the allowed range (0.." + (token_1_columns-1) + ")");
+		}
+		if(rowIx < 0 || rowIx >= token_2_rows) {
+			throw new IllegalArgumentException("Specified rowIx (" + rowIx 
+					+ ") is outside the allowed range (0.." + (token_2_rows-1) + ")");
+		}
+		return rowIx * token_1_columns + colIx;
+	}
+
+	public void writeBytes(byte[] data, int offset) {
+		
+		LittleEndian.putByte(data, offset + 0, sid + ptgClass);
+		System.arraycopy(field_1_reserved, 0, data, offset+1, RESERVED_FIELD_LEN);
+	}
+
+	public int writeTokenValueBytes(byte[] data, int offset) {
+
+		LittleEndian.putByte(data,  offset + 0, token_1_columns-1);
+		LittleEndian.putShort(data, offset + 1, (short)(token_2_rows-1));
+		ConstantValueParser.encode(data, offset + 3, token_3_arrayValues);
+		return 3 + ConstantValueParser.getEncodedSize(token_3_arrayValues);
+	}
+
+	public short getRowCount() {
+		return token_2_rows;
+	}
+
+	public short getColumnCount() {
+		return token_1_columns;
+	}
+
+	/** This size includes the size of the array Ptg plus the Array Ptg Token value size*/
+	public int getSize()
+	{
+		int size = 1+7+1+2;
+		size += ConstantValueParser.getEncodedSize(token_3_arrayValues);
+		return size;
+	}
+
+	public String toFormulaString(Workbook book)
+	{
+		StringBuffer b = new StringBuffer();
+		b.append("{");
+		for (int x=0;x<getColumnCount();x++) {
+		  	if (x > 0) {
+				b.append(";");
+			}
+		  	for (int y=0;y<getRowCount();y++) {
+				if (y > 0) {
+					b.append(",");
+				}
+		  		Object o = token_3_arrayValues[getValueIndex(x, y)];
+		  		b.append(getConstantText(o));
+		  	}
+		  }
+		b.append("}");
+		return b.toString();
+	}
+	
+	private static String getConstantText(Object o) {
+
+		if (o == null) {
+			return ""; // TODO - how is 'empty value' represented in formulas?
+		}
+		if (o instanceof UnicodeString) {
+			return "\"" + ((UnicodeString)o).getString() + "\"";
+		}
+		if (o instanceof Double) {
+			return ((Double)o).toString();
+		}
+		if (o instanceof Boolean) {
+			((Boolean)o).toString();
+		}
+		if (o instanceof ErrorConstant) {
+			return ((ErrorConstant)o).getText();
+		}
+		throw new IllegalArgumentException("Unexpected constant class (" + o.getClass().getName() + ")");
+	}
+	
+	public byte getDefaultOperandClass() {
+		return Ptg.CLASS_ARRAY;
+	}
+	
+	public Object clone() {
+	  ArrayPtg ptg = new ArrayPtg();
+	  ptg.field_1_reserved = (byte[]) field_1_reserved.clone();
+	  
+	  ptg.token_1_columns = token_1_columns;
+	  ptg.token_2_rows = token_2_rows;
+	  ptg.token_3_arrayValues = (Object[]) token_3_arrayValues.clone();
+	  ptg.setClass(ptgClass);
+	  return ptg;
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgA.java Tue May  6 09:00:36 2008
@@ -17,56 +17,31 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.StringUtil;
-
-import org.apache.poi.hssf.util.CellReference;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.hssf.record.RecordFormatException;
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.record.SSTRecord;
-import org.apache.poi.hssf.record.UnicodeString;
 
 /**
  * ArrayPtgA - handles arrays
  *  
  * @author Jason Height (jheight at chariot dot net dot au)
  */
-
-public class ArrayPtgA extends ArrayPtg
-{
+public final class ArrayPtgA extends ArrayPtg {
     public final static byte sid  = 0x60;
 
-    protected ArrayPtgA() {
-    	super();
+    private ArrayPtgA() {
       //Required for clone methods
     }
 
-    public ArrayPtgA(RecordInputStream in)
-    {
+    public ArrayPtgA(RecordInputStream in) {
     	super(in);
     }
         
     public Object clone() {
       ArrayPtgA ptg = new ArrayPtgA();
-      ptg.field_1_reserved = field_1_reserved;
-      ptg.field_2_reserved = field_2_reserved;
-      ptg.field_3_reserved = field_3_reserved;
-      ptg.field_4_reserved = field_4_reserved;
-      ptg.field_5_reserved = field_5_reserved;
-      ptg.field_6_reserved = field_6_reserved;
-      ptg.field_7_reserved = field_7_reserved;
+      ptg.field_1_reserved = (byte[]) field_1_reserved.clone();
       
       ptg.token_1_columns = token_1_columns;
       ptg.token_2_rows = token_2_rows;
-      ptg.token_3_arrayValues = new Object[getColumnCount()][getRowCount()];
-      for (int x=0;x<getColumnCount();x++) {
-      	for (int y=0;y<getRowCount();y++) {
-      		ptg.token_3_arrayValues[x][y] = token_3_arrayValues[x][y];
-      	}
-      }      
+      ptg.token_3_arrayValues = (Object[]) token_3_arrayValues.clone();
       ptg.setClass(ptgClass);
       return ptg;
     }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/ArrayPtgV.java Tue May  6 09:00:36 2008
@@ -17,22 +17,12 @@
 
 package org.apache.poi.hssf.record.formula;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.StringUtil;
-
-import org.apache.poi.hssf.util.CellReference;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.hssf.record.RecordFormatException;
 import org.apache.poi.hssf.record.RecordInputStream;
-import org.apache.poi.hssf.record.SSTRecord;
-import org.apache.poi.hssf.record.UnicodeString;
 
 /**
  * ArrayPtg - handles arrays
  * 
- * The ArrayPtg is a little wierd, the size of the Ptg when parsing initially only
+ * The ArrayPtg is a little weird, the size of the Ptg when parsing initially only
  * includes the Ptg sid and the reserved bytes. The next Ptg in the expression then follows.
  * It is only after the "size" of all the Ptgs is met, that the ArrayPtg data is actually
  * held after this. So Ptg.createParsedExpression keeps track of the number of 
@@ -40,38 +30,24 @@
  *  
  * @author Jason Height (jheight at chariot dot net dot au)
  */
-
-public class ArrayPtgV extends ArrayPtg
-{
+public final class ArrayPtgV extends ArrayPtg {
     public final static byte sid  = 0x40;
 
-    protected ArrayPtgV() {
+    private ArrayPtgV() {
       //Required for clone methods
     }
 
-    public ArrayPtgV(RecordInputStream in)
-    {
+    public ArrayPtgV(RecordInputStream in) {
     	super(in);
     }
     
     public Object clone() {
       ArrayPtgV ptg = new ArrayPtgV();
-      ptg.field_1_reserved = field_1_reserved;
-      ptg.field_2_reserved = field_2_reserved;
-      ptg.field_3_reserved = field_3_reserved;
-      ptg.field_4_reserved = field_4_reserved;
-      ptg.field_5_reserved = field_5_reserved;
-      ptg.field_6_reserved = field_6_reserved;
-      ptg.field_7_reserved = field_7_reserved;
+      ptg.field_1_reserved = (byte[]) field_1_reserved.clone();
       
       ptg.token_1_columns = token_1_columns;
       ptg.token_2_rows = token_2_rows;
-      ptg.token_3_arrayValues = new Object[getColumnCount()][getRowCount()];
-      for (int x=0;x<getColumnCount();x++) {
-      	for (int y=0;y<getRowCount();y++) {
-      		ptg.token_3_arrayValues[x][y] = token_3_arrayValues[x][y];
-      	}
-      }      
+      ptg.token_3_arrayValues = (Object[]) token_3_arrayValues.clone();
       ptg.setClass(ptgClass);
       return ptg;
     }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncPtg.java Tue May  6 09:00:36 2008
@@ -57,10 +57,12 @@
         }
         numParams = fm.getMinParams();
     }
-    public FuncPtg(int functionIndex, int numberOfParameters) {
+    public FuncPtg(int functionIndex) {
         field_2_fnc_index = (short) functionIndex;
-        numParams = numberOfParameters;
-        paramClass = new byte[] { Ptg.CLASS_VALUE, }; // TODO
+        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByIndex(functionIndex);
+        numParams = fm.getMinParams(); // same as max since these are not var-arg funcs
+        returnClass = fm.getReturnClassCode();
+        paramClass = fm.getParameterClassCodes();
     }
 
     public void writeBytes(byte[] array, int offset) {

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java?rev=653822&r1=653821&r2=653822&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java Tue May  6 09:00:36 2008
@@ -54,8 +54,8 @@
             returnClass = Ptg.CLASS_VALUE;
             paramClass = new byte[] {Ptg.CLASS_VALUE};
         } else {
-            returnClass = Ptg.CLASS_VALUE;
-            paramClass = new byte[] {Ptg.CLASS_VALUE};
+            returnClass = fm.getReturnClassCode();
+            paramClass = fm.getParameterClassCodes();
         }
     }
 



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