poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r674296 - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/examples/src/org/apache/poi/hssf/eventusermodel/examples/ src/java/org/apache/poi/hssf/eventusermodel/ src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hss...
Date Sun, 06 Jul 2008 13:10:10 GMT
Author: nick
Date: Sun Jul  6 06:10:09 2008
New Revision: 674296

URL: http://svn.apache.org/viewvc?rev=674296&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-651991,651993-652284,652286-652287,652289,652291,652293-652297,652299-652328,652330-652425,652427-652445,652447-652560,652562-652933,652935,652937-652993,652995-653116,653118-653124,653126-653483,653487-653519,653522-653550,653552-653607,653609-653667,653669-653674,653676-653814,653817-653830,653832-653891,653893-653944,653946-654055,654057-654355,654357-654365,654367-654648,654651-655215,655217-655277,655279-655281,655283-655911,655913-656212,656214,656216-656251,656253-656698,656700-656756,656758-656892,656894-657135,657137-657165,657168-657179,657181-657354,657356-657357,657359-657701,657703-657874,657876-658032,658034-658284,658286,658288-658301,658303-658307,658309-658321,658323-658335,658337-658348,658351,658353-658832,658834-658983,658985,658987-659066,659068-659402,659404-659428,659430-659451,659453-659454,659456-659461,659463-659477,659479-659524,659526-65
 9571,659574,659576-660255,660257-660262,660264-660279,660281-660343,660345-660473,660475-660827,660829-660833,660835-660888,660890-663321,663323-663435,663437-663764,663766-663854,663856-664219,664221-664489,664494-664514,664516-668013,668015-668142,668144-668152,668154,668156-668256,668258,668260-669139,669141-669455,669457-669657,669659-669808,669810-670189,670191-674287 via svnmerge from 
https://svn.apache.org/repos/asf/poi/trunk

........
  r671322 | nick | 2008-06-24 20:53:53 +0100 (Tue, 24 Jun 2008) | 1 line
  
  Make a start on being able to process formulas in the eventusermodel code
........
  r672230 | nick | 2008-06-27 11:12:11 +0100 (Fri, 27 Jun 2008) | 1 line
  
  Add MethodNotFound exceptions to the faq
........
  r672550 | nick | 2008-06-28 18:04:09 +0100 (Sat, 28 Jun 2008) | 1 line
  
  Finish the EventWorkbookBuilder, now does sheet references in formulas properly
........
  r672553 | nick | 2008-06-28 18:12:38 +0100 (Sat, 28 Jun 2008) | 1 line
  
  Update changelog about EventWorkbookBuilder, and tweak XLS2CSVmra to use it if formulas required
........
  r672562 | nick | 2008-06-28 19:21:21 +0100 (Sat, 28 Jun 2008) | 1 line
  
  Avoid spurious missing lines with the MissingRecordAware event code, and odd files that contain RowRecords in the middle of the cell Records.
........
  r672567 | nick | 2008-06-28 19:48:35 +0100 (Sat, 28 Jun 2008) | 1 line
  
  Patch from dnapoletano from bug #45175 - Support for variable length operands in org.apache.poi.hwpf.sprm.SprmOperation
........
  r672569 | nick | 2008-06-28 19:54:02 +0100 (Sat, 28 Jun 2008) | 1 line
  
  Patch from N. Hira from bug #45001 - Further fix for HWPF Range.delete() and unicode characters
........
  r672570 | nick | 2008-06-28 19:58:23 +0100 (Sat, 28 Jun 2008) | 1 line
  
  Patch from N.Hira from bug #45252 - Improvement for HWPF Range.replaceText()
........
  r673050 | yegor | 2008-07-01 11:32:29 +0100 (Tue, 01 Jul 2008) | 1 line
  
  updated status of the latest release, 3.1-FINAL
........
  r673853 | josh | 2008-07-03 23:20:18 +0100 (Thu, 03 Jul 2008) | 1 line
  
  Fix for bug 45334 - formula parser needs to handle dots in identifiers
........
  r673863 | josh | 2008-07-04 00:09:08 +0100 (Fri, 04 Jul 2008) | 1 line
  
  Fix for bug 45334 - added impl for ERROR.TYPE()
........
  r673987 | nick | 2008-07-04 10:58:21 +0100 (Fri, 04 Jul 2008) | 1 line
  
  Fix bug #45336 - Fix HSSFColor.getTripletHash()
........
  r673997 | nick | 2008-07-04 11:46:59 +0100 (Fri, 04 Jul 2008) | 1 line
  
  Fix bug #45338 - Fix HSSFWorkbook to give you the same HSSFFont every time, and then fix it to find newly added fonts
........

Added:
    poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java
      - copied unchanged from r673997, poi/trunk/src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeDelete.doc
      - copied unchanged from r673997, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/testRangeDelete.doc
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java
      - copied unchanged from r673997, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeDelete.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/3dFormulas.xls
      - copied unchanged from r673997, poi/trunk/src/testcases/org/apache/poi/hssf/data/3dFormulas.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/MRExtraLines.xls
      - copied unchanged from r673997, poi/trunk/src/testcases/org/apache/poi/hssf/data/MRExtraLines.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestEventWorkbookBuilder.java
      - copied unchanged from r673997, poi/trunk/src/testcases/org/apache/poi/hssf/eventusermodel/TestEventWorkbookBuilder.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java
      - copied unchanged from r673997, poi/trunk/src/testcases/org/apache/poi/hssf/util/TestHSSFColor.java
Modified:
    poi/branches/ooxml/   (props changed)
    poi/branches/ooxml/src/documentation/content/xdocs/changes.xml
    poi/branches/ooxml/src/documentation/content/xdocs/faq.xml
    poi/branches/ooxml/src/documentation/content/xdocs/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/util/HSSFColor.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/FormulaEvalTestData.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/model/TestFormulaParser.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Jul  6 06:10:09 2008
@@ -1 +1 @@
-/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-671000
+/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642562,642564-642566,642568-642574,642576-642736,642739-650914,650916-674287

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=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Sun Jul  6 06:10:09 2008
@@ -36,7 +36,7 @@
     </devs>
 
 		<!-- Don't forget to update status.xml too! -->
-        <release version="3.5.1-alpha1" date="2008-04-??">
+        <release version="3.5.1-beta1" date="2008-07-11">
            <action dev="POI-DEVELOPERS" type="add">45018 - Support for fetching embeded documents from within an OOXML file</action>
            <action dev="POI-DEVELOPERS" type="add">Port support for setting a policy on missing / blank cells when fetching, to XSSF too</action>
            <action dev="POI-DEVELOPERS" type="add">Common text extraction factory, which returns the correct POITextExtractor for the supplied data</action>
