]> source.dussan.org Git - poi.git/commitdiff
Formula changes. . Disable for 1.5...alow compile in if desired.
authorAndrew C. Oliver <acoliver@apache.org>
Wed, 17 Apr 2002 22:21:16 +0000 (22:21 +0000)
committerAndrew C. Oliver <acoliver@apache.org>
Wed, 17 Apr 2002 22:21:16 +0000 (22:21 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352431 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/dev/BiffViewer.java
src/java/org/apache/poi/hssf/record/FormulaRecord.java
src/java/org/apache/poi/hssf/record/RecordFactory.java

index 8385dc3014f855c25818e05a2c3d56fa7bbd8e4a..3796866989f3791d829c559d72b339254c1845ea 100644 (file)
@@ -630,6 +630,11 @@ public class BiffViewer
             case LinkedDataRecord.sid:
                 retval = new LinkedDataRecord(rectype, size, data);
                 break;
+                
+            case FormulaRecord.sid:
+                retval = new FormulaRecord(rectype, size, data);
+                break;
+                
 
             default :
                 retval = new UnknownRecord(rectype, size, data);
index ea0a6e6f6b8ed3a25a63bd581e0aa321562bdd28..4c027b6e28b1415117fca34dd3cae48844dfb14d 100644 (file)
@@ -77,8 +77,12 @@ public class FormulaRecord
     extends Record
     implements CellValueRecordInterface, Comparable
 {
+    
+    public static final boolean EXPERIMENTAL_FORMULA_SUPPORT_ENABLED=false;
+    
     public static final short sid =
         0x06;   // docs say 406...because of a bug Microsoft support site article #Q184647)
+    
     private short             field_1_row;
     private short             field_2_column;
     private short             field_3_xf;
@@ -87,6 +91,9 @@ public class FormulaRecord
     private int               field_6_zero;
     private short             field_7_expression_len;
     private Stack             field_8_parsed_expr;
+    
+    private byte[]            all_data; //if formula support is not enabled then
+                                        //we'll just store/reserialize
 
     /** Creates new FormulaRecord */
 
@@ -126,6 +133,7 @@ public class FormulaRecord
 
     protected void fillFields(byte [] data, short size, int offset)
     {
+        if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
         field_1_row            = LittleEndian.getShort(data, 0 + offset);
         field_2_column         = LittleEndian.getShort(data, 2 + offset);
         field_3_xf             = LittleEndian.getShort(data, 4 + offset);
@@ -133,9 +141,16 @@ public class FormulaRecord
         field_5_options        = LittleEndian.getShort(data, 14 + offset);
         field_6_zero           = LittleEndian.getInt(data, 16 + offset);
         field_7_expression_len = LittleEndian.getShort(data, 20 + offset);
+        field_8_parsed_expr    = getParsedExpressionTokens(data, size,
+                                 offset);
+        
+        } else {
+            all_data = new byte[size+4];
+            LittleEndian.putShort(all_data,0,sid);
+            LittleEndian.putShort(all_data,2,size);
+            System.arraycopy(data,offset,all_data,4,size);
+        }
 
-        // field_8_parsed_expr    = getParsedExpressionTokens(data, size,
-        // offset);
     }
 
     private Stack getParsedExpressionTokens(byte [] data, short size,
@@ -332,6 +347,7 @@ public class FormulaRecord
 
     public int serialize(int offset, byte [] data)
     {
+        if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
         int ptgSize = getTotalPtgSize();
 
         LittleEndian.putShort(data, 0 + offset, sid);
@@ -343,6 +359,9 @@ public class FormulaRecord
         LittleEndian.putShort(data, 18 + offset, getOptions());
         LittleEndian.putInt(data, 20 + offset, field_6_zero);
         LittleEndian.putShort(data, 24 + offset, getExpressionLength());
+        } else {
+            System.arraycopy(all_data,0,data,offset,all_data.length);
+        }
 
         // serializePtgs(data, 26+offset);
         return getRecordSize();
@@ -350,7 +369,14 @@ public class FormulaRecord
 
     public int getRecordSize()
     {
-        return 0;
+        int retval =0;
+        
+        if (EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
+            retval = getTotalPtgSize() + 28;
+        } else {
+            retval =all_data.length;
+        }
+        return retval;
 
         // return getTotalPtgSize() + 28;
     }
index 480c9fbfacf60ef3602cdff1e57c3adfca76fb72..4a1ce1933da333ca7137e457ad2a6a29c6d70a2e 100644 (file)
@@ -77,33 +77,68 @@ import org.apache.poi.util.LittleEndian;
 public class RecordFactory
 {
     private static int           NUM_RECORDS = 10000;
-    private static final Class[] records     = new Class[]
-    {
-        BOFRecord.class, InterfaceHdrRecord.class, MMSRecord.class,
-        InterfaceEndRecord.class, WriteAccessRecord.class,
-        CodepageRecord.class, DSFRecord.class, TabIdRecord.class,
-        FnGroupCountRecord.class, WindowProtectRecord.class,
-        ProtectRecord.class, PasswordRecord.class, ProtectionRev4Record.class,
-        PasswordRev4Record.class, WindowOneRecord.class, BackupRecord.class,
-        HideObjRecord.class, DateWindow1904Record.class,
-        PrecisionRecord.class, RefreshAllRecord.class, BookBoolRecord.class,
-        FontRecord.class, FormatRecord.class, ExtendedFormatRecord.class,
-        StyleRecord.class, UseSelFSRecord.class, BoundSheetRecord.class,
-        CountryRecord.class, SSTRecord.class, ExtSSTRecord.class,
-        EOFRecord.class, IndexRecord.class, CalcModeRecord.class,
-        CalcCountRecord.class, RefModeRecord.class, IterationRecord.class,
-        DeltaRecord.class, SaveRecalcRecord.class, PrintHeadersRecord.class,
-        PrintGridlinesRecord.class, GridsetRecord.class, GutsRecord.class,
-        DefaultRowHeightRecord.class, WSBoolRecord.class, HeaderRecord.class,
-        FooterRecord.class, HCenterRecord.class, VCenterRecord.class,
-        PrintSetupRecord.class, DefaultColWidthRecord.class,
-        DimensionsRecord.class, RowRecord.class, LabelSSTRecord.class,
-        RKRecord.class, NumberRecord.class, DBCellRecord.class,
-        WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class,
-        LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class,
-        MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class,
-        FormulaRecord.class, BoolErrRecord.class
-    };
+    private static final Class[] records;
+    
+    static {
+        if (FormulaRecord.EXPERIMENTAL_FORMULA_SUPPORT_ENABLED) {
+            records = new Class[]
+            {
+                BOFRecord.class, InterfaceHdrRecord.class, MMSRecord.class,
+                InterfaceEndRecord.class, WriteAccessRecord.class,
+                CodepageRecord.class, DSFRecord.class, TabIdRecord.class,
+                FnGroupCountRecord.class, WindowProtectRecord.class,
+                ProtectRecord.class, PasswordRecord.class, ProtectionRev4Record.class,
+                PasswordRev4Record.class, WindowOneRecord.class, BackupRecord.class,
+                HideObjRecord.class, DateWindow1904Record.class,
+                PrecisionRecord.class, RefreshAllRecord.class, BookBoolRecord.class,
+                FontRecord.class, FormatRecord.class, ExtendedFormatRecord.class,
+                StyleRecord.class, UseSelFSRecord.class, BoundSheetRecord.class,
+                CountryRecord.class, SSTRecord.class, ExtSSTRecord.class,
+                EOFRecord.class, IndexRecord.class, CalcModeRecord.class,
+                CalcCountRecord.class, RefModeRecord.class, IterationRecord.class,
+                DeltaRecord.class, SaveRecalcRecord.class, PrintHeadersRecord.class,
+                PrintGridlinesRecord.class, GridsetRecord.class, GutsRecord.class,
+                DefaultRowHeightRecord.class, WSBoolRecord.class, HeaderRecord.class,
+                FooterRecord.class, HCenterRecord.class, VCenterRecord.class,
+                PrintSetupRecord.class, DefaultColWidthRecord.class,
+                DimensionsRecord.class, RowRecord.class, LabelSSTRecord.class,
+                RKRecord.class, NumberRecord.class, DBCellRecord.class,
+                WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class,
+                LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class,
+                MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class,
+                FormulaRecord.class, BoolErrRecord.class
+            };
+        } else {
+            records = new Class[]
+            {
+                BOFRecord.class, InterfaceHdrRecord.class, MMSRecord.class,
+                InterfaceEndRecord.class, WriteAccessRecord.class,
+                CodepageRecord.class, DSFRecord.class, TabIdRecord.class,
+                FnGroupCountRecord.class, WindowProtectRecord.class,
+                ProtectRecord.class, PasswordRecord.class, ProtectionRev4Record.class,
+                PasswordRev4Record.class, WindowOneRecord.class, BackupRecord.class,
+                HideObjRecord.class, DateWindow1904Record.class,
+                PrecisionRecord.class, RefreshAllRecord.class, BookBoolRecord.class,
+                FontRecord.class, FormatRecord.class, ExtendedFormatRecord.class,
+                StyleRecord.class, UseSelFSRecord.class, BoundSheetRecord.class,
+                CountryRecord.class, SSTRecord.class, ExtSSTRecord.class,
+                EOFRecord.class, IndexRecord.class, CalcModeRecord.class,
+                CalcCountRecord.class, RefModeRecord.class, IterationRecord.class,
+                DeltaRecord.class, SaveRecalcRecord.class, PrintHeadersRecord.class,
+                PrintGridlinesRecord.class, GridsetRecord.class, GutsRecord.class,
+                DefaultRowHeightRecord.class, WSBoolRecord.class, HeaderRecord.class,
+                FooterRecord.class, HCenterRecord.class, VCenterRecord.class,
+                PrintSetupRecord.class, DefaultColWidthRecord.class,
+                DimensionsRecord.class, RowRecord.class, LabelSSTRecord.class,
+                RKRecord.class, NumberRecord.class, DBCellRecord.class,
+                WindowTwoRecord.class, SelectionRecord.class, ContinueRecord.class,
+                LabelRecord.class, BlankRecord.class, ColumnInfoRecord.class,
+                MulRKRecord.class, MulBlankRecord.class, MergeCellsRecord.class,
+                BoolErrRecord.class
+            };
+            
+        }
+    }
     private static Map           recordsMap  = recordsToMap(records);
 
     /**