p2.log
poi.ipr
release-bin
-POILogger.log
\ No newline at end of file
+POILogger.log
+jakarta-poi.ipr
\ No newline at end of file
target="${target.vm}">
<classpath refid="scratchpad.classpath"/>
</javac>
+
+ </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>
<!-- =================================================================== -->
retval = new MergeCellsRecord(rectype, size, data);
break;
+ case AreaRecord.sid :
+ retval = new AreaRecord(rectype, size, data);
+ break;
+
+ case DataFormatRecord.sid :
+ retval = new DataFormatRecord(rectype, size, data);
+ break;
+
default :
retval = new UnknownRecord(rectype, size, data);
}
--- /dev/null
+
+/* ====================================================================
+ * 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 area record is used to define a area chart.
+ * 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 (gstamp at iprimus dot com dot au)
+ */
+public class AreaRecord
+ extends Record
+{
+ public final static short sid = 0x101A;
+ private short field_1_formatFlags;
+ private BitField stacked = new BitField(0x1);
+ private BitField displayAsPercentage = new BitField(0x2);
+ private BitField shadow = new BitField(0x4);
+
+
+ public AreaRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a Area record and sets its fields appropriately.
+ *
+ * @param id id must be 0x101A 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 AreaRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a Area record and sets its fields appropriately.
+ *
+ * @param id id must be 0x101A 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 AreaRecord(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 Area record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_formatFlags = LittleEndian.getShort(data, 0 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[Area]\n");
+
+ buffer.append(" .formatFlags = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getFormatFlags()))
+ .append(" (").append(getFormatFlags()).append(" )\n");
+ buffer.append(" .stacked = ").append(isStacked ()).append('\n');
+ buffer.append(" .displayAsPercentage = ").append(isDisplayAsPercentage ()).append('\n');
+ buffer.append(" .shadow = ").append(isShadow ()).append('\n');
+
+ buffer.append("[/Area]\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.putShort(data, 4 + offset, field_1_formatFlags);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 2;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the format flags field for the Area record.
+ */
+ public short getFormatFlags()
+ {
+ return field_1_formatFlags;
+ }
+
+ /**
+ * Set the format flags field for the Area record.
+ */
+ public void setFormatFlags(short field_1_formatFlags)
+ {
+ this.field_1_formatFlags = field_1_formatFlags;
+ }
+
+ /**
+ * Sets the stacked field value.
+ * series is stacked
+ */
+ public void setStacked(boolean value)
+ {
+ field_1_formatFlags = stacked.setShortBoolean(field_1_formatFlags, value);
+ }
+
+ /**
+ * series is stacked
+ * @return the stacked field value.
+ */
+ public boolean isStacked()
+ {
+ return stacked.isSet(field_1_formatFlags);
+ }
+
+ /**
+ * Sets the display as percentage field value.
+ * results displayed as percentages
+ */
+ public void setDisplayAsPercentage(boolean value)
+ {
+ field_1_formatFlags = displayAsPercentage.setShortBoolean(field_1_formatFlags, value);
+ }
+
+ /**
+ * results displayed as percentages
+ * @return the display as percentage field value.
+ */
+ public boolean isDisplayAsPercentage()
+ {
+ return displayAsPercentage.isSet(field_1_formatFlags);
+ }
+
+ /**
+ * Sets the shadow field value.
+ * display a shadow for the chart
+ */
+ public void setShadow(boolean value)
+ {
+ field_1_formatFlags = shadow.setShortBoolean(field_1_formatFlags, value);
+ }
+
+ /**
+ * display a shadow for the chart
+ * @return the shadow field value.
+ */
+ public boolean isShadow()
+ {
+ return shadow.isSet(field_1_formatFlags);
+ }
+
+
+} // END OF CLASS
+
+
+
+
--- /dev/null
+
+/* ====================================================================
+ * 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 bar record is used to define a bar chart.
+ * 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 (gstamp at iprimus dot com dot au)
+ */
+public class BarRecord
+ extends Record
+{
+ public final static short sid = 0x1017;
+ private short field_1_barSpace;
+ private short field_2_categorySpace;
+ private short field_3_formatFlags;
+ private BitField horizontal = new BitField(0x1);
+ private BitField stacked = new BitField(0x2);
+ private BitField displayAsPercentage = new BitField(0x4);
+ private BitField shadow = new BitField(0x8);
+
+
+ public BarRecord()
+ {
+ field_2_categorySpace = 50;
+
+ }
+
+ /**
+ * Constructs a Bar record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1017 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 BarRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a Bar record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1017 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 BarRecord(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 Bar record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_barSpace = LittleEndian.getShort(data, 0 + offset);
+ field_2_categorySpace = LittleEndian.getShort(data, 2 + offset);
+ field_3_formatFlags = LittleEndian.getShort(data, 4 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[Bar]\n");
+
+ buffer.append(" .barSpace = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getBarSpace()))
+ .append(" (").append(getBarSpace()).append(" )\n");
+
+ buffer.append(" .categorySpace = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getCategorySpace()))
+ .append(" (").append(getCategorySpace()).append(" )\n");
+
+ buffer.append(" .formatFlags = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getFormatFlags()))
+ .append(" (").append(getFormatFlags()).append(" )\n");
+ buffer.append(" .horizontal = ").append(isHorizontal ()).append('\n');
+ buffer.append(" .stacked = ").append(isStacked ()).append('\n');
+ buffer.append(" .displayAsPercentage = ").append(isDisplayAsPercentage ()).append('\n');
+ buffer.append(" .shadow = ").append(isShadow ()).append('\n');
+
+ buffer.append("[/Bar]\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.putShort(data, 4 + offset, field_1_barSpace);
+ LittleEndian.putShort(data, 6 + offset, field_2_categorySpace);
+ LittleEndian.putShort(data, 8 + offset, field_3_formatFlags);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 2 + 2 + 2;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the bar space field for the Bar record.
+ */
+ public short getBarSpace()
+ {
+ return field_1_barSpace;
+ }
+
+ /**
+ * Set the bar space field for the Bar record.
+ */
+ public void setBarSpace(short field_1_barSpace)
+ {
+ this.field_1_barSpace = field_1_barSpace;
+ }
+
+ /**
+ * Get the category space field for the Bar record.
+ */
+ public short getCategorySpace()
+ {
+ return field_2_categorySpace;
+ }
+
+ /**
+ * Set the category space field for the Bar record.
+ */
+ public void setCategorySpace(short field_2_categorySpace)
+ {
+ this.field_2_categorySpace = field_2_categorySpace;
+ }
+
+ /**
+ * Get the format flags field for the Bar record.
+ */
+ public short getFormatFlags()
+ {
+ return field_3_formatFlags;
+ }
+
+ /**
+ * Set the format flags field for the Bar record.
+ */
+ public void setFormatFlags(short field_3_formatFlags)
+ {
+ this.field_3_formatFlags = field_3_formatFlags;
+ }
+
+ /**
+ * Sets the horizontal field value.
+ * true to display horizontal bar charts, false for vertical
+ */
+ public void setHorizontal(boolean value)
+ {
+ field_3_formatFlags = horizontal.setShortBoolean(field_3_formatFlags, value);
+ }
+
+ /**
+ * true to display horizontal bar charts, false for vertical
+ * @return the horizontal field value.
+ */
+ public boolean isHorizontal()
+ {
+ return horizontal.isSet(field_3_formatFlags);
+ }
+
+ /**
+ * Sets the stacked field value.
+ * stack displayed values
+ */
+ public void setStacked(boolean value)
+ {
+ field_3_formatFlags = stacked.setShortBoolean(field_3_formatFlags, value);
+ }
+
+ /**
+ * stack displayed values
+ * @return the stacked field value.
+ */
+ public boolean isStacked()
+ {
+ return stacked.isSet(field_3_formatFlags);
+ }
+
+ /**
+ * Sets the display as percentage field value.
+ * display chart values as a percentage
+ */
+ public void setDisplayAsPercentage(boolean value)
+ {
+ field_3_formatFlags = displayAsPercentage.setShortBoolean(field_3_formatFlags, value);
+ }
+
+ /**
+ * display chart values as a percentage
+ * @return the display as percentage field value.
+ */
+ public boolean isDisplayAsPercentage()
+ {
+ return displayAsPercentage.isSet(field_3_formatFlags);
+ }
+
+ /**
+ * Sets the shadow field value.
+ * display a shadow for the chart
+ */
+ public void setShadow(boolean value)
+ {
+ field_3_formatFlags = shadow.setShortBoolean(field_3_formatFlags, value);
+ }
+
+ /**
+ * display a shadow for the chart
+ * @return the shadow field value.
+ */
+ public boolean isShadow()
+ {
+ return shadow.isSet(field_3_formatFlags);
+ }
+
+
+} // END OF CLASS
+
+
+
+
--- /dev/null
+
+/* ====================================================================
+ * 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 dat record is used to store options for the chart.
+ * 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 (gstamp at iprimus dot com dot au)
+ */
+public class DatRecord
+ extends Record
+{
+ public final static short sid = 0x1063;
+ private short field_1_options;
+ private BitField horizontalBorder = new BitField(0x1);
+ private BitField verticalBorder = new BitField(0x2);
+ private BitField border = new BitField(0x4);
+ private BitField showSeriesKey = new BitField(0x8);
+
+
+ public DatRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a Dat record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1063 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 DatRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a Dat record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1063 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 DatRecord(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 Dat record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_options = LittleEndian.getShort(data, 0 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[Dat]\n");
+
+ buffer.append(" .options = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getOptions()))
+ .append(" (").append(getOptions()).append(" )\n");
+ buffer.append(" .horizontalBorder = ").append(isHorizontalBorder ()).append('\n');
+ buffer.append(" .verticalBorder = ").append(isVerticalBorder ()).append('\n');
+ buffer.append(" .border = ").append(isBorder ()).append('\n');
+ buffer.append(" .showSeriesKey = ").append(isShowSeriesKey ()).append('\n');
+
+ buffer.append("[/Dat]\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.putShort(data, 4 + offset, field_1_options);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 2;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the options field for the Dat record.
+ */
+ public short getOptions()
+ {
+ return field_1_options;
+ }
+
+ /**
+ * Set the options field for the Dat record.
+ */
+ public void setOptions(short field_1_options)
+ {
+ this.field_1_options = field_1_options;
+ }
+
+ /**
+ * Sets the horizontal border field value.
+ * has a horizontal border
+ */
+ public void setHorizontalBorder(boolean value)
+ {
+ field_1_options = horizontalBorder.setShortBoolean(field_1_options, value);
+ }
+
+ /**
+ * has a horizontal border
+ * @return the horizontal border field value.
+ */
+ public boolean isHorizontalBorder()
+ {
+ return horizontalBorder.isSet(field_1_options);
+ }
+
+ /**
+ * Sets the vertical border field value.
+ * has vertical border
+ */
+ public void setVerticalBorder(boolean value)
+ {
+ field_1_options = verticalBorder.setShortBoolean(field_1_options, value);
+ }
+
+ /**
+ * has vertical border
+ * @return the vertical border field value.
+ */
+ public boolean isVerticalBorder()
+ {
+ return verticalBorder.isSet(field_1_options);
+ }
+
+ /**
+ * Sets the border field value.
+ * data table has a border
+ */
+ public void setBorder(boolean value)
+ {
+ field_1_options = border.setShortBoolean(field_1_options, value);
+ }
+
+ /**
+ * data table has a border
+ * @return the border field value.
+ */
+ public boolean isBorder()
+ {
+ return border.isSet(field_1_options);
+ }
+
+ /**
+ * Sets the show series key field value.
+ * shows the series key
+ */
+ public void setShowSeriesKey(boolean value)
+ {
+ field_1_options = showSeriesKey.setShortBoolean(field_1_options, value);
+ }
+
+ /**
+ * shows the series key
+ * @return the show series key field value.
+ */
+ public boolean isShowSeriesKey()
+ {
+ return showSeriesKey.isSet(field_1_options);
+ }
+
+
+} // END OF CLASS
+
+
+
+
--- /dev/null
+
+/* ====================================================================
+ * 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 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 (gstamp at iprimus dot com dot au)
+ */
+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 = new BitField(0x1);
+
+
+ public DataFormatRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a DataFormat record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1006 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 DataFormatRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a DataFormat record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1006 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 DataFormatRecord(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 DataFormat record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_pointNumber = LittleEndian.getShort(data, 0 + offset);
+ field_2_seriesIndex = LittleEndian.getShort(data, 2 + offset);
+ field_3_seriesNumber = LittleEndian.getShort(data, 4 + offset);
+ field_4_formatFlags = LittleEndian.getShort(data, 6 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[DataFormat]\n");
+
+ buffer.append(" .pointNumber = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getPointNumber()))
+ .append(" (").append(getPointNumber()).append(" )\n");
+
+ buffer.append(" .seriesIndex = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getSeriesIndex()))
+ .append(" (").append(getSeriesIndex()).append(" )\n");
+
+ buffer.append(" .seriesNumber = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getSeriesNumber()))
+ .append(" (").append(getSeriesNumber()).append(" )\n");
+
+ buffer.append(" .formatFlags = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getFormatFlags()))
+ .append(" (").append(getFormatFlags()).append(" )\n");
+ buffer.append(" .useExcel4Colors = ").append(isUseExcel4Colors ()).append('\n');
+
+ buffer.append("[/DataFormat]\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.putShort(data, 4 + offset, field_1_pointNumber);
+ LittleEndian.putShort(data, 6 + offset, field_2_seriesIndex);
+ LittleEndian.putShort(data, 8 + offset, field_3_seriesNumber);
+ LittleEndian.putShort(data, 10 + offset, field_4_formatFlags);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 2 + 2 + 2 + 2;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the point number field for the DataFormat record.
+ */
+ public short getPointNumber()
+ {
+ return field_1_pointNumber;
+ }
+
+ /**
+ * Set the point number field for the DataFormat record.
+ */
+ public void setPointNumber(short field_1_pointNumber)
+ {
+ this.field_1_pointNumber = field_1_pointNumber;
+ }
+
+ /**
+ * Get the series index field for the DataFormat record.
+ */
+ public short getSeriesIndex()
+ {
+ return field_2_seriesIndex;
+ }
+
+ /**
+ * Set the series index field for the DataFormat record.
+ */
+ public void setSeriesIndex(short field_2_seriesIndex)
+ {
+ this.field_2_seriesIndex = field_2_seriesIndex;
+ }
+
+ /**
+ * Get the series number field for the DataFormat record.
+ */
+ public short getSeriesNumber()
+ {
+ return field_3_seriesNumber;
+ }
+
+ /**
+ * Set the series number field for the DataFormat record.
+ */
+ public void setSeriesNumber(short field_3_seriesNumber)
+ {
+ this.field_3_seriesNumber = field_3_seriesNumber;
+ }
+
+ /**
+ * Get the format flags field for the DataFormat record.
+ */
+ public short getFormatFlags()
+ {
+ return field_4_formatFlags;
+ }
+
+ /**
+ * Set the format flags field for the DataFormat record.
+ */
+ public void setFormatFlags(short field_4_formatFlags)
+ {
+ this.field_4_formatFlags = field_4_formatFlags;
+ }
+
+ /**
+ * Sets the use excel 4 colors field value.
+ * set true to use excel 4 colors.
+ */
+ public void setUseExcel4Colors(boolean value)
+ {
+ field_4_formatFlags = useExcel4Colors.setShortBoolean(field_4_formatFlags, value);
+ }
+
+ /**
+ * set true to use excel 4 colors.
+ * @return the use excel 4 colors field value.
+ */
+ public boolean isUseExcel4Colors()
+ {
+ return useExcel4Colors.isSet(field_4_formatFlags);
+ }
+
+
+} // END OF CLASS
+
+
+
+
--- /dev/null
+
+/* ====================================================================
+ * 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 frame record indicates whether there is a border around the displayed text of a chart.
+ * 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 (gstamp at iprimus dot com dot au)
+ */
+public class FrameRecord
+ extends Record
+{
+ public final static short sid = 0x1032;
+ 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 = new BitField(0x1);
+ private BitField autoPosition = new BitField(0x2);
+
+
+ public FrameRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a Frame record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1032 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 FrameRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a Frame record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1032 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 FrameRecord(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 Frame record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_borderType = LittleEndian.getShort(data, 0 + offset);
+ field_2_options = LittleEndian.getShort(data, 2 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[Frame]\n");
+
+ buffer.append(" .borderType = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getBorderType()))
+ .append(" (").append(getBorderType()).append(" )\n");
+
+ buffer.append(" .options = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getOptions()))
+ .append(" (").append(getOptions()).append(" )\n");
+ buffer.append(" .autoSize = ").append(isAutoSize ()).append('\n');
+ buffer.append(" .autoPosition = ").append(isAutoPosition ()).append('\n');
+
+ buffer.append("[/Frame]\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.putShort(data, 4 + offset, field_1_borderType);
+ LittleEndian.putShort(data, 6 + offset, field_2_options);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 2 + 2;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the border type field for the Frame record.
+ *
+ * @return One of
+ * BORDER_TYPE_REGULAR
+ * BORDER_TYPE_SHADOW
+ */
+ public short getBorderType()
+ {
+ return field_1_borderType;
+ }
+
+ /**
+ * Set the border type field for the Frame record.
+ *
+ * @param field_1_borderType
+ * One of
+ * BORDER_TYPE_REGULAR
+ * BORDER_TYPE_SHADOW
+ */
+ public void setBorderType(short field_1_borderType)
+ {
+ this.field_1_borderType = field_1_borderType;
+ }
+
+ /**
+ * Get the options field for the Frame record.
+ */
+ public short getOptions()
+ {
+ return field_2_options;
+ }
+
+ /**
+ * Set the options field for the Frame record.
+ */
+ public void setOptions(short field_2_options)
+ {
+ this.field_2_options = field_2_options;
+ }
+
+ /**
+ * Sets the auto size field value.
+ * excel calculates the size automatically if true
+ */
+ public void setAutoSize(boolean value)
+ {
+ field_2_options = autoSize.setShortBoolean(field_2_options, value);
+ }
+
+ /**
+ * excel calculates the size automatically if true
+ * @return the auto size field value.
+ */
+ public boolean isAutoSize()
+ {
+ return autoSize.isSet(field_2_options);
+ }
+
+ /**
+ * Sets the auto position field value.
+ * excel calculates the position automatically
+ */
+ public void setAutoPosition(boolean value)
+ {
+ field_2_options = autoPosition.setShortBoolean(field_2_options, value);
+ }
+
+ /**
+ * excel calculates the position automatically
+ * @return the auto position field value.
+ */
+ public boolean isAutoPosition()
+ {
+ return autoPosition.isSet(field_2_options);
+ }
+
+
+} // END OF CLASS
+
+
+
+
--- /dev/null
+
+/* ====================================================================
+ * 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 legend record specifies the location of legend on a chart and it's overall size.
+ * 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 (gstamp at iprimus dot com dot au)
+ */
+public class LegendRecord
+ extends Record
+{
+ public final static short sid = 0x1015;
+ private int field_1_xPosition;
+ private int field_2_yPosition;
+ private int field_3_xSize;
+ private int field_4_ySize;
+ private byte field_5_type;
+ public final static byte TYPE_BOTTOM = 0;
+ public final static byte TYPE_CORNER = 1;
+ public final static byte TYPE_TOP = 2;
+ public final static byte TYPE_RIGHT = 3;
+ public final static byte TYPE_LEFT = 4;
+ public final static byte TYPE_NOT_DOCKED = 7;
+ private byte field_6_spacing;
+ public final static byte SPACING_CLOSE = 0;
+ public final static byte SPACING_MEDIUM = 1;
+ public final static byte SPACING_OPEN = 2;
+ private short field_7_options;
+ private BitField autoPosition = new BitField(0x1);
+ private BitField autoSeries = new BitField(0x2);
+ private BitField autoPosX = new BitField(0x4);
+ private BitField autoPosY = new BitField(0x8);
+ private BitField vert = new BitField(0x10);
+ private BitField containsDataTable = new BitField(0x20);
+
+
+ public LegendRecord()
+ {
+
+ }
+
+ /**
+ * Constructs a Legend record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1015 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 LegendRecord(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a Legend record and sets its fields appropriately.
+ *
+ * @param id id must be 0x1015 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 LegendRecord(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 Legend record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+ field_1_xPosition = LittleEndian.getInt(data, 0 + offset);
+ field_2_yPosition = LittleEndian.getInt(data, 4 + offset);
+ field_3_xSize = LittleEndian.getInt(data, 8 + offset);
+ field_4_ySize = LittleEndian.getInt(data, 12 + offset);
+ field_5_type = data[ 16 + offset ];
+ field_6_spacing = data[ 17 + offset ];
+ field_7_options = LittleEndian.getShort(data, 18 + offset);
+
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[Legend]\n");
+
+ buffer.append(" .xPosition = ")
+ .append("0x")
+ .append(HexDump.toHex((int)getXPosition()))
+ .append(" (").append(getXPosition()).append(" )\n");
+
+ buffer.append(" .yPosition = ")
+ .append("0x")
+ .append(HexDump.toHex((int)getYPosition()))
+ .append(" (").append(getYPosition()).append(" )\n");
+
+ buffer.append(" .xSize = ")
+ .append("0x")
+ .append(HexDump.toHex((int)getXSize()))
+ .append(" (").append(getXSize()).append(" )\n");
+
+ buffer.append(" .ySize = ")
+ .append("0x")
+ .append(HexDump.toHex((int)getYSize()))
+ .append(" (").append(getYSize()).append(" )\n");
+
+ buffer.append(" .type = ")
+ .append("0x")
+ .append(HexDump.toHex((byte)getType()))
+ .append(" (").append(getType()).append(" )\n");
+
+ buffer.append(" .spacing = ")
+ .append("0x")
+ .append(HexDump.toHex((byte)getSpacing()))
+ .append(" (").append(getSpacing()).append(" )\n");
+
+ buffer.append(" .options = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getOptions()))
+ .append(" (").append(getOptions()).append(" )\n");
+ buffer.append(" .autoPosition = ").append(isAutoPosition ()).append('\n');
+ buffer.append(" .autoSeries = ").append(isAutoSeries ()).append('\n');
+ buffer.append(" .autoPosX = ").append(isAutoPosX ()).append('\n');
+ buffer.append(" .autoPosY = ").append(isAutoPosY ()).append('\n');
+ buffer.append(" .vert = ").append(isVert ()).append('\n');
+ buffer.append(" .containsDataTable = ").append(isContainsDataTable ()).append('\n');
+
+ buffer.append("[/Legend]\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.putInt(data, 4 + offset, field_1_xPosition);
+ LittleEndian.putInt(data, 8 + offset, field_2_yPosition);
+ LittleEndian.putInt(data, 12 + offset, field_3_xSize);
+ LittleEndian.putInt(data, 16 + offset, field_4_ySize);
+ data[ 20 + offset ] = field_5_type;
+ data[ 21 + offset ] = field_6_spacing;
+ LittleEndian.putShort(data, 22 + offset, field_7_options);
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+ return 4 + 4 + 4 + 4 + 4 + 1 + 1 + 2;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+
+ /**
+ * Get the x position field for the Legend record.
+ */
+ public int getXPosition()
+ {
+ return field_1_xPosition;
+ }
+
+ /**
+ * Set the x position field for the Legend record.
+ */
+ public void setXPosition(int field_1_xPosition)
+ {
+ this.field_1_xPosition = field_1_xPosition;
+ }
+
+ /**
+ * Get the y position field for the Legend record.
+ */
+ public int getYPosition()
+ {
+ return field_2_yPosition;
+ }
+
+ /**
+ * Set the y position field for the Legend record.
+ */
+ public void setYPosition(int field_2_yPosition)
+ {
+ this.field_2_yPosition = field_2_yPosition;
+ }
+
+ /**
+ * Get the x size field for the Legend record.
+ */
+ public int getXSize()
+ {
+ return field_3_xSize;
+ }
+
+ /**
+ * Set the x size field for the Legend record.
+ */
+ public void setXSize(int field_3_xSize)
+ {
+ this.field_3_xSize = field_3_xSize;
+ }
+
+ /**
+ * Get the y size field for the Legend record.
+ */
+ public int getYSize()
+ {
+ return field_4_ySize;
+ }
+
+ /**
+ * Set the y size field for the Legend record.
+ */
+ public void setYSize(int field_4_ySize)
+ {
+ this.field_4_ySize = field_4_ySize;
+ }
+
+ /**
+ * Get the type field for the Legend record.
+ *
+ * @return One of
+ * TYPE_BOTTOM
+ * TYPE_CORNER
+ * TYPE_TOP
+ * TYPE_RIGHT
+ * TYPE_LEFT
+ * TYPE_NOT_DOCKED
+ */
+ public byte getType()
+ {
+ return field_5_type;
+ }
+
+ /**
+ * Set the type field for the Legend record.
+ *
+ * @param field_5_type
+ * One of
+ * TYPE_BOTTOM
+ * TYPE_CORNER
+ * TYPE_TOP
+ * TYPE_RIGHT
+ * TYPE_LEFT
+ * TYPE_NOT_DOCKED
+ */
+ public void setType(byte field_5_type)
+ {
+ this.field_5_type = field_5_type;
+ }
+
+ /**
+ * Get the spacing field for the Legend record.
+ *
+ * @return One of
+ * SPACING_CLOSE
+ * SPACING_MEDIUM
+ * SPACING_OPEN
+ */
+ public byte getSpacing()
+ {
+ return field_6_spacing;
+ }
+
+ /**
+ * Set the spacing field for the Legend record.
+ *
+ * @param field_6_spacing
+ * One of
+ * SPACING_CLOSE
+ * SPACING_MEDIUM
+ * SPACING_OPEN
+ */
+ public void setSpacing(byte field_6_spacing)
+ {
+ this.field_6_spacing = field_6_spacing;
+ }
+
+ /**
+ * Get the options field for the Legend record.
+ */
+ public short getOptions()
+ {
+ return field_7_options;
+ }
+
+ /**
+ * Set the options field for the Legend record.
+ */
+ public void setOptions(short field_7_options)
+ {
+ this.field_7_options = field_7_options;
+ }
+
+ /**
+ * Sets the auto position field value.
+ * set to true if legend is docked
+ */
+ public void setAutoPosition(boolean value)
+ {
+ field_7_options = autoPosition.setShortBoolean(field_7_options, value);
+ }
+
+ /**
+ * set to true if legend is docked
+ * @return the auto position field value.
+ */
+ public boolean isAutoPosition()
+ {
+ return autoPosition.isSet(field_7_options);
+ }
+
+ /**
+ * Sets the auto series field value.
+ * automatic series distribution
+ */
+ public void setAutoSeries(boolean value)
+ {
+ field_7_options = autoSeries.setShortBoolean(field_7_options, value);
+ }
+
+ /**
+ * automatic series distribution
+ * @return the auto series field value.
+ */
+ public boolean isAutoSeries()
+ {
+ return autoSeries.isSet(field_7_options);
+ }
+
+ /**
+ * Sets the auto pos x field value.
+ * x positioning is done automatically
+ */
+ public void setAutoPosX(boolean value)
+ {
+ field_7_options = autoPosX.setShortBoolean(field_7_options, value);
+ }
+
+ /**
+ * x positioning is done automatically
+ * @return the auto pos x field value.
+ */
+ public boolean isAutoPosX()
+ {
+ return autoPosX.isSet(field_7_options);
+ }
+
+ /**
+ * Sets the auto pos y field value.
+ * y positioning is done automatically
+ */
+ public void setAutoPosY(boolean value)
+ {
+ field_7_options = autoPosY.setShortBoolean(field_7_options, value);
+ }
+
+ /**
+ * y positioning is done automatically
+ * @return the auto pos y field value.
+ */
+ public boolean isAutoPosY()
+ {
+ return autoPosY.isSet(field_7_options);
+ }
+
+ /**
+ * Sets the vert field value.
+ * if true legend is vertical (otherwise it's horizonal)
+ */
+ public void setVert(boolean value)
+ {
+ field_7_options = vert.setShortBoolean(field_7_options, value);
+ }
+
+ /**
+ * if true legend is vertical (otherwise it's horizonal)
+ * @return the vert field value.
+ */
+ public boolean isVert()
+ {
+ return vert.isSet(field_7_options);
+ }
+
+ /**
+ * Sets the contains data table field value.
+ * true if the chart contains the data table
+ */
+ public void setContainsDataTable(boolean value)
+ {
+ field_7_options = containsDataTable.setShortBoolean(field_7_options, value);
+ }
+
+ /**
+ * true if the chart contains the data table
+ * @return the contains data table field value.
+ */
+ public boolean isContainsDataTable()
+ {
+ return containsDataTable.isSet(field_7_options);
+ }
+
+
+} // END OF CLASS
+
+
+
+
/**
* Constructs a Protect record and sets its fields appropriately.
*
- * @param short id must be 0x12 or an exception will be throw upon validation
- * @param short size the size of the data area of the record
- * @param byte[] data of the record (should not contain sid/len)
+ * @param id id must be 0x12 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 ProtectRecord(short id, short size, byte [] data)
/**
* Constructs a Protect record and sets its fields appropriately.
*
- * @param short id must be 0x12 or an exception will be throw upon validation
- * @param short size the size of the data area of the record
- * @param byte[] data of the record (should not contain sid/len)
+ * @param id id must be 0x12 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 data
*/
/**
* set whether the sheet is protected or not
- * @param whether to protect the sheet or not
+ * @param protect whether to protect the sheet or not
*/
public void setProtect(boolean protect)
* <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 series record defines the (graphing) series within a chart.
- * This record is matched with a corresponding EndRecord.
- *
+ * The series record describes the overall data for 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 (gstamp at iprimus dot com dot au)
*/
-
public class SeriesRecord
extends Record
{
- public static final short sid = 0x1003;
- public static final short AXIS_TYPE_DATE = 0;
- public static final short AXIS_TYPE_NUMERIC = 1;
- public static final short AXIS_TYPE_SEQUENCE = 3;
- public static final short AXIS_TYPE_TEXT = 4;
- private short field_1_xAxisType;
- private short field_2_yAxisType;
- private short field_3_countOfXValues;
- private short field_4_countOfYValues;
- private short field_5_bubbleType; // type of data in "bubble size series"
- private short field_6_countOfBubbleSeries; // count of bubble series values
+ public final static short sid = 0x1003;
+ private short field_1_categoryDataType;
+ public final static short CATEGORY_DATA_TYPE_DATES = 0;
+ public final static short CATEGORY_DATA_TYPE_NUMERIC = 1;
+ public final static short CATEGORY_DATA_TYPE_SEQUENCE = 2;
+ public final static short CATEGORY_DATA_TYPE_TEXT = 3;
+ private short field_2_valuesDataType;
+ public final static short VALUES_DATA_TYPE_DATES = 0;
+ public final static short VALUES_DATA_TYPE_NUMERIC = 1;
+ public final static short VALUES_DATA_TYPE_SEQUENCE = 2;
+ public final static short VALUES_DATA_TYPE_TEXT = 3;
+ private short field_3_numCategories;
+ private short field_4_numValues;
+ private short field_5_bubbleSeriesType;
+ public final static short BUBBLE_SERIES_TYPE_DATES = 0;
+ public final static short BUBBLE_SERIES_TYPE_NUMERIC = 1;
+ public final static short BUBBLE_SERIES_TYPE_SEQUENCE = 2;
+ public final static short BUBBLE_SERIES_TYPE_TEXT = 3;
+ private short field_6_numBubbleValues;
+
public SeriesRecord()
{
+
}
/**
- * Constructs a SeriesRecord record and sets its fields appropriately.
+ * Constructs a Series record and sets its fields appropriately.
*
- * @param short id must be 0x1003 or an exception will be throw upon validation
- * @param short size the size of the data area of the record
- * @param byte[] data of the record (should not contain sid/len)
+ * @param id id must be 0x1003 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 SeriesRecord(short id, short size, byte [] data)
}
/**
- * Constructs a SeriesRecord record and sets its fields appropriately.
+ * Constructs a Series record and sets its fields appropriately.
*
- * @param short id must be 0x1003 or an exception will be throw upon validation
- * @param short size the size of the data area of the record
- * @param byte[] data of the record (should not contain sid/len)
+ * @param id id must be 0x1003 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
*/
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 SERIES RECORD");
+ throw new RecordFormatException("Not a Series record");
}
}
protected void fillFields(byte [] data, short size, int offset)
{
- field_1_xAxisType = LittleEndian.getShort(data, 0 + offset);
- field_2_yAxisType = LittleEndian.getShort(data, 2 + offset);
- field_3_countOfXValues = LittleEndian.getShort(data, 4 + offset);
- field_4_countOfYValues = LittleEndian.getShort(data, 6 + offset);
- field_5_bubbleType = LittleEndian.getShort(data, 8 + offset);
- field_6_countOfBubbleSeries = LittleEndian.getShort(data,
- 10 + offset);
+ field_1_categoryDataType = LittleEndian.getShort(data, 0 + offset);
+ field_2_valuesDataType = LittleEndian.getShort(data, 2 + offset);
+ field_3_numCategories = LittleEndian.getShort(data, 4 + offset);
+ field_4_numValues = LittleEndian.getShort(data, 6 + offset);
+ field_5_bubbleSeriesType = LittleEndian.getShort(data, 8 + offset);
+ field_6_numBubbleValues = LittleEndian.getShort(data, 10 + offset);
+
}
public String toString()
{
StringBuffer buffer = new StringBuffer();
- buffer.append("[SERIES]\n");
- buffer.append(" .xAxisType = ")
- .append(Integer.toHexString(getXAxisType())).append("\n");
- buffer.append(" .yAxisType = ")
- .append(Integer.toHexString(getYAxisType())).append("\n");
- buffer.append(" .countOfXValues = ").append(getCountOfXValues())
- .append("\n");
- buffer.append(" .countOfYValues = ").append(getCountOfYValues())
- .append("\n");
- buffer.append("[/SERIES]\n");
+ buffer.append("[Series]\n");
+
+ buffer.append(" .categoryDataType = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getCategoryDataType()))
+ .append(" (").append(getCategoryDataType()).append(" )\n");
+
+ buffer.append(" .valuesDataType = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getValuesDataType()))
+ .append(" (").append(getValuesDataType()).append(" )\n");
+
+ buffer.append(" .numCategories = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getNumCategories()))
+ .append(" (").append(getNumCategories()).append(" )\n");
+
+ buffer.append(" .numValues = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getNumValues()))
+ .append(" (").append(getNumValues()).append(" )\n");
+
+ buffer.append(" .bubbleSeriesType = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getBubbleSeriesType()))
+ .append(" (").append(getBubbleSeriesType()).append(" )\n");
+
+ buffer.append(" .numBubbleValues = ")
+ .append("0x")
+ .append(HexDump.toHex((short)getNumBubbleValues()))
+ .append(" (").append(getNumBubbleValues()).append(" )\n");
+
+ buffer.append("[/Series]\n");
return buffer.toString();
}
- public int serialize(int offset, byte [] data)
+ public int serialize(int offset, byte[] data)
{
LittleEndian.putShort(data, 0 + offset, sid);
- LittleEndian.putShort(data, 2 + offset,
- (( short ) 12)); // 12 byte length
- LittleEndian.putShort(data, 4 + offset, getXAxisType());
- LittleEndian.putShort(data, 6 + offset, getYAxisType());
- LittleEndian.putShort(data, 8 + offset, getCountOfXValues());
- LittleEndian.putShort(data, 10 + offset, getCountOfYValues());
+ LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
+
+ LittleEndian.putShort(data, 4 + offset, field_1_categoryDataType);
+ LittleEndian.putShort(data, 6 + offset, field_2_valuesDataType);
+ LittleEndian.putShort(data, 8 + offset, field_3_numCategories);
+ LittleEndian.putShort(data, 10 + offset, field_4_numValues);
+ LittleEndian.putShort(data, 12 + offset, field_5_bubbleSeriesType);
+ LittleEndian.putShort(data, 14 + offset, field_6_numBubbleValues);
+
return getRecordSize();
}
+ /**
+ * Size of record (exluding 4 byte header)
+ */
public int getRecordSize()
{
- return 12;
+ return 4 + 2 + 2 + 2 + 2 + 2 + 2;
}
public short getSid()
return this.sid;
}
+
/**
- * @return one of AXIS_TYPE_XXX
+ * Get the category data type field for the Series record.
+ *
+ * @return One of
+ * CATEGORY_DATA_TYPE_DATES
+ * CATEGORY_DATA_TYPE_NUMERIC
+ * CATEGORY_DATA_TYPE_SEQUENCE
+ * CATEGORY_DATA_TYPE_TEXT
*/
-
- public short getXAxisType()
+ public short getCategoryDataType()
{
- return field_1_xAxisType;
+ return field_1_categoryDataType;
}
/**
- * @param xAxisType one of AXIS_TYPE_XXX
+ * Set the category data type field for the Series record.
+ *
+ * @param field_1_categoryDataType
+ * One of
+ * CATEGORY_DATA_TYPE_DATES
+ * CATEGORY_DATA_TYPE_NUMERIC
+ * CATEGORY_DATA_TYPE_SEQUENCE
+ * CATEGORY_DATA_TYPE_TEXT
*/
-
- public void setXAxisType(short xAxisType)
+ public void setCategoryDataType(short field_1_categoryDataType)
{
- this.field_1_xAxisType = xAxisType;
+ this.field_1_categoryDataType = field_1_categoryDataType;
}
/**
- * @return one of AXIS_TYPE_XXX
+ * Get the values data type field for the Series record.
+ *
+ * @return One of
+ * VALUES_DATA_TYPE_DATES
+ * VALUES_DATA_TYPE_NUMERIC
+ * VALUES_DATA_TYPE_SEQUENCE
+ * VALUES_DATA_TYPE_TEXT
*/
-
- public short getYAxisType()
+ public short getValuesDataType()
{
- return field_2_yAxisType;
+ return field_2_valuesDataType;
}
/**
- * @param xAxisType one of AXIS_TYPE_XXX
+ * Set the values data type field for the Series record.
+ *
+ * @param field_2_valuesDataType
+ * One of
+ * VALUES_DATA_TYPE_DATES
+ * VALUES_DATA_TYPE_NUMERIC
+ * VALUES_DATA_TYPE_SEQUENCE
+ * VALUES_DATA_TYPE_TEXT
*/
-
- public void setYAxisType(short yAxisType)
+ public void setValuesDataType(short field_2_valuesDataType)
{
- this.field_2_yAxisType = yAxisType;
+ this.field_2_valuesDataType = field_2_valuesDataType;
}
/**
- * @return number of x values in the series.
+ * Get the num categories field for the Series record.
*/
+ public short getNumCategories()
+ {
+ return field_3_numCategories;
+ }
- public short getCountOfXValues()
+ /**
+ * Set the num categories field for the Series record.
+ */
+ public void setNumCategories(short field_3_numCategories)
{
- return field_3_countOfXValues;
+ this.field_3_numCategories = field_3_numCategories;
}
/**
- * Sets the number of x values in the series.
+ * Get the num values field for the Series record.
*/
+ public short getNumValues()
+ {
+ return field_4_numValues;
+ }
- public void setCountOfXValues(short countOfXValues)
+ /**
+ * Set the num values field for the Series record.
+ */
+ public void setNumValues(short field_4_numValues)
{
- this.field_3_countOfXValues = countOfXValues;
+ this.field_4_numValues = field_4_numValues;
}
/**
- * @return number of y values in the series.
+ * Get the bubble series type field for the Series record.
+ *
+ * @return One of
+ * BUBBLE_SERIES_TYPE_DATES
+ * BUBBLE_SERIES_TYPE_NUMERIC
+ * BUBBLE_SERIES_TYPE_SEQUENCE
+ * BUBBLE_SERIES_TYPE_TEXT
*/
+ public short getBubbleSeriesType()
+ {
+ return field_5_bubbleSeriesType;
+ }
- public short getCountOfYValues()
+ /**
+ * Set the bubble series type field for the Series record.
+ *
+ * @param field_5_bubbleSeriesType
+ * One of
+ * BUBBLE_SERIES_TYPE_DATES
+ * BUBBLE_SERIES_TYPE_NUMERIC
+ * BUBBLE_SERIES_TYPE_SEQUENCE
+ * BUBBLE_SERIES_TYPE_TEXT
+ */
+ public void setBubbleSeriesType(short field_5_bubbleSeriesType)
{
- return field_4_countOfYValues;
+ this.field_5_bubbleSeriesType = field_5_bubbleSeriesType;
}
/**
- * @param countOfYValues sets the number of y values for the series.
+ * Get the num bubble values field for the Series record.
*/
+ public short getNumBubbleValues()
+ {
+ return field_6_numBubbleValues;
+ }
- public void setCountOfYValues(short countOfYValues)
+ /**
+ * Set the num bubble values field for the Series record.
+ */
+ public void setNumBubbleValues(short field_6_numBubbleValues)
{
- this.field_4_countOfYValues = countOfYValues;
+ this.field_6_numBubbleValues = field_6_numBubbleValues;
}
-}
+
+
+} // END OF CLASS
+
+
+
+
--- /dev/null
+/* ====================================================================
+ * 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.util;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Node;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import java.io.File;
+
+public class RecordGenerator
+{
+ public static void main(String[] args)
+ throws Exception
+ {
+ if (args.length != 4)
+ {
+ System.out.println("Usage:");
+ System.out.println(" java org.apache.poi.hssf.util.RecordGenerator RECORD_DEFINTIONS RECORD_STYLES DEST_SRC_PATH TEST_SRC_PATH");
+ }
+ else
+ {
+ generateRecords(args[0], args[1], args[2], args[3]);
+ }
+ }
+
+ private static void generateRecords(String defintionsDir, String recordStyleDir, String destSrcPathDir, String testSrcPathDir)
+ throws Exception
+ {
+ File definitionsFile = new File(defintionsDir);
+
+ for (int i = 0; i < definitionsFile.listFiles().length; i++)
+ {
+ File file = definitionsFile.listFiles()[i];
+ if (file.isFile() && file.getName().endsWith("_record.xml"))
+ {
+ // Get record name and package
+ DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document document = builder.parse(file);
+ Element record = document.getDocumentElement();
+ String recordName = record.getAttributes().getNamedItem("name").getNodeValue();
+ String packageName = record.getAttributes().getNamedItem("package").getNodeValue();
+ packageName = packageName.replace('.','/');
+
+ // Generate record
+ String destinationPath = destSrcPathDir + "/" + packageName ;
+ File destinationPathFile = new File(destinationPath);
+ destinationPathFile.mkdirs();
+ String destinationFilepath = destinationPath + "/" + recordName + "Record.java";
+ String args[] = new String [] { "-in", file.getAbsolutePath(), "-xsl", recordStyleDir + "/record.xsl",
+ "-out", destinationFilepath,
+ "-TEXT"};
+ org.apache.xalan.xslt.Process.main( args );
+ System.out.println("Generated record: " + destinationFilepath);
+
+ // Generate test (if not already generated)
+ destinationPath = testSrcPathDir + "/" + packageName ;
+ destinationPathFile = new File(destinationPath);
+ destinationPathFile.mkdirs();
+ destinationFilepath = destinationPath + "/Test" + recordName + "Record.java";
+ if (new File(destinationFilepath).exists() == false)
+ {
+ args = new String [] { "-in", file.getAbsolutePath(), "-xsl", recordStyleDir + "/record_test.xsl",
+ "-out", destinationFilepath,
+ "-TEXT"};
+ org.apache.xalan.xslt.Process.main( args );
+ System.out.println("Generated test: " + destinationFilepath);
+ }
+ else
+ {
+ System.out.println("Skipped test generation: " + destinationFilepath);
+ }
+ }
+ }
+ }
+}
/**
* dump data in hexadecimal format; derived from a HexDump utility I
- * wrote in June 2001
+ * wrote in June 2001.
*
* @author Marc Johnson
+ * @author Glen Stampoultzis (glens at apache.org)
*/
public class HexDump
* null
*/
- public static void dump(final byte [] data, final long offset,
+ public synchronized static void dump(final byte [] data, final long offset,
final OutputStream stream, final int index)
throws IOException, ArrayIndexOutOfBoundsException,
IllegalArgumentException
}
return _cbuffer;
}
+
+ /**
+ * Converts the parameter to a hex value.
+ *
+ * @param value The value to convert
+ * @return The result right padded with 0
+ */
+ public static String toHex(final short value)
+ {
+ return toHex(value, 4);
+ }
+
+ /**
+ * Converts the parameter to a hex value.
+ *
+ * @param value The value to convert
+ * @return The result right padded with 0
+ */
+ public static String toHex(final byte value)
+ {
+ return toHex(value, 2);
+ }
+
+ /**
+ * Converts the parameter to a hex value.
+ *
+ * @param value The value to convert
+ * @return The result right padded with 0
+ */
+ public static String toHex(final int value)
+ {
+ return toHex(value, 8);
+ }
+
+
+ private static String toHex(final long value, final int digits)
+ {
+ StringBuffer result = new StringBuffer(digits);
+ for (int j = 0; j < digits; j++)
+ {
+ result.append( _hexcodes[ (int) ((value >> _shifts[ j + (8 - digits) ]) & 15)]);
+ }
+ return result.toString();
+ }
}
--- /dev/null
+<record id="0x101A" name="Area" package="org.apache.poi.hssf.record">
+ <description>The area record is used to define a area chart.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="format flags">
+ <bit number="0" name="stacked" description="series is stacked"/>
+ <bit number="1" name="display as percentage" description="results displayed as percentages"/>
+ <bit number="2" name="shadow" description="display a shadow for the chart"/>
+ </field>
+ </fields>
+</record>
--- /dev/null
+<record id="0x1017" name="Bar" package="org.apache.poi.hssf.record">
+ <description>The bar record is used to define a bar chart.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="bar space" description="space between bars"/>
+ <field type="int" size="2" name="category space" default="50" description="space between categories"/>
+ <field type="int" size="2" name="format flags">
+ <bit number="0" name="horizontal" description="true to display horizontal bar charts, false for vertical"/>
+ <bit number="1" name="stacked" description="stack displayed values"/>
+ <bit number="2" name="display as percentage" description="display chart values as a percentage"/>
+ <bit number="3" name="shadow" description="display a shadow for the chart"/>
+ </field>
+ </fields>
+</record>
--- /dev/null
+<record id="0x1063" name="Dat" package="org.apache.poi.hssf.record">
+ <description>The dat record is used to store options for the chart.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="options">
+ <bit number="0" name="horizontal border" description="has a horizontal border"/>
+ <bit number="1" name="vertical border" description="has vertical border"/>
+ <bit number="2" name="border" description="data table has a border"/>
+ <bit number="3" name="show series key" description="shows the series key"/>
+ </field>
+ </fields>
+</record>
--- /dev/null
+<record id="0x1006" name="DataFormat" package="org.apache.poi.hssf.record">
+ <description>The data format record is used to index into a series.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="point number" description="0xFFFF for entire series"/>
+ <field type="int" size="2" name="series index" description="relative index"/>
+ <field type="int" size="2" name="series number" description="series number (which can be different from series index when series order is changed)"/>
+ <field type="int" size="2" name="format flags">
+ <bit number="0" name="use excel 4 colors" description="set true to use excel 4 colors."/>
+ </field>
+ </fields>
+</record>
--- /dev/null
+<record id="0x31" name="Font" package="org.apache.poi.hssf.records">
+ <description>Describes a font record. In Excel a font belongs in the font table.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="font height"/>
+ <field type="bits" size="2" name="attributes">
+ <bit number="1" name="italic" description="Indicates whether a font has an italic appearance"/>
+ <bit number="3" name="struck out" description="Indicates whether a font has a line through the middle."/>
+ </field>
+ <field type="int" size="2" name="colour palette index"/>
+ <field type="int" size="2" name="bold weight">
+ <const name="normal text" value="400" description="Sets text to normal appearance"/>
+ <const name="bold text" value="700" description="Redenders a font bold"/>
+ </field>
+ <field type="int" size="2" name="super sub script">
+ <const name="none" value="0"/>
+ <const name="super script" value="1"/>
+ <const name="subscript" value="2"/>
+ </field>
+ <field type="int" size="1" name="underline">
+ <const name="none" value="0"/>
+ <const name="single" value="1"/>
+ <const name="double" value="2"/>
+ <const name="single accounting" value="3"/>
+ <const name="double accounting" value="4"/>
+ </field>
+ <field type="int" size="1" name="font family"/>
+ <field type="int" size="1" name="character set"/>
+ <field type="int" size="1" name="reserved"/>
+ <field type="string" size="var" name="font name"/>
+ </fields>
+</record>
--- /dev/null
+<record id="0x1032" name="Frame" package="org.apache.poi.hssf.record">
+ <description>The frame record indicates whether there is a border around the displayed text of a chart.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="border type">
+ <const name="regular" value="0" description="regular rectangle or no border"/>
+ <const name="shadow" value="1" description="rectangle with shadow"/>
+ </field>
+ <field type="int" size="2" name="options">
+ <bit number="0" name="auto size" description="excel calculates the size automatically if true"/>
+ <bit number="1" name="auto position" description="excel calculates the position automatically"/>
+ </field>
+ </fields>
+</record>
--- /dev/null
+<record id="0x1015" name="Legend" package="org.apache.poi.hssf.record">
+ <description>The legend record specifies the location of legend on a chart and it's overall size.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="4" name="x position"/>
+ <field type="int" size="4" name="y position"/>
+ <field type="int" size="4" name="x size"/>
+ <field type="int" size="4" name="y size"/>
+ <field type="int" size="1" name="type">
+ <const name="bottom" value="0"/>
+ <const name="corner" value="1"/>?
+ <const name="top" value="2"/>
+ <const name="right" value="3"/>
+ <const name="left" value="4"/>
+ <const name="not docked" value="7"/>
+ </field>
+ <field type="int" size="1" name="spacing">
+ <const name="close" value="0"/>
+ <const name="medium" value="1"/>
+ <const name="open" value="2"/>
+ </field>
+ <field type="int" size="2" name="options">
+ <bit number="0" name="auto position" description="set to true if legend is docked"/>
+ <bit number="1" name="auto series" description="automatic series distribution"/>
+ <bit number="2" name="auto pos x" description="x positioning is done automatically"/>
+ <bit number="3" name="auto pos y" description="y positioning is done automatically"/>
+ <bit number="4" name="vert" description="if true legend is vertical (otherwise it's horizonal)"/>
+ <bit number="5" name="contains data table" description="true if the chart contains the data table"/>
+ </field>
+ </fields>
+</record>
--- /dev/null
+<record id="0x1003" name="Series" package="org.apache.poi.hssf.record">
+ <description>The series record describes the overall data for a series.</description>
+ <author>Glen Stampoultzis (gstamp at iprimus dot com dot au)</author>
+ <fields>
+ <field type="int" size="2" name="category data type">
+ <const name="dates" value="0"/>
+ <const name="numeric" value="1"/>
+ <const name="sequence" value="2"/>
+ <const name="text" value="3"/>
+ </field>
+ <field type="int" size="2" name="values data type">
+ <const name="dates" value="0"/>
+ <const name="numeric" value="1"/>
+ <const name="sequence" value="2"/>
+ <const name="text" value="3"/>
+ </field>
+ <field type="int" size="2" name="num categories"/>
+ <field type="int" size="2" name="num values"/>
+ <field type="int" size="2" name="bubble series type">
+ <const name="dates" value="0"/>
+ <const name="numeric" value="1"/>
+ <const name="sequence" value="2"/>
+ <const name="text" value="3"/>
+ </field>
+ <field type="int" size="2" name="num bubble values"/>
+ </fields>
+</record>
--- /dev/null
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:recutil="org.apache.poi.generator.RecordUtil"
+ xmlns:field="org.apache.poi.generator.FieldIterator"
+ xmlns:java="java" >
+
+<xsl:template match="record">
+/* ====================================================================
+ * 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/>.
+ */
+
+<xsl:if test="@package">
+package <xsl:value-of select="@package"/>;
+</xsl:if>
+
+
+import org.apache.poi.util.BitField;
+import org.apache.poi.util.LittleEndian;
+import org.apache.poi.util.StringUtil;
+import org.apache.poi.util.HexDump;
+
+/**
+ * <xsl:value-of select="/record/description"/>
+ * NOTE: This source is automatically generated please do not modify this file. Either subclass or
+ * remove the record in src/records/definitions.
+<xsl:apply-templates select="author"/>
+ */
+public class <xsl:value-of select="@name"/>Record
+ extends Record
+{
+ public final static short sid = <xsl:value-of select="@id"/>;
+<xsl:for-each select="//fields/field"> private <xsl:value-of select="recutil:getType(@size,@type,10)"/><xsl:text> </xsl:text><xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>;
+<xsl:apply-templates select="./bit|./const"/>
+</xsl:for-each>
+
+ public <xsl:value-of select="@name"/>Record()
+ {
+<xsl:for-each select="//fields/field"><xsl:if test="@default">
+<xsl:text> </xsl:text>
+<xsl:value-of select="recutil:getFieldName(position(),@name,0)"/> = <xsl:value-of select="@default"/>;
+</xsl:if></xsl:for-each>
+ }
+
+ /**
+ * Constructs a <xsl:value-of select="@name"/> record and sets its fields appropriately.
+ *
+ * @param id id must be <xsl:value-of select="@id"/> 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 <xsl:value-of select="@name"/>Record(short id, short size, byte [] data)
+ {
+ super(id, size, data);
+ }
+
+ /**
+ * Constructs a <xsl:value-of select="@name"/> record and sets its fields appropriately.
+ *
+ * @param id id must be <xsl:value-of select="@id"/> 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 <xsl:value-of select="@name"/>Record(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 <xsl:value-of select="@name"/> record");
+ }
+ }
+
+ protected void fillFields(byte [] data, short size, int offset)
+ {
+<xsl:variable name="fieldIterator" select="field:new()"/>
+<xsl:for-each select="//fields/field">
+<xsl:text> </xsl:text><xsl:value-of select="recutil:getFieldName(position(),@name,30)"/> = <xsl:value-of select="field:fillDecoder($fieldIterator,@size,@type)"/>;
+</xsl:for-each>
+ }
+
+ public String toString()
+ {
+ StringBuffer buffer = new StringBuffer();
+
+ buffer.append("[<xsl:value-of select="@name"/>]\n");
+<xsl:apply-templates select="//field" mode="tostring"/>
+ buffer.append("[/<xsl:value-of select="@name"/>]\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));
+<xsl:variable name="fieldIterator" select="field:new()"/>
+<xsl:for-each select="//fields/field"><xsl:text>
+ </xsl:text><xsl:value-of select="field:serialiseEncoder($fieldIterator,position(),@name,@size,@type)"/>
+</xsl:for-each>
+
+ return getRecordSize();
+ }
+
+ /**
+ * Size of record (exluding 4 byte header)
+ */
+ public int getRecordSize()
+ {
+<xsl:variable name="fieldIterator" select="field:new()"/>
+<xsl:text> return 4 + </xsl:text>
+<xsl:for-each select="//fields/field">
+ <xsl:value-of select="field:calcSize($fieldIterator,position(),@name,@size,@type)"/>
+</xsl:for-each>;
+ }
+
+ public short getSid()
+ {
+ return this.sid;
+ }
+
+<xsl:apply-templates select="//field" mode="getset"/>
+<xsl:apply-templates select="//field" mode="bits"/>
+
+} // END OF CLASS
+
+
+
+
+</xsl:template>
+
+<xsl:template match = "field" mode="bits">
+<xsl:variable name="fieldNum" select="position()"/>
+<xsl:for-each select="bit">
+ /**
+ * Sets the <xsl:value-of select="@name"/> field value.
+ * <xsl:value-of select="@description"/>
+ */
+ public void set<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>(boolean value)
+ {
+ <xsl:value-of select="recutil:getFieldName($fieldNum,../@name,0)"/> = <xsl:value-of select="recutil:getFieldName(@name,0)"/>.set<xsl:value-of select="recutil:getType1stCap(../@size,../@type,0)"/>Boolean(<xsl:value-of select="recutil:getFieldName($fieldNum,../@name,0)"/>, value);
+ }
+
+ /**
+ * <xsl:value-of select="@description"/>
+ * @return the <xsl:value-of select="@name"/> field value.
+ */
+ public boolean is<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>()
+ {
+ return <xsl:value-of select="recutil:getFieldName(@name,0)"/>.isSet(<xsl:value-of select="recutil:getFieldName($fieldNum,../@name,0)"/>);
+ }
+</xsl:for-each>
+</xsl:template>
+
+<xsl:template match = "bit" > private BitField <xsl:value-of select="recutil:getFieldName(@name,42)"/> = new BitField(<xsl:value-of select="recutil:getMask(@number)"/>);
+</xsl:template>
+<xsl:template match = "const"> public final static <xsl:value-of select="recutil:getType(../@size,../@type,10)"/><xsl:text> </xsl:text><xsl:value-of select="recutil:getConstName(../@name,@name,30)"/> = <xsl:value-of select="@value"/>;
+</xsl:template>
+
+<xsl:template match = "const" mode="listconsts">
+<xsl:text>
+ * </xsl:text>
+<xsl:value-of select="recutil:getConstName(../@name,@name,0)"/></xsl:template>
+<xsl:template match="field" mode="getset">
+ /**
+ * Get the <xsl:value-of select="@name"/> field for the <xsl:value-of select="../../@name"/> record.<xsl:if test="./const">
+ *
+ * @return One of <xsl:apply-templates select="./const" mode="listconsts"/></xsl:if>
+ */
+ public <xsl:value-of select="recutil:getType(@size,@type,0)"/> get<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>()
+ {
+ return <xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>;
+ }
+
+ /**
+ * Set the <xsl:value-of select="@name"/> field for the <xsl:value-of select="../../@name"/> record.<xsl:if test="./const">
+ *
+ * @param <xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>
+ * One of <xsl:apply-templates select="./const" mode="listconsts"/></xsl:if>
+ */
+ public void set<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>(<xsl:value-of select="recutil:getType(@size,@type,0)"/><xsl:text> </xsl:text><xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>)
+ {
+ this.<xsl:value-of select="recutil:getFieldName(position(),@name,0)"/> = <xsl:value-of select="recutil:getFieldName(position(),@name,0)"/>;
+ }
+</xsl:template>
+
+<xsl:template match="field" mode="tostring">
+ buffer.append(" .<xsl:value-of select="recutil:getFieldName(@name,20)"/> = ")<xsl:if test="@type != 'string'">
+ .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");
+<xsl:apply-templates select="bit" mode="bittostring"/>
+</xsl:template>
+
+<xsl:template match="bit" mode="bittostring"> buffer.append(" .<xsl:value-of select="recutil:getFieldName(@name,20)"/> = ").append(is<xsl:value-of select="recutil:getFieldName1stCap(@name,20)"/>()).append('\n');
+</xsl:template>
+
+<xsl:template match="author">
+ * @author <xsl:value-of select="."/>
+</xsl:template>
+
+</xsl:stylesheet>
--- /dev/null
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:recutil="org.apache.poi.generator.RecordUtil"
+ xmlns:field="org.apache.poi.generator.FieldIterator"
+ xmlns:java="java" >
+
+<xsl:template match="record">
+<document>
+ <header>
+ <title><xsl:value-of select="@name"/> Record Documentation</title>
+ </header>
+
+ <body>
+ <s1 title="Record Description">
+ <p><xsl:value-of select="/record/description"/>
+ </p>
+ </s1>
+ <s1 title="Fields">
+ <table>
+ <tr>
+ <th colspan="1" rowspan="1">Name</th>
+ <th colspan="1" rowspan="1">Size</th>
+ <th colspan="1" rowspan="1">Offset</th>
+ <th colspan="1" rowspan="1">Description</th>
+ <th colspan="1" rowspan="1">Default Value</th>
+ </tr>
+ <xsl:apply-templates select="//field"/>
+ </table>
+ </s1>
+ </body>
+ <footer>
+ <legal>
+ Copyright (c) @year@ The Poi Project All rights reserved.
+ $Revision$ $Date$
+ </legal>
+ </footer>
+
+</document>
+</xsl:template>
+
+<xsl:template match="field">
+ <tr>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="@size"/></td>
+ <td> </td>
+ <td><xsl:value-of select="@description"/></td>
+ <td><xsl:value-of select="@default"/></td>
+ </tr>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:recutil="org.apache.poi.generator.RecordUtil"
+ xmlns:field="org.apache.poi.generator.FieldIterator"
+ xmlns:java="java" >
+
+<xsl:template match="record">
+/* ====================================================================
+ * 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/>.
+ */
+
+<xsl:if test="@package">
+package <xsl:value-of select="@package"/>;
+</xsl:if>
+
+import junit.framework.TestCase;
+
+/**
+ * Tests the serialization and deserialization of the <xsl:value-of select="@name"/>Record
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+<xsl:apply-templates select="author"/>
+ */
+public class Test<xsl:value-of select="@name"/>Record
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ // PASTE DATA HERE
+ };
+
+ public Test<xsl:value-of select="@name"/>Record(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ <xsl:value-of select="@name"/>Record record = new <xsl:value-of select="@name"/>Record((short)<xsl:value-of select="@id"/>, (short)data.length, data);
+<xsl:for-each select="//fields/field"> assertEquals( XXX, record.get<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>());
+<xsl:apply-templates select="./bit" mode="get"/>
+</xsl:for-each>
+
+ assertEquals( XXX, record.getRecordSize() );
+
+ record.validateSid((short)<xsl:value-of select="@id"/>);
+ }
+
+ public void testStore()
+ {
+ <xsl:value-of select="@name"/>Record record = new <xsl:value-of select="@name"/>Record();
+<xsl:for-each select="//fields/field"> record.set<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>( XXXX );
+<xsl:apply-templates select="./bit" mode="set"/>
+</xsl:for-each>
+
+ 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]);
+ }
+}
+</xsl:template>
+
+<xsl:template match="author">
+ * @author <xsl:value-of select="."/>
+</xsl:template>
+
+<xsl:template match="bit" mode="get">
+<xsl:text> </xsl:text>assertEquals( XXX, record.is<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>() );<xsl:text>
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="bit" mode="set">
+<xsl:text> </xsl:text>record.set<xsl:value-of select="recutil:getFieldName1stCap(@name,0)"/>( XXX );<xsl:text>
+</xsl:text>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+/* ====================================================================
+ * 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.generator;
+
+/**
+ * For iterating through our fields. Todo: Change this to javascript in the style sheet.
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class FieldIterator
+{
+ int offset;
+
+ public FieldIterator()
+ {
+ }
+
+ public void init(org.apache.xalan.extensions.XSLProcessorContext context,
+ org.apache.xalan.templates.ElemExtensionCall extElem)
+ {
+ offset = 0;
+ }
+
+ public String fillDecoder(String size, String type)
+ {
+ String javaType = RecordUtil.getType(size, type, 0);
+
+ String result = "";
+ if (javaType.equals("short"))
+ result = "LittleEndian.getShort(data, " + offset + " + offset)";
+ else if (javaType.equals("int"))
+ result = "LittleEndian.getInt(data, " + offset + " + offset)";
+ else if (javaType.equals("byte"))
+ result = "data[ " + offset + " + offset ]";
+ else if (javaType.equals("ExcelString"))
+ result = "ExcelStringUtil.decodeExcelString(data, " + offset + " + offset)";
+
+ try
+ {
+ offset += Integer.parseInt(size);
+ }
+ catch (NumberFormatException ignore)
+ {
+ }
+ return result;
+ }
+
+ //position(),@name,@size,@type
+ public String serialiseEncoder( int fieldNumber, String fieldName, String size, String type)
+ {
+ String javaType = RecordUtil.getType(size, type, 0);
+ String javaFieldName = RecordUtil.getFieldName(fieldNumber,fieldName,0);
+
+ String result = "";
+ if (javaType.equals("short"))
+ result = "LittleEndian.putShort(data, " + (offset+4) + " + offset, " + javaFieldName + ");";
+ else if (javaType.equals("int"))
+ result = "LittleEndian.putInt(data, " + (offset+4) + " + offset, " + javaFieldName + ");";
+ else if (javaType.equals("byte"))
+ result = "data[ " + (offset+4) + " + offset ] = " + javaFieldName + ";";
+ else if (javaType.equals("ExcelString"))
+ result = "StringUtil.putUncompressedUnicode(getFontName(), data, 20 + offset);";
+
+ try
+ {
+ offset += Integer.parseInt(size);
+ }
+ catch (NumberFormatException ignore)
+ {
+ }
+ return result;
+
+ }
+
+ public String calcSize( int fieldNumber, String fieldName, String size, String type)
+ {
+ String result = fieldNumber == 1 ? "" : " + ";
+ if ("var".equals(size))
+ {
+ String javaFieldName = RecordUtil.getFieldName(fieldNumber,fieldName,0);
+ return result + javaFieldName + ".sizeInBytes()";
+ }
+ else
+ {
+ return result + size;
+ }
+ }
+
+}
+
+
+
--- /dev/null
+/* ====================================================================
+ * 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.generator;
+
+
+/**
+ * Helper functions for the record transformations. TODO: Change this to
+ * javascript in the style sheet.
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class RecordUtil
+{
+ public static String getFieldName(int position, String name, int padTo)
+ {
+ StringBuffer fieldName = new StringBuffer("field_" + position + "_");
+ toIdentifier(name, fieldName);
+ pad(fieldName, padTo);
+
+ return fieldName.toString();
+ }
+
+ private static StringBuffer pad(StringBuffer fieldName, int padTo)
+ {
+ for (int i = fieldName.length(); i < padTo; i++)
+ fieldName.append(' ');
+ return fieldName;
+ }
+
+ public static String getFieldName(String name, int padTo)
+ {
+ StringBuffer fieldName = new StringBuffer();
+ toIdentifier(name, fieldName);
+ pad(fieldName, padTo);
+
+ return fieldName.toString();
+ }
+
+ public static String getFieldName1stCap(String name, int padTo)
+ {
+ StringBuffer fieldName = new StringBuffer();
+ toIdentifier(name, fieldName);
+ fieldName.setCharAt(0, Character.toUpperCase(fieldName.charAt(0)));
+ pad(fieldName, padTo);
+
+ return fieldName.toString();
+ }
+
+ private static void toIdentifier(String name, StringBuffer fieldName)
+ {
+ for (int i = 0; i < name.length(); i++)
+ {
+ if (name.charAt(i) == ' ')
+ fieldName.append(Character.toUpperCase(name.charAt(++i)));
+ else
+ fieldName.append(name.charAt(i));
+ }
+ }
+
+ private static void toConstIdentifier(String name, StringBuffer fieldName)
+ {
+ for (int i = 0; i < name.length(); i++)
+ {
+ if (name.charAt(i) == ' ')
+ fieldName.append('_');
+ else
+ fieldName.append(Character.toUpperCase(name.charAt(i)));
+ }
+ }
+
+ public static String getType(String size, String type, int padTo)
+ {
+ boolean numeric = type.equals("bits") || type.equals("int");
+ if (numeric && "1".equals(size))
+ return pad(new StringBuffer("byte"), padTo).toString();
+ else if (numeric && "2".equals(size))
+ return pad(new StringBuffer("short"), padTo).toString();
+ else if (numeric && "4".equals(size))
+ return pad(new StringBuffer("int"), padTo).toString();
+ else if (type.equals("string"))
+ return pad(new StringBuffer("ExcelString"), padTo).toString();
+
+ return "";
+ }
+
+ public static String getType1stCap(String size, String type, int padTo)
+ {
+ StringBuffer result;
+ boolean numeric = type.equals("bits") || type.equals("int");
+ if (numeric && "1".equals(size))
+ result = pad(new StringBuffer("byte"), padTo);
+ else if (numeric && "2".equals(size))
+ result = pad(new StringBuffer("short"), padTo);
+ else if (type.equals("string"))
+ result = pad(new StringBuffer("ExcelString"), padTo);
+ else
+ return "";
+
+ result.setCharAt(0, Character.toUpperCase(result.charAt(0)));
+
+ return result.toString();
+ }
+
+ public static String getMask(int bit)
+ {
+ int mask = (int)Math.pow(2, bit);
+
+ return "0x" + Integer.toHexString(mask);
+ }
+
+ public static String getConstName(String parentName, String constName, int padTo)
+ {
+ StringBuffer fieldName = new StringBuffer();
+ toConstIdentifier(parentName, fieldName);
+ fieldName.append('_');
+ toConstIdentifier(constName, fieldName);
+ pad(fieldName, padTo);
+ return fieldName.toString();
+ }
+
+}
--- /dev/null
+
+/* ====================================================================
+ * 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 AreaRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestAreaRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x02,(byte)0x00 // format flags
+ };
+
+ public TestAreaRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ AreaRecord record = new AreaRecord((short)0x101A, (short)data.length, data);
+ assertEquals( 2, record.getFormatFlags());
+ assertEquals( false, record.isStacked() );
+ assertEquals( true, record.isDisplayAsPercentage() );
+ assertEquals( false, record.isShadow() );
+
+
+ assertEquals( 6, record.getRecordSize() );
+
+ record.validateSid((short)0x101A);
+ }
+
+ public void testStore()
+ {
+ AreaRecord record = new AreaRecord();
+ record.setStacked( false );
+ record.setDisplayAsPercentage( true );
+ record.setShadow( false );
+
+
+ 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]);
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * 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 BarRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestBarRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x00,(byte)0x00, // bar space
+ (byte)0x96,(byte)0x00, // category space
+ (byte)0x00,(byte)0x00 // format flags
+ };
+
+ public TestBarRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ BarRecord record = new BarRecord((short)0x1017, (short)data.length, data);
+ assertEquals( 0, record.getBarSpace());
+ assertEquals( 0x96, record.getCategorySpace());
+ assertEquals( 0, record.getFormatFlags());
+ assertEquals( false, record.isHorizontal() );
+ assertEquals( false, record.isStacked() );
+ assertEquals( false, record.isDisplayAsPercentage() );
+ assertEquals( false, record.isShadow() );
+
+
+ assertEquals( 10, record.getRecordSize() );
+
+ record.validateSid((short)0x1017);
+ }
+
+ public void testStore()
+ {
+ BarRecord record = new BarRecord();
+ record.setBarSpace( (short)0 );
+ record.setCategorySpace( (short)0x96 );
+ record.setHorizontal( false );
+ record.setStacked( false );
+ record.setDisplayAsPercentage( false );
+ record.setShadow( false );
+
+
+ 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]);
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * 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 DatRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestDatRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x0D,(byte)0x00 // options
+ };
+
+ public TestDatRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ DatRecord record = new DatRecord((short)0x1063, (short)data.length, data);
+ assertEquals( 0xD, record.getOptions());
+ assertEquals( true, record.isHorizontalBorder() );
+ assertEquals( false, record.isVerticalBorder() );
+ assertEquals( true, record.isBorder() );
+ assertEquals( true, record.isShowSeriesKey() );
+
+
+ assertEquals( 6, record.getRecordSize() );
+
+ record.validateSid((short)0x1063);
+ }
+
+ public void testStore()
+ {
+ DatRecord record = new DatRecord();
+ record.setHorizontalBorder( true );
+ record.setVerticalBorder( false );
+ record.setBorder( true );
+ record.setShowSeriesKey( 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]);
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * 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 DataFormatRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestDataFormatRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0xFF,(byte)0xFF, // point number
+ (byte)0x00,(byte)0x00, // series index
+ (byte)0x00,(byte)0x00, // series number
+ (byte)0x00,(byte)0x00 // format flags
+ };
+
+ public TestDataFormatRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ DataFormatRecord record = new DataFormatRecord((short)0x1006, (short)data.length, data);
+ assertEquals( (short)0xFFFF, record.getPointNumber());
+ assertEquals( 0, record.getSeriesIndex());
+ assertEquals( 0, record.getSeriesNumber());
+ assertEquals( 0, record.getFormatFlags());
+ assertEquals( false, record.isUseExcel4Colors() );
+
+
+ assertEquals( 12, record.getRecordSize() );
+
+ record.validateSid((short)0x1006);
+ }
+
+ public void testStore()
+ {
+ DataFormatRecord record = new DataFormatRecord();
+ record.setPointNumber( (short)0xFFFF );
+ record.setSeriesIndex( (short)0 );
+ record.setSeriesNumber( (short)0 );
+ record.setFormatFlags( (short)0 );
+ record.setUseExcel4Colors( false );
+
+
+ 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]);
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * 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 FrameRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestFrameRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x00,(byte)0x00, // border type
+ (byte)0x02,(byte)0x00 // options
+ };
+
+ public TestFrameRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ FrameRecord record = new FrameRecord((short)0x1032, (short)data.length, data);
+ assertEquals( FrameRecord.BORDER_TYPE_REGULAR, record.getBorderType());
+ assertEquals( 2, record.getOptions());
+ assertEquals( false, record.isAutoSize() );
+ assertEquals( true, record.isAutoPosition() );
+
+
+ assertEquals( 8, record.getRecordSize() );
+
+ record.validateSid((short)0x1032);
+ }
+
+ public void testStore()
+ {
+ FrameRecord record = new FrameRecord();
+ record.setBorderType( FrameRecord.BORDER_TYPE_REGULAR );
+ record.setOptions( (short)2 );
+ record.setAutoSize( false );
+ record.setAutoPosition( 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]);
+ }
+}
--- /dev/null
+/* ====================================================================
+ * 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 LegendRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestLegendRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0xB2,(byte)0x0D,(byte)0x00,(byte)0x00, //field_1_xPosition
+ (byte)0x39,(byte)0x06,(byte)0x00,(byte)0x00, //field_2_yPosition
+ (byte)0xD9,(byte)0x01,(byte)0x00,(byte)0x00, //field_3_xSize
+ (byte)0x34,(byte)0x02,(byte)0x00,(byte)0x00, //field_4_ySize
+ (byte)0x03, //field_5_type
+ (byte)0x01, //field_6_spacing
+ (byte)0x1F,(byte)0x00 //field_7_options
+ };
+
+ public TestLegendRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ LegendRecord legendRecord = new LegendRecord((short)0x1015, (short)data.length, data);
+ assertEquals(3506, legendRecord.getXPosition());
+ assertEquals(1593, legendRecord.getYPosition());
+ assertEquals(473, legendRecord.getXSize());
+ assertEquals(564, legendRecord.getYSize());
+ assertEquals(LegendRecord.TYPE_RIGHT, legendRecord.getType());
+ assertEquals(LegendRecord.SPACING_MEDIUM, legendRecord.getSpacing());
+ assertEquals(31, legendRecord.getOptions());
+ assertEquals(true, legendRecord.isAutoPosition());
+ assertEquals(true, legendRecord.isAutoSeries());
+ assertEquals(true, legendRecord.isAutoPosX());
+ assertEquals(true, legendRecord.isAutoPosY());
+ assertEquals(true, legendRecord.isVert());
+ assertEquals(false, legendRecord.isContainsDataTable());
+
+ assertEquals(24, legendRecord.getRecordSize());
+
+ legendRecord.validateSid((short)0x1015);
+ }
+
+ public void testStore()
+ {
+ LegendRecord legendRecord = new LegendRecord();
+ legendRecord.setXPosition(3506);
+ legendRecord.setYPosition(1593);
+ legendRecord.setXSize(473);
+ legendRecord.setYSize(564);
+ legendRecord.setType(LegendRecord.TYPE_RIGHT);
+ legendRecord.setSpacing(LegendRecord.SPACING_MEDIUM);
+ legendRecord.setAutoPosition(true);
+ legendRecord.setAutoSeries(true);
+ legendRecord.setAutoPosX(true);
+ legendRecord.setAutoPosY(true);
+ legendRecord.setVert(true);
+ legendRecord.setContainsDataTable(false);
+
+ byte [] recordBytes = legendRecord.serialize();
+ assertEquals(recordBytes.length - 4, data.length);
+ for (int i = 0; i < data.length; i++)
+ assertEquals("At offset " + i, data[i], recordBytes[i+4]);
+ }
+}
--- /dev/null
+
+/* ====================================================================
+ * 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 SeriesRecord
+ * class works correctly. Test data taken directly from a real
+ * Excel file.
+ *
+ * @author Glen Stampoultzis (gstamp at iprimus dot com dot au)
+ */
+public class TestSeriesRecord
+ extends TestCase
+{
+ byte[] data = new byte[] {
+ (byte)0x01,(byte)0x00, // category data type
+ (byte)0x01,(byte)0x00, // values data type
+ (byte)0x1B,(byte)0x00, // num categories
+ (byte)0x1B,(byte)0x00, // num values
+ (byte)0x01,(byte)0x00, // bubble series type
+ (byte)0x00,(byte)0x00 // num bubble values
+ };
+
+ public TestSeriesRecord(String name)
+ {
+ super(name);
+ }
+
+ public void testLoad()
+ throws Exception
+ {
+
+ SeriesRecord record = new SeriesRecord((short)0x1003, (short)data.length, data);
+ assertEquals( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC, record.getCategoryDataType());
+ assertEquals( SeriesRecord.VALUES_DATA_TYPE_NUMERIC, record.getValuesDataType());
+ assertEquals( 27, record.getNumCategories());
+ assertEquals( 27, record.getNumValues());
+ assertEquals( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC, record.getBubbleSeriesType());
+ assertEquals( 0, record.getNumBubbleValues());
+
+
+ assertEquals( 16, record.getRecordSize() );
+
+ record.validateSid((short)0x1003);
+ }
+
+ public void testStore()
+ {
+ SeriesRecord record = new SeriesRecord();
+ record.setCategoryDataType( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC );
+ record.setValuesDataType( SeriesRecord.VALUES_DATA_TYPE_NUMERIC );
+ record.setNumCategories( (short)27 );
+ record.setNumValues( (short)27 );
+ record.setBubbleSeriesType( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC );
+ record.setNumBubbleValues( (short)0 );
+
+ 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]);
+ }
+}
}
}
+ public void testToHex()
+ throws Exception
+ {
+ assertEquals( "000A", HexDump.toHex((short)0xA));
+ assertEquals( "0A", HexDump.toHex((byte)0xA));
+ assertEquals( "0000000A", HexDump.toHex((int)0xA));
+
+ assertEquals( "FFFF", HexDump.toHex((short)0xFFFF));
+
+ }
+
private char toAscii(final int c)
{
char rval = '.';