]> source.dussan.org Git - poi.git/commitdiff
Patch from dnapoletano from bug #45175 - Support for variable length operands in...
authorNick Burch <nick@apache.org>
Sat, 28 Jun 2008 18:48:35 +0000 (18:48 +0000)
committerNick Burch <nick@apache.org>
Sat, 28 Jun 2008 18:48:35 +0000 (18:48 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@672567 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/scratchpad/src/org/apache/poi/hwpf/sprm/SprmOperation.java
src/testcases/org/apache/poi/hssf/eventusermodel/TestMissingRecordAwareHSSFListener.java

index d8e6c421d7f4943cf47bad5ddc44957ac14d4510..825c99cc5b9d3535ca8234c1376c8f5c43a4d89d 100644 (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>
index 93a290c0b08626eb8988107778a9d363c4aeadf5..cafa18cc542d0812f782a90ca9eb3244f2534b40 100644 (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>
index cacbbaaa38e60dea15c3d744421ec06e3aa8ad6c..764fc06c4dcf5cee54c5f925af8649cf63d5885c 100644 (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];
index bbad7b7f48b3a94d97dd8cc3873afc8b8caaa9c6..37e594940cd8ff56f42415b714cbbf073b4250b0 100644 (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