From 302a48a25b5bffb93233438936cb87943383a9c9 Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Wed, 25 Jul 2012 15:45:09 +0000 Subject: [PATCH] Bugzilla 53205 - Fix some parsing errors and encoding issues in HDGF git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1365638 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../src/org/apache/poi/hdgf/chunks/Chunk.java | 126 +++++++++--------- .../apache/poi/hdgf/chunks/ChunkHeader.java | 3 + .../poi/hdgf/chunks/ChunkHeaderV11.java | 7 + .../poi/hdgf/chunks/ChunkHeaderV4V5.java | 7 + .../apache/poi/hdgf/chunks/ChunkHeaderV6.java | 7 + .../apache/poi/hdgf/streams/ChunkStream.java | 26 ++-- .../org/apache/poi/hdgf/TestHDGFCore.java | 25 ++++ 8 files changed, 132 insertions(+), 70 deletions(-) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 4e5d4384dc..0602dfd241 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 53205 - Fix some parsing errors and encoding issues in HDGF 53204 - Improved performanceof PageSettingsBlock in HSSF 53500 - Getter for repeating rows and columns 53369 - Fixed tests failing on JDK 1.7 diff --git a/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java b/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java index fc880d5db3..b2a42536c3 100644 --- a/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java +++ b/src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java @@ -161,70 +161,76 @@ public final class Chunk { continue; } - // Process - switch(type) { - // Types 0->7 = a flat at bit 0->7 - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: - int val = contents[offset] & (1< 0); - break; - case 8: - command.value = Byte.valueOf(contents[offset]); - break; - case 9: - command.value = new Double( - LittleEndian.getDouble(contents, offset) - ); - break; - case 12: - // A Little Endian String - // Starts 8 bytes into the data segment - // Ends at end of data, or 00 00 - - // Ensure we have enough data - if(contents.length < 8) { - command.value = ""; + try { + // Process + switch(type) { + // Types 0->7 = a flat at bit 0->7 + case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: + int val = contents[offset] & (1< 0); break; - } - - // Find the end point - int startsAt = 8; - int endsAt = startsAt; - for(int j=startsAt; j