Patch from Patrick Cheng (bugzilla 46189) - added chart records: CHARTFRTINFO, STARTBLOCK, ENDBLOCK, STARTOBJECT, ENDOBJECT, and CATLAB

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@713892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Josh Micich 2008-11-14 01:10:26 +00:00
parent 41ad7b2410
commit a4b5d9ff2e
11 changed files with 585 additions and 5 deletions

View File

@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.5-beta4" date="2008-??-??">
<action dev="POI-DEVELOPERS" type="add">46189 - added chart records: CHARTFRTINFO, STARTBLOCK, ENDBLOCK, STARTOBJECT, ENDOBJECT, and CATLAB</action>
<action dev="POI-DEVELOPERS" type="fix">46199 - More tweaks to EmbeddedObjectRefSubRecord</header>
<action dev="POI-DEVELOPERS" type="add">Changes to formula evaluation allowing for reduced memory usage</action>
<action dev="POI-DEVELOPERS" type="fix">45290 - Support odd files where the POIFS header block comes after the data blocks, and is on the data blocks list</header>

View File

@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.5-beta4" date="2008-??-??">
<action dev="POI-DEVELOPERS" type="add">46189 - added chart records: CHARTFRTINFO, STARTBLOCK, ENDBLOCK, STARTOBJECT, ENDOBJECT, and CATLAB</action>
<action dev="POI-DEVELOPERS" type="fix">46199 - More tweaks to EmbeddedObjectRefSubRecord</header>
<action dev="POI-DEVELOPERS" type="add">Changes to formula evaluation allowing for reduced memory usage</action>
<action dev="POI-DEVELOPERS" type="fix">45290 - Support odd files where the POIFS header block comes after the data blocks, and is on the data blocks list</header>

View File

@ -30,6 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.poi.hssf.record.chart.*;
/**
* Title: Record Factory<P>
* Description: Takes a stream and outputs an array of Record objects.<P>
@ -158,6 +160,19 @@ public final class RecordFactory {
WriteAccessRecord.class,
WriteProtectRecord.class,
WSBoolRecord.class,
LinkedDataRecord.class,
ChartFRTInfoRecord.class,
ChartStartBlockRecord.class,
ChartEndBlockRecord.class,
ChartStartObjectRecord.class,
ChartEndObjectRecord.class,
CatLabRecord.class,
BeginRecord.class,
EndRecord.class,
SeriesToChartGroupRecord.class,
};
/**

View File

@ -0,0 +1,52 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record;
import org.apache.poi.util.LittleEndianByteArrayOutputStream;
import org.apache.poi.util.LittleEndianOutput;
/**
* Subclasses of this class (the majority of BIFF records) are non-continuable. This allows for
* some simplification of serialization logic
*
* @author Josh Micich
*/
public abstract class StandardRecord extends Record {
@Override
public final int serialize(int offset, byte[] data) {
int dataSize = getDataSize();
int recSize = 4 + dataSize;
LittleEndianByteArrayOutputStream out = new LittleEndianByteArrayOutputStream(data, offset, recSize);
out.writeShort(getSid());
out.writeShort(dataSize);
serialize(out);
if (out.getWriteIndex() - offset != recSize) {
throw new IllegalStateException("Incorrect number of bytes written - expected "
+ recSize + " but got " + (out.getWriteIndex() - offset));
}
return recSize;
}
/**
* Write the data content of this BIFF record. The 'ushort sid' and 'ushort size' header fields
* have already been written by the superclass.<br/>
*
* The subclass must write the exact number of bytes as reported by {@link Record#getDataSize()}
*/
protected abstract void serialize(LittleEndianOutput out);
}

View File

