poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r642560 [1/3] - in /poi/branches/ooxml: ./ src/documentation/content/xdocs/ src/documentation/content/xdocs/hwpf/ src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/ src/java/org/apache/poi/hssf/record/aggregates/ src/j...
Date Sat, 29 Mar 2008 17:19:12 GMT
Author: nick
Date: Sat Mar 29 10:19:09 2008
New Revision: 642560

URL: http://svn.apache.org/viewvc?rev=642560&view=rev
Log:
Merged revisions 612484-612511,612513-612519,612521-613394,613397-613399,613402-614210,614212-614273,614275-614869,614871-614877,614879-614908,614910-615189,615191-615254,615256-615258,615260-615309,615311-615314,615316-615609,615611-615768,615770-615858,615860-617155,617157-617166,617168-617482,617484-617486,617488-617490,617492-617515,617517-617522,617524-617554,617556-617833,617835-618229,618231-618234,618236-618327,618329-618679,618681-618689,618691,618693-618939,618941-619000,619002-619309,619311-619381,619383-619501,619503-619508,619510-619847,619850,619852-619967,619969-620340,620342-620556,620558-620581,620583-627778,627780-627787,627789-627998,628000-628026,628028,628030-628032,628034,628036-628043,628045-628064,628066-628713,628715-629551,629553-629737,629739-629741,629743-629754,629756-629820,629822-629828,629830,629833-629836,629838-629848,629850-629864,629866-630159,630161-630163,630165-633113,633115-633117,633119-633125,633127-633150,633152-633168,633170-633204,
 633206-633504,633506-633546,633549-634317,634319-634370,634373-634616,634618,634620-634629,634631-636750,636752-636755,636757-636785,636787-636789,636791-637188,637190-637592,637594,637596-637597,637599,637602-637869,637871-638784,638786-638802,638805-638811,638813-638814,638816-639230,639233-639241,639243-639253,639255-639486,639488-639601,639603-639835,639837-640056,640058-642557
via svnmerge from 
https://svn.apache.org/repos/asf/poi/trunk

........
  r639918 | josh | 2008-03-21 23:47:51 +0000 (Fri, 21 Mar 2008) | 1 line
  
  sort to int conversion sign extension fix
........
  r640711 | josh | 2008-03-25 06:18:33 +0000 (Tue, 25 Mar 2008) | 1 line
  
  Added class javadoc.  Patch 30311 from Dmtriy.
........
  r641157 | josh | 2008-03-26 05:29:08 +0000 (Wed, 26 Mar 2008) | 1 line
  
  more javadoc + clean-up from Dmitriy (bug 30311 att 21711)
........
  r641185 | josh | 2008-03-26 07:32:28 +0000 (Wed, 26 Mar 2008) | 1 line
  
  patch 44675 - made POI capable of recognising var-args functions.  Some related fixes.
........
  r641796 | nick | 2008-03-27 12:48:55 +0000 (Thu, 27 Mar 2008) | 1 line
  
  Patch from Raghu from bug #44652 - Improved handling of Pictures in Word Documents
........
  r641799 | nick | 2008-03-27 12:54:32 +0000 (Thu, 27 Mar 2008) | 1 line
  
  Fix typo, and point hwpf people at the new microsoft docs
........
  r641934 | nick | 2008-03-27 18:24:39 +0000 (Thu, 27 Mar 2008) | 1 line
  
  Add failing (but disabled) test from bug #44691
........
  r641964 | josh | 2008-03-27 20:03:29 +0000 (Thu, 27 Mar 2008) | 1 line
  
  fixes for ExternalNameRecord serialisation bug #44691
........
  r641967 | josh | 2008-03-27 20:15:13 +0000 (Thu, 27 Mar 2008) | 1 line
  
  annotated previous changelist(641964) with wrong buzilla number.  Previous changes were
for bug #44695.
........
  r641996 | josh | 2008-03-27 21:54:21 +0000 (Thu, 27 Mar 2008) | 1 line
  
  (real) fix for  bug #44691. Modified Pmt.java to allow for 3 arguments.  Added TestPmt junit.
........
  r642231 | nick | 2008-03-28 13:35:37 +0000 (Fri, 28 Mar 2008) | 1 line
  
  Add test to show that bug #44693 is incorrect
