From 54d27d0cc616958254c8e5531a9dd9b64506491b Mon Sep 17 00:00:00 2001 From: Josh Micich Date: Wed, 2 Dec 2009 21:29:44 +0000 Subject: Bugzilla 48332 - fixed ColumnInfoRecord to tolerate missing reserved field git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@886311 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/hssf/record/TestColumnInfoRecord.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/testcases') diff --git a/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java b/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java index 8f11d90604..fd0e41217e 100644 --- a/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java +++ b/src/testcases/org/apache/poi/hssf/record/TestColumnInfoRecord.java @@ -48,6 +48,30 @@ public final class TestColumnInfoRecord extends TestCase { assertTrue(Arrays.equals(data, cir.serialize())); } + /** + * Some applications skip the last reserved field when writing {@link ColumnInfoRecord}s + * The attached file was apparently created by "SoftArtisans OfficeWriter for Excel". + * Excel reads that file OK and assumes zero for the value of the reserved field. + */ + public void testZeroResevedBytes_bug48332() { + // Taken from bugzilla attachment 24661 (offset 0x1E73) + byte[] inpData = HexRead.readFromString("7D 00 0A 00 00 00 00 00 D5 19 0F 00 02 00"); + byte[] outData = HexRead.readFromString("7D 00 0C 00 00 00 00 00 D5 19 0F 00 02 00 00 00"); + + RecordInputStream in = TestcaseRecordInputStream.create(inpData); + ColumnInfoRecord cir; + try { + cir = new ColumnInfoRecord(in); + } catch (RuntimeException e) { + if (e.getMessage().equals("Unusual record size remaining=(0)")) { + throw new AssertionFailedError("Identified bug 48332"); + } + throw e; + } + assertEquals(0, in.remaining()); + assertTrue(Arrays.equals(outData, cir.serialize())); + } + /** * Some sample files have just one reserved byte (field 6): * OddStyleRecord.xls, NoGutsRecords.xls, WORKBOOK_in_capitals.xls -- cgit v1.2.3