@@ -45,8 +45,15 @@
            <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.2-alpha1" date="2008-??-??">
-          <action dev="POI-DEVELOPERS" type="add"><!-- to keep forrest dtd quiet--></action>
+        <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45338 - Fix HSSFWorkbook to give you the same HSSFFont every time, and then fix it to find newly added fonts</action>
+           <action dev="POI-DEVELOPERS" type="fix">45336 - Fix HSSFColor.getTripletHash()</action>
+           <action dev="POI-DEVELOPERS" type="fix">45334 - Fixed formula parser to handle dots in identifiers</action>
+           <action dev="POI-DEVELOPERS" type="fix">45252 - Improvement for HWPF Range.replaceText()</action>
+           <action dev="POI-DEVELOPERS" type="fix">45001 - Further fix for HWPF Range.delete() and unicode characters</action>
+           <action dev="POI-DEVELOPERS" type="add">45175 - Support for variable length operands in org.apache.poi.hwpf.sprm.SprmOperation</action>
+           <action dev="POI-DEVELOPERS" type="fix">Avoid spurious missing lines with the MissingRecordAware event code, and odd files that contain RowRecords in the middle of the cell Records.</action>
+           <action dev="POI-DEVELOPERS" type="add">Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder</action>
         </release>
         <release version="3.1-final" date="2008-06-29">
            <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d</action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/faq.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/faq.xml?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/faq.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/faq.xml Sun Jul  6 06:10:09 2008
@@ -22,6 +22,36 @@
 <faqs title="Frequently Asked Questions">
     <faq>
         <question>
+          My code uses some new HSSF feature, compiles fine but fails when live with a "MethodNotFoundException"
+        </question>
+		<answer>
+		 <p>You almost certainly have an older version of POI earlier 
+		 on your classpath. Quite a few runtimes and other packages 
+		 will ship an older version of POI, so this is an easy problem
+		 to hit without realising.</p>
+		 <p>The best way to identify the offending earlier jar file is
+		 with a few lines of java. These will load one of the core POI
+		 classes, and report where it came from.</p>
+		 <source>
+ClassLoader classloader = org.apache.poi.poifs.filesystem.POIFSFileSystem.class.getClassLoader();
+URL res = classloader.getResource("org/apache/poi/poifs/filesystem/POIFSFileSystem.class">
+String path = res.getPath();
+System.out.println("Core POI came from " + path);
+		 </source>
+		</answer>
+	</faq>
+    <faq>
+        <question>
+          My code uses the scratchpad, compiles fine but fails to run with a "MethodNotFoundException"
+        </question>
+		<answer>
+		 <p>You almost certainly have an older version earlier on your
+		 classpath. See the answer to the similar question above for
+		 how to track this down.</p>
+		</answer>
+	</faq>
+    <faq>
+        <question>
           Why is reading a simple sheet taking so long?
         </question>
         <answer>

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=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/index.xml Sun Jul  6 06:10:09 2008
@@ -31,35 +31,24 @@
   </header>
 
   <body>
-    <section><title>Office Open XML Support</title>
+    <section><title>POI 3.5.1 beta 1, and Office Open XML Support (2008-07-11)</title>
       <p>We are currently working to support the new Office Open XML
        file formats, such as XLSX and PPTX, which were introduced in
        Office 2007.</p>
-      <p>Support for these is currently only available in an svn branch,
-       but we hope to have a full release including it by the summer.
-       People interested should follow the
+      <p>Development for this is in a svn branch, but we are please to
+       announce our first preview release containing this support.
+       Users interested in the OOXML support should download the
+       <link href="http://www.apache.org/dyn/closer.cgi/poi/dev/">POI 3.5.1 beta 1</link>
+       the source and binaries from their
+       <link href="http://www.apache.org/dyn/closer.cgi/poi/dev/">local mirror</link>.
+       People interested should also follow the
        <link href="mailinglists.html">dev list</link> to track progress.</p>
     </section>
-    <section><title>POI 3.1-BETA2 Released (2008-05-28)</title>
+    <section><title>POI 3.1-FINAL Released (2008-06-29)</title>
       <p>
-        The POI team is pleased to announce the release of 3.1 BETA2 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-beta2".
-      </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 
+        The POI team is pleased to announce the release of 3.1 FINAL, the latest release of Apache POI.
+        There have been many important bug fixes since the 3.0.2 release and a lot of new features. 
+       </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/release/">download</link>
 		the source and binaries from your
@@ -67,13 +56,8 @@
       </p>
       <p>
         The release is also available from the central Maven repository 
-        under Group ID "org.apache.poi" and Version "3.0.2-FINAL".
+        under Group ID "org.apache.poi" and Version "3.1-FINAL".
       </p>  
-      <p>We would also like to confirm that verions 3.0 and 3.0.1 of Apache 
-		POI do
-		<em>not</em> contain any viruses. Users of broken virus checkers
-		which do detect a 94 byte file, sci_cec.db, as containing one are
-		advised to contact their vendor for a fix.</p>
     </section>
 
     <section><title>Purpose</title>

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=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Sun Jul  6 06:10:09 2008
@@ -33,7 +33,7 @@
 
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
-        <release version="3.5.1-alpha1" date="2008-04-??">
+        <release version="3.5.1-beta1" date="2008-07-11">
            <action dev="POI-DEVELOPERS" type="add">45018 - Support for fetching embeded documents from within an OOXML file</action>
            <action dev="POI-DEVELOPERS" type="add">Port support for setting a policy on missing / blank cells when fetching, to XSSF too</action>
            <action dev="POI-DEVELOPERS" type="add">Common text extraction factory, which returns the correct POITextExtractor for the supplied data</action>
@@ -42,8 +42,15 @@
            <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.2-alpha1" date="2008-??-??">
-          <action dev="POI-DEVELOPERS" type="add"><!-- to keep forrest dtd quiet--></action>
+        <release version="3.1.1-alpha1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">45338 - Fix HSSFWorkbook to give you the same HSSFFont every time, and then fix it to find newly added fonts</action>
+           <action dev="POI-DEVELOPERS" type="fix">45336 - Fix HSSFColor.getTripletHash()</action>
+           <action dev="POI-DEVELOPERS" type="fix">45334 - Fixed formula parser to handle dots in identifiers</action>
+           <action dev="POI-DEVELOPERS" type="fix">45252 - Improvement for HWPF Range.replaceText()</action>
+           <action dev="POI-DEVELOPERS" type="fix">45001 - Further fix for HWPF Range.delete() and unicode characters</action>
+           <action dev="POI-DEVELOPERS" type="add">45175 - Support for variable length operands in org.apache.poi.hwpf.sprm.SprmOperation</action>
+           <action dev="POI-DEVELOPERS" type="fix">Avoid spurious missing lines with the MissingRecordAware event code, and odd files that contain RowRecords in the middle of the cell Records.</action>
+           <action dev="POI-DEVELOPERS" type="add">Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder</action>
         </release>
         <release version="3.1-final" date="2008-06-29">
            <action dev="POI-DEVELOPERS" type="fix">30978 - Fixed re-serialization of tRefErr3d and tAreaErr3d</action>

Modified: poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java (original)
+++ poi/branches/ooxml/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java Sun Jul  6 06:10:09 2008
@@ -30,9 +30,11 @@
 import org.apache.poi.hssf.eventusermodel.HSSFListener;
 import org.apache.poi.hssf.eventusermodel.HSSFRequest;
 import org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener;
+import org.apache.poi.hssf.eventusermodel.EventWorkbookBuilder.SheetRecordCollectingListener;
 import org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord;
 import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord;
 import org.apache.poi.hssf.model.FormulaParser;
+import org.apache.poi.hssf.record.BOFRecord;
 import org.apache.poi.hssf.record.BlankRecord;
 import org.apache.poi.hssf.record.BoolErrRecord;
 import org.apache.poi.hssf.record.CellValueRecordInterface;
@@ -46,6 +48,7 @@
 import org.apache.poi.hssf.record.SSTRecord;
 import org.apache.poi.hssf.record.StringRecord;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.poifs.filesystem.POIFSFileSystem;
 
 /**
@@ -64,6 +67,10 @@
 	/** Should we output the formula, or the value it has? */
 	private boolean outputFormulaValues = true;
 	
+	/** For parsing Formulas */
+	private SheetRecordCollectingListener workbookBuildingListener;
+	private HSSFWorkbook stubWorkbook;
+	
 	// Records we pick up as we process
 	private SSTRecord sstRecord;
 	private FormatTrackingHSSFListener formatListener;
@@ -108,7 +115,13 @@
 		
 		HSSFEventFactory factory = new HSSFEventFactory();
 		HSSFRequest request = new HSSFRequest();
-		request.addListenerForAllRecords(formatListener);
+		
+		if(outputFormulaValues) {
+			request.addListenerForAllRecords(formatListener);
+		} else {
+			workbookBuildingListener = new SheetRecordCollectingListener(formatListener);
+			request.addListenerForAllRecords(workbookBuildingListener);
+		}
 		
 		factory.processWorkbookEvents(request, fs);
 	}