........

Added:
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/function/
      - copied from r642231, poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/function/FunctionDataBuilder.java
      - copied unchanged from r642231, poi/trunk/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
      - copied unchanged from r642231, poi/trunk/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
      - copied unchanged from r642231, poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/FunctionMetadataReader.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/function/FunctionMetadataRegistry.java
      - copied unchanged from r642231, poi/trunk/src/java/org/apache/poi/hssf/record/formula/function/FunctionMetadataRegistry.java
    poi/branches/ooxml/src/resources/main/
      - copied from r642231, poi/trunk/src/resources/main/
    poi/branches/ooxml/src/resources/main/font_metrics.properties
      - copied unchanged from r642231, poi/trunk/src/resources/main/font_metrics.properties
    poi/branches/ooxml/src/resources/main/org/
      - copied from r642231, poi/trunk/src/resources/main/org/
    poi/branches/ooxml/src/resources/main/org/apache/
      - copied from r642231, poi/trunk/src/resources/main/org/apache/
    poi/branches/ooxml/src/resources/main/org/apache/poi/
      - copied from r642231, poi/trunk/src/resources/main/org/apache/poi/
    poi/branches/ooxml/src/resources/main/org/apache/poi/hssf/
      - copied from r642231, poi/trunk/src/resources/main/org/apache/poi/hssf/
    poi/branches/ooxml/src/resources/main/org/apache/poi/hssf/record/
      - copied from r642231, poi/trunk/src/resources/main/org/apache/poi/hssf/record/
    poi/branches/ooxml/src/resources/main/org/apache/poi/hssf/record/formula/
      - copied from r642231, poi/trunk/src/resources/main/org/apache/poi/hssf/record/formula/
    poi/branches/ooxml/src/resources/main/org/apache/poi/hssf/record/formula/function/
      - copied from r642231, poi/trunk/src/resources/main/org/apache/poi/hssf/record/formula/function/
    poi/branches/ooxml/src/resources/main/org/apache/poi/hssf/record/formula/function/functionMetadata-asGenerated.txt
      - copied unchanged from r642231, poi/trunk/src/resources/main/org/apache/poi/hssf/record/formula/function/functionMetadata-asGenerated.txt
    poi/branches/ooxml/src/resources/main/org/apache/poi/hssf/record/formula/function/functionMetadata.txt
      - copied unchanged from r642231, poi/trunk/src/resources/main/org/apache/poi/hssf/record/formula/function/functionMetadata.txt
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java
      - copied unchanged from r642231, poi/trunk/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44603.doc
      - copied unchanged from r642231, poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/data/Bug44603.doc
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/44693.xls
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/data/44693.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/data/missingFuncs44675.xls
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/data/missingFuncs44675.xls
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/TestExternalNameRecord.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/
      - copied from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/AllFormulaFunctionTests.java
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/AllFormulaFunctionTests.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/ExcelFileFormatDocFunctionExtractor.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestFunctionMetadataRegistry.java
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/TestFunctionMetadataRegistry.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/TestParseMissingBuiltInFuncs.java
    poi/branches/ooxml/src/testcases/org/apache/poi/hssf/record/formula/function/TestReadMissingBuiltInFuncs.java
      - copied unchanged from r642231, poi/trunk/src/testcases/org/apache/poi/hssf/record/formula/function/TestReadMissingBuiltInFuncs.java
Removed:
    poi/branches/ooxml/src/resources/fontmetrics/font_metrics.properties
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/hwpf/docoverview.xml
    poi/branches/ooxml/src/documentation/content/xdocs/hwpf/index.xml
    poi/branches/ooxml/src/documentation/content/xdocs/status.xml
    poi/branches/ooxml/src/java/org/apache/poi/hssf/model/FormulaParser.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.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/FuncPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/record/formula/FuncVarPtg.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFConditionalFormatting.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
    poi/branches/ooxml/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hssf/record/formula/functions/Pmt.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/HWPFDocument.java
    poi/branches/ooxml/src/scratchpad/src/org/apache/poi/hwpf/model/PicturesTable.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hssf/record/formula/functions/AllIndividualFunctionEvaluationTests.java
    poi/branches/ooxml/src/scratchpad/testcases/org/apache/poi/hwpf/usermodel/TestPictures.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/usermodel/TestBugs.java

