From: Glen Stampoultzis Date: Mon, 4 Mar 2002 00:05:33 +0000 (+0000) Subject: Added new chart record and readded record generation support to the build; it got... X-Git-Tag: prelogging~67 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c79eeffb7d5fd2c52c52c4df1e8e591c625698f9;p=poi.git Added new chart record and readded record generation support to the build; it got lost git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352145 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/dev/BiffViewer.java b/src/java/org/apache/poi/hssf/dev/BiffViewer.java index ac71cdc500..b953088fae 100644 --- a/src/java/org/apache/poi/hssf/dev/BiffViewer.java +++ b/src/java/org/apache/poi/hssf/dev/BiffViewer.java @@ -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); } diff --git a/src/java/org/apache/poi/hssf/record/FrameRecord.java b/src/java/org/apache/poi/hssf/record/FrameRecord.java index ad980f22c3..c4fa52f8f7 100644 --- a/src/java/org/apache/poi/hssf/record/FrameRecord.java +++ b/src/java/org/apache/poi/hssf/record/FrameRecord.java @@ -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 */ diff --git a/src/java/org/apache/poi/hssf/record/LegendRecord.java b/src/java/org/apache/poi/hssf/record/LegendRecord.java index 740b866876..2a0eea0536 100644 --- a/src/java/org/apache/poi/hssf/record/LegendRecord.java +++ b/src/java/org/apache/poi/hssf/record/LegendRecord.java @@ -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 diff --git a/src/java/org/apache/poi/hssf/record/SeriesRecord.java b/src/java/org/apache/poi/hssf/record/SeriesRecord.java index ce3f209790..c060284e6a 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesRecord.java @@ -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 index 0000000000..f77010d725 --- /dev/null +++ b/src/java/org/apache/poi/hssf/record/ValueRangeRecord.java @@ -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 + * . + */ + + +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 index 0000000000..d2dfc1c0bf --- /dev/null +++ b/src/records/definitions/value_range_record.xml @@ -0,0 +1,22 @@ + + The value range record defines the range of the value axis. + Glen Stampoultzis (glens at apache.org) + + + + + + + + + + + + + + + + + + + diff --git a/src/records/styles/record.xsl b/src/records/styles/record.xsl index 4a5964d63f..435fd17977 100644 --- a/src/records/styles/record.xsl +++ b/src/records/styles/record.xsl @@ -246,7 +246,7 @@ public class Record - buffer.append(" . = ") + buffer.append(" . = ") .append("0x") .append(HexDump.toHex(()get())) .append(" (").append(get()).append(" )\n"); diff --git a/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java b/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java index 7db42b942d..528de89422 100644 --- a/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java +++ b/src/scratchpad/src/org/apache/poi/generator/FieldIterator.java @@ -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);"; diff --git a/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java b/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java index 8645d77f09..29a081f45f 100644 --- a/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java +++ b/src/scratchpad/src/org/apache/poi/generator/RecordUtil.java @@ -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 index 0000000000..8459d2ed29 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/TestValueRangeRecord.java @@ -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 + * . + */ + + +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]); + } +} diff --git a/tools/targets/dev.xtarget b/tools/targets/dev.xtarget index 7efc8dee68..b8d29ae12a 100644 --- a/tools/targets/dev.xtarget +++ b/tools/targets/dev.xtarget @@ -206,4 +206,18 @@ - + + + + + + + + + + + + + + diff --git a/tools/targets/interactive.xtarget b/tools/targets/interactive.xtarget index 5915c338fe..ca9918bbc7 100644 --- a/tools/targets/interactive.xtarget +++ b/tools/targets/interactive.xtarget @@ -14,15 +14,16 @@ - - - - - - - - - + + + + + + + + +