@ -153,11 +153,8 @@ public final class UnknownRecord extends Record {
case 0x0803: return "DBQUERYEXT";
case 0x0805: return "TXTQUERY";
case 0x0812: return "CONTINUEFRT";
case QUICKTIP_0800: return "QUICKTIP";
case 0x0850: return "CHARTFRTINFO";
case 0x0852: return "STARTBLOCK";
case 0x0853: return "ENDBLOCK";
case 0x0856: return "CATLAB";
case SHEETEXT_0862: return "SHEETEXT";
case 0x0863: return "BOOKEXT";
case SHEETPROTECTION_0867: return "SHEETPROTECTION";
@ -169,6 +166,7 @@ public final class UnknownRecord extends Record {
case 0x087B: return "CFEX";
case 0x087C: return "XFCRC";
case 0x087D: return "XFEXT";
case 0x087F: return "CONTINUEFRT12";
case 0x088B: return "PLV";
case 0x088C: return "COMPAT12";
case 0x088D: return "DXF";
@ -179,6 +177,7 @@ public final class UnknownRecord extends Record {
case 0x089A: return "MTRSETTINGS";
case 0x089B: return "COMPRESSPICTURES";
case 0x089C: return "HEADERFOOTER";
case 0x08A1: return "SHAPEPROPSSTREAM";
case 0x08A3: return "FORCEFULLCALCULATION";
case 0x08A4: return "SHAPEPROPSSTREAM";
case 0x08A5: return "TEXTPROPSSTREAM";
@ -186,7 +185,6 @@ public final class UnknownRecord extends Record {
case 0x08C8: return "PLV{Mac Excel}";
case 0x1051: return "SHAPEPROPSSTREAM";
}
if (isObservedButUnknown(sid)) {

View File

@ -0,0 +1,85 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.chart;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
/**
* CATLAB - Category Labels (0x0856)<br/>
*
* @author Patrick Cheng
*/
public final class CatLabRecord extends StandardRecord {
public static final short sid = 0x0856;
private short rt;
private short grbitFrt;
private short wOffset;
private short at;
private short grbit;
private short unused;
public CatLabRecord(RecordInputStream in) {
rt = in.readShort();
grbitFrt = in.readShort();
wOffset = in.readShort();
at = in.readShort();
grbit = in.readShort();
unused = in.readShort();
}
@Override
protected int getDataSize() {
return 2 + 2 + 2 + 2 + 2 + 2;
}
@Override
public short getSid() {
return sid;
}
@Override
public void serialize(LittleEndianOutput out) {
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeShort(wOffset);
out.writeShort(at);
out.writeShort(grbit);
out.writeShort(unused);
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[CATLAB]\n");
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
buffer.append(" .grbitFrt=").append(HexDump.shortToHex(grbitFrt)).append('\n');
buffer.append(" .wOffset =").append(HexDump.shortToHex(wOffset)).append('\n');
buffer.append(" .at =").append(HexDump.shortToHex(at)).append('\n');
buffer.append(" .grbit =").append(HexDump.shortToHex(grbit)).append('\n');
buffer.append(" .unused =").append(HexDump.shortToHex(unused)).append('\n');
buffer.append("[/CATLAB]\n");
return buffer.toString();
}
}

View File

@ -0,0 +1,78 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.chart;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
/**
* ENDBLOCK - Chart Future Record Type End Block (0x0853)<br/>
*
* @author Patrick Cheng
*/
public final class ChartEndBlockRecord extends StandardRecord {
public static final short sid = 0x0853;
private short rt;
private short grbitFrt;
private short iObjectKind;
private byte[] unused;
public ChartEndBlockRecord(RecordInputStream in) {
rt = in.readShort();
grbitFrt = in.readShort();
iObjectKind = in.readShort();
unused = new byte[6];
in.readFully(unused);
}
@Override
protected int getDataSize() {
return 2 + 2 + 2 + 6;
}
@Override
public short getSid() {
return sid;
}
@Override
public void serialize(LittleEndianOutput out) {
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeShort(iObjectKind);
// 6 bytes unused
out.write(unused);
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[ENDBLOCK]\n");
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
buffer.append(" .iObjectKind=").append(HexDump.shortToHex(iObjectKind)).append('\n');
buffer.append(" .unused =").append(HexDump.toHex(unused)).append('\n');
buffer.append("[/ENDBLOCK]\n");
return buffer.toString();
}
}

View File

@ -0,0 +1,78 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.chart;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
/**
* ENDOBJECT - Chart Future Record Type End Object (0x0855)<br/>
*
* @author Patrick Cheng
*/
public final class ChartEndObjectRecord extends StandardRecord {
public static final short sid = 0x0855;
private short rt;
private short grbitFrt;
private short iObjectKind;
private byte[] unused;
public ChartEndObjectRecord(RecordInputStream in) {
rt = in.readShort();
grbitFrt = in.readShort();
iObjectKind = in.readShort();
unused = new byte[6];
in.readFully(unused);
}
@Override
protected int getDataSize() {
return 2 + 2 + 2 + 6;
}
@Override
public short getSid() {
return sid;
}
@Override
public void serialize(LittleEndianOutput out) {
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeShort(iObjectKind);
// 6 bytes unused
out.write(unused);
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[ENDOBJECT]\n");
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
buffer.append(" .iObjectKind=").append(HexDump.shortToHex(iObjectKind)).append('\n');
buffer.append(" .unused =").append(HexDump.toHex(unused)).append('\n');
buffer.append("[/ENDOBJECT]\n");
return buffer.toString();
}
}

View File

@ -0,0 +1,106 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.chart;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
/**
* CHARTFRTINFO - Chart Future Record Type Info (0x0850)<br/>
*
* @author Patrick Cheng
*/
public final class ChartFRTInfoRecord extends StandardRecord {
public static final short sid = 0x850;
private short rt;
private short grbitFrt;
private byte verOriginator;
private byte verWriter;
private CFRTID[] rgCFRTID;
private static final class CFRTID {
public static final int ENCODED_SIZE = 4;
private int rtFirst;
private int rtLast;
public CFRTID(RecordInputStream in) {
rtFirst = in.readShort();
rtLast = in.readShort();
}
public void serialize(LittleEndianOutput out) {
out.writeShort(rtFirst);
out.writeShort(rtLast);
}
}
public ChartFRTInfoRecord(RecordInputStream in) {
rt = in.readShort();
grbitFrt = in.readShort();
verOriginator = in.readByte();
verWriter = in.readByte();
int cCFRTID = in.readShort();
rgCFRTID = new CFRTID[cCFRTID];
for (int i = 0; i < cCFRTID; i++) {
rgCFRTID[i] = new CFRTID(in);
}
}
@Override
protected int getDataSize() {
return 2 + 2 + 1 + 1 + 2 + rgCFRTID.length * CFRTID.ENCODED_SIZE;
}
@Override
public short getSid() {
return sid;
}
@Override
public void serialize(LittleEndianOutput out) {
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeByte(verOriginator);
out.writeByte(verWriter);
int nCFRTIDs = rgCFRTID.length;
out.writeShort(nCFRTIDs);
for (int i = 0; i < nCFRTIDs; i++) {
rgCFRTID[i].serialize(out);
}
}
@Override
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[CHARTFRTINFO]\n");
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
buffer.append(" .verOriginator=").append(HexDump.byteToHex(verOriginator)).append('\n');
buffer.append(" .verWriter =").append(HexDump.byteToHex(verOriginator)).append('\n');
buffer.append(" .nCFRTIDs =").append(HexDump.shortToHex(rgCFRTID.length)).append('\n');
buffer.append("[/CHARTFRTINFO]\n");
return buffer.toString();
}
}

View File

@ -0,0 +1,83 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.chart;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
/**
* STARTBLOCK - Chart Future Record Type Start Block (0x0852)<br/>
*
* @author Patrick Cheng
*/
public final class ChartStartBlockRecord extends StandardRecord {
public static final short sid = 0x0852;
private short rt;
private short grbitFrt;
private short iObjectKind;
private short iObjectContext;
private short iObjectInstance1;
private short iObjectInstance2;
public ChartStartBlockRecord(RecordInputStream in) {
rt = in.readShort();
grbitFrt = in.readShort();
iObjectKind = in.readShort();
iObjectContext = in.readShort();
iObjectInstance1 = in.readShort();
iObjectInstance2 = in.readShort();
}
@Override
protected int getDataSize() {
return 2 + 2 + 2 + 2 + 2 + 2;
}
@Override
public short getSid() {
return sid;
}
@Override
public void serialize(LittleEndianOutput out) {
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeShort(iObjectKind);
out.writeShort(iObjectContext);
out.writeShort(iObjectInstance1);
out.writeShort(iObjectInstance2);
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[STARTBLOCK]\n");
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
buffer.append(" .iObjectKind =").append(HexDump.shortToHex(iObjectKind)).append('\n');
buffer.append(" .iObjectContext =").append(HexDump.shortToHex(iObjectContext)).append('\n');
buffer.append(" .iObjectInstance1=").append(HexDump.shortToHex(iObjectInstance1)).append('\n');
buffer.append(" .iObjectInstance2=").append(HexDump.shortToHex(iObjectInstance2)).append('\n');
buffer.append("[/STARTBLOCK]\n");
return buffer.toString();
}
}

View File

@ -0,0 +1,83 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.record.chart;
import org.apache.poi.hssf.record.RecordInputStream;
import org.apache.poi.hssf.record.StandardRecord;
import org.apache.poi.util.HexDump;
import org.apache.poi.util.LittleEndianOutput;
/**
* STARTOBJECT - Chart Future Record Type Start Object (0x0854)<br/>
*
* @author Patrick Cheng
*/
public final class ChartStartObjectRecord extends StandardRecord {
public static final short sid = 0x0854;
private short rt;
private short grbitFrt;
private short iObjectKind;
private short iObjectContext;
private short iObjectInstance1;
private short iObjectInstance2;
public ChartStartObjectRecord(RecordInputStream in) {
rt = in.readShort();
grbitFrt = in.readShort();
iObjectKind = in.readShort();
iObjectContext = in.readShort();
iObjectInstance1 = in.readShort();
iObjectInstance2 = in.readShort();
}
@Override
protected int getDataSize() {
return 2 + 2 + 2 + 2 + 2 + 2;
}
@Override
public short getSid() {
return sid;
}
@Override
public void serialize(LittleEndianOutput out) {
out.writeShort(rt);
out.writeShort(grbitFrt);
out.writeShort(iObjectKind);
out.writeShort(iObjectContext);
out.writeShort(iObjectInstance1);
out.writeShort(iObjectInstance2);
}
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[STARTOBJECT]\n");
buffer.append(" .rt =").append(HexDump.shortToHex(rt)).append('\n');
buffer.append(" .grbitFrt =").append(HexDump.shortToHex(grbitFrt)).append('\n');
buffer.append(" .iObjectKind =").append(HexDump.shortToHex(iObjectKind)).append('\n');
buffer.append(" .iObjectContext =").append(HexDump.shortToHex(iObjectContext)).append('\n');
buffer.append(" .iObjectInstance1=").append(HexDump.shortToHex(iObjectInstance1)).append('\n');
buffer.append(" .iObjectInstance2=").append(HexDump.shortToHex(iObjectInstance2)).append('\n');
buffer.append("[/STARTOBJECT]\n");
return buffer.toString();
}
}