Propchange: poi/branches/ooxml/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Mar 29 10:19:09 2008
@@ -1 +1 @@
-/poi/trunk:1-612483,612512,612520,613395-613401,614211,614274,614870,614878-614909,615190-618235,618328,618680-620582,627779-638784,638786-639486,639488-639601,639603-639836
+/poi/trunk:1-638784,638786-639486,639488-639601,639603-640056,640058-642557

Modified: poi/branches/ooxml/build.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/build.xml?rev=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/build.xml (original)
+++ poi/branches/ooxml/build.xml Sat Mar 29 10:19:09 2008
@@ -70,7 +70,7 @@
   <property name="forrest.home" value="${env.FORREST_HOME}"/>
 
   <!-- Main: -->
-  <property name="main.resource1.dir" value="src/resources/fontmetrics"/>
+  <property name="main.resource1.dir" value="src/resources/main"/>
   <property name="main.src" location="src/java"/>
   <property name="main.src.test" location="src/testcases"/>
   <property name="main.documentation" value="src/documentation"/>

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=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/changes.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/changes.xml Sat Mar 29 10:19:09 2008
@@ -36,6 +36,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">44652 / 44603 - Improved handling
of Pictures in Word Documents</action>
            <action dev="POI-DEVELOPERS" type="fix">44636 - Fix formula parsing of RefVPtg,
which was causing #VALUE to be shown on subsequent edits</action>
            <action dev="POI-DEVELOPERS" type="fix">44627 - Improve the thread safety
of POILogFactory</action>
            <action dev="POI-DEVELOPERS" type="add">30311 - Initial support for Conditional
Formatting</action>

Modified: poi/branches/ooxml/src/documentation/content/xdocs/hwpf/docoverview.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/hwpf/docoverview.xml?rev=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/hwpf/docoverview.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/hwpf/docoverview.xml Sat Mar 29 10:19:09
2008
@@ -33,8 +33,9 @@
 
    <p>The purpose of this document is to give a brief high level overview of the
       HWPF document format. This document does not go into in-depth technical
-      detail and is only meant as a supplement to the Microsoft Word 97 Binary
-      File Format freely available at <link href="http://wotsit.org">Wotsit.org</link>.</p>
+      detail and is only meant as a supplement to the Microsoft Word 97-2007 
+      Binary File Format freely available from 
+      <link href="http://www.microsoft.com/interop/docs/officebinaryformats.mspx">Microsoft</link>.</p>
    <p>The OLE file format is not discussed in this document. It is assumed that
       the reader has a working knowledge of the POIFS API. </p>
 

Modified: poi/branches/ooxml/src/documentation/content/xdocs/hwpf/index.xml
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/documentation/content/xdocs/hwpf/index.xml?rev=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/hwpf/index.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/hwpf/index.xml Sat Mar 29 10:19:09
2008
@@ -87,7 +87,7 @@
      <li>anything else that seems reasonable</li>
     </ul>
 
-    <p>When you start start coding, you will not yet have write access to the
+    <p>When you start coding, you will not yet have write access to the
      CVS repository. Please submit your patches to <link
       href="http://issues.apache.org/">Bugzilla</link> and nag <link
       href="mailto:klute@apache.org">Rainer Klute</link> until he commits

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=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/src/documentation/content/xdocs/status.xml (original)
+++ poi/branches/ooxml/src/documentation/content/xdocs/status.xml Sat Mar 29 10:19:09 2008
@@ -33,6 +33,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.1-beta1" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="add">44652 / 44603 - Improved handling
of Pictures in Word Documents</action>
            <action dev="POI-DEVELOPERS" type="fix">44636 - Fix formula parsing of RefVPtg,
which was causing #VALUE to be shown on subsequent edits</action>
            <action dev="POI-DEVELOPERS" type="fix">44627 - Improve the thread safety
of POILogFactory</action>
            <action dev="POI-DEVELOPERS" type="add">30311 - Initial support for Conditional
Formatting</action>

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=642560&r1=642559&r2=642560&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 Sat Mar 29 10:19:09
2008
@@ -25,6 +25,8 @@
 
 //import PTG's .. 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;
 
 
 
