]> source.dussan.org Git - poi.git/commitdiff
Added new chart record and readded record generation support to the build; it got...
authorGlen Stampoultzis <glens@apache.org>
Mon, 4 Mar 2002 00:05:33 +0000 (00:05 +0000)
committerGlen Stampoultzis <glens@apache.org>
Mon, 4 Mar 2002 00:05:33 +0000 (00:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352145 13f79535-47bb-0310-9956-ffa450edef68

12 files changed:
src/java/org/apache/poi/hssf/dev/BiffViewer.java
src/java/org/apache/poi/hssf/record/FrameRecord.java
src/java/org/apache/poi/hssf/record/LegendRecord.java
src/java/org/apache/poi/hssf/record/SeriesRecord.java
src/java/org/apache/poi/hssf/record/ValueRangeRecord.java [new file with mode: 0644]
src/records/definitions/value_range_record.xml [new file with mode: 0644]
src/records/styles/record.xsl
src/scratchpad/src/org/apache/poi/generator/FieldIterator.java
src/scratchpad/src/org/apache/poi/generator/RecordUtil.java
src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java [new file with mode: 0644]
tools/targets/dev.xtarget
tools/targets/interactive.xtarget

index ac71cdc500f5f9c0deda79f1b874265da357b68b..b953088fae6766dcca3302826a02cb8281ef36ea 100644 (file)
@@ -609,6 +609,10 @@ public class BiffViewer
                 retval = new FrameRecord(rectype, size, data);
                 break;
 
+            case ValueRangeRecord.sid :
+                retval = new ValueRangeRecord(rectype, size, data);
+                break;
+
             default :
                 retval = new UnknownRecord(rectype, size, data);
         }
index ad980f22c307ff42fdd90c28c1643132cedf70df..c4fa52f8f7bd590f46cf2fad2542a1560093a26c 100644 (file)
@@ -186,7 +186,7 @@ public class FrameRecord
     /**
      * Get the border type field for the Frame record.
      *
-     * @return  One of
+     * @return  One of 
      *        BORDER_TYPE_REGULAR
      *        BORDER_TYPE_SHADOW
      */
@@ -199,7 +199,7 @@ public class FrameRecord
      * Set the border type field for the Frame record.
      *
      * @param field_1_borderType
-     *        One of
+     *        One of 
      *        BORDER_TYPE_REGULAR
      *        BORDER_TYPE_SHADOW
      */
