poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r683670 [2/4] - in /poi/branches/ooxml: ./ src/java/org/apache/poi/hssf/dev/ src/java/org/apache/poi/hssf/model/ src/java/org/apache/poi/hssf/record/ src/java/org/apache/poi/hssf/record/aggregates/ src/java/org/apache/poi/hssf/record/formul...
Date Thu, 07 Aug 2008 18:21:34 GMT
Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DatRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DatRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DatRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DatRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The dat record is used to store options for the chart.
@@ -30,15 +29,15 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class DatRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1063;
+public final class DatRecord extends Record {
+    public final static short sid = 0x1063;
+
+    private static final BitField horizontalBorder = BitFieldFactory.getInstance(0x1);
+    private static final BitField verticalBorder   = BitFieldFactory.getInstance(0x2);
+    private static final BitField border           = BitFieldFactory.getInstance(0x4);
+    private static final BitField showSeriesKey    = BitFieldFactory.getInstance(0x8);
+
     private  short      field_1_options;
-    private  BitField   horizontalBorder                            = BitFieldFactory.getInstance(0x1);
-    private  BitField   verticalBorder                              = BitFieldFactory.getInstance(0x2);
-    private  BitField   border                                      = BitFieldFactory.getInstance(0x4);
-    private  BitField   showSeriesKey                               = BitFieldFactory.getInstance(0x8);
 
 
     public DatRecord()
@@ -216,10 +215,4 @@
     {
         return showSeriesKey.isSet(field_1_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DataFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DataFormatRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DataFormatRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/DataFormatRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,30 +14,30 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The data format record is used to index into a series.
  * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
  *       remove the record in src/records/definitions.
-
+ *
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class DataFormatRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1006;
-    private  short      field_1_pointNumber;
-    private  short      field_2_seriesIndex;
-    private  short      field_3_seriesNumber;
-    private  short      field_4_formatFlags;
-    private  BitField   useExcel4Colors                             = BitFieldFactory.getInstance(0x1);
+public final class DataFormatRecord extends Record {
+    public final static short sid = 0x1006;
+
+    private static final BitField useExcel4Colors = BitFieldFactory.getInstance(0x1);
+
+    private short field_1_pointNumber;
+    private short field_2_seriesIndex;
+    private short field_3_seriesNumber;
+    private short field_4_formatFlags;
 
 
     public DataFormatRecord()
@@ -228,10 +227,4 @@
     {
         return useExcel4Colors.isSet(field_4_formatFlags);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FormulaRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,7 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
-/*
- * FormulaRecord.java
- *
- * Created on October 28, 2001, 5:44 PM
- */
 package org.apache.poi.hssf.record;
 
 import java.util.List;
@@ -39,24 +32,22 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 2.0-pre
  */
-
 public final class FormulaRecord
     extends Record
     implements CellValueRecordInterface, Comparable
 {
     
-    public static final short sid =
-        0x06;   // docs say 406...because of a bug Microsoft support site article #Q184647)
-    
-    //private short             field_1_row;
+    public static final short sid = 0x0006;   // docs say 406...because of a bug Microsoft support site article #Q184647)
+
+    private static final BitField alwaysCalc = BitFieldFactory.getInstance(0x0001);
+    private static final BitField calcOnLoad = BitFieldFactory.getInstance(0x0002);
+    private static final BitField sharedFormula = BitFieldFactory.getInstance(0x0008);    
+
     private int             field_1_row;
     private short             field_2_column;
     private short             field_3_xf;
     private double            field_4_value;
     private short             field_5_options;
-    private BitField          alwaysCalc = BitFieldFactory.getInstance(0x0001);
-    private BitField          calcOnLoad = BitFieldFactory.getInstance(0x0002);
-    private BitField          sharedFormula = BitFieldFactory.getInstance(0x0008);    
     private int               field_6_zero;
     private short             field_7_expression_len;
     private Stack             field_8_parsed_expr;

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FrameRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FrameRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FrameRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/FrameRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The frame record indicates whether there is a border around the displayed text of a chart.
@@ -30,16 +29,16 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class FrameRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1032;
+public final class FrameRecord extends Record {
+    public final static short sid  = 0x1032;
+
+    private static final BitField autoSize     = BitFieldFactory.getInstance(0x1);
+    private static final BitField autoPosition = BitFieldFactory.getInstance(0x2);
+
     private  short      field_1_borderType;
     public final static short       BORDER_TYPE_REGULAR            = 0;
     public final static short       BORDER_TYPE_SHADOW             = 1;
     private  short      field_2_options;
-    private  BitField   autoSize                                    = BitFieldFactory.getInstance(0x1);
-    private  BitField   autoPosition                                = BitFieldFactory.getInstance(0x2);
 
 
     public FrameRecord()
@@ -211,10 +210,4 @@
     {
         return autoPosition.isSet(field_2_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}
\ No newline at end of file

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/HorizontalPageBreakRecord.java Thu Aug  7 11:21:32 2008
@@ -1,60 +1,67 @@
-
 /* ====================================================================
-   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.
-==================================================================== */
-        
+ 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;
 
+import java.util.Iterator;
+
 /**
- * HorizontalPageBreak record that stores page breaks at rows
- * <p>
- * This class is just used so that SID compares work properly in the RecordFactory
+ * HorizontalPageBreak (0x001B) record that stores page breaks at rows <p/>
+ * 
  * @see PageBreakRecord
- * @author Danny Mui (dmui at apache dot org) 
+ * @author Danny Mui (dmui at apache dot org)
  */
-public class HorizontalPageBreakRecord extends PageBreakRecord {
+public final class HorizontalPageBreakRecord extends PageBreakRecord {
+
+	public static final short sid = 0x001B;
 
-    public static final short sid = PageBreakRecord.HORIZONTAL_SID; 
-    
 	/**
-	 * 
+	 * Creates an empty horizontal page break record
 	 */
 	public HorizontalPageBreakRecord() {
-		super();
+		//
 	}
 
 	/**
-	 * @param sid
-	 */
-	public HorizontalPageBreakRecord(short sid) {
-		super(sid);
-	}
-
-   /**
-     * @param in the RecordInputstream to read the record from
+	 * @param in
+	 *            the RecordInputstream to read the record from
 	 */
 	public HorizontalPageBreakRecord(RecordInputStream in) {
 		super(in);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.apache.poi.hssf.record.Record#getSid()
-	 */
+	protected void validateSid(short id) {
+		if (id != getSid()) {
+			throw new RecordFormatException(
+					"NOT A HorizontalPageBreak or VerticalPageBreak RECORD!! " + id);
+		}
+	}
+
 	public short getSid() {
 		return sid;
 	}
 
+	public Object clone() {
+		PageBreakRecord result = new HorizontalPageBreakRecord();
+		Iterator iterator = getBreaksIterator();
+		while (iterator.hasNext()) {
+			Break original = (Break) iterator.next();
+			result.addBreak(original.main, original.subFrom, original.subTo);
+		}
+		return result;
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LegendRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LegendRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LegendRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LegendRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * Defines a legend for a chart.
@@ -30,10 +29,16 @@
 
  * @author Andrew C. Oliver (acoliver at apache.org)
  */
-public class LegendRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1015;
+public final class LegendRecord extends Record {
+    public final static short sid = 0x1015;
+
+    private static final BitField autoPosition     = BitFieldFactory.getInstance(0x01);
+    private static final BitField autoSeries       = BitFieldFactory.getInstance(0x02);
+    private static final BitField autoXPositioning = BitFieldFactory.getInstance(0x04);
+    private static final BitField autoYPositioning = BitFieldFactory.getInstance(0x08);
+    private static final BitField vertical         = BitFieldFactory.getInstance(0x10);
+    private static final BitField dataTable        = BitFieldFactory.getInstance(0x20);
+
     private  int        field_1_xAxisUpperLeft;
     private  int        field_2_yAxisUpperLeft;
     private  int        field_3_xSize;
@@ -50,12 +55,6 @@
     public final static byte        SPACING_MEDIUM                 = 1;
     public final static byte        SPACING_OPEN                   = 2;
     private  short      field_7_options;
-    private  BitField   autoPosition                                = BitFieldFactory.getInstance(0x1);
-    private  BitField   autoSeries                                  = BitFieldFactory.getInstance(0x2);
-    private  BitField   autoXPositioning                            = BitFieldFactory.getInstance(0x4);
-    private  BitField   autoYPositioning                            = BitFieldFactory.getInstance(0x8);
-    private  BitField   vertical                                    = BitFieldFactory.getInstance(0x10);
-    private  BitField   dataTable                                   = BitFieldFactory.getInstance(0x20);
 
 
     public LegendRecord()
@@ -437,10 +436,4 @@
     {
         return dataTable.isSet(field_7_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LineFormatRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LineFormatRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LineFormatRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LineFormatRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * Describes a line format record.  The line format record controls how a line on a chart appears.
@@ -30,10 +29,13 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class LineFormatRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1007;
+public final class LineFormatRecord extends Record {
+    public final static short sid = 0x1007;
+
+    private static final BitField auto      = BitFieldFactory.getInstance(0x1);
+    private static final BitField drawTicks = BitFieldFactory.getInstance(0x4);
+    private static final BitField unknown   = BitFieldFactory.getInstance(0x4);
+
     private  int        field_1_lineColor;
     private  short      field_2_linePattern;
     public final static short       LINE_PATTERN_SOLID             = 0;
@@ -51,9 +53,6 @@
     public final static short       WEIGHT_MEDIUM                  = 1;
     public final static short       WEIGHT_WIDE                    = 2;
     private  short      field_4_format;
-    private  BitField   auto                                        = BitFieldFactory.getInstance(0x1);
-    private  BitField   drawTicks                                   = BitFieldFactory.getInstance(0x4);
-    private  BitField   unknown                                     = BitFieldFactory.getInstance(0x4);
     private  short      field_5_colourPaletteIndex;
 
 
@@ -342,10 +341,4 @@
     {
         return unknown.isSet(field_4_format);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/LinkedDataRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * Describes a linked data record.  This record referes to the series data or text.
@@ -30,10 +29,11 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class LinkedDataRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1051;
+public final class LinkedDataRecord extends Record {
+    public final static short sid  = 0x1051;
+
+    private static final BitField customNumberFormat= BitFieldFactory.getInstance(0x1);
+    
     private  byte       field_1_linkType;
     public final static byte        LINK_TYPE_TITLE_OR_TEXT        = 0;
     public final static byte        LINK_TYPE_VALUES               = 1;
@@ -45,7 +45,6 @@
     public final static byte        REFERENCE_TYPE_NOT_USED        = 3;
     public final static byte        REFERENCE_TYPE_ERROR_REPORTED  = 4;
     private  short      field_3_options;
-    private  BitField   customNumberFormat                          = BitFieldFactory.getInstance(0x1);
     private  short      field_4_indexNumberFmtRecord;
     private  LinkedDataFormulaField field_5_formulaOfLink;
 
@@ -86,7 +85,7 @@
         field_2_referenceType          = in.readByte();
         field_3_options                = in.readShort();
         field_4_indexNumberFmtRecord   = in.readShort();
-        field_5_formulaOfLink = new org.apache.poi.hssf.record.LinkedDataFormulaField();
+        field_5_formulaOfLink = new LinkedDataFormulaField();
         field_5_formulaOfLink.fillField(in);
     }
 
@@ -156,7 +155,7 @@
         rec.field_2_referenceType = field_2_referenceType;
         rec.field_3_options = field_3_options;
         rec.field_4_indexNumberFmtRecord = field_4_indexNumberFmtRecord;
-        rec.field_5_formulaOfLink = ((org.apache.poi.hssf.record.LinkedDataFormulaField)field_5_formulaOfLink.clone());;
+        rec.field_5_formulaOfLink = ((LinkedDataFormulaField)field_5_formulaOfLink.clone());;
         return rec;
     }
 
@@ -286,10 +285,4 @@
     {
         return customNumberFormat.isSet(field_3_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/MergeCellsRecord.java Thu Aug  7 11:21:32 2008
@@ -32,68 +32,51 @@
  */
 public final class MergeCellsRecord extends Record {
     public final static short sid = 0x00E5;
-    private CellRangeAddressList _regions;
-
-    /** 
-     * Creates an empty <tt>MergedCellsRecord</tt>
-     */
-    public MergeCellsRecord() {
-    	_regions = new CellRangeAddressList();
+    /** sometimes the regions array is shared with other MergedCellsRecords */ 
+    private CellRangeAddress[] _regions;
+    private final int _startIndex;
+    private final int _numberOfRegions;
+
+    public MergeCellsRecord(CellRangeAddress[] regions, int startIndex, int numberOfRegions) {
+		_regions = regions;
+		_startIndex = startIndex;
+		_numberOfRegions = numberOfRegions;
     }
-
     /**
      * Constructs a MergedCellsRecord and sets its fields appropriately
      * @param in the RecordInputstream to read the record from
      */
     public MergeCellsRecord(RecordInputStream in) {
-        super(in);
+     	int nRegions = in.readUShort();
+    	CellRangeAddress[] cras = new CellRangeAddress[nRegions];
+    	for (int i = 0; i < nRegions; i++) {
+			cras[i] = new org.apache.poi.hssf.util.CellRangeAddress(in);
+		}
+    	_numberOfRegions = nRegions;
+    	_startIndex = 0;
+    	_regions = cras;
     }
-
     protected void fillFields(RecordInputStream in) {
-    	_regions = new org.apache.poi.hssf.util.CellRangeAddressList(in);
+    	throw new RuntimeException("obsolete");
     }
-
     /**
      * get the number of merged areas.  If this drops down to 0 you should just go
      * ahead and delete the record.
      * @return number of areas
      */
     public short getNumAreas() {
-        return (short)_regions.countRanges();
-    }
-
-    /**
-     * Add an area to consider a merged cell.  The index returned is only gauranteed to
-     * be correct provided you do not add ahead of or remove ahead of it  (in which case
-     * you should increment or decrement appropriately....in other words its an arrayList)
-     *
-     * @param firstRow - the upper left hand corner's row
-     * @param firstCol - the upper left hand corner's col
-     * @param lastRow - the lower right hand corner's row
-     * @param lastCol - the lower right hand corner's col
-     * @return new index of said area (don't depend on it if you add/remove)
-     */
-    public void addArea(int firstRow, int firstCol, int lastRow, int lastCol) {
-    	_regions.addCellRangeAddress(firstRow, firstCol, lastRow, lastCol);
-    }
-
-    /**
-     * essentially unmerge the cells in the "area" stored at the passed in index
-     * @param areaIndex
-     */
-    public void removeAreaAt(int areaIndex) {
-        _regions.remove(areaIndex);
+        return (short)_numberOfRegions;
     }
 
     /**
      * @return MergedRegion at the given index representing the area that is Merged (r1,c1 - r2,c2)
      */
     public CellRangeAddress getAreaAt(int index) {
-        return _regions.getCellRangeAddress(index);
+        return _regions[_startIndex + index];
     }
 
     public int getRecordSize() {
-    	return 4 + _regions.getSize();
+    	return 4 + CellRangeAddressList.getEncodedSize(_numberOfRegions);
     }
 
     public short getSid() {
@@ -101,11 +84,16 @@
     }
 
     public int serialize(int offset, byte [] data) {
-        int dataSize = _regions.getSize();
+        int dataSize = CellRangeAddressList.getEncodedSize(_numberOfRegions);
 
-        LittleEndian.putShort(data, offset + 0, sid);
+        LittleEndian.putUShort(data, offset + 0, sid);
         LittleEndian.putUShort(data, offset + 2, dataSize);
-        _regions.serialize(offset + 4, data);
+        int nItems = _numberOfRegions;
+        LittleEndian.putUShort(data, offset + 4, nItems);
+        int pos = 6;
+        for (int i = 0; i < _numberOfRegions; i++) {
+			pos += _regions[_startIndex + i].serialize(offset+pos, data);
+		}
         return 4 + dataSize;
     }
 
@@ -113,17 +101,16 @@
         StringBuffer retval = new StringBuffer();
 
         retval.append("[MERGEDCELLS]").append("\n");
-        retval.append("     .sid        =").append(sid).append("\n");
         retval.append("     .numregions =").append(getNumAreas())
             .append("\n");
-        for (int k = 0; k < _regions.countRanges(); k++) {
-            CellRangeAddress region = _regions.getCellRangeAddress(k);
+        for (int k = 0; k < _numberOfRegions; k++) {
+            CellRangeAddress region = _regions[_startIndex + k];
 
             retval.append("     .rowfrom    =").append(region.getFirstRow())
                 .append("\n");
-            retval.append("     .colfrom    =").append(region.getFirstColumn())
-                .append("\n");
             retval.append("     .rowto      =").append(region.getLastRow())
+            	.append("\n");
+            retval.append("     .colfrom    =").append(region.getFirstColumn())
                 .append("\n");
             retval.append("     .colto      =").append(region.getLastColumn())
                 .append("\n");
@@ -140,13 +127,11 @@
     }
 
     public Object clone() {
-        MergeCellsRecord rec = new MergeCellsRecord();        
-        for (int k = 0; k < _regions.countRanges(); k++) {
-            CellRangeAddress oldRegion = _regions.getCellRangeAddress(k);
-           rec.addArea(oldRegion.getFirstRow(), oldRegion.getFirstColumn(), 
-        		   oldRegion.getLastRow(), oldRegion.getLastColumn());
-        }
-        
-        return rec;
+    	int nRegions = _numberOfRegions;
+    	CellRangeAddress[] clonedRegions = new CellRangeAddress[nRegions];
+		for (int i = 0; i < clonedRegions.length; i++) {
+			clonedRegions[i] = _regions[_startIndex + i].copy();
+		}
+        return new MergeCellsRecord(clonedRegions, 0, nRegions);
     }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/PageBreakRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/PageBreakRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/PageBreakRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/PageBreakRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,11 +14,10 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hssf.record;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -29,140 +27,128 @@
 
 /**
  * <p>Record that contains the functionality page breaks (horizontal and vertical)</p>
- * 
+ *
  * <p>The other two classes just specifically set the SIDS for record creation.</p>
- * 
+ *
  * <p>REFERENCE:  Microsoft Excel SDK page 322 and 420</p>
- * 
+ *
  * @see HorizontalPageBreakRecord
  * @see VerticalPageBreakRecord
  * @author Danny Mui (dmui at apache dot org)
  */
-public class PageBreakRecord extends Record {
-   public static final short HORIZONTAL_SID = (short)0x1B;
-   public static final short VERTICAL_SID = (short)0x1A;
-   public short sid;
-   private short numBreaks;
-   private List breaks;
-   private Map BreakMap;
-      
+public abstract class PageBreakRecord extends Record {
+    private static final boolean IS_EMPTY_RECORD_WRITTEN = false;
+    private static final int[] EMPTY_INT_ARRAY = { };
+
+    private List _breaks;
+    private Map _breakMap;
+
     /**
-     * Since both records store 2byte integers (short), no point in 
+     * Since both records store 2byte integers (short), no point in
      * differentiating it in the records.
      * <p>
      * The subs (rows or columns, don't seem to be able to set but excel sets
      * them automatically)
      */
-    public class Break
-    {
+    public class Break {
 
-        public short main;
-        public short subFrom;
-        public short subTo;
+        public static final int ENCODED_SIZE = 6;
+        public int main;
+        public int subFrom;
+        public int subTo;
 
-        public Break(short main, short subFrom, short subTo)
+        public Break(int main, int subFrom, int subTo)
         {
             this.main = main;
             this.subFrom = subFrom;
             this.subTo = subTo;
         }
-    }
 
-    public PageBreakRecord()
-    {
+        public Break(RecordInputStream in) {
+            main = in.readUShort() - 1;
+            subFrom = in.readUShort();
+            subTo = in.readUShort();
+        }
 
+        public int serialize(int offset, byte[] data) {
+            LittleEndian.putUShort(data, offset + 0, main + 1);
+            LittleEndian.putUShort(data, offset + 2, subFrom);
+            LittleEndian.putUShort(data, offset + 4, subTo);
+            return ENCODED_SIZE;
+        }
     }
 
-    /**
-     * 
-     * @param sid
-     */
-    public PageBreakRecord(short sid) {
-       super();
-       this.sid = sid;
+    protected PageBreakRecord() {
+        _breaks = new ArrayList();
+        _breakMap = new HashMap();
     }
 
-    public PageBreakRecord(RecordInputStream in)
-    {
+    protected PageBreakRecord(RecordInputStream in) {
         super(in);
-        this.sid = in.getSid();
     }
 
     protected void fillFields(RecordInputStream in)
     {
-        short loadedBreaks = in.readShort();
-        setNumBreaks(loadedBreaks);
-        for(int k = 0; k < loadedBreaks; k++)
-        {
-            addBreak((short)(in.readShort()-1), in.readShort(), in.readShort());
+        int nBreaks = in.readShort();
+        _breaks = new ArrayList(nBreaks + 2);
+        _breakMap = new HashMap();
+
+        for(int k = 0; k < nBreaks; k++) {
+            Break br = new Break(in);
+            _breaks.add(br);
+            _breakMap.put(new Integer(br.main), br);
         }
 
     }
 
-    public short getSid()
-    {
-        return sid;
+    private int getDataSize() {
+        return 2 + _breaks.size() * Break.ENCODED_SIZE;
+    }
+    public int getRecordSize() {
+        int nBreaks = _breaks.size();
+        if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
+            return 0;
+        }
+        return 4 + getDataSize();
     }
 
-    public int serialize(int offset, byte data[])
-    {
-        int recordsize = getRecordSize();
+
+    public final int serialize(int offset, byte data[]) {
+        int nBreaks = _breaks.size();
+        if (!IS_EMPTY_RECORD_WRITTEN && nBreaks < 1) {
+            return 0;
+        }
+        int dataSize = getDataSize();
+        LittleEndian.putUShort(data, offset + 0, getSid());
+        LittleEndian.putUShort(data, offset + 2, dataSize);
+        LittleEndian.putUShort(data, offset + 4, nBreaks);
         int pos = 6;
-        LittleEndian.putShort(data, offset + 0, getSid());
-        LittleEndian.putShort(data, offset + 2, (short)(recordsize - 4));
-        LittleEndian.putShort(data, offset + 4, getNumBreaks());
-        for(Iterator iterator = getBreaksIterator(); iterator.hasNext();)
-        {
-            Break Break = (Break)iterator.next();
-            LittleEndian.putShort(data, offset + pos, (short)(Break.main + 1));
-            pos += 2;
-            LittleEndian.putShort(data, offset + pos, Break.subFrom);
-            pos += 2;
-            LittleEndian.putShort(data, offset + pos, Break.subTo);
-            pos += 2;
+        for (int i=0; i<nBreaks; i++) {
+            Break br = (Break)_breaks.get(i);
+            pos += br.serialize(offset+pos, data);
         }
 
-        return recordsize;
+        return 4 + dataSize;
     }
 
-    protected void validateSid(short id)
-    {
-        if(id != HORIZONTAL_SID && id != VERTICAL_SID)
-            throw new RecordFormatException("NOT A HorizontalPageBreak or VerticalPageBreak RECORD!! " + id);
-        else
-            return;
-    }
-
-    public short getNumBreaks()
-    {
-        return breaks != null ? (short)breaks.size() : numBreaks;
+    public int getNumBreaks() {
+        return _breaks.size();
     }
 
-    public void setNumBreaks(short numBreaks)
-    {
-        this.numBreaks = numBreaks;
-    }
-
-    public Iterator getBreaksIterator()
-    {
-        if(breaks == null)
-            return Collections.EMPTY_LIST.iterator();
-        else
-            return breaks.iterator();
+    public final Iterator getBreaksIterator() {
+        return _breaks.iterator();
     }
 
     public String toString()
     {
         StringBuffer retval = new StringBuffer();
-        
-        if (getSid() != HORIZONTAL_SID && getSid()!= VERTICAL_SID) 
-            return "[INVALIDPAGEBREAK]\n     .sid ="+getSid()+"[INVALIDPAGEBREAK]";
-        
+
+
         String label;
         String mainLabel;
         String subLabel;
-        
-        if (getSid() == HORIZONTAL_SID) {
+
+        if (getSid() == HorizontalPageBreakRecord.sid) {
            label = "HORIZONTALPAGEBREAK";
            mainLabel = "row";
            subLabel = "col";
@@ -171,7 +157,7 @@
            mainLabel = "column";
            subLabel = "row";
         }
-        
+
         retval.append("["+label+"]").append("\n");
         retval.append("     .sid        =").append(getSid()).append("\n");
         retval.append("     .numbreaks =").append(getNumBreaks()).append("\n");
@@ -179,7 +165,7 @@
         for(int k = 0; k < getNumBreaks(); k++)
         {
             Break region = (Break)iterator.next();
-            
+
             retval.append("     .").append(mainLabel).append(" (zero-based) =").append(region.main).append("\n");
             retval.append("     .").append(subLabel).append("From    =").append(region.subFrom).append("\n");
             retval.append("     .").append(subLabel).append("To      =").append(region.subTo).append("\n");
@@ -192,46 +178,33 @@
    /**
     * Adds the page break at the specified parameters
     * @param main Depending on sid, will determine row or column to put page break (zero-based)
-    * @param subFrom No user-interface to set (defaults to minumum, 0)
+    * @param subFrom No user-interface to set (defaults to minimum, 0)
     * @param subTo No user-interface to set
     */
-    public void addBreak(short main, short subFrom, short subTo)
-    {
-        if(breaks == null)
-        {
-            breaks = new ArrayList(getNumBreaks() + 10);
-            BreakMap = new HashMap();
-        }
+    public void addBreak(int main, int subFrom, int subTo) {
+
         Integer key = new Integer(main);
-        Break region = (Break)BreakMap.get(key);
-        if(region != null)
-        {
+        Break region = (Break)_breakMap.get(key);
+        if(region == null) {
+            region = new Break(main, subFrom, subTo);
+            _breakMap.put(key, region);
+            _breaks.add(region);
+        } else {
             region.main = main;
             region.subFrom = subFrom;
             region.subTo = subTo;
-        } else
-        {
-            region = new Break(main, subFrom, subTo);
-            breaks.add(region);
         }
-        BreakMap.put(key, region);
     }
 
     /**
      * Removes the break indicated by the parameter
      * @param main (zero-based)
      */
-    public void removeBreak(short main)
-    {
+    public final void removeBreak(int main) {
         Integer rowKey = new Integer(main);
-        Break region = (Break)BreakMap.get(rowKey);
-        breaks.remove(region);
-        BreakMap.remove(rowKey);
-    }
-
-    public int getRecordSize()
-    {
-        return 6 + getNumBreaks() * 6;
+        Break region = (Break)_breakMap.get(rowKey);
+        _breaks.remove(region);
+        _breakMap.remove(rowKey);
     }
 
     /**
@@ -239,26 +212,21 @@
      * @param main FIXME: Document this!
      * @return The Break or null if no break exists at the row/col specified.
      */
-    public Break getBreak(short main)
-    {
-    	if (BreakMap == null)
-    		return null;
+    public final Break getBreak(int main) {
         Integer rowKey = new Integer(main);
-        return (Break)BreakMap.get(rowKey);
+        return (Break)_breakMap.get(rowKey);
     }
 
-   /* Clones the page break record 
-    * @see java.lang.Object#clone()
-    */
-   public Object clone() {
-      PageBreakRecord record = new PageBreakRecord(getSid());      
-      Iterator iterator = getBreaksIterator();
-      while (iterator.hasNext()) {
-         Break original = (Break)iterator.next();
-         record.addBreak(original.main, original.subFrom, original.subTo);
-      }
-      return record;
-   }
-
-    
+    public final int[] getBreaks() {
+        int count = getNumBreaks();
+        if (count < 1) {
+            return EMPTY_INT_ARRAY;
+        }
+        int[] result = new int[count];
+        for (int i=0; i<count; i++) {
+            Break breakItem = (Break)_breaks.get(i);
+            result[i] = breakItem.main;
+        }
+        return result;
+    }
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/Record.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/Record.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/Record.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/Record.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
@@ -32,15 +30,13 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 2.0-pre
  */
-
-public abstract class Record
-{
+public abstract class Record extends RecordBase {
 
     /**
      * instantiates a blank record strictly for ID matching
      */
 
-    public Record()
+    protected Record()
     {
     }
 
@@ -49,7 +45,7 @@
      *
      * @param in the RecordInputstream to read the record from
      */
-    public Record(RecordInputStream in)
+    protected Record(RecordInputStream in)
     {
         validateSid(in.getSid());
         fillFields(in);
@@ -89,17 +85,6 @@
         return retval;
     }
 
-    /**
-     * 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 abstract int serialize(int offset, byte [] data);
 
     /**
      * gives the current serialized size of the record. Should include the sid and reclength (4 bytes).

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SeriesLabelsRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The series label record defines the type of label associated with the data format record.
@@ -30,18 +29,17 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class SeriesLabelsRecord
-    extends Record
-{
-    public final static short      sid                             = 0x100c;
-    private  short      field_1_formatFlags;
-    private  BitField   showActual                                  = BitFieldFactory.getInstance(0x1);
-    private  BitField   showPercent                                 = BitFieldFactory.getInstance(0x2);
-    private  BitField   labelAsPercentage                           = BitFieldFactory.getInstance(0x4);
-    private  BitField   smoothedLine                                = BitFieldFactory.getInstance(0x8);
-    private  BitField   showLabel                                   = BitFieldFactory.getInstance(0x10);
-    private  BitField   showBubbleSizes                             = BitFieldFactory.getInstance(0x20);
+public final class SeriesLabelsRecord extends Record {
+    public final static short      sid = 0x100c;
+
+    private static final BitField showActual        = BitFieldFactory.getInstance(0x01);
+    private static final BitField showPercent       = BitFieldFactory.getInstance(0x02);
+    private static final BitField labelAsPercentage = BitFieldFactory.getInstance(0x04);
+    private static final BitField smoothedLine      = BitFieldFactory.getInstance(0x08);
+    private static final BitField showLabel         = BitFieldFactory.getInstance(0x10);
+    private static final BitField showBubbleSizes   = BitFieldFactory.getInstance(0x20);
 
+    private  short      field_1_formatFlags;
 
     public SeriesLabelsRecord()
     {
@@ -256,10 +254,4 @@
     {
         return showBubbleSizes.isSet(field_1_formatFlags);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/SheetPropertiesRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * Describes a chart sheet properties record.
@@ -30,16 +29,16 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class SheetPropertiesRecord
-    extends Record
-{
-    public final static short      sid                             = 0x1044;
+public final class SheetPropertiesRecord extends Record {
+    public final static short sid = 0x1044;
+    
+    private static final BitField chartTypeManuallyFormatted = BitFieldFactory.getInstance(0x01);
+    private static final BitField plotVisibleOnly            = BitFieldFactory.getInstance(0x02);
+    private static final BitField doNotSizeWithWindow        = BitFieldFactory.getInstance(0x04);
+    private static final BitField defaultPlotDimensions      = BitFieldFactory.getInstance(0x08);
+    private static final BitField autoPlotArea               = BitFieldFactory.getInstance(0x10);
+    
     private  short      field_1_flags;
-    private  BitField   chartTypeManuallyFormatted                  = BitFieldFactory.getInstance(0x1);
-    private  BitField   plotVisibleOnly                             = BitFieldFactory.getInstance(0x2);
-    private  BitField   doNotSizeWithWindow                         = BitFieldFactory.getInstance(0x4);
-    private  BitField   defaultPlotDimensions                       = BitFieldFactory.getInstance(0x8);
-    private  BitField   autoPlotArea                                = BitFieldFactory.getInstance(0x10);
     private  byte       field_2_empty;
     public final static byte        EMPTY_NOT_PLOTTED              = 0;
     public final static byte        EMPTY_ZERO                     = 1;
@@ -274,10 +273,4 @@
     {
         return autoPlotArea.isSet(field_1_flags);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/StyleRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/StyleRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/StyleRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/StyleRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,14 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-import org.apache.poi.util.LittleEndian;
-import org.apache.poi.util.StringUtil;
 import org.apache.poi.util.BitField;
 import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.StringUtil;
 
 /**
  * Title:        Style Record<P>
@@ -32,11 +30,11 @@
  * @author aviks : string fixes for UserDefined Style
  * @version 2.0-pre
  */
+public final class StyleRecord extends Record {
+    public final static short sid = 0x0293;
+
+    private static final BitField fHighByte = BitFieldFactory.getInstance(0x01);
 
-public class StyleRecord
-    extends Record
-{
-    public final static short sid                = 0x293;
     public final static short STYLE_USER_DEFINED = 0;
     public final static short STYLE_BUILT_IN     = 1;
 
@@ -50,7 +48,6 @@
     // only for user defined styles
     private short              field_2_name_length; //OO doc says 16 bit length, so we believe
     private byte               field_3_string_options;
-    private BitField fHighByte;
     private String             field_4_name;
 
     public StyleRecord()
@@ -77,8 +74,6 @@
 
     protected void fillFields(RecordInputStream in)
     {
-        fHighByte = BitFieldFactory.getInstance(0x01); //have to init here, since we are being called
-                                        //from super, and class level init hasnt been done. 
         field_1_xf_index = in.readShort();
         if (getType() == STYLE_BUILT_IN)
         {

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TableRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TableRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TableRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TableRecord.java Thu Aug  7 11:21:32 2008
@@ -14,8 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
+package org.apache.poi.hssf.record;
+
+import org.apache.poi.hssf.record.formula.TblPtg;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.LittleEndian;
 /**
  * TableRecord - The record specifies a data table.
  * This record is preceded by a single Formula record that
@@ -24,15 +29,18 @@
  * 
  * See p536 of the June 08 binary docs
  */
-package org.apache.poi.hssf.record;
-
-import org.apache.poi.hssf.record.formula.TblPtg;
-import org.apache.poi.util.BitField;
-import org.apache.poi.util.BitFieldFactory;
-import org.apache.poi.util.LittleEndian;
-
-public class TableRecord extends Record {
+public final class TableRecord extends Record {
     public static final short sid = 566;
+    
+    private static final BitField alwaysCalc      = BitFieldFactory.getInstance(0x0001);
+    private static final BitField reserved1       = BitFieldFactory.getInstance(0x0002);
+    private static final BitField rowOrColInpCell = BitFieldFactory.getInstance(0x0004);
+    private static final BitField oneOrTwoVar     = BitFieldFactory.getInstance(0x0008);
+    private static final BitField rowDeleted      = BitFieldFactory.getInstance(0x0010);
+    private static final BitField colDeleted      = BitFieldFactory.getInstance(0x0020);
+    private static final BitField reserved2       = BitFieldFactory.getInstance(0x0040);
+    private static final BitField reserved3       = BitFieldFactory.getInstance(0x0080);
+    
     private short field_1_ref_rowFirst;
     private short field_2_ref_rowLast;
     private short field_3_ref_colFirst;
@@ -45,14 +53,6 @@
     private short field_9_rowInputCol;
     private short field_10_colInputCol;
     
-    private BitField alwaysCalc      = BitFieldFactory.getInstance(0x0001);
-    private BitField reserved1       = BitFieldFactory.getInstance(0x0002);
-    private BitField rowOrColInpCell = BitFieldFactory.getInstance(0x0004);
-    private BitField oneOrTwoVar     = BitFieldFactory.getInstance(0x0008);
-    private BitField rowDeleted      = BitFieldFactory.getInstance(0x0010);
-    private BitField colDeleted      = BitFieldFactory.getInstance(0x0020);
-    private BitField reserved2       = BitFieldFactory.getInstance(0x0040);
-    private BitField reserved3       = BitFieldFactory.getInstance(0x0080);
 
 	protected void fillFields(RecordInputStream in) {
 		field_1_ref_rowFirst = in.readShort();

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextObjectBaseRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextObjectBaseRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextObjectBaseRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextObjectBaseRecord.java Thu Aug  7 11:21:32 2008
@@ -32,25 +32,25 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class TextObjectBaseRecord
-    extends Record
-{
+public class TextObjectBaseRecord extends Record {
     public final static short      sid                             = 0x1B6;
+    
+    private static final BitField reserved1               = BitFieldFactory.getInstance(0x0001);
+    private static final BitField HorizontalTextAlignment = BitFieldFactory.getInstance(0x000E);
+    private static final BitField VerticalTextAlignment   = BitFieldFactory.getInstance(0x0070);
+    private static final BitField reserved2               = BitFieldFactory.getInstance(0x0180);
+    private static final BitField textLocked              = BitFieldFactory.getInstance(0x0200);
+    private static final BitField reserved3               = BitFieldFactory.getInstance(0xFC00);
+    
     private  short      field_1_options;
-    private  BitField   reserved1                                   = BitFieldFactory.getInstance(0x1);
-    private BitField   HorizontalTextAlignment                    = BitFieldFactory.getInstance(0x000E);
     public final static short  HORIZONTAL_TEXT_ALIGNMENT_LEFT_ALIGNED = 1;
     public final static short  HORIZONTAL_TEXT_ALIGNMENT_CENTERED = 2;
     public final static short  HORIZONTAL_TEXT_ALIGNMENT_RIGHT_ALIGNED = 3;
     public final static short  HORIZONTAL_TEXT_ALIGNMENT_JUSTIFIED = 4;
-    private BitField   VerticalTextAlignment                      = BitFieldFactory.getInstance(0x0070);
     public final static short  VERTICAL_TEXT_ALIGNMENT_TOP    = 1;
     public final static short  VERTICAL_TEXT_ALIGNMENT_CENTER = 2;
     public final static short  VERTICAL_TEXT_ALIGNMENT_BOTTOM = 3;
     public final static short  VERTICAL_TEXT_ALIGNMENT_JUSTIFY = 4;
-    private BitField   reserved2                                  = BitFieldFactory.getInstance(0x0180);
-    private  BitField   textLocked                                  = BitFieldFactory.getInstance(0x200);
-    private BitField   reserved3                                  = BitFieldFactory.getInstance(0xFC00);
     private  short      field_2_textOrientation;
     public final static short       TEXT_ORIENTATION_NONE          = 0;
     public final static short       TEXT_ORIENTATION_TOP_TO_BOTTOM = 1;
@@ -452,10 +452,4 @@
     {
         return reserved3.getShortValue(field_1_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TextRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The text record is used to define text stored on a chart.
@@ -30,10 +29,26 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class TextRecord
-    extends Record
-{
+public final class TextRecord extends Record {
     public final static short      sid                             = 0x1025;
+    
+    private static final BitField dataLabelPlacement            = BitFieldFactory.getInstance(0x000F);
+    private static final BitField autoColor                     = BitFieldFactory.getInstance(0x0001);
+    private static final BitField showKey                       = BitFieldFactory.getInstance(0x0002);
+    private static final BitField showValue                     = BitFieldFactory.getInstance(0x0004);
+    private static final BitField vertical                      = BitFieldFactory.getInstance(0x0008);
+    private static final BitField autoGeneratedText             = BitFieldFactory.getInstance(0x0010);
+    private static final BitField generated                     = BitFieldFactory.getInstance(0x0020);
+    private static final BitField autoLabelDeleted              = BitFieldFactory.getInstance(0x0040);
+    private static final BitField autoBackground                = BitFieldFactory.getInstance(0x0080);
+    private static final BitField rotation                      = BitFieldFactory.getInstance(0x0700);
+
+    private static final BitField showCategoryLabelAsPercentage = BitFieldFactory.getInstance(0x0800);
+    private static final BitField showValueAsPercentage         = BitFieldFactory.getInstance(0x1000);
+    private static final BitField showBubbleSizes               = BitFieldFactory.getInstance(0x2000);
+    private static final BitField showLabel                     = BitFieldFactory.getInstance(0x4000);
+    
+    
     private  byte       field_1_horizontalAlignment;
     public final static byte        HORIZONTAL_ALIGNMENT_LEFT      = 1;
     public final static byte        HORIZONTAL_ALIGNMENT_CENTER    = 2;
@@ -53,26 +68,12 @@
     private  int        field_7_width;
     private  int        field_8_height;
     private  short      field_9_options1;
-    private  BitField   autoColor                                   = BitFieldFactory.getInstance(0x1);
-    private  BitField   showKey                                     = BitFieldFactory.getInstance(0x2);
-    private  BitField   showValue                                   = BitFieldFactory.getInstance(0x4);
-    private  BitField   vertical                                    = BitFieldFactory.getInstance(0x8);
-    private  BitField   autoGeneratedText                           = BitFieldFactory.getInstance(0x10);
-    private  BitField   generated                                   = BitFieldFactory.getInstance(0x20);
-    private  BitField   autoLabelDeleted                            = BitFieldFactory.getInstance(0x40);
-    private  BitField   autoBackground                              = BitFieldFactory.getInstance(0x80);
-    private BitField   rotation                                   = BitFieldFactory.getInstance(0x0700);
     public final static short  ROTATION_NONE                  = 0;
     public final static short  ROTATION_TOP_TO_BOTTOM         = 1;
     public final static short  ROTATION_ROTATED_90_DEGREES    = 2;
     public final static short  ROTATION_ROTATED_90_DEGREES_CLOCKWISE = 3;
-    private  BitField   showCategoryLabelAsPercentage               = BitFieldFactory.getInstance(0x800);
-    private  BitField   showValueAsPercentage                       = BitFieldFactory.getInstance(0x1000);
-    private  BitField   showBubbleSizes                             = BitFieldFactory.getInstance(0x2000);
-    private  BitField   showLabel                                   = BitFieldFactory.getInstance(0x4000);
     private  short      field_10_indexOfColorValue;
     private  short      field_11_options2;
-    private BitField   dataLabelPlacement                         = BitFieldFactory.getInstance(0x000F);
     public final static short  DATA_LABEL_PLACEMENT_CHART_DEPENDENT = 0;
     public final static short  DATA_LABEL_PLACEMENT_OUTSIDE   = 1;
     public final static short  DATA_LABEL_PLACEMENT_INSIDE    = 2;
@@ -740,10 +741,4 @@
     {
         return dataLabelPlacement.getShortValue(field_11_options2);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TickRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TickRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TickRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/TickRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The Tick record defines how tick marks and label positioning/formatting
@@ -30,10 +29,14 @@
 
  * @author Andrew C. Oliver(acoliver at apache.org)
  */
-public class TickRecord
-    extends Record
-{
-    public final static short      sid                             = 0x101e;
+public final class TickRecord extends Record {
+    public final static short sid = 0x101E;
+    
+    private static final BitField autoTextColor      = BitFieldFactory.getInstance(0x1);
+    private static final BitField autoTextBackground = BitFieldFactory.getInstance(0x2);
+    private static final BitField rotation           = BitFieldFactory.getInstance(0x1c);
+    private static final BitField autorotate         = BitFieldFactory.getInstance(0x20);
+    
     private  byte       field_1_majorTickType;
     private  byte       field_2_minorTickType;
     private  byte       field_3_labelPosition;
@@ -44,10 +47,6 @@
     private  int        field_8_zero3;
     private  int        field_9_zero4;
     private  short      field_10_options;
-    private  BitField   autoTextColor                               = BitFieldFactory.getInstance(0x1);
-    private  BitField   autoTextBackground                          = BitFieldFactory.getInstance(0x2);
-    private BitField   rotation                                   = BitFieldFactory.getInstance(0x1c);
-    private  BitField   autorotate                                  = BitFieldFactory.getInstance(0x20);
     private  short      field_11_tickColor;
     private  short      field_12_zero5;
 
@@ -442,10 +441,4 @@
     {
         return autorotate.isSet(field_10_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,13 +14,13 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
-
-
-import org.apache.poi.util.*;
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.BitFieldFactory;
+import org.apache.poi.util.HexDump;
+import org.apache.poi.util.LittleEndian;
 
 /**
  * The value range record defines the range of the value axis.
@@ -30,25 +29,25 @@
 
  * @author Glen Stampoultzis (glens at apache.org)
  */
-public class ValueRangeRecord
-    extends Record
-{
-    public final static short      sid                             = 0x101f;
+public final class ValueRangeRecord extends Record {
+    public final static short sid = 0x101f;
+    
+    private static final BitField automaticMinimum           = BitFieldFactory.getInstance(0x0001);
+    private static final BitField automaticMaximum           = BitFieldFactory.getInstance(0x0002);
+    private static final BitField automaticMajor             = BitFieldFactory.getInstance(0x0004);
+    private static final BitField automaticMinor             = BitFieldFactory.getInstance(0x0008);
+    private static final BitField automaticCategoryCrossing  = BitFieldFactory.getInstance(0x0010);
+    private static final BitField logarithmicScale           = BitFieldFactory.getInstance(0x0020);
+    private static final BitField valuesInReverse            = BitFieldFactory.getInstance(0x0040);
+    private static final BitField crossCategoryAxisAtMaximum = BitFieldFactory.getInstance(0x0080);
+    private static final BitField reserved                   = BitFieldFactory.getInstance(0x0100);
+    
     private  double     field_1_minimumAxisValue;
     private  double     field_2_maximumAxisValue;
     private  double     field_3_majorIncrement;
     private  double     field_4_minorIncrement;
     private  double     field_5_categoryAxisCross;
     private  short      field_6_options;
-    private  BitField   automaticMinimum                            = BitFieldFactory.getInstance(0x1);
-    private  BitField   automaticMaximum                            = BitFieldFactory.getInstance(0x2);
-    private  BitField   automaticMajor                              = BitFieldFactory.getInstance(0x4);
-    private  BitField   automaticMinor                              = BitFieldFactory.getInstance(0x8);
-    private  BitField   automaticCategoryCrossing                   = BitFieldFactory.getInstance(0x10);
-    private  BitField   logarithmicScale                            = BitFieldFactory.getInstance(0x20);
-    private  BitField   valuesInReverse                             = BitFieldFactory.getInstance(0x40);
-    private  BitField   crossCategoryAxisAtMaximum                  = BitFieldFactory.getInstance(0x80);
-    private  BitField   reserved                                    = BitFieldFactory.getInstance(0x100);
 
 
     public ValueRangeRecord()
@@ -432,10 +431,4 @@
     {
         return reserved.isSet(field_6_options);
     }
-
-
-}  // END OF CLASS
-
-
-
-
+}

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/VerticalPageBreakRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,46 +14,53 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
+
 package org.apache.poi.hssf.record;
 
+import java.util.Iterator;
+
 /**
- * VerticalPageBreak record that stores page breaks at columns
- * <p>
- * This class is just used so that SID compares work properly in the RecordFactory
+ * VerticalPageBreak (0x001A) record that stores page breaks at columns<p/>
+ * 
  * @see PageBreakRecord
- * @author Danny Mui (dmui at apache dot org) 
+ * @author Danny Mui (dmui at apache dot org)
  */
-public class VerticalPageBreakRecord extends PageBreakRecord {
-	
-    public static final short sid = PageBreakRecord.VERTICAL_SID;
-    
+public final class VerticalPageBreakRecord extends PageBreakRecord {
+
+	public static final short sid = 0x001A;
+
 	/**
-	 * 
+	 * Creates an empty vertical page break record
 	 */
 	public VerticalPageBreakRecord() {
-		super();
-	}
 
-	/**
-	 * @param sid
-	 */
-	public VerticalPageBreakRecord(short sid) {
-		super(sid);
 	}
 
 	/**
-     * @param in the RecordInputstream to read the record from
+	 * @param in the RecordInputstream to read the record from
 	 */
 	public VerticalPageBreakRecord(RecordInputStream in) {
 		super(in);
 	}
 
-	/* (non-Javadoc)
-	 * @see org.apache.poi.hssf.record.Record#getSid()
-	 */
+	protected void validateSid(short id) {
+		if (id != getSid()) {
+			throw new RecordFormatException(
+					"NOT A HorizontalPageBreak or VerticalPageBreak RECORD!! " + id);
+		}
+	}
+
 	public short getSid() {
 		return sid;
 	}
 
+	public Object clone() {
+		PageBreakRecord result = new VerticalPageBreakRecord();
+		Iterator iterator = getBreaksIterator();
+		while (iterator.hasNext()) {
+			Break original = (Break) iterator.next();
+			result.addBreak(original.main, original.subFrom, original.subTo);
+		}
+		return result;
+	}
 }

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/WindowTwoRecord.java Thu Aug  7 11:21:32 2008
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record;
 
@@ -31,34 +29,27 @@
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 2.0-pre
  */
-
-public class WindowTwoRecord
-    extends Record
-{
-    public final static short sid = 0x23e;
-    private short             field_1_options;
+public final class WindowTwoRecord extends Record {
+    public final static short sid = 0x023E;
 
     // bitfields
-    private BitField          displayFormulas         = BitFieldFactory.getInstance(0x01);
-    private BitField          displayGridlines        = BitFieldFactory.getInstance(0x02);
-    private BitField          displayRowColHeadings   = BitFieldFactory.getInstance(0x04);
-    private BitField          freezePanes             = BitFieldFactory.getInstance(0x08);
-    private BitField          displayZeros            = BitFieldFactory.getInstance(0x10);
-    private BitField          defaultHeader           =
-        BitFieldFactory.getInstance(0x20);   // if false use color in field 4
-
-    // if true use default foreground
-    // for headers
-    private BitField          arabic                  =
-        BitFieldFactory.getInstance(0x40);   // for our desert dwelling friends
-    private BitField          displayGuts             = BitFieldFactory.getInstance(0x80);
-    private BitField          freezePanesNoSplit      = BitFieldFactory.getInstance(0x100);
-    private BitField          selected                = BitFieldFactory.getInstance(0x200);
-    private BitField          active                  = BitFieldFactory.getInstance(0x400);
-    private BitField          savedInPageBreakPreview = BitFieldFactory.getInstance(0x800);
-
+    private static final BitField displayFormulas         = BitFieldFactory.getInstance(0x01);
+    private static final BitField displayGridlines        = BitFieldFactory.getInstance(0x02);
+    private static final BitField displayRowColHeadings   = BitFieldFactory.getInstance(0x04);
+    private static final BitField freezePanes             = BitFieldFactory.getInstance(0x08);
+    private static final BitField displayZeros            = BitFieldFactory.getInstance(0x10);
+    /**  if false use color in field 4 if true use default foreground for headers */
+    private static final BitField defaultHeader           = BitFieldFactory.getInstance(0x20);   
+    private static final BitField arabic                  = BitFieldFactory.getInstance(0x040);
+    private static final BitField displayGuts             = BitFieldFactory.getInstance(0x080);
+    private static final BitField freezePanesNoSplit      = BitFieldFactory.getInstance(0x100);
+    private static final BitField selected                = BitFieldFactory.getInstance(0x200);
+    private static final BitField active                  = BitFieldFactory.getInstance(0x400);
+    private static final BitField savedInPageBreakPreview = BitFieldFactory.getInstance(0x800);
     // 4-7 reserved
     // end bitfields
+
+    private short             field_1_options;
     private short             field_2_top_row;
     private short             field_3_left_col;
     private int               field_4_header_color;

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=683670&r1=683669&r2=683670&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 Thu Aug  7 11:21:32 2008
@@ -14,20 +14,20 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
+
 package org.apache.poi.hssf.record.aggregates;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.poi.hssf.model.RecordStream;
 import org.apache.poi.hssf.record.CFHeaderRecord;
 import org.apache.poi.hssf.record.CFRuleRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.RecordInputStream;
 import org.apache.poi.ss.util.Region;
 import org.apache.poi.ss.util.CellRangeAddress;
-import org.apache.poi.util.POILogFactory;
-import org.apache.poi.util.POILogger;
 
 /**
  * CFRecordsAggregate - aggregates Conditional Formatting records CFHeaderRecord 
@@ -37,15 +37,12 @@
  * @author Dmitriy Kumshayev
  *
  */
-public final class CFRecordsAggregate extends Record
-{
+public final class CFRecordsAggregate extends Record {
 	/** Excel allows up to 3 conditional formating rules */
 	private static final int MAX_CONDTIONAL_FORMAT_RULES = 3;
 
 	public final static short sid = -2008; // not a real BIFF record
 
-	private static POILogger log = POILogFactory.getLogger(CFRecordsAggregate.class);
-
 	private final CFHeaderRecord header;
 
 	/** List of CFRuleRecord objects */
@@ -79,9 +76,8 @@
 	 * @param offset - position of {@link CFHeaderRecord} object in the list of Record objects
 	 * @return CFRecordsAggregate object
 	 */
-	public static CFRecordsAggregate createCFAggregate(List recs, int pOffset)
-	{
-		Record rec = ( Record ) recs.get(pOffset);
+	public static CFRecordsAggregate createCFAggregate(RecordStream rs) {
+		Record rec = rs.getNext();
 		if (rec.getSid() != CFHeaderRecord.sid) {
 			throw new IllegalStateException("next record sid was " + rec.getSid() 
 					+ " instead of " + CFHeaderRecord.sid + " as expected");
@@ -91,35 +87,10 @@
 		int nRules = header.getNumberOfConditionalFormats();
 
 		CFRuleRecord[] rules = new CFRuleRecord[nRules];
-		int offset = pOffset;
-		int countFound = 0;
-		while (countFound < rules.length) {
-			offset++;
-			if(offset>=recs.size()) {
-				break;
-			}
-			rec = (Record)recs.get(offset);
-			if(rec instanceof CFRuleRecord) {
-				rules[countFound] = (CFRuleRecord) rec;
-				countFound++;
-			} else {
-				break;
-			}
-		}
-
-		if (countFound < nRules)
-		{ // TODO -(MAR-2008) can this ever happen? write junit 
-			
-			if (log.check(POILogger.DEBUG))
-			{
-				log.log(POILogger.DEBUG, "Expected  " + nRules + " Conditional Formats, "
-						+ "but found " + countFound + " rules");
-			}
-			header.setNumberOfConditionalFormats(nRules);
-			CFRuleRecord[] lessRules = new CFRuleRecord[countFound];
-			System.arraycopy(rules, 0, lessRules, 0, countFound);
-			rules = lessRules;
+		for (int i = 0; i < rules.length; i++) {
+			rules[i] = (CFRuleRecord) rs.getNext();
 		}
+		
 		return new CFRecordsAggregate(header, rules);
 	}
 

Modified: poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
URL: http://svn.apache.org/viewvc/poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java?rev=683670&r1=683669&r2=683670&view=diff
==============================================================================
--- poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java (original)
+++ poi/branches/ooxml/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java Thu Aug  7 11:21:32 2008
@@ -1,72 +1,52 @@
-/*
-* 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.aggregates;
+/* ====================================================================
+   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.
+==================================================================== */
 
-import org.apache.poi.hssf.record.ColumnInfoRecord;
-import org.apache.poi.hssf.record.Record;
-import org.apache.poi.hssf.record.RecordInputStream;
+package org.apache.poi.hssf.record.aggregates;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
+import org.apache.poi.hssf.model.RecordStream;
+import org.apache.poi.hssf.record.ColumnInfoRecord;
+import org.apache.poi.hssf.record.Record;
+
 /**
  * @author Glen Stampoultzis
  * @version $Id$
  */
-public class ColumnInfoRecordsAggregate
-    extends Record
-{
-//    int     size     = 0;
-    List records = null;
-
-    public ColumnInfoRecordsAggregate()
-    {
-        records = new ArrayList();
-    }
-
-    /** You never fill an aggregate */
-    protected void fillFields(RecordInputStream in)
-    {
-    }
-
-    /** Not required by an aggregate */
-    protected void validateSid(short id)
-    {
-    }
-
-    /** It's an aggregate... just made something up */
-    public short getSid()
-    {
-        return -1012;
-    }
+public final class ColumnInfoRecordsAggregate extends RecordAggregate {
+	private final List records;
 
-    public int getRecordSize()
-    {
-        int size = 0;
-        for ( Iterator iterator = records.iterator(); iterator.hasNext(); )
-            size += ( (ColumnInfoRecord) iterator.next() ).getRecordSize();
-        return size;
-    }
-
-    public Iterator getIterator()
-    {
-        return records.iterator();
-    }
+	/**
+	 * Creates an empty aggregate
+	 */
+	public ColumnInfoRecordsAggregate() {
+		records = new ArrayList();
+	}
+    public ColumnInfoRecordsAggregate(RecordStream rs) {
+        this();
+        
+        while(rs.peekNextClass() == ColumnInfoRecord.class) {
+        	records.add(rs.getNext());
+        }
+        if (records.size() < 1) {
+        	throw new RuntimeException("No column info records found");
+        }
+   }
 
     /**
      * Performs a deep clone of the record
@@ -105,25 +85,14 @@
         return records.size();
     }
 
-    /**
-     * 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    offset to begin writing at
-     * @param data      byte array containing instance data
-     * @return          number of bytes written
-     */
-    public int serialize(int offset, byte [] data)
-    {
-        Iterator itr = records.iterator();
-        int      pos = offset;
-
-        while (itr.hasNext())
-        {
-            pos += (( Record ) itr.next()).serialize(pos, data);
-        }
-        return pos - offset;
+    public void visitContainedRecords(RecordVisitor rv) {
+    	int nItems = records.size();
+    	if (nItems < 1) {
+    		return;
+    	}
+    	for(int i=0; i<nItems; i++) {
+    		rv.visitRecord((Record)records.get(i));
+    	}
     }
 
     public int findStartOfColumnOutlineGroup(int idx)
@@ -178,8 +147,7 @@
         return idx;
     }
 
-    public ColumnInfoRecord getColInfo(int idx)
-    {
+    private ColumnInfoRecord getColInfo(int idx) {
         return (ColumnInfoRecord) records.get( idx );
     }
 
@@ -191,7 +159,7 @@
             columnInfo.setHidden( hidden );
             if (idx + 1 < records.size())
             {
-                ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) records.get( idx + 1 );
+                ColumnInfoRecord nextColumnInfo = getColInfo(idx + 1);
                 if (columnInfo.getLastColumn() + 1 == nextColumnInfo.getFirstColumn())
                 {
                     if (nextColumnInfo.getOutlineLevel() < level)
@@ -279,7 +247,7 @@
             return;
 
         // Find the start of the group.
-        ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get( findStartOfColumnOutlineGroup( idx ) );
+        ColumnInfoRecord columnInfo = getColInfo( findStartOfColumnOutlineGroup( idx ) );
 
         // Hide all the columns until the end of the group
         columnInfo = writeHidden( columnInfo, idx, true );
@@ -331,7 +299,7 @@
      * @see org.apache.poi.hssf.record.ColumnInfoRecord
      * @return record containing a ColumnInfoRecord
      */
-    public static Record createColInfo()
+    public static ColumnInfoRecord createColInfo()
     {
         ColumnInfoRecord retval = new ColumnInfoRecord();
 
@@ -452,7 +420,7 @@
             ci.setCollapsed( collapsed.booleanValue() );
     }
 
-    public int findColumnIdx(int column, int fromIdx)
+    private int findColumnIdx(int column, int fromIdx)
     {
         if (column < 0)
             throw new IllegalArgumentException( "column parameter out of range: " + column );
@@ -462,7 +430,7 @@
         ColumnInfoRecord ci;
         for (int k = fromIdx; k < records.size(); k++)
         {
-            ci = ( ColumnInfoRecord ) records.get(k);
+            ci = getColInfo(k);
             if ((ci.getFirstColumn() <= column)
                     && (column <= ci.getLastColumn()))
             {
@@ -477,8 +445,8 @@
     {
         if (columnIdx == 0)
             return;
-        ColumnInfoRecord previousCol = (ColumnInfoRecord) records.get( columnIdx - 1);
-        ColumnInfoRecord currentCol = (ColumnInfoRecord) records.get( columnIdx );
+        ColumnInfoRecord previousCol = getColInfo( columnIdx - 1);
+        ColumnInfoRecord currentCol = getColInfo( columnIdx );
         boolean adjacentColumns = previousCol.getLastColumn() == currentCol.getFirstColumn() - 1;
         if (!adjacentColumns)
             return;
@@ -513,7 +481,7 @@
             int columnIdx = findColumnIdx( i, Math.max(0,fromIdx) );
             if (columnIdx != -1)
             {
-                level = ((ColumnInfoRecord)records.get( columnIdx )).getOutlineLevel();
+                level = getColInfo(columnIdx).getOutlineLevel();
                 if (indent) level++; else level--;
                 level = Math.max(0, level);
                 level = Math.min(7, level);
@@ -525,6 +493,30 @@
         }
 
     }
+    /**
+     * Finds the <tt>ColumnInfoRecord</tt> which contains the specified columnIndex
+     * @param columnIndex index of the column (not the index of the ColumnInfoRecord)
+     * @return <code>null</code> if no column info found for the specified column
+     */
+	public ColumnInfoRecord findColumnInfo(int columnIndex) {
+		int nInfos = records.size();
+		for(int i=0; i< nInfos; i++) {
+			ColumnInfoRecord ci = getColInfo(i);
+			if (ci.getFirstColumn() <= columnIndex && columnIndex <= ci.getLastColumn()) {
+				return ci;
+			}
+		}
+		return null;
+	}
+	public int getMaxOutlineLevel() {
+        int result = 0;
+        int count=records.size();
+        for (int i=0; i<count; i++) {
+            ColumnInfoRecord columnInfoRecord = getColInfo(i);
+            result = Math.max(columnInfoRecord.getOutlineLevel(), result);
+        }
+        return result;
+	}
 
 
 }



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


Mime
View raw message