@@ -369,7 +371,23 @@
      */
     private AbstractFunctionPtg getFunction(String name, int numArgs, List argumentPointers)
{
 
-        AbstractFunctionPtg retval = new FuncVarPtg(name, (byte)numArgs);
+        boolean isVarArgs;
+        int funcIx;
+        FunctionMetadata fm = FunctionMetadataRegistry.getFunctionByName(name.toUpperCase());
+        if(fm == null) {
+            // must be external function
+            isVarArgs = true;
+            funcIx = FunctionMetadataRegistry.FUNCTION_INDEX_EXTERNAL;
+        } else {
+            isVarArgs = !fm.hasFixedArgsLength();
+            funcIx = fm.getIndex();
+        }
+        AbstractFunctionPtg retval;
+        if(isVarArgs) {
+            retval = new FuncVarPtg(name, (byte)numArgs);
+        } else {
+            retval = new FuncPtg(funcIx, (byte)numArgs);
+        }
         if (!name.equals(AbstractFunctionPtg.FUNCTION_NAME_IF)) {
             // early return for everything else besides IF()
             return retval;
@@ -969,6 +987,10 @@
                     // tAttrSpace comes *before* the operand it applies to, which may be
consistent
                     // with how the formula text appears but is against the RPN ordering
assumed here 
                 }
+                if (attrPtg.isSemiVolatile()) {
+                    // similar to tAttrSpace - RPN is violated
+                    continue;
+                }
             }
 
             final OperationPtg o = (OperationPtg) ptg;
@@ -979,7 +1001,7 @@
                 if(stack.isEmpty()) {
                    String msg = "Too few arguments suppled to operation token ("
                         + o.getClass().getName() + "). Expected (" + nOperands
-                        + ") operands but got (" + (nOperands - j + 1) + ")";
+                        + ") operands but got (" + (nOperands - j - 1) + ")";
                     throw new IllegalStateException(msg);
                 }
                 operands[j] = (String) stack.pop();

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java?rev=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ExternalNameRecord.java Sat Mar
29 10:19:09 2008
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.record;
 
-import java.util.List;
 import java.util.Stack;
 
 import org.apache.poi.hssf.record.formula.Ptg;