@@ -124,6 +137,16 @@
 		
 		switch (record.getSid())
         {
+		case BOFRecord.sid:
+			BOFRecord br = (BOFRecord)record;
+			if(br.getType() == BOFRecord.TYPE_WORKSHEET) {
+				// Create sub workbook if required
+				if(workbookBuildingListener != null && stubWorkbook == null) {
+					stubWorkbook = workbookBuildingListener.getStubHSSFWorkbook();
+				}
+			}
+			break;
+		
 		case SSTRecord.sid:
 			sstRecord = (SSTRecord) record;
 			break;
@@ -161,7 +184,7 @@
         		}
         	} else {
         		thisStr = '"' + 
-        			FormulaParser.toFormulaString(null, frec.getParsedExpression()) + '"';
+        			FormulaParser.toFormulaString(stubWorkbook, frec.getParsedExpression()) + '"';
         	}
             break;
         case StringRecord.sid:

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/eventusermodel/MissingRecordAwareHSSFListener.java Sun Jul  6 06:10:09 2008
@@ -46,8 +46,14 @@
  */
 public class MissingRecordAwareHSSFListener implements HSSFListener {
 	private HSSFListener childListener;
-	private int lastSeenRow = -1;
-	private int lastSeenColumn = -1;
+	
+	// Need to have different counters for cell rows and
+	//  row rows, as you sometimes get a RowRecord in the
+	//  middle of some cells, and that'd break everything
+	private int lastRowRow = -1;
+	
+	private int lastCellRow = -1;
+	private int lastCellColumn = -1;
 	
 	/**
 	 * Constructs a new MissingRecordAwareHSSFListener, which
@@ -71,14 +77,16 @@
                 if (bof.getType() == bof.TYPE_WORKBOOK)
                 {
                 	// Reset the row and column counts - new workbook
-                	lastSeenRow = -1;
-                	lastSeenColumn = -1;
+                	lastRowRow = -1;
+                	lastCellRow = -1;
+                	lastCellColumn = -1;
                     //System.out.println("Encountered workbook");
                 } else if (bof.getType() == bof.TYPE_WORKSHEET)
                 {
                 	// Reset the row and column counts - new sheet
-                	lastSeenRow = -1;
-                	lastSeenColumn = -1;
+                	lastRowRow = -1;
+                	lastCellRow = -1;
+                	lastCellColumn = -1;
                     //System.out.println("Encountered sheet reference");
                 }
                 break;
@@ -92,15 +100,15 @@
                 //        + rowrec.getFirstCol() + " last column at " + rowrec.getLastCol());
                 
                 // If there's a jump in rows, fire off missing row records
-                if(lastSeenRow+1 < rowrec.getRowNumber()) {
-                	for(int i=(lastSeenRow+1); i<rowrec.getRowNumber(); i++) {
+                if(lastRowRow+1 < rowrec.getRowNumber()) {
+                	for(int i=(lastRowRow+1); i<rowrec.getRowNumber(); i++) {
                 		MissingRowDummyRecord dr = new MissingRowDummyRecord(i);
                 		childListener.processRecord(dr);
                 	}
                 }
                 
                 // Record this as the last row we saw
-                lastSeenRow = rowrec.getRowNumber();
+                lastRowRow = rowrec.getRowNumber();
                 break;
                 
                 
@@ -157,45 +165,49 @@
             	break;
         }
 		
-		// Do we need to fire dummy end-of-row records?
-		if(thisRow != lastSeenRow) {
-			for(int i=lastSeenRow; i<thisRow; i++) {
+		// If we're on cells, and this cell isn't in the same
+		//  row as the last one, then fire the 
+		//  dummy end-of-row records?
+		if(thisRow != lastCellRow && lastCellRow > -1) {
+			for(int i=lastCellRow; i<thisRow; i++) {
 				int cols = -1;
-				if(i == lastSeenRow) {
-					cols = lastSeenColumn;
+				if(i == lastCellRow) {
+					cols = lastCellColumn;
 				}
 				LastCellOfRowDummyRecord r = new LastCellOfRowDummyRecord(i, cols);
 				childListener.processRecord(r);
 			}
 		}
-		// If we've finished with the columns, then fire the final
-		//  dummy end-of-row record
-		if(lastSeenRow != -1 && lastSeenColumn != -1 && thisRow == -1) {
-			LastCellOfRowDummyRecord r = new LastCellOfRowDummyRecord(lastSeenRow, lastSeenColumn);
+		
+		// If we've just finished with the cells, then fire the
+		//  final dummy end-of-row record
+		if(lastCellRow != -1 && lastCellColumn != -1 && thisRow == -1) {
+			LastCellOfRowDummyRecord r = new LastCellOfRowDummyRecord(lastCellRow, lastCellColumn);
 			childListener.processRecord(r);
 			
-			lastSeenRow = -1;
-			lastSeenColumn = -1;
+			lastCellRow = -1;
+			lastCellColumn = -1;
 		}
 		
 		// If we've moved onto a new row, the ensure we re-set
 		//  the column counter
-		if(thisRow != lastSeenRow) {
-			lastSeenColumn = -1;
+		if(thisRow != lastCellRow) {
+			lastCellColumn = -1;
 		}
 		
-		// Do we need to fire dummy cell records?
-		if(lastSeenColumn != (thisColumn-1)) {
-			for(int i=lastSeenColumn+1; i<thisColumn; i++) {
+		// If there's a gap in the cells, then fire
+		//  the dummy cell records?
+		if(lastCellColumn != (thisColumn-1)) {
+			for(int i=lastCellColumn+1; i<thisColumn; i++) {
 				MissingCellDummyRecord r = new MissingCellDummyRecord(thisRow, i);
 				childListener.processRecord(r);
 			}
 		}
 		
-		// Update cell and row counts if doing cells
+		// Update cell and row counts as needed
 		if(thisColumn != -1) {
-			lastSeenRow = thisRow;
-			lastSeenColumn = thisColumn;
+			lastCellColumn = thisColumn;
+			lastCellRow = thisRow;
 		}
 		
 		childListener.processRecord(record);

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=674296&r1=674295&r2=674296&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 Sun Jul  6 06:10:09 2008
@@ -22,11 +22,13 @@
 import java.util.Stack;
 import java.util.regex.Pattern;
 
-//import PTG's .. since we need everything, import *
+//import PTGs .. since we need everything, import *
 import org.apache.poi.hssf.record.formula.*;
 import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
 import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
 import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.hssf.util.AreaReference;
+import org.apache.poi.hssf.util.CellReference;
 
 /**
  * This class parses a formula string into a List of tokens in RPN order.
@@ -178,8 +180,14 @@
         GetChar();
     }
 
-    /** Get an Identifier */
-    private String GetName() {
+    /**
+     * Parses a sheet name, named range name, or simple cell reference.<br/>
+     * Note - identifiers in Excel can contain dots, so this method may return a String
+     * which may need to be converted to an area reference.  For example, this method 
+     * may return a value like "A1..B2", in which case the caller must convert it to 
+     * an area reference like "A1:B2"
+     */
+    private String parseIdentifier() {
         StringBuffer Token = new StringBuffer();
         if (!IsAlpha(look) && look != '\'') {
             throw expected("Name");
@@ -201,7 +209,9 @@
         }
         else
         {
-            while (IsAlNum(look)) {
+            // allow for any sequence of dots and identifier chars
+            // special case of two consecutive dots is best treated in the calling code
+            while (IsAlNum(look) || look == '.') {
                 Token.append(look);
                 GetChar();
             }
@@ -220,15 +230,22 @@
         return value.length() == 0 ? null : value.toString();
     }
 
-    private ParseNode parseFunctionOrIdentifier() {
-        String name = GetName();
+    private ParseNode parseFunctionReferenceOrName() {
+        String name = parseIdentifier();
         if (look == '('){
             //This is a function
             return function(name);
         }
-        return new ParseNode(parseIdentifier(name));
+        return new ParseNode(parseNameOrReference(name));
     }
-    private Ptg parseIdentifier(String name) {
+
+    private Ptg parseNameOrReference(String name) {
+        
+        AreaReference areaRef = parseArea(name);
+        if (areaRef != null) {
+            // will happen if dots are used instead of colon
+            return new AreaPtg(areaRef.formatAsString());
+        }
 
         if (look == ':' || look == '.') { // this is a AreaReference
             GetChar();
@@ -238,23 +255,28 @@
             }
 
             String first = name;
-            String second = GetName();
+            String second = parseIdentifier();
             return new AreaPtg(first+":"+second);
         }
 
         if (look == '!') {
             Match('!');
             String sheetName = name;
-            String first = GetName();
+            String first = parseIdentifier();
             short externIdx = (short)book.getExternalSheetIndex(book.getSheetIndex(sheetName));
+            areaRef = parseArea(name);
+            if (areaRef != null) {
+                // will happen if dots are used instead of colon
+                return new Area3DPtg(areaRef.formatAsString(), externIdx);
+            }
             if (look == ':') {
                 Match(':');
-                String second=GetName();
+                String second=parseIdentifier();
                 if (look == '!') {
                     //The sheet name was included in both of the areas. Only really
                     //need it once
                     Match('!');
-                    String third=GetName();
+                    String third=parseIdentifier();
 
                     if (!sheetName.equals(second))
                         throw new RuntimeException("Unhandled double sheet reference.");
@@ -271,9 +293,7 @@
 
         // This can be either a cell ref or a named range
         // Try to spot which it is
-        boolean cellRef = CELL_REFERENCE_PATTERN.matcher(name).matches();
-
-        if (cellRef) {
+        if (isValidCellReference(name)) {
             return new RefPtg(name);
         }
 
@@ -288,6 +308,41 @@
     }
 
     /**
+     * @return <code>null</code> if name cannot be split at a dot
+     */
+    private AreaReference parseArea(String name) {
+        int dotPos = name.indexOf('.');
+        if (dotPos < 0) {
+            return null;
+        }
+        int dotCount = 1;
+        while (dotCount<name.length() && name.charAt(dotPos+dotCount) == '.') {
+            dotCount++;
+            if (dotCount>3) {
+                // four or more consecutive dots does not convert to ':'
+                return null;
+            }
+        }
+        String partA = name.substring(0, dotPos);
+        if (!isValidCellReference(partA)) {
+            return null;
+        }
+        String partB = name.substring(dotPos+dotCount);
+        if (!isValidCellReference(partB)) {
+            return null;
+        }
+        CellReference topLeft = new CellReference(partA);
+        CellReference bottomRight = new CellReference(partB);
+        return new AreaReference(topLeft, bottomRight);
+    }
+
+    private static boolean isValidCellReference(String str) {
+        // TODO - exact rules for recognising cell references may be too complicated for regex 
+        return CELL_REFERENCE_PATTERN.matcher(str).matches();
+    }
+    
+    
+    /**
      * Note - Excel function names are 'case aware but not case sensitive'.  This method may end
      * up creating a defined name record in the workbook if the specified name is not an internal
      * Excel function, and has not been encountered before.
@@ -465,7 +520,7 @@
                 return new ParseNode(parseStringLiteral());
         }
         if (IsAlpha(look) || look == '\''){
-            return parseFunctionOrIdentifier();
+            return parseFunctionReferenceOrName();
         }
         // else - assume number
         return new ParseNode(parseNumber());
@@ -510,7 +565,7 @@
 
     private ErrPtg parseErrorLiteral() {
         Match('#');
-        String part1 = GetName().toUpperCase();
+        String part1 = parseIdentifier().toUpperCase();
 
         switch(part1.charAt(0)) {
             case 'V':

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java Sun Jul  6 06:10:09 2008
@@ -1,25 +1,78 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Created on May 15, 2005
- *
- */
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+	   http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
 package org.apache.poi.hssf.record.formula.functions;
 
-public class Errortype extends NotImplementedFunction {
+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.EvaluationException;
+import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.OperandResolver;
+import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
+
+/**
+ * Implementation for the ERROR.TYPE() Excel function.<p/>
+ * 
+ * <b>Syntax:</b><br/>
+ * <b>ERROR.TYPE</b>(<b>errorValue</b>)<p/>
+ * 
+ * Returns a number corresponding to the error type of the supplied argument.<p/>
+ * 
+ *    <table border="1" cellpadding="1" cellspacing="1" summary="Return values for ERROR.TYPE()">
+ *      <tr><td>errorValue</td><td>Return Value</td></tr>
+ *      <tr><td>#NULL!</td><td>1</td></tr>
+ *      <tr><td>#DIV/0!</td><td>2</td></tr>
+ *      <tr><td>#VALUE!</td><td>3</td></tr>
+ *      <tr><td>#REF!</td><td>4</td></tr>
+ *      <tr><td>#NAME?</td><td>5</td></tr>
+ *      <tr><td>#NUM!</td><td>6</td></tr>
+ *      <tr><td>#N/A!</td><td>7</td></tr>
+ *      <tr><td>everything else</td><td>#N/A!</td></tr>
+ *    </table>
+ * 
+ * Note - the results of ERROR.TYPE() are different to the constants defined in 
+ * <tt>HSSFErrorConstants</tt>.
+ * 
+ * @author Josh Micich
+ */
+public final class Errortype implements Function {
+
+	public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+		
+		try {
+			OperandResolver.getSingleValue(args[0], srcCellRow, srcCellCol);
+			return ErrorEval.NA;
+		} catch (EvaluationException e) {
+			int result = translateErrorCodeToErrorTypeValue(e.getErrorEval().getErrorCode());
+			return new NumberEval(result);
+		}
+	}
+
+	private int translateErrorCodeToErrorTypeValue(int errorCode) {
+		switch (errorCode) {
+			case HSSFErrorConstants.ERROR_NULL:  return 1;
+			case HSSFErrorConstants.ERROR_DIV_0: return 2;
+			case HSSFErrorConstants.ERROR_VALUE: return 3;
+			case HSSFErrorConstants.ERROR_REF:   return 4;
+			case HSSFErrorConstants.ERROR_NAME:  return 5;
+			case HSSFErrorConstants.ERROR_NUM:   return 6;
+			case HSSFErrorConstants.ERROR_NA :   return 7;
+		}
+		throw new IllegalArgumentException("Invalid error code (" + errorCode + ")");
+	}
 
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java Sun Jul  6 06:10:09 2008
@@ -24,6 +24,7 @@
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Stack;
@@ -105,6 +106,12 @@
      */
 
     private ArrayList names;
+    
+    /**
+     * this holds the HSSFFont objects attached to this workbook.
+     * We only create these from the low level records as required.
+     */
+    private Hashtable fonts;
 
     /**
      * holds whether or not to preserve other nodes in the POIFS.  Used
@@ -1021,9 +1028,10 @@
         if(fontindex == Short.MAX_VALUE){
             throw new IllegalArgumentException("Maximum number of fonts was exceeded");
         }
-        HSSFFont retval = new HSSFFont(fontindex, font);
-
-        return retval;
+        
+        // Ask getFontAt() to build it for us,
+        //  so it gets properly cached
+        return getFontAt(fontindex);
     }
 
     /**
@@ -1033,15 +1041,11 @@
                              String name, boolean italic, boolean strikeout,
                              short typeOffset, byte underline)
     {
-//        System.out.println( boldWeight + ", " + color + ", " + fontHeight + ", " + name + ", " + italic + ", " + strikeout + ", " + typeOffset + ", " + underline );
-        for (short i = 0; i < workbook.getNumberOfFontRecords(); i++)
-        {
-            if (i == 4)
-                continue;
-
-            FontRecord font = workbook.getFontRecordAt(i);
-            HSSFFont hssfFont = new HSSFFont(i, font);
-//            System.out.println( hssfFont.getBoldweight() + ", " + hssfFont.getColor() + ", " + hssfFont.getFontHeight() + ", " + hssfFont.getFontName() + ", " + hssfFont.getItalic() + ", " + hssfFont.getStrikeout() + ", " + hssfFont.getTypeOffset() + ", " + hssfFont.getUnderline() );
+    	for (short i=0; i<=getNumberOfFonts(); i++) {
+    		// Remember - there is no 4!
+    		if(i == 4) continue;
+    		
+    		HSSFFont hssfFont = getFontAt(i);
             if (hssfFont.getBoldweight() == boldWeight
                     && hssfFont.getColor() == color
                     && hssfFont.getFontHeight() == fontHeight
@@ -1051,12 +1055,10 @@
                     && hssfFont.getTypeOffset() == typeOffset
                     && hssfFont.getUnderline() == underline)
             {
-//                System.out.println( "Found font" );
                 return hssfFont;
             }
         }
 
-//        System.out.println( "No font found" );
         return null;
     }
 
@@ -1071,15 +1073,26 @@
     }
 
     /**
-     * get the font at the given index number
+     * Get the font at the given index number
      * @param idx  index number
      * @return HSSFFont at the index
      */
 
     public HSSFFont getFontAt(short idx)
     {
+    	if(fonts == null) fonts = new Hashtable();
+    	
+    	// So we don't confuse users, give them back
+    	//  the same object every time, but create
+    	//  them lazily
+    	Short sIdx = Short.valueOf(idx);
+    	if(fonts.containsKey(sIdx)) {
+    		return (HSSFFont)fonts.get(sIdx);
+    	}
+    	
         FontRecord font = workbook.getFontRecordAt(idx);
         HSSFFont retval = new HSSFFont(idx, font);
+        fonts.put(sIdx, retval);
 
         return retval;
     }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/util/HSSFColor.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/util/HSSFColor.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/util/HSSFColor.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/util/HSSFColor.java Sun Jul  6 06:10:09 2008
@@ -155,8 +155,12 @@
 
             String hexString = color.getHexString();
             if (result.containsKey(hexString)) {
-                throw new RuntimeException("Dup color hexString (" + hexString
-                        + ") for color (" + color.getClass().getName() + ")");
+            	HSSFColor other = (HSSFColor)result.get(hexString);
+                throw new RuntimeException(
+                		"Dup color hexString (" + hexString
+                        + ") for color (" + color.getClass().getName() + ") - "
+                        + " already taken by (" + other.getClass().getName() + ")"
+                );
             }
             result.put(hexString, color);
         }
@@ -1511,9 +1515,9 @@
         public final static short   index     = 0x19;
         public final static short[] triplet   =
         {
-            153, 51, 102
+            127, 0, 0
         };
-        public final static String  hexString = "9999:3333:6666";
+        public final static String  hexString = "8000:0:0";
 
         public short getIndex()
         {

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/TextPiece.java Sun Jul  6 06:10:09 2008
@@ -91,15 +91,18 @@
    public void adjustForDelete(int start, int length)
    {
 
+	   // length is expected to be the number of code-points,
+	   // not the number of characters
+	   int numChars = length;
 	   if (usesUnicode()) {
 
 		   start /= 2;
-		   length /= 2;
+		   numChars = (length / 2);
 	   }
 
 	   int myStart = getStart();
 	   int myEnd = getEnd();
-	   int end = start + length;
+	   int end = start + numChars;
 
 	   /* do we have to delete from this text piece? */
 	   if (start <= myEnd && end >= myStart) {
@@ -108,9 +111,14 @@
 		   int overlapStart = Math.max(myStart, start);
 		   int overlapEnd = Math.min(myEnd, end);
 		   ((StringBuffer)_buf).delete(overlapStart, overlapEnd);
-		   
-		   super.adjustForDelete(start, length);
 	   }
+
+	   // We need to invoke this even if text from this piece is not being
+	   // deleted because the adjustment must propagate to all subsequent
+	   // text pieces i.e., if text from tp[n] is being deleted, then
+	   // tp[n + 1], tp[n + 2], etc. will need to be adjusted.
+	   // The superclass is expected to use a separate sentry for this.
+	   super.adjustForDelete(start, length);
    }
 
    public int characterLength()

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java Sun Jul  6 06:10:09 2008
@@ -101,7 +101,14 @@
       case 3:
         return LittleEndian.getInt(_grpprl, _gOffset);
       case 6:
-        throw new UnsupportedOperationException("This SPRM contains a variable length operand");
+          byte operandLength = _grpprl[_gOffset + 1];   //surely shorter than an int...
+    	  
+          byte [] codeBytes = new byte[LittleEndian.INT_SIZE]; //initialized to zeros by JVM
+          for(int i = 0; i < operandLength; i++)
+              if(_gOffset + i < _grpprl.length)
+    			  codeBytes[i] = _grpprl[_gOffset + 1 + i];
+
+          return LittleEndian.getInt(codeBytes, 0);
       case 7:
         byte threeByteInt[] = new byte[4];
         threeByteInt[0] = _grpprl[_gOffset];

Modified: poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java (original)
+++ poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/usermodel/Range.java Sun Jul  6 06:10:09 2008
@@ -333,7 +333,7 @@
     _doc.getCharacterTable().adjustForInsert(_charStart, adjustedLength);
     _doc.getParagraphTable().adjustForInsert(_parStart, adjustedLength);
     _doc.getSectionTable().adjustForInsert(_sectionStart, adjustedLength);
-    adjustForInsert(text.length());
+	adjustForInsert(adjustedLength);
 
 	// update the FIB.CCPText field
 	adjustFIB(text.length());
@@ -656,8 +656,15 @@
             );
     }
 
+	// this Range isn't a proper parent of the subRange() so we'll have to keep
+	// track of an updated endOffset on our own
+	int previousEndOffset = subRange.getEndOffset();
+
     subRange.insertBefore(pValue);
 
+	if (subRange.getEndOffset() != previousEndOffset)
+		_end += (subRange.getEndOffset() - previousEndOffset);
+
     // re-create the sub-range so we can delete it
     subRange = new Range(
             (absPlaceHolderIndex + pValue.length()),
@@ -671,10 +678,31 @@
 					  (pValue.length() * 2)), getDocument()
             );
 
+	// deletes are automagically propagated
     subRange.delete();
   }
 
   /**
+   * Replace (all instances of) a piece of text with another...
+   *
+   * @param pPlaceHolder    The text to be replaced (e.g., "${organization}")
+   * @param pValue          The replacement text (e.g., "Apache Software Foundation")
+   */
+  public void replaceText(String pPlaceHolder, String pValue)
+  {
+		boolean keepLooking = true;
+		while (keepLooking) {
+
+			String text = text();
+			int offset = text.indexOf(pPlaceHolder);
+			if (offset >= 0)
+				replaceText(pPlaceHolder, pValue, offset);
+			else
+				keepLooking = false;
+		}
+  }
+
+  /**
    * Gets the character run at index. The index is relative to this range.
    *
    * @param index The index of the character run to get.
@@ -915,7 +943,7 @@
 
   /**
    * adjust this range after an insert happens.
-   * @param length the length to adjust for
+   * @param length the length to adjust for (expected to be a count of code-points, not necessarily chars)
    */
   private void adjustForInsert(int length)
   {

Modified: poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java (original)
+++ poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestRangeReplacement.java Sun Jul  6 06:10:09 2008
@@ -39,8 +39,9 @@
 		"It is used to confirm that text replacement works even if Unicode characters (such as \u201c\u2014\u201d (U+2014), \u201c\u2e8e\u201d (U+2E8E), or \u201c\u2714\u201d (U+2714)) are present.  Everybody should be thankful to the ${organization} and all the POI contributors for their assistance in this matter.\r";
 	private String searchText = "${organization}";
 	private String replacementText = "Apache Software Foundation";
-	private String expectedText =
+	private String expectedText2 =
 		"It is used to confirm that text replacement works even if Unicode characters (such as \u201c\u2014\u201d (U+2014), \u201c\u2e8e\u201d (U+2E8E), or \u201c\u2714\u201d (U+2714)) are present.  Everybody should be thankful to the Apache Software Foundation and all the POI contributors for their assistance in this matter.\r";
+	private String expectedText3 = "Thank you, Apache Software Foundation!\r";
 
 	private String illustrativeDocFile;
 
@@ -84,7 +85,7 @@
 	/**
 	 * Test that we can replace text in our Range with Unicode text.
 	 */
-	public void testRangeReplacement() throws Exception {
+	public void testRangeReplacementOne() throws Exception {
 
 		HWPFDocument daDoc = new HWPFDocument(new FileInputStream(illustrativeDocFile));
 
@@ -104,16 +105,46 @@
 
 		para.replaceText(searchText, replacementText, offset);
 
-		// we need to let the model re-calculate the Range before we evaluate it
-		range = daDoc.getRange();
-
 		assertEquals(1, range.numSections());
 		section = range.getSection(0);
 
+		assertEquals(4, section.numParagraphs());
+		para = section.getParagraph(2);
+
+		text = para.text();
+		assertEquals(expectedText2, text);
+	}
+
+	/**
+	 * Test that we can replace text in our Range with Unicode text.
+	 */
+	public void testRangeReplacementAll() throws Exception {
+
+		HWPFDocument daDoc = new HWPFDocument(new FileInputStream(illustrativeDocFile));
+
+		Range range = daDoc.getRange();
+		assertEquals(1, range.numSections());
+
+		Section section = range.getSection(0);
+		assertEquals(5, section.numParagraphs());
+
+		Paragraph para = section.getParagraph(2);
+
+		String text = para.text();
+		assertEquals(originalText, text);
+
+		range.replaceText(searchText, replacementText);
+
+		assertEquals(1, range.numSections());
+		section = range.getSection(0);
 		assertEquals(5, section.numParagraphs());
+
 		para = section.getParagraph(2);
+		text = para.text();
+		assertEquals(expectedText2, text);
 
+		para = section.getParagraph(3);
 		text = para.text();
-		assertEquals(expectedText, text);
+		assertEquals(expectedText3, text);
 	}
 }

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

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java Sun Jul  6 06:10:09 2008
@@ -16,8 +16,6 @@
 ==================================================================== */
 
 package org.apache.poi.hssf.eventusermodel;
-import java.io.File;
-import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
@@ -29,6 +27,7 @@
 import org.apache.poi.hssf.eventusermodel.dummyrecord.LastCellOfRowDummyRecord;
 import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingCellDummyRecord;
 import org.apache.poi.hssf.eventusermodel.dummyrecord.MissingRowDummyRecord;
+import org.apache.poi.hssf.record.BOFRecord;
 import org.apache.poi.hssf.record.LabelSSTRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.RowRecord;
@@ -40,8 +39,7 @@
 	
 	private Record[] r;
 
-	public void setUp() {
-
+	public void openNormal() {
 		HSSFRequest req = new HSSFRequest();
 		MockHSSFListener mockListen = new MockHSSFListener();
 		MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(mockListen);
@@ -55,10 +53,31 @@
 		} catch (IOException e) {
 			throw new RuntimeException(e);
 		}
+		
+		r = mockListen.getRecords();
+		assertTrue(r.length > 100);
+	} 
+	public void openAlt() {
+		HSSFRequest req = new HSSFRequest();
+		MockHSSFListener mockListen = new MockHSSFListener();
+		MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener(mockListen);
+		req.addListenerForAllRecords(listener);
+		
+		HSSFEventFactory factory = new HSSFEventFactory();
+		try {
+			InputStream is = HSSFTestDataSamples.openSampleFileStream("MRExtraLines.xls");
+			POIFSFileSystem fs = new POIFSFileSystem(is);
+			factory.processWorkbookEvents(req, fs);
+		} catch (IOException e) {
+			throw new RuntimeException(e);
+		}
+		
 		r = mockListen.getRecords();
+		assertTrue(r.length > 100);
 	} 
 	
 	public void testMissingRowRecords() throws Exception {
+		openNormal();
 		
 		// We have rows 0, 1, 2, 20 and 21
 		int row0 = -1;
@@ -108,6 +127,7 @@
 	}
 	
 	public void testEndOfRowRecords() throws Exception {
+		openNormal();
 		
 		// Find the cell at 0,0
 		int cell00 = -1;
@@ -194,7 +214,7 @@
 		assertTrue(r[cell00+57] instanceof LastCellOfRowDummyRecord);
 		
 		// Check the numbers of the last seen columns
-		LastCellOfRowDummyRecord[] lrs = new LastCellOfRowDummyRecord[23];
+		LastCellOfRowDummyRecord[] lrs = new LastCellOfRowDummyRecord[24];
 		int lrscount = 0;
 		for(int i=0; i<r.length; i++) {
 			if(r[i] instanceof LastCellOfRowDummyRecord) {
@@ -229,6 +249,7 @@
 	
 	
 	public void testMissingCellRecords() throws Exception {
+		openNormal();
 		
 		// Find the cell at 0,0
 		int cell00 = -1;
@@ -326,10 +347,38 @@
 		assertEquals(22, mc.getRow());
 		assertEquals(10, mc.getColumn());
 	}
+	
+	// Make sure we don't put in any extra new lines
+	//  that aren't already there
+	public void testNoExtraNewLines() throws Exception {
+		// Load a different file
+		openAlt();
+		
+		
+		// This file has has something in lines 1-33
+		List lcor = new ArrayList();
+		for(int i=0; i<r.length; i++) {
+			if(r[i] instanceof LastCellOfRowDummyRecord)
+				lcor.add( (LastCellOfRowDummyRecord)r[i] );
+		}
+		
+		// Check we got the 33 rows
+		assertEquals(33, lcor.size());
+		LastCellOfRowDummyRecord[] rowEnds = (LastCellOfRowDummyRecord[])
+			lcor.toArray(new LastCellOfRowDummyRecord[lcor.size()]);
+		assertEquals(33, rowEnds.length);
+		
+		// And check they have the right stuff in them,
+		//  no repeats
+		for(int i=0; i<rowEnds.length; i++) {
+			assertEquals(i, rowEnds[i].getRow());
+		}
+	}
 
 	private static final class MockHSSFListener implements HSSFListener {
 		public MockHSSFListener() {}
 		private final List _records = new ArrayList();
+		private boolean logToStdOut = false;
 
 		public void processRecord(Record record) {
 			_records.add(record);
@@ -346,9 +395,20 @@
 				LastCellOfRowDummyRecord lc = (LastCellOfRowDummyRecord)record;
 				log("Got end-of row, row was " + lc.getRow() + ", last column was " + lc.getLastColumnNumber());
 			}
+			
+			if(record instanceof BOFRecord) {
+				BOFRecord r = (BOFRecord)record;
+				if(r.getType() == BOFRecord.TYPE_WORKSHEET) {
+					log("On new sheet");
+				}
+			}
+			if(record instanceof RowRecord) {
+				RowRecord rr = (RowRecord)record;
+				log("Starting row #" + rr.getRowNumber());
+			}
 		}
-		private static void log(String msg) {
-			if(false) { // successful tests should be quiet
+		private void log(String msg) {
+			if(logToStdOut) {
 				System.out.println(msg);
 			}
 		}

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=674296&r1=674295&r2=674296&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 Sun Jul  6 06:10:09 2008
@@ -759,7 +759,7 @@
 		}
 	}
 
-	public void testParseErrorExpecteMsg() {
+	public void testParseErrorExpectedMsg() {
 
 		try {
 			parseFormula("round(3.14;2)");
@@ -768,4 +768,27 @@
 			assertEquals("Parse error near char 10 ';' in specified formula 'round(3.14;2)'. Expected ',' or ')'", e.getMessage());
 		}
 	}
+	
+	/**
+	 * this function name has a dot in it.
+	 */
+	public void testParseErrorTypeFunction() {
+
+		Ptg[] ptgs;
+		try {
+			ptgs = parseFormula("error.type(A1)");
+			
+			
+		} catch (IllegalArgumentException e) {
+			if (e.getMessage().equals("Invalid Formula cell reference: 'error'")) {
+				throw new AssertionFailedError("Identified bug 45334");
+			}
+			throw e;
+		}
+		assertEquals(2, ptgs.length);
+		assertEquals(FuncPtg.class, ptgs[1].getClass());
+		FuncPtg funcPtg = (FuncPtg) ptgs[1];
+		assertEquals("ERROR.TYPE", funcPtg.getName());
+	}
+	
 }

Modified: poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=674296&r1=674295&r2=674296&view=diff
==============================================================================
--- poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/branches/ooxml/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Sun Jul  6 06:10:09 2008
@@ -1052,4 +1052,88 @@
         	assertTrue(nd.get(0) instanceof DeletedArea3DPtg);
         }
     }
+    
+    /**
+     * Test that fonts get added properly
+     */
+    public void test45338() throws Exception {
+    	HSSFWorkbook wb = new HSSFWorkbook();
+    	assertEquals(4, wb.getNumberOfFonts());
+    	
+    	HSSFSheet s = wb.createSheet();
+    	s.createRow(0);
+    	s.createRow(1);
+    	HSSFCell c1 = s.getRow(0).createCell((short)0);
+    	HSSFCell c2 = s.getRow(1).createCell((short)0);
+    	
+    	assertEquals(4, wb.getNumberOfFonts());
+    	
+    	HSSFFont f1 = wb.getFontAt((short)0);
+    	assertEquals(400, f1.getBoldweight());
+    	
+    	// Check that asking for the same font
+    	//  multiple times gives you the same thing.
+    	// Otherwise, our tests wouldn't work!
+    	assertEquals(
+    			wb.getFontAt((short)0),
+    			wb.getFontAt((short)0)
+    	);
+    	assertEquals(
+    			wb.getFontAt((short)2),
+    			wb.getFontAt((short)2)
+    	);
+    	assertTrue(
+    			wb.getFontAt((short)0)
+    			!=
+    			wb.getFontAt((short)2)
+    	);
+    	
+    	// Look for a new font we have
+    	//  yet to add
+    	assertNull(
+    		wb.findFont(
+    			(short)11, (short)123, (short)22, 
+    			"Thingy", false, true, (short)2, (byte)2
+    		)
+    	);
+    	
+    	HSSFFont nf = wb.createFont();
+    	assertEquals(5, wb.getNumberOfFonts());
+    	
+    	assertEquals(5, nf.getIndex());
+    	assertEquals(nf, wb.getFontAt((short)5));
+    	
+    	nf.setBoldweight((short)11);
+    	nf.setColor((short)123);
+    	nf.setFontHeight((short)22);
+    	nf.setFontName("Thingy");
+    	nf.setItalic(false);
+    	nf.setStrikeout(true);
+    	nf.setTypeOffset((short)2);
+    	nf.setUnderline((byte)2);
+    	
+    	assertEquals(5, wb.getNumberOfFonts());
+    	assertEquals(nf, wb.getFontAt((short)5));
+    	
+    	// Find it now
+    	assertNotNull(
+    		wb.findFont(
+    			(short)11, (short)123, (short)22, 
+    			"Thingy", false, true, (short)2, (byte)2
+    		)
+    	);
+    	assertEquals(
+    		5,
+    		wb.findFont(
+       			(short)11, (short)123, (short)22, 
+       			"Thingy", false, true, (short)2, (byte)2
+       		).getIndex()
+    	);
+    	assertEquals(nf,
+       		wb.findFont(
+       			(short)11, (short)123, (short)22, 
+       			"Thingy", false, true, (short)2, (byte)2
+       		)
+    	);
+    }
 }



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


Mime
View raw message