Patch from dnapoletano from bug #45175 - Support for variable length operands in org.apache.poi.hwpf.sprm.SprmOperation

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@672567 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Burch 2008-06-28 18:48:35 +00:00
parent 70f9a0a528
commit 1f27ceb98f
4 changed files with 10 additions and 4 deletions

View File

@ -37,6 +37,7 @@
<!-- Don't forget to update status.xml too! -->
<release version="3.1.1-alpha1" date="2008-??-??">
<action dev="POI-DEVELOPERS" type="add">45175 - Support for variable length operands in org.apache.poi.hwpf.sprm.SprmOperation</action>
<action dev="POI-DEVELOPERS" type="fix">Avoid spurious missing lines with the MissingRecordAware event code, and odd files that contain RowRecords in the middle of the cell Records.</action>
<action dev="POI-DEVELOPERS" type="add">Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder</action>
</release>

View File

@ -34,6 +34,7 @@
<!-- Don't forget to update changes.xml too! -->
<changes>
<release version="3.1.1-alpha1" date="2008-??-??">
<action dev="POI-DEVELOPERS" type="add">45175 - Support for variable length operands in org.apache.poi.hwpf.sprm.SprmOperation</action>
<action dev="POI-DEVELOPERS" type="fix">Avoid spurious missing lines with the MissingRecordAware event code, and odd files that contain RowRecords in the middle of the cell Records.</action>
<action dev="POI-DEVELOPERS" type="add">Support for parsing formulas during EventUserModel processing, via the new EventWorkbookBuilder</action>
</release>

View File

@ -101,7 +101,14 @@ public class SprmOperation
case 3:
return LittleEndian.getInt(_grpprl, _gOffset);
case 6:
throw new UnsupportedOperationException("This SPRM contains a variable length operand");
byte operandLength = _grpprl[_gOffset + 1]; //surely shorter than an int...
byte [] codeBytes = new byte[LittleEndian.INT_SIZE]; //initialized to zeros by JVM
for(int i = 0; i < operandLength; i++)
if(_gOffset + i < _grpprl.length)
codeBytes[i] = _grpprl[_gOffset + 1 + i];
return LittleEndian.getInt(codeBytes, 0);
case 7:
byte threeByteInt[] = new byte[4];
threeByteInt[0] = _grpprl[_gOffset];

View File

@ -353,9 +353,6 @@ public final class TestMissingRecordAwareHSSFListener extends TestCase {
public void testNoExtraNewLines() throws Exception {
// Load a different file
openAlt();
for(int i=0; i<r.length; i++) {
System.err.println(r[i]);
}
// This file has has something in lines 1-33