@@ -27,153 +26,160 @@
 /**
  * EXTERNALNAME<p/>
  * 
- * @author josh micich
+ * @author Josh Micich
  */
 public final class ExternalNameRecord extends Record {
 
-    public final static short sid = 0x23; // as per BIFF8. (some old versions used 0x223)
+	public final static short sid = 0x23; // as per BIFF8. (some old versions used 0x223)
 
+	private static final int OPT_BUILTIN_NAME          = 0x0001;
+	private static final int OPT_AUTOMATIC_LINK        = 0x0002;
+	private static final int OPT_PICTURE_LINK          = 0x0004;
+	private static final int OPT_STD_DOCUMENT_NAME     = 0x0008;
+	private static final int OPT_OLE_LINK              = 0x0010;
+//	private static final int OPT_CLIP_FORMAT_MASK	   = 0x7FE0;
+	private static final int OPT_ICONIFIED_PICTURE_LINK= 0x8000;
+
+
+	private short  field_1_option_flag;
+	private short  field_2_index;
+	private short  field_3_not_used;
+	private String field_4_name;
+	private Ptg[]  field_5_name_definition; // TODO - junits for name definition field
 
-    private static final int OPT_BUILTIN_NAME           =   0x0001;
-    private static final int OPT_AUTOMATIC_LINK         =   0x0002;
-    private static final int OPT_PICTURE_LINK           =   0x0004;
-    private static final int OPT_STD_DOCUMENT_NAME      =   0x0008;
-    private static final int OPT_OLE_LINK               =   0x0010;
-//    private static final int OPT_CLIP_FORMAT_MASK       =   0x7FE0;
-    private static final int OPT_ICONIFIED_PICTURE_LINK =   0x8000;
-
-
-    private short             field_1_option_flag;
-    private short              field_2_index;
-    private short              field_3_not_used;
-    private String             field_4_name;
-    private Stack             field_5_name_definition;
-
-
-    public ExternalNameRecord(RecordInputStream in) {
-        super(in);
-    }
+	public ExternalNameRecord(RecordInputStream in) {
+		super(in);
+	}
 
  	/**
  	 * Convenience Function to determine if the name is a built-in name
 	 */
 	public boolean isBuiltInName() {
-	    return (field_1_option_flag & OPT_BUILTIN_NAME) != 0;
+		return (field_1_option_flag & OPT_BUILTIN_NAME) != 0;
+	}
+	/**
+	 * For OLE and DDE, links can be either 'automatic' or 'manual'
+	 */
+	public boolean isAutomaticLink() {
+		return (field_1_option_flag & OPT_AUTOMATIC_LINK) != 0;
+	}
+	/**
+	 * only for OLE and DDE
+	 */
+	public boolean isPicureLink() {
+		return (field_1_option_flag & OPT_PICTURE_LINK) != 0;
+	}
+	/**
+	 * DDE links only. If <code>true</code>, this denotes the 'StdDocumentName'
+	 */
+	public boolean isStdDocumentNameIdentifier() {
+		return (field_1_option_flag & OPT_STD_DOCUMENT_NAME) != 0;
+	}
+	public boolean isOLELink() {
+		return (field_1_option_flag & OPT_OLE_LINK) != 0;
+	}
+	public boolean isIconifiedPictureLink() {
+		return (field_1_option_flag & OPT_ICONIFIED_PICTURE_LINK) != 0;
+	}
+	/**
+	 * @return the standard String representation of this name
+	 */
+	public String getText() {
+		return field_4_name;
+	}
+
+
+	/**
+	 * called by constructor, should throw runtime exception in the event of a
+	 * record passed with a differing ID.
+	 *
+	 * @param id alleged id for this record
+	 */
+	protected void validateSid(short id) {
+		if (id != sid) {
+			throw new RecordFormatException("NOT A valid ExternalName RECORD");
+		}
 	}
-    /**
-     * For OLE and DDE, links can be either 'automatic' or 'manual'
-     */
-    public boolean isAutomaticLink() {
-        return (field_1_option_flag & OPT_AUTOMATIC_LINK) != 0;
-    }
-    /**
-     * only for OLE and DDE
-     */
-    public boolean isPicureLink() {
-        return (field_1_option_flag & OPT_PICTURE_LINK) != 0;
-    }
-    /**
-     * DDE links only. If <code>true</code>, this denotes the 'StdDocumentName'
-     */
-    public boolean isStdDocumentNameIdentifier() {
-        return (field_1_option_flag & OPT_STD_DOCUMENT_NAME) != 0;
-    }
-    public boolean isOLELink() {
-        return (field_1_option_flag & OPT_OLE_LINK) != 0;
-    }
-    public boolean isIconifiedPictureLink() {
-        return (field_1_option_flag & OPT_ICONIFIED_PICTURE_LINK) != 0;
-    }
-    /**
-     * @return the standard String representation of this name
-     */
-    public String getText() {
-    	return field_4_name;
-    }
-
-
-    /**
-     * called by constructor, should throw runtime exception in the event of a
-     * record passed with a differing ID.
-     *
-     * @param id alleged id for this record
-     */
-    protected void validateSid(short id) {
-        if (id != sid) {
-            throw new RecordFormatException("NOT A valid ExternalName RECORD");
-        }
-    }
-
-    private int getDataSize(){
-        return 2 + 2 + field_4_name.length() + 2 + getNameDefinitionSize();
-    }
-
-    /**
-     * called by the class that is responsible for writing this sucker.
-     * Subclasses should implement this so that their data is passed back in a
-     * byte array.
-     *
-     * @param offset to begin writing at
-     * @param data byte array containing instance data
-     * @return number of bytes written
-     */
-    public int serialize( int offset, byte[] data ) {
-   	// TODO - junit tests
-        int dataSize = getDataSize();
 
-        LittleEndian.putShort( data, 0 + offset, sid );
+	private int getDataSize(){
+		return 3 * 2  // 3 short fields
+			+ 2 + field_4_name.length() // nameLen and name
+			+ 2 + getNameDefinitionSize(); // nameDefLen and nameDef
+	}
+
+	/**
+	 * called by the class that is responsible for writing this sucker.
+	 * Subclasses should implement this so that their data is passed back in a
+	 * byte array.
+	 *
+	 * @param offset to begin writing at
+	 * @param data byte array containing instance data
+	 * @return number of bytes written
+	 */
+	public int serialize( int offset, byte[] data ) {
+		int dataSize = getDataSize();
+
+		LittleEndian.putShort( data, 0 + offset, sid );
 		LittleEndian.putShort( data, 2 + offset, (short) dataSize );
-        LittleEndian.putShort( data, 4 + offset, field_1_option_flag );
-        LittleEndian.putShort( data, 6 + offset, field_2_index );
-        LittleEndian.putShort( data, 8 + offset, field_3_not_used );
-        short nameLen = (short) field_4_name.length();
+		LittleEndian.putShort( data, 4 + offset, field_1_option_flag );
+		LittleEndian.putShort( data, 6 + offset, field_2_index );
+		LittleEndian.putShort( data, 8 + offset, field_3_not_used );
+		short nameLen = (short) field_4_name.length();
 		LittleEndian.putShort( data, 10 + offset, nameLen );
-        StringUtil.putCompressedUnicode( field_4_name, data, 10 + offset );
-        short defLen = (short) getNameDefinitionSize();
-        LittleEndian.putShort( data, 12 + nameLen + offset, defLen );
-		Ptg.serializePtgStack(field_5_name_definition, data, 12 + nameLen + offset );
+		StringUtil.putCompressedUnicode( field_4_name, data, 12 + offset );
+		short defLen = (short) getNameDefinitionSize();
+		LittleEndian.putShort( data, 12 + nameLen + offset, defLen );
+		Ptg.serializePtgStack(toStack(field_5_name_definition), data, 14 + nameLen + offset );
 		return dataSize + 4;
-    }
+	}
+
+	private int getNameDefinitionSize() {
+		int result = 0;
+		for (int i = 0; i < field_5_name_definition.length; i++) {
+			result += field_5_name_definition[i].getSize();
+		}
+		return result;
+	}
+
+
+	public int getRecordSize(){
+		return 4 + getDataSize();
+	}
+
 
-    private int getNameDefinitionSize() {
-    	int result = 0;
-        List list   = field_5_name_definition;
-
-        for (int k = 0; k < list.size(); k++)
-        {
-        	Ptg ptg = ( Ptg ) list.get(k);
-        
-        	result += ptg.getSize();
-        }
-        return result;
-    }
-
-
-    public int getRecordSize(){
-        return 6 + 2 + field_4_name.length() + 2 + getNameDefinitionSize();
-    }
-
-
-    protected void fillFields(RecordInputStream in) {
-        field_1_option_flag             = in.readShort();
-        field_2_index                   = in.readShort();
-        field_3_not_used                = in.readShort();
-        short nameLength = in.readShort();
-        field_4_name                    = in.readCompressedUnicode(nameLength);
-        short formulaLen = in.readShort();
-		field_5_name_definition         = Ptg.createParsedExpressionTokens(formulaLen, in);
-    }
-
-    public short getSid() {
-        return sid;
-    }
-
-    public String toString() {
-        StringBuffer sb = new StringBuffer();
-        sb.append(getClass().getName()).append(" [EXTERNALNAME ");
-        sb.append(" ").append(field_4_name);
-        sb.append(" ix=").append(field_2_index);
-        sb.append("]");
-        return sb.toString();
-    }
+	protected void fillFields(RecordInputStream in) {
+		field_1_option_flag = in.readShort();
+		field_2_index	   = in.readShort();
+		field_3_not_used	= in.readShort();
+		short nameLength	= in.readShort();
+		field_4_name		= in.readCompressedUnicode(nameLength);
+		short formulaLen	= in.readShort();
+		field_5_name_definition = toPtgArray(Ptg.createParsedExpressionTokens(formulaLen, in));
+	}
+
+	private static Ptg[] toPtgArray(Stack s) {
+		Ptg[] result = new Ptg[s.size()];
+		s.toArray(result);
+		return result;
+	}
+	private static Stack toStack(Ptg[] ptgs) {
+		Stack result = new Stack();
+		for (int i = 0; i < ptgs.length; i++) {
+			result.push(ptgs[i]);
+		}
+		return result;
+	}
+ 
+	public short getSid() {
+		return sid;
+	}
+
+	public String toString() {
+		StringBuffer sb = new StringBuffer();
+		sb.append(getClass().getName()).append(" [EXTERNALNAME ");
+		sb.append(" ").append(field_4_name);
+		sb.append(" ix=").append(field_2_index);
+		sb.append("]");
+		return sb.toString();
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java?rev=642560&r1=642559&r2=642560&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
(original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/CFRecordsAggregate.java
Sat Mar 29 10:19:09 2008
@@ -35,54 +35,55 @@
  * @author Dmitriy Kumshayev
  *
  */
-public class CFRecordsAggregate extends Record
+public final class CFRecordsAggregate extends Record
 {
-    public final static short sid = -2008;
+	public final static short sid = -2008; // not a real BIFF record
+
+	private static POILogger  log = POILogFactory.getLogger(CFRecordsAggregate.class);
+
+	private CFHeaderRecord header;
+
+	// List of CFRuleRecord objects
+	private final List rules;
+
+	public CFRecordsAggregate()
+	{
+		header = null;
+		rules  = new ArrayList(3);
+	}
+
+	/**
+	 * Create CFRecordsAggregate from a list of CF Records
+	 * @param recs - list of {@link Record} objects
+	 * @param offset - position of {@link CFHeaderRecord} object in the list of Record objects
+	 * @return CFRecordsAggregate object
+	 */
+	public static CFRecordsAggregate createCFAggregate(List recs, int pOffset)
+	{
+
+		int offset = pOffset;
+		CFRecordsAggregate 	cfRecords  = new CFRecordsAggregate();
+		ArrayList 		records = new ArrayList(4);
+
+		Record rec = ( Record ) recs.get(offset++);
+
+		if (rec.getSid() == CFHeaderRecord.sid)
+		{
+			records.add(rec);
+			cfRecords.header = (CFHeaderRecord)rec;
+
+			int nRules = cfRecords.header.getNumberOfConditionalFormats();
+			int rulesCount = 0;
+			while(  offset<recs.size() &&
+					(rec = (Record)recs.get(offset++)).getSid() == CFRuleRecord.sid && 
+					rec instanceof CFRuleRecord &&
+					rulesCount++ < nRules
+				 )
+			{
+				records.add(rec);
+				cfRecords.rules.add(rec);
+			}
 
-    private static POILogger  log = POILogFactory.getLogger(CFRecordsAggregate.class);
-    
-    private CFHeaderRecord header;
-
-    // List of CFRuleRecord objects
-	private List rules;
-	
-    public CFRecordsAggregate()
-    {
-        header = null;
-    	rules  = new ArrayList(3);
-    }
-    
-    /**
-     * Create CFRecordsAggregate from a list of CF Records
-     * @param recs - list of {@link Record} objects
-     * @param offset - position of {@link CFHeaderRecord} object in the list of Record objects
-     * @return CFRecordsAggregate object
-     */
-    public static CFRecordsAggregate createCFAggregate(List recs, int offset)
-    {
-    	CFRecordsAggregate 	cfRecords  = new CFRecordsAggregate();
-        ArrayList 		records = new ArrayList(4);
-        
-        int count = 0;
-        Record rec = ( Record ) recs.get(offset++);
-        
-        if (rec.getSid() == CFHeaderRecord.sid)
-        {
-            records.add(rec);
-            cfRecords.header = (CFHeaderRecord)rec;
-            
-            int nRules = cfRecords.header.getNumberOfConditionalFormats();
-            int rulesCount = 0;
-            while(  offset<recs.size() &&
-            		(rec = (Record)recs.get(offset++)).getSid() == CFRuleRecord.sid &&

-            		rec instanceof CFRuleRecord &&
-            		rulesCount++ < nRules
-            	 )
-            {
-                records.add(rec);
-                cfRecords.rules.add(rec);
-            }
-            
 			if (nRules != cfRecords.rules.size())
 			{
 				if (log.check(POILogger.DEBUG))
@@ -93,66 +94,66 @@
 				cfRecords.header.setNumberOfConditionalFormats(nRules);
 			}
 
-        }
-        return cfRecords;
-    }
-    
-    /**
-     * Create a deep clone of the record
-     * @return
-     */
-    public CFRecordsAggregate cloneCFAggregate()
-    {
-    	
-      ArrayList records = new ArrayList(this.rules.size()+1);
-      
-      records.add(this.header.clone());
-      
-      for (int i=0; i<this.rules.size();i++) 
-      {
-        Record rec = (Record)((Record)this.rules.get(i)).clone();
-        records.add(rec);
-      }
-      return createCFAggregate(records, 0);
-    }
-    
-    /** You never fill an aggregate */
+		}
+		return cfRecords;
+	}
+
+	/**
+	 * Create a deep clone of the record
+	 * @return
+	 */
+	public CFRecordsAggregate cloneCFAggregate()
+	{
+
+	  ArrayList records = new ArrayList(this.rules.size()+1);
+	  
+	  records.add(this.header.clone());
+	  
+	  for (int i=0; i<this.rules.size();i++) 
+	  {
+		Record rec = (Record)((Record)this.rules.get(i)).clone();
+		records.add(rec);
+	  }
+	  return createCFAggregate(records, 0);
+	}
+
+	/** You never fill an aggregate */
 	protected void fillFields(RecordInputStream in)
 	{
 	}
-	
+
 	public short getSid()
 	{
 		return sid;
 	}
-	
-    /**
-     * called by the class that is responsible for writing this sucker.
-     * Subclasses should implement this so that their data is passed back in a
-     * byte array.
-     *
-     * @param offset to begin writing at
-     * @param data byte array containing instance data
-     * @return number of bytes written
-     */
+
+	/**
+	 * called by the class that is responsible for writing this sucker.
+	 * Subclasses should implement this so that their data is passed back in a
+	 * byte array.
+	 *
+	 * @param offset to begin writing at
+	 * @param data byte array containing instance data
+	 * @return number of bytes written
+	 */
 
 	public int serialize(int offset, byte[] data)
 	{
-        int pos = offset;
+		int pos = offset;
 		if( header != null && rules.size()>0 )
 		{
 			header.setNumberOfConditionalFormats(rules.size());
 
-            pos += (( Record ) header).serialize(pos, data);
+			pos += (( Record ) header).serialize(pos, data);
 
-	        for(Iterator itr = rules.iterator(); itr.hasNext();)
-	        {
-	            pos += (( Record ) itr.next()).serialize(pos, data);
-	        }
+			for(Iterator itr = rules.iterator(); itr.hasNext();)
+			{
+				pos += (( Record ) itr.next()).serialize(pos, data);
+			}
 		}
-        return pos - offset;
+		return pos - offset;
 	}
-	
+
 	protected void validateSid(short id)
 	{
 		// do nothing here
@@ -179,21 +180,21 @@
 	 */
 	public int getRecordSize() 
 	{
-        int size = 0;
-        if( header != null)
-        {
-        	size += header.getRecordSize();
-        }
-        if( rules != null)
-        {
-            for(Iterator irecs = rules.iterator(); irecs.hasNext(); )
-            {
-                size += (( Record ) irecs.next()).getRecordSize();
-            }
-        }
-        return size;
-    }
-	
+		int size = 0;
+		if( header != null)
+		{
+			size += header.getRecordSize();
+		}
+		if( rules != null)
+		{
+			for(Iterator irecs = rules.iterator(); irecs.hasNext(); )
+			{
+				size += (( Record ) irecs.next()).getRecordSize();
+			}
+		}
+		return size;
+	}
+
 	/**
 	 * String representation of CFRecordsAggregate
 	 */
@@ -206,19 +207,15 @@
 		{
 			buffer.append(header.toString());
 		}
-		if( rules != null )
+		for(int i=0; i<rules.size(); i++)
 		{
-			for(int i=0; i<rules.size(); i++)
+			CFRuleRecord cfRule = (CFRuleRecord)rules.get(i);
+			if(cfRule!=null)
 			{
-				CFRuleRecord cfRule = (CFRuleRecord)rules.get(i);
-				if(cfRule!=null)
-				{
-					buffer.append(cfRule.toString());
-				}
+				buffer.append(cfRule.toString());
 			}
 		}
 		buffer.append("[/CF]\n");
 		return buffer.toString();
 	}
-	
 }



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


Mime
View raw message