index 740b866876f546584846a664755a955a3ac64e92..2a0eea0536607a2e1153f8a635c23641180c692f 100644 (file)
@@ -305,7 +305,7 @@ public class LegendRecord
     /**
      * Get the type field for the Legend record.
      *
-     * @return  One of
+     * @return  One of 
      *        TYPE_BOTTOM
      *        TYPE_CORNER
      *        TYPE_TOP
@@ -322,7 +322,7 @@ public class LegendRecord
      * Set the type field for the Legend record.
      *
      * @param field_5_type
-     *        One of
+     *        One of 
      *        TYPE_BOTTOM
      *        TYPE_CORNER
      *        TYPE_TOP
@@ -338,7 +338,7 @@ public class LegendRecord
     /**
      * Get the spacing field for the Legend record.
      *
-     * @return  One of
+     * @return  One of 
      *        SPACING_CLOSE
      *        SPACING_MEDIUM
      *        SPACING_OPEN
@@ -352,7 +352,7 @@ public class LegendRecord
      * Set the spacing field for the Legend record.
      *
      * @param field_6_spacing
-     *        One of
+     *        One of 
      *        SPACING_CLOSE
      *        SPACING_MEDIUM
      *        SPACING_OPEN
index ce3f20979053b919bb14e695a9c1bd1d9ee682c3..c060284e6a9a59dbd4c9b2aa8a236e717093264d 100644 (file)
@@ -224,7 +224,7 @@ public class SeriesRecord
     /**
      * Get the category data type field for the Series record.
      *
-     * @return  One of
+     * @return  One of 
      *        CATEGORY_DATA_TYPE_DATES
      *        CATEGORY_DATA_TYPE_NUMERIC
      *        CATEGORY_DATA_TYPE_SEQUENCE
@@ -239,7 +239,7 @@ public class SeriesRecord
      * Set the category data type field for the Series record.
      *
      * @param field_1_categoryDataType
-     *        One of
+     *        One of 
      *        CATEGORY_DATA_TYPE_DATES
      *        CATEGORY_DATA_TYPE_NUMERIC
      *        CATEGORY_DATA_TYPE_SEQUENCE
@@ -253,7 +253,7 @@ public class SeriesRecord
     /**
      * Get the values data type field for the Series record.
      *
-     * @return  One of
+     * @return  One of 
      *        VALUES_DATA_TYPE_DATES
      *        VALUES_DATA_TYPE_NUMERIC
      *        VALUES_DATA_TYPE_SEQUENCE
@@ -268,7 +268,7 @@ public class SeriesRecord
      * Set the values data type field for the Series record.
      *
      * @param field_2_valuesDataType
-     *        One of
+     *        One of 
      *        VALUES_DATA_TYPE_DATES
      *        VALUES_DATA_TYPE_NUMERIC
      *        VALUES_DATA_TYPE_SEQUENCE
@@ -314,7 +314,7 @@ public class SeriesRecord
     /**
      * Get the bubble series type field for the Series record.
      *
-     * @return  One of
+     * @return  One of 
      *        BUBBLE_SERIES_TYPE_DATES
      *        BUBBLE_SERIES_TYPE_NUMERIC
      *        BUBBLE_SERIES_TYPE_SEQUENCE
@@ -329,7 +329,7 @@ public class SeriesRecord
      * Set the bubble series type field for the Series record.
      *
      * @param field_5_bubbleSeriesType
-     *        One of
+     *        One of 
      *        BUBBLE_SERIES_TYPE_DATES
      *        BUBBLE_SERIES_TYPE_NUMERIC
      *        BUBBLE_SERIES_TYPE_SEQUENCE
diff --git a/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java b/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java
new file mode 100644 (file)
index 0000000..f77010d
--- /dev/null
@@ -0,0 +1,483 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ *    "Apache POI" must not be used to endorse or promote products
+ *    derived from this software without prior written permission. For
+ *    written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    "Apache POI", nor may "Apache" appear in their name, without
+ *    prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.StringUtil;
+import org.apache.poi.util.HexDump;
+
+/**
+ * The value range record defines the range of the value axis.
+ * 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 ValueRangeRecord
+    extends Record
+{
+    public final static short      sid                             = 0x101f;
+    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                           = new BitField(0x1);
+    private BitField   automaticMaximum                           = new BitField(0x2);
+    private BitField   automaticMajor                             = new BitField(0x4);
+    private BitField   automaticMinor                             = new BitField(0x8);
+    private BitField   automaticCategoryCrossing                  = new BitField(0x10);
+    private BitField   logarithmicScale                           = new BitField(0x20);
+    private BitField   valuesInReverse                            = new BitField(0x40);
+    private BitField   crossCategoryAxisAtMaximum                 = new BitField(0x80);
+    private BitField   reserved                                   = new BitField(0x100);
+
+
+    public ValueRangeRecord()
+    {
+
+    }
+
+    /**
+     * Constructs a ValueRange record and sets its fields appropriately.
+     *
+     * @param id    id must be 0x101f or an exception
+     *              will be throw upon validation
+     * @param size  size the size of the data area of the record
+     * @param data  data of the record (should not contain sid/len)
+     */
+
+    public ValueRangeRecord(short id, short size, byte [] data)
+    {
+        super(id, size, data);
+    }
+
+    /**
+     * Constructs a ValueRange record and sets its fields appropriately.
+     *
+     * @param id    id must be 0x101f or an exception
+     *              will be throw upon validation
+     * @param size  size the size of the data area of the record
+     * @param data  data of the record (should not contain sid/len)
+     * @param offset of the record's data
+     */
+
+    public ValueRangeRecord(short id, short size, byte [] data, int offset)
+    {
+        super(id, size, data, offset);
+    }
+
+    /**
+     * Checks the sid matches the expected side for this record
+     *
+     * @param id   the expected sid.
+     */
+    protected void validateSid(short id)
+    {
+        if (id != sid)
+        {
+            throw new RecordFormatException("Not a ValueRange record");
+        }
+    }
+
+    protected void fillFields(byte [] data, short size, int offset)
+    {
+        field_1_minimumAxisValue        = LittleEndian.getDouble(data, 0 + offset);
+        field_2_maximumAxisValue        = LittleEndian.getDouble(data, 8 + offset);
+        field_3_majorIncrement          = LittleEndian.getDouble(data, 16 + offset);
+        field_4_minorIncrement          = LittleEndian.getDouble(data, 24 + offset);
+        field_5_categoryAxisCross       = LittleEndian.getDouble(data, 32 + offset);
+        field_6_options                 = LittleEndian.getShort(data, 40 + offset);
+
+    }
+
+    public String toString()
+    {
+        StringBuffer buffer = new StringBuffer();
+
+        buffer.append("[ValueRange]\n");
+
+        buffer.append("    .minimumAxisValue     = ")
+            .append(" (").append(getMinimumAxisValue()).append(" )\n");
+
+        buffer.append("    .maximumAxisValue     = ")
+            .append(" (").append(getMaximumAxisValue()).append(" )\n");
+
+        buffer.append("    .majorIncrement       = ")
+            .append(" (").append(getMajorIncrement()).append(" )\n");
+
+        buffer.append("    .minorIncrement       = ")
+            .append(" (").append(getMinorIncrement()).append(" )\n");
+
+        buffer.append("    .categoryAxisCross    = ")
+            .append(" (").append(getCategoryAxisCross()).append(" )\n");
+
+        buffer.append("    .options              = ")
+            .append("0x")
+            .append(HexDump.toHex((short)getOptions()))
+            .append(" (").append(getOptions()).append(" )\n");
+        buffer.append("         .automaticMinimum         = ").append(isAutomaticMinimum    ()).append('\n');
+        buffer.append("         .automaticMaximum         = ").append(isAutomaticMaximum    ()).append('\n');
+        buffer.append("         .automaticMajor           = ").append(isAutomaticMajor      ()).append('\n');
+        buffer.append("         .automaticMinor           = ").append(isAutomaticMinor      ()).append('\n');
+        buffer.append("         .automaticCategoryCrossing     = ").append(isAutomaticCategoryCrossing()).append('\n');
+        buffer.append("         .logarithmicScale         = ").append(isLogarithmicScale    ()).append('\n');
+        buffer.append("         .valuesInReverse          = ").append(isValuesInReverse     ()).append('\n');
+        buffer.append("         .crossCategoryAxisAtMaximum     = ").append(isCrossCategoryAxisAtMaximum()).append('\n');
+        buffer.append("         .reserved                 = ").append(isReserved            ()).append('\n');
+
+        buffer.append("[/ValueRange]\n");
+        return buffer.toString();
+    }
+
+    public int serialize(int offset, byte[] data)
+    {
+        LittleEndian.putShort(data, 0 + offset, sid);
+        LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+
+        LittleEndian.putDouble(data, 4 + offset, field_1_minimumAxisValue);
+        LittleEndian.putDouble(data, 12 + offset, field_2_maximumAxisValue);
+        LittleEndian.putDouble(data, 20 + offset, field_3_majorIncrement);
+        LittleEndian.putDouble(data, 28 + offset, field_4_minorIncrement);
+        LittleEndian.putDouble(data, 36 + offset, field_5_categoryAxisCross);
+        LittleEndian.putShort(data, 44 + offset, field_6_options);
+
+        return getRecordSize();
+    }
+
+    /**
+     * Size of record (exluding 4 byte header)
+     */
+    public int getRecordSize()
+    {
+        return 4 + 8 + 8 + 8 + 8 + 8 + 2;
+    }
+
+    public short getSid()
+    {
+        return this.sid;
+    }
+
+
+    /**
+     * Get the minimum axis value field for the ValueRange record.
+     */
+    public double getMinimumAxisValue()
+    {
+        return field_1_minimumAxisValue;
+    }
+
+    /**
+     * Set the minimum axis value field for the ValueRange record.
+     */
+    public void setMinimumAxisValue(double field_1_minimumAxisValue)
+    {
+        this.field_1_minimumAxisValue = field_1_minimumAxisValue;
+    }
+
+    /**
+     * Get the maximum axis value field for the ValueRange record.
+     */
+    public double getMaximumAxisValue()
+    {
+        return field_2_maximumAxisValue;
+    }
+
+    /**
+     * Set the maximum axis value field for the ValueRange record.
+     */
+    public void setMaximumAxisValue(double field_2_maximumAxisValue)
+    {
+        this.field_2_maximumAxisValue = field_2_maximumAxisValue;
+    }
+
+    /**
+     * Get the major increment field for the ValueRange record.
+     */
+    public double getMajorIncrement()
+    {
+        return field_3_majorIncrement;
+    }
+
+    /**
+     * Set the major increment field for the ValueRange record.
+     */
+    public void setMajorIncrement(double field_3_majorIncrement)
+    {
+        this.field_3_majorIncrement = field_3_majorIncrement;
+    }
+
+    /**
+     * Get the minor increment field for the ValueRange record.
+     */
+    public double getMinorIncrement()
+    {
+        return field_4_minorIncrement;
+    }
+
+    /**
+     * Set the minor increment field for the ValueRange record.
+     */
+    public void setMinorIncrement(double field_4_minorIncrement)
+    {
+        this.field_4_minorIncrement = field_4_minorIncrement;
+    }
+
+    /**
+     * Get the category axis cross field for the ValueRange record.
+     */
+    public double getCategoryAxisCross()
+    {
+        return field_5_categoryAxisCross;
+    }
+
+    /**
+     * Set the category axis cross field for the ValueRange record.
+     */
+    public void setCategoryAxisCross(double field_5_categoryAxisCross)
+    {
+        this.field_5_categoryAxisCross = field_5_categoryAxisCross;
+    }
+
+    /**
+     * Get the options field for the ValueRange record.
+     */
+    public short getOptions()
+    {
+        return field_6_options;
+    }
+
+    /**
+     * Set the options field for the ValueRange record.
+     */
+    public void setOptions(short field_6_options)
+    {
+        this.field_6_options = field_6_options;
+    }
+
+    /**
+     * Sets the automatic minimum field value.
+     * automatic minimum value selected
+     */
+    public void setAutomaticMinimum(boolean value)
+    {
+        field_6_options = automaticMinimum.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * automatic minimum value selected
+     * @return  the automatic minimum field value.
+     */
+    public boolean isAutomaticMinimum()
+    {
+        return automaticMinimum.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the automatic maximum field value.
+     * automatic maximum value selected
+     */
+    public void setAutomaticMaximum(boolean value)
+    {
+        field_6_options = automaticMaximum.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * automatic maximum value selected
+     * @return  the automatic maximum field value.
+     */
+    public boolean isAutomaticMaximum()
+    {
+        return automaticMaximum.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the automatic major field value.
+     * automatic major unit selected
+     */
+    public void setAutomaticMajor(boolean value)
+    {
+        field_6_options = automaticMajor.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * automatic major unit selected
+     * @return  the automatic major field value.
+     */
+    public boolean isAutomaticMajor()
+    {
+        return automaticMajor.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the automatic minor field value.
+     * automatic minor unit selected
+     */
+    public void setAutomaticMinor(boolean value)
+    {
+        field_6_options = automaticMinor.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * automatic minor unit selected
+     * @return  the automatic minor field value.
+     */
+    public boolean isAutomaticMinor()
+    {
+        return automaticMinor.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the automatic category crossing field value.
+     * category crossing point is automatically selected
+     */
+    public void setAutomaticCategoryCrossing(boolean value)
+    {
+        field_6_options = automaticCategoryCrossing.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * category crossing point is automatically selected
+     * @return  the automatic category crossing field value.
+     */
+    public boolean isAutomaticCategoryCrossing()
+    {
+        return automaticCategoryCrossing.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the logarithmic scale field value.
+     * use logarithmic scale
+     */
+    public void setLogarithmicScale(boolean value)
+    {
+        field_6_options = logarithmicScale.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * use logarithmic scale
+     * @return  the logarithmic scale field value.
+     */
+    public boolean isLogarithmicScale()
+    {
+        return logarithmicScale.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the values in reverse field value.
+     * values are reverses in graph
+     */
+    public void setValuesInReverse(boolean value)
+    {
+        field_6_options = valuesInReverse.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * values are reverses in graph
+     * @return  the values in reverse field value.
+     */
+    public boolean isValuesInReverse()
+    {
+        return valuesInReverse.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the cross category axis at maximum field value.
+     * category axis to cross at maximum value
+     */
+    public void setCrossCategoryAxisAtMaximum(boolean value)
+    {
+        field_6_options = crossCategoryAxisAtMaximum.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * category axis to cross at maximum value
+     * @return  the cross category axis at maximum field value.
+     */
+    public boolean isCrossCategoryAxisAtMaximum()
+    {
+        return crossCategoryAxisAtMaximum.isSet(field_6_options);
+    }
+
+    /**
+     * Sets the reserved field value.
+     * reserved, must equal 1 (excel dev. guide says otherwise)
+     */
+    public void setReserved(boolean value)
+    {
+        field_6_options = reserved.setShortBoolean(field_6_options, value);
+    }
+
+    /**
+     * reserved, must equal 1 (excel dev. guide says otherwise)
+     * @return  the reserved field value.
+     */
+    public boolean isReserved()
+    {
+        return reserved.isSet(field_6_options);
+    }
+
+
+}  // END OF CLASS
+
+
+
+
diff --git a/src/records/definitions/value_range_record.xml b/src/records/definitions/value_range_record.xml
new file mode 100644 (file)
index 0000000..d2dfc1c
--- /dev/null
@@ -0,0 +1,22 @@
+<record id="0x101f" name="ValueRange" package="org.apache.poi.hssf.record">
+    <description>The value range record defines the range of the value axis.</description>
+    <author>Glen Stampoultzis (glens at apache.org)</author>
+    <fields>
+        <field type="float" size="8" name="minimum axis value"/>
+        <field type="float" size="8" name="maximum axis value"/>
+        <field type="float" size="8" name="major increment"/>
+        <field type="float" size="8" name="minor increment"/>
+        <field type="float" size="8" name="category axis cross"/>
+        <field type="int" size="2" name="options">
+            <bit number="0" name="automatic minimum" description="automatic minimum value selected"/>
+            <bit number="1" name="automatic maximum" description="automatic maximum value selected"/>
+            <bit number="2" name="automatic major" description="automatic major unit selected"/>
+            <bit number="3" name="automatic minor" description="automatic minor unit selected"/>
+            <bit number="4" name="automatic category crossing" description="category crossing point is automatically selected"/>
+            <bit number="5" name="logarithmic scale" description="use logarithmic scale"/>
+            <bit number="6" name="values in reverse" description="values are reverses in graph"/>
+            <bit number="7" name="cross category axis at maximum" description="category axis to cross at maximum value"/>
+            <bit number="8" name="reserved" description="reserved, must equal 1 (excel dev. guide says otherwise)"/>
+        </field>
+    </fields>
+</record>
index 4a5964d63f28269aa1ff17d3959ab54fa2ca7d5c..435fd17977018cd7f3eb7fe1715bf8754a103e85 100644 (file)
@@ -246,7 +246,7 @@ public class <xsl:value-of select="@name"/>Record
 </xsl:template>
 
 <xsl:template match="field" mode="tostring">
-        buffer.append("    .<xsl:value-of select="recutil:getFieldName(@name,20)"/> = ")<xsl:if test="@type != 'string'">
+        buffer.append("    .<xsl:value-of select="recutil:getFieldName(@name,20)"/> = ")<xsl:if test="@type != 'string' and @type != 'float'">
             .append("0x")
             .append(HexDump.toHex((<xsl:value-of select="recutil:getType(@size,@type,00)"/>)get<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>()))</xsl:if>
             .append(" (").append(get<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>()).append(" )\n");
index 7db42b942deeafafeb604f61d9c1d0db207ae2e3..528de89422ceaa75abfe495b70f35a63dc400577 100644 (file)
@@ -85,6 +85,8 @@ public class FieldIterator
             result = "LittleEndian.getInt(data, " + offset + " + offset)";
         else if (javaType.equals("byte"))
             result = "data[ " + offset + " + offset ]";
+        else if (javaType.equals("double"))
+            result = "LittleEndian.getDouble(data, " + offset + " + offset)";
         else if (javaType.equals("ExcelString"))
             result = "ExcelStringUtil.decodeExcelString(data, " + offset + " + offset)";
 
@@ -111,6 +113,8 @@ public class FieldIterator
             result = "LittleEndian.putInt(data, " + (offset+4) + " + offset, " + javaFieldName + ");";
         else if (javaType.equals("byte"))
             result = "data[ " + (offset+4) + " + offset ] = " + javaFieldName + ";";
+        else if (javaType.equals("double"))
+            result = "LittleEndian.putDouble(data, " + (offset+4) + " + offset, " + javaFieldName + ");";
         else if (javaType.equals("ExcelString"))
             result = "StringUtil.putUncompressedUnicode(getFontName(), data, 20 + offset);";
 
index 8645d77f09d422a724b32a08d9feb8c768452c7c..29a081f45fe854b38e8c31ead42157871b0e794b 100644 (file)
@@ -122,13 +122,15 @@ public class RecordUtil
 
     public static String getType(String size, String type, int padTo)
     {
-        boolean numeric = type.equals("bits") || type.equals("int");
-        if (numeric && "1".equals(size))
+        boolean wholeNumber = type.equals("bits") || type.equals("int");
+        if (wholeNumber && "1".equals(size))
             return pad(new StringBuffer("byte"), padTo).toString();
-        else if (numeric && "2".equals(size))
+        else if (wholeNumber && "2".equals(size))
             return pad(new StringBuffer("short"), padTo).toString();
-        else if (numeric && "4".equals(size))
+        else if (wholeNumber && "4".equals(size))
             return pad(new StringBuffer("int"), padTo).toString();
+        else if (type.equals("float") && "8".equals(size))
+            return pad(new StringBuffer("double"), padTo).toString();
         else if (type.equals("string"))
             return pad(new StringBuffer("ExcelString"), padTo).toString();
 
diff --git a/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java b/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java
new file mode 100644 (file)
index 0000000..8459d2e
--- /dev/null
@@ -0,0 +1,136 @@
+
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ *    "Apache POI" must not be used to endorse or promote products
+ *    derived from this software without prior written permission. For
+ *    written permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    "Apache POI", nor may "Apache" appear in their name, without
+ *    prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ */
+
+
+package org.apache.poi.hssf.record;
+
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the ValueRangeRecord
+ * class works correctly.  Test data taken directly from a real
+ * Excel file.
+ *
+ *
+ * @author Glen Stampoultzis (glens at apache.org)
+ */
+public class TestValueRangeRecord
+        extends TestCase
+{
+    byte[] data = new byte[] {
+        (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,     // min axis value
+        (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,     // max axis value
+        (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,     // major increment
+        (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,     // minor increment
+        (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,     // cross over
+        (byte)0x1F,(byte)0x01                                    // options
+    };
+
+    public TestValueRangeRecord(String name)
+    {
+        super(name);
+    }
+
+    public void testLoad()
+            throws Exception
+    {
+
+        ValueRangeRecord record = new ValueRangeRecord((short)0x101f, (short)data.length, data);
+        assertEquals( 0.0, record.getMinimumAxisValue(), 0.001);
+        assertEquals( 0.0, record.getMaximumAxisValue(), 0.001);
+        assertEquals( 0.0, record.getMajorIncrement(), 0.001);
+        assertEquals( 0.0, record.getMinorIncrement(), 0.001);
+        assertEquals( 0.0, record.getCategoryAxisCross(), 0.001);
+        assertEquals( 0x011f, record.getOptions());
+        assertEquals( true, record.isAutomaticMinimum() );
+        assertEquals( true, record.isAutomaticMaximum() );
+        assertEquals( true, record.isAutomaticMajor() );
+        assertEquals( true, record.isAutomaticMinor() );
+        assertEquals( true, record.isAutomaticCategoryCrossing() );
+        assertEquals( false, record.isLogarithmicScale() );
+        assertEquals( false, record.isValuesInReverse() );
+        assertEquals( false, record.isCrossCategoryAxisAtMaximum() );
+        assertEquals( true, record.isReserved() );
+
+        assertEquals( 42+4, record.getRecordSize() );
+
+        record.validateSid((short)0x101f);
+    }
+
+    public void testStore()
+    {
+        ValueRangeRecord record = new ValueRangeRecord();
+        record.setMinimumAxisValue( 0 );
+        record.setMaximumAxisValue( 0 );
+        record.setMajorIncrement( 0 );
+        record.setMinorIncrement( 0 );
+        record.setCategoryAxisCross( 0 );
+        record.setAutomaticMinimum( true );
+        record.setAutomaticMaximum( true );
+        record.setAutomaticMajor( true );
+        record.setAutomaticMinor( true );
+        record.setAutomaticCategoryCrossing( true );
+        record.setLogarithmicScale( false );
+        record.setValuesInReverse( false );
+        record.setCrossCategoryAxisAtMaximum( false );
+        record.setReserved( true );
+
+        byte [] recordBytes = record.serialize();
+        assertEquals(recordBytes.length - 4, data.length);
+        for (int i = 0; i < data.length; i++)
+            assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+    }
+}
index 7efc8dee6859259f4d16cca8e0c0747b667089fe..b8d29ae12a5ff54b5a7f958e6f982f432e78175a 100644 (file)
           <fixcrlf srcdir="${java.dir}" includes="**/*.java"       eol="lf"/>
   </target>
   
-  
+  <target name="generate-records" depends="prepare"
+     description="Generates the record source code">
+
+      <java classname="org.apache.poi.hssf.util.RecordGenerator" fork="yes">
+          <arg value="src/records/definitions"/>
+          <arg value="src/records/styles"/>
+          <arg value="src/java"/>
+          <arg value="src/testcases"/>
+          <classpath>
+              <path refid="classpath"/>
+              <pathelement location="${build.dest}"/>
+          </classpath>
+      </java>
+
+  </target>
index 5915c338fef602bb490b36c37150806d61059bf1..ca9918bbc79de115232d16b82545254ee69bd9aa 100644 (file)
     <echo message=" You can also invoke them directly; see build.xml for more info. "/> 
     <echo message=" Builds will be in /build directory, distributions in /dist."/>        
     <echo message="  "/>    
-    <echo message=" compile ------ compiles the source code "/>     
-    <echo message=" docs --------- generates the html docs"/>        
-    <echo message=" cleandocs ---- cleans the build docs directory"/>    
-    <echo message=" javadocs ----- generates the API documentation"/>     
-    <echo message=" test --------- performs the jUnit tests"/>       
-    <echo message=" clean -------- cleans the build directory"/>    
-    <echo message=" dist --------- creates src and bin distributions"/>    
-    <echo message=" contrib ------ build-run contributed components"/>    
-    <taskdef name="user-input" classname="UserInput" 
+    <echo message=" compile ----------- compiles the source code "/>
+    <echo message=" docs -------------- generates the html docs"/>
+    <echo message=" cleandocs --------- cleans the build docs directory"/>
+    <echo message=" javadocs ---------- generates the API documentation"/>
+    <echo message=" test -------------- performs the jUnit tests"/>
+    <echo message=" clean ------------- cleans the build directory"/>
+    <echo message=" dist -------------- creates src and bin distributions"/>
+    <echo message=" contrib ----------- build-run contributed components"/>
+    <echo message=" generate-records -- generate records from xml"/>
+    <taskdef name="user-input" classname="UserInput"
         classpath="./tools/anttasks"/>
 
     <property name="input.selection" value="compile"/>