poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From n...@apache.org
Subject svn commit: r832625 - in /poi/trunk/src: documentation/content/xdocs/status.xml scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
Date Wed, 04 Nov 2009 00:07:38 GMT
Author: nick
Date: Wed Nov  4 00:07:37 2009
New Revision: 832625

URL: http://svn.apache.org/viewvc?rev=832625&view=rev
Log:
Patch from Trejkaz - fix bug #48038 - handle reading HWPF stylesheets from non zero offsets

Modified:
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
    poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=832625&r1=832624&r2=832625&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Wed Nov  4 00:07:37 2009
@@ -34,6 +34,7 @@
 
     <changes>
         <release version="3.6-beta1" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">48038 - handle reading HWPF stylesheets
from non zero offsets</action>
            <action dev="POI-DEVELOPERS" type="add">When running the "compile-ooxml-xsds"
ant task, also generate the source jar for the OOXML Schemas</action>
            <action dev="POI-DEVELOPERS" type="fix">45672 - improve handling by MissingRecordAwareHSSFListener
of records that cover multiple cells (MulBlankRecord and MulRKRecord)</action>
            <action dev="POI-DEVELOPERS" type="fix">48096 - relaxed validation check
in RecalcIdRecord</action>

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java?rev=832625&r1=832624&r2=832625&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/StyleSheet.java Wed Nov  4 00:07:37
2009
@@ -65,6 +65,7 @@
    */
   public StyleSheet(byte[] tableStream, int offset)
   {
+      int startOffset = offset;
       _stshiLength = LittleEndian.getShort(tableStream, offset);
       offset += LittleEndian.SHORT_SIZE;
       int stdCount = LittleEndian.getShort(tableStream, offset);
@@ -88,7 +89,7 @@
       _rgftc[2] = LittleEndian.getShort(tableStream, offset);
       offset += LittleEndian.SHORT_SIZE;
 
-      offset = (LittleEndian.SHORT_SIZE + _stshiLength);
+      offset = startOffset + LittleEndian.SHORT_SIZE + _stshiLength;
       _styleDescriptions = new StyleDescription[stdCount];
       for(int x = 0; x < stdCount; x++)
       {

Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java?rev=832625&r1=832624&r2=832625&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hwpf/model/TestStyleSheet.java Wed Nov
 4 00:07:37 2009
@@ -46,6 +46,21 @@
 
   }
 
+  public void testReadWriteFromNonZeroOffset()
+    throws Exception
+  {
+    HWPFFileSystem fileSys = new HWPFFileSystem();
+    HWPFOutputStream tableOut = fileSys.getStream("1Table");
+
+    tableOut.write(new byte[20]); // 20 bytes of whatever at the front.
+    _styleSheet.writeTo(tableOut);
+
+    byte[] newTableStream = tableOut.toByteArray();
+
+    StyleSheet newStyleSheet = new StyleSheet(newTableStream, 20);
+    assertEquals(newStyleSheet, _styleSheet);
+  }
+
   protected void setUp()
     throws Exception
   {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message