poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r726969 - in /poi/trunk/src: documentation/content/xdocs/ java/org/apache/poi/hssf/record/ testcases/org/apache/poi/hssf/record/
Date Tue, 16 Dec 2008 05:44:33 GMT
Author: josh
Date: Mon Dec 15 21:44:32 2008
New Revision: 726969

URL: http://svn.apache.org/viewvc?rev=726969&view=rev
Log:
Fix for bug 46385 (by patch 46362 from Matsuyama Tomohiro) fixed serialization of StyleRecord
with unicode name

Modified:
    poi/trunk/src/documentation/content/xdocs/changes.xml
    poi/trunk/src/documentation/content/xdocs/status.xml
    poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java
    poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java
    poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java

Modified: poi/trunk/src/documentation/content/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/changes.xml?rev=726969&r1=726968&r2=726969&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/changes.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/changes.xml Mon Dec 15 21:44:32 2008
@@ -37,6 +37,7 @@
 
 		<!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta5" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46385 - (also patch 46362) fix serialization
of StyleRecord with unicode name</action>
            <action dev="POI-DEVELOPERS" type="fix">46368 - Fix HSSFRichTextRun and
strings longer than 32768 characters</action>
            <action dev="POI-DEVELOPERS" type="add">Support sheet-level names</action>
            <action dev="POI-DEVELOPERS" type="fix">Fixed XSSFCell to properly handle
cell references with column numbers up to XFD</action>

Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=726969&r1=726968&r2=726969&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Mon Dec 15 21:44:32 2008
@@ -34,6 +34,7 @@
 	<!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta5" date="2008-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46385 - (also patch 46362) fix serialization
of StyleRecord with unicode name</action>
            <action dev="POI-DEVELOPERS" type="fix">46368 - Fix HSSFRichTextRun and
strings longer than 32768 characters</action>
            <action dev="POI-DEVELOPERS" type="add">Support sheet-level names</action>
            <action dev="POI-DEVELOPERS" type="fix">Fixed XSSFCell to properly handle
cell references with column numbers up to XFD</action>

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java?rev=726969&r1=726968&r2=726969&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/StandardRecord.java Mon Dec 15 21:44:32
2008
@@ -40,7 +40,8 @@
 		out.writeShort(dataSize);
 		serialize(out);
 		if (out.getWriteIndex() - offset != recSize) {
-			throw new IllegalStateException("Incorrect number of bytes written - expected " 
+			throw new IllegalStateException("Error in serialization of (" + getClass().getName() +
"): "
+					+ "Incorrect number of bytes written - expected " 
 					+ recSize + " but got " + (out.getWriteIndex() - offset));
 		}
 		return recSize;

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java?rev=726969&r1=726968&r2=726969&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/StyleRecord.java Mon Dec 15 21:44:32 2008
@@ -173,7 +173,11 @@
 		} else {
 			out.writeShort(field_4_name.length());
 			out.writeByte(field_3_stringHasMultibyte ? 0x01 : 0x00);
-			StringUtil.putCompressedUnicode(getName(), out);
+			if (field_3_stringHasMultibyte) {
+				StringUtil.putUnicodeLE(getName(), out);
+			} else {
+				StringUtil.putCompressedUnicode(getName(), out);
+			}
 		}
 	}
 

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java?rev=726969&r1=726968&r2=726969&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestStyleRecord.java Mon Dec 15 21:44:32
2008
@@ -17,17 +17,30 @@
 
 package org.apache.poi.hssf.record;
 
+import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
+
+import org.apache.poi.util.HexRead;
+
 /**
- * 
+ * Tests for {@link StyleRecord}
  */
 public final class TestStyleRecord extends TestCase {
-    public void testUnicodeReadName() {
-    	byte[] data = {
-   			17, 0, 9, 0, 1, 56, 94, -60, -119, 95, 0, 83, 0, 104, 0, 101, 0, 101, 0, 116, 0, 49,
0, 92, 40, //92, 36    			
-    	};
-    	RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
-    	StyleRecord sr = new StyleRecord(in);
-    	assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
-    }
+	public void testUnicodeReadName() {
+		byte[] data = HexRead.readFromString(
+				"11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
+		RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
+		StyleRecord sr = new StyleRecord(in);
+		assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
+		byte[] ser;
+		try {
+			ser = sr.serialize();
+		} catch (IllegalStateException e) {
+			if (e.getMessage().equals("Incorrect number of bytes written - expected 27 but got 18"))
{
+				throw new AssertionFailedError("Identified bug 46385");
+			}
+			throw e;
+		}
+		TestcaseRecordInputStream.confirmRecordEncoding(StyleRecord.sid, data, ser);
+	}
 }



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


Mime
View raw message